From 3c0fb329ecc4a719bd8d80257298d08f80b1bfd3 Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Sat, 3 May 2014 18:33:58 +1000 Subject: Move non GL_View stuff from gld -> ourGlobals. Plus some white space fixes. --- src/extantz/chat.c | 80 ++++++++++----------- src/extantz/ephysics_demo.c | 120 ++++++++++++++++--------------- src/extantz/extantz.c | 170 +++++++++++++++++++++----------------------- src/extantz/extantz.h | 50 ++++++------- src/extantz/fangWin.c | 138 +++++++++++++++++------------------ src/extantz/woMan.c | 17 ++--- 6 files changed, 287 insertions(+), 288 deletions(-) diff --git a/src/extantz/chat.c b/src/extantz/chat.c index e8a0c4d..12f4d20 100644 --- a/src/extantz/chat.c +++ b/src/extantz/chat.c @@ -1,47 +1,47 @@ #include "extantz.h" -void chat_add(GLData *gld) +void chat_add(globals *ourGlobals) { - Evas_Object *win, *bx, *en; - - win = fang_win_add(gld); - - bx = eo_add(ELM_OBJ_BOX_CLASS, win); - 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); - elm_object_text_set(en, "History is shown here"); - eo_do(en, - elm_obj_entry_scrollable_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); - - en = eo_add(ELM_OBJ_ENTRY_CLASS, win); - elm_object_text_set(en, ""); - eo_do(en, - elm_obj_entry_scrollable_set(EINA_TRUE), + Evas_Object *win, *bx, *en; + + win = fang_win_add(ourGlobals); + + bx = eo_add(ELM_OBJ_BOX_CLASS, win); + 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); + elm_object_text_set(en, "History is shown here"); + eo_do(en, + elm_obj_entry_scrollable_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); + + en = eo_add(ELM_OBJ_ENTRY_CLASS, win); + elm_object_text_set(en, ""); + 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_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); - - evas_object_show(bx); - eo_unref(bx); - - fang_win_complete(gld, win, 30, 500, gld->win_w / 3, gld->win_h / 3); + 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); + + evas_object_show(bx); + eo_unref(bx); + + fang_win_complete(ourGlobals, win, 30, 500, ourGlobals->win_w / 3, ourGlobals->win_h / 3); } diff --git a/src/extantz/ephysics_demo.c b/src/extantz/ephysics_demo.c index e3aa62f..a47ca17 100644 --- a/src/extantz/ephysics_demo.c +++ b/src/extantz/ephysics_demo.c @@ -5,65 +5,67 @@ #define EPHYSICS_TEST_THEME "extantz" -EPhysics_World *ephysicsAdd(GLData *gld) +EPhysics_World *ephysicsAdd(globals *ourGlobals) { - EPhysics_Body *boundary; - EPhysics_World *world; - EPhysics_Body *box_body1, *box_body2; - Evas_Object *box1, *box2; - char buf[PATH_MAX]; - - // ePhysics stuff. - world = ephysics_world_new(); - ephysics_world_render_geometry_set(world, 0, 0, -50, gld->win_w, gld->win_h, 100); - - boundary = ephysics_body_bottom_boundary_add(world); - ephysics_body_restitution_set(boundary, 1); - ephysics_body_friction_set(boundary, 0); - - boundary = ephysics_body_top_boundary_add(world); - ephysics_body_restitution_set(boundary, 1); - ephysics_body_friction_set(boundary, 0); - - boundary = ephysics_body_left_boundary_add(world); - ephysics_body_restitution_set(boundary, 1); - ephysics_body_friction_set(boundary, 0); - - boundary = ephysics_body_right_boundary_add(world); - ephysics_body_restitution_set(boundary, 1); - ephysics_body_friction_set(boundary, 0); - - box1 = elm_image_add(gld->win); - sprintf(buf, "%s/%s.edj", elm_app_data_dir_get(), EPHYSICS_TEST_THEME); - elm_image_file_set(box1, strdup(buf), "blue-cube"); - evas_object_move(box1, gld->win_w / 2 - 80, gld->win_h - 200); - evas_object_resize(box1, 70, 70); - evas_object_show(box1); - - box_body1 = ephysics_body_box_add(world); - ephysics_body_evas_object_set(box_body1, box1, EINA_TRUE); - ephysics_body_restitution_set(box_body1, 0.7); - ephysics_body_friction_set(box_body1, 0); - ephysics_body_linear_velocity_set(box_body1, -150, 200, 0); - ephysics_body_angular_velocity_set(box_body1, 0, 0, 36); - ephysics_body_sleeping_threshold_set(box_body1, 0.1, 0.1); - - box2 = elm_image_add(gld->win); - elm_image_file_set(box2, strdup(buf), "purple-cube"); - evas_object_move(box2, gld->win_w / 2 + 10, gld->win_h - 200); - evas_object_resize(box2, 70, 70); - evas_object_show(box2); - - box_body2 = ephysics_body_box_add(world); - ephysics_body_evas_object_set(box_body2, box2, EINA_TRUE); - ephysics_body_restitution_set(box_body2, 0.7); - ephysics_body_friction_set(box_body2, 0); - ephysics_body_linear_velocity_set(box_body2, 80, -60, 0); - ephysics_body_angular_velocity_set(box_body2, 0, 0, 360); - ephysics_body_sleeping_threshold_set(box_body2, 0.1, 0.1); - - ephysics_world_gravity_set(world, 0, 0, 0); - - return world; +// GLData *gld = &ourGlobals->gld; + + EPhysics_Body *boundary; + EPhysics_World *world; + EPhysics_Body *box_body1, *box_body2; + Evas_Object *box1, *box2; + char buf[PATH_MAX]; + + // ePhysics stuff. + world = ephysics_world_new(); + ephysics_world_render_geometry_set(world, 0, 0, -50, ourGlobals->win_w, ourGlobals->win_h, 100); + + boundary = ephysics_body_bottom_boundary_add(world); + ephysics_body_restitution_set(boundary, 1); + ephysics_body_friction_set(boundary, 0); + + boundary = ephysics_body_top_boundary_add(world); + ephysics_body_restitution_set(boundary, 1); + ephysics_body_friction_set(boundary, 0); + + boundary = ephysics_body_left_boundary_add(world); + ephysics_body_restitution_set(boundary, 1); + ephysics_body_friction_set(boundary, 0); + + boundary = ephysics_body_right_boundary_add(world); + ephysics_body_restitution_set(boundary, 1); + ephysics_body_friction_set(boundary, 0); + + box1 = elm_image_add(ourGlobals->win); + sprintf(buf, "%s/%s.edj", elm_app_data_dir_get(), EPHYSICS_TEST_THEME); + elm_image_file_set(box1, strdup(buf), "blue-cube"); + evas_object_move(box1, ourGlobals->win_w / 2 - 80, ourGlobals->win_h - 200); + evas_object_resize(box1, 70, 70); + evas_object_show(box1); + + box_body1 = ephysics_body_box_add(world); + ephysics_body_evas_object_set(box_body1, box1, EINA_TRUE); + ephysics_body_restitution_set(box_body1, 0.7); + ephysics_body_friction_set(box_body1, 0); + ephysics_body_linear_velocity_set(box_body1, -150, 200, 0); + ephysics_body_angular_velocity_set(box_body1, 0, 0, 36); + ephysics_body_sleeping_threshold_set(box_body1, 0.1, 0.1); + + box2 = elm_image_add(ourGlobals->win); + elm_image_file_set(box2, strdup(buf), "purple-cube"); + evas_object_move(box2, ourGlobals->win_w / 2 + 10, ourGlobals->win_h - 200); + evas_object_resize(box2, 70, 70); + evas_object_show(box2); + + box_body2 = ephysics_body_box_add(world); + ephysics_body_evas_object_set(box_body2, box2, EINA_TRUE); + ephysics_body_restitution_set(box_body2, 0.7); + ephysics_body_friction_set(box_body2, 0); + ephysics_body_linear_velocity_set(box_body2, 80, -60, 0); + ephysics_body_angular_velocity_set(box_body2, 0, 0, 360); + ephysics_body_sleeping_threshold_set(box_body2, 0.1, 0.1); + + ephysics_world_gravity_set(world, 0, 0, 0); + + return world; } #endif diff --git a/src/extantz/extantz.c b/src/extantz/extantz.c index 6ef2b75..d1fdf50 100644 --- a/src/extantz/extantz.c +++ b/src/extantz/extantz.c @@ -8,6 +8,7 @@ static void gldata_init(GLData *gld) { gld->useIrr = USE_IRR; +#if DO_GEARS gld->view_rotx = -20.0; gld->view_roty = -30.0; gld->view_rotz = 0.0; @@ -16,10 +17,10 @@ static void gldata_init(GLData *gld) gld->light[0] = 1.0; gld->light[1] = 1.0; gld->light[2] = -5.0; +#endif } - static void _resize_winwin(GLData *gld) { Evas_Coord x, y, w, h; @@ -63,14 +64,15 @@ static void _resize(GLData *gld) static void _resize_gl(Evas_Object *obj) { - int w, h; - GLData *gld = evas_object_data_get(obj, "gld"); - - elm_glview_size_get(obj, &w, &h); + globals *ourGlobals = evas_object_data_get(obj, "glob"); + GLData *gld = &ourGlobals->gld; + int w, h; + if (!ourGlobals) return; - gld->img_w = w; - gld->img_h = h; - _resize(gld); + elm_glview_size_get(obj, &w, &h); + gld->img_w = w; + gld->img_h = h; + _resize(gld); } static void _on_resize(void *data, Evas *evas, Evas_Object *obj, void *event_info) @@ -78,54 +80,51 @@ static void _on_resize(void *data, Evas *evas, Evas_Object *obj, void *event_inf globals *ourGlobals = data; GLData *gld = &ourGlobals->gld; - eo_do(gld->win, evas_obj_size_get(&gld->win_w, &gld->win_h)); - eo_do(ourGlobals->tb, evas_obj_size_set(gld->win_w, 25)); + eo_do(ourGlobals->win, evas_obj_size_get(&ourGlobals->win_w, &ourGlobals->win_h)); + eo_do(ourGlobals->tb, evas_obj_size_set(ourGlobals->win_w, 25)); _resize(gld); } // Callback from Evas, also used as the general callback for deleting the GL stuff. static void _clean_gl(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) { - GLData *gld = data; + globals *ourGlobals = data; + GLData *gld = &ourGlobals->gld; - ecore_animator_del(gld->animator); + ecore_animator_del(ourGlobals->animator); - // Do a make_current before deleting all the GL stuff. + // Do a make_current before deleting all the GL stuff. // 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); + // TODO - Since this is created on the render thread, better hope this is being deleted on the render thread. + finishIrr(gld); #if DO_GEARS - Evas_GL_API *gl = gld->glApi; + Evas_GL_API *gl = gld->glApi; - gl->glDeleteShader(gld->vtx_shader); - gl->glDeleteShader(gld->fgmt_shader); - gl->glDeleteProgram(gld->program); + gl->glDeleteShader(gld->vtx_shader); + gl->glDeleteShader(gld->fgmt_shader); + gl->glDeleteProgram(gld->program); - gl->glDeleteBuffers(1, &gld->gear1->vbo); - gl->glDeleteBuffers(1, &gld->gear2->vbo); - gl->glDeleteBuffers(1, &gld->gear3->vbo); + gl->glDeleteBuffers(1, &gld->gear1->vbo); + gl->glDeleteBuffers(1, &gld->gear2->vbo); + gl->glDeleteBuffers(1, &gld->gear3->vbo); - free_gear(gld->gear1); - free_gear(gld->gear2); - free_gear(gld->gear3); + free_gear(gld->gear1); + free_gear(gld->gear2); + free_gear(gld->gear3); #endif + + evas_object_data_del((Evas_Object*)obj, "glob"); } // Callback from Elm, coz they do shit different. static void _del_gl(Evas_Object *obj) { - GLData *gld = evas_object_data_get(obj, "gld"); - if (!gld) - { - printf("Unable to get GLData. \n"); - return; - } - - _clean_gl(gld, NULL, NULL, NULL); + globals *ourGlobals = evas_object_data_get(obj, "glob"); + if (!ourGlobals) return; - evas_object_data_del((Evas_Object*)obj, "gld"); + _clean_gl(ourGlobals, NULL, NULL, NULL); } // Callback for when the app quits. @@ -200,42 +199,34 @@ static void init_evas_gl(globals *ourGlobals) { GLData *gld = &ourGlobals->gld; - gld->sfc_w = gld->win_w; - gld->sfc_h = gld->win_h; + gld->sfc_w = ourGlobals->win_w; + gld->sfc_h = ourGlobals->win_h; if (USE_IRR || DO_GEARS) { - gld->sfc_h = gld->win_h; - - // 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. - gld->canvas = evas_object_evas_get(gld->win); - // An Ecore_Evas holds an Evas. - // Get the Ecore_Evas that wraps an Evas. - gld->ee = ecore_evas_ecore_evas_get(gld->canvas); // Only use this on Evas that was created with Ecore_Evas. + gld->sfc_h = ourGlobals->win_h; // Add a GLView - gld->elmGl = elm_glview_add(gld->win); + gld->elmGl = elm_glview_add(ourGlobals->win); evas_object_size_hint_align_set(gld->elmGl, EVAS_HINT_FILL, EVAS_HINT_FILL); evas_object_size_hint_weight_set(gld->elmGl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); elm_glview_mode_set(gld->elmGl, 0 | ELM_GLVIEW_ALPHA | ELM_GLVIEW_DEPTH | ELM_GLVIEW_DIRECT); elm_glview_resize_policy_set(gld->elmGl, ELM_GLVIEW_RESIZE_POLICY_RECREATE); // Destroy the current surface on a resize and create a new one. elm_glview_render_policy_set(gld->elmGl, ELM_GLVIEW_RENDER_POLICY_ON_DEMAND); // elm_glview_render_policy_set(gld->elmGl, ELM_GLVIEW_RENDER_POLICY_ALWAYS); + + gld->glApi = elm_glview_gl_api_get(gld->elmGl); + evas_object_data_set(gld->elmGl, "glob", ourGlobals); // These get called in the render thread I think. - // None let me pass data, so this is why we are adding "gld" data to the object below. + // None let me pass data, so this is why we are adding "glob" data to the object above. // Maybe we can use elm_object_signal_callback_add or elm_object_item_signal_callback_add (edje signals)? //elm_glview_init_func_set(gld->elmGl, _init_gl); // Not actually needed, it gets done in on_pixels. elm_glview_del_func_set(gld->elmGl, _del_gl); elm_glview_resize_func_set(gld->elmGl, _resize_gl); elm_glview_render_func_set(gld->elmGl, (Elm_GLView_Func_Cb) _draw_gl); - // Not needed, the resize callback above deals with that. - //elm_win_resize_object_add(gld->win, gld->elmGl); - gld->glApi = elm_glview_gl_api_get(gld->elmGl); - evas_object_data_set(gld->elmGl, "gld", gld); - evas_object_data_set(gld->elmGl, "glob", ourGlobals); evas_object_show(gld->elmGl); - elm_box_pack_end(gld->bx, gld->elmGl); + elm_box_pack_end(ourGlobals->bx, gld->elmGl); } // TODO - apparently the proper way to deal with the new async rendering is to have this animator do the dirty thing, and call the Irrlicht rendering stuff in the _draw_gl call set above. @@ -243,7 +234,7 @@ static void init_evas_gl(globals *ourGlobals) // Jiggling this seems to produce a trade off between flickering and frame rate. Nothing else changed the flickering. ecore_animator_frametime_set(0.04); // Default is 1/30, or 0.033333 - gld->animator = ecore_animator_add(doFrame, ourGlobals); // This animator will be called every frame tick, which defaults to 1/30 seconds. + ourGlobals->animator = ecore_animator_add(doFrame, ourGlobals); // This animator will be called every frame tick, which defaults to 1/30 seconds. return; } @@ -274,29 +265,29 @@ static void makeMainMenu(globals *ourGlobals) Elm_Object_Item *tb_it; // A toolbar thingy. - tb = eo_add(ELM_OBJ_TOOLBAR_CLASS, gld->win); + tb = eo_add(ELM_OBJ_TOOLBAR_CLASS, ourGlobals->win); ourGlobals->tb = tb; eo_do(tb, evas_obj_size_hint_weight_set(EVAS_HINT_EXPAND, 0.0), evas_obj_size_hint_align_set(EVAS_HINT_FILL, EVAS_HINT_FILL), elm_obj_toolbar_shrink_mode_set(ELM_TOOLBAR_SHRINK_MENU), - evas_obj_size_set(gld->win_w, 25), + evas_obj_size_set(ourGlobals->win_w, 25), evas_obj_position_set(0, 0), elm_obj_toolbar_align_set(0.0) ); // Menus. - menu = _toolbar_menu_add(gld->win, tb, "file"); + menu = _toolbar_menu_add(ourGlobals->win, tb, "file"); elm_menu_item_add(menu, NULL, NULL, "quit", _on_done, gld); - menu = _toolbar_menu_add(gld->win, tb, "edit"); + menu = _toolbar_menu_add(ourGlobals->win, tb, "edit"); elm_menu_item_add(menu, NULL, NULL, "preferences", NULL, NULL); - menu = _toolbar_menu_add(gld->win, tb, "view"); - menu = _toolbar_menu_add(gld->win, tb, "world"); - menu = _toolbar_menu_add(gld->win, tb, "tools"); + menu = _toolbar_menu_add(ourGlobals->win, tb, "view"); + menu = _toolbar_menu_add(ourGlobals->win, tb, "world"); + menu = _toolbar_menu_add(ourGlobals->win, tb, "tools"); - menu = _toolbar_menu_add(gld->win, tb, "help"); + menu = _toolbar_menu_add(ourGlobals->win, tb, "help"); elm_menu_item_add(menu, NULL, NULL, "grid help", NULL, NULL); elm_menu_item_separator_add(menu, NULL); elm_menu_item_add(menu, NULL, NULL, "extantz blogs", NULL, NULL); @@ -304,10 +295,10 @@ static void makeMainMenu(globals *ourGlobals) elm_menu_item_separator_add(menu, NULL); elm_menu_item_add(menu, NULL, NULL, "about extantz", NULL, NULL); - menu = _toolbar_menu_add(gld->win, tb, "advanced"); + menu = _toolbar_menu_add(ourGlobals->win, tb, "advanced"); elm_menu_item_add(menu, NULL, NULL, "debug settings", NULL, NULL); - menu = _toolbar_menu_add(gld->win, tb, "god"); + menu = _toolbar_menu_add(ourGlobals->win, tb, "god"); // Other stuff in the toolbar. tb_it = elm_toolbar_item_append(tb, NULL, NULL, NULL, NULL); @@ -354,30 +345,33 @@ EAPI_MAIN int elm_main(int argc, char **argv) // Set the engine to opengl_x11, then open our window. elm_config_preferred_engine_set("opengl_x11"); - gld->win = elm_win_util_standard_add("extantz", "extantz virtual world viewer"); - ourGlobals.win = gld->win; - // 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(gld->win); - + ourGlobals.win = elm_win_util_standard_add("extantz", "extantz virtual world viewer"); // 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. + // 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_PHYSICS if (!ephysics_init()) return 1; #endif - evas_object_smart_callback_add(gld->win, "delete,request", _on_done, gld); - evas_object_event_callback_add(gld->win, EVAS_CALLBACK_RESIZE, _on_resize, &ourGlobals); + evas_object_smart_callback_add(ourGlobals.win, "delete,request", _on_done, gld); + evas_object_event_callback_add(ourGlobals.win, EVAS_CALLBACK_RESIZE, _on_resize, &ourGlobals); // Get the screen size. - elm_win_screen_size_get(gld->win, &gld->win_x, &gld->win_y, &gld->scr_w, &gld->scr_h); - gld->win_x = gld->win_x + (gld->scr_w / 3); - gld->win_w = gld->scr_w / 2; - gld->win_h = gld->scr_h - 30; + elm_win_screen_size_get(ourGlobals.win, &ourGlobals.win_x, &ourGlobals.win_y, &ourGlobals.scr_w, &ourGlobals.scr_h); + ourGlobals.win_x = ourGlobals.win_x + (ourGlobals.scr_w / 3); + ourGlobals.win_w = ourGlobals.scr_w / 2; + ourGlobals.win_h = ourGlobals.scr_h - 30; // Add a background image object. - obj = eo_add(ELM_OBJ_IMAGE_CLASS, gld->win); + obj = eo_add(ELM_OBJ_IMAGE_CLASS, ourGlobals.win); snprintf(buf, sizeof(buf), "%s/sky_03.jpg", elm_app_data_dir_get()); eo_do(obj, evas_obj_size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND), @@ -385,20 +379,20 @@ EAPI_MAIN int elm_main(int argc, char **argv) elm_obj_image_file_set(buf, NULL), evas_obj_visibility_set(EINA_TRUE) ); - elm_win_resize_object_add(gld->win, obj); + elm_win_resize_object_add(ourGlobals.win, obj); eo_unref(obj); - gld->bx = eo_add(ELM_OBJ_BOX_CLASS, gld->win); - eo_do(gld->bx, + ourGlobals.bx = eo_add(ELM_OBJ_BOX_CLASS, ourGlobals.win); + eo_do(ourGlobals.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), evas_obj_visibility_set(EINA_TRUE) ); - elm_win_resize_object_add(gld->win, gld->bx); + elm_win_resize_object_add(ourGlobals.win, ourGlobals.bx); -// overlay_add(gld); - woMan_add(gld); - chat_add(gld); +// overlay_add(&ourGlobals); + woMan_add(&ourGlobals); + chat_add(&ourGlobals); // Gotta do this after adding the windows, otherwise the menu renders under the window. // This sucks, gotta redefine this menu each time we create a new window? @@ -413,12 +407,12 @@ EAPI_MAIN int elm_main(int argc, char **argv) evas_object_image_pixels_get_callback_set(elm_image_object_get(ourGlobals.scene->image), on_pixels, &ourGlobals); #if USE_PHYSICS - world = ephysicsAdd(gld); + world = ephysicsAdd(&ourGlobals); #endif - evas_object_move(gld->win, gld->win_x, gld->win_y); - evas_object_resize(gld->win, gld->win_w, gld->win_h); - evas_object_show(gld->win); + evas_object_move(ourGlobals.win, ourGlobals.win_x, ourGlobals.win_y); + evas_object_resize(ourGlobals.win, ourGlobals.win_w, ourGlobals.win_h); + evas_object_show(ourGlobals.win); _resize_winwin(gld); @@ -429,12 +423,12 @@ EAPI_MAIN int elm_main(int argc, char **argv) ephysics_shutdown(); #endif - if (gld->win) + if (ourGlobals. win) { Evas_3D_Demo_fini(&ourGlobals); eo_unref(ourGlobals.tb); - eo_unref(gld->bx); - evas_object_del(gld->win); + eo_unref(ourGlobals.bx); + evas_object_del(ourGlobals.win); } if (ourGlobals.logDom >= 0) diff --git a/src/extantz/extantz.h b/src/extantz/extantz.h index b91124e..fab6708 100644 --- a/src/extantz/extantz.h +++ b/src/extantz/extantz.h @@ -161,23 +161,13 @@ typedef struct _Scene_Data } Scene_Data; -// GL related data here. +// Elm GL view related data here. struct _GLData { - Evas_Object *win, *winwin; + Evas_Object *winwin; + Evas_Object *elmGl; + Evas_GL_API *glApi; - Ecore_Evas *ee; - Evas *canvas; - - Evas_Object *elmGl; - Evas_GL_API *glApi; - - GLuint program; - GLuint vtx_shader; - GLuint fgmt_shader; - int scr_w, scr_h; // The size of the screen. - int win_w, win_h; // The size of the window. - int win_x, win_y; // The position of the window. int sfc_w, sfc_h; // This is what Irrlicht is using, size of the GL image surface / glview. int img_w, img_h; // Size of the viewport. DON'T reuse sfc_* here. Despite the fact that sfc_* is only used in the init when Irricht is disabled? WTF? int useIrr : 1; @@ -185,9 +175,6 @@ struct _GLData int gearsInited : 1; int resized : 1; - Evas_Object *bx;//, *r1; - Ecore_Animator *animator; - IrrlichtDevice *device; IVideoDriver *driver; ISceneManager *smgr; @@ -195,7 +182,11 @@ struct _GLData cameraMove *move; - // Gear Stuff +#if DO_GEARS + GLuint program; + GLuint vtx_shader; + GLuint fgmt_shader; + GLfloat view_rotx; GLfloat view_roty; GLfloat view_rotz; @@ -212,16 +203,25 @@ struct _GLData GLfloat proj[16]; GLfloat light[3]; +#endif }; typedef struct _globals { - Evas *evas; +// Ecore_Evas *ee; + Evas *evas; Evas_Object *win; // Our Elm window. Evas_Object *tb; // Our Elm toolbar. + Evas_Object *bx; // Our box. Eina_Clist widgets; // Our windows widgets. int logDom; // Our logging domain. + int scr_w, scr_h; // The size of the screen. + int win_w, win_h; // The size of the window. + int win_x, win_y; // The position of the window. + + Ecore_Animator *animator; + struct _GLData gld; Scene_Data *scene; } globals; @@ -233,7 +233,7 @@ void gears_init(GLData *gld); void drawGears(GLData *gld); void free_gear(Gear *gear); -EPhysics_World *ephysicsAdd(GLData *gld); +EPhysics_World *ephysicsAdd(globals *ourGlobals); EAPI int startIrr(GLData *gld); EAPI void drawIrr_start(GLData *gld); @@ -246,12 +246,12 @@ void Evas_3D_Demo_fini(globals *ourGlobals); void cameraAdd(Evas_Object *win, GLData *gld); -Evas_Object *fang_win_add(GLData *gld); -void fang_win_complete(GLData *gld, Evas_Object *win, int x, int y, int w, int h); -void overlay_add(GLData *gld); +Evas_Object *fang_win_add(globals *ourGlobals); +void fang_win_complete(globals *ourGlobals, Evas_Object *win, int x, int y, int w, int h); +void overlay_add(globals *ourGlobals); -void chat_add(GLData *gld); -void woMan_add(GLData *gld); +void chat_add(globals *ourGlobals); +void woMan_add(globals *ourGlobals); #ifdef __cplusplus diff --git a/src/extantz/fangWin.c b/src/extantz/fangWin.c index 8f68658..c7ec145 100644 --- a/src/extantz/fangWin.c +++ b/src/extantz/fangWin.c @@ -78,79 +78,81 @@ static void create_handles(Evas_Object *obj) } } -Evas_Object *fang_win_add(GLData *gld) +Evas_Object *fang_win_add(globals *ourGlobals) { - Evas_Object *win, *bg; - - // 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"); - win = elm_win_add(gld->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); - elm_win_alpha_set(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(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(win, bg); - evas_object_show(bg); - - return win; + GLData *gld = &ourGlobals->gld; + Evas_Object *win, *bg; + + // 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"); + 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); + elm_win_alpha_set(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(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(win, bg); + evas_object_show(bg); + + return win; } -void fang_win_complete(GLData *gld, Evas_Object *win, int x, int y, int w, int h) +void fang_win_complete(globals *ourGlobals, Evas_Object *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), x, y); - // Odd, it needs to be resized twice. WTF? - evas_object_resize(win, w, h); - evas_object_resize(elm_win_inlined_image_object_get(win), w, h); - evas_object_show(win); - create_handles(elm_win_inlined_image_object_get(win)); + // 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), x, y); + // Odd, it needs to be resized twice. WTF? + evas_object_resize(win, w, h); + evas_object_resize(elm_win_inlined_image_object_get(win), w, h); + evas_object_show(win); + create_handles(elm_win_inlined_image_object_get(win)); } -void overlay_add(GLData *gld) +void overlay_add(globals *ourGlobals) { - 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(gld->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); - // In this code, we are making our own camera, so grab it's input when we are focused. - cameraAdd(gld->winwin, gld); - - 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, gld->win_w, gld->win_h); - evas_object_resize(elm_win_inlined_image_object_get(gld->winwin), gld->win_w, gld->win_h); - evas_object_show(gld->winwin); + 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, gld); + // In this code, we are making our own camera, so grab it's input when we are focused. + cameraAdd(gld->winwin, gld); + + 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); } diff --git a/src/extantz/woMan.c b/src/extantz/woMan.c index 3bb42fe..bef449c 100644 --- a/src/extantz/woMan.c +++ b/src/extantz/woMan.c @@ -139,27 +139,28 @@ 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]; +// ezGrid *thisGrid = data; +// GLData *gld = thisGrid->gld; +// 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, "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); // comment this out for now, busy dealing with input stuff, don't want to trigger this multiple times. // system(buf); } -void woMan_add(GLData *gld) +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; char buf[PATH_MAX]; int i; - win = fang_win_add(gld); + win = fang_win_add(ourGlobals); bx = elm_box_add(win); elm_win_resize_object_add(win, bx); @@ -287,5 +288,5 @@ void woMan_add(GLData *gld) eo_unref(bt); evas_object_show(bx); - fang_win_complete(gld, win, 30, 30, gld->win_w / 3, gld->win_h / 3); + fang_win_complete(ourGlobals, win, 30, 30, ourGlobals->win_w / 3, ourGlobals->win_h / 3); } -- cgit v1.1