1luaref(3)                  Library Functions Manual                  luaref(3)
2
3
4

NAME

6       luaref - Edje LUA scripting
7

Introduction

9       Lua scripts are declared in edc files with the lua_script keyword. Like
10       this:
11
12       group {
13          name: 'mygroup';
14          lua_script {
15              print('LUA: on-load script');
16          }
17          parts {
18             ...
19          }
20          programs {
21             program {
22                signal: 'a_signal';
23                source: 'a_part';
24                lua_script {
25                   print('LUA: 'mouse,down,1' on 'button'');
26                }
27             }
28          }
29       }
30
31
32       Inside a lua_script code block, there's a reference to your edje Group
33       named ed, which you may use for accessing your parts (e.g. a part named
34       'label' is accessed through ed.label). This is the main object that is
35       used to access every parts and is also used to create Timer, poller and
36       animator; to emit signal, send messagges, run/stop programs and more.
37       Look at the Group class to see all the methods and properties.
38
39       Some object attributes return a table of values, the Object attribute
40       geometry for example return a table of 4 values (x,y,w,h). This tables
41       don't have named index thus you can access the fields only using:
42       geometry[1] for the x value. NOTE that you can NOT use gemetry.x or
43       .geometry['x']. But you can use the lua unpack function in this way:
44
45       x, y, w, h = unpack(ed.part_name.geometry)
46       print('geometry: ', x, y, w, h)
47       // the same for state names:
48       state, val = unpack(ed.part_name.state)
49       print('state: ', state, val)
50       // and for setting tables attributes:
51       custom.color = { 255, 255, 255, 255 }
52       ed.part_name.state = { 'custom', 0.0 }
53
54
55       Classes hierarchy:
56
57       · Timer
58
59       · Animator
60
61       · Poller
62
63       · Object
64
65         · Group
66
67         · Part
68
69         · Image
70
71         · Line
72
73         · Polygon
74
75         · Table
76
77         · Description
78
79       References:
80
81       · For general LUA documentations look at the official LUA manual
82         (http://www.lua.org/manual/5.1/)
83       · The lua-users wiki is also full of lua info (http://lua-
84         users.org/wiki/)
85       · Examples of edc files that use LUA can be found in the doc/examples
86         folder in the edje sources.
87       Lua snippets:
88       // print one or more values in console in a tabbed way or using printf style
89       print('something to say', val1, val2)
90       s = string.format('%d %d', 3, 4)
91       print(s)
92
93       // string concat
94       print('string1' .. 'string2' .. val1)
95
96       // var to string
97       tostring(var)
98
99       // Print the type of a variable
100       print(type(var))
101
102        Timer Class
103       The timer class is a wrapper around ecore_timer. You can create a timer
104       using the timer(secs,callback) method of the Group class. The callback
105       function will be called every secs seconds until it will return
106       CALLBACK_RENEW. If CALLBACK_CANCEL is returned the timer will stop.
107       Example:
108       lua_script {
109          function timer_cb()
110             print('timer_cb')
111             return CALLBACK_RENEW
112          end
113
114          timer = ed:timer(0.5, timer_cb)
115       }
116
117       A more detailed example can be found in doc/examples/lua_timer.edc
118       See also: Ecore Timer Docs
119       Attributes:
120       · Timer.pending
121       · Timer.precision
122       · Timer.interval
123       Setters:
124       · Timer.interval
125       Methods:
126       · Timer:del()
127       · Timer:freeze()
128       · Timer:thaw()
129       · Timer:delay(secs)
130        Animator Class
131       The animator class is a wrapper around ecore_animator. Animator are
132       used the same way as Timer.
133       Attributes:
134       · Animator.frametime
135       Methods:
136       · Animator:del()
137        Poller Class
138       The poller class is a wrapper around ecore_poller.
139       Attributes:
140       · Poller.interval
141       Methods:
142       · Poller:del()
143        General Object Class
144       This is the base class, many other classes are children of this.
145       You can attach event callbacks to this class using a classic c
146       approach:
147       function mouse_move_cb(self, ...)
148           print('mouse_move', ...)
149       end
150
151       rect = ed:rectangle()
152       rect.mouse_events = true
153       rect.mouse_move = mouse_move_cb
154
155        or you can also do the same in a more lua-fashion style
156       rect = ed:rectangle {
157           mouse_events = true,
158           mouse_move = function (self, ...)
159                           print ('mouse_move', ...)
160                        end
161       }
162
163       See also: Evas Object Docs
164       Methods:
165       · Object:del()
166       · Object:show()
167       · Object:hide()
168       · Object:move(x, y)
169       · Object:resize(w, h)
170       · Object:raise()
171       · Object:lower()
172       · Object:stack_above()
173       · Object:stack_below()
174       · Object:clip_unset()
175       Attributes:
176       · Object.name
177       · Object.geometry: (x, y, width, height)
178       · Object.type: object type (RECT=1, TEXT, IMAGE, SWALLOW, TEXTBLOCK,
179         GRADIENT, GROUP, BOX, TABLE, EXTERNAL)
180       · Object.layer
181       · Object.above
182       · Object.below
183       · Object.size_hint_min: (w,h)
184       · Object.size_hint_max: (w,h)
185       · Object.size_hint_request: (w,h)
186       · Object.size_hint_aspect: (aspect, w, h)
187       · Object.size_hint_align: (w,h)
188       · Object.size_hint_weight: (w,h)
189       · Object.size_hint_padding: (l,r,t,b)
190       · Object.visible
191       · Object.render_op
192       · Object.anti_alias
193       · Object.scale
194       · Object.color: (r, g, b, alpha)
195       · Object.color_interpolation
196       · Object.clip
197       · Object.clipees
198       · Object.evas (not implemeted, always return nil)
199       · Object.pass_events
200       · Object.repeat_events
201       · Object.propagate_events
202       · Object.focus
203       · Object.pointer_mode
204       · Object.precise_is_inside
205       · Object.mouse_events
206       Setters:
207       · Object.name
208       · Object.layer
209       · Object.size_hint_min: (w,h)
210       · Object.size_hint_max: (w,h)
211       · Object.size_hint_request: (w,h)
212       · Object.size_hint_aspect: (w,h)
213       · Object.size_hint_align: (w,h)
214       · Object.size_hint_weight: (w,h)
215       · Object.size_hint_padding: (l,r,t,b)
216       · Object.render_op
217       · Object.anti_alias
218       · Object.scale
219       · Object.color: (r, g, b, alpha)
220       · Object.color_interpolation
221       · Object.clip
222       · Object.pass_events
223       · Object.repeat_events
224       · Object.propagate_events
225       · Object.focus
226       · Object.pointer_mode
227       · Object.precise_is_inside
228       · Object.mouse_events
229       Events:
230       · Object.mouse_in: func(self,output_x,output_y,canvas_x,canvas_y)
231       · Object.mouse_out: func(self,output_x,output_y,canvas_x,canvas_y)
232       · Object.mouse_down:
233         func(self,button,output_x,output_y,canvas_x,canvas_y)
234       · Object.mouse_up:
235         func(self,button,output_x,output_y,canvas_x,canvas_y)
236       · Object.mouse_move:
237         func(self,buttons,output_x,output_y,canvas_x,canvas_y)
238       · Object.mouse_wheel: func(self,z,output_x,output_y,canvas_x,canvas_y)
239        Image Class See also: Evas Object Image Docs
240       Attributes:
241       · Image.size: (w,h)
242       Setters:
243       · Image.file
244       · Image.fill: (x,y,w,h)
245       · Image.fill_transform
246       · Image.alpha
247        Line Class See also: Evas Object Line Docs
248       Attributes:
249       · Line.xy: (x1,y1,x2,y2)
250       Setters:
251       · Line.xy: (x1,y1,x2,y2)
252        Polygon Class See also: Evas Object Polygon Docs
253       Methods:
254       · Polygon:point_add(x,y)
255       · Polygon:points_clear()
256        Table Class See also: Evas Object Table Docs
257       Attributes:
258       · Table.homogeneous
259       · Table.padding: (horiz,vert)
260       · Table.align: (horiz,vert)
261       · Table.col_row_size: (cols,rows)
262       · Table.children
263       Setters:
264       · Table.homogeneous
265       · Table.padding: (horiz,vert)
266       · Table.align: (horiz,vert)
267       Methods:
268       · Table.pack(child,col,row,colspan,rowspan)
269       · Table.unpack(child)
270       · Table.clear(clear)
271        Description Class
272       Attributes:
273       · Description.alignment: (x,y)
274       · Description.min: (w,h)
275       · Description.max: (w,h)
276       · Description.step: (w,h)
277       · Description.aspect: (x,y)
278       · Description.aspect_pref
279       · Description.color: (r,g,b,a)
280       · Description.color2: (r,g,b,a)
281       · Description.color3: (r,g,b,a)
282       · Description.color_class
283       · Description.rel1: (x,y)
284       · Description.rel1_to: (to_x,to_y)
285       · Description.rel1_offset: (x,y)
286       · Description.rel2: (x,y)
287       · Description.rel2_to: (to_x,to_y)
288       · Description.rel2_offset: (x,y)
289       · Description.image (not yet implemented)
290       · Description.border: (l,r,t,b)
291       · Description.fill_smooth
292       · Description.fill_pos: (rel_x,rel_y,offset_x,offset_y)
293       · Description.fill_size: (rel_x,rel_y,offset_x,offset_y)
294       · Description.text
295       · Description.text_class
296       · Description.text_font
297       · Description.text_style
298       · Description.text_size
299       · Description.text_fit: (x,y)
300       · Description.text_min: (x,y)
301       · Description.text_max: (x,y)
302       · Description.text_align: (x,y)
303       · Description.visible
304       Setters:
305       · Description.alignment: (x,y)
306       · Description.min: (w,h)
307       · Description.max: (w,h)
308       · Description.step: (w,h)
309       · Description.aspect: (x,y)
310       · Description.aspect_pref
311       · Description.color: (r,g,b,a)
312       · Description.color2: (r,g,b,a)
313       · Description.color3: (r,g,b,a)
314       · Description.color_class
315       · Description.rel1: (x,y)
316       · Description.rel1_to: (to_x,to_y)
317       · Description.rel1_offset: (x,y)
318       · Description.rel2: (x,y)
319       · Description.rel2_to: (to_x,to_y)
320       · Description.rel2_offset: (x,y)
321       · Description.image
322       · Description.border: (l,r,t,b)
323       · Description.fill_smooth
324       · Description.fill_pos: (rel_x,rel_y,offset_x,offset_y)
325       · Description.fill_size: (rel_x,rel_y,offset_x,offset_y)
326       · Description.text
327       · Description.text_class
328       · Description.text_font
329       · Description.text_style
330       · Description.text_size
331       · Description.text_fit: (x,y)
332       · Description.text_min: (x,y)
333       · Description.text_max: (x,y)
334       · Description.text_align: (x,y)
335       · Description.visible
336        Part Class
337       Parts are objects, that is, they inherit the methods from the Object
338       class. They also contain the following methods and attributes:
339       Attributes:
340       · Object Part.swallow
341       · Part.drag_dir
342       · Part.drag_value: (dx,dy)
343       · Part.drag_size: (dx,dy)
344       · Part.drag_step: (dx,dy)
345       · Part.drag_page: (dx,dy)
346       · Part.type
347       · Part.effect
348       · Part.mouse_events
349       · Part.states_list
350       · Part.state: (state,value)
351       · Part.text
352       · Part.text_selection
353       · Part.text_cursor_geometry: (x,y,w,h)
354       · Part.geometry: (x,y,w,h)
355       · Part.part_col_row_size: (cols,rows)
356       Setters:
357       · Part.drag_value: (dx,dy)
358       · Part.drag_size: (dx,dy)
359       · Part.drag_step: (dx,dy)
360       · Part.drag_page: (dx,dy)
361       · Part.effect
362       · Part.mouse_events
363       · Part.repeat_events
364       · Part.state: (state,value)
365       · Part.tween_state
366       · Part.text
367       Methods:
368       · Part:swallow(obj)
369       · Part:unswallow()
370       · PartDescription Part:custom_state(state_name, state_val)
371       · Part:text_select_none
372       · Part:text_select_all
373       · Part:text_insert(text)
374       · Part:table_pack(child, row, colspan, rowspan)
375       · Part:table_unpack(child)
376       · Part:table_clear(clear)
377       · Part:box_append(item)
378       · Part:box_prepend(item)
379       · Part:box_insert_before(item, before)
380       · Part:box_insert_at(item, index)
381       · Part:box_remove(item)
382       · Part:box_remove_at(item, index)
383       · Part:box_remove_all(clear)
384        Group Class
385       Groups are objects, that is, they inherit the methods from the general
386       Object Class. They also contain the following methods and attributes:
387       Attributes:
388       · Group.group
389       · Group.mouse: (x,y)
390       · Group.mouse_buttons
391       · Group.size_min: (w,h)
392       · Group.size_max: (w,h)
393       · Group.scale
394       · Group.load_error
395       · Group.load_error_str
396       · Group.play
397       · Group.animation
398       · Group.frametime
399       Setters:
400       · Group.group
401       · Group.size_min: (w,h)
402       · Group.size_max: (w,h)
403       · Group.scale
404       · Group.play
405       · Group.animation
406       · Group.text_change_cb
407       · Group.frametime
408       Methods:
409       · Timer Group:timer(secs, callback)
410       · Animator Group:animator(func)
411       · Poller Group:poller(interval, callback)
412       · Transform Group:transform()
413       · Group:signal_emit(emission, source)
414       · Group:message_send(message_type, id, msg)
415       · Group:program_run(name)
416       · Group:program_stop(name)
417       · Group:signal_callback_add(emission, source, callback)
418       · Group:signal_callback_del(emission, source)
419       · Group:freeze()
420       · Group:thaw()
421Edje                              2 Jul 2010                         luaref(3)
Impressum