From d5d869e9ec2c54db9e3ff25c518d0b57ee362c1e Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Mon, 5 May 2014 00:55:37 +1000 Subject: fangWin -> winFang and related changes. --- src/extantz/extantz.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 57 insertions(+), 4 deletions(-) (limited to 'src/extantz/extantz.c') diff --git a/src/extantz/extantz.c b/src/extantz/extantz.c index ef493b8..679a47e 100644 --- a/src/extantz/extantz.c +++ b/src/extantz/extantz.c @@ -328,12 +328,65 @@ static void makeMainMenu(globals *ourGlobals) evas_object_show(tb); } +// Elm inlined image windows needs this to change focus on mouse click. +// Evas style event callback. +static void _cb_mouse_down_elm(void *data, Evas *evas, Evas_Object *obj, void *event_info) +{ + Evas_Event_Mouse_Down *ev = event_info; + + if (1 == ev->button) + elm_object_focus_set(obj, EINA_TRUE); +} + +void overlay_add(globals *ourGlobals) +{ + GLData *gld = &ourGlobals->gld; + Evas_Object *bg; + + // There are many reasons for this window. + // The first is to cover the GL and provide something to click on to change focus. + // The second is to provide something to click on for all the GL type clicking stuff that needs to be done. In other words, no click through, we catch the clicks here. + // So we can probably avoid the following issue - + // How to do click through? evas_object_pass_events_set(rectangle, EINA_TRUE), and maybe need to do that to the underlaying window to? + // Though if the rectangle is entirely transparent, or even hidden, events might pass through anyway. + // Gotta have click through on the parts where there's no other window. + // The third is to have the other windows live here. + // This idea doesn't work, as it breaks the damn focus again. + // Don't think it's needed anyway. + // While on the subject of layers, need a HUD layer of some sort, but Irrlicht might support that itself. + + gld->winwin = elm_win_add(ourGlobals->win, "inlined", ELM_WIN_INLINED_IMAGE); + // 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. + // According to the Elm inlined image window example, this is what's needed to. + evas_object_event_callback_add(elm_win_inlined_image_object_get(gld->winwin), EVAS_CALLBACK_MOUSE_DOWN, _cb_mouse_down_elm, NULL); + // In this code, we are making our own camera, so grab it's input when we are focused. + cameraAdd(ourGlobals, gld->winwin); + + elm_win_alpha_set(gld->winwin, EINA_TRUE); + // Apparently transparent is not good enough for ELM backgrounds, so make it a rectangle. + // Apparently coz ELM prefers stuff to have edjes. A bit over the top if all I want is a transparent rectangle. + bg = evas_object_rectangle_add(evas_object_evas_get(gld->winwin)); + evas_object_color_set(bg, 0, 0, 0, 0); + evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + elm_win_resize_object_add(gld->winwin, bg); + evas_object_show(bg); + + // image object for win is unlinked to its pos/size - so manual control + // this allows also for using map and other things with it. + evas_object_move(elm_win_inlined_image_object_get(gld->winwin), 0, 0); + // Odd, it needs to be resized twice. WTF? + evas_object_resize(gld->winwin, ourGlobals->win_w, ourGlobals->win_h); + evas_object_resize(elm_win_inlined_image_object_get(gld->winwin), ourGlobals->win_w, ourGlobals->win_h); + evas_object_show(gld->winwin); +} + + EAPI_MAIN int elm_main(int argc, char **argv) { Evas_Object *obj; EPhysics_World *world; GLData *gld = NULL; - fangWin *chat = NULL, *woMan = NULL; + winFang *chat = NULL, *woMan = NULL; char buf[PATH_MAX]; // Eina_Bool gotWebKit = elm_need_web(); // Initialise ewebkit if it exists, or return EINA_FALSE if it don't. @@ -452,9 +505,9 @@ EAPI_MAIN int elm_main(int argc, char **argv) { Evas_3D_Demo_fini(&ourGlobals); eo_unref(ourGlobals.tb); - fang_win_del(&ourGlobals, ourGlobals.files); - fang_win_del(&ourGlobals, chat); - fang_win_del(&ourGlobals, woMan); + winFangDel(&ourGlobals, ourGlobals.files); + winFangDel(&ourGlobals, chat); + winFangDel(&ourGlobals, woMan); eo_unref(ourGlobals.bx); evas_object_del(ourGlobals.win); } -- cgit v1.1