forked from enlightenment/efl
From: Daniel Juyung Seo <juyung.seo@samsung.com>
Subject: [E-devel] [Patch] elm_actionslider feature patch for elementary. This patch is for elementary elm_actionslider. Mr. Sumanth created this patch. I reviewed it and fixed some. This patch includes below features. - Indicator label Set/Get APIs. - _del_hook fix for wd->drag_button_base. - Added magnet disable feature. _drag_button_up_cb fix for no magnet handling. If magnet position is set to ELM_ACTIONSLIDER_NONE, it disables magnetic. Added a test case to elementary_test. SVN revision: 55872
This commit is contained in:
parent
5edd6acce3
commit
bbc823a1eb
|
@ -15980,6 +15980,28 @@ collections {
|
|||
color: 255 255 255 190;
|
||||
}
|
||||
}
|
||||
part { name: "elm.text.indicator";
|
||||
type: TEXT;
|
||||
scale: 1;
|
||||
mouse_events: 0;
|
||||
description { state: "default" 0.0;
|
||||
rel1 {
|
||||
to: "elm.drag_button";
|
||||
offset: 5 0;
|
||||
}
|
||||
rel2 {
|
||||
to: "elm.drag_button";
|
||||
offset: -5 0;
|
||||
}
|
||||
color: 0 0 0 255;
|
||||
text {
|
||||
font: "Sans,Edje-Vera";
|
||||
size: 10;
|
||||
align: 0.5 0.5;
|
||||
min: 0 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
programs {
|
||||
program { name: "elm.drag_button,mouse,up";
|
||||
|
@ -16181,6 +16203,28 @@ collections {
|
|||
color: 255 255 255 190;
|
||||
}
|
||||
}
|
||||
part { name: "elm.text.indicator";
|
||||
type: TEXT;
|
||||
scale: 1;
|
||||
mouse_events: 0;
|
||||
description { state: "default" 0.0;
|
||||
rel1 {
|
||||
to: "elm.drag_button";
|
||||
offset: 5 0;
|
||||
}
|
||||
rel2 {
|
||||
to: "elm.drag_button";
|
||||
offset: -5 0;
|
||||
}
|
||||
color: 0 0 0 255;
|
||||
text {
|
||||
font: "Sans,Edje-Vera";
|
||||
size: 10;
|
||||
align: 0.5 0.5;
|
||||
min: 0 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
programs {
|
||||
program { name: "elm.drag_button,mouse,up";
|
||||
|
|
|
@ -19,6 +19,15 @@ _position_change_magnetic_cb(void *data __UNUSED__, Evas_Object * obj, void *eve
|
|||
elm_actionslider_magnet_pos_set(obj, ELM_ACTIONSLIDER_RIGHT);
|
||||
}
|
||||
|
||||
static void
|
||||
_magnet_enable_disable_cb(void *data __UNUSED__, Evas_Object *obj, void *event_info)
|
||||
{
|
||||
if (!strcmp((char *)event_info, "left"))
|
||||
elm_actionslider_magnet_pos_set(obj, ELM_ACTIONSLIDER_CENTER);
|
||||
else if (!strcmp((char *)event_info, "right"))
|
||||
elm_actionslider_magnet_pos_set(obj, ELM_ACTIONSLIDER_NONE);
|
||||
}
|
||||
|
||||
void
|
||||
test_actionslider(void *data __UNUSED__, Evas_Object * obj __UNUSED__, void *event_info __UNUSED__)
|
||||
{
|
||||
|
@ -85,6 +94,7 @@ test_actionslider(void *data __UNUSED__, Evas_Object * obj __UNUSED__, void *eve
|
|||
elm_actionslider_indicator_pos_set(ms, ELM_ACTIONSLIDER_LEFT);
|
||||
elm_actionslider_magnet_pos_set(ms, ELM_ACTIONSLIDER_LEFT);
|
||||
elm_actionslider_labels_set(ms, NULL, "Accept", "Reject");
|
||||
elm_actionslider_indicator_label_set(ms, "Go");
|
||||
evas_object_smart_callback_add(ms, "pos_changed",
|
||||
_position_change_magnetic_cb, NULL);
|
||||
evas_object_smart_callback_add(ms, "selected", _pos_selected_cb, NULL);
|
||||
|
@ -98,6 +108,19 @@ test_actionslider(void *data __UNUSED__, Evas_Object * obj __UNUSED__, void *eve
|
|||
elm_actionslider_indicator_pos_set(ms, ELM_ACTIONSLIDER_LEFT);
|
||||
elm_actionslider_magnet_pos_set(ms, ELM_ACTIONSLIDER_ALL);
|
||||
elm_actionslider_labels_set(ms, "Left", "Center", "Right");
|
||||
elm_actionslider_indicator_label_set(ms, "Go");
|
||||
evas_object_smart_callback_add(ms, "selected", _pos_selected_cb, NULL);
|
||||
evas_object_show(ms);
|
||||
elm_box_pack_end(bx, ms);
|
||||
|
||||
ms = elm_actionslider_add(win);
|
||||
evas_object_size_hint_weight_set(ms, EVAS_HINT_EXPAND, 0);
|
||||
evas_object_size_hint_align_set(ms, EVAS_HINT_FILL, 0);
|
||||
elm_actionslider_indicator_pos_set(ms, ELM_ACTIONSLIDER_CENTER);
|
||||
elm_actionslider_magnet_pos_set(ms, ELM_ACTIONSLIDER_CENTER);
|
||||
elm_actionslider_labels_set(ms, "Enable", "Magnet", "Disable");
|
||||
evas_object_smart_callback_add(ms, "pos_changed",
|
||||
_magnet_enable_disable_cb, NULL);
|
||||
evas_object_smart_callback_add(ms, "selected", _pos_selected_cb, NULL);
|
||||
evas_object_show(ms);
|
||||
elm_box_pack_end(bx, ms);
|
||||
|
|
|
@ -1671,6 +1671,8 @@ extern "C" {
|
|||
EAPI Elm_Actionslider_Pos elm_actionslider_magnet_pos_get(const Evas_Object *obj) EINA_ARG_NONNULL(1);
|
||||
EAPI void elm_actionslider_enabled_pos_set(Evas_Object *obj, Elm_Actionslider_Pos pos) EINA_ARG_NONNULL(1);
|
||||
EAPI Elm_Actionslider_Pos elm_actionslider_enabled_pos_get(const Evas_Object *obj) EINA_ARG_NONNULL(1);
|
||||
EAPI void elm_actionslider_indicator_label_set(Evas_Object *obj, const char *label) EINA_ARG_NONNULL(1);
|
||||
EAPI const char *elm_actionslider_indicator_label_get(Evas_Object *obj) EINA_ARG_NONNULL(1);
|
||||
/* smart callbacks called:
|
||||
* "selected" - when user selects a position (the label is passed as
|
||||
* event info)".
|
||||
|
|
|
@ -24,6 +24,7 @@ struct _Widget_Data
|
|||
Evas_Object *drag_button_base;
|
||||
Elm_Actionslider_Pos magnet_position, enabled_position;
|
||||
const char *text_left, *text_right, *text_center;
|
||||
const char *indicator_label;
|
||||
Ecore_Animator *button_animator;
|
||||
double final_position;
|
||||
Eina_Bool mouse_down : 1;
|
||||
|
@ -47,9 +48,15 @@ _del_hook(Evas_Object *obj)
|
|||
{
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
if (!wd) return;
|
||||
if (wd->drag_button_base)
|
||||
{
|
||||
evas_object_del(wd->drag_button_base);
|
||||
wd->drag_button_base = NULL;
|
||||
}
|
||||
if (wd->text_left) eina_stringshare_del(wd->text_left);
|
||||
if (wd->text_right) eina_stringshare_del(wd->text_right);
|
||||
if (wd->text_center) eina_stringshare_del(wd->text_center);
|
||||
if (wd->indicator_label) eina_stringshare_del(wd->indicator_label);
|
||||
free(wd);
|
||||
}
|
||||
|
||||
|
@ -88,6 +95,7 @@ _theme_hook(Evas_Object *obj)
|
|||
edje_object_part_text_set(wd->as, "elm.text.left", wd->text_left);
|
||||
edje_object_part_text_set(wd->as, "elm.text.right", wd->text_right);
|
||||
edje_object_part_text_set(wd->as, "elm.text.center", wd->text_center);
|
||||
edje_object_part_text_set(wd->as, "elm.text.indicator", wd->indicator_label);
|
||||
edje_object_message_signal_process(wd->as);
|
||||
_sizing_eval(obj);
|
||||
}
|
||||
|
@ -205,11 +213,7 @@ _drag_button_up_cb(void *data, Evas_Object *o __UNUSED__, const char *emission _
|
|||
return;
|
||||
}
|
||||
|
||||
if (!wd->magnet_position)
|
||||
{
|
||||
wd->final_position = 0;
|
||||
goto as_anim;
|
||||
}
|
||||
if (wd->magnet_position == ELM_ACTIONSLIDER_NONE) return;
|
||||
|
||||
if (position < 0.3)
|
||||
{
|
||||
|
@ -505,3 +509,39 @@ elm_actionslider_selected_label_get(const Evas_Object *obj)
|
|||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the label used on the indicator object.
|
||||
*
|
||||
* @param obj The actionslider object
|
||||
* @param label The label which is going to be set.
|
||||
*
|
||||
* @ingroup Actionslider
|
||||
*/
|
||||
EAPI void
|
||||
elm_actionslider_indicator_label_set(Evas_Object *obj, const char *label)
|
||||
{
|
||||
ELM_CHECK_WIDTYPE(obj, widtype);
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
if (!wd) return;
|
||||
|
||||
eina_stringshare_replace(&wd->indicator_label, label);
|
||||
edje_object_part_text_set(wd->as, "elm.text.indicator", wd->indicator_label);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the label used on the indicator object.
|
||||
*
|
||||
* @param obj The actionslider object
|
||||
* @return The indicator label
|
||||
*
|
||||
* @ingroup Actionslider
|
||||
*/
|
||||
EAPI const char *
|
||||
elm_actionslider_indicator_label_get(Evas_Object *obj)
|
||||
{
|
||||
ELM_CHECK_WIDTYPE(obj, widtype) NULL;
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
if (!wd) return;
|
||||
return wd->indicator_label;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue