From 160c161b57595fdae637936c50a162d193f1a982 Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Sat, 3 May 2014 23:40:48 +1000 Subject: More shuffling of gld -> ourGlobals and related cleanups. --- src/extantz/Evas_3D_demo.c | 7 ++---- src/extantz/chat.c | 11 +++++----- src/extantz/crappisspuke.cpp | 14 +++++++----- src/extantz/extantz.c | 24 +++++++++++++++------ src/extantz/extantz.h | 51 ++++++++++++++++++++++---------------------- src/extantz/fangWin.c | 8 +++---- src/extantz/woMan.c | 16 +++++++------- 7 files changed, 69 insertions(+), 62 deletions(-) (limited to 'src/extantz') diff --git a/src/extantz/Evas_3D_demo.c b/src/extantz/Evas_3D_demo.c index b01dd47..95b2f2f 100644 --- a/src/extantz/Evas_3D_demo.c +++ b/src/extantz/Evas_3D_demo.c @@ -266,9 +266,8 @@ _sphere_init(int precision) } -Eina_Bool _animate_scene(void *data) +Eina_Bool _animate_scene(globals *ourGlobals) { - globals *ourGlobals = data; static float angle = 0.0f; static float earthAngle = 0.0f; static int frame = 0; @@ -703,12 +702,10 @@ void Evas_3D_Demo_add(globals *ourGlobals) // Elm can't seem to be able to tell us WHERE an image was clicked, so use raw Evas calbacks instead. evas_object_event_callback_add(temp, EVAS_CALLBACK_MOUSE_MOVE, _on_mouse_move, &ourScene); evas_object_event_callback_add(temp, EVAS_CALLBACK_MOUSE_DOWN, _on_mouse_down, &ourScene); - cameraAdd(obj, &ourGlobals->gld); + cameraAdd(ourGlobals, obj); elm_win_resize_object_add(ourGlobals->win, obj); // elm_box_pack_end(ourGlobals->gld.bx, obj); - // Add animation timer callback. -// ecore_timer_add(0.016, _animate_scene, &ourScene); ourGlobals->gld.move = calloc(1, sizeof(cameraMove)); } diff --git a/src/extantz/chat.c b/src/extantz/chat.c index 12f4d20..4ad5033 100644 --- a/src/extantz/chat.c +++ b/src/extantz/chat.c @@ -1,6 +1,5 @@ #include "extantz.h" - void chat_add(globals *ourGlobals) { Evas_Object *win, *bx, *en; @@ -8,10 +7,10 @@ void chat_add(globals *ourGlobals) win = fang_win_add(ourGlobals); bx = eo_add(ELM_OBJ_BOX_CLASS, win); - eo_do(bx, + eo_do(bx, evas_obj_size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND), evas_obj_size_hint_align_set(EVAS_HINT_FILL, EVAS_HINT_FILL) - ); + ); elm_win_resize_object_add(win, bx); en = eo_add(ELM_OBJ_ENTRY_CLASS, win); @@ -22,7 +21,7 @@ void chat_add(globals *ourGlobals) 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) - ); + ); elm_box_pack_end(bx, en); eo_unref(en); @@ -31,12 +30,12 @@ void chat_add(globals *ourGlobals) eo_do(en, elm_obj_entry_scrollable_set(EINA_TRUE), // TODO - Setting editable to TRUE is what hangs up extantz on exit. -// elm_obj_entry_editable_set(EINA_TRUE), +// elm_obj_entry_editable_set(EINA_TRUE), elm_obj_entry_editable_set(EINA_FALSE), 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) - ); + ); elm_box_pack_end(bx, en); eo_unref(en); diff --git a/src/extantz/crappisspuke.cpp b/src/extantz/crappisspuke.cpp index 04cebca..fca6f35 100644 --- a/src/extantz/crappisspuke.cpp +++ b/src/extantz/crappisspuke.cpp @@ -18,8 +18,9 @@ u32 then; extern "C" { #endif -EAPI int startIrr(GLData *gld) +EAPI int startIrr(globals *ourGlobals) { + GLData *gld = &ourGlobals->gld; SIrrlichtCreationParameters params; #if USE_IRR IrrlichtDevice *device; @@ -92,7 +93,7 @@ etc. of course. */ - sfc = ecore_evas_window_get(gld->ee); + sfc = ecore_evas_window_get(ourGlobals->ee); // This is the way Raster wants me to do things, but these functions are not actually available. Pffft // ctx = gl->glGetCurrentContext(); // display = gl->glGetCurrentDisplay(); @@ -229,8 +230,9 @@ etc. of course. return 1; } -EAPI void drawIrr_start(GLData *gld) +EAPI void drawIrr_start(globals *ourGlobals) { + GLData *gld = &ourGlobals->gld; if (gld->useIrr) { IrrlichtDevice *device = gld->device; @@ -267,16 +269,18 @@ EAPI void drawIrr_start(GLData *gld) } } -EAPI void drawIrr_end(GLData *gld) +EAPI void drawIrr_end(globals *ourGlobals) { + GLData *gld = &ourGlobals->gld; IVideoDriver *driver = gld->driver; if (gld->useIrr) driver->endScene(); } -EAPI void finishIrr(GLData *gld) +EAPI void finishIrr(globals *ourGlobals) { + GLData *gld = &ourGlobals->gld; IrrlichtDevice *device = gld->device; /* diff --git a/src/extantz/extantz.c b/src/extantz/extantz.c index d1fdf50..ace5150 100644 --- a/src/extantz/extantz.c +++ b/src/extantz/extantz.c @@ -89,7 +89,6 @@ static void _on_resize(void *data, Evas *evas, Evas_Object *obj, void *event_inf static void _clean_gl(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) { globals *ourGlobals = data; - GLData *gld = &ourGlobals->gld; ecore_animator_del(ourGlobals->animator); @@ -97,7 +96,9 @@ static void _clean_gl(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNU // evas_gl_make_current(NULL, NULL, NULL); // TODO - Since this is created on the render thread, better hope this is being deleted on the render thread. - finishIrr(gld); +#if USE_IRR + finishIrr(ourGlobals); +#endif #if DO_GEARS Evas_GL_API *gl = gld->glApi; @@ -141,14 +142,19 @@ static void _draw_gl(Evas_Object *obj) GLData *gld = &ourGlobals->gld; if (!ourGlobals) return; - if (!gld->doneIrr) gld->doneIrr = startIrr(gld); // Needs to be after gld->win is shown, and needs to be done in the render thread. +#if USE_IRR + if (!gld->doneIrr) gld->doneIrr = startIrr(ourGlobals); // Needs to be after gld->win is shown, and needs to be done in the render thread. +#endif + #if DO_GEARS if (!gld->gearsInited) gears_init(gld); #endif // if (gld->resized) _resize(gld); - drawIrr_start(gld); +#if USE_IRR + drawIrr_start(ourGlobals); +#endif #if DO_GEARS drawGears(gld); @@ -156,7 +162,9 @@ static void _draw_gl(Evas_Object *obj) _animate_scene(ourGlobals); - drawIrr_end(gld); +#if USE_IRR + drawIrr_end(ourGlobals); +#endif #if USE_IRR #else @@ -349,12 +357,14 @@ EAPI_MAIN int elm_main(int argc, char **argv) // Set preferred engine back to default from config elm_config_preferred_engine_set(NULL); - // TODO, or not TODO - I keep getting rid of these, but keep bringing them back. Leave ee commented for now. + // TODO, or not TODO - I keep getting rid of these, but keep bringing them back. // 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. ourGlobals.evas = evas_object_evas_get(ourGlobals.win); // An Ecore_Evas holds an Evas. // Get the Ecore_Evas that wraps an Evas. - //ourGlobals.ee = ecore_evas_ecore_evas_get(ourGlobals.evas); // Only use this on Evas that was created with Ecore_Evas. +#if USE_IRR + ourGlobals.ee = ecore_evas_ecore_evas_get(ourGlobals.evas); // Only use this on Evas that was created with Ecore_Evas. +#endif #if USE_PHYSICS if (!ephysics_init()) diff --git a/src/extantz/extantz.h b/src/extantz/extantz.h index fab6708..3c671bb 100644 --- a/src/extantz/extantz.h +++ b/src/extantz/extantz.h @@ -1,6 +1,6 @@ #define USE_PHYSICS 1 #define USE_IRR 0 -#define USE_DEMO 1 +#define USE_DEMO 0 #define DO_GEARS 0 @@ -57,9 +57,14 @@ typedef struct ICameraSceneNode ICameraSceneNode; #endif - -typedef struct _Gear Gear; -typedef struct _GLData GLData; +#if DO_GEARS +typedef struct _Gear +{ + GLfloat *vertices; + GLuint vbo; + int count; +} Gear; +#endif typedef enum { @@ -98,7 +103,6 @@ typedef struct ezPlatform platform; ezViewer *viewer; Elm_Object_Item *item; -GLData *gld; // Just a temporary evil hack to pass gld to _grid_sel_cb(). } ezGrid; typedef struct @@ -120,16 +124,6 @@ typedef struct } ezLandmark; - -struct _Gear -{ - GLfloat *vertices; - GLuint vbo; - int count; -}; - - - typedef struct _Scene_Data { Evas_Object *image; // Our Elm image. @@ -162,7 +156,7 @@ typedef struct _Scene_Data } Scene_Data; // Elm GL view related data here. -struct _GLData +typedef struct _GLData { Evas_Object *winwin; Evas_Object *elmGl; @@ -204,11 +198,13 @@ struct _GLData GLfloat proj[16]; GLfloat light[3]; #endif -}; +} GLData; typedef struct _globals { -// Ecore_Evas *ee; +#if USE_IRR + Ecore_Evas *ee; +#endif Evas *evas; Evas_Object *win; // Our Elm window. Evas_Object *tb; // Our Elm toolbar. @@ -222,29 +218,33 @@ typedef struct _globals Ecore_Animator *animator; - struct _GLData gld; + GLData gld; Scene_Data *scene; } globals; extern globals ourGlobals; +#if DO_GEARS void gears_init(GLData *gld); void drawGears(GLData *gld); void free_gear(Gear *gear); +#endif EPhysics_World *ephysicsAdd(globals *ourGlobals); -EAPI int startIrr(GLData *gld); -EAPI void drawIrr_start(GLData *gld); -EAPI void drawIrr_end(GLData *gld); -EAPI void finishIrr(GLData *gld); +#if USE_IRR +EAPI int startIrr(globals *ourGlobals); +EAPI void drawIrr_start(globals *ourGlobals); +EAPI void drawIrr_end(globals *ourGlobals); +EAPI void finishIrr(globals *ourGlobals); +#endif EAPI void Evas_3D_Demo_add(globals *ourGlobals); -Eina_Bool _animate_scene(void *data); +Eina_Bool _animate_scene(globals *ourGlobals); void Evas_3D_Demo_fini(globals *ourGlobals); -void cameraAdd(Evas_Object *win, GLData *gld); +void cameraAdd(globals *ourGlobals, Evas_Object *win); Evas_Object *fang_win_add(globals *ourGlobals); void fang_win_complete(globals *ourGlobals, Evas_Object *win, int x, int y, int w, int h); @@ -257,4 +257,3 @@ void woMan_add(globals *ourGlobals); #ifdef __cplusplus } #endif - diff --git a/src/extantz/fangWin.c b/src/extantz/fangWin.c index c7ec145..e95910c 100644 --- a/src/extantz/fangWin.c +++ b/src/extantz/fangWin.c @@ -6,7 +6,6 @@ // Evas style event callback. static void _cb_mouse_down_elm(void *data, Evas *evas, Evas_Object *obj, void *event_info) { -// GLData *gld = data; Evas_Event_Mouse_Down *ev = event_info; if (1 == ev->button) @@ -80,7 +79,6 @@ static void create_handles(Evas_Object *obj) Evas_Object *fang_win_add(globals *ourGlobals) { - GLData *gld = &ourGlobals->gld; Evas_Object *win, *bg; // In theory this should create an EWS window, in practice, I'm not seeing any difference. @@ -89,7 +87,7 @@ Evas_Object *fang_win_add(globals *ourGlobals) 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(win), EVAS_CALLBACK_MOUSE_DOWN, _cb_mouse_down_elm, gld); + evas_object_event_callback_add(elm_win_inlined_image_object_get(win), EVAS_CALLBACK_MOUSE_DOWN, _cb_mouse_down_elm, NULL); elm_win_alpha_set(win, EINA_TRUE); // Apparently transparent is not good enough for ELM backgrounds, so make it a rectangle. @@ -135,9 +133,9 @@ void overlay_add(globals *ourGlobals) 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, gld); + 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(gld->winwin, gld); + 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. diff --git a/src/extantz/woMan.c b/src/extantz/woMan.c index bef449c..2a1cfc8 100644 --- a/src/extantz/woMan.c +++ b/src/extantz/woMan.c @@ -139,13 +139,13 @@ static Evas_Object *_viewer_content_get(void *data, Evas_Object *obj, const char static void _grid_sel_cb(void *data, Evas_Object *obj, void *event_info) { -// ezGrid *thisGrid = data; -// GLData *gld = thisGrid->gld; -// char buf[PATH_MAX]; + globals *ourGlobals = evas_object_data_get(obj, "glob"); + ezGrid *thisGrid = data; + char buf[PATH_MAX]; -// sprintf(buf, "dillo -f -g '%dx%d+%d+%d' %s &", gld->win_w - (gld->win_w / 5), gld->win_h - 30, gld->win_w / 5, gld->win_y, thisGrid->splashPage); -// sprintf(buf, "uzbl -g '%dx%d+%d+%d' -u %s &", gld->win_w - (gld->win_w / 5), gld->win_h - 30, gld->win_w / 5, gld->win_y, thisGrid->splashPage); -// printf("%s ### genlist obj [%p], item pointer [%p]\n", buf, obj, event_info); +// sprintf(buf, "dillo -f -g '%dx%d+%d+%d' %s &", gld->win_w - (ourGlobals->win_w / 5), ourGlobals->win_h - 30, ourGlobals->win_w / 5, ourGlobals->win_y, thisGrid->splashPage); + sprintf(buf, "uzbl -g '%dx%d+%d+%d' -u %s &", ourGlobals->win_w - (ourGlobals->win_w / 5), ourGlobals->win_h - 30, ourGlobals->win_w / 5, ourGlobals->win_y, thisGrid->splashPage); + printf("%s ### genlist obj [%p], item pointer [%p]\n", buf, obj, event_info); // comment this out for now, busy dealing with input stuff, don't want to trigger this multiple times. // system(buf); } @@ -153,7 +153,6 @@ static void _grid_sel_cb(void *data, Evas_Object *obj, void *event_info) void woMan_add(globals *ourGlobals) { - GLData *gld = &ourGlobals->gld; // Evas_Object *win, *bg, *bx, *ic, *bb, *av, *en, *bt, *nf, *tab, *tb, *gridList, *viewerList, *menu; Evas_Object *win, *bx, *bt, *nf, *tab, *tb, *gridList, *viewerList, *menu; Elm_Object_Item *tb_it, *menu_it, *tab_it; @@ -195,6 +194,7 @@ void woMan_add(globals *ourGlobals) gridList = elm_genlist_add(win); grids = eina_hash_stringshared_new(free); + evas_object_data_set(gridList, "glob", ourGlobals); grid_gic = elm_genlist_item_class_new(); grid_gic->item_style = "double_label"; @@ -214,7 +214,7 @@ void woMan_add(globals *ourGlobals) thisGrid->loginURI = gridTest[i][1]; thisGrid->splashPage = gridTest[i][2]; thisGrid->icon = "folder"; - thisGrid->gld = gld; +// thisGrid->gld = gld; thisGrid->item = elm_genlist_item_append(gridList, grid_gic, thisGrid, NULL, ELM_GENLIST_ITEM_TREE, _grid_sel_cb, thisGrid); eina_hash_add(grids, thisGrid->name, thisGrid); } -- cgit v1.1