aboutsummaryrefslogtreecommitdiffstats
path: root/examples/elementary/test_naviframe.py
blob: a3c6f479f0bb846ff4c689ab443ff6ed47121ff9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#!/usr/bin/env python
# encoding: utf-8

import os

from efl import elementary as elm
from efl.elementary import StandardWindow, Box, Button, Icon, Naviframe, Photo
from efl.evas import EXPAND_BOTH, FILL_BOTH


script_path = os.path.dirname(os.path.abspath(__file__))
img_path = os.path.join(script_path, "images")

def navi_pop(bt, nf):
    nf.item_pop()

def title_visible(obj, item):
    item.title_enabled = (not item.title_enabled, True)

def page2(bt, nf):
    ic = Icon(nf, file=os.path.join(img_path, "icon_right_arrow.png"))

    bt = Button(nf, content=ic)
    bt.callback_clicked_add(page3, nf)

    content = Photo(nf, file=os.path.join(img_path, "plant_01.jpg"),
                    fill_inside=True, style="shadow")

    item = nf.item_push("Page 2", None, bt, content, "basic")
    item.part_text_set("subtitle", "Here is sub-title part!")

def page3(bt, nf):
    bt = Button(nf, text="Prev")
    bt.callback_clicked_add(navi_pop, nf)

    bt2 = Button(nf, text="Next")
    bt2.callback_clicked_add(page4, nf)

    content = Photo(nf, file=os.path.join(img_path, "rock_01.jpg"),
                    fill_inside=True, style="shadow")

    item = nf.item_push("Page 3", bt, bt2, content, "basic")

    ic = Icon(nf, file=os.path.join(img_path, "logo_small.png"))
    item.part_content_set("icon", ic)

def page4(bt, nf):
    ic = Icon(nf, file=os.path.join(img_path, "icon_right_arrow.png"))
    bt = Button(nf, content=ic)
    bt.callback_clicked_add(page5, nf)

    content = Photo(nf, file=os.path.join(img_path, "rock_02.jpg"),
                    fill_inside=True, style="shadow")

    item = nf.item_push("Page 4", None, bt, content, "basic")
    ic = Icon(nf, file=os.path.join(img_path, "logo_small.png"))
    item.part_content_set("icon", ic)
    item.part_text_set("subtitle", "Title area visibility test")
    item.title_enabled = (False, False)

    content.callback_clicked_add(title_visible, item)

def page5(bt, nf):
    bt = Button(nf, text="Page 4")
    bt.callback_clicked_add(navi_pop, nf)

    bt2 = Button(nf, text="Page 6")
    bt2.callback_clicked_add(page6, nf)

    content = Photo(nf, file=os.path.join(img_path, "sky_01.jpg"),
                    fill_inside=True, style="shadow")

    item = nf.item_insert_after(nf.top_item_get(), "Page 5", bt, bt2, content, "basic")
    item.part_text_set("subtitle", "This page is inserted without transition")

def page6(bt, nf):
    bt = Button(nf, text="Page 5")
    bt.callback_clicked_add(navi_pop, nf)

    bt2 = Button(nf, text="Page 7")
    bt2.callback_clicked_add(page7, nf)

    content = Photo(nf, file=os.path.join(img_path, "sky_03.jpg"),
                    fill_inside=True, style="shadow")

    item = nf.item_push("Page 6", bt, bt2, content, "overlap")
    item.part_text_set("subtitle", "Overlap style!")

def page7(bt, nf):
    bt = Button(nf, text="Page 6")
    bt.callback_clicked_add(navi_pop, nf)

    bt2 = Button(nf, text="Page 1")
    bt2.callback_clicked_add(lambda x: nf.data["page1"].promote())

    content = Photo(nf, file=os.path.join(img_path, "sky_02.jpg"),
                    fill_inside=True, style="shadow")

    item = nf.item_push("Page 7", bt, bt2, content, "overlap")
    item.part_text_set("subtitle", "Overlap style!")


def push_pop_cb(nf, item, signal):
    print("Signal: '%s' on item: %s " % (signal, item))


def test_naviframe(obj):
    win = StandardWindow("naviframe", "Naviframe test",
                         autodel=True, size=(400, 400))
    win.focus_highlight_enabled = True

    nf = Naviframe(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
    nf.callback_transition_finished_add(push_pop_cb, "transition,finished")
    nf.callback_item_activated_add(push_pop_cb, "item,activated")
    win.resize_object_add(nf)
    nf.show()

    bt = Button(win, text="Next")
    bt.callback_clicked_add(page2, nf)

    content = Photo(nf, file=os.path.join(img_path, "logo.png"),
                    fill_inside=True, style="shadow")

    item = nf.item_push("Page 1", None, bt, content, "basic")
    nf.data["page1"] = item

    win.show()


if __name__ == "__main__":
    elm.policy_set(elm.ELM_POLICY_QUIT, elm.ELM_POLICY_QUIT_LAST_WINDOW_CLOSED)
    test_naviframe(None)
    elm.run()