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/build.lua | 7 +- src/extantz/chat.c | 10 +-- src/extantz/extantz.c | 61 ++++++++++++++-- src/extantz/extantz.h | 39 +++------- src/extantz/fangWin.c | 196 -------------------------------------------------- src/extantz/files.c | 14 ++-- src/extantz/winFang.c | 154 +++++++++++++++++++++++++++++++++++++++ src/extantz/winFang.h | 32 +++++++++ src/extantz/woMan.c | 8 +-- 9 files changed, 272 insertions(+), 249 deletions(-) delete mode 100644 src/extantz/fangWin.c create mode 100644 src/extantz/winFang.c create mode 100644 src/extantz/winFang.h (limited to 'src') diff --git a/src/extantz/build.lua b/src/extantz/build.lua index 8a02b55..2b6d615 100755 --- a/src/extantz/build.lua +++ b/src/extantz/build.lua @@ -17,10 +17,13 @@ CFLAGS = CFLAGS .. ' -I../../libraries/irrlicht-1.8.1/include -I/usr/X11R6/inc LDFLAGS = LDFLAGS .. ' -L../../libraries/irrlicht-1.8.1/lib/Linux' libs = libs .. ' -lIrrlicht -lGL -lbz2' -removeFiles(dir, {'../../extantz', 'crappisspuke.o', 'CDemo.o', 'extantzCamera.o', 'gears.o', 'ephysics_demo.o', 'camera.o', 'Evas_3D_demo.o', 'fangWin.o', 'chat.o', 'files.o', 'woMan.o', '../../media/extantz.edj'}) +removeFiles(dir, {'crappisspuke.o', 'CDemo.o', 'extantzCamera.o', 'gears.o', 'ephysics_demo.o', 'Evas_3D_demo.o', '../../media/extantz.edj'}) +removeFiles(dir, {'../../extantz', 'camera.o', 'winFang.o', 'chat.o', 'files.o', 'woMan.o'}) runCommand('edje_cc', dir, 'edje_cc ' .. EDJE_FLAGS .. ' extantz.edc ../../media/extantz.edj') runCommand('Irrlicht files', dir, 'g++ ' .. CFLAGS .. ' -ffast-math -c crappisspuke.cpp -o crappisspuke.o ' .. LDFLAGS) runCommand(nil, dir, 'g++ ' .. CFLAGS .. ' -ffast-math -c CDemo.cpp -o CDemo.o ' .. LDFLAGS) runCommand(nil, dir, 'g++ ' .. CFLAGS .. ' -ffast-math -c extantzCamera.cpp -o extantzCamera.o ' .. LDFLAGS) -compileFiles('../../extantz', dir, {'gears', 'ephysics_demo', 'camera', 'Evas_3D_demo', 'fangWin', 'chat', 'files', 'woMan', 'extantz'}, 'crappisspuke.o CDemo.o extantzCamera.o') +runCommand('C libraries', dir, 'gcc ' .. CFLAGS .. ' -fPIC -c winFang.c') +runCommand(nil, dir, 'gcc ' .. CFLAGS .. ' -shared -Wl,-soname,libwinFang.so -o ' .. lib_d .. '/libwinFang.so winFang.o') +compileFiles('../../extantz', dir, {'gears', 'ephysics_demo', 'camera', 'Evas_3D_demo', 'chat', 'files', 'woMan', 'extantz'}, 'crappisspuke.o CDemo.o extantzCamera.o -lwinFang') diff --git a/src/extantz/chat.c b/src/extantz/chat.c index e814842..2155541 100644 --- a/src/extantz/chat.c +++ b/src/extantz/chat.c @@ -5,18 +5,18 @@ // The bug is that editable entry widgets cause the app to hang on exit. void _on_entry_del(void *data, Evas_Object *obj, void *event_info) { -// fangWin *me = data; +// winFang *me = data; elm_entry_editable_set(obj, EINA_FALSE); } -fangWin *chat_add(globals *ourGlobals) +winFang *chat_add(globals *ourGlobals) { - fangWin *me; + winFang *me; Widget *wid; Evas_Object *bx, *en; - me = fang_win_add(ourGlobals); + me = winFangAdd(ourGlobals); bx = eo_add(ELM_OBJ_BOX_CLASS, me->win, evas_obj_size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND), @@ -46,6 +46,6 @@ fangWin *chat_add(globals *ourGlobals) evas_object_show(bx); eo_unref(bx); - fang_win_complete(ourGlobals, me, 30, 500, ourGlobals->win_w / 3, ourGlobals->win_h / 3); + winFangComplete(ourGlobals, me, 30, 500, ourGlobals->win_w / 3, ourGlobals->win_h / 3); return me; } 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); } diff --git a/src/extantz/extantz.h b/src/extantz/extantz.h index a4001c7..046f099 100644 --- a/src/extantz/extantz.h +++ b/src/extantz/extantz.h @@ -10,6 +10,7 @@ #include #include #include "extantzCamera.h" +#include "winFang.h" #ifdef GL_GLES @@ -123,27 +124,7 @@ typedef struct short x, y, z; } ezLandmark; -typedef struct _fangWin -{ - Evas_Object *win; - Eina_Clist widgets; - void *data; - Evas_Smart_Cb on_del; -} fangWin; -typedef struct _Widget -{ - char magic[8]; - Evas_Object *obj; - Eina_Clist node; - char *label, *look, *action, *help; - // foreground / background colour - // thing - // types {} - // skangCoord x, y, w, h - void *data; - Evas_Smart_Cb on_del; -} Widget; typedef struct _Scene_Data { @@ -244,7 +225,7 @@ typedef struct _globals Eina_Clist windows; - fangWin *files; + winFang *files; } globals; extern globals ourGlobals; @@ -265,22 +246,18 @@ EAPI void drawIrr_end(globals *ourGlobals); EAPI void finishIrr(globals *ourGlobals); #endif +void overlay_add(globals *ourGlobals); + EAPI void Evas_3D_Demo_add(globals *ourGlobals); Eina_Bool _animate_scene(globals *ourGlobals); void Evas_3D_Demo_fini(globals *ourGlobals); void cameraAdd(globals *ourGlobals, Evas_Object *win); -fangWin *fang_win_add(globals *ourGlobals); -void fang_win_complete(globals *ourGlobals, fangWin *win, int x, int y, int w, int h); -void fang_win_del(globals *ourGlobals, fangWin *win); -void overlay_add(globals *ourGlobals); -Widget *widgetAdd(fangWin *win, const Eo_Class *klass, Evas_Object *parent, char *title); - -fangWin *chat_add(globals *ourGlobals); -fangWin *filesAdd(globals *ourGlobals, char *path, Eina_Bool multi, Eina_Bool save); -void filesShow(fangWin *me, Evas_Smart_Cb func, void *data); -fangWin *woMan_add(globals *ourGlobals); +winFang *chat_add(globals *ourGlobals); +winFang *filesAdd(globals *ourGlobals, char *path, Eina_Bool multi, Eina_Bool save); +void filesShow(winFang *me, Evas_Smart_Cb func, void *data); +winFang *woMan_add(globals *ourGlobals); #ifdef __cplusplus diff --git a/src/extantz/fangWin.c b/src/extantz/fangWin.c deleted file mode 100644 index 88a5c00..0000000 --- a/src/extantz/fangWin.c +++ /dev/null @@ -1,196 +0,0 @@ -#include "extantz.h" - - -// 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); -} - -static void cb_mouse_move(void *data, Evas *evas, Evas_Object *obj, void *event_info) -{ - Evas_Event_Mouse_Move *ev = event_info; - Evas_Object *orig = data; - Evas_Coord x, y; - Evas_Map *p; - int i, w, h; - - if (!ev->buttons) return; - evas_object_geometry_get(obj, &x, &y, NULL, NULL); - evas_object_move(obj, - x + (ev->cur.canvas.x - ev->prev.output.x), - y + (ev->cur.canvas.y - ev->prev.output.y)); - evas_object_image_size_get(orig, &w, &h); - p = evas_map_new(4); - evas_object_map_enable_set(orig, EINA_TRUE); -// evas_object_raise(orig); - for (i = 0; i < 4; i++) - { - Evas_Object *hand; - char key[32]; - - snprintf(key, sizeof(key), "h-%i\n", i); - hand = evas_object_data_get(orig, key); - evas_object_raise(hand); - evas_object_geometry_get(hand, &x, &y, NULL, NULL); - x += 15; - y += 15; - evas_map_point_coord_set(p, i, x, y, 0); - if (i == 0) evas_map_point_image_uv_set(p, i, 0, 0); - else if (i == 1) evas_map_point_image_uv_set(p, i, w, 0); - else if (i == 2) evas_map_point_image_uv_set(p, i, w, h); - else if (i == 3) evas_map_point_image_uv_set(p, i, 0, h); - } - evas_object_map_set(orig, p); - evas_map_free(p); -} - -static void create_handles(Evas_Object *obj) -{ - int i; - Evas_Coord x, y, w, h; - - evas_object_geometry_get(obj, &x, &y, &w, &h); - for (i = 0; i < 4; i++) - { - Evas_Object *hand; - char buf[PATH_MAX]; - char key[32]; - - hand = evas_object_image_filled_add(evas_object_evas_get(obj)); - evas_object_resize(hand, 31, 31); - snprintf(buf, sizeof(buf), "%s/pt.png", elm_app_data_dir_get()); - evas_object_image_file_set(hand, buf, NULL); - if (i == 0) evas_object_move(hand, x - 15, y - 15); - else if (i == 1) evas_object_move(hand, x + w - 15, y - 15); - else if (i == 2) evas_object_move(hand, x + w - 15, y + h - 15); - else if (i == 3) evas_object_move(hand, x - 15, y + h - 15); - evas_object_event_callback_add(hand, EVAS_CALLBACK_MOUSE_MOVE, cb_mouse_move, obj); - evas_object_show(hand); - snprintf(key, sizeof(key), "h-%i\n", i); - evas_object_data_set(obj, key, hand); - } -} - -fangWin *fang_win_add(globals *ourGlobals) -{ - fangWin *result; - Evas_Object *bg; - - result = calloc(1, sizeof(fangWin)); - eina_clist_init(&result->widgets); - - // In theory this should create an EWS window, in practice, I'm not seeing any difference. - // Guess I'll have to implement my own internal window manager. I don't think a basic one will be that hard. Famous last words. -// elm_config_engine_set("ews"); - result->win = 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(result->win), EVAS_CALLBACK_MOUSE_DOWN, _cb_mouse_down_elm, NULL); - elm_win_alpha_set(result->win, 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(result->win)); - evas_object_color_set(bg, 50, 0, 100, 100); - evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - elm_win_resize_object_add(result->win, bg); - evas_object_show(bg); - - return result; -} - -void fang_win_complete(globals *ourGlobals, fangWin *win, int x, int y, int w, int h) -{ - // 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(win->win), x, y); - // Odd, it needs to be resized twice. WTF? - evas_object_resize(win->win, w, h); - evas_object_resize(elm_win_inlined_image_object_get(win->win), w, h); - evas_object_show(win->win); - create_handles(elm_win_inlined_image_object_get(win->win)); -} - -void fang_win_del(globals *ourGlobals, fangWin *win) -{ - Widget *wid; - - if (!win) return; - - // Elm will delete our widgets, but if we are using eo, we need to unref them. - EINA_CLIST_FOR_EACH_ENTRY(wid, &win->widgets, Widget, node) - { - if (wid->on_del) wid->on_del(wid, wid->obj, NULL); - eo_unref(wid->obj); - } - if (win->on_del) win->on_del(win, win->win, NULL); - evas_object_del(win->win); -} - -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); -} - -Widget *widgetAdd(fangWin *win, const Eo_Class *klass, Evas_Object *parent, char *title) -{ - Widget *result; - - result = calloc(1, sizeof(Widget)); - strcpy(result->magic, "Widget"); - eina_clist_add_head(&win->widgets, &result->node); - - if (parent) - { - result->obj = eo_add(klass, parent, - evas_obj_size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND), - evas_obj_size_hint_align_set(EVAS_HINT_FILL, EVAS_HINT_FILL), - evas_obj_visibility_set(EINA_TRUE) - ); - if (title) elm_object_text_set(result->obj, title); - } - - return result; -} diff --git a/src/extantz/files.c b/src/extantz/files.c index 816894f..ff76dff 100644 --- a/src/extantz/files.c +++ b/src/extantz/files.c @@ -60,7 +60,7 @@ static void _big_icon_clicked(void *data, Evas_Object *obj EINA_UNUSED, void *ev static void my_fileselector_activated(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) { - fangWin *me = data; + winFang *me = data; Evas_Object *fs = me->data; if (elm_fileselector_multi_select_get(fs)) @@ -85,7 +85,7 @@ static void my_fileselector_activated(void *data, Evas_Object *obj EINA_UNUSED, static void _CANCEL_clicked(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) { - fangWin *me = data; + winFang *me = data; evas_object_hide(me->win); } @@ -140,13 +140,13 @@ void _on_fs_del(void *data, Evas_Object *obj, void *event_info) elm_entry_editable_set(obj, EINA_FALSE); } -fangWin *filesAdd(globals *ourGlobals, char *path, Eina_Bool multi, Eina_Bool save) +winFang *filesAdd(globals *ourGlobals, char *path, Eina_Bool multi, Eina_Bool save) { - fangWin *me; + winFang *me; Widget *wid; Evas_Object *bx, *vbox, *fs, *bt, *rd = NULL, *rdg = NULL, *hoversel; - me = fang_win_add(ourGlobals); + me = winFangAdd(ourGlobals); bx = eo_add(ELM_OBJ_BOX_CLASS, me->win, elm_obj_box_homogeneous_set(EINA_FALSE), @@ -277,12 +277,12 @@ fangWin *filesAdd(globals *ourGlobals, char *path, Eina_Bool multi, Eina_Bool sa eo_unref(vbox); eo_unref(bx); - fang_win_complete(ourGlobals, me, ourGlobals->win_w - 380, ourGlobals->win_w - 530, 350, 500); + winFangComplete(ourGlobals, me, ourGlobals->win_w - 380, ourGlobals->win_w - 530, 350, 500); evas_object_hide(me->win); return me; } -void filesShow(fangWin *me, Evas_Smart_Cb func, void *data) +void filesShow(winFang *me, Evas_Smart_Cb func, void *data) { Evas_Object *fs = me->data; diff --git a/src/extantz/winFang.c b/src/extantz/winFang.c new file mode 100644 index 0000000..0f0328f --- /dev/null +++ b/src/extantz/winFang.c @@ -0,0 +1,154 @@ +#include "extantz.h" + + +// 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); +} + +static void cb_mouse_move(void *data, Evas *evas, Evas_Object *obj, void *event_info) +{ + Evas_Event_Mouse_Move *ev = event_info; + Evas_Object *orig = data; + Evas_Coord x, y; + Evas_Map *p; + int i, w, h; + + if (!ev->buttons) return; + evas_object_geometry_get(obj, &x, &y, NULL, NULL); + evas_object_move(obj, + x + (ev->cur.canvas.x - ev->prev.output.x), + y + (ev->cur.canvas.y - ev->prev.output.y)); + evas_object_image_size_get(orig, &w, &h); + p = evas_map_new(4); + evas_object_map_enable_set(orig, EINA_TRUE); +// evas_object_raise(orig); + for (i = 0; i < 4; i++) + { + Evas_Object *hand; + char key[32]; + + snprintf(key, sizeof(key), "h-%i\n", i); + hand = evas_object_data_get(orig, key); + evas_object_raise(hand); + evas_object_geometry_get(hand, &x, &y, NULL, NULL); + x += 15; + y += 15; + evas_map_point_coord_set(p, i, x, y, 0); + if (i == 0) evas_map_point_image_uv_set(p, i, 0, 0); + else if (i == 1) evas_map_point_image_uv_set(p, i, w, 0); + else if (i == 2) evas_map_point_image_uv_set(p, i, w, h); + else if (i == 3) evas_map_point_image_uv_set(p, i, 0, h); + } + evas_object_map_set(orig, p); + evas_map_free(p); +} + +static void create_handles(Evas_Object *obj) +{ + int i; + Evas_Coord x, y, w, h; + + evas_object_geometry_get(obj, &x, &y, &w, &h); + for (i = 0; i < 4; i++) + { + Evas_Object *hand; + char buf[PATH_MAX]; + char key[32]; + + hand = evas_object_image_filled_add(evas_object_evas_get(obj)); + evas_object_resize(hand, 31, 31); + snprintf(buf, sizeof(buf), "%s/pt.png", elm_app_data_dir_get()); + evas_object_image_file_set(hand, buf, NULL); + if (i == 0) evas_object_move(hand, x - 15, y - 15); + else if (i == 1) evas_object_move(hand, x + w - 15, y - 15); + else if (i == 2) evas_object_move(hand, x + w - 15, y + h - 15); + else if (i == 3) evas_object_move(hand, x - 15, y + h - 15); + evas_object_event_callback_add(hand, EVAS_CALLBACK_MOUSE_MOVE, cb_mouse_move, obj); + evas_object_show(hand); + snprintf(key, sizeof(key), "h-%i\n", i); + evas_object_data_set(obj, key, hand); + } +} + +winFang *winFangAdd(globals *ourGlobals) +{ + winFang *result; + Evas_Object *bg; + + result = calloc(1, sizeof(winFang)); + eina_clist_init(&result->widgets); + + // In theory this should create an EWS window, in practice, I'm not seeing any difference. + // Guess I'll have to implement my own internal window manager. I don't think a basic one will be that hard. Famous last words. +// elm_config_engine_set("ews"); + result->win = 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(result->win), EVAS_CALLBACK_MOUSE_DOWN, _cb_mouse_down_elm, NULL); + elm_win_alpha_set(result->win, 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(result->win)); + evas_object_color_set(bg, 50, 0, 100, 100); + evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + elm_win_resize_object_add(result->win, bg); + evas_object_show(bg); + + return result; +} + +void winFangComplete(globals *ourGlobals, winFang *win, int x, int y, int w, int h) +{ + // 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(win->win), x, y); + // Odd, it needs to be resized twice. WTF? + evas_object_resize(win->win, w, h); + evas_object_resize(elm_win_inlined_image_object_get(win->win), w, h); + evas_object_show(win->win); + create_handles(elm_win_inlined_image_object_get(win->win)); +} + +void winFangDel(globals *ourGlobals, winFang *win) +{ + Widget *wid; + + if (!win) return; + + // Elm will delete our widgets, but if we are using eo, we need to unref them. + EINA_CLIST_FOR_EACH_ENTRY(wid, &win->widgets, Widget, node) + { + if (wid->on_del) wid->on_del(wid, wid->obj, NULL); + eo_unref(wid->obj); + } + if (win->on_del) win->on_del(win, win->win, NULL); + evas_object_del(win->win); +} + +Widget *widgetAdd(winFang *win, const Eo_Class *klass, Evas_Object *parent, char *title) +{ + Widget *result; + + result = calloc(1, sizeof(Widget)); + strcpy(result->magic, "Widget"); + eina_clist_add_head(&win->widgets, &result->node); + + if (parent) + { + result->obj = eo_add(klass, parent, + evas_obj_size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND), + evas_obj_size_hint_align_set(EVAS_HINT_FILL, EVAS_HINT_FILL), + evas_obj_visibility_set(EINA_TRUE) + ); + if (title) elm_object_text_set(result->obj, title); + } + + return result; +} diff --git a/src/extantz/winFang.h b/src/extantz/winFang.h new file mode 100644 index 0000000..8749be5 --- /dev/null +++ b/src/extantz/winFang.h @@ -0,0 +1,32 @@ +#include + + +// Forward references. +typedef struct _globals globals; + +typedef struct _winFang +{ + Evas_Object *win; + Eina_Clist widgets; + void *data; + Evas_Smart_Cb on_del; +} winFang; + +typedef struct _Widget +{ + char magic[8]; + Evas_Object *obj; + Eina_Clist node; + char *label, *look, *action, *help; + // foreground / background colour + // thing + // types {} + // skangCoord x, y, w, h + void *data; + Evas_Smart_Cb on_del; +} Widget; + +winFang *winFangAdd(globals *ourGlobals); +void winFangComplete(globals *ourGlobals, winFang *win, int x, int y, int w, int h); +void winFangDel(globals *ourGlobals, winFang *win); +Widget *widgetAdd(winFang *win, const Eo_Class *klass, Evas_Object *parent, char *title); diff --git a/src/extantz/woMan.c b/src/extantz/woMan.c index 0a3456b..fe2e3f2 100644 --- a/src/extantz/woMan.c +++ b/src/extantz/woMan.c @@ -151,15 +151,15 @@ static void _grid_sel_cb(void *data, Evas_Object *obj, void *event_info) } -fangWin *woMan_add(globals *ourGlobals) +winFang *woMan_add(globals *ourGlobals) { - fangWin *me; + winFang *me; Evas_Object *bx, *bt, *nf, *tab, *tb, *gridList, *viewerList, *menu; Elm_Object_Item *tb_it, *menu_it, *tab_it; char buf[PATH_MAX]; int i; - me = fang_win_add(ourGlobals); + me = winFangAdd(ourGlobals); bx = elm_box_add(me->win); elm_win_resize_object_add(me->win, bx); @@ -286,6 +286,6 @@ fangWin *woMan_add(globals *ourGlobals) eo_unref(bt); evas_object_show(bx); - fang_win_complete(ourGlobals, me, 30, 30, ourGlobals->win_w / 3, ourGlobals->win_h / 3); + winFangComplete(ourGlobals, me, 30, 30, ourGlobals->win_w / 3, ourGlobals->win_h / 3); return me; } -- cgit v1.1