summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/bin/elementary/test_scroller.c25
-rw-r--r--src/lib/elementary/elm_interface_scrollable.c57
-rw-r--r--src/lib/elementary/elm_interface_scrollable.h6
-rw-r--r--src/lib/elementary/elm_pan.eo10
4 files changed, 40 insertions, 58 deletions
diff --git a/src/bin/elementary/test_scroller.c b/src/bin/elementary/test_scroller.c
index 2221f80f11..04b6c8067a 100644
--- a/src/bin/elementary/test_scroller.c
+++ b/src/bin/elementary/test_scroller.c
@@ -593,6 +593,15 @@ _append_items(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UN
593} 593}
594 594
595static void 595static void
596_changed_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
597{
598 Evas_Object *sl = data;
599 double val = elm_slider_value_get(obj);
600 elm_scroller_gravity_set(sl, 0.0, val);
601 printf("Gravity change to %lf\n",val);
602}
603
604static void
596_win_del_cb(void *data EINA_UNUSED, 605_win_del_cb(void *data EINA_UNUSED,
597 Evas *e EINA_UNUSED, 606 Evas *e EINA_UNUSED,
598 Evas_Object *obj EINA_UNUSED, 607 Evas_Object *obj EINA_UNUSED,
@@ -605,7 +614,7 @@ _win_del_cb(void *data EINA_UNUSED,
605void 614void
606test_scroller3(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) 615test_scroller3(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
607{ 616{
608 Evas_Object *win, *bt, *bt2, *bt3, *bx, *bx2, *bx3, *bx4, *sc; 617 Evas_Object *win, *bt, *bt2, *bt3, *bx, *bx2, *bx3, *bx4, *sc, *sl;
609 _count = 0; 618 _count = 0;
610 619
611 win = elm_win_util_standard_add("scroller3", "Scroller 3"); 620 win = elm_win_util_standard_add("scroller3", "Scroller 3");
@@ -639,9 +648,20 @@ test_scroller3(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event
639 elm_box_pack_end(bx2, bt3); 648 elm_box_pack_end(bx2, bt3);
640 evas_object_show(bt3); 649 evas_object_show(bt3);
641 650
651 sl = elm_slider_add(bx);
652 elm_object_text_set(sl, "Gravity");
653 elm_slider_unit_format_set(sl, "%1.1f");
654 elm_slider_indicator_format_set(sl, "%1.1f");
655 elm_slider_min_max_set(sl, 0, 1);
656 elm_slider_value_set(sl, 0.0);
657 evas_object_size_hint_align_set(sl, EVAS_HINT_FILL, EVAS_HINT_FILL);
658 evas_object_size_hint_weight_set(sl, EVAS_HINT_EXPAND, 0.1);
659 elm_box_pack_end(bx, sl);
660 evas_object_show(sl);
661
642 bx3 = elm_box_add(bx); 662 bx3 = elm_box_add(bx);
643 evas_object_size_hint_align_set(bx3, EVAS_HINT_FILL, EVAS_HINT_FILL); 663 evas_object_size_hint_align_set(bx3, EVAS_HINT_FILL, EVAS_HINT_FILL);
644 evas_object_size_hint_weight_set(bx3, EVAS_HINT_EXPAND, 0.9); 664 evas_object_size_hint_weight_set(bx3, EVAS_HINT_EXPAND, 0.8);
645 elm_box_pack_end(bx, bx3); 665 elm_box_pack_end(bx, bx3);
646 evas_object_show(bx3); 666 evas_object_show(bx3);
647 667
@@ -660,6 +680,7 @@ test_scroller3(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event
660 evas_object_smart_callback_add(bt, "clicked", _append_item, bx4); 680 evas_object_smart_callback_add(bt, "clicked", _append_item, bx4);
661 evas_object_smart_callback_add(bt2, "clicked", _prepend_item, bx4); 681 evas_object_smart_callback_add(bt2, "clicked", _prepend_item, bx4);
662 evas_object_smart_callback_add(bt3, "clicked", _append_items, bx4); 682 evas_object_smart_callback_add(bt3, "clicked", _append_items, bx4);
683 evas_object_smart_callback_add(sl, "changed", _changed_cb, sc);
663 684
664 evas_object_resize(win, 500, 500); 685 evas_object_resize(win, 500, 500);
665 evas_object_show(win); 686 evas_object_show(win);
diff --git a/src/lib/elementary/elm_interface_scrollable.c b/src/lib/elementary/elm_interface_scrollable.c
index 819ba2bbf1..f43bc0a0db 100644
--- a/src/lib/elementary/elm_interface_scrollable.c
+++ b/src/lib/elementary/elm_interface_scrollable.c
@@ -82,25 +82,7 @@ _round(double value, int pos)
82static void 82static void
83_elm_pan_update(Elm_Pan_Smart_Data *psd) 83_elm_pan_update(Elm_Pan_Smart_Data *psd)
84{ 84{
85 if (!psd->gravity_x && !psd->gravity_y)
86 {
87 evas_object_move(psd->content, psd->x - psd->px, psd->y - psd->py);
88 return;
89 }
90
91 if ((!psd->px) && (!psd->py))
92 {
93 psd->px = psd->delta_posx * psd->gravity_x;
94 psd->py = psd->delta_posy * psd->gravity_y;
95 }
96 psd->delta_posx += psd->content_w - psd->prev_cw;
97 psd->prev_cw = psd->content_w;
98 psd->delta_posy += psd->content_h - psd->prev_ch;
99 psd->prev_ch = psd->content_h;
100
101 evas_object_move(psd->content, psd->x - psd->px, psd->y - psd->py); 85 evas_object_move(psd->content, psd->x - psd->px, psd->y - psd->py);
102 psd->px = psd->delta_posx * psd->gravity_x;
103 psd->py = psd->delta_posy * psd->gravity_y;
104} 86}
105 87
106EOLIAN static void 88EOLIAN static void
@@ -205,24 +187,6 @@ _elm_pan_content_size_get(Eo *obj EINA_UNUSED, Elm_Pan_Smart_Data *psd, Evas_Coo
205 if (h) *h = psd->content_h; 187 if (h) *h = psd->content_h;
206} 188}
207 189
208EOLIAN static void
209_elm_pan_gravity_set(Eo *obj EINA_UNUSED, Elm_Pan_Smart_Data *psd, double x, double y)
210{
211 psd->gravity_x = x;
212 psd->gravity_y = y;
213 psd->prev_cw = psd->content_w;
214 psd->prev_ch = psd->content_h;
215 psd->delta_posx = 0;
216 psd->delta_posy = 0;
217}
218
219EOLIAN static void
220_elm_pan_gravity_get(Eo *obj EINA_UNUSED, Elm_Pan_Smart_Data *psd, double *x, double *y)
221{
222 if (x) *x = psd->gravity_x;
223 if (y) *y = psd->gravity_y;
224}
225
226static Evas_Object * 190static Evas_Object *
227_elm_pan_add(Evas *evas) 191_elm_pan_add(Evas *evas)
228{ 192{
@@ -250,8 +214,7 @@ _elm_pan_content_del_cb(void *data,
250 214
251 psd = data; 215 psd = data;
252 psd->content = NULL; 216 psd->content = NULL;
253 psd->content_w = psd->content_h = psd->px = psd->py = 217 psd->content_w = psd->content_h = psd->px = psd->py = 0;
254 psd->prev_cw = psd->prev_ch = psd->delta_posx = psd->delta_posy = 0;
255 efl_event_callback_legacy_call(psd->self, ELM_PAN_EVENT_CHANGED, NULL); 218 efl_event_callback_legacy_call(psd->self, ELM_PAN_EVENT_CHANGED, NULL);
256} 219}
257 220
@@ -1873,6 +1836,12 @@ _elm_scroll_wanted_region_set(Evas_Object *obj)
1873 wh = sid->wh; 1836 wh = sid->wh;
1874 } 1837 }
1875 1838
1839 wx += (sid->content_info.w - sid->prev_cw) * sid->gravity_x;
1840 sid->wy += (sid->content_info.h - sid->prev_ch) * sid->gravity_y;
1841
1842 sid->prev_cw = sid->content_info.w;
1843 sid->prev_ch = sid->content_info.h;
1844
1876 elm_interface_scrollable_content_region_set(obj, wx, sid->wy, ww, wh); 1845 elm_interface_scrollable_content_region_set(obj, wx, sid->wy, ww, wh);
1877} 1846}
1878 1847
@@ -4427,17 +4396,17 @@ _elm_interface_scrollable_region_bring_in(Eo *obj, Elm_Scrollable_Smart_Interfac
4427EOLIAN static void 4396EOLIAN static void
4428_elm_interface_scrollable_gravity_set(Eo *obj EINA_UNUSED, Elm_Scrollable_Smart_Interface_Data *sid, double x, double y) 4397_elm_interface_scrollable_gravity_set(Eo *obj EINA_UNUSED, Elm_Scrollable_Smart_Interface_Data *sid, double x, double y)
4429{ 4398{
4430 if (!sid->pan_obj) return; 4399 sid->gravity_x = x;
4431 4400 sid->gravity_y = y;
4432 elm_obj_pan_gravity_set(sid->pan_obj, x, y); 4401 sid->prev_cw = sid->content_info.w;
4402 sid->prev_ch = sid->content_info.h;
4433} 4403}
4434 4404
4435EOLIAN static void 4405EOLIAN static void
4436_elm_interface_scrollable_gravity_get(Eo *obj EINA_UNUSED, Elm_Scrollable_Smart_Interface_Data *sid, double *x, double *y) 4406_elm_interface_scrollable_gravity_get(Eo *obj EINA_UNUSED, Elm_Scrollable_Smart_Interface_Data *sid, double *x, double *y)
4437{ 4407{
4438 if (!sid->pan_obj) return; 4408 if (x) *x = sid->gravity_x;
4439 4409 if (y) *y = sid->gravity_y;
4440 elm_obj_pan_gravity_get(sid->pan_obj, x, y);
4441} 4410}
4442 4411
4443EOLIAN static void 4412EOLIAN static void
diff --git a/src/lib/elementary/elm_interface_scrollable.h b/src/lib/elementary/elm_interface_scrollable.h
index aa95df6147..001fb3a2f0 100644
--- a/src/lib/elementary/elm_interface_scrollable.h
+++ b/src/lib/elementary/elm_interface_scrollable.h
@@ -48,8 +48,6 @@ struct _Elm_Pan_Smart_Data
48 Evas_Object *content; 48 Evas_Object *content;
49 Evas_Coord x, y, w, h; 49 Evas_Coord x, y, w, h;
50 Evas_Coord content_w, content_h, px, py; 50 Evas_Coord content_w, content_h, px, py;
51 double gravity_x, gravity_y;
52 Evas_Coord prev_cw, prev_ch, delta_posx, delta_posy;
53}; 51};
54 52
55/** 53/**
@@ -209,6 +207,10 @@ struct _Elm_Scrollable_Smart_Interface_Data
209 unsigned char size_adjust_recurse; 207 unsigned char size_adjust_recurse;
210 unsigned char size_count; 208 unsigned char size_count;
211 void *event_info; 209 void *event_info;
210
211 double gravity_x, gravity_y;
212 Evas_Coord prev_cw, prev_ch;
213
212 Eina_Bool size_adjust_recurse_abort : 1; 214 Eina_Bool size_adjust_recurse_abort : 1;
213 215
214 Eina_Bool momentum_animator_disabled : 1; 216 Eina_Bool momentum_animator_disabled : 1;
diff --git a/src/lib/elementary/elm_pan.eo b/src/lib/elementary/elm_pan.eo
index 164846c257..4fa167edcf 100644
--- a/src/lib/elementary/elm_pan.eo
+++ b/src/lib/elementary/elm_pan.eo
@@ -5,16 +5,6 @@ class Elm.Pan (Efl.Canvas.Group.Clipped)
5 event_prefix: elm_pan; 5 event_prefix: elm_pan;
6 data: Elm_Pan_Smart_Data; 6 data: Elm_Pan_Smart_Data;
7 methods { 7 methods {
8 @property gravity {
9 set {
10 }
11 get {
12 }
13 values {
14 x: double;
15 y: double;
16 }
17 }
18 @property pos { 8 @property pos {
19 set { 9 set {
20 } 10 }