fixed X11_softare_info changing
[ego.git] / test / showcase.lua
blobf4a940ef1b1e0a9c86e512e6e240f9e5ccfa8608
1 images = {
2 'hrg0001.jpg',
3 'hrg0002.jpg',
4 'hrg0003.jpg',
5 'hrg0004.jpg',
6 'hrg0005.jpg',
7 'hrg0006.jpg',
8 'hrg0007.jpg',
9 'hrg0008.jpg',
10 'hrg0009.jpg',
11 'hrg0010.jpg',
12 'hrg0011.jpg',
13 'hrg0012.jpg',
14 'hrg0013.jpg',
16 'thumb_hrg0001.jpg',
17 'thumb_hrg0002.jpg',
18 'thumb_hrg0003.jpg',
19 'thumb_hrg0004.jpg',
20 'thumb_hrg0005.jpg',
21 'thumb_hrg0006.jpg',
22 'thumb_hrg0007.jpg',
23 'thumb_hrg0008.jpg',
24 'thumb_hrg0009.jpg',
25 'thumb_hrg0010.jpg',
26 'thumb_hrg0011.jpg',
27 'thumb_hrg0012.jpg',
28 'thumb_hrg0013.jpg'
31 -- box
32 box = ego:table {
33 size_hint_weight = {1, 1},
34 homogeneous = true,
35 visible = true
38 n = #images / 2
39 box.edjs = {}
40 box.thumbs = {}
41 box.imgs = {}
42 for i = 0, n-1 do
43 box.edjs[i] = ego:edje {
44 id = i,
45 group = 'icon',
46 size_hint_min = {32, 32},
47 size_hint_max = {64, 64},
48 size_hint_weight = {1, 1},
49 size_hint_align = {0, 0},
50 size_hint_aspect = {4, 1, 1},
51 visible = true,
52 callback_mouse_down = function (self, button, x, y, X, Y)
53 if lay.new ~= box.imgs[self.id] then
54 lay:signal_emit ('fade,out', '')
55 lay.old = lay.new
56 lay.new = box.imgs[self.id]
57 end
58 end,
60 box.edjs[i]:resize (64, 64)
62 box.imgs[i] = ego:image {
63 id = i,
64 file = images[i],
65 name = images[i],
66 size_hint_weight = {1, 1},
67 callback_resize = function (self) self:fit () end,
68 visible = false
70 local size = box.imgs[i].size
71 box.imgs[i].size_hint_aspect = {4, size[1], size[2]}
73 box.thumbs[i] = ego:image {
74 id = i + n,
75 file = images[i],
76 name = images[i],
77 size_hint_weight = {1, 1},
78 size_hint_aspect = {4, size[1], size[2]},
79 callback_resize = function (self) self:fit () end,
80 visible = true
82 size = box.thumbs[i].size
83 box.edjs[i].content.swallow = box.thumbs[i]
84 box:pack (box.edjs[i], i-1, 0, 1, 1)
85 end
87 -- scroller
88 scr = ego:scroller {
89 size_hint_weight = {1, 1},
90 content = box,
91 content_min_limit = {false, true}
94 -- layout
95 lay = ego:edje {
96 focus = 1,
97 callback_key_down = function (self, key)
98 if key == 'Escape' then
99 ego:quit ()
100 elseif key == 't' then
101 if ego.visible then
102 ego:hide ()
103 else
104 ego:show ()
107 end,
108 layer = 1,
109 group = 'layout',
110 visible = true,
111 size = {1, 1},
112 signal_callback = function (self, signal, source)
113 if signal == 'faded,out' then
114 lay.bg_content:unswallow ()
115 lay.old.visible = false
116 lay.new.visible = true
117 lay.bg_content.swallow = lay.new
118 lay:signal_emit ('fade,in', '')
122 lay.new = box.imgs[1]
123 lay.new.visible = true
124 lay.bg_content.swallow = lay.new
126 lay.bar_content.swallow = scr
127 lay:signal_emit ('fade,in', '')