forked from enlightenment/efl
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
This commit is contained in:
parent
01117dee6c
commit
74bd15f5bf
|
@ -27,6 +27,24 @@ _my_bt_go_900_900(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EIN
|
|||
elm_scroller_region_bring_in((Evas_Object *)data, 900, 900, 318, 318);
|
||||
}
|
||||
|
||||
static void
|
||||
_my_bt_prev_page(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
{
|
||||
Evas_Object *sc = (Evas_Object *)data;
|
||||
int page_x = 0, page_y = 0;
|
||||
elm_scroller_current_page_get(sc, &page_x, &page_y);
|
||||
elm_scroller_page_bring_in(sc, --page_x, page_y);
|
||||
}
|
||||
|
||||
static void
|
||||
_my_bt_next_page(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
{
|
||||
Evas_Object *sc = (Evas_Object *)data;
|
||||
int page_x = 0, page_y = 0;
|
||||
elm_scroller_current_page_get(sc, &page_x, &page_y);
|
||||
elm_scroller_page_bring_in(sc, ++page_x, page_y);
|
||||
}
|
||||
|
||||
static void
|
||||
_my_bt_freeze_toggle(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
|
||||
{
|
||||
|
@ -350,6 +368,22 @@ test_scroller(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_
|
|||
elm_table_pack(tb2, bt, 2, 2, 1, 1);
|
||||
evas_object_show(bt);
|
||||
|
||||
bt = elm_button_add(win);
|
||||
elm_object_text_set(bt, "prev page");
|
||||
evas_object_smart_callback_add(bt, "clicked", _my_bt_prev_page, sc);
|
||||
evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
evas_object_size_hint_align_set(bt, 0.1, 0.5);
|
||||
elm_table_pack(tb2, bt, 0, 1, 1, 1);
|
||||
evas_object_show(bt);
|
||||
|
||||
bt = elm_button_add(win);
|
||||
elm_object_text_set(bt, "next page");
|
||||
evas_object_smart_callback_add(bt, "clicked", _my_bt_next_page, sc);
|
||||
evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
evas_object_size_hint_align_set(bt, 0.9, 0.5);
|
||||
elm_table_pack(tb2, bt, 2, 1, 1, 1);
|
||||
evas_object_show(bt);
|
||||
|
||||
evas_object_event_callback_add(sc, EVAS_CALLBACK_MOVE, _sc_move_cb, tb2);
|
||||
evas_object_event_callback_add(sc, EVAS_CALLBACK_RESIZE, _sc_resize_cb, tb2);
|
||||
evas_object_geometry_get(sc, &x, &y, &w, &h);
|
||||
|
|
|
@ -2177,7 +2177,10 @@ _elm_scroll_page_x_get(Elm_Scrollable_Smart_Interface_Data *sid,
|
|||
|
||||
if (sid->pagesize_h > 0)
|
||||
{
|
||||
if (x >= 0)
|
||||
x = x + (sid->pagesize_h * 0.5);
|
||||
else if (x < 0 && sid->loop_h)
|
||||
x = x - (sid->pagesize_h * 0.5);
|
||||
x = x / (sid->pagesize_h);
|
||||
x = x * (sid->pagesize_h);
|
||||
}
|
||||
|
@ -2221,7 +2224,10 @@ _elm_scroll_page_y_get(Elm_Scrollable_Smart_Interface_Data *sid,
|
|||
|
||||
if (sid->pagesize_v > 0)
|
||||
{
|
||||
if (y >= 0)
|
||||
y = y + (sid->pagesize_v * 0.5);
|
||||
else if (y < 0 && sid->loop_v)
|
||||
y = y - (sid->pagesize_v * 0.5);
|
||||
y = y / (sid->pagesize_v);
|
||||
y = y * (sid->pagesize_v);
|
||||
}
|
||||
|
@ -4360,8 +4366,8 @@ _elm_interface_scrollable_page_show(Eo *obj, Elm_Scrollable_Smart_Interface_Data
|
|||
|
||||
eo_do(sid->obj, elm_interface_scrollable_content_viewport_geometry_get
|
||||
(NULL, NULL, &w, &h));
|
||||
if (pagenumber_h >= 0) x = sid->pagesize_h * pagenumber_h;
|
||||
if (pagenumber_v >= 0) y = sid->pagesize_v * pagenumber_v;
|
||||
x = sid->pagesize_h * pagenumber_h;
|
||||
y = sid->pagesize_v * pagenumber_v;
|
||||
|
||||
sid->wx = (sid->is_mirrored ? _elm_scroll_x_mirrored_get(sid->obj, x) : x);
|
||||
sid->wy = y;
|
||||
|
@ -4390,8 +4396,8 @@ _elm_interface_scrollable_page_bring_in(Eo *obj, Elm_Scrollable_Smart_Interface_
|
|||
|
||||
eo_do(sid->obj, elm_interface_scrollable_content_viewport_geometry_get
|
||||
(NULL, NULL, &w, &h));
|
||||
if (pagenumber_h >= 0) x = sid->pagesize_h * pagenumber_h;
|
||||
if (pagenumber_v >= 0) y = sid->pagesize_v * pagenumber_v;
|
||||
x = sid->pagesize_h * pagenumber_h;
|
||||
y = sid->pagesize_v * pagenumber_v;
|
||||
if (_elm_scroll_content_region_show_internal(obj, &x, &y, w, h))
|
||||
{
|
||||
_elm_scroll_scroll_to_x(sid, _elm_config->bring_in_scroll_friction, x);
|
||||
|
|
Loading…
Reference in New Issue