Finally committing my edje lua additions after a long chat with raster on IRC.
authoronefang <onefang@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Sun, 6 Nov 2011 09:00:21 +0000 (09:00 +0000)
committeronefang <onefang@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Sun, 6 Nov 2011 09:00:21 +0000 (09:00 +0000)
Not everything discussed is in this commit, but that will come later today.

git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/edje@64803 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

ChangeLog
src/examples/Vera.ttf [new file with mode: 0644]
src/examples/bubble.png [new file with mode: 0644]
src/examples/lua_script.edc
src/examples/test.png [new file with mode: 0644]
src/lib/edje_lua2.c

index d100aa8..59336d8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
        * Add Edje multisense that allows playback of samples and
           vibrator control and ultimately beginsd to pave the way for
           more complex audio etc. support.
+
+2011-11-06  David Seikel (onefang)
+
+       * Lua: Added color_class and text_class functions.
+           Still need to write a function for setting the classes of an object.
+           This works for things in OTHER groups using those classes though.
+       * Add image, text, textblock (commented out), and edje objects.
+           Very basic support.
+       * Add functions for set/get text font, size, and text.
+       * Add function for set/get image image.
+           Still needs to limit to only imagess in the current edje file.
+       * Add functions for set/get image fill and filled.
+       * Add function for set/get edje file.
+           Still needs to limit to only groups in the current edje file.
+       * Add full support for evas line object.
+       * Add full support for evas polygon object.
+       * Beefed up the example lua script to show most of the above.
+         Including some handling of size changes.
+       * White space fixes, one of the editors I use cleans those up automatically.  shrugs
+
diff --git a/src/examples/Vera.ttf b/src/examples/Vera.ttf
new file mode 100644 (file)
index 0000000..58cd6b5
Binary files /dev/null and b/src/examples/Vera.ttf differ
diff --git a/src/examples/bubble.png b/src/examples/bubble.png
new file mode 100644 (file)
index 0000000..8fc50f9
Binary files /dev/null and b/src/examples/bubble.png differ
index be0bafe..da341b4 100644 (file)
@@ -1,5 +1,21 @@
+color_classes {
+    color_class { name: "test_colour"; color: 255 255 255 255; }
+}
+
+fonts {
+   font: "Vera.ttf" "default";
+}
+
+images {
+    image: "bubble.png" COMP;
+    image: "test.png" COMP;
+}
+
 collections {
-   group { name: "example";
+   // The group name NEEDS a / in it, 
+   // or the part below that tries to swallow it don't work.
+   // Leaving just the lua part visible.
+   group { name: "example/lua";
       lua_script_only: 1;
       lua_script {
          --// stick object private/local vars here
@@ -38,20 +54,17 @@ collections {
          end
  
          local function mycb2 ()
-            print("lua::callback animator " .. count);
-            print("lua:: seconds: " .. edje.seconds());
-            print("lua:: looptime: " .. edje.looptime());
-            local date = edje.date();
-            print("lua:: date: " ..
-                  date.year .. "|" ..
-                  date.month .. "|" ..
-                  date.day .. "|" ..
-                  date.yearday .. "|" ..
-                  date.weekday .. "|" ..
-                  date.hour .. "|" ..
-                  date.min .. "|" ..
-                  date.sec
-                 );
+            print("lua::callback animator " .. count .. " seconds: " .. edje.seconds() .. " looptime: " .. edje.looptime());
+            edje.color_class("test_colour", 255, (count * 10) % 255, 255, 255);
+            edje.text_class("test_text_class", "Sans:style=Bold", ((count * 3) % 100) + 8);
+            if (5 > (count % 10)) then
+               D.text:font("default", 32);
+            else
+               D.text:font("Sans:style=Bold", 32);
+            end
+            edje_geom = edje.geom();
+            text_geom = D.text:real_geom();
+            D.text:move((edje_geom.w - text_geom.w) / 2, (edje_geom.h - text_geom.h) / 8);
             return true;  --// repeat the timer
          end
  
@@ -60,7 +73,6 @@ collections {
             count = count + 1; --// keep count of calls - object data
             fndata = fndata + 3; --// play with object vars to see if they persist
             D.tim = edje.timer(0.25, mycb); --// inside cb add new timer
-            D.ani = edje.animator(mycb2);
             return false; --// cease repeating the timer
          end
  
@@ -74,9 +86,22 @@ collections {
          --// actually add the timer to call mycb in 1.23 sec
          D.tim = edje.timer(1.23, mycb);
          D.tra = edje.transition(5.0, mycb3);
+         D.ani = edje.animator(mycb2);
  
          if (edje.spanky) then edje.spanky(); end
 
+         local date = edje.date();
+         print("lua:: date: " ..
+            date.year .. "|" ..
+            date.month .. "|" ..
+            date.day .. "|" ..
+            date.yearday .. "|" ..
+            date.weekday .. "|" ..
+            date.hour .. "|" ..
+            date.min .. "|" ..
+            date.sec
+         );
+
          --// send some random edje message
          edje.messagesend(7, "none"      );
          edje.messagesend(7, "sig",      "signal", "source");
@@ -108,10 +133,28 @@ collections {
          D.rect2:clip(D.clip);
          D.rect:clip(D.clip);
 
+         D.text = edje.text();
+         D.text:geom  (50, 5, 150, 50);
+         D.text:color (255, 0, 0, 255);
+         D.text:font("Sans:style=Bold", 32);
+         D.text:text("Lua rocks!");
+         print(D.text:text());
+         D.text:show();
+
          --// example of deleting something
          --// D.tim:del();
+
+         --// test the color_class stuff
+         colour = edje.color_class("test_colour");
+         print("lua::color_class= " .. colour.r .. "," .. colour.g .. "," .. colour.b .. "," .. colour.a);
+         colour = edje.color_class("test_colour", 32, 64, 255, 128);
+         print("lua::color_class= " .. colour.r .. "," .. colour.g .. "," .. colour.b .. "," .. colour.a);
+         colour = edje.color_class("test_colour", { r=255, g=0, b=255, a=255 });
+         print("lua::color_class= " .. colour.r .. "," .. colour.g .. "," .. colour.b .. "," .. colour.a);
+         text = edje.text_class("test_text_class", "Sans:style=Bold", 8);
+         print("lua::text_class= " .. text.font .. " size " .. text.size);
  
-         --// shutdown func - generally empty or not there. everything gcd for you
+         --// shutdown func - generally empty or not there. everything garbage collected for you
          function shutdown ()
             print("lua::shutdown ... " .. D.val);
          end
@@ -132,15 +175,114 @@ collections {
          function message (id, type, v1, v2)
             print("lua::message ... " .. D.val);
             print("  id=" .. id .. " type=" .. type);
-            --// handle youre message type here. chekc id + type then use v1
+            --// handle your message type here. check id + type then use v1
             --// and/or v2 (or neither) appropriately. they are the same as
             --// the 2nd and 3rd param passed to edje.messagesend() (if any
             --// are passed at all)
          end
          function signal (sig, src)
-            print("lua::signal ... " .. D.val);
-            print("  sig=" .. sig .. " src=" .. src);
+            print("lua::signal sig= " .. sig .. " src= " .. src);
          end
       }
    }
+
+    group
+    { name: "bubbles/lua";
+       lua_script_only: 1;
+       lua_script
+       {
+           local bubbles = { };
+           local bubbleCols = 8;
+           local bubbleRows = 6;
+
+           for i = 1, bubbleRows do
+               row = { };
+               for j = 1, bubbleCols do
+                   image = edje.image_filled();
+                   image:image("bubble.png", "");
+                   image:show();
+                   table.insert(row, image);
+               end
+               table.insert(bubbles, row);
+           end
+
+           function resize (w, h)
+               --// Don't ask why.  lol  (This should go away soon.)
+               bubbles[1][1]:move(12345, 12345);
+
+               for i = 1, bubbleRows do
+                   for j = 1, bubbleCols do
+                       w1 = w / bubbleCols;
+                       h1 = h / bubbleRows;
+                       bubbles[i][j]:geom((j - 1) * w1, (i - 1) * h1, w1, h1);
+                       if ((1 == i) or (1 == j) or (bubbleRows == i) or (bubbleCols == j)) then
+                           bubbles[i][j]:color(0, 255, 0, 200);
+                       else
+                           bubbles[i][j]:color(math.random(200) + 55, 0, math.random(255) + 55, 200);
+                       end
+                   end
+               end
+           end
+       }
+    }
+
+   group {
+      name: "elm/bg/base/default";
+
+      parts {
+         part {
+            name: "background";
+            type: RECT;
+            mouse_events: 0;
+            description {
+               state: "default" 0.0;
+               color: 0 0 0 255;
+            }
+         }
+
+         part {
+            name: "bubbles_lua";
+            type: GROUP;
+            source: "bubbles/lua";
+            mouse_events: 0;
+            description { state: "default" 0.0; }
+         }
+
+         part {
+            name: "background_image";
+            mouse_events: 0;
+            description {
+               state: "default" 0.0;
+               aspect_preference: HORIZONTAL;
+               color_class: "test_colour";
+               image { normal: "test.png"; }
+            }
+         }
+
+         part {
+            name: "some_text";
+            type: TEXT;
+            mouse_events: 0;
+            description {
+               state: "default" 0;
+               text
+               {
+                  text: "This is test text.";
+                  text_class: "test_text_class";
+               }
+            }
+         }
+
+         part {
+            name: "example_lua";
+            type: GROUP;
+            source: "example/lua";
+            mouse_events: 0;
+            description { state: "default" 0.0; }
+         }
+
+      }
+   }
+
 }
+
diff --git a/src/examples/test.png b/src/examples/test.png
new file mode 100644 (file)
index 0000000..fb620d7
Binary files /dev/null and b/src/examples/test.png differ
index b4a0575..76aeb7e 100644 (file)
@@ -27,12 +27,12 @@ struct _Edje_Lua_Alloc
 struct _Edje_Lua_Obj
 {
    EINA_INLIST;
-   
+
    Edje         *ed;
    void        (*free_func) (void *obj);
    Eina_Bool    is_evas_obj : 1;
 };
-  
+
 struct _Edje_Lua_Timer
 {
    Edje_Lua_Obj     obj;
@@ -84,6 +84,9 @@ static int _elua_objpos(lua_State *L);
 static int _elua_objsize(lua_State *L);
 static int _elua_objgeom(lua_State *L);
 
+static int _elua_color_class(lua_State *L);
+static int _elua_text_class(lua_State *L);
+
 static int _elua_show(lua_State *L);
 static int _elua_hide(lua_State *L);
 static int _elua_visible(lua_State *L);
@@ -108,6 +111,24 @@ static int _elua_repeat(lua_State *L);
 static int _elua_precise(lua_State *L);
 
 static int _elua_rect(lua_State *L);
+static int _elua_image(lua_State *L);
+static int _elua_text(lua_State *L);
+//static int _elua_textblock(lua_State *L);  /* XXX: disabled until there are enough textblock functions implemented to make it actually useful
+static int _elua_edje(lua_State *L);
+static int _elua_line(lua_State *L);
+static int _elua_polygon(lua_State *L);
+
+static int _elua_text_text(lua_State *L);
+static int _elua_text_font(lua_State *L);
+static int _elua_image_image(lua_State *L);
+static int _elua_image_fill(lua_State *L);
+static int _elua_image_filled(lua_State *L);
+
+static int _elua_edje_file(lua_State *L);
+static int _elua_line_xy(lua_State *L);
+static int _elua_polygon_point(lua_State *L);
+static int _elua_polygon_clear(lua_State *L);
+
 
 #define ELO "|-ELO"
 
@@ -115,7 +136,7 @@ static int _elua_rect(lua_State *L);
 static lua_State *lstate = NULL;
 static jmp_buf panic_jmp;
 
-// FIXME: methods lua scrupt can provide that edje will call (not done yet):
+// FIXME: methods lua script can provide that edje will call (not done yet):
 // // scale set
 // // key down
 // // key up
@@ -142,22 +163,22 @@ static jmp_buf panic_jmp;
 // // parts extends calc
 // // part object get
 // // part geometry get
-// 
+//
 // // LATER: all the entry calls
 // // LATER: box and table calls
 // // LATER: perspective stuff change
-// 
+//
 static const struct luaL_reg _elua_edje_api [] =
 {
    // add an echo too to make it more shelly
      {"echo",         _elua_echo}, // test func - echo (i know we have print. test)
-   
+
    // time based "callback" systems
      {"timer",        _elua_timer}, // add timer
      {"animator",     _elua_animator}, // add animator
      {"transition",   _elua_transition}, // add transition
    // FIXME: need poller
-   
+
    // system information (time, date blah blah)
      {"seconds",      _elua_seconds}, // get seconds
      {"looptime",     _elua_looptime}, // get loop time
@@ -171,13 +192,21 @@ static const struct luaL_reg _elua_edje_api [] =
      {"pos",          _elua_objpos}, // get while edje object pos in canvas
      {"size",         _elua_objsize}, // get while edje object pos in canvas
      {"geom",         _elua_objgeom}, // get while edje object geometry in canvas
-   
-   // FIXME: query color classes
-   // FIXME: query text classes
 
-     {"rect",         _elua_rect}, // new rect
-   // FIXME: need image(filled, normal), text, textblock, edje
-   
+   // set and query color / text class
+     {"color_class",  _elua_color_class},
+     {"text_class",   _elua_text_class},
+
+   // create new objects
+     {"rect",         _elua_rect},
+     {"image",        _elua_image},  // defaults to a filled image.
+     {"text",         _elua_text},
+//     {"textblock",    _elua_textblock},  /* XXX: disabled until there are enough textblock functions implemented to make it actually useful
+     {"edje",         _elua_edje},
+     {"line",         _elua_line},
+     {"polygon",      _elua_polygon},
+   // FIXME: add the new sound stuff.
+
      {NULL, NULL} // end
 };
 
@@ -185,7 +214,7 @@ static const struct luaL_reg _elua_edje_evas_obj [] =
 {
    // generic object methods
      {"del",          _elua_obj_del}, // generic del any object created for edje (evas objects, timers, animators, transitions... everything)
-   
+
    // now evas stuff (manipulate, delete etc.)
      {"show",         _elua_show}, // show, return current visibility
      {"hide",         _elua_hide}, // hide, return current visibility
@@ -195,7 +224,7 @@ static const struct luaL_reg _elua_edje_evas_obj [] =
      {"pos",          _elua_pos}, // move, return current position
      {"size",         _elua_size}, // resize, return current size
      {"geom",         _elua_geom}, // move and resize and return current geometry
-   
+
      {"raise",        _elua_raise}, // raise to top
      {"lower",        _elua_lower}, // lower to bottom
      {"above",        _elua_above}, // get object above or stack obj above given obj
@@ -210,14 +239,39 @@ static const struct luaL_reg _elua_edje_evas_obj [] =
      {"pass",         _elua_pass}, // set pass events, get pass events
      {"repeat",       _elua_repeat}, // set repeat events, get repeat events
      {"precise",      _elua_precise}, // set precise inside flag, get precise
+
+//     {"color_class",  _elua_object_color_class}, // get or set object color class
+
+
+   // FIXME: make these into a subclass of this evas table using meta table magic.
+   // text object specific
+     {"font",         _elua_text_font}, // get or set text font
+     {"text",         _elua_text_text}, // get or set text
+//     {"text_class", _elua_object_text_class}, // get or set object text class
+
+   // image object specific
+     {"image",        _elua_image_image},  // get or set image
+     {"fill",         _elua_image_fill},   // get or set the fill parameters
+     {"filled",       _elua_image_filled}, // get or set the filled state (overrides fill())
+
+   // edje object specific
+     {"file",         _elua_edje_file}, // get or set edje file and group
+
+   // line object specific
+     {"xy",         _elua_line_xy}, // get or set line coords
+
+   // polygon object specific
+     {"point",         _elua_polygon_point}, // add a polygon point
+     {"clear",         _elua_polygon_clear}, // clear all polygon points
+
    // FIXME: set callbacks (mouse down, up, blah blah blah)
-   // 
+   //
    // FIXME: set scale (explicit value)
    // FIXME: need to set auto-scale (same as scale: 1)
-   
+
    // FIXME: later - set render op, anti-alias, pointer mode (autograb, nograb)
-   // FIXME: later - 
-   
+   // FIXME: later -
+
    // FIXME: map api here
 
      {NULL, NULL} // end
@@ -226,7 +280,7 @@ static const struct luaL_reg _elua_edje_evas_obj [] =
 static const struct luaL_reg _elua_edje_meta [] =
 {
      {"__gc", _elua_obj_gc}, // garbage collector func for edje objects
-   
+
      {NULL, NULL} // end
 };
 
@@ -252,7 +306,7 @@ _elua_alloc(void *ud, void *ptr, size_t osize, size_t nsize)
 {
    Edje_Lua_Alloc *ela = ud;
    void *ptr2;
-   
+
    ela->cur += nsize - osize;
    if (ela->cur > ela->max)
      {
@@ -265,7 +319,7 @@ _elua_alloc(void *ud, void *ptr, size_t osize, size_t nsize)
         free(ptr);
         return NULL;
      }
-   
+
    ptr2 = realloc(ptr, nsize);
    if (ptr2) return ptr2;
    ERR("Edje Lua cannot re-allocate " FMT_SIZE_T " bytes", nsize);
@@ -286,7 +340,7 @@ _edje_lua2_error_full(const char *file, const char *fnc, int line,
                       lua_State *L, int err_code)
 {
    const char *err_type;
-   
+
    switch (err_code)
      {
      case LUA_ERRRUN:
@@ -316,13 +370,13 @@ _elua_init(void)
    static Edje_Lua_Alloc ela = { MAX_LUA_MEM, 0 };
    const luaL_Reg *l;
    lua_State *L;
-   
+
    if (lstate) return;
-   
+
    lstate = L = lua_newstate(_elua_alloc, &ela);
    lua_atpanic(L, _elua_custom_panic);
 
-// FIXME: figure out optimal gc settings later   
+// FIXME: figure out optimal gc settings later
 //   lua_gc(L, LUA_GCSETPAUSE, 200);
 //   lua_gc(L, LUA_GCSETSTEPMUL, 200);
 
@@ -332,11 +386,11 @@ _elua_init(void)
         lua_pushstring(L, l->name);
         lua_call(L, 1, 0);
      }
-   
+
    luaL_register(L, "edje", _elua_edje_api);
    luaL_newmetatable(L, "edje");
    luaL_register(L, 0, _elua_edje_meta);
-   
+
    luaL_register(L, "edje_evas_obj", _elua_edje_evas_obj);
    luaL_newmetatable(L, "edje_evas_obj");
    luaL_register(L, 0, _elua_edje_meta);
@@ -406,7 +460,7 @@ _elua_ref_set(lua_State *L, void *key)
    lua_rawset(L, -3);
    lua_pop(L, 1); // pop obj table
 }
+
 /**
  * Cori: Get an object from the object table
  */
@@ -453,7 +507,7 @@ static int
 _elua_obj_gc(lua_State *L)
 {
    Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1);
-   if (!obj) return 0; 
+   if (!obj) return 0;
    _elua_obj_free(L, obj);
    return 0;
 }
@@ -475,7 +529,7 @@ void
 _edje_lua2_script_func_shutdown(Edje *ed)
 {
    int err;
-   
+
    lua_getglobal(ed->L, "shutdown");
    if (!lua_isnil(ed->L, -1))
      {
@@ -491,7 +545,7 @@ void
 _edje_lua2_script_func_show(Edje *ed)
 {
    int err;
-   
+
    lua_getglobal(ed->L, "show");
    if (!lua_isnil(ed->L, -1))
      {
@@ -506,7 +560,7 @@ void
 _edje_lua2_script_func_hide(Edje *ed)
 {
    int err;
-   
+
    lua_getglobal(ed->L, "hide");
    if (!lua_isnil(ed->L, -1))
      {
@@ -539,7 +593,7 @@ void
 _edje_lua2_script_func_resize(Edje *ed)
 {
    int err;
-   
+
    lua_getglobal(ed->L, "resize");
    if (!lua_isnil(ed->L, -1))
      {
@@ -556,7 +610,7 @@ void
 _edje_lua2_script_func_message(Edje *ed, Edje_Message *em)
 {
    int err, n, c, i;
-   
+
    lua_getglobal(ed->L, "message");
    if (!lua_isnil(ed->L, -1))
      {
@@ -570,8 +624,8 @@ _edje_lua2_script_func_message(Edje *ed, Edje_Message *em)
           case EDJE_MESSAGE_SIGNAL:
              break;
           case EDJE_MESSAGE_STRING:
-             lua_pushstring(ed->L, "str"); 
-             lua_pushstring(ed->L, ((Edje_Message_String *)em->msg)->str); 
+             lua_pushstring(ed->L, "str");
+             lua_pushstring(ed->L, ((Edje_Message_String *)em->msg)->str);
              n += 1;
             break;
           case EDJE_MESSAGE_INT:
@@ -667,7 +721,7 @@ void
 _edje_lua2_script_func_signal(Edje *ed, const char *sig, const char *src)
 {
    int err;
-   
+
    lua_getglobal(ed->L, "signal");
    if (!lua_isnil(ed->L, -1))
      {
@@ -698,7 +752,7 @@ _elua_timer_cb(void *data)
    Edje_Lua_Timer *elt = data;
    lua_State *L;
    int ret = 0, err = 0;
-   
+
    if (!elt->obj.ed) return 0;
    L = elt->obj.ed->L;
    if (!L) return 0;
@@ -747,7 +801,7 @@ _elua_timer(lua_State *L)
 
    val = luaL_checknumber(L, 1);
    luaL_checkany(L, 2);
-  
+
    elt = (Edje_Lua_Timer *)_elua_obj_new(L, ed, sizeof(Edje_Lua_Timer));
    elt->obj.free_func = _elua_timer_free;
    elt->timer = ecore_timer_add(val, _elua_timer_cb, elt);
@@ -764,7 +818,7 @@ _elua_animator_cb(void *data)
    Edje_Lua_Animator *ela = data;
    lua_State *L;
    int ret = 0, err = 0;
-   
+
    if (!ela->obj.ed) return 0;
    L = ela->obj.ed->L;
    if (!L) return 0;
@@ -811,7 +865,7 @@ _elua_animator(lua_State *L)
    Edje_Lua_Animator *ela;
 
    luaL_checkany(L, 1);
-  
+
    ela = (Edje_Lua_Animator *)_elua_obj_new(L, ed, sizeof(Edje_Lua_Animator));
    ela->obj.free_func = _elua_animator_free;
    ela->animator = ecore_animator_add(_elua_animator_cb, ela);
@@ -882,7 +936,7 @@ _elua_transition(lua_State *L)
 
    val = luaL_checknumber(L, 1);
    luaL_checkany(L, 2);
-  
+
    elt = (Edje_Lua_Transition *)_elua_obj_new(L, ed, sizeof(Edje_Lua_Transition));
    elt->obj.free_func = _elua_transition_free;
    elt->animator = ecore_animator_add(_elua_transition_cb, elt);
@@ -1213,6 +1267,131 @@ _elua_2_int_get(lua_State *L, int i, Eina_Bool tr,
    return n;
 }
 
+// FIXME: Should have separate functions for each lua type, instead of these multi argument style ones.
+static int
+_elua_str_int_get(lua_State *L, int i, Eina_Bool tr,
+                const char *n1, char **v1,
+                const char *n2, int *v2
+               )
+{
+   int n = 0;
+
+   if (lua_istable(L, i))
+     {
+        lua_getfield(L, i, n1);
+        if (lua_isnil(L, -1))
+          {
+             lua_pop(L, 1);
+             lua_rawgeti(L, i, 1);
+             lua_rawgeti(L, i, 2);
+          }
+        else
+          lua_getfield(L, i, n2);
+        if ((!lua_isnil(L, -1)) && (!lua_isnil(L, -2)))
+          {
+             size_t len;
+             const char *temp = lua_tolstring(L, -2, &len);
+
+             len++;  // Cater for the null at the end.
+             *v1 = malloc(len);
+             if (*v1)
+               {
+                  memcpy(*v1, temp, len);
+                  *v2 = lua_tointeger(L, -1);
+                  n = 1;
+               }
+          }
+        if (tr) lua_settop(L, i);
+     }
+   else
+     {
+        if ((lua_isstring(L, i + 0)) && (lua_isnumber(L, i + 1)))
+          {
+             size_t len;
+             const char *temp = lua_tolstring(L, i + 0, &len);
+
+             len++;  // Cater for the null at the end.
+             *v1 = malloc(len);
+             if (*v1)
+               {
+                  memcpy(*v1, temp, len);
+                  *v2 = lua_tointeger(L, i + 1);
+                  n = 2;
+               }
+          }
+        if (tr) lua_newtable(L);
+     }
+   return n;
+}
+
+static int
+_elua_2_str_get(lua_State *L, int i, Eina_Bool tr,
+                const char *n1, char **v1,
+                const char *n2, char **v2
+               )
+{
+   int n = 0;
+
+   if (lua_istable(L, i))
+     {
+        lua_getfield(L, i, n1);
+        if (lua_isnil(L, -1))
+          {
+             lua_pop(L, 1);
+             lua_rawgeti(L, i, 1);
+             lua_rawgeti(L, i, 2);
+          }
+        else
+          lua_getfield(L, i, n2);
+        if ((!lua_isnil(L, -1)) && (!lua_isnil(L, -2)))
+          {
+             size_t len;
+             char *temp = (char *) lua_tolstring(L, -2, &len);
+
+             len++;  // Cater for the null at the end.
+             *v1 = malloc(len);
+             if (*v1)
+               memcpy(*v1, temp, len);
+
+             temp = (char *) lua_tolstring(L, -1, &len);
+             len++;  // Cater for the null at the end.
+             *v2 = malloc(len);
+             if (*v2)
+               memcpy(*v2, temp, len);
+             n = 1;
+          }
+        if (tr) lua_settop(L, i);
+     }
+   else
+     {
+        if ((lua_isstring(L, i + 0)) && (lua_isstring(L, i + 1)))
+          {
+             size_t len;
+             char *temp = (char *) lua_tolstring(L, i + 0, &len);
+
+             len++;  // Cater for the null at the end.
+             *v1 = malloc(len);
+             if (*v1)
+               {
+                  memcpy(*v1, temp, len);
+                  n++;
+               }
+
+             temp = (char *) lua_tolstring(L, i + 1, &len);
+
+             len++;  // Cater for the null at the end.
+             *v2 = malloc(len);
+             if (*v2)
+               {
+                  memcpy(*v2, temp, len);
+                  n++;
+               }
+          }
+        if (tr) lua_newtable(L);
+     }
+   return n;
+}
+
 /* XXX: not used
 static int
 _elua_3_int_get(lua_State *L, int i, Eina_Bool tr,
@@ -1238,7 +1417,7 @@ _elua_3_int_get(lua_State *L, int i, Eina_Bool tr,
              lua_getfield(L, i, n2);
              lua_getfield(L, i, n3);
           }
-        if ((!lua_isnil(L, -1)) && (!lua_isnil(L, -2)) && 
+        if ((!lua_isnil(L, -1)) && (!lua_isnil(L, -2)) &&
             (!lua_isnil(L, -3)))
           {
              *v1 = lua_tointeger(L, -3);
@@ -1291,7 +1470,7 @@ _elua_4_int_get(lua_State *L, int i, Eina_Bool tr,
              lua_getfield(L, i, n3);
              lua_getfield(L, i, n4);
           }
-        if ((!lua_isnil(L, -1)) && (!lua_isnil(L, -2)) && 
+        if ((!lua_isnil(L, -1)) && (!lua_isnil(L, -2)) &&
             (!lua_isnil(L, -3)) && (!lua_isnil(L, -4)))
           {
              *v1 = lua_tointeger(L, -4);
@@ -1327,6 +1506,14 @@ _elua_int_ret(lua_State *L, const char *n, int v)
 }
 
 static void
+_elua_str_ret(lua_State *L, const char *n, const char *v)
+{
+   lua_pushstring(L, n);
+   lua_pushstring(L, v);
+   lua_settable(L, -3);
+}
+
+static void
 _elua_color_fix(int *r, int *g, int *b, int *a)
 {
    if (*r > *a) *r = *a;
@@ -1338,6 +1525,65 @@ _elua_color_fix(int *r, int *g, int *b, int *a)
 //-------------
 
 static int
+_elua_color_class(lua_State *L)
+{
+   Edje *ed = (Edje *)_elua_table_ptr_get(L, _elua_key);
+   Edje_Color_Class *c_class;
+   const char *class = luaL_checkstring(L, 1);
+   int r, g, b, a;
+
+   if (!class) return 0;
+
+   if (_elua_4_int_get(L, 2, EINA_TRUE, "r", &r, "g", &g, "b", &b, "a", &a) > 0)
+     {
+        _elua_color_fix(&r, &g, &b, &a);
+        // This is the way that embryo does it -
+        //edje_object_color_class_set(ed->obj, class, r, g, b, a, r, g, b, a, r, g, b, a);
+        // But that deals with object scope, which is currently useless in lua,
+        // since we have no objects that can use color_class yet.
+        // So we do it at global scope instead.
+        // LATER - Should do both?
+        edje_color_class_set(class, r, g, b, a, r, g, b, a, r, g, b, a);
+     }
+
+   c_class = _edje_color_class_find(ed, class);
+   if (!c_class) return 0;
+
+   _elua_int_ret(L, "r", c_class->r);
+   _elua_int_ret(L, "g", c_class->g);
+   _elua_int_ret(L, "b", c_class->b);
+   _elua_int_ret(L, "a", c_class->a);
+   return 1;
+}
+
+static int
+_elua_text_class(lua_State *L)
+{
+   Edje *ed = (Edje *)_elua_table_ptr_get(L, _elua_key);
+   Edje_Text_Class *t_class;
+   const char *class = luaL_checkstring(L, 1);
+   char *font = NULL;
+   Evas_Font_Size size = 0;
+
+   if (!class) return 0;
+
+   // Just like color_class above, this does things differently from embryo,
+   // for the same reason.
+   if (_elua_str_int_get(L, 2, EINA_TRUE, "font", &font, "size", &size) > 0)
+        edje_text_class_set(class, font, size);
+
+   t_class = _edje_text_class_find(ed, class);
+   if (!t_class) return 0;
+
+   _elua_str_ret(L, "font", t_class->font);
+   _elua_int_ret(L, "size", t_class->size);
+   return 1;
+}
+
+//-------------
+//-------------
+
+static int
 _elua_show(lua_State *L)
 {
    Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1);
@@ -1397,8 +1643,8 @@ _elua_move(lua_State *L)
           {
              elo->x = x;
              elo->y = y;
-             evas_object_move(elo->evas_obj, 
-                              obj->ed->x + elo->x, 
+             evas_object_move(elo->evas_obj,
+                              obj->ed->x + elo->x,
                               obj->ed->y + elo->y);
           }
      }
@@ -1460,8 +1706,8 @@ _elua_geom(lua_State *L)
           {
              elo->x = x;
              elo->y = y;
-             evas_object_move(elo->evas_obj, 
-                              obj->ed->x + elo->x, 
+             evas_object_move(elo->evas_obj,
+                              obj->ed->x + elo->x,
                               obj->ed->y + elo->y);
           }
         if ((w != ow) || (h != oh))
@@ -1726,6 +1972,208 @@ _elua_precise(lua_State *L)
    return 1;
 }
 
+static int
+_elua_text_font(lua_State *L)
+{
+   Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1);
+   Edje_Lua_Evas_Object *elo = (Edje_Lua_Evas_Object *)obj;
+   char *font, *font2 = NULL;
+   Evas_Font_Size   size;
+   int     inlined_font = 0;
+
+   if (!obj) return 0;
+   if (!obj->is_evas_obj) return 0;
+
+   if (_elua_str_int_get(L, 2, EINA_TRUE, "font", &font, "size", &size) > 0)
+    {
+       /* Check if the font is embedded in the .edj
+        * This is a simple check.
+        * There is a much more complicated version in edje_text.c _edje_text_recalc_apply().
+        * If we need to get more complicated, we can do that later,
+        * and maybe refactor things.
+        */
+       if (obj->ed->file->fonts)
+        {
+          Edje_Font_Directory_Entry *fnt = eina_hash_find(obj->ed->file->fonts, font);
+
+          if (fnt)
+           {
+              size_t len = strlen(font) + sizeof("edje/fonts/") + 1;
+              font2 = alloca(len);
+              sprintf(font2, "edje/fonts/%s", font);
+              font = font2;
+              inlined_font = 1;
+              font2 = NULL;
+           }
+        }
+
+       if (inlined_font) evas_object_text_font_source_set(elo->evas_obj, obj->ed->path);
+       else evas_object_text_font_source_set(elo->evas_obj, NULL);
+
+       evas_object_text_font_set(elo->evas_obj, font, size);
+    }
+
+   evas_object_text_font_get(elo->evas_obj, &font, &size);
+   _elua_str_ret(L, "font", font);
+   _elua_int_ret(L, "size", size);
+   return 1;
+}
+
+static int
+_elua_text_text(lua_State *L)
+{
+   Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1);
+   Edje_Lua_Evas_Object *elo = (Edje_Lua_Evas_Object *)obj;
+   int n;
+   if (!obj) return 0;
+   if (!obj->is_evas_obj) return 0;
+   n = lua_gettop(L);
+   if (n == 2)
+     {
+        if (lua_isstring(L, 2))
+          {
+             const char *str;
+
+             if (str = lua_tostring(L, 2))
+                evas_object_text_text_set(elo->evas_obj, str);
+          }
+     }
+   lua_pushstring(L, evas_object_text_text_get(elo->evas_obj));
+   return 1;
+}
+
+static int
+_elua_image_image(lua_State *L)
+{
+   Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1);
+   Edje_Lua_Evas_Object *elo = (Edje_Lua_Evas_Object *)obj;
+   char *file = NULL, *key = NULL;
+
+   if (!obj) return 0;
+   if (!obj->is_evas_obj) return 0;
+
+   if (_elua_2_str_get(L, 2, EINA_TRUE, "file", &file, "key", &key) > 0)
+     {
+        // FIXME: ONLY allow access to the images in the current edje file.
+        evas_object_image_file_set(elo->evas_obj, file, key);
+     }
+   evas_object_image_file_get(elo->evas_obj, &file, &key);
+   _elua_str_ret(L, "file", file);
+   _elua_str_ret(L, "key", key);
+   return 1;
+}
+
+static int
+_elua_image_fill(lua_State *L)
+{
+   Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1);
+   Edje_Lua_Evas_Object *elo = (Edje_Lua_Evas_Object *)obj;
+   Evas_Coord x, y, w, h;
+
+   if (!obj) return 0;
+   if (!obj->is_evas_obj) return 0;
+
+   if (_elua_4_int_get(L, 2, EINA_TRUE, "x", &x, "y", &y, "w", &w, "h", &h) > 0)
+     {
+        evas_object_image_fill_set(elo->evas_obj, x, y, w, h);
+     }
+   evas_object_image_fill_get(elo->evas_obj, &x, &y, &w, &h);
+   _elua_int_ret(L, "x", x);
+   _elua_int_ret(L, "y", y);
+   _elua_int_ret(L, "w", w);
+   _elua_int_ret(L, "h", h);
+
+   return 1;
+}
+
+static int
+_elua_image_filled(lua_State *L)
+{
+   Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1);
+   Edje_Lua_Evas_Object *elo = (Edje_Lua_Evas_Object *)obj;
+   int n;
+
+   if (!obj) return 0;
+   if (!obj->is_evas_obj) return 0;
+
+   n = lua_gettop(L);
+   if (n == 2)
+     {
+        evas_object_image_filled_set(elo->evas_obj, lua_toboolean(L, 2));
+     }
+   lua_pushboolean(L, evas_object_image_filled_get(elo->evas_obj));
+   return 1;
+}
+
+static int _elua_edje_file(lua_State *L)
+{
+   Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1);
+   Edje_Lua_Evas_Object *elo = (Edje_Lua_Evas_Object *)obj;
+   char *file = NULL, *group = NULL;
+
+   if (!obj) return 0;
+   if (!obj->is_evas_obj) return 0;
+
+   // FIXME: Only allow groups from the same file this edje came from.
+   if (_elua_2_str_get(L, 2, EINA_TRUE, "file", &file, "group", &group) > 0)
+     {
+        edje_object_file_set(elo->evas_obj, file, group);
+     }
+   edje_object_file_get(elo->evas_obj, &file, &group);
+   _elua_str_ret(L, "file", file);
+   _elua_str_ret(L, "group", group);
+   return 1;
+}
+
+static int _elua_line_xy(lua_State *L)
+{
+   Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1);
+   Edje_Lua_Evas_Object *elo = (Edje_Lua_Evas_Object *)obj;
+   Evas_Coord x1, y1, x2, y2;
+
+   if (!obj) return 0;
+   if (!obj->is_evas_obj) return 0;
+
+   if (_elua_4_int_get(L, 2, EINA_TRUE, "x1", &x1, "y1", &y1, "x2", &x2, "y2", &y2) > 0)
+     {
+        evas_object_line_xy_set(elo->evas_obj, x1, y1, x2, y2);
+     }
+   evas_object_line_xy_get(elo->evas_obj, &x1, &y1, &x2, &y2);
+   _elua_int_ret(L, "x1", x1);
+   _elua_int_ret(L, "y1", y1);
+   _elua_int_ret(L, "x2", x2);
+   _elua_int_ret(L, "y2", y2);
+   return 1;
+}
+
+static int _elua_polygon_point(lua_State *L)
+{
+   Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1);
+   Edje_Lua_Evas_Object *elo = (Edje_Lua_Evas_Object *)obj;
+   Evas_Coord x, y;
+
+   if (!obj) return 0;
+   if (!obj->is_evas_obj) return 0;
+
+   if (_elua_2_int_get(L, 2, EINA_FALSE, "x", &x, "y", &y) > 0)
+     {
+        evas_object_polygon_point_add(elo->evas_obj, x, y);
+     }
+
+   return 1;
+}
+
+static int _elua_polygon_clear(lua_State *L)
+{
+   Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1);
+   Edje_Lua_Evas_Object *elo = (Edje_Lua_Evas_Object *)obj;
+
+   if (!obj) return 0;
+   if (!obj->is_evas_obj) return 0;
+   evas_object_polygon_points_clear(elo->evas_obj);
+   return 1;
+}
+
 //-------------
 static void
 _elua_evas_obj_free(void *obj)
@@ -1756,6 +2204,116 @@ _elua_rect(lua_State *L)
    return 1;
 }
 
+static int
+_elua_image(lua_State *L)
+{
+   Edje *ed = (Edje *)_elua_table_ptr_get(L, _elua_key);
+   Edje_Lua_Evas_Object *elo;
+
+   elo = (Edje_Lua_Evas_Object *)_elua_obj_new(L, ed, sizeof(Edje_Lua_Evas_Object));
+   elo->obj.free_func = _elua_evas_obj_free;
+   elo->obj.is_evas_obj = 1;
+   elo->evas_obj = evas_object_image_filled_add(evas_object_evas_get(ed->obj));
+   evas_object_smart_member_add(elo->evas_obj, ed->obj);
+   evas_object_clip_set(elo->evas_obj, ed->base.clipper);
+   evas_object_move(elo->evas_obj, ed->x, ed->y);
+   evas_object_resize(elo->evas_obj, 0, 0);
+   evas_object_data_set(elo->evas_obj, ELO, elo);
+   return 1;
+}
+
+static int
+_elua_text(lua_State *L)
+{
+   Edje *ed = (Edje *)_elua_table_ptr_get(L, _elua_key);
+   Edje_Lua_Evas_Object *elo;
+
+   elo = (Edje_Lua_Evas_Object *)_elua_obj_new(L, ed, sizeof(Edje_Lua_Evas_Object));
+   elo->obj.free_func = _elua_evas_obj_free;
+   elo->obj.is_evas_obj = 1;
+   elo->evas_obj = evas_object_text_add(evas_object_evas_get(ed->obj));
+   evas_object_smart_member_add(elo->evas_obj, ed->obj);
+   evas_object_clip_set(elo->evas_obj, ed->base.clipper);
+   evas_object_move(elo->evas_obj, ed->x, ed->y);
+   evas_object_resize(elo->evas_obj, 0, 0);
+   evas_object_data_set(elo->evas_obj, ELO, elo);
+   return 1;
+}
+
+/* XXX: disabled until there are enough textblock functions implemented to make it actually useful
+static int
+_elua_textblock(lua_State *L)
+{
+   Edje *ed = (Edje *)_elua_table_ptr_get(L, _elua_key);
+   Edje_Lua_Evas_Object *elo;
+
+   elo = (Edje_Lua_Evas_Object *)_elua_obj_new(L, ed, sizeof(Edje_Lua_Evas_Object));
+   elo->obj.free_func = _elua_evas_obj_free;
+   elo->obj.is_evas_obj = 1;
+   elo->evas_obj = evas_object_textblock_add(evas_object_evas_get(ed->obj));
+   evas_object_smart_member_add(elo->evas_obj, ed->obj);
+   evas_object_clip_set(elo->evas_obj, ed->base.clipper);
+   evas_object_move(elo->evas_obj, ed->x, ed->y);
+   evas_object_resize(elo->evas_obj, 0, 0);
+   evas_object_data_set(elo->evas_obj, ELO, elo);
+   return 1;
+}
+*/
+
+static int
+_elua_edje(lua_State *L)
+{
+   Edje *ed = (Edje *)_elua_table_ptr_get(L, _elua_key);
+   Edje_Lua_Evas_Object *elo;
+
+   elo = (Edje_Lua_Evas_Object *)_elua_obj_new(L, ed, sizeof(Edje_Lua_Evas_Object));
+   elo->obj.free_func = _elua_evas_obj_free;
+   elo->obj.is_evas_obj = 1;
+   elo->evas_obj = edje_object_add(evas_object_evas_get(ed->obj));
+   evas_object_smart_member_add(elo->evas_obj, ed->obj);
+   evas_object_clip_set(elo->evas_obj, ed->base.clipper);
+   evas_object_move(elo->evas_obj, ed->x, ed->y);
+   evas_object_resize(elo->evas_obj, 0, 0);
+   evas_object_data_set(elo->evas_obj, ELO, elo);
+   return 1;
+}
+
+static int
+_elua_line(lua_State *L)
+{
+   Edje *ed = (Edje *)_elua_table_ptr_get(L, _elua_key);
+   Edje_Lua_Evas_Object *elo;
+
+   elo = (Edje_Lua_Evas_Object *)_elua_obj_new(L, ed, sizeof(Edje_Lua_Evas_Object));
+   elo->obj.free_func = _elua_evas_obj_free;
+   elo->obj.is_evas_obj = 1;
+   elo->evas_obj = evas_object_line_add(evas_object_evas_get(ed->obj));
+   evas_object_smart_member_add(elo->evas_obj, ed->obj);
+   evas_object_clip_set(elo->evas_obj, ed->base.clipper);
+   evas_object_move(elo->evas_obj, ed->x, ed->y);
+   evas_object_resize(elo->evas_obj, 0, 0);
+   evas_object_data_set(elo->evas_obj, ELO, elo);
+   return 1;
+}
+
+static int
+_elua_polygon(lua_State *L)
+{
+   Edje *ed = (Edje *)_elua_table_ptr_get(L, _elua_key);
+   Edje_Lua_Evas_Object *elo;
+
+   elo = (Edje_Lua_Evas_Object *)_elua_obj_new(L, ed, sizeof(Edje_Lua_Evas_Object));
+   elo->obj.free_func = _elua_evas_obj_free;
+   elo->obj.is_evas_obj = 1;
+   elo->evas_obj = evas_object_polygon_add(evas_object_evas_get(ed->obj));
+   evas_object_smart_member_add(elo->evas_obj, ed->obj);
+   evas_object_clip_set(elo->evas_obj, ed->base.clipper);
+   evas_object_move(elo->evas_obj, ed->x, ed->y);
+   evas_object_resize(elo->evas_obj, 0, 0);
+   evas_object_data_set(elo->evas_obj, ELO, elo);
+   return 1;
+}
+
 //-------------
 //---------------
 //-------------------
@@ -1773,13 +2331,13 @@ _edje_lua2_script_init(Edje *ed)
    void *data;
    int size;
    lua_State *L;
-   
+
    if (ed->L) return;
    _elua_init();
    L = ed->L = lua_newstate(_elua_alloc, &ela);
    lua_atpanic(L, _elua_custom_panic);
 
-// FIXME: figure out optimal gc settings later   
+// FIXME: figure out optimal gc settings later
 //   lua_gc(L, LUA_GCSETPAUSE, 200);
 //   lua_gc(L, LUA_GCSETSTEPMUL, 200);
 
@@ -1789,8 +2347,8 @@ _edje_lua2_script_init(Edje *ed)
         lua_pushstring(L, l->name);
         lua_call(L, 1, 0);
      }
-   
-   
+
+
    luaL_register(L, "edje", _elua_edje_api);
    luaL_newmetatable(L, "edje");
    luaL_register(L, 0, _elua_edje_meta);
@@ -1811,21 +2369,21 @@ _edje_lua2_script_init(Edje *ed)
    lua_pushstring(L, "v");
    lua_rawset(L, -3);
    lua_rawset(L, LUA_REGISTRYINDEX);
-   
+
    _elua_table_ptr_set(L, _elua_key, ed);
-   
+
    snprintf(buf, sizeof(buf), "edje/scripts/lua/%i", ed->collection->id);
    data = eet_read(ed->file->ef, buf, &size);
-   
+
    if (data)
      {
         int err;
-   
+
         err = luaL_loadbuffer(L, data, size, "edje_lua_script");
         if (err)
           {
              if (err == LUA_ERRSYNTAX)
-               ERR("lua load syntax error: %s", 
+               ERR("lua load syntax error: %s",
                    lua_tostring(L, -1));
              else if (err == LUA_ERRMEM)
                ERR("lua load memory allocation error: %s",