summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJehun Lim <jehun.lim@samsung.com>2015-09-30 17:05:23 +0900
committerJehun Lim <jehun.lim@samsung.com>2015-09-30 17:05:23 +0900
commit242a22d3de6ce22a806b9d96c5ca73609c236caa (patch)
tree354a3a3a119693ff7143d8ee30993501a013afae
parent78e8e210cb8dfc8eeda5a806a99e5287a7f39680 (diff)
downloadair_mediahub-242a22d3de6ce22a806b9d96c5ca73609c236caa.tar.gz
air_mediahub-242a22d3de6ce22a806b9d96c5ca73609c236caa.tar.bz2
air_mediahub-242a22d3de6ce22a806b9d96c5ca73609c236caa.zip
listmgr: add focus policy for grid item
Change-Id: If9aa57805f553f8d4d8717fcadd181acfdcd6c06 Signed-off-by: Jehun Lim <jehun.lim@samsung.com>
-rw-r--r--src/util/listmgr.c99
1 files changed, 99 insertions, 0 deletions
diff --git a/src/util/listmgr.c b/src/util/listmgr.c
index 6d9df60..83d20d7 100644
--- a/src/util/listmgr.c
+++ b/src/util/listmgr.c
@@ -435,6 +435,8 @@ static Evas_Object *_add_list_item_grid(struct listmgr *lmgr,
elm_object_focus_next_object_set(grid, lmgr->data->view_btn,
ELM_FOCUS_DOWN);
+ elm_object_focus_region_show_mode_set(grid, ELM_FOCUS_REGION_SHOW_ITEM);
+
inputmgr_add_callback(grid, LISTMGR_GRID, &_grid_handler, lmgr);
return grid;
@@ -668,6 +670,101 @@ bool listmgr_update_content_item(struct listmgr *lmgr)
return true;
}
+static void _set_prev_grid_focus(Evas_Object *prev, Evas_Object *cur,
+ int item_col)
+{
+ Elm_Object_Item *it, *prev_last_it, *cur_first_it;
+ int prev_cnt;
+ int prev_last, cur_first, num_set;
+
+ prev_cnt = elm_gengrid_items_count(prev);
+
+ prev_last = prev_cnt % item_col;
+ if (!prev_last)
+ return;
+
+ cur_first = elm_gengrid_items_count(cur);
+ if (cur_first > item_col)
+ cur_first = item_col;
+
+ if (prev_last >= cur_first)
+ return;
+
+ /* items to be set next item as last item of previous grid */
+ num_set = cur_first - prev_last;
+
+ prev_last_it = elm_gengrid_last_item_get(prev);
+ cur_first_it = elm_gengrid_first_item_get(cur);
+
+ it = cur_first_it;
+ while (prev_last--)
+ it = elm_gengrid_item_next_get(it);
+
+ while (num_set--) {
+ elm_object_item_focus_next_item_set(it, prev_last_it,
+ ELM_FOCUS_LEFT);
+ it = elm_gengrid_item_next_get(it);
+ }
+}
+
+static void _set_current_grid_focus(Evas_Object *grid, int item_col)
+{
+ Elm_Object_Item *it, *last_it;
+ int cnt;
+ int num_last, num_set;
+
+ cnt = elm_gengrid_items_count(grid);
+
+ if (cnt <= item_col)
+ return;
+
+ num_last = cnt % item_col;
+ if (!num_last)
+ return;
+
+ /* items to be set next item as last item */
+ num_set = item_col - num_last;
+
+ last_it = elm_gengrid_last_item_get(grid);
+
+ it = last_it;
+ while (num_last--)
+ it = elm_gengrid_item_prev_get(it);
+
+ while (num_set--) {
+ elm_object_item_focus_next_item_set(it, last_it,
+ ELM_FOCUS_RIGHT);
+ it = elm_gengrid_item_prev_get(it);
+ }
+}
+
+static void _set_grid_focus(struct listmgr *lmgr)
+{
+ Eina_List *list, *l;
+ Evas_Object *ly;
+ Evas_Object *prev, *cur;
+ int item_num;
+
+ list = elm_box_children_get(lmgr->box);
+
+ if (lmgr->play_info)
+ list = eina_list_next(list);
+
+ item_num = lmgr->data->gdata->item_num;
+
+ prev = NULL;
+ EINA_LIST_FOREACH(list, l, ly) {
+ cur = elm_object_part_content_get(ly, PART_ITEM_CONTENT);
+
+ if (prev)
+ _set_prev_grid_focus(prev, cur, item_num);
+
+ _set_current_grid_focus(cur, item_num);
+
+ prev = cur;
+ }
+}
+
void listmgr_clear_content_list(struct listmgr *lmgr)
{
Eina_List *list, *l;
@@ -744,6 +841,8 @@ bool listmgr_update_content_list(struct listmgr *lmgr, Eina_List *list,
grid = elm_object_part_content_get(ly, PART_ITEM_CONTENT);
elm_object_focus_next_object_set(grid, grid, ELM_FOCUS_RIGHT);
+ _set_grid_focus(lmgr);
+
lmgr->focused = _get_box_first_item(lmgr->box);
elm_object_focus_allow_set(lmgr->scr, EINA_TRUE);