Update edje examples to use embryo instead of lua. Inline lua scripting was removed...
authordavemds <davemds@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Wed, 6 Oct 2010 23:03:28 +0000 (23:03 +0000)
committerdavemds <davemds@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Wed, 6 Oct 2010 23:03:28 +0000 (23:03 +0000)
git-svn-id: http://svn.enlightenment.org/svn/e/trunk/edje@53124 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

doc/examples/embryo_set_state.edc [moved from doc/examples/lua_set_state.edc with 93% similarity]
doc/examples/embryo_set_text.edc [moved from doc/examples/lua_set_text.edc with 83% similarity]
doc/examples/embryo_timer.edc [moved from doc/examples/lua_timer.edc with 53% similarity]

similarity index 93%
rename from doc/examples/lua_set_state.edc
rename to doc/examples/embryo_set_state.edc
index dc24ae9..e752fad 100644 (file)
@@ -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);
             }
          }
       }
similarity index 83%
rename from doc/examples/lua_set_text.edc
rename to doc/examples/embryo_set_text.edc
index 2676104..d656019 100644 (file)
@@ -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."); 
             }
          }
       }
similarity index 53%
rename from doc/examples/lua_timer.edc
rename to doc/examples/embryo_timer.edc
index 492fb1a..2c2f8e5 100644 (file)
@@ -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);
             }
          }
       }