aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--legacy/elementary/data/themes/edc/elm/gengrid.edc4
-rw-r--r--legacy/elementary/src/bin/test.c2
-rw-r--r--legacy/elementary/src/bin/test_gengrid.c90
-rw-r--r--legacy/elementary/src/lib/elm_gengrid.c480
-rw-r--r--legacy/elementary/src/lib/elm_gengrid.h2
-rw-r--r--legacy/elementary/src/lib/elm_widget_gengrid.h3
6 files changed, 547 insertions, 34 deletions
diff --git a/legacy/elementary/data/themes/edc/elm/gengrid.edc b/legacy/elementary/data/themes/edc/elm/gengrid.edc
index 4889b7ddf3..bb21ae52f3 100644
--- a/legacy/elementary/data/themes/edc/elm/gengrid.edc
+++ b/legacy/elementary/data/themes/edc/elm/gengrid.edc
@@ -4,6 +4,7 @@ group { name: "elm/gengrid/item/group_index/default";
group { name: "elm/gengrid/item/default/default";
data.item: "selectraise" "on";
+ data.item: "focusraise" "on";
data.item: "texts" "elm.text";
data.item: "contents" "elm.swallow.icon elm.swallow.end";
#define IMGP() \
@@ -322,6 +323,7 @@ group { name: "elm/gengrid/item/default/default";
group { name: "elm/gengrid/item/default_style/default";
data.item: "selectraise" "on";
+ data.item: "focusraise" "on";
data.item: "texts" "elm.text";
data.item: "contents" "elm.swallow.icon elm.swallow.end";
styles.style { name: "gengrid_style";
@@ -525,6 +527,7 @@ group { name: "elm/gengrid/item/up/default";
group { name: "elm/gengrid/item/album-preview/default";
data.item: "selectraise" "on";
+ data.item: "focusraise" "on";
data.item: "texts" "elm.text";
data.item: "contents" "elm.swallow.icon.1 elm.swallow.icon.2 elm.swallow.icon.3 elm.swallow.icon.4";
data.item: "states" "have_files";
@@ -736,6 +739,7 @@ group { name: "elm/gengrid/item/album-preview/default";
group { name: "elm/gengrid/item/thumb/default";
data.item: "selectraise" "on";
+ data.item: "focusraise" "on";
data.item: "texts" "elm.text";
data.item: "contents" "elm.swallow.icon elm.swallow.end";
diff --git a/legacy/elementary/src/bin/test.c b/legacy/elementary/src/bin/test.c
index 2d333f291f..31349b6fad 100644
--- a/legacy/elementary/src/bin/test.c
+++ b/legacy/elementary/src/bin/test.c
@@ -132,6 +132,7 @@ void test_gengrid3(void *data, Evas_Object *obj, void *event_info);
void test_gengrid_item_styles(void *data, Evas_Object *obj, void *event_info);
void test_gengrid4(void *data, Evas_Object *obj, void *event_info);
void test_gengrid_speed(void *data, Evas_Object *obj, void *event_info);
+void test_gengrid_item_focus(void *data, Evas_Object *obj, void *event_info);
void test_win_state(void *data, Evas_Object *obj, void *event_info);
void test_win_state2(void *data, Evas_Object *obj, void *event_info);
void test_progressbar(void *data, Evas_Object *obj, void *event_info);
@@ -663,6 +664,7 @@ add_tests:
ADD_TEST(NULL, "Lists - Gengrid", "GenGrid Show/Bring_in", test_gengrid4);
ADD_TEST(NULL, "Lists - Gengrid", "GenGrid Item Styles", test_gengrid_item_styles);
ADD_TEST(NULL, "Lists - Gengrid", "Gengrid Update Speed", test_gengrid_speed);
+ ADD_TEST(NULL, "Lists - Gengrid", "GenGrid Item Focus", test_gengrid_item_focus);
//------------------------------//
ADD_TEST(NULL, "General", "Scaling", test_scaling);
diff --git a/legacy/elementary/src/bin/test_gengrid.c b/legacy/elementary/src/bin/test_gengrid.c
index 36658c9493..048a1c61a2 100644
--- a/legacy/elementary/src/bin/test_gengrid.c
+++ b/legacy/elementary/src/bin/test_gengrid.c
@@ -1304,6 +1304,96 @@ test_gengrid_speed(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *e
elm_config_scale_get() * 36);
elm_object_content_set(fr, api->grid);
evas_object_show(api->grid);
+ evas_object_resize(win, 600, 600);
+ evas_object_show(win);
+}
+
+void
+test_gengrid_item_focus(void *data EINA_UNUSED,
+ Evas_Object *obj EINA_UNUSED,
+ void *event_info EINA_UNUSED)
+{
+ Evas_Object *win, *bx, *bx_horiz, *gengrid, *btn, *fr, *lb;
+ Elm_Gengrid_Item_Class *ic;
+ Item_Data *id;
+ char buf[PATH_MAX];
+ int i, n;
+
+ win = elm_win_util_standard_add("gengrid-item-focus", "Gengrid Item Focus");
+ elm_win_focus_highlight_enabled_set(win, EINA_TRUE);
+ elm_win_focus_highlight_animate_set(win, EINA_TRUE);
+ elm_win_autodel_set(win, EINA_TRUE);
+
+ bx_horiz = elm_box_add(win);
+ elm_box_horizontal_set(bx_horiz, EINA_TRUE);
+ evas_object_size_hint_weight_set(bx_horiz, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ elm_win_resize_object_add(win, bx_horiz);
+ evas_object_show(bx_horiz);
+
+ btn = elm_button_add(bx_horiz);
+ elm_object_text_set(btn, "Left");
+ elm_box_pack_end(bx_horiz, btn);
+ evas_object_show(btn);
+
+ bx = elm_box_add(bx_horiz);
+ evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(bx, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ elm_box_pack_end(bx_horiz, bx);
+ evas_object_show(bx);
+
+ fr = elm_frame_add(bx);
+ elm_object_text_set(fr, "Gengrid Item Focus");
+ elm_box_pack_end(bx, fr);
+ evas_object_show(fr);
+
+ lb = elm_label_add(fr);
+ elm_object_text_set(lb, "<align=left>Gengrid Item focus</align>");
+ elm_object_content_set(fr, lb);
+ evas_object_show(lb);
+
+ btn = elm_button_add(bx);
+ elm_object_text_set(btn, "Up");
+ elm_box_pack_end(bx, btn);
+ evas_object_show(btn);
+ elm_object_focus_set(btn, EINA_TRUE);
+
+ gengrid = elm_gengrid_add(bx);
+ elm_gengrid_item_size_set(gengrid,
+ elm_config_scale_get() * 150,
+ elm_config_scale_get() * 150);
+ evas_object_size_hint_weight_set(gengrid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(gengrid, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ elm_box_pack_end(bx, gengrid);
+ evas_object_show(gengrid);
+
+ btn = elm_button_add(bx);
+ elm_object_text_set(btn, "Down");
+ elm_box_pack_end(bx, btn);
+ evas_object_show(btn);
+
+ btn = elm_button_add(bx_horiz);
+ elm_object_text_set(btn, "Right");
+ elm_box_pack_end(bx_horiz, btn);
+ evas_object_show(btn);
+
+ ic = elm_gengrid_item_class_new();
+ ic->item_style = "default";
+ ic->func.text_get = grid_text_get;
+ ic->func.content_get = grid_content_get;
+ ic->func.state_get = NULL;
+ ic->func.del = grid_del;
+
+ n = 0;
+ for (i = 0; i < 24; i++)
+ {
+ id = calloc(1, sizeof(Item_Data));
+ snprintf(buf, sizeof(buf), "%s/images/%s", elm_app_data_dir_get(), img[n]);
+ n = (n + 1) % 9;
+ id->mode = i;
+ id->path = eina_stringshare_add(buf);
+ id->item = elm_gengrid_item_append(gengrid, ic, id, NULL, NULL);
+ }
+ elm_gengrid_item_class_free(ic);
evas_object_resize(win, 600, 600);
evas_object_show(win);
diff --git a/legacy/elementary/src/lib/elm_gengrid.c b/legacy/elementary/src/lib/elm_gengrid.c
index a223af0c07..b76dd43d43 100644
--- a/legacy/elementary/src/lib/elm_gengrid.c
+++ b/legacy/elementary/src/lib/elm_gengrid.c
@@ -67,6 +67,8 @@ EAPI const char ELM_GENGRID_PAN_SMART_NAME[] = "elm_gengrid_pan";
cmd(SIG_INDEX_UPDATE, "index,update", "") \
cmd(SIG_HIGHLIGHTED, "highlighted", "") \
cmd(SIG_UNHIGHLIGHTED, "unhighlighted", "") \
+ cmd(SIG_ITEM_FOCUSED, "item,focused", "") \
+ cmd(SIG_ITEM_UNFOCUSED, "item,unfocused", "") \
cmd(SIG_PRESSED, "pressed", "") \
cmd(SIG_RELEASED, "released", "")
@@ -78,6 +80,8 @@ static const Evas_Smart_Cb_Description _smart_callbacks[] = {
{SIG_WIDGET_ACCESS_CHANGED, ""}, /**< handled by elm_widget */
{SIG_LAYOUT_FOCUSED, ""}, /**< handled by elm_layout */
{SIG_LAYOUT_UNFOCUSED, ""}, /**< handled by elm_layout */
+ {SIG_ITEM_FOCUSED, ""},
+ {SIG_ITEM_UNFOCUSED, ""},
{NULL, NULL}
};
@@ -609,7 +613,12 @@ _item_mouse_up_cb(void *data,
if (it->want_unrealize)
_elm_gengrid_item_unrealize(it, EINA_FALSE);
}
+
if (elm_widget_item_disabled_get(it) || (dragged)) return;
+
+ if (sd->focused_item != (Elm_Object_Item *)it)
+ elm_object_item_focus_set((Elm_Object_Item *)it, EINA_TRUE);
+
if (sd->multi &&
((sd->multi_select_mode != ELM_OBJECT_MULTI_SELECT_MODE_WITH_CONTROL) ||
(evas_key_modifier_is_set(ev->modifiers, "Control"))))
@@ -883,6 +892,8 @@ _item_realize(Elm_Gen_Item *it)
if (it->mouse_cursor)
elm_widget_item_cursor_set(it, it->mouse_cursor);
+ _elm_widget_item_highlight_in_theme(WIDGET(it), (Elm_Object_Item *)it);
+
it->realized = EINA_TRUE;
it->want_unrealize = EINA_FALSE;
}
@@ -1311,16 +1322,17 @@ _elm_gengrid_pan_smart_calculate(Eo *obj EINA_UNUSED, void *_pd, va_list *list E
Elm_Gen_Item *it;
Elm_Gengrid_Pan_Smart_Data *psd = _pd;
+ Elm_Gengrid_Smart_Data *sd = psd->wsd;
- if (!psd->wsd->nmax) return;
+ if (!sd->nmax) return;
- psd->wsd->reorder_item_changed = EINA_FALSE;
+ sd->reorder_item_changed = EINA_FALSE;
- EINA_INLIST_FOREACH(psd->wsd->items, it)
+ EINA_INLIST_FOREACH(sd->items, it)
{
if (it->group)
{
- if (psd->wsd->horizontal)
+ if (sd->horizontal)
{
if (cy)
{
@@ -1339,10 +1351,10 @@ _elm_gengrid_pan_smart_calculate(Eo *obj EINA_UNUSED, void *_pd, va_list *list E
}
_item_place(it, cx, cy);
- if (psd->wsd->reorder_item_changed) return;
+ if (sd->reorder_item_changed) return;
if (it->group)
{
- if (psd->wsd->horizontal)
+ if (sd->horizontal)
{
cx++;
cy = 0;
@@ -1355,32 +1367,35 @@ _elm_gengrid_pan_smart_calculate(Eo *obj EINA_UNUSED, void *_pd, va_list *list E
}
else
{
- if (psd->wsd->horizontal)
+ if (sd->horizontal)
{
- cy = (cy + 1) % psd->wsd->nmax;
+ cy = (cy + 1) % sd->nmax;
if (!cy) cx++;
}
else
{
- cx = (cx + 1) % psd->wsd->nmax;
+ cx = (cx + 1) % sd->nmax;
if (!cx) cy++;
}
}
}
_group_item_place(psd);
- if ((psd->wsd->reorder_mode) && (psd->wsd->reorder_it))
+ if ((sd->reorder_mode) && (sd->reorder_it))
{
- if (!psd->wsd->reorder_item_changed)
+ if (!sd->reorder_item_changed)
{
- psd->wsd->old_pan_x = psd->wsd->pan_x;
- psd->wsd->old_pan_y = psd->wsd->pan_y;
+ sd->old_pan_x = sd->pan_x;
+ sd->old_pan_y = sd->pan_y;
}
- psd->wsd->move_effect_enabled = EINA_FALSE;
+ sd->move_effect_enabled = EINA_FALSE;
}
evas_object_smart_callback_call
(psd->wobj, SIG_CHANGED, NULL);
+
+ if (sd->focused_item)
+ _elm_widget_focus_highlight_start(psd->wobj);
}
static void
@@ -1484,6 +1499,180 @@ static const Eo_Class_Description _elm_obj_gengrid_pan_class_desc = {
EO_DEFINE_CLASS(elm_obj_gengrid_pan_class_get, &_elm_obj_gengrid_pan_class_desc, ELM_OBJ_PAN_CLASS, NULL);
+static void
+_elm_gengrid_item_focused(Elm_Gen_Item *it)
+{
+ Evas_Object *obj = WIDGET(it);
+ Elm_Gengrid_Smart_Data *sd = GG_IT(it)->wsd;
+ const char *focus_raise;
+
+ if (it->generation < sd->generation)
+ return;
+
+ if ((sd->select_mode == ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY) ||
+ (it->select_mode == ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY) ||
+ (it == (Elm_Gen_Item *)sd->focused_item) ||
+ (elm_widget_item_disabled_get(it)))
+ return;
+
+ elm_gengrid_item_bring_in
+ ((Elm_Object_Item *)it, ELM_GENGRID_ITEM_SCROLLTO_IN);
+ sd->focused_item = (Elm_Object_Item *)it;
+
+ if (elm_widget_focus_highlight_enabled_get(obj))
+ {
+ edje_object_signal_emit
+ (VIEW(it), "elm,state,focused", "elm");
+ }
+
+ focus_raise = edje_object_data_get(VIEW(it), "focusraise");
+ if ((focus_raise) && (!strcmp(focus_raise, "on")))
+ evas_object_raise(VIEW(it));
+ evas_object_smart_callback_call
+ (WIDGET(it), SIG_ITEM_FOCUSED, it);
+}
+
+static void
+_elm_gengrid_item_unfocused(Elm_Gen_Item *it)
+{
+ Elm_Gengrid_Smart_Data *sd = GG_IT(it)->wsd;
+
+ if (it->generation < sd->generation)
+ return;
+
+ if ((sd->select_mode == ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY) ||
+ (it->select_mode == ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY))
+ return;
+
+ if ((!sd->focused_item) ||
+ (it != (Elm_Gen_Item *)sd->focused_item))
+ return;
+
+ sd->prev_focused_item = (Elm_Object_Item *)it;
+
+ edje_object_signal_emit
+ (VIEW(sd->focused_item), "elm,state,unfocused", "elm");
+
+ sd->focused_item = NULL;
+ evas_object_smart_callback_call
+ (WIDGET(it), SIG_ITEM_UNFOCUSED, it);
+}
+
+static Eina_Bool
+_item_focus_up(Elm_Gengrid_Smart_Data *sd)
+{
+ unsigned int i;
+ Elm_Gen_Item *prev;
+
+ if (!sd->focused_item)
+ {
+ prev = ELM_GEN_ITEM_FROM_INLIST(sd->items->last);
+ while ((prev) && (prev->generation < sd->generation))
+ prev = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
+ elm_object_item_focus_set((Elm_Object_Item *)prev, EINA_TRUE);
+ return EINA_TRUE;
+ }
+ else
+ {
+ prev = (Elm_Gen_Item *)elm_gengrid_item_prev_get(sd->focused_item);
+ if (!prev) return EINA_FALSE;
+ if(prev == (Elm_Gen_Item *)sd->focused_item) return EINA_FALSE;
+ }
+
+ for (i = 1; i < sd->nmax; i++)
+ {
+ Elm_Object_Item *tmp =
+ elm_gengrid_item_prev_get((Elm_Object_Item *)prev);
+ if (!tmp) return EINA_FALSE;
+ prev = (Elm_Gen_Item *)tmp;
+ }
+
+ elm_object_item_focus_set((Elm_Object_Item *)prev, EINA_TRUE);
+
+ return EINA_TRUE;
+}
+
+static Eina_Bool
+_item_focus_down(Elm_Gengrid_Smart_Data *sd)
+{
+ unsigned int i;
+ Elm_Gen_Item *next;
+
+ if (!sd->focused_item)
+ {
+ next = ELM_GEN_ITEM_FROM_INLIST(sd->items);
+ while ((next) && (next->generation < sd->generation))
+ next = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
+
+ elm_object_item_focus_set((Elm_Object_Item *)next, EINA_TRUE);
+ return EINA_TRUE;
+ }
+ else
+ {
+ next = (Elm_Gen_Item *)elm_gengrid_item_next_get(sd->focused_item);
+ if (!next) return EINA_FALSE;
+ if (next == (Elm_Gen_Item *)sd->focused_item) return EINA_FALSE;
+ }
+
+ for (i = 1; i < sd->nmax; i++)
+ {
+ Elm_Object_Item *tmp =
+ elm_gengrid_item_next_get((Elm_Object_Item *)next);
+ if (!tmp) return EINA_FALSE;
+ next = (Elm_Gen_Item *)tmp;
+ }
+
+ elm_object_item_focus_set((Elm_Object_Item *)next, EINA_TRUE);
+
+ return EINA_TRUE;
+}
+
+static Eina_Bool
+_item_focus_left(Elm_Gengrid_Smart_Data *sd)
+{
+ Elm_Gen_Item *prev;
+
+ if (!sd->focused_item)
+ {
+ prev = ELM_GEN_ITEM_FROM_INLIST(sd->items->last);
+ while ((prev) && (prev->generation < sd->generation))
+ prev = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
+ }
+ else
+ {
+ prev = (Elm_Gen_Item *)elm_gengrid_item_prev_get(sd->focused_item);
+ if (!prev) return EINA_FALSE;
+ if (prev == (Elm_Gen_Item *)sd->focused_item) return EINA_FALSE;
+ }
+
+ elm_object_item_focus_set((Elm_Object_Item *)prev, EINA_TRUE);
+
+ return EINA_TRUE;
+}
+
+static Eina_Bool
+_item_focus_right(Elm_Gengrid_Smart_Data *sd)
+{
+ Elm_Gen_Item *next;
+
+ if (!sd->focused_item)
+ {
+ next = ELM_GEN_ITEM_FROM_INLIST(sd->items);
+ while ((next) && (next->generation < sd->generation))
+ next = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
+ }
+ else
+ {
+ next = (Elm_Gen_Item *)elm_gengrid_item_next_get(sd->focused_item);
+ if (!next) return EINA_FALSE;
+ if (next == (Elm_Gen_Item *)sd->focused_item) return EINA_FALSE;
+ }
+
+ elm_object_item_focus_set((Elm_Object_Item *)next, EINA_TRUE);
+
+ return EINA_TRUE;
+}
+
static Eina_Bool
_item_multi_select_left(Elm_Gengrid_Smart_Data *sd)
{
@@ -1588,8 +1777,6 @@ _item_single_select_up(Elm_Gengrid_Smart_Data *sd)
while ((prev) && (prev->generation < sd->generation))
prev = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(prev)->prev);
elm_gengrid_item_selected_set((Elm_Object_Item *)prev, EINA_TRUE);
- elm_gengrid_item_show
- ((Elm_Object_Item *)prev, ELM_GENGRID_ITEM_SCROLLTO_IN);
return EINA_TRUE;
}
else
@@ -1608,8 +1795,7 @@ _item_single_select_up(Elm_Gengrid_Smart_Data *sd)
_all_items_deselect(sd);
elm_gengrid_item_selected_set((Elm_Object_Item *)prev, EINA_TRUE);
- elm_gengrid_item_show
- ((Elm_Object_Item *)prev, ELM_GENGRID_ITEM_SCROLLTO_IN);
+
return EINA_TRUE;
}
@@ -1625,8 +1811,6 @@ _item_single_select_down(Elm_Gengrid_Smart_Data *sd)
while ((next) && (next->generation < sd->generation))
next = ELM_GEN_ITEM_FROM_INLIST(EINA_INLIST_GET(next)->next);
elm_gengrid_item_selected_set((Elm_Object_Item *)next, EINA_TRUE);
- elm_gengrid_item_show
- ((Elm_Object_Item *)next, ELM_GENGRID_ITEM_SCROLLTO_IN);
return EINA_TRUE;
}
else
@@ -1645,8 +1829,6 @@ _item_single_select_down(Elm_Gengrid_Smart_Data *sd)
_all_items_deselect(sd);
elm_gengrid_item_selected_set((Elm_Object_Item *)next, EINA_TRUE);
- elm_gengrid_item_show
- ((Elm_Object_Item *)next, ELM_GENGRID_ITEM_SCROLLTO_IN);
return EINA_TRUE;
}
@@ -1670,8 +1852,6 @@ _item_single_select_left(Elm_Gengrid_Smart_Data *sd)
_all_items_deselect(sd);
elm_gengrid_item_selected_set((Elm_Object_Item *)prev, EINA_TRUE);
- elm_gengrid_item_show
- ((Elm_Object_Item *)prev, ELM_GENGRID_ITEM_SCROLLTO_IN);
return EINA_TRUE;
}
@@ -1695,8 +1875,6 @@ _item_single_select_right(Elm_Gengrid_Smart_Data *sd)
_all_items_deselect(sd);
elm_gengrid_item_selected_set((Elm_Object_Item *)next, EINA_TRUE);
- elm_gengrid_item_show
- ((Elm_Object_Item *)next, ELM_GENGRID_ITEM_SCROLLTO_IN);
return EINA_TRUE;
}
@@ -1744,7 +1922,6 @@ _elm_gengrid_smart_event(Eo *obj, void *_pd, va_list *list)
{
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
if (ret) *ret = EINA_TRUE;
- return;
}
else if ((!sd->horizontal) &&
(((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
@@ -1753,10 +1930,36 @@ _elm_gengrid_smart_event(Eo *obj, void *_pd, va_list *list)
{
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
if (ret) *ret = EINA_TRUE;
- return;
}
else
x -= step_x;
+
+ if (sd->horizontal)
+ {
+ if (_item_focus_up(sd))
+ {
+ ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
+ if (ret) *ret = EINA_TRUE;
+ }
+ else
+ {
+ if (ret) *ret = EINA_FALSE;
+ }
+ }
+ else
+ {
+ if (_item_focus_left(sd))
+ {
+ ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
+ if (ret) *ret = EINA_TRUE;
+ }
+ else
+ {
+ if (ret) *ret = EINA_FALSE;
+ }
+ }
+
+ return;
}
else if ((!strcmp(ev->key, "Right")) ||
((!strcmp(ev->key, "KP_Right")) && (!ev->string)))
@@ -1768,7 +1971,6 @@ _elm_gengrid_smart_event(Eo *obj, void *_pd, va_list *list)
{
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
if (ret) *ret = EINA_TRUE;
- return;
}
else if ((!sd->horizontal) &&
(((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
@@ -1777,10 +1979,36 @@ _elm_gengrid_smart_event(Eo *obj, void *_pd, va_list *list)
{
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
if (ret) *ret = EINA_TRUE;
- return;
}
else
x += step_x;
+
+ if (sd->horizontal)
+ {
+ if (_item_focus_down(sd))
+ {
+ ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
+ if (ret) *ret = EINA_TRUE;
+ }
+ else
+ {
+ if (ret) *ret = EINA_FALSE;
+ }
+ }
+ else
+ {
+ if (_item_focus_right(sd))
+ {
+ ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
+ if (ret) *ret = EINA_TRUE;
+ }
+ else
+ {
+ if (ret) *ret = EINA_FALSE;
+ }
+ }
+
+ return;
}
else if ((!strcmp(ev->key, "Up")) ||
((!strcmp(ev->key, "KP_Up")) && (!ev->string)))
@@ -1792,7 +2020,6 @@ _elm_gengrid_smart_event(Eo *obj, void *_pd, va_list *list)
{
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
if (ret) *ret = EINA_TRUE;
- return;
}
else if ((!sd->horizontal) &&
(((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
@@ -1801,10 +2028,36 @@ _elm_gengrid_smart_event(Eo *obj, void *_pd, va_list *list)
{
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
if (ret) *ret = EINA_TRUE;
- return;
}
else
y -= step_y;
+
+ if (sd->horizontal)
+ {
+ if (_item_focus_left(sd))
+ {
+ ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
+ if (ret) *ret = EINA_TRUE;
+ }
+ else
+ {
+ if (ret) *ret = EINA_FALSE;
+ }
+ }
+ else
+ {
+ if (_item_focus_up(sd))
+ {
+ ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
+ if (ret) *ret = EINA_TRUE;
+ }
+ else
+ {
+ if (ret) *ret = EINA_FALSE;
+ }
+ }
+
+ return;
}
else if ((!strcmp(ev->key, "Down")) ||
((!strcmp(ev->key, "KP_Down")) && (!ev->string)))
@@ -1816,7 +2069,6 @@ _elm_gengrid_smart_event(Eo *obj, void *_pd, va_list *list)
{
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
if (ret) *ret = EINA_TRUE;
- return;
}
else if ((!sd->horizontal) &&
(((evas_key_modifier_is_set(ev->modifiers, "Shift")) &&
@@ -1825,10 +2077,36 @@ _elm_gengrid_smart_event(Eo *obj, void *_pd, va_list *list)
{
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
if (ret) *ret = EINA_TRUE;
- return;
}
else
y += step_y;
+
+ if (sd->horizontal)
+ {
+ if (_item_focus_right(sd))
+ {
+ ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
+ if (ret) *ret = EINA_TRUE;
+ }
+ else
+ {
+ if (ret) *ret = EINA_FALSE;
+ }
+ }
+ else
+ {
+ if (_item_focus_down(sd))
+ {
+ ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
+ if (ret) *ret = EINA_TRUE;
+ }
+ else
+ {
+ if (ret) *ret = EINA_FALSE;
+ }
+ }
+
+ return;
}
else if ((!strcmp(ev->key, "Home")) ||
((!strcmp(ev->key, "KP_Home")) && (!ev->string)))
@@ -1915,6 +2193,7 @@ _elm_gengrid_smart_on_focus(Eo *obj, void *_pd EINA_UNUSED, va_list *list)
if (ret) *ret = EINA_FALSE;
Eina_Bool int_ret = EINA_FALSE;
Elm_Gengrid_Smart_Data *sd = _pd;
+ Elm_Object_Item *it = NULL;
eo_do_super(obj, MY_CLASS, elm_obj_widget_on_focus(&int_ret));
if (!int_ret) return;
@@ -1923,6 +2202,29 @@ _elm_gengrid_smart_on_focus(Eo *obj, void *_pd EINA_UNUSED, va_list *list)
(!sd->last_selected_item))
sd->last_selected_item = eina_list_data_get(sd->selected);
+ if (elm_widget_focus_get(obj))
+ {
+ if (sd->last_focused_item)
+ elm_object_item_focus_set(sd->last_focused_item, EINA_TRUE);
+ else if (sd->last_selected_item)
+ elm_object_item_focus_set(sd->last_selected_item, EINA_TRUE);
+ else
+ {
+ it = elm_gengrid_first_item_get(obj);
+ elm_object_item_focus_set(it, EINA_TRUE);
+ }
+ _elm_widget_focus_highlight_start(obj);
+ }
+ else
+ {
+ if (sd->focused_item)
+ {
+ sd->prev_focused_item = sd->focused_item;
+ sd->last_focused_item = sd->focused_item;
+ _elm_gengrid_item_unfocused((Elm_Gen_Item *)sd->focused_item);
+ }
+ }
+
if (ret) *ret = EINA_TRUE;
}
@@ -2030,6 +2332,12 @@ _elm_gengrid_item_del_not_serious(Elm_Gen_Item *it)
sd->selected = eina_list_remove(sd->selected, it);
if (sd->last_selected_item == (Elm_Object_Item *)it)
sd->last_selected_item = NULL;
+ if (sd->focused_item == (Elm_Object_Item *)it)
+ sd->focused_item = NULL;
+ if (sd->last_focused_item == (Elm_Object_Item *)it)
+ sd->last_focused_item = NULL;
+ if (sd->prev_focused_item == (Elm_Object_Item *)it)
+ sd->prev_focused_item = NULL;
if (it->itc->func.del)
it->itc->func.del((void *)it->base.data, WIDGET(it));
@@ -2217,6 +2525,43 @@ _item_signal_emit_hook(Elm_Object_Item *it,
}
static void
+_item_focus_set_hook(Elm_Object_Item *it, Eina_Bool focused)
+{
+ ELM_GENGRID_ITEM_CHECK_OR_RETURN(it);
+ Evas_Object *obj = WIDGET(it);
+ ELM_GENGRID_DATA_GET(obj, sd);
+
+ if (focused)
+ {
+ if (!elm_object_focus_get(obj))
+ elm_object_focus_set(obj, EINA_TRUE);
+
+ if (it != sd->focused_item)
+ {
+ if (sd->focused_item)
+ _elm_gengrid_item_unfocused((Elm_Gen_Item *)sd->focused_item);
+ _elm_gengrid_item_focused((Elm_Gen_Item *)it);
+ _elm_widget_focus_highlight_start(obj);
+ }
+ }
+ else
+ _elm_gengrid_item_unfocused((Elm_Gen_Item *)it);
+}
+
+static Eina_Bool
+_item_focus_get_hook(Elm_Object_Item *it)
+{
+ ELM_GENGRID_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
+ Evas_Object *obj = WIDGET(it);
+ ELM_GENGRID_DATA_GET(obj, sd);
+
+ if (it == sd->focused_item)
+ return EINA_TRUE;
+
+ return EINA_FALSE;
+}
+
+static void
_elm_gengrid_clear(Evas_Object *obj,
Eina_Bool standby)
{
@@ -2341,6 +2686,9 @@ _elm_gengrid_item_new(Elm_Gengrid_Smart_Data *sd,
elm_widget_item_disable_hook_set(it, _item_disable_hook);
elm_widget_item_del_pre_hook_set(it, _item_del_pre_hook);
elm_widget_item_signal_emit_hook_set(it, _item_signal_emit_hook);
+ elm_widget_item_focus_set_hook_set(it, _item_focus_set_hook);
+ elm_widget_item_focus_get_hook_set(it, _item_focus_get_hook);
+
it->del_cb = (Ecore_Cb)_item_del;
it->highlight_cb = (Ecore_Cb)_item_highlight;
@@ -4060,6 +4408,68 @@ elm_gengrid_nth_item_get(const Evas_Object *obj, unsigned int nth)
}
static void
+_elm_gengrid_focus_highlight_geometry_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
+{
+ Evas_Coord *x = va_arg(*list, Evas_Coord *);
+ Evas_Coord *y = va_arg(*list, Evas_Coord *);
+ Evas_Coord *w = va_arg(*list, Evas_Coord *);
+ Evas_Coord *h = va_arg(*list, Evas_Coord *);
+ Eina_Bool is_next = va_arg(*list, int);
+ Evas_Coord ox, oy, oh, item_x = 0, item_y = 0, item_w = 0, item_h = 0;
+
+ Elm_Gengrid_Smart_Data *sd = _pd;
+ evas_object_geometry_get(obj, &ox, &oy, NULL, &oh);
+
+ if (is_next)
+ {
+ if (sd->focused_item)
+ {
+ evas_object_geometry_get(VIEW(sd->focused_item), &item_x, &item_y, &item_w, &item_h);
+ elm_widget_focus_highlight_focus_part_geometry_get(VIEW(sd->focused_item), &item_x, &item_y, &item_w, &item_h);
+ }
+ }
+ else
+ {
+ if (sd->prev_focused_item)
+ {
+ evas_object_geometry_get(VIEW(sd->prev_focused_item), &item_x, &item_y, &item_w, &item_h);
+ elm_widget_focus_highlight_focus_part_geometry_get(VIEW(sd->prev_focused_item), &item_x, &item_y, &item_w, &item_h);
+ }
+ }
+
+ if (item_y < oy)
+ {
+ *x = item_x;
+ *y = oy;
+ *w = item_w;
+ *h = item_h;
+ }
+ else if (item_y > (oy + oh - item_h))
+ {
+ *x = item_x;
+ *y = oy + oh - item_h;
+ *w = item_w;
+ *h = item_h;
+ }
+ else
+ {
+ *x = item_x;
+ *y = item_y;
+ *w = item_w;
+ *h = item_h;
+ }
+}
+
+static void
+_elm_gengrid_focused_item_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
+{
+ Elm_Object_Item **ret = va_arg(*list, Elm_Object_Item **);
+ Elm_Gengrid_Smart_Data *sd = _pd;
+
+ if (ret) *ret = sd->focused_item;
+}
+
+static void
_class_constructor(Eo_Class *klass)
{
const Eo_Op_Func_Description func_desc[] = {
@@ -4078,6 +4488,8 @@ _class_constructor(Eo_Class *klass)
EO_OP_FUNC(ELM_OBJ_WIDGET_ID(ELM_OBJ_WIDGET_SUB_ID_FOCUS_NEXT), _elm_gengrid_smart_focus_next),
EO_OP_FUNC(ELM_OBJ_WIDGET_ID(ELM_OBJ_WIDGET_SUB_ID_ACCESS), _elm_gengrid_smart_access),
EO_OP_FUNC(ELM_OBJ_WIDGET_ID(ELM_OBJ_WIDGET_SUB_ID_FOCUS_DIRECTION_MANAGER_IS), _elm_gengrid_smart_focus_direction_manager_is),
+ EO_OP_FUNC(ELM_OBJ_WIDGET_ID(ELM_OBJ_WIDGET_SUB_ID_FOCUS_HIGHLIGHT_GEOMETRY_GET), _elm_gengrid_focus_highlight_geometry_get),
+ EO_OP_FUNC(ELM_OBJ_WIDGET_ID(ELM_OBJ_WIDGET_SUB_ID_FOCUSED_ITEM_GET), _elm_gengrid_focused_item_get),
EO_OP_FUNC(ELM_OBJ_LAYOUT_ID(ELM_OBJ_LAYOUT_SUB_ID_SIZING_EVAL), _elm_gengrid_smart_sizing_eval),
diff --git a/legacy/elementary/src/lib/elm_gengrid.h b/legacy/elementary/src/lib/elm_gengrid.h
index e850146d63..405b75269c 100644
--- a/legacy/elementary/src/lib/elm_gengrid.h
+++ b/legacy/elementary/src/lib/elm_gengrid.h
@@ -237,6 +237,8 @@
* be translated.
* - @c "focused" - When the gengrid has received focus. (since 1.8)
* - @c "unfocused" - When the gengrid has lost focus. (since 1.8)
+ * - @c "item,focused" - When the gengrid item has received focus. (since 1.10)
+ * - @c "item,unfocused" - When the gengrid item has lost focus. (since 1.10)
*
* Supported elm_object common APIs
* @li elm_object_signal_emit()
diff --git a/legacy/elementary/src/lib/elm_widget_gengrid.h b/legacy/elementary/src/lib/elm_widget_gengrid.h
index 52a4ea0fd6..e5394e53cd 100644
--- a/legacy/elementary/src/lib/elm_widget_gengrid.h
+++ b/legacy/elementary/src/lib/elm_widget_gengrid.h
@@ -38,6 +38,9 @@ struct _Elm_Gengrid_Smart_Data
* being
* repositioned */
Elm_Object_Item *last_selected_item;
+ Elm_Object_Item *focused_item; /**< a focused item by keypad arrow or mouse. This is set to NULL if widget looses focus. */
+ Elm_Object_Item *last_focused_item; /**< This records the last focused item when widget looses focus. This is required to set the focus on last focused item when widgets gets focus. */
+ Elm_Object_Item *prev_focused_item; /**< a previous focused item by keypad arrow or mouse. */
Elm_Gen_Item *show_it;
Elm_Gen_Item *bring_in_it;
Elm_Gengrid_Item_Scrollto_Type scroll_to_type;