summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukasz Stanislawski <l.stanislaws@samsung.com>2016-01-04 14:05:29 -0800
committerCedric BAIL <cedric@osg.samsung.com>2016-01-04 14:05:32 -0800
commit9230a3d31e5428e7f3c69ff6dde8c6f0c59403fc (patch)
treecf8ed9bc3fcd991fdc249de1a225eb3f3b5d9691
parent34d2c8e1250c21e06593efba67eeefc97a216d98 (diff)
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 <cedric@osg.samsung.com>
-rw-r--r--src/bin/test.c2
-rw-r--r--src/bin/test_genlist.c153
-rw-r--r--src/lib/elm_genlist.c4
-rw-r--r--src/lib/elm_genlist_item.eo3
4 files changed, 161 insertions, 1 deletions
diff --git a/src/bin/test.c b/src/bin/test.c
index 8019ac046..53f419d5b 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);
124void test_genlist_multi_select(void *data, Evas_Object *obj, void *event_info); 124void test_genlist_multi_select(void *data, Evas_Object *obj, void *event_info);
125void test_genlist_del(void *data, Evas_Object *obj, void *event_info); 125void test_genlist_del(void *data, Evas_Object *obj, void *event_info);
126void test_genlist_filter(void *data, Evas_Object *obj, void *event_info); 126void test_genlist_filter(void *data, Evas_Object *obj, void *event_info);
127void test_genlist_show_bring(void *data, Evas_Object *obj, void *event_info);
127void test_gesture_layer(void *data, Evas_Object *obj, void *event_info); 128void test_gesture_layer(void *data, Evas_Object *obj, void *event_info);
128void test_gesture_layer2(void *data, Evas_Object *obj, void *event_info); 129void test_gesture_layer2(void *data, Evas_Object *obj, void *event_info);
129void test_gesture_layer3(void *data, Evas_Object *obj, void *event_info); 130void test_gesture_layer3(void *data, Evas_Object *obj, void *event_info);
@@ -695,6 +696,7 @@ add_tests:
695 ADD_TEST(NULL, "Lists - Genlist", "Genlist Multi Select", test_genlist_multi_select); 696 ADD_TEST(NULL, "Lists - Genlist", "Genlist Multi Select", test_genlist_multi_select);
696 ADD_TEST(NULL, "Lists - Genlist", "Genlist Del", test_genlist_del); 697 ADD_TEST(NULL, "Lists - Genlist", "Genlist Del", test_genlist_del);
697 ADD_TEST(NULL, "Lists - Genlist", "Genlist Filter", test_genlist_filter); 698 ADD_TEST(NULL, "Lists - Genlist", "Genlist Filter", test_genlist_filter);
699 ADD_TEST(NULL, "Lists - Genlist", "Genlist Show/Bring", test_genlist_show_bring);
698 700
699 //------------------------------// 701 //------------------------------//
700 702
diff --git a/src/bin/test_genlist.c b/src/bin/test_genlist.c
index 36cd529a9..9dcebc19e 100644
--- a/src/bin/test_genlist.c
+++ b/src/bin/test_genlist.c
@@ -21,6 +21,7 @@ struct _api_data
21 void *gl; 21 void *gl;
22 22
23 void *filter_data; /* The data used for filtering */ 23 void *filter_data; /* The data used for filtering */
24 int scrollto;
24}; 25};
25typedef struct _api_data api_data; 26typedef struct _api_data api_data;
26 27
@@ -5080,3 +5081,155 @@ test_genlist_filter(void *data EINA_UNUSED,
5080 evas_object_smart_callback_add(entry, "changed,user", _entry_change_cb, api); 5081 evas_object_smart_callback_add(entry, "changed,user", _entry_change_cb, api);
5081} 5082}
5082 5083
5084static void
5085_rd_changed_cb(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
5086{
5087 api_data *ad = data;
5088 ad->scrollto = elm_radio_state_value_get(obj);
5089}
5090
5091static Evas_Object *
5092_scrollto_mode_frame_new(Evas_Object *win, void *data)
5093{
5094 Evas_Object *fr, *bx, *rd, *rdg;
5095 api_data *sd = data;
5096
5097 fr = elm_frame_add(win);
5098 elm_object_text_set(fr, "Scrollto Mode");
5099 evas_object_show(fr);
5100
5101 bx = elm_box_add(win);
5102 elm_object_content_set(fr, bx);
5103 evas_object_show(bx);
5104
5105 rd = elm_radio_add(win);
5106 elm_radio_state_value_set(rd, 0);
5107 elm_object_text_set(rd, "SCROLLTO_NONE");
5108 evas_object_smart_callback_add(rd, "changed", _rd_changed_cb, sd);
5109 evas_object_show(rd);
5110 elm_box_pack_end(bx, rd);
5111 rdg = rd;
5112
5113 rd = elm_radio_add(win);
5114 elm_radio_state_value_set(rd, 1);
5115 elm_object_text_set(rd, "SCROLLTO_IN");
5116 elm_radio_group_add(rd, rdg);
5117 evas_object_smart_callback_add(rd, "changed", _rd_changed_cb, sd);
5118 evas_object_show(rd);
5119 elm_box_pack_end(bx, rd);
5120
5121 rd = elm_radio_add(win);
5122 elm_radio_state_value_set(rd, 2);
5123 elm_object_text_set(rd, "SCROLLTO_TOP");
5124 elm_radio_group_add(rd, rdg);
5125 evas_object_smart_callback_add(rd, "changed", _rd_changed_cb, sd);
5126 evas_object_show(rd);
5127 elm_box_pack_end(bx, rd);
5128
5129 rd = elm_radio_add(win);
5130 elm_radio_state_value_set(rd, 4);
5131 elm_object_text_set(rd, "SCROLLTO_MIDDLE");
5132 elm_radio_group_add(rd, rdg);
5133 evas_object_smart_callback_add(rd, "changed", _rd_changed_cb, sd);
5134 evas_object_show(rd);
5135 elm_box_pack_end(bx, rd);
5136
5137 rd = elm_radio_add(win);
5138 elm_radio_state_value_set(rd, 8);
5139 elm_object_text_set(rd, "SCROLLTO_BOTTOM");
5140 elm_radio_group_add(rd, rdg);
5141 evas_object_smart_callback_add(rd, "changed", _rd_changed_cb, sd);
5142 evas_object_show(rd);
5143 elm_box_pack_end(bx, rd);
5144
5145 return fr;
5146}
5147
5148void
5149_scrollto_item_show(void *data,
5150 Evas_Object *obj EINA_UNUSED,
5151 void *event_info EINA_UNUSED)
5152{
5153 api_data *api = data;
5154 Elm_Object_Item *it = elm_genlist_selected_item_get(api->gl);
5155 elm_genlist_item_show(it, api->scrollto);
5156}
5157
5158void
5159_scrollto_item_bring(void *data,
5160 Evas_Object *obj EINA_UNUSED,
5161 void *event_info EINA_UNUSED)
5162{
5163 api_data *api = data;
5164 Elm_Object_Item *it = elm_genlist_selected_item_get(api->gl);
5165 elm_genlist_item_bring_in(it, api->scrollto);
5166}
5167
5168void
5169test_genlist_show_bring(void *data EINA_UNUSED,
5170 Evas_Object *obj EINA_UNUSED,
5171 void *event_info EINA_UNUSED)
5172{
5173 Evas_Object *win, *gl, *bt_show, *bt_bring, *bx, *bxx, *fr;
5174 Elm_Object_Item *gli;
5175 int i, max;
5176 api_data *api = calloc(1, sizeof(api_data));
5177
5178 win = elm_win_util_standard_add("genlist", "Genlist Item Show/Bring");
5179 elm_win_autodel_set(win, EINA_TRUE);
5180 evas_object_event_callback_add(win, EVAS_CALLBACK_DEL, _cleanup_cb, api);
5181
5182 bxx = elm_box_add(win);
5183 evas_object_size_hint_weight_set(bxx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
5184 elm_win_resize_object_add(win, bxx);
5185 evas_object_show(bxx);
5186
5187 bx = elm_box_add(win);
5188 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
5189 evas_object_size_hint_align_set(bx, EVAS_HINT_FILL, EVAS_HINT_FILL);
5190 evas_object_show(bx);
5191 elm_box_pack_end(bxx, bx);
5192
5193 gl = elm_genlist_add(win);
5194 evas_object_size_hint_weight_set(gl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
5195 evas_object_size_hint_align_set(gl, EVAS_HINT_FILL, EVAS_HINT_FILL);
5196 elm_box_pack_end(bx, gl);
5197 evas_object_show(gl);
5198 api->gl = gl;
5199
5200 api->itc1 = elm_genlist_item_class_new();
5201 api->itc1->item_style = "default";
5202 api->itc1->func.text_get = gl_text_get1;
5203 api->itc1->func.content_get = gl_content_get;
5204 api->itc1->func.state_get = NULL;
5205 api->itc1->func.del = NULL;
5206
5207 bt_show = elm_button_add(win);
5208 elm_object_text_set(bt_show, "Show");
5209 evas_object_smart_callback_add(bt_show, "clicked", _scrollto_item_show, api);
5210 evas_object_show(bt_show);
5211 elm_box_pack_end(bx, bt_show);
5212
5213 bt_bring = elm_button_add(win);
5214 elm_object_text_set(bt_bring, "Bring");
5215 evas_object_smart_callback_add(bt_bring, "clicked", _scrollto_item_bring, api);
5216 evas_object_show(bt_bring);
5217 elm_box_pack_end(bx, bt_bring);
5218
5219 fr = _scrollto_mode_frame_new(win, api);
5220 elm_box_pack_end(bx, fr);
5221
5222 max = 2000;
5223 for (i = 0; i < max; i++)
5224 elm_genlist_item_append(gl, api->itc1, (void*)(uintptr_t)i, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
5225
5226 elm_genlist_item_class_free(api->itc1);
5227 gli = elm_genlist_nth_item_get(gl, 1340);
5228 elm_genlist_item_selected_set(gli, EINA_TRUE);
5229 elm_genlist_item_show(gli, ELM_GENLIST_ITEM_SCROLLTO_MIDDLE);
5230
5231 evas_object_resize(win, 480, 400);
5232 explode_win_enable(win);
5233 evas_object_show(win);
5234}
5235
diff --git a/src/lib/elm_genlist.c b/src/lib/elm_genlist.c
index d4d24c9ea..b78081f84 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,
6872 *y = it->y + it->item->block->y - (*h / 2) + (it->item->h / 2); 6872 *y = it->y + it->item->block->y - (*h / 2) + (it->item->h / 2);
6873 break; 6873 break;
6874 6874
6875 case ELM_GENLIST_ITEM_SCROLLTO_BOTTOM:
6876 *y = it->y + it->item->block->y - *h + it->item->h;
6877 break;
6878
6875 default: 6879 default:
6876 return EINA_FALSE; 6880 return EINA_FALSE;
6877 } 6881 }
diff --git a/src/lib/elm_genlist_item.eo b/src/lib/elm_genlist_item.eo
index b8187e76b..695296ee9 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
32 none = 0, [[No scrollto.]] 32 none = 0, [[No scrollto.]]
33 in = (1 << 0), [[To the nearest viewport.]] 33 in = (1 << 0), [[To the nearest viewport.]]
34 top = (1 << 1), [[To the top of viewport.]] 34 top = (1 << 1), [[To the top of viewport.]]
35 middle = (1 << 2) [[To the middle of viewport.]] 35 middle = (1 << 2), [[To the middle of viewport.]]
36 bottom = (1 << 3) [[To the bottom of viewport.]]
36} 37}
37 38
38class Elm.Genlist_Item(Elm.Widget_Item) 39class Elm.Genlist_Item(Elm.Widget_Item)