Another day, another patch.  One big patch as raster requested, with
all my edje lua changes in it.  He wants to chat about it today, but I
gotta take a nap now.  lol

I had a poke at subclassing the various evas object types, so their
particular functions are kept on their own and not pollute the general
evas object function name space, but...

...not sure why there are two lua states created.  One is for each edje
lua only script, and that's fine.  The other seems to be a global one
that is never used.  Each had it's own copy of the existing edje and
evas name spaces.  Duplicating the entire structure of evas object
functions seemed like a silly idea.  I'm tired, so I left that for
later.  I at least got the code for this figured out.

It's bad enough that lua wants these sorts of things in three places
itself.  lol

It all needs a bit of refactoring anyway.  It will be mostly boiler
plate, so all that duplication should be stuffed into macros or small
common functions.  Depending on which way we want to go.

/me sleeps and hopes to catch raster later today for the promised chat.

-- 
A big old stinking pile of genius that no one wants
coz there are too many silver coated monkeys in the world.
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 64787)
+++ ChangeLog	(working copy)
@@ -175,3 +175,25 @@
 2011-10-03  Tom Hacohen (TAsn)
 
 	* Entry: Added change information to entry,changed,user
+
+2011-10-30  David Seikel (onefang)
+
+	* Lua: Added color_class function.
+
+2011-10-31  David Seikel (onefang)
+
+	* Lua: Added text_class function.
+
+2011-11-06  David Seikel (onefang)
+
+	* Lua: Add image, image_filled, text, textblock, and edje objects.
+	  Very basic support.
+	* Add real_geom function, to bypass the cached geom values and see what evas set them to.
+	* Add functions for set/get text font and text.
+	* Add function for set/get image image (still needs to be able to read images in the edje file).
+	* Add function for set/get 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.
+
Index: src/lib/edje_lua2.c
===================================================================
--- src/lib/edje_lua2.c	(revision 64787)
+++ src/lib/edje_lua2.c	(working copy)
@@ -84,6 +84,9 @@
 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);
@@ -92,6 +95,7 @@
 static int _elua_pos(lua_State *L);
 static int _elua_size(lua_State *L);
 static int _elua_geom(lua_State *L);
+static int _elua_real_geom(lua_State *L);
 static int _elua_raise(lua_State *L);
 static int _elua_lower(lua_State *L);
 static int _elua_above(lua_State *L);
@@ -108,14 +112,31 @@
 static int _elua_precise(lua_State *L);
 
 static int _elua_rect(lua_State *L);
+static int _elua_image(lua_State *L);
+static int _elua_image_filled(lua_State *L);
+static int _elua_text(lua_State *L);
+static int _elua_textblock(lua_State *L);
+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_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"
 
 //--------------------------------------------------------------------------//
 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
@@ -172,11 +193,19 @@
      {"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
+   // set and query color / text class
+     {"color_class",  _elua_color_class},
+     {"text_class",   _elua_text_class},
 
-     {"rect",         _elua_rect}, // new rect
-   // FIXME: need image(filled, normal), text, textblock, edje
+   // create new objects
+     {"rect",         _elua_rect},
+     {"image",        _elua_image},
+     {"image_filled", _elua_image_filled},
+     {"text",         _elua_text},
+     {"textblock",    _elua_textblock},
+     {"edje",         _elua_edje},
+     {"line",         _elua_line},
+     {"polygon",      _elua_polygon},
    
      {NULL, NULL} // end
 };
@@ -195,6 +224,7 @@
      {"pos",          _elua_pos}, // move, return current position
      {"size",         _elua_size}, // resize, return current size
      {"geom",         _elua_geom}, // move and resize and return current geometry
+     {"real_geom",    _elua_real_geom}, // return current real geometry
    
      {"raise",        _elua_raise}, // raise to top
      {"lower",        _elua_lower}, // lower to bottom
@@ -210,6 +240,27 @@
      {"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
+
+   // 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
+
+   // 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)
@@ -1213,6 +1264,131 @@
    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,
@@ -1327,6 +1503,14 @@
 }
 
 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 +1522,65 @@
 //-------------
 
 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);
@@ -1476,6 +1719,24 @@
 }
 
 static int
+_elua_real_geom(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 x, y, w, h;
+
+   if (!obj) return 0;
+   if (!obj->is_evas_obj) return 0;
+   evas_object_geometry_get(elo->evas_obj, &x, &y, &w, &h);
+   lua_newtable(L);
+   _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_raise(lua_State *L)
 {
    Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1);
@@ -1724,6 +1985,164 @@
    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)
+     {
+        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_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;
+
+   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)
@@ -1754,6 +2173,132 @@
    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_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_image_filled(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;
+}
+
+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;
+}
+
 //-------------
 //---------------
 //-------------------
Index: src/examples/lua_script.edc
===================================================================
--- src/examples/lua_script.edc	(revision 64787)
+++ src/examples/lua_script.edc	(working copy)
@@ -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 @@
          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 @@
             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 @@
          --// 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 @@
          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();
  
-         --// shutdown func - generally empty or not there. everything gcd for you
+         --// 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 garbage collected for you
          function shutdown ()
             print("lua::shutdown ... " .. D.val);
          end
@@ -132,15 +175,114 @@
          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. chekc 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
+		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; }
+         }
+
+      }
+   }
+
+}
+

Attachment: signature.asc
Description: PGP signature

------------------------------------------------------------------------------
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to