diff options
author | David Walter Seikel | 2014-05-06 16:53:17 +1000 |
---|---|---|
committer | David Walter Seikel | 2014-05-06 16:53:17 +1000 |
commit | 20f851e6e2ceed52739ffcad85e10fa4c183bff1 (patch) | |
tree | dff97aa7a2b694e27e8c32ae58489e375805bade | |
parent | Disable the non working Elm input callback, and TODO++. (diff) | |
download | SledjHamr-20f851e6e2ceed52739ffcad85e10fa4c183bff1.zip SledjHamr-20f851e6e2ceed52739ffcad85e10fa4c183bff1.tar.gz SledjHamr-20f851e6e2ceed52739ffcad85e10fa4c183bff1.tar.bz2 SledjHamr-20f851e6e2ceed52739ffcad85e10fa4c183bff1.tar.xz |
Every window is a winFang now, and winFangs delete their own children.
-rw-r--r-- | src/GuiLua/GuiLua.c | 19 | ||||
-rw-r--r-- | src/GuiLua/GuiLua.h | 4 | ||||
-rw-r--r-- | src/extantz/chat.c | 3 | ||||
-rw-r--r-- | src/extantz/extantz.c | 24 | ||||
-rw-r--r-- | src/extantz/extantz.h | 3 | ||||
-rw-r--r-- | src/extantz/files.c | 3 | ||||
-rw-r--r-- | src/extantz/woMan.c | 3 | ||||
-rw-r--r-- | src/libraries/winFang.c | 16 | ||||
-rw-r--r-- | src/libraries/winFang.h | 3 |
9 files changed, 38 insertions, 40 deletions
diff --git a/src/GuiLua/GuiLua.c b/src/GuiLua/GuiLua.c index 7463abb..3ff8f94 100644 --- a/src/GuiLua/GuiLua.c +++ b/src/GuiLua/GuiLua.c | |||
@@ -232,7 +232,7 @@ static int colour(lua_State *L) | |||
232 | static int window(lua_State *L) | 232 | static int window(lua_State *L) |
233 | { | 233 | { |
234 | winFang *win = NULL; | 234 | winFang *win = NULL; |
235 | Evas_Object *parent = NULL; | 235 | winFang *parent = 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; |
@@ -246,7 +246,12 @@ static int window(lua_State *L) | |||
246 | if (gl && gl->parent) parent = gl->parent; | 246 | if (gl && gl->parent) parent = gl->parent; |
247 | 247 | ||
248 | win = winFangAdd(parent, 25, 25, w, h, title, name); | 248 | win = winFangAdd(parent, 25, 25, w, h, title, name); |
249 | eina_clist_add_head(&gl->winFangs, &win->node); | 249 | // If there's no parent, we become the parent. |
250 | if (gl && !parent) | ||
251 | { | ||
252 | gl->parent = win; | ||
253 | eina_clist_add_head(&gl->winFangs, &win->node); | ||
254 | } | ||
250 | lua_pushlightuserdata(L, win); | 255 | lua_pushlightuserdata(L, win); |
251 | 256 | ||
252 | return 1; | 257 | return 1; |
@@ -282,10 +287,12 @@ static int closeWindow(lua_State *L) | |||
282 | gl = lua_touserdata(L, -1); | 287 | gl = lua_touserdata(L, -1); |
283 | lua_pop(L, 1); | 288 | lua_pop(L, 1); |
284 | 289 | ||
285 | 290 | if (gl) | |
286 | EINA_CLIST_FOR_EACH_ENTRY(win, &gl->winFangs, winFang, node) | ||
287 | { | 291 | { |
288 | winFangDel(win); | 292 | EINA_CLIST_FOR_EACH_ENTRY(win, &gl->winFangs, winFang, node) |
293 | { | ||
294 | winFangDel(win); | ||
295 | } | ||
289 | } | 296 | } |
290 | 297 | ||
291 | return 0; | 298 | return 0; |
@@ -357,7 +364,7 @@ PD("GuiLua 3"); | |||
357 | return 1; | 364 | return 1; |
358 | } | 365 | } |
359 | 366 | ||
360 | GuiLua *GuiLuaDo(int argc, char **argv, Evas_Object *parent) | 367 | GuiLua *GuiLuaDo(int argc, char **argv, winFang *parent) |
361 | { | 368 | { |
362 | GuiLua *result; | 369 | GuiLua *result; |
363 | lua_State *L; | 370 | lua_State *L; |
diff --git a/src/GuiLua/GuiLua.h b/src/GuiLua/GuiLua.h index 3548a44..d390000 100644 --- a/src/GuiLua/GuiLua.h +++ b/src/GuiLua/GuiLua.h | |||
@@ -18,7 +18,7 @@ | |||
18 | typedef struct _GuiLua | 18 | typedef struct _GuiLua |
19 | { | 19 | { |
20 | lua_State *L; | 20 | lua_State *L; |
21 | Evas_Object *parent; // Our parent window, if it exists. | 21 | winFang *parent; // Our parent window, if it exists. |
22 | Eina_Clist winFangs; // The windows we might open. | 22 | Eina_Clist winFangs; // The windows we might open. |
23 | 23 | ||
24 | Eina_Clist node; | 24 | Eina_Clist node; |
@@ -26,6 +26,6 @@ typedef struct _GuiLua | |||
26 | Evas_Smart_Cb on_del; | 26 | Evas_Smart_Cb on_del; |
27 | } GuiLua; | 27 | } GuiLua; |
28 | 28 | ||
29 | GuiLua *GuiLuaDo(int argc, char **argv, Evas_Object *parent); | 29 | GuiLua *GuiLuaDo(int argc, char **argv, winFang *parent); |
30 | 30 | ||
31 | #endif | 31 | #endif |
diff --git a/src/extantz/chat.c b/src/extantz/chat.c index d060cb1..4c18e53 100644 --- a/src/extantz/chat.c +++ b/src/extantz/chat.c | |||
@@ -16,8 +16,7 @@ winFang *chat_add(globals *ourGlobals) | |||
16 | Widget *wid; | 16 | Widget *wid; |
17 | Evas_Object *bx, *en; | 17 | Evas_Object *bx, *en; |
18 | 18 | ||
19 | me = winFangAdd(ourGlobals->win, 30, 520, ourGlobals->win_w / 3, ourGlobals->win_h / 3, "chatter box", "chat"); | 19 | me = winFangAdd(ourGlobals->mainWindow, 30, 520, ourGlobals->win_w / 3, ourGlobals->win_h / 3, "chatter box", "chat"); |
20 | eina_clist_add_head(&ourGlobals->winFangs, &me->node); | ||
21 | 20 | ||
22 | bx = eo_add(ELM_OBJ_BOX_CLASS, me->win, | 21 | bx = eo_add(ELM_OBJ_BOX_CLASS, me->win, |
23 | evas_obj_size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND), | 22 | evas_obj_size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND), |
diff --git a/src/extantz/extantz.c b/src/extantz/extantz.c index b7de3a7..aceebe7 100644 --- a/src/extantz/extantz.c +++ b/src/extantz/extantz.c | |||
@@ -140,8 +140,6 @@ static void _on_open(void *data, Evas_Object *obj EINA_UNUSED, void *event_info | |||
140 | 140 | ||
141 | static void _on_done(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) | 141 | static void _on_done(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) |
142 | { | 142 | { |
143 | // GLData *gld = data; | ||
144 | |||
145 | elm_exit(); | 143 | elm_exit(); |
146 | } | 144 | } |
147 | 145 | ||
@@ -420,13 +418,14 @@ EAPI_MAIN int elm_main(int argc, char **argv) | |||
420 | elm_config_finger_size_set(0); | 418 | elm_config_finger_size_set(0); |
421 | elm_config_scale_set(1.0); | 419 | elm_config_scale_set(1.0); |
422 | 420 | ||
423 | eina_clist_init(&ourGlobals.winFangs); | ||
424 | gld = &ourGlobals.gld; | 421 | gld = &ourGlobals.gld; |
425 | gldata_init(gld); | 422 | gldata_init(gld); |
426 | 423 | ||
427 | // Set the engine to opengl_x11, then open our window. | 424 | // Set the engine to opengl_x11, then open our window. |
428 | elm_config_preferred_engine_set("opengl_x11"); | 425 | elm_config_preferred_engine_set("opengl_x11"); |
429 | ourGlobals.win = elm_win_util_standard_add("extantz", "extantz virtual world viewer"); | 426 | |
427 | ourGlobals.mainWindow = winFangAdd(NULL, 0, 0, 50, 20, "extantz virtual world viewer", "extantz"); | ||
428 | ourGlobals.win = ourGlobals.mainWindow->win; | ||
430 | // Set preferred engine back to default from config | 429 | // Set preferred engine back to default from config |
431 | elm_config_preferred_engine_set(NULL); | 430 | elm_config_preferred_engine_set(NULL); |
432 | 431 | ||
@@ -444,7 +443,6 @@ EAPI_MAIN int elm_main(int argc, char **argv) | |||
444 | return 1; | 443 | return 1; |
445 | #endif | 444 | #endif |
446 | 445 | ||
447 | evas_object_smart_callback_add(ourGlobals.win, "delete,request", _on_done, gld); | ||
448 | evas_object_event_callback_add(ourGlobals.win, EVAS_CALLBACK_RESIZE, _on_resize, &ourGlobals); | 446 | evas_object_event_callback_add(ourGlobals.win, EVAS_CALLBACK_RESIZE, _on_resize, &ourGlobals); |
449 | 447 | ||
450 | // Get the screen size. | 448 | // Get the screen size. |
@@ -476,7 +474,7 @@ EAPI_MAIN int elm_main(int argc, char **argv) | |||
476 | chat_add(&ourGlobals); | 474 | chat_add(&ourGlobals); |
477 | ourGlobals.files = filesAdd(&ourGlobals, (char *) elm_app_data_dir_get(), EINA_TRUE, EINA_FALSE); | 475 | ourGlobals.files = filesAdd(&ourGlobals, (char *) elm_app_data_dir_get(), EINA_TRUE, EINA_FALSE); |
478 | char *args[] = {"extantz", "-l", "test", "-foo", "COMBINED!", NULL}; | 476 | char *args[] = {"extantz", "-l", "test", "-foo", "COMBINED!", NULL}; |
479 | GuiLua *test = GuiLuaDo(5, args, ourGlobals.win); | 477 | GuiLua *test = GuiLuaDo(5, args, ourGlobals.mainWindow); |
480 | 478 | ||
481 | // Gotta do this after adding the windows, otherwise the menu renders under the window. | 479 | // Gotta do this after adding the windows, otherwise the menu renders under the window. |
482 | // This sucks, gotta redefine this menu each time we create a new window? | 480 | // This sucks, gotta redefine this menu each time we create a new window? |
@@ -511,22 +509,10 @@ EAPI_MAIN int elm_main(int argc, char **argv) | |||
511 | 509 | ||
512 | if (ourGlobals.win) | 510 | if (ourGlobals.win) |
513 | { | 511 | { |
514 | winFang *win; | ||
515 | |||
516 | Evas_3D_Demo_fini(&ourGlobals); | 512 | Evas_3D_Demo_fini(&ourGlobals); |
517 | eo_unref(ourGlobals.tb); | 513 | eo_unref(ourGlobals.tb); |
518 | |||
519 | EINA_CLIST_FOR_EACH_ENTRY(win, &test->winFangs, winFang, node) | ||
520 | { | ||
521 | winFangDel(win); | ||
522 | } | ||
523 | |||
524 | EINA_CLIST_FOR_EACH_ENTRY(win, &ourGlobals.winFangs, winFang, node) | ||
525 | { | ||
526 | winFangDel(win); | ||
527 | } | ||
528 | eo_unref(ourGlobals.bx); | 514 | eo_unref(ourGlobals.bx); |
529 | evas_object_del(ourGlobals.win); | 515 | winFangDel(ourGlobals.mainWindow); |
530 | } | 516 | } |
531 | 517 | ||
532 | if (logDom >= 0) | 518 | if (logDom >= 0) |
diff --git a/src/extantz/extantz.h b/src/extantz/extantz.h index aab5de5..502420b 100644 --- a/src/extantz/extantz.h +++ b/src/extantz/extantz.h | |||
@@ -216,6 +216,7 @@ typedef struct _globals | |||
216 | Evas_Object *bx; // Our box. | 216 | Evas_Object *bx; // Our box. |
217 | int logDom; // Our logging domain. | 217 | int logDom; // Our logging domain. |
218 | 218 | ||
219 | winFang *mainWindow; | ||
219 | int scr_w, scr_h; // The size of the screen. | 220 | int scr_w, scr_h; // The size of the screen. |
220 | int win_w, win_h; // The size of the window. | 221 | int win_w, win_h; // The size of the window. |
221 | int win_x, win_y; // The position of the window. | 222 | int win_x, win_y; // The position of the window. |
@@ -225,8 +226,6 @@ typedef struct _globals | |||
225 | GLData gld; | 226 | GLData gld; |
226 | Scene_Data *scene; | 227 | Scene_Data *scene; |
227 | 228 | ||
228 | Eina_Clist winFangs; | ||
229 | |||
230 | winFang *files; | 229 | winFang *files; |
231 | } globals; | 230 | } globals; |
232 | 231 | ||
diff --git a/src/extantz/files.c b/src/extantz/files.c index 357769e..948c261 100644 --- a/src/extantz/files.c +++ b/src/extantz/files.c | |||
@@ -146,8 +146,7 @@ winFang *filesAdd(globals *ourGlobals, char *path, Eina_Bool multi, Eina_Bool sa | |||
146 | Widget *wid; | 146 | Widget *wid; |
147 | Evas_Object *bx, *vbox, *fs, *bt, *rd = NULL, *rdg = NULL, *hoversel; | 147 | Evas_Object *bx, *vbox, *fs, *bt, *rd = NULL, *rdg = NULL, *hoversel; |
148 | 148 | ||
149 | me = winFangAdd(ourGlobals->win, ourGlobals->win_w - 380, ourGlobals->win_w - 530, 350, 500, "file selector", "files"); | 149 | me = winFangAdd(ourGlobals->mainWindow, ourGlobals->win_w - 380, ourGlobals->win_w - 530, 350, 500, "file selector", "files"); |
150 | eina_clist_add_head(&ourGlobals->winFangs, &me->node); | ||
151 | 150 | ||
152 | bx = eo_add(ELM_OBJ_BOX_CLASS, me->win, | 151 | bx = eo_add(ELM_OBJ_BOX_CLASS, me->win, |
153 | elm_obj_box_homogeneous_set(EINA_FALSE), | 152 | elm_obj_box_homogeneous_set(EINA_FALSE), |
diff --git a/src/extantz/woMan.c b/src/extantz/woMan.c index ee0cc02..8215253 100644 --- a/src/extantz/woMan.c +++ b/src/extantz/woMan.c | |||
@@ -159,8 +159,7 @@ winFang *woMan_add(globals *ourGlobals) | |||
159 | char buf[PATH_MAX]; | 159 | char buf[PATH_MAX]; |
160 | int i; | 160 | int i; |
161 | 161 | ||
162 | me = winFangAdd(ourGlobals->win, 30, 150, ourGlobals->win_w / 3, ourGlobals->win_h / 3, "virtual world manager", "woMan"); | 162 | me = winFangAdd(ourGlobals->mainWindow, 30, 150, ourGlobals->win_w / 3, ourGlobals->win_h / 3, "virtual world manager", "woMan"); |
163 | eina_clist_add_head(&ourGlobals->winFangs, &me->node); | ||
164 | 163 | ||
165 | bx = elm_box_add(me->win); | 164 | bx = elm_box_add(me->win); |
166 | elm_win_resize_object_add(me->win, bx); | 165 | elm_win_resize_object_add(me->win, bx); |
diff --git a/src/libraries/winFang.c b/src/libraries/winFang.c index 4d54627..33d5ea6 100644 --- a/src/libraries/winFang.c +++ b/src/libraries/winFang.c | |||
@@ -72,7 +72,7 @@ void winFangShow(winFang *win) | |||
72 | evas_object_show(win->hand[i]); | 72 | evas_object_show(win->hand[i]); |
73 | } | 73 | } |
74 | 74 | ||
75 | winFang *winFangAdd(Evas_Object *parent, int x, int y, int w, int h, char *title, char *name) | 75 | winFang *winFangAdd(winFang *parent, int x, int y, int w, int h, char *title, char *name) |
76 | { | 76 | { |
77 | winFang *result; | 77 | winFang *result; |
78 | Evas_Object *obj, *obj2, *bg; | 78 | Evas_Object *obj, *obj2, *bg; |
@@ -81,6 +81,7 @@ winFang *winFangAdd(Evas_Object *parent, int x, int y, int w, int h, char *title | |||
81 | 81 | ||
82 | result = calloc(1, sizeof(winFang)); | 82 | result = calloc(1, sizeof(winFang)); |
83 | eina_clist_init(&result->widgets); | 83 | eina_clist_init(&result->widgets); |
84 | eina_clist_init(&result->winFangs); | ||
84 | 85 | ||
85 | if (parent) result->internal = EINA_TRUE; | 86 | if (parent) result->internal = EINA_TRUE; |
86 | 87 | ||
@@ -94,7 +95,8 @@ winFang *winFangAdd(Evas_Object *parent, int x, int y, int w, int h, char *title | |||
94 | // elm_config_engine_set("ews"); | 95 | // elm_config_engine_set("ews"); |
95 | if (result->internal) | 96 | if (result->internal) |
96 | { | 97 | { |
97 | result->win = elm_win_add(parent, name, ELM_WIN_INLINED_IMAGE); | 98 | result->win = elm_win_add(parent->win, name, ELM_WIN_INLINED_IMAGE); |
99 | eina_clist_add_head(&parent->winFangs, &result->node); | ||
98 | obj = elm_win_inlined_image_object_get(result->win); | 100 | obj = elm_win_inlined_image_object_get(result->win); |
99 | // On mouse down we try to shift focus to the backing image, this seems to be the correct thing to force focus onto it's widgets. | 101 | // On mouse down we try to shift focus to the backing image, this seems to be the correct thing to force focus onto it's widgets. |
100 | // According to the Elm inlined image window example, this is what's needed to. | 102 | // According to the Elm inlined image window example, this is what's needed to. |
@@ -144,7 +146,7 @@ winFang *winFangAdd(Evas_Object *parent, int x, int y, int w, int h, char *title | |||
144 | } | 146 | } |
145 | else | 147 | else |
146 | { | 148 | { |
147 | result->win = elm_win_add(parent, name, ELM_WIN_BASIC); | 149 | result->win = elm_win_add(NULL, name, ELM_WIN_BASIC); |
148 | evas_object_move(result->win, result->x, result->y); | 150 | evas_object_move(result->win, result->x, result->y); |
149 | evas_object_smart_callback_add(result->win, "delete,request", _on_done, NULL); | 151 | evas_object_smart_callback_add(result->win, "delete,request", _on_done, NULL); |
150 | } | 152 | } |
@@ -168,10 +170,16 @@ winFang *winFangAdd(Evas_Object *parent, int x, int y, int w, int h, char *title | |||
168 | 170 | ||
169 | void winFangDel(winFang *win) | 171 | void winFangDel(winFang *win) |
170 | { | 172 | { |
171 | Widget *wid; | 173 | winFang *wf; |
174 | Widget *wid; | ||
172 | 175 | ||
173 | if (!win) return; | 176 | if (!win) return; |
174 | 177 | ||
178 | EINA_CLIST_FOR_EACH_ENTRY(wf, &win->winFangs, winFang, node) | ||
179 | { | ||
180 | winFangDel(wf); | ||
181 | } | ||
182 | |||
175 | // Elm will delete our widgets, but if we are using eo, we need to unref them. | 183 | // Elm will delete our widgets, but if we are using eo, we need to unref them. |
176 | EINA_CLIST_FOR_EACH_ENTRY(wid, &win->widgets, Widget, node) | 184 | EINA_CLIST_FOR_EACH_ENTRY(wid, &win->widgets, Widget, node) |
177 | { | 185 | { |
diff --git a/src/libraries/winFang.h b/src/libraries/winFang.h index 38487cc..f3c4861 100644 --- a/src/libraries/winFang.h +++ b/src/libraries/winFang.h | |||
@@ -19,6 +19,7 @@ typedef struct _winFang | |||
19 | { | 19 | { |
20 | Evas_Object *win; | 20 | Evas_Object *win; |
21 | Eina_Clist widgets; | 21 | Eina_Clist widgets; |
22 | Eina_Clist winFangs; | ||
22 | int x, y, w, h; | 23 | int x, y, w, h; |
23 | Eina_Bool internal; | 24 | Eina_Bool internal; |
24 | 25 | ||
@@ -45,7 +46,7 @@ typedef struct _Widget | |||
45 | Evas_Smart_Cb on_del; | 46 | Evas_Smart_Cb on_del; |
46 | } Widget; | 47 | } Widget; |
47 | 48 | ||
48 | winFang *winFangAdd(Evas_Object *parent, int x, int y, int w, int h, char *title, char *name); | 49 | winFang *winFangAdd(winFang *parent, int x, int y, int w, int h, char *title, char *name); |
49 | void winFangHide(winFang *win); | 50 | void winFangHide(winFang *win); |
50 | void winFangShow(winFang *win); | 51 | void winFangShow(winFang *win); |
51 | void winFangDel(winFang *win); | 52 | void winFangDel(winFang *win); |