Rechercher une page de manuel
luaref
Langue: en
Version: 379131 (fedora - 01/12/10)
Section: 3 (Bibliothèques de fonctions)
Sommaire
NAME
luaref - Edje LUA scriptingIntroduction
Lua scripts are declared in edc files with the lua_script keyword. Like this:
group { name: 'mygroup'; lua_script { print('LUA: on-load script'); } parts { ... } programs { program { signal: 'a_signal'; source: 'a_part'; lua_script { print('LUA: 'mouse,down,1' on 'button''); } } } }
Inside a lua_script code block, there's a reference to your edje Group named ed, which you may use for accessing your parts (e.g. a part named 'label' is accessed through ed.label). This is the main object that is used to access every parts and is also used to create Timer, poller and animator; to emit signal, send messagges, run/stop programs and more. Look at the Group class to see all the methods and properties.
Some object attributes return a table of values, the Object attribute geometry for example return a table of 4 values (x,y,w,h). This tables don't have named index thus you can access the fields only using: geometry[1] for the x value. NOTE that you can NOT use gemetry.x or .geometry['x']. But you can use the lua unpack function in this way:
x, y, w, h = unpack(ed.part_name.geometry) print('geometry: ', x, y, w, h) // the same for state names: state, val = unpack(ed.part_name.state) print('state: ', state, val) // and for setting tables attributes: custom.color = { 255, 255, 255, 255 } ed.part_name.state = { 'custom', 0.0 }
Classes hierarchy:
- *
- Timer
- *
- Animator
- *
- Poller
- *
- Object
- *
- Group
- *
- Part
- *
- Image
- *
- Line
- *
- Polygon
- *
- Table
- *
- Description
References:
- *
- For general LUA documentations look at the official LUA manual (http://www.lua.org/manual/5.1/)
- *
- The lua-users wiki is also full of lua info (http://lua-users.org/wiki/)
- *
- Examples of edc files that use LUA can be found in the doc/examples folder in the edje sources.
Lua snippets:
// print one or more values in console in a tabbed way or using printf style print('something to say', val1, val2) s = string.format('%d %d', 3, 4) print(s) // string concat print('string1' .. 'string2' .. val1) // var to string tostring(var) // Print the type of a variable print(type(var))
Timer Class
The timer class is a wrapper around ecore_timer. You can create a timer using the timer(secs,callback) method of the Group class. The callback function will be called every secs seconds until it will return CALLBACK_RENEW. If CALLBACK_CANCEL is returned the timer will stop.
Example:
lua_script { function timer_cb() print('timer_cb') return CALLBACK_RENEW end timer = ed:timer(0.5, timer_cb) }
A more detailed example can be found in doc/examples/lua_timer.edc
See also: Ecore Timer Docs
Attributes:
- *
- Timer.pending
- *
- Timer.precision
- *
- Timer.interval
Setters:
- *
- Timer.interval
Methods:
- *
- Timer:del()
- *
- Timer:freeze()
- *
- Timer:thaw()
- *
- Timer:delay(secs)
Animator Class
The animator class is a wrapper around ecore_animator. Animator are used the same way as Timer.
Attributes:
- *
- Animator.frametime
Methods:
- *
- Animator:del()
Poller Class
The poller class is a wrapper around ecore_poller.
Attributes:
- *
- Poller.interval
Methods:
- *
- Poller:del()
General Object Class
This is the base class, many other classes are children of this.
You can attach event callbacks to this class using a classic c approach:
function mouse_move_cb(self, ...) print('mouse_move', ...) end rect = ed:rectangle() rect.mouse_events = true rect.mouse_move = mouse_move_cb
or you can also do the same in a more lua-fashion style
rect = ed:rectangle { mouse_events = true, mouse_move = function (self, ...) print ('mouse_move', ...) end }
See also: Evas Object Docs
Methods:
- *
- Object:del()
- *
- Object:show()
- *
- Object:hide()
- *
- Object:move(x, y)
- *
- Object:resize(w, h)
- *
- Object:raise()
- *
- Object:lower()
- *
- Object:stack_above()
- *
- Object:stack_below()
- *
- Object:clip_unset()
Attributes:
- *
- Object.name
- *
- Object.geometry: (x, y, width, height)
- *
- Object.type: object type (RECT=1, TEXT, IMAGE, SWALLOW, TEXTBLOCK, GRADIENT, GROUP, BOX, TABLE, EXTERNAL)
- *
- Object.layer
- *
- Object.above
- *
- Object.below
- *
- Object.size_hint_min: (w,h)
- *
- Object.size_hint_max: (w,h)
- *
- Object.size_hint_request: (w,h)
- *
- Object.size_hint_aspect: (aspect, w, h)
- *
- Object.size_hint_align: (w,h)
- *
- Object.size_hint_weight: (w,h)
- *
- Object.size_hint_padding: (l,r,t,b)
- *
- Object.visible
- *
- Object.render_op
- *
- Object.anti_alias
- *
- Object.scale
- *
- Object.color: (r, g, b, alpha)
- *
- Object.color_interpolation
- *
- Object.clip
- *
- Object.clipees
- *
- Object.evas (not implemeted, always return nil)
- *
- Object.pass_events
- *
- Object.repeat_events
- *
- Object.propagate_events
- *
- Object.focus
- *
- Object.pointer_mode
- *
- Object.precise_is_inside
- *
- Object.mouse_events
Setters:
- *
- Object.name
- *
- Object.layer
- *
- Object.size_hint_min: (w,h)
- *
- Object.size_hint_max: (w,h)
- *
- Object.size_hint_request: (w,h)
- *
- Object.size_hint_aspect: (w,h)
- *
- Object.size_hint_align: (w,h)
- *
- Object.size_hint_weight: (w,h)
- *
- Object.size_hint_padding: (l,r,t,b)
- *
- Object.render_op
- *
- Object.anti_alias
- *
- Object.scale
- *
- Object.color: (r, g, b, alpha)
- *
- Object.color_interpolation
- *
- Object.clip
- *
- Object.pass_events
- *
- Object.repeat_events
- *
- Object.propagate_events
- *
- Object.focus
- *
- Object.pointer_mode
- *
- Object.precise_is_inside
- *
- Object.mouse_events
Events:
- *
- Object.mouse_in: func(self,output_x,output_y,canvas_x,canvas_y)
- *
- Object.mouse_out: func(self,output_x,output_y,canvas_x,canvas_y)
- *
- Object.mouse_down: func(self,button,output_x,output_y,canvas_x,canvas_y)
- *
- Object.mouse_up: func(self,button,output_x,output_y,canvas_x,canvas_y)
- *
- Object.mouse_move: func(self,buttons,output_x,output_y,canvas_x,canvas_y)
- *
- Object.mouse_wheel: func(self,z,output_x,output_y,canvas_x,canvas_y)
Image Class See also: Evas Object Image Docs
Attributes:
- *
- Image.size: (w,h)
Setters:
- *
- Image.file
- *
- Image.fill: (x,y,w,h)
- *
- Image.fill_transform
- *
- Image.alpha
Line Class See also: Evas Object Line Docs
Attributes:
- *
- Line.xy: (x1,y1,x2,y2)
Setters:
- *
- Line.xy: (x1,y1,x2,y2)
Polygon Class See also: Evas Object Polygon Docs
Methods:
- *
- Polygon:point_add(x,y)
- *
- Polygon:points_clear()
Table Class See also: Evas Object Table Docs
Attributes:
- *
- Table.homogeneous
- *
- Table.padding: (horiz,vert)
- *
- Table.align: (horiz,vert)
- *
- Table.col_row_size: (cols,rows)
- *
- Table.children
Setters:
- *
- Table.homogeneous
- *
- Table.padding: (horiz,vert)
- *
- Table.align: (horiz,vert)
Methods:
- *
- Table.pack(child,col,row,colspan,rowspan)
- *
- Table.unpack(child)
- *
- Table.clear(clear)
Description Class
Attributes:
- *
- Description.alignment: (x,y)
- *
- Description.min: (w,h)
- *
- Description.max: (w,h)
- *
- Description.step: (w,h)
- *
- Description.aspect: (x,y)
- *
- Description.aspect_pref
- *
- Description.color: (r,g,b,a)
- *
- Description.color2: (r,g,b,a)
- *
- Description.color3: (r,g,b,a)
- *
- Description.color_class
- *
- Description.rel1: (x,y)
- *
- Description.rel1_to: (to_x,to_y)
- *
- Description.rel1_offset: (x,y)
- *
- Description.rel2: (x,y)
- *
- Description.rel2_to: (to_x,to_y)
- *
- Description.rel2_offset: (x,y)
- *
- Description.image (not yet implemented)
- *
- Description.border: (l,r,t,b)
- *
- Description.fill_smooth
- *
- Description.fill_pos: (rel_x,rel_y,offset_x,offset_y)
- *
- Description.fill_size: (rel_x,rel_y,offset_x,offset_y)
- *
- Description.text
- *
- Description.text_class
- *
- Description.text_font
- *
- Description.text_style
- *
- Description.text_size
- *
- Description.text_fit: (x,y)
- *
- Description.text_min: (x,y)
- *
- Description.text_max: (x,y)
- *
- Description.text_align: (x,y)
- *
- Description.visible
Setters:
- *
- Description.alignment: (x,y)
- *
- Description.min: (w,h)
- *
- Description.max: (w,h)
- *
- Description.step: (w,h)
- *
- Description.aspect: (x,y)
- *
- Description.aspect_pref
- *
- Description.color: (r,g,b,a)
- *
- Description.color2: (r,g,b,a)
- *
- Description.color3: (r,g,b,a)
- *
- Description.color_class
- *
- Description.rel1: (x,y)
- *
- Description.rel1_to: (to_x,to_y)
- *
- Description.rel1_offset: (x,y)
- *
- Description.rel2: (x,y)
- *
- Description.rel2_to: (to_x,to_y)
- *
- Description.rel2_offset: (x,y)
- *
- Description.image
- *
- Description.border: (l,r,t,b)
- *
- Description.fill_smooth
- *
- Description.fill_pos: (rel_x,rel_y,offset_x,offset_y)
- *
- Description.fill_size: (rel_x,rel_y,offset_x,offset_y)
- *
- Description.text
- *
- Description.text_class
- *
- Description.text_font
- *
- Description.text_style
- *
- Description.text_size
- *
- Description.text_fit: (x,y)
- *
- Description.text_min: (x,y)
- *
- Description.text_max: (x,y)
- *
- Description.text_align: (x,y)
- *
- Description.visible
Part Class
Parts are objects, that is, they inherit the methods from the Object class. They also contain the following methods and attributes:
Attributes:
- *
- Object Part.swallow
- *
- Part.drag_dir
- *
- Part.drag_value: (dx,dy)
- *
- Part.drag_size: (dx,dy)
- *
- Part.drag_step: (dx,dy)
- *
- Part.drag_page: (dx,dy)
- *
- Part.type
- *
- Part.effect
- *
- Part.mouse_events
- *
- Part.states_list
- *
- Part.state: (state,value)
- *
- Part.text
- *
- Part.text_selection
- *
- Part.text_cursor_geometry: (x,y,w,h)
- *
- Part.geometry: (x,y,w,h)
- *
- Part.part_col_row_size: (cols,rows)
Setters:
- *
- Part.drag_value: (dx,dy)
- *
- Part.drag_size: (dx,dy)
- *
- Part.drag_step: (dx,dy)
- *
- Part.drag_page: (dx,dy)
- *
- Part.effect
- *
- Part.mouse_events
- *
- Part.repeat_events
- *
- Part.state: (state,value)
- *
- Part.tween_state
- *
- Part.text
Methods:
- *
- Part:swallow(obj)
- *
- Part:unswallow()
- *
- PartDescription Part:custom_state(state_name, state_val)
- *
- Part:text_select_none
- *
- Part:text_select_all
- *
- Part:text_insert(text)
- *
- Part:table_pack(child, row, colspan, rowspan)
- *
- Part:table_unpack(child)
- *
- Part:table_clear(clear)
- *
- Part:box_append(item)
- *
- Part:box_prepend(item)
- *
- Part:box_insert_before(item, before)
- *
- Part:box_insert_at(item, index)
- *
- Part:box_remove(item)
- *
- Part:box_remove_at(item, index)
- *
- Part:box_remove_all(clear)
Group Class
Groups are objects, that is, they inherit the methods from the general Object Class. They also contain the following methods and attributes:
Attributes:
- *
- Group.group
- *
- Group.mouse: (x,y)
- *
- Group.mouse_buttons
- *
- Group.size_min: (w,h)
- *
- Group.size_max: (w,h)
- *
- Group.scale
- *
- Group.load_error
- *
- Group.load_error_str
- *
- Group.play
- *
- Group.animation
- *
- Group.frametime
Setters:
- *
- Group.group
- *
- Group.size_min: (w,h)
- *
- Group.size_max: (w,h)
- *
- Group.scale
- *
- Group.play
- *
- Group.animation
- *
- Group.text_change_cb
- *
- Group.frametime
Methods:
- *
- Timer Group:timer(secs, callback)
- *
- Animator Group:animator(func)
- *
- Poller Group:poller(interval, callback)
- *
- Transform Group:transform()
- *
- Group:signal_emit(emission, source)
- *
- Group:message_send(message_type, id, msg)
- *
- Group:program_run(name)
- *
- Group:program_stop(name)
- *
- Group:signal_callback_add(emission, source, callback)
- *
- Group:signal_callback_del(emission, source)
- *
- Group:freeze()
- *
- Group:thaw()
Contenus ©2006-2024 Benjamin Poulain
Design ©2006-2024 Maxime Vantorre