cedric pushed a commit to branch master.

http://git.enlightenment.org/core/elementary.git/commit/?id=9230a3d31e5428e7f3c69ff6dde8c6f0c59403fc

commit 9230a3d31e5428e7f3c69ff6dde8c6f0c59403fc
Author: Lukasz Stanislawski <l.stanisl...@samsung.com>
Date:   Mon Jan 4 14:05:29 2016 -0800

    genlist: new SCROLLTO_BOTTOM alignment
    
    Summary:
    Add new scrollto type allowing to align genlist item to bottom of viewport.
    Feature compleates and closes list of all alignment types for genlist items.
    
    @feature
    
    Test Plan: elementary_test => Genlist Show/Bring
    
    Reviewers: cedric, seoz, SanghyeonLee
    
    Subscribers: seoz
    
    Differential Revision: https://phab.enlightenment.org/D3447
    
    Signed-off-by: Cedric BAIL <ced...@osg.samsung.com>
---
 src/bin/test.c              |   2 +
 src/bin/test_genlist.c      | 153 ++++++++++++++++++++++++++++++++++++++++++++
 src/lib/elm_genlist.c       |   4 ++
 src/lib/elm_genlist_item.eo |   3 +-
 4 files changed, 161 insertions(+), 1 deletion(-)

diff --git a/src/bin/test.c b/src/bin/test.c
index 8019ac0..53f419d 100644
--- a/src/bin/test.c
+++ b/src/bin/test.c
@@ -124,6 +124,7 @@ void test_genlist_item_styles(void *data, Evas_Object *obj, 
void *event_info);
 void test_genlist_multi_select(void *data, Evas_Object *obj, void *event_info);
 void test_genlist_del(void *data, Evas_Object *obj, void *event_info);
 void test_genlist_filter(void *data, Evas_Object *obj, void *event_info);
+void test_genlist_show_bring(void *data, Evas_Object *obj, void *event_info);
 void test_gesture_layer(void *data, Evas_Object *obj, void *event_info);
 void test_gesture_layer2(void *data, Evas_Object *obj, void *event_info);
 void test_gesture_layer3(void *data, Evas_Object *obj, void *event_info);
@@ -695,6 +696,7 @@ add_tests:
    ADD_TEST(NULL, "Lists - Genlist", "Genlist Multi Select", 
test_genlist_multi_select);
    ADD_TEST(NULL, "Lists - Genlist", "Genlist Del", test_genlist_del);
    ADD_TEST(NULL, "Lists - Genlist", "Genlist Filter", test_genlist_filter);
+   ADD_TEST(NULL, "Lists - Genlist", "Genlist Show/Bring", 
test_genlist_show_bring);
 
    //------------------------------//
 
diff --git a/src/bin/test_genlist.c b/src/bin/test_genlist.c
index 36cd529..9dcebc1 100644
--- a/src/bin/test_genlist.c
+++ b/src/bin/test_genlist.c
@@ -21,6 +21,7 @@ struct _api_data
    void *gl;
 
    void *filter_data;   /* The data used for filtering     */
+   int scrollto;
 };
 typedef struct _api_data api_data;
 
@@ -5080,3 +5081,155 @@ test_genlist_filter(void *data EINA_UNUSED,
    evas_object_smart_callback_add(entry, "changed,user", _entry_change_cb, 
api);
 }
 
