aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/GuiLua
diff options
context:
space:
mode:
authorDavid Walter Seikel2014-05-05 17:36:39 +1000
committerDavid Walter Seikel2014-05-05 17:36:39 +1000
commit9e803d749af50c55a2858b9c1c26cc3db5fa49bb (patch)
tree3dca283fac62a99601b7dbe2d237a79be8aed0aa /src/GuiLua
parentWhitespace-- (diff)
downloadSledjHamr-9e803d749af50c55a2858b9c1c26cc3db5fa49bb.zip
SledjHamr-9e803d749af50c55a2858b9c1c26cc3db5fa49bb.tar.gz
SledjHamr-9e803d749af50c55a2858b9c1c26cc3db5fa49bb.tar.bz2
SledjHamr-9e803d749af50c55a2858b9c1c26cc3db5fa49bb.tar.xz
GuiLua handles multiple windows now.
Diffstat (limited to 'src/GuiLua')
-rw-r--r--src/GuiLua/GuiLua.c45
1 files changed, 27 insertions, 18 deletions
diff --git a/src/GuiLua/GuiLua.c b/src/GuiLua/GuiLua.c
index 310d90b..f3956cb 100644
--- a/src/GuiLua/GuiLua.c
+++ b/src/GuiLua/GuiLua.c
@@ -143,8 +143,8 @@ and ordinary elementary widgets. Proper introspection can come later.
143#include "GuiLua.h" 143#include "GuiLua.h"
144 144
145 145
146static int logDom; // Our logging domain. 146static int logDom; // Our logging domain.
147static winFang *win; 147static Eina_Clist winFangs; // The windows we might open.
148 148
149 149
150/* Sooo, how to do this - 150/* Sooo, how to do this -
@@ -156,7 +156,6 @@ win.quitter.colour.r = 5 -> direct access to the table, well "direct" via Th
156*/ 156*/
157 157
158 158
159// TODO - These functions should be able to deal with multiple windows.
160// TODO - Should be able to open external and internal windows, and even switch between them on the fly. 159// TODO - Should be able to open external and internal windows, and even switch between them on the fly.
161static void _on_click(void *data, Evas_Object *obj, void *event_info EINA_UNUSED) 160static void _on_click(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
162{ 161{
@@ -172,14 +171,14 @@ static void _on_click(void *data, Evas_Object *obj, void *event_info EINA_UNUSED
172 } 171 }
173} 172}
174 173
175// TODO - skang.thingasm() should pass us the winFang pointer it has as the parent module.
176static int widget(lua_State *L) 174static int widget(lua_State *L)
177{ 175{
178 char *type = "label"; 176 winFang *win = NULL;
177 char *type = "button";
179 char *title = ":"; 178 char *title = ":";
180 int x = 1, y = 1, w = WIDTH/3, h = HEIGHT/3; 179 int x = 1, y = 1, w = WIDTH/3, h = HEIGHT/3;
181 180
182 pull_lua(L, 1, "$type $title %x %y %w %h", &type, &title, &x, &y, &w, &h); 181 pull_lua(L, 1, "*window $type $title %x %y %w %h", &win, &type, &title, &x, &y, &w, &h);
183 182
184 // Poor mans introspection, until I write real introspection into EFL. 183 // Poor mans introspection, until I write real introspection into EFL.
185 // TODO - The alternative is to just lookup the ELM_*_CLASS in a hash table? 184 // TODO - The alternative is to just lookup the ELM_*_CLASS in a hash table?
@@ -198,11 +197,6 @@ static int widget(lua_State *L)
198 ); 197 );
199 evas_object_smart_callback_add(wid->obj, "clicked", _on_click, wid); 198 evas_object_smart_callback_add(wid->obj, "clicked", _on_click, wid);
200 199
201 /* Evas_Object *bt isn't a real pointer it seems. At least Lua bitches about it -
202 PANIC: unprotected error in call to Lua API (bad light userdata pointer)
203 So we wrap the _Widget instead of the Evas_Object.
204 TODO - Might as well make _Widget a full userdata.
205 */
206 lua_pushlightuserdata(L, (void *) wid); 200 lua_pushlightuserdata(L, (void *) wid);
207 return 1; 201 return 1;
208 } 202 }
@@ -231,16 +225,22 @@ static int colour(lua_State *L)
231 return 0; 225 return 0;
232} 226}
233 227
228/* userdata vs light userdata
229 Lua wants to allocate the memory for userdata itself.
230 Light user data an actual pointer.
231*/
232
234static int window(lua_State *L) 233static int window(lua_State *L)
235{ 234{
235 winFang *win = NULL;
236 char *name = "GuiLua"; 236 char *name = "GuiLua";
237 char *title = "GuiLua test harness"; 237 char *title = "GuiLua test harness";
238 int w = WIDTH, h = HEIGHT; 238 int w = WIDTH, h = HEIGHT;
239 239
240 pull_lua(L, 1, "%w %h $title $name", &w, &h, &title, &name); 240 pull_lua(L, 1, "%w %h $title $name", &w, &h, &title, &name);
241 win = winFangAdd(NULL, 0, 0, w, h, title, name); 241 win = winFangAdd(NULL, 0, 0, w, h, title, name);
242 242 eina_clist_add_head(&winFangs, &win->node);
243 lua_pushlightuserdata(L, &win); 243 lua_pushlightuserdata(L, win);
244 244
245 return 1; 245 return 1;
246} 246}
@@ -254,8 +254,7 @@ static int clear(lua_State *L)
254 254
255static int loopWindow(lua_State *L) 255static int loopWindow(lua_State *L)
256{ 256{
257 if (win) 257 elm_run();
258 elm_run();
259 258
260 return 0; 259 return 0;
261} 260}
@@ -269,7 +268,12 @@ static int quit(lua_State *L)
269 268
270static int closeWindow(lua_State *L) 269static int closeWindow(lua_State *L)
271{ 270{
272 winFangDel(win); 271 winFang *win;
272
273 EINA_CLIST_FOR_EACH_ENTRY(win, &winFangs, winFang, node)
274 {
275 winFangDel(win);
276 }
273 277
274 if (logDom >= 0) 278 if (logDom >= 0)
275 { 279 {
@@ -310,6 +314,8 @@ int luaopen_GuiLua(lua_State *L)
310 elm_config_finger_size_set(0); 314 elm_config_finger_size_set(0);
311 elm_config_scale_set(1.0); 315 elm_config_scale_set(1.0);
312 316
317 eina_clist_init(&winFangs);
318
313// pseudo-indices, special tables that can be accessed like the stack - 319// pseudo-indices, special tables that can be accessed like the stack -
314// LUA_GLOBALSINDEX - thread environment, where globals are 320// LUA_GLOBALSINDEX - thread environment, where globals are
315// LUA_ENVIRONINDEX - C function environment, in this case luaopen_GuiLUa() is the C function 321// LUA_ENVIRONINDEX - C function environment, in this case luaopen_GuiLUa() is the C function
@@ -330,7 +336,11 @@ int luaopen_GuiLua(lua_State *L)
330//thingasm{'window', 'The size and title of the application Frame.', window, 'x,y,name', acl='GGG'} 336//thingasm{'window', 'The size and title of the application Frame.', window, 'x,y,name', acl='GGG'}
331 push_lua(L, "@ ( { = $ $ & $ $acl } )", skang, THINGASM, skang, "Cwindow", "Opens our window.", window, "number,number,string", "GGG", 0); 337 push_lua(L, "@ ( { = $ $ & $ $acl } )", skang, THINGASM, skang, "Cwindow", "Opens our window.", window, "number,number,string", "GGG", 0);
332 push_lua(L, "@ ( = $ $ & )", skang, THINGASM, skang, "clear", "The current skin is cleared of all widgets.", clear, 0); 338 push_lua(L, "@ ( = $ $ & )", skang, THINGASM, skang, "clear", "The current skin is cleared of all widgets.", clear, 0);
333 push_lua(L, "@ ( = $ $ & )", skang, THINGASM, skang, "widget", "Create a widget.", widget, 0); 339PD("GuiLua 2");
340// TODO - This one crashes sometimes. Figure out why later.
341// push_lua(L, "@ ( { = $ $ & $ } )", skang, THINGASM, skang, "widget", "Create a widget.", widget, "userdata,string,string,number,number,number,number");
342 push_lua(L, "@ ( = $ $ & )", skang, THINGASM, skang, "widget", "Create a widget.", widget, 0);
343PD("GuiLua 3");
334 push_lua(L, "@ ( = $ $ & )", skang, THINGASM, skang, "action", "Add an action to a widget.", action, 0); 344 push_lua(L, "@ ( = $ $ & )", skang, THINGASM, skang, "action", "Add an action to a widget.", action, 0);
335 push_lua(L, "@ ( = $ $ & )", skang, THINGASM, skang, "Colour", "Change widget colours.", colour, 0); 345 push_lua(L, "@ ( = $ $ & )", skang, THINGASM, skang, "Colour", "Change widget colours.", colour, 0);
336 push_lua(L, "@ ( = $ $ & )", skang, THINGASM, skang, "loopWindow", "Run our windows main loop.", loopWindow, 0); 346 push_lua(L, "@ ( = $ $ & )", skang, THINGASM, skang, "loopWindow", "Run our windows main loop.", loopWindow, 0);
@@ -344,7 +354,6 @@ int luaopen_GuiLua(lua_State *L)
344 return 1; 354 return 1;
345} 355}
346 356
347
348void GuiLuaDo(int argc, char **argv, Eina_Bool mainloop) 357void GuiLuaDo(int argc, char **argv, Eina_Bool mainloop)
349{ 358{
350 lua_State *L; 359 lua_State *L;