interface_scrollable: Unify basis of calculation of page_get logic
authorWonki Kim <wonki_.kim@samsung.com>
Mon, 16 Jan 2017 05:20:04 +0000 (14:20 +0900)
committerJean-Philippe Andre <jp.andre@samsung.com>
Mon, 16 Jan 2017 05:20:04 +0000 (14:20 +0900)
Summary:
If rtl mode is set, current_page_get api should return reversed page number.
To do that, make x position x-axis reversed before page calculating.

Also bring_in and page_show should show the reversed page in rtl mode.
This patch modify the functions to support that.

Lastly, scroller should be scrolling based on the right edge of the page.

This patch is a combination of the patches(D4559,D4560)

Test Plan:
1. Run scroller test on elementary_test
2. Turn ui mirrored mode on
3. Manipulate scroller in various ways
    - It should scroll proper position when you click next or prev btn.

Reviewers: woohyun, taxi2se, z-wony, cedric

Subscribers: cedric, jpeg

Differential Revision: https://phab.enlightenment.org/D4558

src/lib/elementary/elm_interface_scrollable.c

index 4c6c169..a9f79d2 100644 (file)
@@ -2203,6 +2203,7 @@ _elm_scroll_page_x_get(Elm_Scrollable_Smart_Interface_Data *sid,
           x += (abs(offset) < dx ? offset : -(dx + 1));
      }
 
+   if (sid->is_mirrored) x += w;
    if (sid->pagesize_h > 0)
      {
         if (x >= 0)
@@ -2212,6 +2213,7 @@ _elm_scroll_page_x_get(Elm_Scrollable_Smart_Interface_Data *sid,
         x = x / (sid->pagesize_h);
         x = x * (sid->pagesize_h);
      }
+   if (sid->is_mirrored) x -= w;
    if (!sid->loop_h)
      {
         if ((x + w) > cw) x = cw - w;
@@ -4319,6 +4321,9 @@ _elm_interface_scrollable_current_page_get(Eo *obj EINA_UNUSED, Elm_Scrollable_S
    elm_interface_scrollable_content_pos_get(sid->obj, &x, &y);
    if (pagenumber_h)
      {
+        if (sid->is_mirrored)
+          x = _elm_scroll_x_mirrored_get(sid->obj, x);
+
         if (sid->pagesize_h > 0)
           {
              double result = (double)x / (double)sid->pagesize_h;
@@ -4384,9 +4389,10 @@ _elm_interface_scrollable_page_show(Eo *obj, Elm_Scrollable_Smart_Interface_Data
    elm_interface_scrollable_content_viewport_geometry_get
          (sid->obj, NULL, NULL, &w, &h);
    x = sid->pagesize_h * pagenumber_h;
+   x = (sid->is_mirrored ? _elm_scroll_x_mirrored_get(sid->obj, x) : x);
    y = sid->pagesize_v * pagenumber_v;
 
-   sid->wx = (sid->is_mirrored ? _elm_scroll_x_mirrored_get(sid->obj, x) : x);
+   sid->wx = x;
    sid->wy = y;
    sid->ww = w;
    sid->wh = h;
@@ -4411,6 +4417,7 @@ _elm_interface_scrollable_page_bring_in(Eo *obj, Elm_Scrollable_Smart_Interface_
    elm_interface_scrollable_content_viewport_geometry_get
          (sid->obj, NULL, NULL, &w, &h);
    x = sid->pagesize_h * pagenumber_h;
+   x = (sid->is_mirrored ? _elm_scroll_x_mirrored_get(sid->obj, x) : x);
    y = sid->pagesize_v * pagenumber_v;
    if (_elm_scroll_content_region_show_internal(obj, &x, &y, w, h))
      {