aboutsummaryrefslogtreecommitdiffstats
path: root/examples/elementary/test_scroller.py
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 /examples/elementary/test_scroller.py
parentUse atexit to shutdown eo, evas and ecore modules (diff)
downloadpython-efl-f183fc171f314cdafe40a05c3d8fb57a13cf6134.tar.gz
New 1.14 API: elm.Scroller.loop
Scroller test redone to include loop and more
Diffstat (limited to 'examples/elementary/test_scroller.py')
-rw-r--r--examples/elementary/test_scroller.py139
1 files changed, 103 insertions, 36 deletions
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, \
from efl import elementary
from efl.elementary.window import StandardWindow
from efl.elementary.background import Background
+from efl.elementary.box import Box
from efl.elementary.button import Button
-from efl.elementary.scroller import Scroller
+from efl.elementary.check import Check
+from efl.elementary.frame import Frame
+from efl.elementary.scroller import Scroller, \
+ ELM_SCROLLER_MOVEMENT_BLOCK_VERTICAL, ELM_SCROLLER_MOVEMENT_BLOCK_HORIZONTAL
from efl.elementary.table import Table
@@ -37,6 +41,36 @@ def cb_drags(obj, action):
def cb_anims(obj, action):
print("Anim callback: " + action)
+def cb_freeze(chk, scroller):
+ if chk.state:
+ scroller.scroll_freeze_push()
+ else:
+ scroller.scroll_freeze_pop()
+
+def cb_hold(chk, scroller):
+ if chk.state:
+ scroller.scroll_hold_push()
+ else:
+ scroller.scroll_hold_pop()
+
+def cb_block(chk, scroller, direction):
+ if chk.state:
+ scroller.movement_block |= direction
+ else:
+ scroller.movement_block &= 0xFF ^ direction
+
+def cb_snap(chk, scroller):
+ scroller.page_snap = (chk.state, chk.state)
+
+def cb_loop_h(chk, scroller):
+ h, v = scroller.loop
+ scroller.loop = chk.state, v
+
+def cb_loop_v(chk, scroller):
+ h, v = scroller.loop
+ scroller.loop = h, chk.state
+
+
def scroller_clicked(obj):
win = StandardWindow("scroller", "Scroller", autodel=True, size=(320, 320))
if obj is None:
@@ -44,31 +78,23 @@ def scroller_clicked(obj):
tb = Table(win, size_hint_weight=EXPAND_BOTH)
- img = ["panel_01.jpg",
- "plant_01.jpg",
- "rock_01.jpg",
- "rock_02.jpg",
- "sky_01.jpg",
- "sky_02.jpg",
- "sky_03.jpg",
- "sky_04.jpg",
- "wood_01.jpg"]
+ img = ["panel_01.jpg", "plant_01.jpg", "rock_01.jpg",
+ "rock_02.jpg", "sky_01.jpg", "sky_02.jpg",
+ "sky_03.jpg", "sky_04.jpg", "wood_01.jpg"]
n = 0
for j in range(12):
for i in range(12):
- bg2 = Background(win, file=os.path.join(img_path, img[n]),
- size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH,
- size_hint_min=(318, 318))
-
+ bg = Background(win, file=os.path.join(img_path, img[n]),
+ size_hint_min=(318, 318))
n += 1
if n >= 9:
n = 0
- tb.pack(bg2, i, j, 1, 1)
- bg2.show()
+ tb.pack(bg, i, j, 1, 1)
+ bg.show()
- sc = Scroller(win, size_hint_weight=EXPAND_BOTH, content=tb,
- page_relative=(1.0, 1.0))
+ sc = Scroller(win, content=tb, page_size=(318, 318),
+ size_hint_expand=EXPAND_BOTH, size_hint_fill=FILL_BOTH)
sc.callback_edge_top_add(cb_edges, "top")
sc.callback_edge_bottom_add(cb_edges, "bottom")
sc.callback_edge_left_add(cb_edges, "left")
@@ -77,41 +103,82 @@ def scroller_clicked(obj):
sc.callback_scroll_drag_stop_add(cb_drags, "stop")
sc.callback_scroll_anim_start_add(cb_anims, "start")
sc.callback_scroll_anim_stop_add(cb_anims, "stop")
- win.resize_object_add(sc)
-
- tb.show()
-
sc.show()
+ tb.show()
- tb2 = Table(win, size_hint_weight=EXPAND_BOTH)
+ tb2 = Table(win, size_hint_expand=EXPAND_BOTH, size_hint_fill=FILL_BOTH)
win.resize_object_add(tb2)
+ tb2.pack(sc, 0, 1, 1, 1)
+ tb2.show()
- bt = Button(win, text="to 300 300", size_hint_weight=EXPAND_BOTH,
- size_hint_align=(0.1, 0.1))
+ fr = Frame(win, text="Options", size_hint_expand=EXPAND_HORIZ,
+ size_hint_fill=FILL_HORIZ)
+ tb2.pack(fr, 0, 0, 1, 1)
+ fr.show()
+
+ box = Box(fr, horizontal=True)
+ fr.content = box
+ box.show()
+
+ ck = Check(box, text="Freeze")
+ ck.callback_changed_add(cb_freeze, sc)
+ box.pack_end(ck)
+ ck.show()
+
+ ck = Check(box, text="Hold")
+ ck.callback_changed_add(cb_hold, sc)
+ box.pack_end(ck)
+ ck.show()
+
+ ck = Check(box, text="Block in X axis")
+ ck.callback_changed_add(cb_block, sc, ELM_SCROLLER_MOVEMENT_BLOCK_HORIZONTAL)
+ box.pack_end(ck)
+ ck.show()
+
+ ck = Check(box, text="Block in Y axis")
+ ck.callback_changed_add(cb_block, sc, ELM_SCROLLER_MOVEMENT_BLOCK_VERTICAL)
+ box.pack_end(ck)
+ ck.show()
+
+ ck = Check(box, text="Snap to pages")
+ ck.callback_changed_add(cb_snap, sc)
+ box.pack_end(ck)
+ ck.show()
+
+ ck = Check(box, text="Loop in X axis")
+ ck.callback_changed_add(cb_loop_h, sc)
+ box.pack_end(ck)
+ ck.show()
+
+ ck = Check(box, text="Loop in Y axis")
+ ck.callback_changed_add(cb_loop_v, sc)
+ box.pack_end(ck)
+ ck.show()
+
+ bt = Button(win, text="to 300 300", size_hint_expand=EXPAND_BOTH,
+ size_hint_align=(0.1, 0.1))
bt.callback_clicked_add(my_scroller_go_300_300, sc)
- tb2.pack(bt, 0, 0, 1, 1)
+ tb2.pack(bt, 0, 1, 1, 1)
bt.show()
- bt = Button(win, text="to 900 300", size_hint_weight=EXPAND_BOTH,
- size_hint_align=(0.9, 0.1))
+ bt = Button(win, text="to 900 300", size_hint_expand=EXPAND_BOTH,
+ size_hint_align=(0.9, 0.1))
bt.callback_clicked_add(my_scroller_go_900_300, sc)
- tb2.pack(bt, 1, 0, 1, 1)
+ tb2.pack(bt, 0, 1, 1, 1)
bt.show()
- bt = Button(win, text="to 300 900", size_hint_weight=EXPAND_BOTH,
- size_hint_align=(0.1, 0.9))
+ bt = Button(win, text="to 300 900", size_hint_expand=EXPAND_BOTH,
+ size_hint_align=(0.1, 0.9))
bt.callback_clicked_add(my_scroller_go_300_900, sc)
tb2.pack(bt, 0, 1, 1, 1)
bt.show()
- bt = Button(win, text="to 900 900", size_hint_weight=EXPAND_BOTH,
- size_hint_align=(0.9, 0.9))
+ bt = Button(win, text="to 900 900", size_hint_expand=EXPAND_BOTH,
+ size_hint_align=(0.9, 0.9))
bt.callback_clicked_add(my_scroller_go_900_900, sc)
- tb2.pack(bt, 1, 1, 1, 1)
+ tb2.pack(bt, 0, 1, 1, 1)
bt.show()
- tb2.show()
-
win.show()