summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHosang Kim <hosang12.kim@samsung.com>2015-08-28 21:12:30 +0900
committerChunEon Park <hermet@hermet.pe.kr>2015-08-28 21:12:30 +0900
commit074923fd616f614b4d218e4909cfaeb78f94cb1a (patch)
tree60888d5e84e0e8ba911ba75361ec58188f0e46f8
parent4298e69a26398308bdcc55dbaa4dccade4e609d4 (diff)
scroller: fix page calculation logic when looping is enabled.
Test Plan: 1. elementary_test -> scroller 2. Lopping in x axis 3. click prev page or next page Reviewers: SanghyeonLee, singh.amitesh, Hermet, seoz, cedric, raster, jaehwan Differential Revision: https://phab.enlightenment.org/D2982
-rw-r--r--src/bin/test_scroller.c34
-rw-r--r--src/lib/elm_interface_scrollable.c18
2 files changed, 46 insertions, 6 deletions
diff --git a/src/bin/test_scroller.c b/src/bin/test_scroller.c
index 75ddfb783..3a53d1bd3 100644
--- a/src/bin/test_scroller.c
+++ b/src/bin/test_scroller.c
@@ -28,6 +28,24 @@ _my_bt_go_900_900(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EIN
28} 28}
29 29
30static void 30static void
31_my_bt_prev_page(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
32{
33 Evas_Object *sc = (Evas_Object *)data;
34 int page_x = 0, page_y = 0;
35 elm_scroller_current_page_get(sc, &page_x, &page_y);
36 elm_scroller_page_bring_in(sc, --page_x, page_y);
37}
38
39static void
40_my_bt_next_page(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
41{
42 Evas_Object *sc = (Evas_Object *)data;
43 int page_x = 0, page_y = 0;
44 elm_scroller_current_page_get(sc, &page_x, &page_y);
45 elm_scroller_page_bring_in(sc, ++page_x, page_y);
46}
47
48static void
31_my_bt_freeze_toggle(void *data, Evas_Object *obj, void *event_info EINA_UNUSED) 49_my_bt_freeze_toggle(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
32{ 50{
33 if (elm_check_state_get(obj)) 51 if (elm_check_state_get(obj))
@@ -350,6 +368,22 @@ test_scroller(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_
350 elm_table_pack(tb2, bt, 2, 2, 1, 1); 368 elm_table_pack(tb2, bt, 2, 2, 1, 1);
351 evas_object_show(bt); 369 evas_object_show(bt);
352 370
371 bt = elm_button_add(win);
372 elm_object_text_set(bt, "prev page");
373 evas_object_smart_callback_add(bt, "clicked", _my_bt_prev_page, sc);
374 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
375 evas_object_size_hint_align_set(bt, 0.1, 0.5);
376 elm_table_pack(tb2, bt, 0, 1, 1, 1);
377 evas_object_show(bt);
378
379 bt = elm_button_add(win);
380 elm_object_text_set(bt, "next page");
381 evas_object_smart_callback_add(bt, "clicked", _my_bt_next_page, sc);
382 evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
383 evas_object_size_hint_align_set(bt, 0.9, 0.5);
384 elm_table_pack(tb2, bt, 2, 1, 1, 1);
385 evas_object_show(bt);
386
353 evas_object_event_callback_add(sc, EVAS_CALLBACK_MOVE, _sc_move_cb, tb2); 387 evas_object_event_callback_add(sc, EVAS_CALLBACK_MOVE, _sc_move_cb, tb2);
354 evas_object_event_callback_add(sc, EVAS_CALLBACK_RESIZE, _sc_resize_cb, tb2); 388 evas_object_event_callback_add(sc, EVAS_CALLBACK_RESIZE, _sc_resize_cb, tb2);
355 evas_object_geometry_get(sc, &x, &y, &w, &h); 389 evas_object_geometry_get(sc, &x, &y, &w, &h);
diff --git a/src/lib/elm_interface_scrollable.c b/src/lib/elm_interface_scrollable.c
index 914fc9a03..77763ab1f 100644
--- a/src/lib/elm_interface_scrollable.c
+++ b/src/lib/elm_interface_scrollable.c
@@ -2177,7 +2177,10 @@ _elm_scroll_page_x_get(Elm_Scrollable_Smart_Interface_Data *sid,
2177 2177
2178 if (sid->pagesize_h > 0) 2178 if (sid->pagesize_h > 0)
2179 { 2179 {
2180 x = x + (sid->pagesize_h * 0.5); 2180 if (x >= 0)
2181 x = x + (sid->pagesize_h * 0.5);
2182 else if (x < 0 && sid->loop_h)
2183 x = x - (sid->pagesize_h * 0.5);
2181 x = x / (sid->pagesize_h); 2184 x = x / (sid->pagesize_h);
2182 x = x * (sid->pagesize_h); 2185 x = x * (sid->pagesize_h);
2183 } 2186 }
@@ -2221,7 +2224,10 @@ _elm_scroll_page_y_get(Elm_Scrollable_Smart_Interface_Data *sid,
2221 2224
2222 if (sid->pagesize_v > 0) 2225 if (sid->pagesize_v > 0)
2223 { 2226 {
2224 y = y + (sid->pagesize_v * 0.5); 2227 if (y >= 0)
2228 y = y + (sid->pagesize_v * 0.5);
2229 else if (y < 0 && sid->loop_v)
2230 y = y - (sid->pagesize_v * 0.5);
2225 y = y / (sid->pagesize_v); 2231 y = y / (sid->pagesize_v);
2226 y = y * (sid->pagesize_v); 2232 y = y * (sid->pagesize_v);
2227 } 2233 }
@@ -4360,8 +4366,8 @@ _elm_interface_scrollable_page_show(Eo *obj, Elm_Scrollable_Smart_Interface_Data
4360 4366
4361 eo_do(sid->obj, elm_interface_scrollable_content_viewport_geometry_get 4367 eo_do(sid->obj, elm_interface_scrollable_content_viewport_geometry_get
4362 (NULL, NULL, &w, &h)); 4368 (NULL, NULL, &w, &h));
4363 if (pagenumber_h >= 0) x = sid->pagesize_h * pagenumber_h; 4369 x = sid->pagesize_h * pagenumber_h;
4364 if (pagenumber_v >= 0) y = sid->pagesize_v * pagenumber_v; 4370 y = sid->pagesize_v * pagenumber_v;
4365 4371
4366 sid->wx = (sid->is_mirrored ? _elm_scroll_x_mirrored_get(sid->obj, x) : x); 4372 sid->wx = (sid->is_mirrored ? _elm_scroll_x_mirrored_get(sid->obj, x) : x);
4367 sid->wy = y; 4373 sid->wy = y;
@@ -4390,8 +4396,8 @@ _elm_interface_scrollable_page_bring_in(Eo *obj, Elm_Scrollable_Smart_Interface_
4390 4396
4391 eo_do(sid->obj, elm_interface_scrollable_content_viewport_geometry_get 4397 eo_do(sid->obj, elm_interface_scrollable_content_viewport_geometry_get
4392 (NULL, NULL, &w, &h)); 4398 (NULL, NULL, &w, &h));
4393 if (pagenumber_h >= 0) x = sid->pagesize_h * pagenumber_h; 4399 x = sid->pagesize_h * pagenumber_h;
4394 if (pagenumber_v >= 0) y = sid->pagesize_v * pagenumber_v; 4400 y = sid->pagesize_v * pagenumber_v;
4395 if (_elm_scroll_content_region_show_internal(obj, &x, &y, w, h)) 4401 if (_elm_scroll_content_region_show_internal(obj, &x, &y, w, h))
4396 { 4402 {
4397 _elm_scroll_scroll_to_x(sid, _elm_config->bring_in_scroll_friction, x); 4403 _elm_scroll_scroll_to_x(sid, _elm_config->bring_in_scroll_friction, x);