summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Andreoli <dave@gurumeditation.it>2015-04-16 22:05:41 +0200
committerDave Andreoli <dave@gurumeditation.it>2015-04-16 22:05:55 +0200
commitf183fc171f314cdafe40a05c3d8fb57a13cf6134 (patch)
tree584b1b8d58d0b4bdc32b22ee3ce30bbc0e2eb2d3
parent219ba9cdd960838dd164aa383b2233e44af5337f (diff)
New 1.14 API: elm.Scroller.loop
Scroller test redone to include loop and more
-rw-r--r--efl/elementary/scroller.pxd2
-rw-r--r--efl/elementary/scroller.pyx27
-rw-r--r--examples/elementary/test_scroller.py139
3 files changed, 131 insertions, 37 deletions
diff --git a/efl/elementary/scroller.pxd b/efl/elementary/scroller.pxd
index 0b008c5..7de1f39 100644
--- a/efl/elementary/scroller.pxd
+++ b/efl/elementary/scroller.pxd
@@ -60,6 +60,8 @@ cdef extern from "Elementary.h":
60 void elm_scroller_gravity_get(const Evas_Object *obj, double *x, double *y) 60 void elm_scroller_gravity_get(const Evas_Object *obj, double *x, double *y)
61 void elm_scroller_movement_block_set(Evas_Object *obj, Elm_Scroller_Movement_Block block) 61 void elm_scroller_movement_block_set(Evas_Object *obj, Elm_Scroller_Movement_Block block)
62 Elm_Scroller_Movement_Block elm_scroller_movement_block_get(const Evas_Object *obj) 62 Elm_Scroller_Movement_Block elm_scroller_movement_block_get(const Evas_Object *obj)
63 void elm_scroller_loop_set(Evas_Object *obj, Eina_Bool loop_h, Eina_Bool loop_v)
64 void elm_scroller_loop_get(const Evas_Object *obj, Eina_Bool *loop_h, Eina_Bool *loop_v)
63 65
64cdef class Scrollable(Object): 66cdef class Scrollable(Object):
65 pass 67 pass
diff --git a/efl/elementary/scroller.pyx b/efl/elementary/scroller.pyx
index d4ab6e0..8efff31 100644
--- a/efl/elementary/scroller.pyx
+++ b/efl/elementary/scroller.pyx
@@ -696,7 +696,6 @@ cdef class Scrollable(Object):
696 696
697 .. versionadded:: 1.8 697 .. versionadded:: 1.8
698 698
699
700 """ 699 """
701 def __set__(self, Elm_Scroller_Movement_Block block): 700 def __set__(self, Elm_Scroller_Movement_Block block):
702 elm_scroller_movement_block_set(self.obj, block) 701 elm_scroller_movement_block_set(self.obj, block)
@@ -704,6 +703,32 @@ cdef class Scrollable(Object):
704 def __get__(self): 703 def __get__(self):
705 return elm_scroller_movement_block_get(self.obj) 704 return elm_scroller_movement_block_get(self.obj)
706 705
706 property loop:
707 """
708
709 Set an infinite loop for the scroller
710
711 :type: (bool **h**, bool **v**)
712
713 .. versionadded:: 1.14
714
715 """
716 def __set__(self, value):
717 h, v = value
718 elm_scroller_loop_set(self.obj, h, v)
719
720 def __get__(self):
721 cdef Eina_Bool h, v
722 elm_scroller_loop_get(self.obj, &h, &v)
723 return (h, v)
724
725 def loop_set(self, h, v):
726 elm_scroller_loop_set(self.obj, h, v)
727 def loop_get(self):
728 cdef Eina_Bool h, v
729 elm_scroller_loop_get(self.obj, &h, &v)
730 return (h, v)
731
707 def callback_edge_left_add(self, func, *args, **kwargs): 732 def callback_edge_left_add(self, func, *args, **kwargs):
708 """The left edge of the content has been reached.""" 733 """The left edge of the content has been reached."""
709 self._callback_add("edge,left", func, args, kwargs) 734 self._callback_add("edge,left", func, args, kwargs)
diff --git a/examples/elementary/test_scroller.py b/examples/elementary/test_scroller.py
index 1b9827b..1b01763 100644
--- a/examples/elementary/test_scroller.py
+++ b/examples/elementary/test_scroller.py
@@ -8,8 +8,12 @@ from efl.evas import EVAS_HINT_EXPAND, EVAS_HINT_FILL, \
8from efl import elementary 8from efl import elementary
9from efl.elementary.window import StandardWindow 9from efl.elementary.window import StandardWindow
10from efl.elementary.background import Background 10from efl.elementary.background import Background
11from efl.elementary.box import Box
11from efl.elementary.button import Button 12from efl.elementary.button import Button
12from efl.elementary.scroller import Scroller 13from efl.elementary.check import Check
14from efl.elementary.frame import Frame
15from efl.elementary.scroller import Scroller, \
16 ELM_SCROLLER_MOVEMENT_BLOCK_VERTICAL, ELM_SCROLLER_MOVEMENT_BLOCK_HORIZONTAL
13from efl.elementary.table import Table 17from efl.elementary.table import Table
14 18
15 19
@@ -37,6 +41,36 @@ def cb_drags(obj, action):
37def cb_anims(obj, action): 41def cb_anims(obj, action):
38 print("Anim callback: " + action) 42 print("Anim callback: " + action)
39 43
44def cb_freeze(chk, scroller):
45 if chk.state:
46 scroller.scroll_freeze_push()
47 else:
48 scroller.scroll_freeze_pop()
49
50def cb_hold(chk, scroller):
51 if chk.state:
52 scroller.scroll_hold_push()
53 else:
54 scroller.scroll_hold_pop()
55
56def cb_block(chk, scroller, direction):
57 if chk.state:
58 scroller.movement_block |= direction
59 else:
60 scroller.movement_block &= 0xFF ^ direction
61
62def cb_snap(chk, scroller):
63 scroller.page_snap = (chk.state, chk.state)
64
65def cb_loop_h(chk, scroller):
66 h, v = scroller.loop
67 scroller.loop = chk.state, v
68
69def cb_loop_v(chk, scroller):
70 h, v = scroller.loop
71 scroller.loop = h, chk.state
72
73
40def scroller_clicked(obj): 74def scroller_clicked(obj):
41 win = StandardWindow("scroller", "Scroller", autodel=True, size=(320, 320)) 75 win = StandardWindow("scroller", "Scroller", autodel=True, size=(320, 320))
42 if obj is None: 76 if obj is None:
@@ -44,31 +78,23 @@ def scroller_clicked(obj):
44 78
45 tb = Table(win, size_hint_weight=EXPAND_BOTH) 79 tb = Table(win, size_hint_weight=EXPAND_BOTH)
46 80
47 img = ["panel_01.jpg", 81 img = ["panel_01.jpg", "plant_01.jpg", "rock_01.jpg",
48 "plant_01.jpg", 82 "rock_02.jpg", "sky_01.jpg", "sky_02.jpg",
49 "rock_01.jpg", 83 "sky_03.jpg", "sky_04.jpg", "wood_01.jpg"]
50 "rock_02.jpg",
51 "sky_01.jpg",
52 "sky_02.jpg",
53 "sky_03.jpg",
54 "sky_04.jpg",
55 "wood_01.jpg"]
56 84
57 n = 0 85 n = 0
58 for j in range(12): 86 for j in range(12):
59 for i in range(12): 87 for i in range(12):
60 bg2 = Background(win, file=os.path.join(img_path, img[n]), 88 bg = Background(win, file=os.path.join(img_path, img[n]),
61 size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH, 89 size_hint_min=(318, 318))
62 size_hint_min=(318, 318))
63
64 n += 1 90 n += 1
65 if n >= 9: 91 if n >= 9:
66 n = 0 92 n = 0
67 tb.pack(bg2, i, j, 1, 1) 93 tb.pack(bg, i, j, 1, 1)
68 bg2.show() 94 bg.show()
69 95
70 sc = Scroller(win, size_hint_weight=EXPAND_BOTH, content=tb, 96 sc = Scroller(win, content=tb, page_size=(318, 318),
71 page_relative=(1.0, 1.0)) 97 size_hint_expand=EXPAND_BOTH, size_hint_fill=FILL_BOTH)
72 sc.callback_edge_top_add(cb_edges, "top") 98 sc.callback_edge_top_add(cb_edges, "top")
73 sc.callback_edge_bottom_add(cb_edges, "bottom") 99 sc.callback_edge_bottom_add(cb_edges, "bottom")
74 sc.callback_edge_left_add(cb_edges, "left") 100 sc.callback_edge_left_add(cb_edges, "left")
@@ -77,41 +103,82 @@ def scroller_clicked(obj):
77 sc.callback_scroll_drag_stop_add(cb_drags, "stop") 103 sc.callback_scroll_drag_stop_add(cb_drags, "stop")
78 sc.callback_scroll_anim_start_add(cb_anims, "start") 104 sc.callback_scroll_anim_start_add(cb_anims, "start")
79 sc.callback_scroll_anim_stop_add(cb_anims, "stop") 105 sc.callback_scroll_anim_stop_add(cb_anims, "stop")
80 win.resize_object_add(sc)
81
82 tb.show()
83
84 sc.show() 106 sc.show()
107 tb.show()
85 108
86 tb2 = Table(win, size_hint_weight=EXPAND_BOTH) 109 tb2 = Table(win, size_hint_expand=EXPAND_BOTH, size_hint_fill=FILL_BOTH)
87 win.resize_object_add(tb2) 110 win.resize_object_add(tb2)
111 tb2.pack(sc, 0, 1, 1, 1)
112 tb2.show()
88 113
89 bt = Button(win, text="to 300 300", size_hint_weight=EXPAND_BOTH, 114 fr = Frame(win, text="Options", size_hint_expand=EXPAND_HORIZ,
90 size_hint_align=(0.1, 0.1)) 115 size_hint_fill=FILL_HORIZ)
116 tb2.pack(fr, 0, 0, 1, 1)
117 fr.show()
118
119 box = Box(fr, horizontal=True)
120 fr.content = box
121 box.show()
122
123 ck = Check(box, text="Freeze")
124 ck.callback_changed_add(cb_freeze, sc)
125 box.pack_end(ck)
126 ck.show()
127
128 ck = Check(box, text="Hold")
129 ck.callback_changed_add(cb_hold, sc)
130 box.pack_end(ck)
131 ck.show()
132
133 ck = Check(box, text="Block in X axis")
134 ck.callback_changed_add(cb_block, sc, ELM_SCROLLER_MOVEMENT_BLOCK_HORIZONTAL)
135 box.pack_end(ck)
136 ck.show()
137
138 ck = Check(box, text="Block in Y axis")
139 ck.callback_changed_add(cb_block, sc, ELM_SCROLLER_MOVEMENT_BLOCK_VERTICAL)
140 box.pack_end(ck)
141 ck.show()
142
143 ck = Check(box, text="Snap to pages")
144 ck.callback_changed_add(cb_snap, sc)
145 box.pack_end(ck)
146 ck.show()
147
148 ck = Check(box, text="Loop in X axis")
149 ck.callback_changed_add(cb_loop_h, sc)
150 box.pack_end(ck)
151 ck.show()
152
153 ck = Check(box, text="Loop in Y axis")
154 ck.callback_changed_add(cb_loop_v, sc)
155 box.pack_end(ck)
156 ck.show()
157
158 bt = Button(win, text="to 300 300", size_hint_expand=EXPAND_BOTH,
159 size_hint_align=(0.1, 0.1))
91 bt.callback_clicked_add(my_scroller_go_300_300, sc) 160 bt.callback_clicked_add(my_scroller_go_300_300, sc)
92 tb2.pack(bt, 0, 0, 1, 1) 161 tb2.pack(bt, 0, 1, 1, 1)
93 bt.show() 162 bt.show()
94 163
95 bt = Button(win, text="to 900 300", size_hint_weight=EXPAND_BOTH, 164 bt = Button(win, text="to 900 300", size_hint_expand=EXPAND_BOTH,
96 size_hint_align=(0.9, 0.1)) 165 size_hint_align=(0.9, 0.1))
97 bt.callback_clicked_add(my_scroller_go_900_300, sc) 166 bt.callback_clicked_add(my_scroller_go_900_300, sc)
98 tb2.pack(bt, 1, 0, 1, 1) 167 tb2.pack(bt, 0, 1, 1, 1)
99 bt.show() 168 bt.show()
100 169
101 bt = Button(win, text="to 300 900", size_hint_weight=EXPAND_BOTH, 170 bt = Button(win, text="to 300 900", size_hint_expand=EXPAND_BOTH,
102 size_hint_align=(0.1, 0.9)) 171 size_hint_align=(0.1, 0.9))
103 bt.callback_clicked_add(my_scroller_go_300_900, sc) 172 bt.callback_clicked_add(my_scroller_go_300_900, sc)
104 tb2.pack(bt, 0, 1, 1, 1) 173 tb2.pack(bt, 0, 1, 1, 1)
105 bt.show() 174 bt.show()
106 175
107 bt = Button(win, text="to 900 900", size_hint_weight=EXPAND_BOTH, 176 bt = Button(win, text="to 900 900", size_hint_expand=EXPAND_BOTH,
108 size_hint_align=(0.9, 0.9)) 177 size_hint_align=(0.9, 0.9))
109 bt.callback_clicked_add(my_scroller_go_900_900, sc) 178 bt.callback_clicked_add(my_scroller_go_900_900, sc)
110 tb2.pack(bt, 1, 1, 1, 1) 179 tb2.pack(bt, 0, 1, 1, 1)
111 bt.show() 180 bt.show()
112 181
113 tb2.show()
114
115 win.show() 182 win.show()
116 183
117 184