aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/LuaSL/LuaSL.edc
diff options
context:
space:
mode:
Diffstat (limited to 'LuaSL/LuaSL.edc')
-rw-r--r--LuaSL/LuaSL.edc205
1 files changed, 205 insertions, 0 deletions
diff --git a/LuaSL/LuaSL.edc b/LuaSL/LuaSL.edc
new file mode 100644
index 0000000..844fc8e
--- /dev/null
+++ b/LuaSL/LuaSL.edc
@@ -0,0 +1,205 @@
1color_classes {
2 color_class { name: "test_colour"; color: 255 255 255 255; }
3}
4
5//fonts {
6// font: "Vera.ttf" "default";
7//}
8
9images {
10 image: "bubble.png" COMP;
11 image: "test.png" COMP;
12}
13
14collections {
15 group {
16 name: "main";
17 lua_script_only: 1;
18 lua_script {
19 --// stick object private/local vars here
20 local D;
21 local text_geom;
22
23 --// init object here
24 D = {}; --// data is empty table to start
25
26 --// send some random edje message
27 edje.messagesend(7, "none" );
28 edje.messagesend(7, "sig", "signal", "source");
29 edje.messagesend(7, "str", "hello world");
30 edje.messagesend(7, "int", 987);
31 edje.messagesend(7, "float", 987.321);
32 edje.messagesend(7, "strset", {"hello", "there", "world"});
33 edje.messagesend(7, "intset", {1, 2, 3});
34 edje.messagesend(7, "floatset", {1.1, 2.2, 3.3});
35 edje.messagesend(7, "strint", "hello world", 7);
36 edje.messagesend(7, "strfloat", "hello world", 7.654);
37 edje.messagesend(7, "strintset","hello world", {1, 2, 3});
38
39 D.edje = edje.edje();
40 D.edje:file("plain/edje/group");
41 D.edje:show();
42
43 D.text = edje.text();
44 D.text:geom (50, 5, 150, 50);
45 D.text:color (255, 0, 0, 255);
46 D.text:font("Sans:style=Bold", 32);
47 D.text:text("Lua rocks!");
48 text_geom = D.text:geom();
49--// print(D.text:text());
50 D.text:show();
51
52
53 --// shutdown func - generally empty or not there. everything garbage collected for you
54 function shutdown ()
55--// print("lua::shutdown");
56 end
57
58 function show ()
59--// print("lua::show");
60 end
61
62 function hide ()
63--// print("lua::hide");
64 end
65
66 function move (x, y)
67--// print("lua::move x=" .. x .. " x=" .. y);
68 D.edje:move(0, 0);
69 end
70
71 function resize (w, h)
72--// print("lua::resize w=" .. w .. " h=" .. h);
73 D.text:move((w - text_geom.w) / 2, (h - text_geom.h) / 8);
74 D.edje:resize(w, h);
75 end
76
77 function message (id, type, ...)
78 print("lua::message id=" .. id .. " type=" .. type);
79 --// handle your message type here. check id + type then use the
80 --// vararg appropriately. they are the same as the params passed
81 --// to edje:messagesend() (if any are passed at all). Any array
82 --// arguments are passed as a single table.
83
84 if ("none" == type) then
85 print("lua::message no args");
86 elseif ("strset" == type) then
87 strs = ... ;
88 print_table_start(strs, "", "lua::message strings");
89 elseif ("intset" == type) then
90 ints = ... ;
91 print_table_start(ints, "", "lua::message ints");
92 elseif ("floatset" == type) then
93 floats = ... ;
94 print_table_start(floats, "", "lua::message floats");
95 elseif ("strintset" == type) then
96 str, ints = ... ;
97 print("lua::message " .. str);
98 print_table_start(ints, "", "lua::message ints");
99 elseif ("strfloatset" == type) then
100 str, floats = ... ;
101 print("lua::message " .. str);
102 print_table_start(floats, "", "lua::message floats");
103 else
104 print("lua::message " .. ... );
105 end
106 end
107
108 function signal (sig, src)
109 print("lua::signal sig= " .. sig .. " src= " .. src);
110 end
111 }
112 }
113
114 // The group name NEEDS a / in it,
115 // or the part below that tries to swallow it won't work.
116 // Leaving just the lua part visible.
117 group {
118 name: "bubbles/lua";
119 lua_script_only: 1;
120 lua_script {
121 local bubbles = { };
122 local bubbleCols = 8;
123 local bubbleRows = 6;
124
125 for i = 1, bubbleRows do
126 row = { };
127 for j = 1, bubbleCols do
128 image = edje.image();
129 image:image("bubble.png");
130 image:show();
131 table.insert(row, image);
132 end
133 table.insert(bubbles, row);
134 end
135
136 function resize (w, h)
137 for i = 1, bubbleRows do
138 for j = 1, bubbleCols do
139 w1 = w / bubbleCols;
140 h1 = h / bubbleRows;
141 bubbles[i][j]:geom((j - 1) * w1, (i - 1) * h1, w1, h1);
142 if ((1 == i) or (1 == j) or (bubbleRows == i) or (bubbleCols == j)) then
143 bubbles[i][j]:color(0, 255, 0, 200);
144 else
145 bubbles[i][j]:color(math.random(200) + 55, 0, math.random(255) + 55, 200);
146 end
147 end
148 end
149 end
150 }
151 }
152
153 group {
154 name: "plain/edje/group";
155 parts {
156 part {
157 name: "background";
158 type: RECT;
159 mouse_events: 0;
160 description {
161 state: "default" 0.0;
162 color: 0 0 0 255;
163 }
164 }
165
166 // A lua group embedded in an edje group.
167 part {
168 name: "bubbles_lua";
169 type: GROUP;
170 source: "bubbles/lua";
171 mouse_events: 0;
172 description { state: "default" 0.0; }
173 }
174
175 part {
176 name: "background_image";
177 type: IMAGE;
178 mouse_events: 0;
179 description {
180 state: "default" 0.0;
181 aspect_preference: HORIZONTAL;
182 color_class: "test_colour";
183 image { normal: "test.png"; }
184 }
185 }
186
187 part {
188 name: "some_text";
189 type: TEXT;
190 mouse_events: 0;
191 description {
192 state: "default" 0;
193 text
194 {
195 text: "This is test text.";
196 text_class: "test_text_class";
197 }
198 }
199 }
200
201 }
202 }
203
204}
205