diff --git a/legacy/edje/doc/examples/lua_set_state.edc b/legacy/edje/doc/examples/embryo_set_state.edc similarity index 93% rename from legacy/edje/doc/examples/lua_set_state.edc rename to legacy/edje/doc/examples/embryo_set_state.edc index dc24ae95c6..e752fadda9 100644 --- a/legacy/edje/doc/examples/lua_set_state.edc +++ b/legacy/edje/doc/examples/embryo_set_state.edc @@ -37,8 +37,8 @@ collections { program { signal: "mouse,down,1"; source: "label"; - lua_script { - ed.red_rect.state = { "default", 1.0} + script { + set_state(PART:"red_rect", "default", 1.0); } } } diff --git a/legacy/edje/doc/examples/lua_set_text.edc b/legacy/edje/doc/examples/embryo_set_text.edc similarity index 83% rename from legacy/edje/doc/examples/lua_set_text.edc rename to legacy/edje/doc/examples/embryo_set_text.edc index 2676104aa9..d656019fb1 100644 --- a/legacy/edje/doc/examples/lua_set_text.edc +++ b/legacy/edje/doc/examples/embryo_set_text.edc @@ -23,15 +23,15 @@ collections { program { signal: "mouse,down,1"; source: "label"; - lua_script { - ed.label.text = "Clicked!" + script { + set_text(PART:"label", "Clicked!"); } } program { signal: "mouse,up,1"; source: "label"; - lua_script { - ed.label.text = "Click me." + script { + set_text(PART:"label", "Click me."); } } } diff --git a/legacy/edje/doc/examples/lua_timer.edc b/legacy/edje/doc/examples/embryo_timer.edc similarity index 53% rename from legacy/edje/doc/examples/lua_timer.edc rename to legacy/edje/doc/examples/embryo_timer.edc index 492fb1a05e..2c2f8e510e 100644 --- a/legacy/edje/doc/examples/lua_timer.edc +++ b/legacy/edje/doc/examples/embryo_timer.edc @@ -1,5 +1,21 @@ collections { group { name: "main"; + script { + public timer_cb(val) { + new x, y, w, h; + new buf[32]; + + /* set labels with object info */ + get_geometry(PART:"red_rect", x, y, w, h); + snprintf(buf, sizeof(buf), "Timer called %d times.", val); + set_text(PART:"label1", buf) + snprintf(buf, sizeof(buf), "Object x: %d w: %d", x, w); + set_text(PART:"label2", buf) + + /* renew the timer */ + timer(1 / 30, "timer_cb", val + 1); + } + } parts { part { name: "bg"; type: RECT; @@ -12,7 +28,7 @@ collections { description { state: "default" 0.0; color: 0 0 0 255; text { - text: "Timer delayed..."; + text: ""; font: "Sans"; size: 12; align: 0.0 0.7; @@ -30,17 +46,6 @@ collections { } } } - part { name: "label3"; - type: TEXT; - description { state: "default" 0.0; - color: 0 0 0 255; - text { - font: "Sans"; - size: 12; - align: 0.0 0.9; - } - } - } part { name: "red_rect"; type: RECT; description { state: "default" 0.0; @@ -51,12 +56,13 @@ collections { description { state: "default" 1.0; inherit: "default" 0.0; color: 0 0 255 255; + max: 50 30; align: 0.9 0.2; } } } programs { - /* Move the red rect back an forth in a loop */ + /* move the red rect back an forth in a loop */ program { name: "init"; signal: "load"; source: ""; @@ -71,35 +77,12 @@ collections { target: "red_rect"; after: "init"; } - program { name: "lua_init"; + /* run the timer_cb for the first time */ + program { name: "init2"; signal: "load"; source: ""; - lua_script { - function timer_cb() - /* Print Timer attributes */ - print("## timer_cb") - print(" timer.pending:", timer.pending) - print(" timer.precision:", timer.precision) - print(" timer.interval:", timer.interval) - - /* Slow down the timer */ - timer.interval = timer.interval + 0.005 - - /* Set labels with object info */ - ed.label1.text = "timer interval: " .. timer.interval - ed.label2.text = "object x: " .. ed.red_rect.geometry[1] - r, g, b, a = unpack(ed.red_rect.color) - ed.label3.text = "object color: "..r.." "..g.." ".. b - - /* or return CALLBACK_CANCEL to stop the timer*/ - return CALLBACK_RENEW - end - - /* Start a new timer that will call timer_cb every 0.01s */ - timer = ed:timer(0.01, timer_cb) - - /* Delay the timer execution by 2s */ - timer:delay(2) + script { + timer_cb(0); } } }