From 85eaa17d79ce4eb399470a0a20d6dc59f9b07c43 Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Sun, 18 May 2014 01:57:28 +1000 Subject: Add widget hide, show, and text setting functions. --- src/GuiLua/GuiLua.c | 39 +++++++++++++++++++++++++++++++++++++-- src/libraries/winFang.c | 10 ++++++++++ src/libraries/winFang.h | 2 ++ 3 files changed, 49 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/GuiLua/GuiLua.c b/src/GuiLua/GuiLua.c index ae9af48..5a30ff9 100644 --- a/src/GuiLua/GuiLua.c +++ b/src/GuiLua/GuiLua.c @@ -216,6 +216,37 @@ static int colour(lua_State *L) return 0; } +static int widHide(lua_State *L) +{ + Widget *wid = lua_touserdata(L, 1); + + if (wid && strcmp(wid->magic, "Widget") == 0) + widgetHide(wid); + return 0; +} + +static int widShow(lua_State *L) +{ + Widget *wid = lua_touserdata(L, 1); + + if (wid && strcmp(wid->magic, "Widget") == 0) + widgetShow(wid); + return 0; +} + +static int text(lua_State *L) +{ + Widget *wid = lua_touserdata(L, 1); + char *text = ""; + + pull_lua(L, 2, "$", &text); + if (wid && strcmp(wid->magic, "Widget") == 0) + { + elm_object_text_set(wid->obj, text); + } + return 0; +} + /* userdata vs light userdata Lua wants to allocate the memory for userdata itself. Light user data an actual pointer. @@ -358,11 +389,15 @@ PD("GuiLua 2"); // push_lua(L, "@ ( = $ $ & $ )", skang, THINGASM, skang, "widget", "Create a widget.", widget, "userdata,string,string,number,number,number,number"); push_lua(L, "@ ( = $ $ & )", skang, THINGASM, skang, "widget", "Create a widget.", widget, 0); PD("GuiLua 3"); - push_lua(L, "@ ( = $ $ & )", skang, THINGASM, skang, "action", "Add an action to a widget.", action, 0); + push_lua(L, "@ ( = $ $ & $ )", skang, THINGASM, skang, "action", "Add an action to a widget.", action, "string", 0); push_lua(L, "@ ( = $ $ & )", skang, THINGASM, skang, "Colour", "Change widget colours.", colour, 0); + push_lua(L, "@ ( = $ $ & )", skang, THINGASM, skang, "hide", "Hide a widget.", widHide, 0); + push_lua(L, "@ ( = $ $ & )", skang, THINGASM, skang, "show", "Show a widget.", widShow, 0); + push_lua(L, "@ ( = $ $ & $ )", skang, THINGASM, skang, "text", "Set the text for a widget.", text, "string", 0); + push_lua(L, "@ ( = $ $ & )", skang, THINGASM, skang, "loopWindow", "Run our windows main loop.", loopWindow, 0); push_lua(L, "@ ( = $ $ & )", skang, THINGASM, skang, "quit", "Quit, exit, remove thyself.", quit, 0); - push_lua(L, "@ ( = $ $ & $ )", skang, THINGASM, skang, "closeWindow", "Closes a window.", closeWindow, "userdata", 0); // TODO - closeWindow, "userdata"); + push_lua(L, "@ ( = $ $ & $ )", skang, THINGASM, skang, "closeWindow", "Closes a window.", closeWindow, "userdata", 0); // TODO - closeWindow, "userdata"); // A test of the array building stuff. push_lua(L, "@ ( { = $ $ % $widget !required } )", skang, THINGASM, skang, "wibble", "It's wibbly!", 1, "'edit', 'The wibblinator:', 1, 1, 10, 50", 1, 0); diff --git a/src/libraries/winFang.c b/src/libraries/winFang.c index dc5188a..0d1622d 100644 --- a/src/libraries/winFang.c +++ b/src/libraries/winFang.c @@ -199,6 +199,16 @@ void winFangShow(winFang *win) evas_object_show(win->hand[i]); } +void widgetHide(Widget *wid) +{ + evas_object_hide(wid->obj); +} + +void widgetShow(Widget *wid) +{ + evas_object_show(wid->obj); +} + winFang *winFangAdd(winFang *parent, int x, int y, int w, int h, char *title, char *name, EPhysics_World *world) { winFang *result; diff --git a/src/libraries/winFang.h b/src/libraries/winFang.h index bae3082..f3f4170 100644 --- a/src/libraries/winFang.h +++ b/src/libraries/winFang.h @@ -94,6 +94,8 @@ void HamrTime(void *elm_main, char *domain); winFang *winFangAdd(winFang *parent, int x, int y, int w, int h, char *title, char *name, EPhysics_World *world); void winFangHide(winFang *win); void winFangShow(winFang *win); +void widgetHide(Widget *wid); +void widgetShow(Widget *wid); void winFangCalcMinSize(winFang *win); void winFangDel(winFang *win); -- cgit v1.1