So try this one instead.  It works.  B-)

-- 
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 64519)
+++ ChangeLog	(working copy)
@@ -175,3 +175,7 @@
 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.
Index: src/lib/edje_lua2.c
===================================================================
--- src/lib/edje_lua2.c	(revision 64519)
+++ src/lib/edje_lua2.c	(working copy)
@@ -84,6 +84,8 @@
 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_show(lua_State *L);
 static int _elua_hide(lua_State *L);
 static int _elua_visible(lua_State *L);
@@ -172,7 +174,8 @@
      {"size",         _elua_objsize}, // get while edje object pos in canvas
      {"geom",         _elua_objgeom}, // get while edje object geometry in canvas
    
-   // FIXME: query color classes
+   // query color
+     {"color_class",        _elua_color_class},
    // FIXME: query text classes
 
      {"rect",         _elua_rect}, // new rect
@@ -1338,6 +1341,41 @@
 //-------------
 
 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_show(lua_State *L)
 {
    Edje_Lua_Obj *obj = (Edje_Lua_Obj *)lua_touserdata(L, 1);
Index: src/examples/lua_script.edc
===================================================================
--- src/examples/lua_script.edc	(revision 64519)
+++ src/examples/lua_script.edc	(working copy)
@@ -1,3 +1,7 @@
+color_classes {
+    color_class { name:  "test_colour";	color: 255 255 0 255; }
+}
+
 collections {
    group { name: "example";
       lua_script_only: 1;
@@ -110,6 +114,16 @@
 
          --// 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", 0, 255, 255, 128);
+         print("lua::color_class= " .. colour.r .. "," .. colour.g .. "," .. colour.b .. "," .. colour.a);
+         colour = edje.color_class("test_colour", { r=32, g=64, b=128, a=255 });
+         print("lua::color_class= " .. colour.r .. "," .. colour.g .. "," .. colour.b .. "," .. colour.a);
+         colour = edje.color_class("test_colour");
+         print("lua::color_class= " .. colour.r .. "," .. colour.g .. "," .. colour.b .. "," .. colour.a);
  
          --// shutdown func - generally empty or not there. everything gcd for you
          function shutdown ()

Attachment: signature.asc
Description: PGP signature

------------------------------------------------------------------------------
Get your Android app more play: Bring it to the BlackBerry PlayBook 
in minutes. BlackBerry App World™ now supports Android™ Apps 
for the BlackBerry® PlayBook™. Discover just how easy and simple 
it is! http://p.sf.net/sfu/android-dev2dev
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to