+static void
+_rd_changed_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
+{
+   api_data *ad = data;
+   ad->scrollto = elm_radio_state_value_get(obj);
+}
+
+static Evas_Object *
+_scrollto_mode_frame_new(Evas_Object *win, void *data)
+{
+   Evas_Object *fr, *bx, *rd, *rdg;
+   api_data *sd = data;
+
+   fr = elm_frame_add(win);
+   elm_object_text_set(fr, "Scrollto Mode");
+   evas_object_show(fr);
+
+   bx = elm_box_add(win);
+   elm_object_content_set(fr, bx);
+   evas_object_show(bx);
+
+   rd = elm_radio_add(win);
+   elm_radio_state_value_set(rd, 0);
+   elm_object_text_set(rd, "SCROLLTO_NONE");
+   evas_object_smart_callback_add(rd, "changed", _rd_changed_cb, sd);
+   evas_object_show(rd);
+   elm_box_pack_end(bx, rd);
+   rdg = rd;
+
+   rd = elm_radio_add(win);
+   elm_radio_state_value_set(rd, 1);
+   elm_object_text_set(rd, "SCROLLTO_IN");
+   elm_radio_group_add(rd, rdg);
+   evas_object_smart_callback_add(rd, "changed", _rd_changed_cb, sd);
+   evas_object_show(rd);
+   elm_box_pack_end(bx, rd);
+
+   rd = elm_radio_add(win);
+   elm_radio_state_value_set(rd, 2);
+   elm_object_text_set(rd, "SCROLLTO_TOP");
+   elm_radio_group_add(rd, rdg);
+   evas_object_smart_callback_add(rd, "changed", _rd_changed_cb, sd);
+   evas_object_show(rd);
+   elm_box_pack_end(bx, rd);
+
+   rd = elm_radio_add(win);
+   elm_radio_state_value_set(rd, 4);
+   elm_object_text_set(rd, "SCROLLTO_MIDDLE");
+   elm_radio_group_add(rd, rdg);
+   evas_object_smart_callback_add(rd, "changed", _rd_changed_cb, sd);
+   evas_object_show(rd);
+   elm_box_pack_end(bx, rd);
+
+   rd = elm_radio_add(win);
+   elm_radio_state_value_set(rd, 8);
+   elm_object_text_set(rd, "SCROLLTO_BOTTOM");
+   elm_radio_group_add(rd, rdg);
+   evas_object_smart_callback_add(rd, "changed", _rd_changed_cb, sd);
+   evas_object_show(rd);
+   elm_box_pack_end(bx, rd);
+
+   return fr;
+}
+
+void
+_scrollto_item_show(void *data,
+                    Evas_Object *obj EINA_UNUSED,
+                    void *event_info EINA_UNUSED)
+{
+   api_data *api = data;
+   Elm_Object_Item *it = elm_genlist_selected_item_get(api->gl);
+   elm_genlist_item_show(it, api->scrollto);
+}
+
+void
+_scrollto_item_bring(void *data,
+                     Evas_Object *obj EINA_UNUSED,
+                     void *event_info EINA_UNUSED)
+{
+   api_data *api = data;
+   Elm_Object_Item *it = elm_genlist_selected_item_get(api->gl);
+   elm_genlist_item_bring_in(it, api->scrollto);
+}
+
+void
+test_genlist_show_bring(void *data EINA_UNUSED,
+                        Evas_Object *obj EINA_UNUSED,
+                        void *event_info EINA_UNUSED)
+{
+   Evas_Object *win, *gl, *bt_show, *bt_bring, *bx, *bxx, *fr;
+   Elm_Object_Item *gli;
+   int i, max;
+   api_data *api = calloc(1, sizeof(api_data));
+
+   win = elm_win_util_standard_add("genlist", "Genlist Item Show/Bring");
+   elm_win_autodel_set(win, EINA_TRUE);
+   evas_object_event_callback_add(win, EVAS_CALLBACK_DEL, _cleanup_cb, api);
+
+   bxx = elm_box_add(win);
+   evas_object_size_hint_weight_set(bxx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+   elm_win_resize_object_add(win, bxx);
+   evas_object_show(bxx);
+
+   bx = elm_box_add(win);
+   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);
+   evas_object_show(bx);
+   elm_box_pack_end(bxx, bx);
+
+   gl = elm_genlist_add(win);
+   evas_object_size_hint_weight_set(gl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+   evas_object_size_hint_align_set(gl, EVAS_HINT_FILL, EVAS_HINT_FILL);
+   elm_box_pack_end(bx, gl);
+   evas_object_show(gl);
+   api->gl = gl;
+
+   api->itc1 = elm_genlist_item_class_new();
+   api->itc1->item_style = "default";
+   api->itc1->func.text_get = gl_text_get1;
+   api->itc1->func.content_get = gl_content_get;
+   api->itc1->func.state_get = NULL;
+   api->itc1->func.del = NULL;
+
+   bt_show = elm_button_add(win);
+   elm_object_text_set(bt_show, "Show");
+   evas_object_smart_callback_add(bt_show, "clicked", _scrollto_item_show, 
api);
+   evas_object_show(bt_show);
+   elm_box_pack_end(bx, bt_show);
+
+   bt_bring = elm_button_add(win);
+   elm_object_text_set(bt_bring, "Bring");
+   evas_object_smart_callback_add(bt_bring, "clicked", _scrollto_item_bring, 
api);
+   evas_object_show(bt_bring);
+   elm_box_pack_end(bx, bt_bring);
+
+   fr = _scrollto_mode_frame_new(win, api);
+   elm_box_pack_end(bx, fr);
+
+   max = 2000;
+   for (i = 0; i < max; i++)
+       elm_genlist_item_append(gl, api->itc1, (void*)(uintptr_t)i, NULL, 
ELM_GENLIST_ITEM_NONE, NULL, NULL);
+
+   elm_genlist_item_class_free(api->itc1);
+   gli = elm_genlist_nth_item_get(gl, 1340);
+   elm_genlist_item_selected_set(gli, EINA_TRUE);
+   elm_genlist_item_show(gli, ELM_GENLIST_ITEM_SCROLLTO_MIDDLE);
+
+   evas_object_resize(win, 480, 400);
+   explode_win_enable(win);
+   evas_object_show(win);
+}
+
diff --git a/src/lib/elm_genlist.c b/src/lib/elm_genlist.c
index d4d24c9..b78081f 100644
--- a/src/lib/elm_genlist.c
+++ b/src/lib/elm_genlist.c
@@ -6872,6 +6872,10 @@ _elm_genlist_item_coordinates_calc(Elm_Gen_Item *it,
         *y = it->y + it->item->block->y - (*h / 2) + (it->item->h / 2);
         break;
 
+      case ELM_GENLIST_ITEM_SCROLLTO_BOTTOM:
+        *y = it->y + it->item->block->y - *h + it->item->h;
+        break;
+
       default:
         return EINA_FALSE;
      }
diff --git a/src/lib/elm_genlist_item.eo b/src/lib/elm_genlist_item.eo
index b8187e7..695296e 100644
--- a/src/lib/elm_genlist_item.eo
+++ b/src/lib/elm_genlist_item.eo
@@ -32,7 +32,8 @@ enum Elm.Genlist.Item.Scrollto_Type
    none = 0,   [[No scrollto.]]
    in = (1 << 0),   [[To the nearest viewport.]]
    top = (1 << 1),   [[To the top of viewport.]]
-   middle = (1 << 2)   [[To the middle of viewport.]]
+   middle = (1 << 2),   [[To the middle of viewport.]]
+   bottom = (1 << 3)   [[To the bottom of viewport.]]
 }
 
 class Elm.Genlist_Item(Elm.Widget_Item)

-- 


Reply via email to