aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--lib/skang.lua10
-rw-r--r--src/GuiLua/GuiLua.c39
-rw-r--r--src/libraries/winFang.c10
-rw-r--r--src/libraries/winFang.h2
4 files changed, 57 insertions, 4 deletions
diff --git a/lib/skang.lua b/lib/skang.lua
index 90079ad..e44d4bc 100644
--- a/lib/skang.lua
+++ b/lib/skang.lua
@@ -1031,14 +1031,18 @@ local widgets = {}
1031--thingasm{widgets, 'window', 'The window.', types='userdata'} 1031--thingasm{widgets, 'window', 'The window.', types='userdata'}
1032thingasm{widgets, 'W', 'Holds all the widgets', types='Keyed'} 1032thingasm{widgets, 'W', 'Holds all the widgets', types='Keyed'}
1033widgets.W{'Cwidget', 'The widget.', types='userdata'} 1033widgets.W{'Cwidget', 'The widget.', types='userdata'}
1034widgets.W{'action,a', 'The action for the widget.', 'nada', types='string'} 1034widgets.W{'action,a', 'The action for the widget.', 'nada()', types='string'}
1035widgets.W{'text,t', 'The text for the widget.', '', types='string'}
1035local aIsValid = function (self, parent) 1036local aIsValid = function (self, parent)
1036 local result = Thing.isValid(self, parent) 1037 local result = Thing.isValid(self, parent)
1037 1038
1038 if result then 1039 if result then
1039 local value = parent[self.names[1] ] 1040 local value = parent[self.names[1] ]
1041 if 'userdata' == type(parent.Cwidget) then
1040--print('NEW ACTION - ' .. self.names[1] .. ' = ' .. value .. ' ' .. type(parent.Cwidget)) 1042--print('NEW ACTION - ' .. self.names[1] .. ' = ' .. value .. ' ' .. type(parent.Cwidget))
1041 action(parent.Cwidget, value) 1043 if ('action' == self.names[1]) and ('nada()' ~= value) then action(parent.Cwidget, value) end
1044 if ('text' == self.names[1]) and ('' ~= value) then text (parent.Cwidget, value) end
1045 end
1042 end 1046 end
1043 return result 1047 return result
1044end 1048end
@@ -1095,6 +1099,8 @@ window = function(w, h, title, name)
1095 win = copy(widgets, name) 1099 win = copy(widgets, name)
1096 local wMum, wThingy = getStuffed(win.W, 'a') 1100 local wMum, wThingy = getStuffed(win.W, 'a')
1097 wThingy.isValid = aIsValid 1101 wThingy.isValid = aIsValid
1102 local wMum, wThingy = getStuffed(win.W, 't')
1103 wThingy.isValid = aIsValid
1098 win.window = Cwindow(caller, w, h, title, name) 1104 win.window = Cwindow(caller, w, h, title, name)
1099 return win 1105 return win
1100end 1106end
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)
216 return 0; 216 return 0;
217} 217}
218 218
219static int widHide(lua_State *L)
220{
221 Widget *wid = lua_touserdata(L, 1);
222
223 if (wid && strcmp(wid->magic, "Widget") == 0)
224 widgetHide(wid);
225 return 0;
226}
227
228static int widShow(lua_State *L)
229{
230 Widget *wid = lua_touserdata(L, 1);
231
232 if (wid && strcmp(wid->magic, "Widget") == 0)
233 widgetShow(wid);
234 return 0;
235}
236
237static int text(lua_State *L)
238{
239 Widget *wid = lua_touserdata(L, 1);
240 char *text = "";
241
242 pull_lua(L, 2, "$", &text);
243 if (wid && strcmp(wid->magic, "Widget") == 0)
244 {
245 elm_object_text_set(wid->obj, text);
246 }
247 return 0;
248}
249
219/* userdata vs light userdata 250/* userdata vs light userdata
220 Lua wants to allocate the memory for userdata itself. 251 Lua wants to allocate the memory for userdata itself.
221 Light user data an actual pointer. 252 Light user data an actual pointer.
@@ -358,11 +389,15 @@ PD("GuiLua 2");
358// push_lua(L, "@ ( = $ $ & $ )", skang, THINGASM, skang, "widget", "Create a widget.", widget, "userdata,string,string,number,number,number,number"); 389// push_lua(L, "@ ( = $ $ & $ )", skang, THINGASM, skang, "widget", "Create a widget.", widget, "userdata,string,string,number,number,number,number");
359 push_lua(L, "@ ( = $ $ & )", skang, THINGASM, skang, "widget", "Create a widget.", widget, 0); 390 push_lua(L, "@ ( = $ $ & )", skang, THINGASM, skang, "widget", "Create a widget.", widget, 0);
360PD("GuiLua 3"); 391PD("GuiLua 3");
361 push_lua(L, "@ ( = $ $ & )", skang, THINGASM, skang, "action", "Add an action to a widget.", action, 0); 392 push_lua(L, "@ ( = $ $ & $ )", skang, THINGASM, skang, "action", "Add an action to a widget.", action, "string", 0);
362 push_lua(L, "@ ( = $ $ & )", skang, THINGASM, skang, "Colour", "Change widget colours.", colour, 0); 393 push_lua(L, "@ ( = $ $ & )", skang, THINGASM, skang, "Colour", "Change widget colours.", colour, 0);
394 push_lua(L, "@ ( = $ $ & )", skang, THINGASM, skang, "hide", "Hide a widget.", widHide, 0);
395 push_lua(L, "@ ( = $ $ & )", skang, THINGASM, skang, "show", "Show a widget.", widShow, 0);
396 push_lua(L, "@ ( = $ $ & $ )", skang, THINGASM, skang, "text", "Set the text for a widget.", text, "string", 0);
397
363 push_lua(L, "@ ( = $ $ & )", skang, THINGASM, skang, "loopWindow", "Run our windows main loop.", loopWindow, 0); 398 push_lua(L, "@ ( = $ $ & )", skang, THINGASM, skang, "loopWindow", "Run our windows main loop.", loopWindow, 0);
364 push_lua(L, "@ ( = $ $ & )", skang, THINGASM, skang, "quit", "Quit, exit, remove thyself.", quit, 0); 399 push_lua(L, "@ ( = $ $ & )", skang, THINGASM, skang, "quit", "Quit, exit, remove thyself.", quit, 0);
365 push_lua(L, "@ ( = $ $ & $ )", skang, THINGASM, skang, "closeWindow", "Closes a window.", closeWindow, "userdata", 0); // TODO - closeWindow, "userdata"); 400 push_lua(L, "@ ( = $ $ & $ )", skang, THINGASM, skang, "closeWindow", "Closes a window.", closeWindow, "userdata", 0); // TODO - closeWindow, "userdata");
366 401
367 // A test of the array building stuff. 402 // A test of the array building stuff.
368 push_lua(L, "@ ( { = $ $ % $widget !required } )", skang, THINGASM, skang, "wibble", "It's wibbly!", 1, "'edit', 'The wibblinator:', 1, 1, 10, 50", 1, 0); 403 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)
199 evas_object_show(win->hand[i]); 199 evas_object_show(win->hand[i]);
200} 200}
201 201
202void widgetHide(Widget *wid)
203{
204 evas_object_hide(wid->obj);
205}
206
207void widgetShow(Widget *wid)
208{
209 evas_object_show(wid->obj);
210}
211
202winFang *winFangAdd(winFang *parent, int x, int y, int w, int h, char *title, char *name, EPhysics_World *world) 212winFang *winFangAdd(winFang *parent, int x, int y, int w, int h, char *title, char *name, EPhysics_World *world)
203{ 213{
204 winFang *result; 214 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);
94winFang *winFangAdd(winFang *parent, int x, int y, int w, int h, char *title, char *name, EPhysics_World *world); 94winFang *winFangAdd(winFang *parent, int x, int y, int w, int h, char *title, char *name, EPhysics_World *world);
95void winFangHide(winFang *win); 95void winFangHide(winFang *win);
96void winFangShow(winFang *win); 96void winFangShow(winFang *win);
97void widgetHide(Widget *wid);
98void widgetShow(Widget *wid);
97void winFangCalcMinSize(winFang *win); 99void winFangCalcMinSize(winFang *win);
98void winFangDel(winFang *win); 100void winFangDel(winFang *win);
99 101