interface_scrollable: Improve gravity_set api to support pan changing 10/124410/1
authorWonki Kim <wonki_.kim@samsung.com>
Wed, 15 Feb 2017 12:01:46 +0000 (21:01 +0900)
committerWonki Kim <wonki_.kim@samsung.com>
Tue, 11 Apr 2017 08:26:09 +0000 (17:26 +0900)
Summary:
When you set gravity 1 on scroller, scroller sticks to the bottom
even content is changed.
however, scroller don't work like above, if size of pan is changed.

this commit uses pan_pos_max rather than w/h of content_info
because pan_pos_max is related with both content_size and pan size.

gravity_set will work properly even if both size of content and pan are
changed simultaneously.

Test Plan:
1. Select 'scroll3' in the elementary_test
2. Append enough items so that scroll bar appears (about 30 items)
3. Go to the bottom and Set gravity 1.0
4. Check that scroller sticks to the bottom once you append another item
   (it works)
5. Check that scroller sticks to to bottom once you resize window(pan)
   (it doesn't work without this patch)

Reviewers: eagleeye, jpeg, cedric, woohyun, z-wony

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

Change-Id: I0af8e737cae4a31f9aa2082b7a89c0d01392f5f3
Signed-off-by: Wonki Kim <wonki_.kim@samsung.com>
src/lib/elm_interface_scrollable.c

index ee5aa35..dc39b02 100644 (file)
@@ -2071,6 +2071,7 @@ _elm_interface_scrollable_wanted_region_set(Eo *obj, Elm_Scrollable_Smart_Interf
 //
 {
    Evas_Coord ww, wh, wx;
+   Evas_Coord mx = 0, my = 0;
 
 //TIZEN_ONLY(20150825) : Use the specific wanted_region_set func only for gengrid.
 //   ELM_SCROLL_IFACE_DATA_GET_OR_RETURN(obj, sid);
@@ -2101,11 +2102,13 @@ _elm_interface_scrollable_wanted_region_set(Eo *obj, Elm_Scrollable_Smart_Interf
         wh = sid->wh;
      }
 
-   wx += (sid->content_info.w - sid->prev_cw) * sid->gravity_x;
-   sid->wy += (sid->content_info.h - sid->prev_ch) * sid->gravity_y;
+   eo_do(sid->pan_obj, elm_obj_pan_pos_max_get(&mx, &my));
+
+   wx += (mx - sid->prev_cw) * sid->gravity_x;
+   sid->wy += (my - sid->prev_ch) * sid->gravity_y;
 
-   sid->prev_cw = sid->content_info.w;
-   sid->prev_ch = sid->content_info.h;
+   sid->prev_cw = mx;
+   sid->prev_ch = my;
 
    eo_do(obj, elm_interface_scrollable_content_region_set(wx, sid->wy, ww, wh));
 }
@@ -5181,8 +5184,7 @@ _elm_interface_scrollable_gravity_set(Eo *obj EINA_UNUSED, Elm_Scrollable_Smart_
 {
    sid->gravity_x = x;
    sid->gravity_y = y;
-   sid->prev_cw = sid->content_info.w;
-   sid->prev_ch = sid->content_info.h;
+   eo_do(sid->pan_obj, elm_obj_pan_pos_max_get(&sid->prev_cw, &sid->prev_ch));
 }
 
 EOLIAN static void