From 6bd9299cf74f534eb20c249379f25673085708dd Mon Sep 17 00:00:00 2001 From: Davide Andreoli Date: Sun, 7 Mar 2010 19:34:28 +0000 Subject: [PATCH] Add the examples/ folder in edje/doc/ and put in the first 2 lua examples SVN revision: 46955 --- legacy/edje/doc/examples/lua_set_text.edc | 39 ++++++++ legacy/edje/doc/examples/lua_timer.edc | 108 ++++++++++++++++++++++ 2 files changed, 147 insertions(+) create mode 100644 legacy/edje/doc/examples/lua_set_text.edc create mode 100644 legacy/edje/doc/examples/lua_timer.edc diff --git a/legacy/edje/doc/examples/lua_set_text.edc b/legacy/edje/doc/examples/lua_set_text.edc new file mode 100644 index 0000000000..2676104aa9 --- /dev/null +++ b/legacy/edje/doc/examples/lua_set_text.edc @@ -0,0 +1,39 @@ +collections { + group { name: "main"; + parts { + part { name: "bg"; + type: RECT; + description { state: "default" 0.0; + color: 255 255 255 255; + } + } + part { name: "label"; + type: TEXT; + description { state: "default" 0.0; + color: 0 0 0 255; + text { + text: "Click me."; + font: "Sans"; + size: 12; + } + } + } + } + programs { + program { + signal: "mouse,down,1"; + source: "label"; + lua_script { + ed.label.text = "Clicked!" + } + } + program { + signal: "mouse,up,1"; + source: "label"; + lua_script { + ed.label.text = "Click me." + } + } + } + } +} diff --git a/legacy/edje/doc/examples/lua_timer.edc b/legacy/edje/doc/examples/lua_timer.edc new file mode 100644 index 0000000000..798d0fe7cd --- /dev/null +++ b/legacy/edje/doc/examples/lua_timer.edc @@ -0,0 +1,108 @@ +collections { + group { name: "main"; + parts { + part { name: "bg"; + type: RECT; + description { state: "default" 0.0; + color: 255 255 255 255; + } + } + part { name: "label1"; + type: TEXT; + description { state: "default" 0.0; + color: 0 0 0 255; + text { + text: "Timer delayed..."; + font: "Sans"; + size: 12; + align: 0.0 0.7; + } + } + } + part { name: "label2"; + type: TEXT; + description { state: "default" 0.0; + color: 0 0 0 255; + text { + font: "Sans"; + size: 12; + align: 0.0 0.8; + } + } + } + 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; + color: 255 0 0 255; + max: 30 30; + align: 0.1 0.2; + } + description { state: "default" 1.0; + inherit: "default" 0.0; + color: 0 0 255 255; + align: 0.9 0.2; + } + } + } + programs { + /* Move the red rect back an forth in a loop */ + program { name: "init"; + signal: "load"; + source: ""; + action: STATE_SET "default" 1.0; + transition: SINUSOIDAL 1.0; + target: "red_rect"; + after: "loop"; + } + program { name: "loop"; + action: STATE_SET "default" 0.0; + transition: SINUSOIDAL 1.0; + target: "red_rect"; + after: "init"; + } + program { name: "lua_init"; + 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] + ed.label3.text = "object color: " .. ed.red_rect.color[1] .. " " + .. ed.red_rect.color[2] .. " " + .. ed.red_rect.color[3] + + /* 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) + } + } + } + } +}