From e20db4aa6aaa8c346425cfd5df50b8ea16fad85b Mon Sep 17 00:00:00 2001 From: Taehyub Kim Date: Fri, 9 Sep 2016 15:36:44 +0900 Subject: [PATCH] colorselector: apply new focus ui for palette and components items Change-Id: I39b6227efe511db47c0490122ec824810bee9254 --- src/lib/elm_color_item.eo | 2 + src/lib/elm_colorselector.c | 99 ++++++++++++++++++++++++++++++++------ src/lib/elm_colorselector.eo | 1 + src/lib/elm_widget_colorselector.h | 4 ++ 4 files changed, 91 insertions(+), 15 deletions(-) diff --git a/src/lib/elm_color_item.eo b/src/lib/elm_color_item.eo index 2dd3c33..af85e9b 100644 --- a/src/lib/elm_color_item.eo +++ b/src/lib/elm_color_item.eo @@ -39,6 +39,8 @@ class Elm.Color_Item(Elm.Widget_Item, Elm_Interface_Atspi_Widget_Action) Eo.Base.destructor; Elm.Widget_Item.access_register; Elm.Widget_Item.signal_emit; + Elm.Widget_Item.focus.set; + Elm.Widget_Item.focus.get; //TIZEN_ONLY(20150707) : improve colorselctor atspi support Elm_Interface_Atspi_Accessible.state_set.get; Elm_Interface_Atspi_Accessible.name.get; diff --git a/src/lib/elm_colorselector.c b/src/lib/elm_colorselector.c index b031942..dac8d59 100644 --- a/src/lib/elm_colorselector.c +++ b/src/lib/elm_colorselector.c @@ -184,9 +184,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} }; @@ -238,6 +240,7 @@ _items_del(Elm_Colorselector_Data *sd) sd->items = NULL; sd->selected = NULL; + sd->focus_items = NULL; } static void @@ -2006,6 +2009,7 @@ _elm_colorselector_evas_object_smart_add(Eo *obj, Elm_Colorselector_Data *priv) 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; @@ -2124,7 +2128,7 @@ _key_action_move(Evas_Object *obj, const char *params) if (!strcmp(dir, "left")) { 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) _button_clicked_cb(sd->cb_data[sd->sel_color_type], sd->cb_data[sd->sel_color_type]->lbt, NULL, NULL); @@ -2133,7 +2137,7 @@ _key_action_move(Evas_Object *obj, const char *params) else if (!strcmp(dir, "right")) { 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) _button_clicked_cb(sd->cb_data[sd->sel_color_type], sd->cb_data[sd->sel_color_type]->rbt, NULL, NULL); @@ -2162,16 +2166,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; @@ -2196,20 +2200,29 @@ _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); - eo_do(WIDGET(item), eo_event_callback_call - (ELM_COLORSELECTOR_EVENT_COLOR_ITEM_SELECTED, eo_item)); - eo_do(eo_item, elm_obj_color_item_selected_set(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); + eo_do(eo_item, elm_obj_color_item_selected_set(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) { @@ -2220,6 +2233,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, ev, key_actions)) return EINA_FALSE; @@ -2320,6 +2334,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) { _elm_colorselector_smart_focus_next_enable = acs; @@ -2596,6 +2624,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"); + eo_do(WIDGET(item), eo_event_callback_call + (ELM_COLORSELECTOR_EVENT_COLOR_ITEM_SELECTED, eo_item)); } } @@ -2698,6 +2730,43 @@ _elm_color_item_elm_interface_atspi_accessible_state_set_get(Eo *obj EINA_UNUSED return ret; } +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; +} + EOLIAN static Eina_Bool _elm_color_item_elm_interface_atspi_component_highlight_grab(Eo *eo_it, Elm_Color_Item_Data *it) { diff --git a/src/lib/elm_colorselector.eo b/src/lib/elm_colorselector.eo index 3ce6d56..4d002a7 100644 --- a/src/lib/elm_colorselector.eo +++ b/src/lib/elm_colorselector.eo @@ -168,6 +168,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/elm_widget_colorselector.h b/src/lib/elm_widget_colorselector.h index a288c29..b538f4f 100644 --- a/src/lib/elm_widget_colorselector.h +++ b/src/lib/elm_widget_colorselector.h @@ -50,6 +50,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]; -- 2.7.4