aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/GuiLua/GuiLua.c
diff options
context:
space:
mode:
authorDavid Walter Seikel2014-05-05 05:42:54 +1000
committerDavid Walter Seikel2014-05-05 05:42:54 +1000
commit579b3b0afdff09433a2153a254b1d66abdb906ee (patch)
treefdfbee6eec1defe0f0ff5e8089552d317ee58fd7 /src/GuiLua/GuiLua.c
parentMerge inline and external window creation. (diff)
downloadSledjHamr-579b3b0afdff09433a2153a254b1d66abdb906ee.zip
SledjHamr-579b3b0afdff09433a2153a254b1d66abdb906ee.tar.gz
SledjHamr-579b3b0afdff09433a2153a254b1d66abdb906ee.tar.bz2
SledjHamr-579b3b0afdff09433a2153a254b1d66abdb906ee.tar.xz
Move winFang to libraries, and convert GuiLua to use it.
Diffstat (limited to 'src/GuiLua/GuiLua.c')
-rw-r--r--src/GuiLua/GuiLua.c71
1 files changed, 8 insertions, 63 deletions
diff --git a/src/GuiLua/GuiLua.c b/src/GuiLua/GuiLua.c
index 34c747f..21c9bdf 100644
--- a/src/GuiLua/GuiLua.c
+++ b/src/GuiLua/GuiLua.c
@@ -156,18 +156,6 @@ win.quitter:colour(1,2,3,4) -> win.quitter.colour(win.quitter, 1,2,3,4) -> __
156win.quitter.colour.r = 5 -> direct access to the table, well "direct" via Thing and Mum. We eventually want to call skang.colour() though. 156win.quitter.colour.r = 5 -> direct access to the table, well "direct" via Thing and Mum. We eventually want to call skang.colour() though.
157*/ 157*/
158 158
159struct _Widget
160{
161 char magic[8];
162 Evas_Object *obj;
163 Eina_Clist node;
164 char *label, *look, *action, *help;
165 // foreground / background colour
166 // thing
167 // types {}
168 // skangCoord x, y, w, h
169};
170
171 159
172// TODO - These functions should be able to deal with multiple windows. 160// TODO - These functions should be able to deal with multiple windows.
173// TODO - Should be able to open external and internal windows, and even switch between them on the fly. 161// TODO - Should be able to open external and internal windows, and even switch between them on the fly.
@@ -175,7 +163,7 @@ static void _on_click(void *data, Evas_Object *obj, void *event_info EINA_UNUSED
175{ 163{
176 globals *ourGlobals; 164 globals *ourGlobals;
177 lua_State *L = data; 165 lua_State *L = data;
178 struct _Widget *wid; 166 Widget *wid;
179 167
180 lua_getfield(L, LUA_REGISTRYINDEX, globName); 168 lua_getfield(L, LUA_REGISTRYINDEX, globName);
181 ourGlobals = lua_touserdata(L, -1); 169 ourGlobals = lua_touserdata(L, -1);
@@ -215,18 +203,12 @@ static int widget(lua_State *L)
215 // TODO - The alternative is to just lookup the ELM_*_CLASS in a hash table? 203 // TODO - The alternative is to just lookup the ELM_*_CLASS in a hash table?
216 if (strcmp(type, "button") == 0) 204 if (strcmp(type, "button") == 0)
217 { 205 {
218 struct _Widget *wid; 206 Widget *wid;
219
220 wid = calloc(1, sizeof(struct _Widget));
221 strcpy(wid->magic, "Widget");
222 eina_clist_add_head(&ourGlobals->widgets, &wid->node);
223 wid->label = strdup(title);
224 207
225 // These two lines are likely the only ones that will be different for the different sorts of widgets. 208 // These two lines are likely the only ones that will be different for the different sorts of widgets.
226 wid->obj = eo_add(ELM_OBJ_BUTTON_CLASS, ourGlobals->win); 209 wid = widgetAdd(ourGlobals->win, ELM_OBJ_BUTTON_CLASS, ourGlobals->win->win, title);
227 evas_object_smart_callback_add(wid->obj, "clicked", _on_click, L); 210 evas_object_smart_callback_add(wid->obj, "clicked", _on_click, L);
228 211
229 elm_object_part_text_set(wid->obj, NULL, wid->label);
230 eo_do(wid->obj, 212 eo_do(wid->obj,
231// elm_obj_widget_part_text_set(NULL, wid->label), 213// elm_obj_widget_part_text_set(NULL, wid->label),
232 evas_obj_size_set(w, h), 214 evas_obj_size_set(w, h),
@@ -250,7 +232,7 @@ static int widget(lua_State *L)
250static int action(lua_State *L) 232static int action(lua_State *L)
251{ 233{
252 globals *ourGlobals; 234 globals *ourGlobals;
253 struct _Widget *wid = lua_touserdata(L, 1); 235 Widget *wid = lua_touserdata(L, 1);
254 char *action = "nada"; 236 char *action = "nada";
255 237
256 lua_getfield(L, LUA_REGISTRYINDEX, globName); 238 lua_getfield(L, LUA_REGISTRYINDEX, globName);
@@ -278,7 +260,6 @@ static int window(lua_State *L)
278 globals *ourGlobals; 260 globals *ourGlobals;
279 char *name = "GuiLua"; 261 char *name = "GuiLua";
280 char *title = "GuiLua test harness"; 262 char *title = "GuiLua test harness";
281 Evas_Object *obj;
282 int result = 0; 263 int result = 0;
283 int w = WIDTH, h = HEIGHT; 264 int w = WIDTH, h = HEIGHT;
284 265
@@ -287,38 +268,9 @@ static int window(lua_State *L)
287 lua_pop(L, 1); 268 lua_pop(L, 1);
288 269
289 pull_lua(L, 1, "%w %h $title $name", &w, &h, &title, &name); 270 pull_lua(L, 1, "%w %h $title $name", &w, &h, &title, &name);
290 271 ourGlobals->win = winFangAdd(NULL, 0, 0, w, h, title, name);
291 // Set the engine to opengl_x11, then open the window. 272 lua_pushlightuserdata(L, &ourGlobals->win);
292 elm_config_preferred_engine_set("opengl_x11"); 273 result = 1;
293 if ((ourGlobals->win = elm_win_util_standard_add(name, title)))
294 {
295 eina_clist_init(&ourGlobals->widgets);
296
297 evas_object_smart_callback_add(ourGlobals->win, "delete,request", _on_done, ourGlobals);
298 evas_object_resize(ourGlobals->win, w, h);
299 evas_object_move(ourGlobals->win, 0, 0);
300 evas_object_show(ourGlobals->win);
301
302 // Get the Evas / canvas from the elm window (that the Evas_Object "lives on"), which is itself an Evas_Object created by Elm, so not sure if it was created internally with Ecore_Evas.
303 ourGlobals->evas = evas_object_evas_get(ourGlobals->win);
304
305 // Add a background image object.
306 obj = eo_add(ELM_OBJ_IMAGE_CLASS, ourGlobals->win);
307 eo_do(obj,
308 evas_obj_size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND),
309 elm_obj_image_fill_outside_set(EINA_TRUE),
310 elm_obj_image_file_set("../../media/sky_01.jpg", NULL),
311 evas_obj_visibility_set(EINA_TRUE)
312 );
313 elm_win_resize_object_add(ourGlobals->win, obj);
314 eo_unref(obj);
315
316 lua_pushlightuserdata(L, &ourGlobals->win);
317 result = 1;
318 }
319
320 // Set preferred engine back to default from config
321 elm_config_preferred_engine_set(NULL);
322 274
323 return result; 275 return result;
324} 276}
@@ -367,14 +319,7 @@ static int closeWindow(lua_State *L)
367 319
368 if (ourGlobals->win) 320 if (ourGlobals->win)
369 { 321 {
370 struct _Widget *wid; 322 winFangDel(ourGlobals->win);
371
372 // Elm will delete our widgets, but if we are using eo, we need to unref them.
373 EINA_CLIST_FOR_EACH_ENTRY(wid, &ourGlobals->widgets, struct _Widget, node)
374 {
375 eo_unref(wid->obj);
376 }
377 evas_object_del(ourGlobals->win);
378 } 323 }
379 324
380 if (ourGlobals->logDom >= 0) 325 if (ourGlobals->logDom >= 0)