From 77d4d162bc631f043dd2c6c91b7b3267c0df7488 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ot=C3=83=C2=A1vio=20Pontes?= Date: Tue, 7 Dec 2010 15:55:14 +0000 Subject: [PATCH] Using finger size to calc actionslider size. SVN revision: 55354 --- data/themes/default.edc | 143 ++++++++++++++++++++++++++++++++++++--------- src/lib/elm_actionslider.c | 67 ++++++++++++--------- 2 files changed, 154 insertions(+), 56 deletions(-) diff --git a/data/themes/default.edc b/data/themes/default.edc index 94c953b..8a510b6 100644 --- a/data/themes/default.edc +++ b/data/themes/default.edc @@ -15105,6 +15105,9 @@ collections { images { image: "shelf_inset.png" COMP; image: "ilist_1.png" COMP; + image: "bt_bases.png" COMP; + image: "bt_basew.png" COMP; + image: "bt_hilightw.png" COMP; } parts { @@ -15113,8 +15116,7 @@ collections { mouse_events: 0; description { state: "default" 0.0; - max: 99999 30; - min: 150 30; + min: 75 25; rel1.offset: 1 1; rel2.offset: -2 -2; image { @@ -15188,13 +15190,13 @@ collections { } } } - part { name: "elm.swallow.icon"; + part { name: "elm.drag_button_base"; type: SWALLOW; - mouse_events: 1; + mouse_events: 0; scale: 1; description { state: "default" 0.0; - min: 64 30; fixed: 1 1; + min: 50 25; align: 0.5 0.5; rel1.to: "icon.dragable.area"; rel2 { @@ -15204,28 +15206,23 @@ collections { } dragable { confine: "icon.dragable.area"; - x: 1 1 1530; + x: 1 1 0; y: 0 0 0; } } - } - } - - group { name: "elm/actionslider/icon/default"; - alias: "elm/actionslider/icon/bar"; - - images { - image: "bt_bases.png" COMP; - image: "bt_basew.png" COMP; - image: "bt_hilightw.png" COMP; - } - - parts { - part { name: "button"; + part { name: "elm.drag_button"; type: RECT; mouse_events: 1; description { state: "default" 0.0; + min: 50 25; color: 255 255 255 0; + rel1.to_x: "elm.drag_button_base"; + rel1.to_y: "icon.dragable.area"; + rel2.to_x: "elm.drag_button_base"; + rel2.to_y: "icon.dragable.area"; + } + dragable { + events: "elm.drag_button_base"; } } part { name: "button0"; @@ -15246,8 +15243,8 @@ collections { part { name: "button2"; mouse_events: 0; description { state: "default" 0.0; - rel1.to: "button"; - rel2.to: "button"; + rel1.to: "elm.drag_button"; + rel2.to: "elm.drag_button"; image { normal: "bt_basew.png"; border: 7 7 7 7; @@ -15270,6 +15267,23 @@ collections { } } } + programs { + program { name: "elm.drag_button,mouse,up"; + signal: "mouse,up,1"; + source: "elm.drag_button"; + action: SIGNAL_EMIT "elm.drag_button,mouse,up" ""; + } + program { name: "elm.drag_button,mouse,down"; + signal: "mouse,down,1"; + source: "elm.drag_button"; + action: SIGNAL_EMIT "elm.drag_button,mouse,down" ""; + } + program { name: "elm.drag_button,mouse,move"; + signal: "mouse,move"; + source: "elm.drag_button_base"; + action: SIGNAL_EMIT "elm.drag_button,mouse,move" ""; + } + } } group { name: "elm/actionslider/base/bar"; @@ -15277,6 +15291,9 @@ collections { images { image: "shelf_inset.png" COMP; image: "ilist_1.png" COMP; + image: "bt_bases.png" COMP; + image: "bt_basew.png" COMP; + image: "bt_hilightw.png" COMP; } parts { @@ -15285,7 +15302,6 @@ collections { mouse_events: 0; description { state: "default" 0.0; - max: 99999 30; min: 150 30; rel1.offset: 1 1; rel2.offset: -2 -2; @@ -15369,19 +15385,19 @@ collections { rel2 { relative: 0 1; offset: 3 -3; - to_x: "elm.swallow.icon"; + to_x: "elm.drag_button_base"; to_y: "base"; } color: 0 0 0 180; } } - part { name: "elm.swallow.icon"; + part { name: "elm.drag_button_base"; type: SWALLOW; mouse_events: 1; scale: 1; description { state: "default" 0.0; - min: 64 30; fixed: 1 1; + min: 50 25; align: 0.5 0.5; rel1.to: "icon.dragable.area"; rel2 { @@ -15391,10 +15407,83 @@ collections { } dragable { confine: "icon.dragable.area"; - x: 1 1 1530; + x: 1 1 0; y: 0 0 0; } } + part { name: "elm.drag_button"; + type: RECT; + mouse_events: 1; + description { state: "default" 0.0; + min: 50 25; + color: 255 255 255 0; + rel1.to_x: "elm.drag_button_base"; + rel1.to_y: "icon.dragable.area"; + rel2.to_x: "elm.drag_button_base"; + rel2.to_y: "icon.dragable.area"; + } + dragable { + events: "elm.drag_button_base"; + } + } + part { name: "button0"; + mouse_events: 0; + description { state: "default" 0.0; + rel1.to: "button2"; + rel1.offset: -4 -4; + rel2.to: "button2"; + rel2.offset: 3 3; + image { + normal: "bt_bases.png"; + border: 11 11 11 11; + middle: SOLID; + } + color: 255 255 255 128; + } + } + part { name: "button2"; + mouse_events: 0; + description { state: "default" 0.0; + rel1.to: "elm.drag_button"; + rel2.to: "elm.drag_button"; + image { + normal: "bt_basew.png"; + border: 7 7 7 7; + middle: SOLID; + } + color: 255 255 255 210; + } + } + part { name: "button3"; + mouse_events: 0; + description { state: "default" 0.0; + rel1.to: "button2"; + rel2.to: "button2"; + rel2.relative: 1.0 0.5; + image { + normal: "bt_hilightw.png"; + border: 4 4 4 0; + } + color: 255 255 255 190; + } + } + } + programs { + program { name: "elm.drag_button,mouse,up"; + signal: "mouse,up,1"; + source: "elm.drag_button"; + action: SIGNAL_EMIT "elm.drag_button,mouse,up" ""; + } + program { name: "elm.drag_button,mouse,down"; + signal: "mouse,down,1"; + source: "elm.drag_button"; + action: SIGNAL_EMIT "elm.drag_button,mouse,down" ""; + } + program { name: "elm.drag_button,mouse,move"; + signal: "mouse,move"; + source: "elm.drag_button_base"; + action: SIGNAL_EMIT "elm.drag_button,mouse,move" ""; + } } } diff --git a/src/lib/elm_actionslider.c b/src/lib/elm_actionslider.c index d59c424..2655656 100644 --- a/src/lib/elm_actionslider.c +++ b/src/lib/elm_actionslider.c @@ -21,10 +21,10 @@ typedef struct _Widget_Data Widget_Data; struct _Widget_Data { Evas_Object *ms; // actionslider - Evas_Object *icon; // an icon for a button or a bar + Evas_Object *drag_button_base; Elm_Actionslider_Pos magnet_position, enabled_position; const char *text_left, *text_right, *text_center; - Ecore_Animator *icon_animator; + Ecore_Animator *button_animator; double final_position; Eina_Bool mouse_down : 1; }; @@ -58,8 +58,15 @@ _sizing_eval(Evas_Object *obj) { Widget_Data *wd = elm_widget_data_get(obj); Evas_Coord minw = -1, minh = -1; + if (!wd) return; - elm_coords_finger_size_adjust(4, &minw, 1, &minh); + elm_coords_finger_size_adjust(1, &minw, 1, &minh); + evas_object_size_hint_min_set(wd->drag_button_base, minw, minh); + evas_object_size_hint_max_set(wd->drag_button_base, -1, -1); + + minw = -1; + minh = -1; + elm_coords_finger_size_adjust(3, &minw, 1, &minh); edje_object_size_min_restricted_calc(wd->ms, &minw, &minh, minw, minh); evas_object_size_hint_min_set(obj, minw, minh); evas_object_size_hint_max_set(obj, -1, -1); @@ -70,14 +77,14 @@ _theme_hook(Evas_Object *obj) { Widget_Data *wd = elm_widget_data_get(obj); if (!wd) return; - if (!edje_object_part_swallow_get(wd->ms, "elm.swallow.icon")) - edje_object_part_unswallow(wd->ms, wd->icon); + if (!edje_object_part_swallow_get(wd->ms, "elm.drag_button_base")) + edje_object_part_unswallow(wd->ms, wd->drag_button_base); _elm_theme_object_set(obj, wd->ms, "actionslider", "base", elm_widget_style_get(obj)); - _elm_theme_object_set(obj, wd->icon, "actionslider", - "icon", elm_widget_style_get(obj)); - edje_object_part_swallow(wd->ms, "elm.swallow.icon", wd->icon); + _elm_theme_object_set(obj, wd->drag_button_base, "actionslider", + "drag_button", elm_widget_style_get(obj)); + edje_object_part_swallow(wd->ms, "elm.drag_button_base", wd->drag_button_base); edje_object_part_text_set(wd->ms, "elm.text.left", wd->text_left); edje_object_part_text_set(wd->ms, "elm.text.right", wd->text_right); edje_object_part_text_set(wd->ms, "elm.text.center", wd->text_center); @@ -86,7 +93,7 @@ _theme_hook(Evas_Object *obj) } static void -_icon_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) +_drag_button_down_cb(void *data, Evas_Object *o __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__) { Widget_Data *wd = elm_widget_data_get((Evas_Object *) data); if (!wd) return; @@ -94,7 +101,7 @@ _icon_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void } static void -_icon_move_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) +_drag_button_move_cb(void *data, Evas_Object *o __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__) { Evas_Object *as = (Evas_Object *) data; Widget_Data *wd = elm_widget_data_get(as); @@ -102,7 +109,7 @@ _icon_move_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void if (!wd) return; if (!wd->mouse_down) return; - edje_object_part_drag_value_get(wd->ms, "elm.swallow.icon", &pos, NULL); + edje_object_part_drag_value_get(wd->ms, "elm.drag_button_base", &pos, NULL); if (pos == 0.0) evas_object_smart_callback_call(as, SIG_CHANGED, (void *)"left"); else if (pos == 1.0) @@ -112,7 +119,7 @@ _icon_move_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void } static Eina_Bool -_icon_animation(void *data) +_button_animation(void *data) { Widget_Data *wd = elm_widget_data_get(data); double cur_position = 0.0, new_position = 0.0; @@ -121,7 +128,7 @@ _icon_animation(void *data) if (!wd) return EINA_FALSE; edje_object_part_drag_value_get(wd->ms, - "elm.swallow.icon", &cur_position, NULL); + "elm.drag_button_base", &cur_position, NULL); if ((wd->final_position == 0.0) || (wd->final_position == 0.5 && cur_position >= wd->final_position)) { @@ -143,7 +150,7 @@ _icon_animation(void *data) } } edje_object_part_drag_value_set(wd->ms, - "elm.swallow.icon", new_position, 0.5); + "elm.drag_button_base", new_position, 0.5); if (flag_finish_animation) { if ((!wd->final_position) && @@ -164,7 +171,7 @@ _icon_animation(void *data) } static void -_icon_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__) +_drag_button_up_cb(void *data, Evas_Object *o __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__) { Widget_Data *wd = elm_widget_data_get(data); double position = 0.0; @@ -172,7 +179,7 @@ _icon_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *e wd->mouse_down = EINA_FALSE; - edje_object_part_drag_value_get(wd->ms, "elm.swallow.icon", + edje_object_part_drag_value_get(wd->ms, "elm.drag_button_base", &position, NULL); if (position == 0.0 && (wd->enabled_position & ELM_ACTIONSLIDER_LEFT)) @@ -242,7 +249,7 @@ _icon_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *e wd->final_position = 0; } as_anim: - wd->icon_animator = ecore_animator_add(_icon_animation, data); + wd->button_animator = ecore_animator_add(_button_animation, data); } /** @@ -279,17 +286,19 @@ elm_actionslider_add(Evas_Object *parent) _elm_theme_object_set(obj, wd->ms, "actionslider", "base", "default"); elm_widget_resize_object_set(obj, wd->ms); - wd->icon = edje_object_add(e); - elm_widget_sub_object_add(obj, wd->icon); - _elm_theme_object_set(obj, wd->icon, "actionslider", "icon", "default"); - edje_object_part_swallow(wd->ms, "elm.swallow.icon", wd->icon); + wd->drag_button_base = evas_object_rectangle_add(e); + evas_object_color_set(wd->drag_button_base, 0, 0, 0, 0); + edje_object_part_swallow(wd->ms, "elm.drag_button_base", wd->drag_button_base); - evas_object_event_callback_add(wd->icon, EVAS_CALLBACK_MOUSE_DOWN, - _icon_down_cb, obj); - evas_object_event_callback_add(wd->icon, EVAS_CALLBACK_MOUSE_MOVE, - _icon_move_cb, obj); - evas_object_event_callback_add(wd->icon, EVAS_CALLBACK_MOUSE_UP, - _icon_up_cb, obj); + edje_object_signal_callback_add(wd->ms, + "elm.drag_button,mouse,up", "", + _drag_button_up_cb, obj); + edje_object_signal_callback_add(wd->ms, + "elm.drag_button,mouse,down", "", + _drag_button_down_cb, obj); + edje_object_signal_callback_add(wd->ms, + "elm.drag_button,mouse,move", "", + _drag_button_move_cb, obj); evas_object_smart_callbacks_descriptions_set(obj, _signals); _sizing_eval(obj); @@ -313,7 +322,7 @@ elm_actionslider_indicator_pos_set(Evas_Object *obj, Elm_Actionslider_Pos pos) if (!wd) return; if (pos == ELM_ACTIONSLIDER_CENTER) position = 0.5; else if (pos == ELM_ACTIONSLIDER_RIGHT) position = 1.0; - edje_object_part_drag_value_set(wd->ms, "elm.swallow.icon", position, 0.5); + edje_object_part_drag_value_set(wd->ms, "elm.drag_button_base", position, 0.5); } /** @@ -332,7 +341,7 @@ elm_actionslider_indicator_pos_get(const Evas_Object *obj) double position; if (!wd) return ELM_ACTIONSLIDER_NONE; - edje_object_part_drag_value_get(wd->ms, "elm.swallow.icon", &position, NULL); + edje_object_part_drag_value_get(wd->ms, "elm.drag_button_base", &position, NULL); if (position < 0.3) return ELM_ACTIONSLIDER_LEFT; else if (position < 0.7) -- 2.7.4