diff options
Diffstat (limited to 'src/GuiLua')
-rw-r--r-- | src/GuiLua/GuiLua.c | 71 | ||||
-rw-r--r-- | src/GuiLua/GuiLua.h | 5 | ||||
-rwxr-xr-x | src/GuiLua/build.lua | 7 |
3 files changed, 14 insertions, 69 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) -> __ | |||
156 | win.quitter.colour.r = 5 -> direct access to the table, well "direct" via Thing and Mum. We eventually want to call skang.colour() though. | 156 | win.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 | ||
159 | struct _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) | |||
250 | static int action(lua_State *L) | 232 | static 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) |
diff --git a/src/GuiLua/GuiLua.h b/src/GuiLua/GuiLua.h index ee669ce..82415c9 100644 --- a/src/GuiLua/GuiLua.h +++ b/src/GuiLua/GuiLua.h | |||
@@ -1,6 +1,7 @@ | |||
1 | #include "SledjHamr.h" | 1 | #include "SledjHamr.h" |
2 | #include "LumbrJack.h" | 2 | #include "LumbrJack.h" |
3 | #include "Runnr.h" | 3 | #include "Runnr.h" |
4 | #include "winFang.h" | ||
4 | 5 | ||
5 | 6 | ||
6 | #define WIDTH (300) | 7 | #define WIDTH (300) |
@@ -14,9 +15,7 @@ | |||
14 | 15 | ||
15 | typedef struct _globals | 16 | typedef struct _globals |
16 | { | 17 | { |
17 | Evas *evas; | 18 | winFang *win; |
18 | Evas_Object *win; // Our Elm window. | ||
19 | Eina_Clist widgets; // Our windows widgets. | ||
20 | int logDom; // Our logging domain. | 19 | int logDom; // Our logging domain. |
21 | } globals; | 20 | } globals; |
22 | 21 | ||
diff --git a/src/GuiLua/build.lua b/src/GuiLua/build.lua index 169e198..8b4a1c8 100755 --- a/src/GuiLua/build.lua +++ b/src/GuiLua/build.lua | |||
@@ -18,6 +18,7 @@ LDFLAGS = '-L ' .. dir .. ' ' .. LDFLAGS | |||
18 | removeFiles(dir, {'test_c.so', 'GuiLua.o', lib_d .. '/libGuiLua.so', '../../skang'}) | 18 | removeFiles(dir, {'test_c.so', 'GuiLua.o', lib_d .. '/libGuiLua.so', '../../skang'}) |
19 | 19 | ||
20 | runCommand('C modules', dir, 'gcc ' .. CFLAGS .. ' -fPIC -shared -o test_c.so test_c.c') | 20 | runCommand('C modules', dir, 'gcc ' .. CFLAGS .. ' -fPIC -shared -o test_c.so test_c.c') |
21 | runCommand(nil, dir, 'gcc ' .. CFLAGS .. ' -fPIC -c GuiLua.c') | 21 | |
22 | runCommand('C libraries', dir, 'gcc ' .. CFLAGS .. ' -shared -Wl,-soname,libGuiLua.so -o ' .. lib_d .. '/libGuiLua.so GuiLua.o') | 22 | runCommand('C libraries', dir, 'gcc ' .. CFLAGS .. ' -fPIC -c GuiLua.c') |
23 | runCommand('C apps', dir, 'gcc ' .. CFLAGS .. ' -Wl,-export-dynamic -o ../../skang skang.c ' .. LDFLAGS .. ' -lGuiLua ' .. libs) | 23 | runCommand(nil, dir, 'gcc ' .. CFLAGS .. ' -shared -Wl,-soname,libGuiLua.so -o ' .. lib_d .. '/libGuiLua.so GuiLua.o') |
24 | runCommand('C apps', dir, 'gcc ' .. CFLAGS .. ' -Wl,-export-dynamic -o ../../skang skang.c ' .. LDFLAGS .. ' -lGuiLua -lwinFang ' .. libs) | ||