Add the examples/ folder in edje/doc/ and put in the first 2 lua examples
authordavemds <davemds@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Sun, 7 Mar 2010 19:34:28 +0000 (19:34 +0000)
committerdavemds <davemds@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Sun, 7 Mar 2010 19:34:28 +0000 (19:34 +0000)
git-svn-id: http://svn.enlightenment.org/svn/e/trunk/edje@46955 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

doc/examples/lua_set_text.edc [new file with mode: 0644]
doc/examples/lua_timer.edc [new file with mode: 0644]

diff --git a/doc/examples/lua_set_text.edc b/doc/examples/lua_set_text.edc
new file mode 100644 (file)
index 0000000..2676104
--- /dev/null
@@ -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/doc/examples/lua_timer.edc b/doc/examples/lua_timer.edc
new file mode 100644 (file)
index 0000000..798d0fe
--- /dev/null
@@ -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)
+            }
+         }
+      }
+   }
+}