aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/extantz/extantz.c91
1 files changed, 56 insertions, 35 deletions
diff --git a/src/extantz/extantz.c b/src/extantz/extantz.c
index 027a8eb..cf2d7b0 100644
--- a/src/extantz/extantz.c
+++ b/src/extantz/extantz.c
@@ -78,13 +78,17 @@ static void _resize_gl(Evas_Object *obj)
78 _resize(gld); 78 _resize(gld);
79} 79}
80 80
81static void _on_resize(void *data, Evas *evas, Evas_Object *obj, void *event_info) 81static void _on_resize(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
82{ 82{
83 globals *ourGlobals = data; 83 globals *ourGlobals = data;
84 GLData *gld = &ourGlobals->gld; 84 GLData *gld = &ourGlobals->gld;
85 Evas_Coord h;
85 86
86 eo_do(ourGlobals->win, evas_obj_size_get(&ourGlobals->win_w, &ourGlobals->win_h)); 87 eo_do(ourGlobals->win, evas_obj_size_get(&ourGlobals->win_w, &ourGlobals->win_h));
87 eo_do(ourGlobals->tb, evas_obj_size_set(ourGlobals->win_w, 25)); 88 eo_do(ourGlobals->tb,
89 evas_obj_size_hint_min_get(NULL, &h),
90 evas_obj_size_set(ourGlobals->win_w, h)
91 );
88 _resize(gld); 92 _resize(gld);
89} 93}
90 94
@@ -258,20 +262,38 @@ static void init_evas_gl(globals *ourGlobals)
258 262
259//-------------------------// 263//-------------------------//
260 264
261 265static void _on_menu_focus(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
262static Evas_Object *_toolbar_menu_add(Evas_Object *win, Evas_Object *tb, char *label)
263{ 266{
264 Evas_Object *menu= NULL; 267 evas_object_raise(obj);
265 Elm_Object_Item *tb_it; 268}
266
267 tb_it = elm_toolbar_item_append(tb, NULL, label, NULL, NULL);
268 elm_toolbar_item_menu_set(tb_it, EINA_TRUE);
269 // Priority is for when toolbar items are set to hide or menu when there are too many of them. They get hidden or put on the menu based on priority.
270 elm_toolbar_item_priority_set(tb_it, 9999);
271 elm_toolbar_menu_parent_set(tb, win);
272 menu = elm_toolbar_item_menu_get(tb_it);
273 269
274 return menu; 270static Evas_Object *_menuAdd(Evas_Object *win, Evas_Object *tb, char *label)
271{
272 Evas_Object *menu= NULL;
273 Elm_Object_Item *tb_it;
274
275 // Evas_Object * obj, const char *icon, const char *label, Evas_Smart_Cb func, const void *data
276 // The function is called when the item is clicked.
277 tb_it = elm_toolbar_item_append(tb, NULL, label, NULL, NULL);
278 // Mark it as a menu.
279 elm_toolbar_item_menu_set(tb_it, EINA_TRUE);
280 // This alledgedly marks it as a menu (not true), and gets an Evas_Object for us to play with.
281 menu = elm_toolbar_item_menu_get(tb_it);
282 // Alas this does not work. B-(
283 evas_object_smart_callback_add(menu, "focused", _on_menu_focus, NULL);
284
285 // Priority is for when toolbar items are set to hide or menu when there are too many of them. They get hidden or put on the menu based on priority.
286 elm_toolbar_item_priority_set(tb_it, 9999);
287
288 // The docs for this functien are meaningless, but it wont work right if you leave it out.
289 elm_toolbar_menu_parent_set(tb, win);
290
291 // Add a seperator after, so that there's some visual distinction between menu items.
292 // Coz using all lower case and with no underline on the first letter, it's hard to tell.
293 tb_it = elm_toolbar_item_append(tb, NULL, NULL, NULL, NULL);
294 elm_toolbar_item_separator_set(tb_it, EINA_TRUE);
295
296 return menu;
275} 297}
276 298
277static void makeMainMenu(globals *ourGlobals) 299static void makeMainMenu(globals *ourGlobals)
@@ -285,25 +307,25 @@ static void makeMainMenu(globals *ourGlobals)
285 evas_obj_size_hint_weight_set(EVAS_HINT_EXPAND, 0.0), 307 evas_obj_size_hint_weight_set(EVAS_HINT_EXPAND, 0.0),
286 evas_obj_size_hint_align_set(EVAS_HINT_FILL, EVAS_HINT_FILL), 308 evas_obj_size_hint_align_set(EVAS_HINT_FILL, EVAS_HINT_FILL),
287 elm_obj_toolbar_shrink_mode_set(ELM_TOOLBAR_SHRINK_MENU), 309 elm_obj_toolbar_shrink_mode_set(ELM_TOOLBAR_SHRINK_MENU),
288 evas_obj_size_set(ourGlobals->win_w, 25),
289 evas_obj_position_set(0, 0), 310 evas_obj_position_set(0, 0),
290 elm_obj_toolbar_align_set(0.0) 311 elm_obj_toolbar_align_set(0.0)
291 ); 312 );
292 ourGlobals->tb = tb; 313 ourGlobals->tb = tb;
293 314
294 // Menus. 315 // Menus.
295 menu = _toolbar_menu_add(ourGlobals->win, tb, "file"); 316 menu = _menuAdd(ourGlobals->win, tb, "file");
317 // Evas_Object *obj, Elm_Object_Item *parent, const char *icon, const char *label, Evas_Smart_Cb func, const void *data
296 elm_menu_item_add(menu, NULL, NULL, "open", _on_open, ourGlobals); 318 elm_menu_item_add(menu, NULL, NULL, "open", _on_open, ourGlobals);
297 elm_menu_item_add(menu, NULL, NULL, "quit", _on_done, gld); 319 elm_menu_item_add(menu, NULL, NULL, "quit", _on_done, gld);
298 320
299 menu = _toolbar_menu_add(ourGlobals->win, tb, "edit"); 321 menu = _menuAdd(ourGlobals->win, tb, "edit");
300 elm_menu_item_add(menu, NULL, NULL, "preferences", NULL, NULL); 322 elm_menu_item_add(menu, NULL, NULL, "preferences", NULL, NULL);
301 323
302 menu = _toolbar_menu_add(ourGlobals->win, tb, "view"); 324 menu = _menuAdd(ourGlobals->win, tb, "view");
303 menu = _toolbar_menu_add(ourGlobals->win, tb, "world"); 325 menu = _menuAdd(ourGlobals->win, tb, "world");
304 menu = _toolbar_menu_add(ourGlobals->win, tb, "tools"); 326 menu = _menuAdd(ourGlobals->win, tb, "tools");
305 327
306 menu = _toolbar_menu_add(ourGlobals->win, tb, "help"); 328 menu = _menuAdd(ourGlobals->win, tb, "help");
307 elm_menu_item_add(menu, NULL, NULL, "grid help", NULL, NULL); 329 elm_menu_item_add(menu, NULL, NULL, "grid help", NULL, NULL);
308 elm_menu_item_separator_add(menu, NULL); 330 elm_menu_item_separator_add(menu, NULL);
309 elm_menu_item_add(menu, NULL, NULL, "extantz blogs", NULL, NULL); 331 elm_menu_item_add(menu, NULL, NULL, "extantz blogs", NULL, NULL);
@@ -311,20 +333,16 @@ static void makeMainMenu(globals *ourGlobals)
311 elm_menu_item_separator_add(menu, NULL); 333 elm_menu_item_separator_add(menu, NULL);
312 elm_menu_item_add(menu, NULL, NULL, "about extantz", NULL, NULL); 334 elm_menu_item_add(menu, NULL, NULL, "about extantz", NULL, NULL);
313 335
314 menu = _toolbar_menu_add(ourGlobals->win, tb, "advanced"); 336 menu = _menuAdd(ourGlobals->win, tb, "advanced");
315 elm_menu_item_add(menu, NULL, NULL, "debug settings", NULL, NULL); 337 elm_menu_item_add(menu, NULL, NULL, "debug settings", NULL, NULL);
316 338
317 menu = _toolbar_menu_add(ourGlobals->win, tb, "god"); 339 menu = _menuAdd(ourGlobals->win, tb, "god");
318 340
319 // Other stuff in the toolbar. 341 // Other stuff in the toolbar.
320 tb_it = elm_toolbar_item_append(tb, NULL, NULL, NULL, NULL);
321 elm_toolbar_item_separator_set(tb_it, EINA_TRUE);
322 tb_it = elm_toolbar_item_append(tb, NULL, "restriction icons", NULL, NULL); 342 tb_it = elm_toolbar_item_append(tb, NULL, "restriction icons", NULL, NULL);
323 tb_it = elm_toolbar_item_append(tb, NULL, NULL, NULL, NULL); 343 tb_it = elm_toolbar_item_append(tb, NULL, NULL, NULL, NULL); elm_toolbar_item_separator_set(tb_it, EINA_TRUE);
324 elm_toolbar_item_separator_set(tb_it, EINA_TRUE);
325 tb_it = elm_toolbar_item_append(tb, NULL, "hop://localhost/Anarchadia 152, 155, 51 - Lost plot (Adult)", NULL, NULL); 344 tb_it = elm_toolbar_item_append(tb, NULL, "hop://localhost/Anarchadia 152, 155, 51 - Lost plot (Adult)", NULL, NULL);
326 tb_it = elm_toolbar_item_append(tb, NULL, NULL, NULL, NULL); 345 tb_it = elm_toolbar_item_append(tb, NULL, NULL, NULL, NULL); elm_toolbar_item_separator_set(tb_it, EINA_TRUE);
327 elm_toolbar_item_separator_set(tb_it, EINA_TRUE);
328 tb_it = elm_toolbar_item_append(tb, NULL, "date time:o'clock", NULL, NULL); 346 tb_it = elm_toolbar_item_append(tb, NULL, "date time:o'clock", NULL, NULL);
329 347
330 evas_object_show(tb); 348 evas_object_show(tb);
@@ -491,6 +509,11 @@ EAPI_MAIN int elm_main(int argc, char **argv)
491 evas_object_data_set(elm_image_object_get(ourGlobals.scene->image), "glob", &ourGlobals); 509 evas_object_data_set(elm_image_object_get(ourGlobals.scene->image), "glob", &ourGlobals);
492 evas_object_image_pixels_get_callback_set(elm_image_object_get(ourGlobals.scene->image), on_pixels, &ourGlobals); 510 evas_object_image_pixels_get_callback_set(elm_image_object_get(ourGlobals.scene->image), on_pixels, &ourGlobals);
493 511
512 // Gotta do this after adding the windows, otherwise the menu renders under the window.
513 // This sucks, gotta redefine this menu each time we create a new window?
514 // Also, GL focus gets lost when any menu is used. sigh
515 makeMainMenu(&ourGlobals);
516
494// overlay_add(&ourGlobals); 517// overlay_add(&ourGlobals);
495 woMan_add(&ourGlobals); 518 woMan_add(&ourGlobals);
496 chat_add(&ourGlobals); 519 chat_add(&ourGlobals);
@@ -498,17 +521,15 @@ EAPI_MAIN int elm_main(int argc, char **argv)
498 char *args[] = {"extantz", "-l", "test", "-foo", "COMBINED!", NULL}; 521 char *args[] = {"extantz", "-l", "test", "-foo", "COMBINED!", NULL};
499 GuiLuaDo(5, args, ourGlobals.mainWindow); 522 GuiLuaDo(5, args, ourGlobals.mainWindow);
500 523
501 // Gotta do this after adding the windows, otherwise the menu renders under the window.
502 // This sucks, gotta redefine this menu each time we create a new window?
503 // Also, GL focus gets lost when any menu is used. sigh
504 makeMainMenu(&ourGlobals);
505
506#if USE_PHYSICS 524#if USE_PHYSICS
507 world = ephysicsAdd(&ourGlobals); 525 world = ephysicsAdd(&ourGlobals);
508#endif 526#endif
509 527
528 // Bump the top toolbar above the windows.
529 evas_object_raise(ourGlobals.tb);
530
510 evas_object_show(ourGlobals.mainWindow->box); 531 evas_object_show(ourGlobals.mainWindow->box);
511 _resize_winwin(gld); 532 _on_resize(&ourGlobals, NULL, NULL, NULL);
512 533
513 elm_run(); 534 elm_run();
514 535