This is my first crack at adding more lua stuff to edje. This implements getting and setting color_classes.
It's not working though, I'm missing something. The function reads the existing color_classes fine. The actual values in the colour_class actually change, but the on screen colour never does. I copied how embryo does it. Perhaps the color_class in the lua script only group is not a pointer to the one in the edje, but a clone of it? Maybe someone can enlighten me about what is wrong? Yes, we would also need a function to set the color_class of a lua object. That might shed some light on the problem. I'll probably write that next. My tests use a color_class defined outside the collection, an edje group with parts using that color_class, and a script only lua group trying to change that color_class. My changes to lua_script.edc just show basic usage, think that example edc needs some love. -- 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,35 @@ //------------- 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); + edje_object_color_class_set(ed->obj, 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 ()
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