2
color_class { name: "test_colour"; color: 255 255 255 255; }
6
font: "Vera.ttf" "default";
10
image: "bubble.png" COMP;
11
image: "test.png" COMP;
19
--// stick object private/local vars here
25
--// Functions to print tables.
26
local print_table, print_table_start;
28
function print_table_start(table, space, name)
29
print(space .. name .. ": ");
31
print_table(table, space .. " ");
35
function print_table(table, space)
36
for k, v in pairs(table) do
37
if type(v) == "table" then
38
print_table_start(v, space, k);
39
elseif type(v) == "string" then
40
print(space .. k .. ': "' .. v .. '";')
42
print(space .. k .. ": " .. v .. ";")
47
local function mycb3 (v)
48
print("lua::callback transition " .. D.val .. " v: " .. v);
51
print("lua::objsize= " .. d.w .. " , " .. d.h);
52
sz = {w=v * 80, h=v * 40};
53
D.rect:geom(((d.w / 2) * math.sin(v * 2 * math.pi)) + ((d.w - sz.w) / 2),
54
((d.h / 2) * math.cos(v * 2 * math.pi)) + ((d.h - sz.h) / 2),
56
D.rect:color(255, 128, v * 255, 255);
58
print("lua::pos= " .. d.x .. " , " .. d.y);
63
r:color(20, v * 255, 60, 255);
65
print("lua::r none!!!!!!!!!!!!!!1");
68
D.clip:geom(10, 10, d.w - 20, d.h - 20);
72
print("lua::" .. i .. " geom = " .. d.x .. "," .. d.y .. " " .. d.w .. "x" .. d.h);
74
return true; --// repeat the timer
77
local function mycb2 ()
78
print("lua::callback animator " .. count .. " seconds: " .. edje.seconds() .. " looptime: " .. edje.looptime());
79
edje.color_class("test_colour", 255, (count * 10) % 255, 255, 255);
80
edje.text_class("test_text_class", "Sans:style=Bold", ((count * 3) % 100) + 8);
81
if (5 > (count % 10)) then
82
D.text:font("default", 32);
84
D.text:font("Sans:style=Bold", 32);
86
edje_geom = edje.geom();
87
text_geom = D.text:geom();
88
D.text:move((edje_geom.w - text_geom.w) / 2, (edje_geom.h - text_geom.h) / 8);
89
return true; --// repeat the timer
92
local function mycb ()
93
print("lua::callback timer " .. count .. " fndata = " .. fndata);
94
count = count + 1; --// keep count of calls - object data
95
fndata = fndata + 3; --// play with object vars to see if they persist
96
D.tim = edje.timer(0.25, mycb); --// inside cb add new timer
97
return false; --// cease repeating the timer
100
--// init object here
101
D = {}; --// data is empty table to start
102
D.val = math.random(); --// start with some random value so
103
fndata = fndata + D.val; --// func data start point
104
print("lua::init ... " .. D.val);
105
edje.echo("lua::echo('hello world')");
107
--// How to check the edje version.
108
version = edje.version();
109
print("The edje version number is " .. version.major .. "." .. version.minor);
111
--// actually add the timer to call mycb in 1.23 sec
112
D.tim = edje.timer(1.23, mycb);
113
D.tra = edje.transition(5.0, mycb3);
114
D.ani = edje.animator(mycb2);
115
edje_geom = edje.geom();
117
if (edje.spanky) then edje.spanky(); end
119
local date = edje.date();
120
print("lua:: date: " ..
124
date.yearday .. "|" ..
125
date.weekday .. "|" ..
131
--// send some random edje message
132
edje.messagesend(7, "none" );
133
edje.messagesend(7, "sig", "signal", "source");
134
edje.messagesend(7, "str", "hello world");
135
edje.messagesend(7, "int", 987);
136
edje.messagesend(7, "float", 987.321);
137
edje.messagesend(7, "strset", {"hello", "there", "world"});
138
edje.messagesend(7, "intset", {1, 2, 3});
139
edje.messagesend(7, "floatset", {1.1, 2.2, 3.3});
140
edje.messagesend(7, "strint", "hello world", 7);
141
edje.messagesend(7, "strfloat", "hello world", 7.654);
142
edje.messagesend(7, "strintset","hello world", {1, 2, 3});
144
D.edje = edje.edje();
145
D.edje:file("plain/edje/group");
148
D.rect = edje.rect();
149
D.rect:geom (5, 10, 50, 30);
150
D.rect:color (255, 128, 60, 255);
153
D.rect2 = edje.rect();
154
D.rect2:geom (50, 50, 50, 50);
155
D.rect2:color (20, 30, 60, 120);
158
D.clip = edje.rect();
159
D.clip:geom (10, 10, 150, 150);
160
D.clip:color (200, 200, 50, 200);
163
D.rect2:clip(D.clip);
166
D.text = edje.text();
167
D.text:geom (50, 5, 150, 50);
168
D.text:color (255, 0, 0, 255);
169
D.text:font("Sans:style=Bold", 32);
170
D.text:text("Lua rocks!");
171
text_geom = D.text:geom();
172
print(D.text:text());
175
--// Put a few bogus API calls here to test the bogus API protection,
176
--// If the bogus API protection works, these should get ignored, but everything else runs smoothly.
177
--// Otherwise, the map is not done, the bubbles are not done, but the timers keep runinng.
178
bogus.failme(1, "two", D.rect);
179
temp = bogus.failme2();
184
D.map = edje.map(4); --// 4 is the only supported map size at the moment.
185
--// These all do the same thing.
186
--// Note, lua likes to start at 1, C (and thus evas) at 0. I choose to agree with C.
187
D.map:coord(0, 50, 50, 0);
188
D.map:coord(1, 100, 50, 0);
189
D.map:coord(2, 100, 100, 0);
190
D.map:coord(3, 50, 100, 0);
191
D.map:populate(50, 50, 50, 50, 0);
192
D.map:populate(D.rect2, 0);
193
D.map:populate(D.rect2);
195
--// print the results
196
D.coord = D.map:coord(0);
197
print("lua::map coords for point 0 x=" .. D.coord.x .. " y=" .. D.coord.y .. " z=" .. D.coord.z);
198
D.coord = D.map:coord(1);
199
print("lua::map coords for point 1 x=" .. D.coord.x .. " y=" .. D.coord.y .. " z=" .. D.coord.z);
200
D.coord = D.map:coord(2);
201
print("lua::map coords for point 2 x=" .. D.coord.x .. " y=" .. D.coord.y .. " z=" .. D.coord.z);
202
D.coord = D.map:coord(3);
203
print("lua::map coords for point 3 x=" .. D.coord.x .. " y=" .. D.coord.y .. " z=" .. D.coord.z);
208
if (D.map:alpha()) then
209
print("lua::map is alpha");
212
if (D.map:smooth()) then
213
print("lua::map is smooooth");
216
if (D.map:clockwise()) then
217
print("lua::map is clockwise");
220
D.map:color(255, 255, 255, 255); // set all points to this colour.
221
D.map:color(1, 255, 0, 255, 255); // set just one point to this colour.
223
D.map:lighting(75, 75, 10, 255, 255, 255, 0, 255, 0); // Ambient light and a 3D light source.
226
D.map:rotate(45.0, 75, 75);
227
D.map:zoom(1.5, 1.5, 75, 75);
228
D.map:rotate3d(10.0, 20.0, 30.0, 75, 75, 0);
229
D.map:perspective(200, 200, 0, 20);
231
--// For image UV mapping.
232
D.map:uv(0, 0.0, 0.0);
233
D.map:uv(1, 50.0, 0.0);
234
D.map:uv(2, 50.0, 50.0);
235
D.map:uv(3, 0.0, 50.0);
237
--// Actually apply the resulting transformations.
239
D.rect2:map_enable(true);
240
if (D.rect2:map_enable()) then
241
print("lua::map enabled");
244
D.rect2:map_source(D.rect); --// Don't think this is actually implemented in evas.
247
--// D.map:size(); --// perhaps overide the # operator? For now it's only gonna return 4 anyway.
249
--// example of deleting something
252
--// test the color_class stuff
253
colour = edje.color_class("test_colour");
254
print("lua::color_class= " .. colour.r .. "," .. colour.g .. "," .. colour.b .. "," .. colour.a);
255
colour = edje.color_class("test_colour", 32, 64, 255, 128);
256
print("lua::color_class= " .. colour.r .. "," .. colour.g .. "," .. colour.b .. "," .. colour.a);
257
colour = edje.color_class("test_colour", { r=255, g=0, b=255, a=255 });
258
print("lua::color_class= " .. colour.r .. "," .. colour.g .. "," .. colour.b .. "," .. colour.a);
259
text = edje.text_class("test_text_class", "Sans:style=Bold", 8);
260
print("lua::text_class= " .. text.font .. " size " .. text.size);
262
--// Do something bad, just to see what happens.
263
--// edje.color_class(nil);
265
--// shutdown func - generally empty or not there. everything garbage collected for you
267
print("lua::shutdown ... " .. D.val);
271
print("lua::show ... " .. D.val);
275
print("lua::hide ... " .. D.val);
279
print("lua::move x=" .. x .. " x=" .. y);
283
function resize (w, h)
284
print("lua::resize w=" .. w .. " h=" .. h);
285
D.text:move((w - text_geom.w) / 2, (h - text_geom.h) / 8);
289
function message (id, type, ...)
290
print("lua::message id=" .. id .. " type=" .. type);
291
--// handle your message type here. check id + type then use the
292
--// vararg appropriately. they are the same as the params passed
293
--// to edje:messagesend() (if any are passed at all). Any array
294
--// arguments are passed as a single table.
296
if ("none" == type) then
297
print("lua::message no args");
298
elseif ("strset" == type) then
300
print_table_start(strs, "", "lua::message strings");
301
elseif ("intset" == type) then
303
print_table_start(ints, "", "lua::message ints");
304
elseif ("floatset" == type) then
306
print_table_start(floats, "", "lua::message floats");
307
elseif ("strintset" == type) then
309
print("lua::message " .. str);
310
print_table_start(ints, "", "lua::message ints");
311
elseif ("strfloatset" == type) then
313
print("lua::message " .. str);
314
print_table_start(floats, "", "lua::message floats");
316
print("lua::message " .. ... );
320
function signal (sig, src)
321
print("lua::signal sig= " .. sig .. " src= " .. src);
326
// The group name NEEDS a / in it,
327
// or the part below that tries to swallow it won't work.
328
// Leaving just the lua part visible.
334
local bubbleCols = 8;
335
local bubbleRows = 6;
337
for i = 1, bubbleRows do
339
for j = 1, bubbleCols do
340
image = edje.image();
341
image:image("bubble.png");
343
table.insert(row, image);
345
table.insert(bubbles, row);
348
function resize (w, h)
349
for i = 1, bubbleRows do
350
for j = 1, bubbleCols do
353
bubbles[i][j]:geom((j - 1) * w1, (i - 1) * h1, w1, h1);
354
if ((1 == i) or (1 == j) or (bubbleRows == i) or (bubbleCols == j)) then
355
bubbles[i][j]:color(0, 255, 0, 200);
357
bubbles[i][j]:color(math.random(200) + 55, 0, math.random(255) + 55, 200);
366
name: "plain/edje/group";
373
state: "default" 0.0;
378
// A lua group embedded in an edje group.
382
source: "bubbles/lua";
384
description { state: "default" 0.0; }
388
name: "background_image";
392
state: "default" 0.0;
393
aspect_preference: HORIZONTAL;
394
color_class: "test_colour";
395
image { normal: "test.png"; }
407
text: "This is test text.";
408
text_class: "test_text_class";