From ee83f2aa3d6a089487b97c3f9cdad30a0cb5a9d8 Mon Sep 17 00:00:00 2001 From: Taehyub Kim Date: Tue, 25 Oct 2016 13:32:50 -0700 Subject: [PATCH] elementary: colorselector - apply new focus ui for palette and components items Summary: colorselector focus ui is not moving for palette and components items. now it is changed to focus each item of palette and components. Test Plan: 1. build efl elementary with this patch 2. remove /home/{user}/.elementary 3. launch colorselector with elementary_test -to colorselector 4. move direction key 5. see the new focus ui Reviewers: jpeg, raster, Hermet, woohyun, bu5hm4n, cedric Reviewed By: cedric Differential Revision: https://phab.enlightenment.org/D4288 Signed-off-by: Cedric Bail --- config/default/base.src.in | 6 ++ config/mobile/base.src.in | 6 ++ config/standard/base.src.in | 6 ++ src/lib/elementary/elm_color_item.eo | 2 + src/lib/elementary/elm_colorselector.c | 100 +++++++++++++++--- src/lib/elementary/elm_colorselector.eo | 1 + src/lib/elementary/elm_widget_colorselector.h | 4 + 7 files changed, 110 insertions(+), 15 deletions(-) diff --git a/config/default/base.src.in b/config/default/base.src.in index 9e05df6e19..90188f3827 100644 --- a/config/default/base.src.in +++ b/config/default/base.src.in @@ -803,6 +803,12 @@ group "Elm_Config" struct { value "action" string: "move"; value "params" string: "down"; } + group "Elm_Config_Binding_Key" struct { + value "context" int: 0; + value "key" string: "Return"; + value "action" string: "activate"; + value "params" string: ""; + } } } group "Elm_Config_Bindings_Widget" struct { diff --git a/config/mobile/base.src.in b/config/mobile/base.src.in index 56c4f3fbf3..5619970c93 100644 --- a/config/mobile/base.src.in +++ b/config/mobile/base.src.in @@ -807,6 +807,12 @@ group "Elm_Config" struct { value "action" string: "move"; value "params" string: "down"; } + group "Elm_Config_Binding_Key" struct { + value "context" int: 0; + value "key" string: "Return"; + value "action" string: "activate"; + value "params" string: ""; + } } } group "Elm_Config_Bindings_Widget" struct { diff --git a/config/standard/base.src.in b/config/standard/base.src.in index e628f8274d..849185f6e5 100644 --- a/config/standard/base.src.in +++ b/config/standard/base.src.in @@ -804,6 +804,12 @@ group "Elm_Config" struct { value "action" string: "move"; value "params" string: "down"; } + group "Elm_Config_Binding_Key" struct { + value "context" int: 0; + value "key" string: "Return"; + value "action" string: "activate"; + value "params" string: ""; + } } } group "Elm_Config_Bindings_Widget" struct { diff --git a/src/lib/elementary/elm_color_item.eo b/src/lib/elementary/elm_color_item.eo index eab8b5416e..00928c379f 100644 --- a/src/lib/elementary/elm_color_item.eo +++ b/src/lib/elementary/elm_color_item.eo @@ -40,5 +40,7 @@ class Elm.Color.Item(Elm.Widget.Item) Efl.Object.destructor; Elm.Widget.Item.access_register; Elm.Widget.Item.signal_emit; + Elm.Widget.Item.focus.set; + Elm.Widget.Item.focus.get; } } diff --git a/src/lib/elementary/elm_colorselector.c b/src/lib/elementary/elm_colorselector.c index 189d341f87..66af2e211a 100644 --- a/src/lib/elementary/elm_colorselector.c +++ b/src/lib/elementary/elm_colorselector.c @@ -183,9 +183,11 @@ static const Elm_Color_Name _color_name[] = { }; static Eina_Bool _key_action_move(Evas_Object *obj, const char *params); +static Eina_Bool _key_action_activate(Evas_Object *obj, const char *params); static const Elm_Action key_actions[] = { {"move", _key_action_move}, + {"activate", _key_action_activate}, {NULL, NULL} }; @@ -237,6 +239,7 @@ _items_del(Elm_Colorselector_Data *sd) sd->items = NULL; sd->selected = NULL; + sd->focus_items = NULL; } static void @@ -1895,6 +1898,7 @@ _elm_colorselector_efl_canvas_group_group_add(Eo *obj, Elm_Colorselector_Data *p priv->focused = ELM_COLORSELECTOR_PALETTE; priv->sel_color_type = HUE; priv->selected = NULL; + priv->focus_items = NULL; priv->er = 255; priv->eg = 0; priv->eb = 0; @@ -2014,7 +2018,7 @@ _key_action_move(Evas_Object *obj, const char *params) { if (sd->focused == ELM_COLORSELECTOR_PALETTE && sd->selected) { - cl = eina_list_prev(sd->selected); + cl = eina_list_prev(sd->focus_items); } else if (sd->focused == ELM_COLORSELECTOR_COMPONENTS) { @@ -2028,7 +2032,7 @@ _key_action_move(Evas_Object *obj, const char *params) { if (sd->focused == ELM_COLORSELECTOR_PALETTE && sd->selected) { - cl = eina_list_next(sd->selected); + cl = eina_list_next(sd->focus_items); } else if (sd->focused == ELM_COLORSELECTOR_COMPONENTS) { @@ -2061,16 +2065,16 @@ _key_action_move(Evas_Object *obj, const char *params) } } else if (sd->focused == ELM_COLORSELECTOR_PALETTE) - { - cl = _palette_box_vertical_item_get(sd->selected, PALETTE_BOX_UP); - if (!cl) cl = sd->selected; - } + { + cl = _palette_box_vertical_item_get(sd->focus_items, PALETTE_BOX_UP); + if (!cl) cl = sd->focus_items; + } } else if (!strcmp(dir, "down")) { if (sd->focused == ELM_COLORSELECTOR_PALETTE) { - cl = _palette_box_vertical_item_get(sd->selected, PALETTE_BOX_DOWN); + cl = _palette_box_vertical_item_get(sd->focus_items, PALETTE_BOX_DOWN); if (sd->mode == ELM_COLORSELECTOR_BOTH && !cl) { sd->focused = ELM_COLORSELECTOR_COMPONENTS; @@ -2095,20 +2099,30 @@ _key_action_move(Evas_Object *obj, const char *params) { eo_item = eina_list_data_get(cl); ELM_COLOR_ITEM_DATA_GET(eo_item, item); - elm_object_signal_emit(VIEW(item), "elm,anim,activate", "elm"); - elm_colorselector_color_set - (WIDGET(item), item->color->r, item->color->g, item->color->b, - item->color->a); - efl_event_callback_legacy_call - (WIDGET(item), ELM_COLORSELECTOR_EVENT_COLOR_ITEM_SELECTED, eo_item); - elm_obj_color_item_selected_set(eo_item, EINA_TRUE); + elm_object_item_focus_set(eo_item, EINA_TRUE); } - else if (!cl && sd->focused == ELM_COLORSELECTOR_PALETTE) + else if (!cl && (sd->focused == ELM_COLORSELECTOR_PALETTE)) return EINA_FALSE; + else if (!cl && (sd->focused == ELM_COLORSELECTOR_COMPONENTS)) + _elm_widget_focus_highlight_start(obj); return EINA_TRUE; } + +static Eina_Bool +_key_action_activate(Evas_Object *obj, const char *params EINA_UNUSED) +{ + ELM_COLORSELECTOR_DATA_GET(obj, sd); + + if (sd->focused == ELM_COLORSELECTOR_PALETTE) + { + Elm_Object_Item *eo_item = NULL; + eo_item = eina_list_data_get(sd->focus_items); + elm_obj_color_item_selected_set(eo_item, EINA_TRUE); + } +} + EOLIAN static Eina_Bool _elm_colorselector_elm_widget_event(Eo *obj, Elm_Colorselector_Data *sd, Evas_Object *src, Evas_Callback_Type type, void *event_info) { @@ -2119,6 +2133,7 @@ _elm_colorselector_elm_widget_event(Eo *obj, Elm_Colorselector_Data *sd, Evas_Ob if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE; if (!sd) return EINA_FALSE; if (!sd->selected) sd->selected = sd->items; + if (!sd->focus_items) sd->focus_items = sd->items; if (!_elm_config_key_binding_call(obj, MY_CLASS_NAME, ev, key_actions)) return EINA_FALSE; @@ -2218,6 +2233,20 @@ _access_obj_process(Evas_Object *obj, Eina_Bool is_access) } } +EOLIAN static void +_elm_colorselector_elm_widget_focus_highlight_geometry_get(const Eo *obj EINA_UNUSED, Elm_Colorselector_Data *sd, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h) +{ + if (sd->focused_item && (sd->focused == ELM_COLORSELECTOR_PALETTE)) + { + ELM_COLOR_ITEM_DATA_GET(sd->focused_item, focus_it); + evas_object_geometry_get(VIEW(focus_it), x, y, w, h); + } + else if(sd->focused == ELM_COLORSELECTOR_COMPONENTS) + evas_object_geometry_get(sd->cb_data[sd->sel_color_type]->colorbar, x, y, w, h); + else + evas_object_geometry_get(obj, x, y, w, h); +} + EOLIAN static void _elm_colorselector_elm_widget_access(Eo *obj, Elm_Colorselector_Data *_pd EINA_UNUSED, Eina_Bool acs) { @@ -2491,6 +2520,10 @@ _elm_color_item_selected_set(Eo *eo_item, EINA_LIST_FOREACH(sd->items, l, eo_temp_item) if (eo_item == eo_temp_item) sd->selected = l; + + elm_object_signal_emit(VIEW(item), "elm,anim,activate", "elm"); + efl_event_callback_legacy_call + (WIDGET(item), ELM_COLORSELECTOR_EVENT_COLOR_ITEM_SELECTED, eo_item); } } @@ -2558,6 +2591,43 @@ _elm_colorselector_elm_interface_atspi_widget_action_elm_actions_get(Eo *obj EIN return &atspi_actions[0]; } +EOLIAN static void +_elm_color_item_elm_widget_item_focus_set(Eo *eo_it, Elm_Color_Item_Data *it, Eina_Bool focused) +{ + Evas_Object *obj = WIDGET(it); + ELM_COLORSELECTOR_DATA_GET(obj, sd); + + if (focused) + { + if (eo_it != sd->focused_item) + sd->focused_item = eo_it; + + Eina_List *l; + Eo *eo_temp_item; + EINA_LIST_FOREACH(sd->items, l, eo_temp_item) + if (eo_it == eo_temp_item) sd->focus_items = l; + } + else + { + if (!elm_widget_focus_get(obj)) + return; + sd->focused_item = NULL; + } + + _elm_widget_focus_highlight_start(obj); +} + +EOLIAN static Eina_Bool +_elm_color_item_elm_widget_item_focus_get(Eo *eo_it, Elm_Color_Item_Data *it) +{ + Evas_Object *obj = WIDGET(it); + ELM_COLORSELECTOR_DATA_GET(obj, sd); + + if (eo_it == sd->focused_item) + return EINA_TRUE; + return EINA_FALSE; +} + #include "elm_colorselector.eo.c" #include "elm_color_item.eo.c" diff --git a/src/lib/elementary/elm_colorselector.eo b/src/lib/elementary/elm_colorselector.eo index 78faf142a8..3563b8e30b 100644 --- a/src/lib/elementary/elm_colorselector.eo +++ b/src/lib/elementary/elm_colorselector.eo @@ -114,6 +114,7 @@ selected.]] Elm.Widget.focus_next_manager_is; Elm.Widget.focus_next; Elm.Widget.focus_direction_manager_is; + Elm.Widget.focus_highlight_geometry_get; Elm.Widget.access; Elm.Widget.event; Elm.Layout.sizing_eval; diff --git a/src/lib/elementary/elm_widget_colorselector.h b/src/lib/elementary/elm_widget_colorselector.h index 943297a778..a6bd8d38d6 100644 --- a/src/lib/elementary/elm_widget_colorselector.h +++ b/src/lib/elementary/elm_widget_colorselector.h @@ -49,6 +49,10 @@ struct _Elm_Colorselector_Data #endif } grab; + /* focus support data */ + Elm_Object_Item *focused_item; + Eina_List *focus_items; + Eina_List *items, *selected; Color_Bar_Data *cb_data[4];