From c00ac16f0801e07eb8331a3301f5885f53c3e3ea Mon Sep 17 00:00:00 2001 From: kumar navneet Date: Fri, 10 Apr 2015 14:37:10 +0900 Subject: [PATCH] [elm_panel] Fix mirroring issue. Summary: Issue: Mirroring of elm_panel not working correctly. Solution: Handle mirroring appropriately for animations. @fix Test Plan: Case: 1 1. Open elementary_test 2. Mirror on 3. Open scrollable panel, click on toggle button. Case: 2 1. Keep the scroller panel opened 2. Turn off Mirror Case: 3 1. Turn on mirror 2. Check direction button in non-scrollable panel. Reviewers: shilpasingh, raster, Hermet, Princekrdubey Reviewed By: shilpasingh Subscribers: poornima.srinivasan, subodh6129 Differential Revision: https://phab.enlightenment.org/D2237 --- legacy/elementary/AUTHORS | 1 + .../elementary/data/themes/edc/elm/panel.edc | 116 +++++++++++- legacy/elementary/src/lib/elm_authors.h | 3 +- legacy/elementary/src/lib/elm_panel.c | 173 ++++++++++++------ 4 files changed, 229 insertions(+), 64 deletions(-) diff --git a/legacy/elementary/AUTHORS b/legacy/elementary/AUTHORS index 1e0a28ed2d..4c6dc9a2d6 100644 --- a/legacy/elementary/AUTHORS +++ b/legacy/elementary/AUTHORS @@ -163,3 +163,4 @@ Vitalii Vorobiov Jee-Yong Um Ji-In Moon Subodh Kumar +Kumar Navneet diff --git a/legacy/elementary/data/themes/edc/elm/panel.edc b/legacy/elementary/data/themes/edc/elm/panel.edc index 7a99dbb734..ad3bb5e9ac 100644 --- a/legacy/elementary/data/themes/edc/elm/panel.edc +++ b/legacy/elementary/data/themes/edc/elm/panel.edc @@ -391,6 +391,9 @@ group { name: "elm/panel/left/default"; images.image: "icon_arrow_up.png" COMP; images.image: "icon_arrow_down.png" COMP; data.item: "focus_highlight" "on"; + script { + public is_rtl = 0; + } parts { part { name: "shadow"; mouse_events: 0; description { state: "default" 0.0; @@ -487,6 +490,10 @@ group { name: "elm/panel/left/default"; rel2.to: "elm.swallow.event"; color: 0 0 0 0; } + description { state: "hidden" 0.0; + rel1.to: "elm.swallow.event"; + rel2.to: "elm.swallow.event"; + } } part { name: "dots"; mouse_events: 0; description { state: "default" 0.0; @@ -524,24 +531,78 @@ group { name: "elm/panel/left/default"; transition: DECELERATE 0.3; target: "elm.swallow.event"; target: "base"; - target: "icn"; + } + program { + signal: "elm,action,show"; source: "elm"; + script { + if (get_int(is_rtl) == 0) + set_state(PART:"icn", "default", 0.0); + else + set_state(PART:"icn", "hidden", 0.0); + } + } + program { + signal: "edje,state,rtl"; + source: "edje"; + script { + new st[31]; + new Float:vl; + get_state(PART:"elm.swallow.event", st, 30, vl); + if (!strcmp(st, "default")) + set_state(PART:"icn", "hidden", 0.0); + else + set_state(PART:"icn", "default", 0.0); + set_int(is_rtl, 1); + } + } + program { + signal: "edje,state,ltr"; + source: "edje"; + script { + new st[31]; + new Float:vl; + get_state(PART:"elm.swallow.event", st, 30, vl); + if (!strcmp(st, "default")) + set_state(PART:"icn", "default", 0.0); + else + set_state(PART:"icn", "hidden", 0.0); + set_int(is_rtl, 0); + } } program { signal: "elm,action,hide"; source: "elm"; action: STATE_SET "hidden" 0.0; transition: ACCELERATE 0.3; target: "elm.swallow.event"; - target: "icn"; + } + program { + signal: "elm,action,hide"; source: "elm"; + script { + if (get_int(is_rtl) == 0) + set_state(PART:"icn", "hidden", 0.0); + else + set_state(PART:"icn", "default", 0.0); + } } program { name: "hide1"; signal: "elm,action,hide"; source: "elm"; script { new x, y, w, h; - - custom_state(PART:"base", "default", 0.0); - set_state_val(PART:"base", STATE_REL1, -1.0, 0.0); - get_geometry(PART:"elm.swallow.event", x, y, w, h); - set_state_val(PART:"base", STATE_REL1_OFFSET, w, 0); + if (get_int(is_rtl) == 0) + { + custom_state(PART:"base", "default", 0.0); + set_state_val(PART:"base", STATE_REL1, -1.0, 0.0); + get_geometry(PART:"elm.swallow.event", x, y, w, h); + set_state_val(PART:"base", STATE_REL1_OFFSET, w, 0); + } + else + { + custom_state(PART:"base", "default", 0.0); + set_state_val(PART:"base", STATE_REL1, -1.0, 0.0); + set_state_val(PART:"base", STATE_REL2, -2.0, 1.0); + get_geometry(PART:"elm.swallow.event", x, y, w, h); + set_state_val(PART:"base", STATE_REL2_OFFSET, -w, 0); + } } after: "hide2"; } @@ -608,7 +669,7 @@ group { name: "elm/panel/right/default"; program { name: "hide1"; script { new x, y, w, h; - + custom_state(PART:"base", "default", 0.0); set_state_val(PART:"base", STATE_REL1, 1.0, 0.0); set_state_val(PART:"base", STATE_REL2, 2.0, 1.0); @@ -674,11 +735,47 @@ group { name: "elm/panel/top/default"; set_state_val(PART:"base", STATE_REL1_OFFSET, 0, h); } } + program { + signal: "elm,action,show"; source: "elm"; + action: STATE_SET "default" 0.0; + target: "icn"; + } + program { + signal: "edje,state,rtl"; + source: "edje"; + script { + new st[31]; + new Float:vl; + get_state(PART:"elm.swallow.event", st, 30, vl); + if (!strcmp(st, "default")) + set_state(PART:"icn", "default", 0.0); + else + set_state(PART:"icn", "hidden", 0.0); + } + } + program { + signal: "edje,state,ltr"; + source: "edje"; + script { + new st[31]; + new Float:vl; + get_state(PART:"elm.swallow.event", st, 30, vl); + if (!strcmp(st, "default")) + set_state(PART:"icn", "default", 0.0); + else + set_state(PART:"icn", "hidden", 0.0); + } + } + program { + signal: "elm,action,hide"; source: "elm"; + action: STATE_SET "hidden" 0.0; + target: "icn"; + } } } group { name: "elm/panel/bottom/default"; - inherit: "elm/panel/left/default"; + inherit: "elm/panel/top/default"; parts { part { name: "base"; description { state: "default" 0.0; @@ -724,7 +821,6 @@ group { name: "elm/panel/bottom/default"; program { name: "hide1"; script { new x, y, w, h; - custom_state(PART:"base", "default", 0.0); set_state_val(PART:"base", STATE_REL1, 0.0, 1.0); set_state_val(PART:"base", STATE_REL2, 1.0, 2.0); diff --git a/legacy/elementary/src/lib/elm_authors.h b/legacy/elementary/src/lib/elm_authors.h index f4cf2f9e8d..6c2f996724 100644 --- a/legacy/elementary/src/lib/elm_authors.h +++ b/legacy/elementary/src/lib/elm_authors.h @@ -160,7 +160,8 @@ * @author Jae Yong Hwang * @author Kabeer Khan * @author yinsc - * @author Subodh Kumar + * @author Subodh Kumar + * @author Kumar Navneet * * Please contact to get in * contact with the developers and maintainers. diff --git a/legacy/elementary/src/lib/elm_panel.c b/legacy/elementary/src/lib/elm_panel.c index 733386fa47..4847f2efd6 100644 --- a/legacy/elementary/src/lib/elm_panel.c +++ b/legacy/elementary/src/lib/elm_panel.c @@ -27,8 +27,10 @@ static const Evas_Smart_Cb_Description _smart_callbacks[] = { {SIG_LAYOUT_UNFOCUSED, ""}, /**< handled by elm_layout */ {NULL, NULL} }; - +static void _panel_toggle(void *, Evas_Object *, const char *,const char *); static Eina_Bool _key_action_toggle(Evas_Object *obj, const char *params); +static void _drawer_open(Evas_Object *, Evas_Coord , Evas_Coord , Eina_Bool ); +static void _drawer_close(Evas_Object *, Evas_Coord , Evas_Coord , Eina_Bool); static const Elm_Action key_actions[] = { {"toggle", _key_action_toggle}, @@ -142,33 +144,15 @@ _orient_set_do(Evas_Object *obj) break; case ELM_PANEL_ORIENT_LEFT: - if (!elm_widget_mirrored_get(obj)) - { - if (!elm_layout_theme_set - (obj, "panel", "left", elm_widget_style_get(obj))) - CRI("Failed to set layout!"); - } - else - { - if (!elm_layout_theme_set - (obj, "panel", "right", elm_widget_style_get(obj))) - CRI("Failed to set layout!"); - } + if (!elm_layout_theme_set(obj, "panel", "left", + elm_widget_style_get(obj))) + CRI("Failed to set layout!"); break; case ELM_PANEL_ORIENT_RIGHT: - if (!elm_widget_mirrored_get(obj)) - { - if (!elm_layout_theme_set - (obj, "panel", "right", elm_widget_style_get(obj))) - CRI("Failed to set layout!"); - } - else - { - if (!elm_layout_theme_set - (obj, "panel", "left", elm_widget_style_get(obj))) - CRI("Failed to set layout!"); - } + if (!elm_layout_theme_set(obj, "panel", "right", + elm_widget_style_get(obj))) + CRI("Failed to set layout!"); break; } @@ -221,6 +205,7 @@ EOLIAN static Eina_Bool _elm_panel_elm_widget_theme_apply(Eo *obj, Elm_Panel_Data *sd) { const char *str; + int w, h; Evas_Coord minw = 0, minh = 0; Eina_Bool int_ret = EINA_FALSE; @@ -238,7 +223,9 @@ _elm_panel_elm_widget_theme_apply(Eo *obj, Elm_Panel_Data *sd) elm_widget_theme_object_set(obj, sd->scr_edje, "scroller", "panel", elm_widget_style_get(obj)); _scrollable_layout_theme_set(obj, sd); - + evas_object_geometry_get(obj, NULL, NULL, &w, &h); + if (!sd->hidden) _drawer_open(obj, w, h, EINA_FALSE); + else _drawer_close(obj, w, h, EINA_FALSE); handler_size = edje_object_data_get(sd->scr_edje, "handler_size"); if (handler_size) sd->handler_size = (int) (elm_object_scale_get(obj)) * (atoi(handler_size)); @@ -370,7 +357,7 @@ _drawer_open(Evas_Object *obj, Evas_Coord w, Evas_Coord h, Eina_Bool anim) if (sd->freeze) { eo_do(obj, elm_interface_scrollable_movement_block_set - (ELM_SCROLLER_MOVEMENT_NO_BLOCK)); + (ELM_SCROLLER_MOVEMENT_NO_BLOCK)); sd->freeze = EINA_FALSE; elm_layout_signal_emit(sd->scr_ly, "elm,state,content,visible", "elm"); } @@ -378,7 +365,10 @@ _drawer_open(Evas_Object *obj, Evas_Coord w, Evas_Coord h, Eina_Bool anim) switch (sd->orient) { case ELM_PANEL_ORIENT_TOP: + break; case ELM_PANEL_ORIENT_LEFT: + if (elm_widget_mirrored_get(obj)) + x = w * sd->content_size_ratio; break; case ELM_PANEL_ORIENT_BOTTOM: @@ -386,7 +376,8 @@ _drawer_open(Evas_Object *obj, Evas_Coord w, Evas_Coord h, Eina_Bool anim) break; case ELM_PANEL_ORIENT_RIGHT: - x = w * sd->content_size_ratio; + if (!elm_widget_mirrored_get(obj)) + x = w * sd->content_size_ratio; break; } @@ -412,13 +403,17 @@ _drawer_close(Evas_Object *obj, Evas_Coord w, Evas_Coord h, Eina_Bool anim) break; case ELM_PANEL_ORIENT_LEFT: - x = w * sd->content_size_ratio; + if (!elm_widget_mirrored_get(obj)) + x = w * sd->content_size_ratio; horizontal = EINA_TRUE; break; case ELM_PANEL_ORIENT_BOTTOM: break; + case ELM_PANEL_ORIENT_RIGHT: + if (elm_widget_mirrored_get(obj)) + x = w * sd->content_size_ratio; horizontal = EINA_TRUE; break; } @@ -535,9 +530,18 @@ _state_sync(Evas_Object *obj) eo_do(obj, elm_interface_scrollable_content_pos_get(&pos, NULL)); horizontal = EINA_TRUE; - if (pos == 0) open = EINA_TRUE; - else if (pos == panel_size) open = EINA_FALSE; - else return EINA_FALSE; + if (!elm_widget_mirrored_get(obj)) + { + if (pos == 0) open = EINA_TRUE; + else if (pos == panel_size) open = EINA_FALSE; + else return EINA_FALSE; + } + else + { + if (pos == panel_size) open = EINA_TRUE; + else if (pos == 0) open = EINA_FALSE; + else return EINA_FALSE; + } break; case ELM_PANEL_ORIENT_RIGHT: @@ -545,9 +549,18 @@ _state_sync(Evas_Object *obj) eo_do(obj, elm_interface_scrollable_content_pos_get(&pos, NULL)); horizontal = EINA_TRUE; - if (pos == panel_size) open = EINA_TRUE; - else if (pos == 0) open = EINA_FALSE; - else return EINA_FALSE; + if (!elm_widget_mirrored_get(obj)) + { + if (pos == 0) open = EINA_TRUE; + else if (pos == panel_size) open = EINA_FALSE; + else return EINA_FALSE; + } + else + { + if (pos == panel_size) open = EINA_TRUE; + else if (pos == 0) open = EINA_FALSE; + else return EINA_FALSE; + } break; } @@ -649,6 +662,7 @@ _on_mouse_down(void *data, Evas_Coord finger_size = elm_config_finger_size_get(); Evas_Coord x, y, w, h; evas_object_geometry_get(obj, &x, &y, &w, &h); + Eina_Bool is_mirrored = elm_widget_mirrored_get(obj); sd->down_x = ev->canvas.x - x; sd->down_y = ev->canvas.y - y; @@ -672,14 +686,16 @@ _on_mouse_down(void *data, } break; case ELM_PANEL_ORIENT_LEFT: - if ((sd->freeze) && (sd->down_x >= 0) && (sd->down_x < finger_size)) + if ((!is_mirrored && (sd->freeze) && (sd->down_x >= 0) && (sd->down_x < finger_size)) || + ((is_mirrored && (sd->freeze) && (sd->down_x <= w) && (sd->down_x > (w - finger_size))))) { ecore_timer_del(sd->timer); sd->timer = ecore_timer_add(0.2, _timer_cb, obj); } break; case ELM_PANEL_ORIENT_RIGHT: - if ((sd->freeze) && (sd->down_x <= w) && (sd->down_x > (w - finger_size))) + if ((is_mirrored && (sd->freeze) && (sd->down_x >= 0) && (sd->down_x < finger_size)) || + (!is_mirrored && (sd->freeze) && (sd->down_x <= w) && (sd->down_x > (w - finger_size)))) { ecore_timer_del(sd->timer); sd->timer = ecore_timer_add(0.2, _timer_cb, obj); @@ -699,6 +715,7 @@ _on_mouse_move(void *data, Evas_Coord x, y, w, h, cur_x, cur_y, finger_size; evas_object_geometry_get(obj, &x, &y, &w, &h); finger_size = elm_config_finger_size_get(); + Eina_Bool is_mirrored = elm_widget_mirrored_get(obj); cur_x = ev->cur.canvas.x - x; cur_y = ev->cur.canvas.y - y; @@ -725,7 +742,8 @@ _on_mouse_move(void *data, } break; case ELM_PANEL_ORIENT_LEFT: - if (sd->timer && ((cur_x - sd->down_x) > finger_size)) + if ((!is_mirrored && (sd->timer) && ((cur_x - sd->down_x) > finger_size)) || + ((is_mirrored) && (sd->timer) && ((sd->down_x - cur_x) > finger_size))) { eo_do(obj, elm_interface_scrollable_freeze_set(EINA_FALSE)); sd->freeze = EINA_FALSE; @@ -733,7 +751,8 @@ _on_mouse_move(void *data, } break; case ELM_PANEL_ORIENT_RIGHT: - if (sd->timer && ((sd->down_x - cur_x) > finger_size)) + if ((is_mirrored && (sd->timer) && ((cur_x - sd->down_x) > finger_size)) || + (!is_mirrored && (sd->timer) && ((sd->down_x - cur_x) > finger_size))) { eo_do(obj, elm_interface_scrollable_freeze_set(EINA_FALSE)); sd->freeze = EINA_FALSE; @@ -803,15 +822,31 @@ _on_mouse_up(void *data, threshold = panel_size / 4; eo_do(obj, elm_interface_scrollable_content_pos_get(&pos, NULL)); - if (sd->hidden) + if (elm_widget_mirrored_get(obj)) { - if (pos < (panel_size - threshold)) _drawer_open(obj, w, h, EINA_TRUE); - else _drawer_close(obj, w, h, EINA_TRUE); + if (sd->hidden) + { + if (pos > threshold) _drawer_open(obj, w, h, EINA_TRUE); + else _drawer_close(obj, w, h, EINA_TRUE); + } + else + { + if (pos > (panel_size - threshold)) _drawer_open(obj, w, h, EINA_TRUE); + else _drawer_close(obj, w, h, EINA_TRUE); + } } else { - if (pos < threshold) _drawer_open(obj, w, h, EINA_TRUE); - else _drawer_close(obj, w, h, EINA_TRUE); + if (sd->hidden) + { + if (pos < (panel_size - threshold)) _drawer_open(obj, w, h, EINA_TRUE); + else _drawer_close(obj, w, h, EINA_TRUE); + } + else + { + if (pos < threshold) _drawer_open(obj, w, h, EINA_TRUE); + else _drawer_close(obj, w, h, EINA_TRUE); + } } break; @@ -820,15 +855,31 @@ _on_mouse_up(void *data, threshold = panel_size / 4; eo_do(obj, elm_interface_scrollable_content_pos_get(&pos, NULL)); - if (sd->hidden) + if (!elm_widget_mirrored_get(obj)) { - if (pos > threshold) _drawer_open(obj, w, h, EINA_TRUE); - else _drawer_close(obj, w, h, EINA_TRUE); + if (sd->hidden) + { + if (pos > threshold) _drawer_open(obj, w, h, EINA_TRUE); + else _drawer_close(obj, w, h, EINA_TRUE); + } + else + { + if (pos > (panel_size - threshold)) _drawer_open(obj, w, h, EINA_TRUE); + else _drawer_close(obj, w, h, EINA_TRUE); + } } else { - if (pos > (panel_size - threshold)) _drawer_open(obj, w, h, EINA_TRUE); - else _drawer_close(obj, w, h, EINA_TRUE); + if (sd->hidden) + { + if (pos < (panel_size - threshold)) _drawer_open(obj, w, h, EINA_TRUE); + else _drawer_close(obj, w, h, EINA_TRUE); + } + else + { + if (pos < threshold) _drawer_open(obj, w, h, EINA_TRUE); + else _drawer_close(obj, w, h, EINA_TRUE); + } } break; } @@ -1237,12 +1288,28 @@ _scroll_cb(Evas_Object *obj, void *data EINA_UNUSED) event.rel_y = (double) y / (double) ((sd->content_size_ratio) * h); break; case ELM_PANEL_ORIENT_LEFT: - event.rel_x = 1 - ((double) x / (double) ((sd->content_size_ratio) * w)); - event.rel_y = 1; + if (!elm_widget_mirrored_get(obj)) + { + event.rel_x = 1 - ((double) x / (double) ((sd->content_size_ratio) * w)); + event.rel_y = 1; + } + else + { + event.rel_x = (double) x / (double) ((sd->content_size_ratio) * w); + event.rel_y = 1; + } break; case ELM_PANEL_ORIENT_RIGHT: - event.rel_x = (double) x / (double) ((sd->content_size_ratio) * w); - event.rel_y = 1; + if (elm_widget_mirrored_get(obj)) + { + event.rel_x = 1 - ((double) x / (double) ((sd->content_size_ratio) * w)); + event.rel_y = 1; + } + else + { + event.rel_x = (double) x / (double) ((sd->content_size_ratio) * w); + event.rel_y = 1; + } break; } evas_object_smart_callback_call(obj, SIG_SCROLL, (void *) &event);