From c1740912848c2f90bcf72aea42b672b4adeaa439 Mon Sep 17 00:00:00 2001 From: Sanjeev BA Date: Wed, 7 Mar 2012 12:57:17 +0000 Subject: [PATCH] Add top,middle bring_in and show support to gengrid. Implementation to be done later. Signed-off-by: Sanjeev BA SVN revision: 68943 --- src/bin/test_gengrid.c | 2 +- src/examples/gengrid_example.c | 4 ++-- src/examples/index_example_02.c | 2 +- src/lib/elm_gengrid.c | 38 ++++++++++++++++++++++++-------------- src/lib/elm_gengrid.h | 26 ++++++++++++++++++-------- 5 files changed, 46 insertions(+), 26 deletions(-) diff --git a/src/bin/test_gengrid.c b/src/bin/test_gengrid.c index 406c1ea..015aaac 100644 --- a/src/bin/test_gengrid.c +++ b/src/bin/test_gengrid.c @@ -38,7 +38,7 @@ set_api_state(api_data *api) break; case GRID_BRING_IN: /* 1 */ - elm_gengrid_item_bring_in(elm_gengrid_first_item_get(grid)); + elm_gengrid_item_bring_in(elm_gengrid_first_item_get(grid), ELM_GENGRID_ITEM_SCROLLTO_IN); break; case GRID_NO_SELECT_MODE: /* 2 */ diff --git a/src/examples/gengrid_example.c b/src/examples/gengrid_example.c index b75734c..51c4293 100644 --- a/src/examples/gengrid_example.c +++ b/src/examples/gengrid_example.c @@ -237,7 +237,7 @@ _bring_1st_clicked(void *data, if (!gg_it) return; - elm_gengrid_item_bring_in(gg_it); + elm_gengrid_item_bring_in(gg_it, ELM_GENGRID_ITEM_SCROLLTO_IN); } /* show last item */ @@ -250,7 +250,7 @@ _show_last_clicked(void *data, if (!gg_it) return; - elm_gengrid_item_show(gg_it); + elm_gengrid_item_show(gg_it, ELM_GENGRID_ITEM_SCROLLTO_IN); } /* disable selected item */ diff --git a/src/examples/index_example_02.c b/src/examples/index_example_02.c index a056746..5e2df84 100644 --- a/src/examples/index_example_02.c +++ b/src/examples/index_example_02.c @@ -34,7 +34,7 @@ _index_changed(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info) { - elm_gengrid_item_bring_in(event_info); + elm_gengrid_item_bring_in(event_info, ELM_GENGRID_ITEM_SCROLLTO_IN); } static void diff --git a/src/lib/elm_gengrid.c b/src/lib/elm_gengrid.c index 3358b3b..0c5794c 100644 --- a/src/lib/elm_gengrid.c +++ b/src/lib/elm_gengrid.c @@ -275,7 +275,7 @@ _event_hook(Evas_Object *obj, else if ((!strcmp(ev->keyname, "Home")) || (!strcmp(ev->keyname, "KP_Home"))) { it = elm_gengrid_first_item_get(obj); - elm_gengrid_item_bring_in(it); + elm_gengrid_item_bring_in(it, ELM_GENGRID_ITEM_SCROLLTO_IN); elm_gengrid_item_selected_set(it, EINA_TRUE); ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD; return EINA_TRUE; @@ -283,7 +283,7 @@ _event_hook(Evas_Object *obj, else if ((!strcmp(ev->keyname, "End")) || (!strcmp(ev->keyname, "KP_End"))) { it = elm_gengrid_last_item_get(obj); - elm_gengrid_item_bring_in(it); + elm_gengrid_item_bring_in(it, ELM_GENGRID_ITEM_SCROLLTO_IN); elm_gengrid_item_selected_set(it, EINA_TRUE); ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD; return EINA_TRUE; @@ -366,12 +366,12 @@ _item_multi_select_left(Widget_Data *wd) { elm_gengrid_item_selected_set(wd->last_selected_item, EINA_FALSE); wd->last_selected_item = prev; - elm_gengrid_item_show(wd->last_selected_item); + elm_gengrid_item_show(wd->last_selected_item, ELM_GENGRID_ITEM_SCROLLTO_IN); } else { elm_gengrid_item_selected_set(prev, EINA_TRUE); - elm_gengrid_item_show(prev); + elm_gengrid_item_show(prev, ELM_GENGRID_ITEM_SCROLLTO_IN); } return EINA_TRUE; @@ -389,12 +389,12 @@ _item_multi_select_right(Widget_Data *wd) { elm_gengrid_item_selected_set(wd->last_selected_item, EINA_FALSE); wd->last_selected_item = next; - elm_gengrid_item_show(wd->last_selected_item); + elm_gengrid_item_show(wd->last_selected_item, ELM_GENGRID_ITEM_SCROLLTO_IN); } else { elm_gengrid_item_selected_set(next, EINA_TRUE); - elm_gengrid_item_show(next); + elm_gengrid_item_show(next, ELM_GENGRID_ITEM_SCROLLTO_IN); } return EINA_TRUE; @@ -441,7 +441,7 @@ _item_single_select_up(Widget_Data *wd) while ((prev) && (prev->generation < wd->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_show((Elm_Object_Item *) prev, ELM_GENGRID_ITEM_SCROLLTO_IN); return EINA_TRUE; } else @@ -460,7 +460,7 @@ _item_single_select_up(Widget_Data *wd) _deselect_all_items(wd); elm_gengrid_item_selected_set((Elm_Object_Item *) prev, EINA_TRUE); - elm_gengrid_item_show((Elm_Object_Item *) prev); + elm_gengrid_item_show((Elm_Object_Item *) prev, ELM_GENGRID_ITEM_SCROLLTO_IN); return EINA_TRUE; } @@ -477,7 +477,7 @@ _item_single_select_down(Widget_Data *wd) while ((next) && (next->generation < wd->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_show((Elm_Object_Item *) next, ELM_GENGRID_ITEM_SCROLLTO_IN); return EINA_TRUE; } else @@ -496,7 +496,7 @@ _item_single_select_down(Widget_Data *wd) _deselect_all_items(wd); elm_gengrid_item_selected_set((Elm_Object_Item *) next, EINA_TRUE); - elm_gengrid_item_show((Elm_Object_Item *) next); + elm_gengrid_item_show((Elm_Object_Item *) next, ELM_GENGRID_ITEM_SCROLLTO_IN); return EINA_TRUE; } @@ -518,7 +518,7 @@ _item_single_select_left(Widget_Data *wd) _deselect_all_items(wd); elm_gengrid_item_selected_set((Elm_Object_Item *) prev, EINA_TRUE); - elm_gengrid_item_show((Elm_Object_Item *) prev); + elm_gengrid_item_show((Elm_Object_Item *) prev, ELM_GENGRID_ITEM_SCROLLTO_IN); return EINA_TRUE; } @@ -540,7 +540,7 @@ _item_single_select_right(Widget_Data *wd) _deselect_all_items(wd); elm_gengrid_item_selected_set((Elm_Object_Item *) next, EINA_TRUE); - elm_gengrid_item_show((Elm_Object_Item *) next); + elm_gengrid_item_show((Elm_Object_Item *) next, ELM_GENGRID_ITEM_SCROLLTO_IN); return EINA_TRUE; } @@ -2715,7 +2715,7 @@ elm_gengrid_item_gengrid_get(const Elm_Object_Item *it) } EAPI void -elm_gengrid_item_show(Elm_Object_Item *it) +elm_gengrid_item_show(Elm_Object_Item *it, Elm_Gengrid_Item_Scrollto_Type type) { ELM_OBJ_ITEM_CHECK_OR_RETURN(it); Elm_Gen_Item *_it = (Elm_Gen_Item *)it; @@ -2725,6 +2725,11 @@ elm_gengrid_item_show(Elm_Object_Item *it) if ((_it->generation < _it->wd->generation)) return; _pan_min_get(wd->pan_smart, &minx, &miny); + if (type==ELM_GENGRID_ITEM_SCROLLTO_IN) + { + //TODO : type based handling like genlist + } + if (wd->horizontal) elm_smart_scroller_region_bring_in(_it->wd->scr, ((_it->x - _it->item->prev_group) * wd->item_width) + (_it->item->prev_group * _it->wd->group_item_width) + minx, @@ -2740,7 +2745,7 @@ elm_gengrid_item_show(Elm_Object_Item *it) } EAPI void -elm_gengrid_item_bring_in(Elm_Object_Item *it) +elm_gengrid_item_bring_in(Elm_Object_Item *it, Elm_Gengrid_Item_Scrollto_Type type) { ELM_OBJ_ITEM_CHECK_OR_RETURN(it); Elm_Gen_Item *_it = (Elm_Gen_Item *)it; @@ -2751,6 +2756,11 @@ elm_gengrid_item_bring_in(Elm_Object_Item *it) Widget_Data *wd = _it->wd; _pan_min_get(wd->pan_smart, &minx, &miny); + if (type==ELM_GENGRID_ITEM_SCROLLTO_IN) + { + //TODO : type based handling like genlist + } + if (wd->horizontal) elm_smart_scroller_region_bring_in(_it->wd->scr, ((_it->x - _it->item->prev_group) * wd->item_width) + (_it->item->prev_group * _it->wd->group_item_width) + minx, diff --git a/src/lib/elm_gengrid.h b/src/lib/elm_gengrid.h index 8ae4951..6b3e0e6 100644 --- a/src/lib/elm_gengrid.h +++ b/src/lib/elm_gengrid.h @@ -226,6 +226,20 @@ #define ELM_GENGRID_ITEM_CLASS_HEADER ELM_GEN_ITEM_CLASS_HEADER /** + * Defines where to position the item in the genlist. + * + * @ingroup Genlist + */ +typedef enum +{ + ELM_GENGRID_ITEM_SCROLLTO_NONE = 0, /**< no scrollto */ + ELM_GENGRID_ITEM_SCROLLTO_IN = (1 << 0), /**< to the nearest viewport */ + ELM_GENGRID_ITEM_SCROLLTO_TOP = (1 << 1), /**< to the top of viewport */ + ELM_GENGRID_ITEM_SCROLLTO_MIDDLE = (1 << 2) /**< to the middle of viewport */ +} Elm_Gengrid_Item_Scrollto_Type; + + +/** * @see Elm_Gen_Item_Class */ typedef Elm_Gen_Item_Class Elm_Gengrid_Item_Class; @@ -656,6 +670,7 @@ EAPI Eina_Bool elm_gengrid_item_selected_get(const Elm_Objec * item, @b immediately. * * @param it The item to display + * @param type Where to position the item in the viewport. * * This causes gengrid to @b redraw its viewport's contents to the * region containing the given @p item item, if it is not fully @@ -665,13 +680,14 @@ EAPI Eina_Bool elm_gengrid_item_selected_get(const Elm_Objec * * @ingroup Gengrid */ -EAPI void elm_gengrid_item_show(Elm_Object_Item *it); +EAPI void elm_gengrid_item_show(Elm_Object_Item *it, Elm_Gengrid_Item_Scrollto_Type type); /** * Animatedly bring in, to the visible area of a gengrid, a given * item on it. * * @param it The gengrid item to display + * @param type Where to position the item in the viewport. * * This causes gengrid to jump to the given @p item and show * it (by scrolling), if it is not fully visible. This will use @@ -681,13 +697,7 @@ EAPI void elm_gengrid_item_show(Elm_Object_Item *it); * * @ingroup Gengrid */ -EAPI void elm_gengrid_item_bring_in(Elm_Object_Item *it); - -//XXX: Let's add as possible -//EAPI void elm_gengrid_item_top_show(Elm_Object_Item *it); -//EAPI void elm_gengrid_item_top_bring_in(Elm_Object_Item *it); -//EAPI void elm_gengrid_item_middle_show(Elm_Object_Item *it); -//EAPI void elm_gengrid_item_middle_bring_in(Elm_Object_Item *it); +EAPI void elm_gengrid_item_bring_in(Elm_Object_Item *it, Elm_Gengrid_Item_Scrollto_Type type); /** * Update the contents of a given gengrid item -- 2.7.4