From 041d246dfc219a0bb2e10345090a4ff9613b5920 Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Sun, 11 May 2014 13:34:49 +1000 Subject: Change internal windows from Elm win to Elm layout. --- src/GuiLua/GuiLua.c | 19 +++++--- src/extantz/extantz.c | 1 - src/extantz/files.c | 8 ++- src/extantz/woMan.c | 8 ++- src/libraries/build.lua | 3 +- src/libraries/winFang.c | 121 +++++++++++++++++++--------------------------- src/libraries/winFang.edc | 115 +++++++++++++++++++++++++++++++++++++++++++ src/libraries/winFang.h | 9 ++-- src/purkle/purkle.c | 7 +-- 9 files changed, 191 insertions(+), 100 deletions(-) create mode 100644 src/libraries/winFang.edc (limited to 'src') diff --git a/src/GuiLua/GuiLua.c b/src/GuiLua/GuiLua.c index 2e16927..b25c60f 100644 --- a/src/GuiLua/GuiLua.c +++ b/src/GuiLua/GuiLua.c @@ -175,13 +175,10 @@ static int widget(lua_State *L) winFang *win = NULL; char *type = "button"; char *title = ":"; - int x = 1, y = 1, w = WIDTH/3, h = HEIGHT/3, cy; + int x = 1, y = 1, w = WIDTH/3, h = HEIGHT/3; pull_lua(L, 1, "*window $type $title %x %y %w %h", &win, &type, &title, &x, &y, &w, &h); - evas_object_geometry_get(win->content, NULL, &cy, NULL, NULL); - y += cy; - // Poor mans introspection, until I write real introspection into EFL. // TODO - The alternative is to just lookup the ELM_*_CLASS in a hash table? if (strcmp(type, "button") == 0) @@ -192,14 +189,20 @@ static int widget(lua_State *L) wid = widgetAdd(win, ELM_OBJ_BUTTON_CLASS, win->win, title); wid->data = L; eo_do(wid->obj, - evas_obj_size_set(w, h), - evas_obj_position_set(x, y), evas_obj_visibility_set(EINA_TRUE), eo_key_data_set("Widget", wid, NULL) ); - evas_object_smart_callback_add(wid->obj, "clicked", _on_click, wid); - evas_object_show(win->box); + if (win->grid) + elm_grid_pack(win->grid, wid->obj, x, y, w, h); + else + { + eo_do(wid->obj, + evas_obj_size_set(w, h), + evas_obj_position_set(x, y) + ); + } + evas_object_smart_callback_add(wid->obj, "clicked", _on_click, wid); lua_pushlightuserdata(L, (void *) wid); return 1; diff --git a/src/extantz/extantz.c b/src/extantz/extantz.c index 03979ab..fe6a3c2 100644 --- a/src/extantz/extantz.c +++ b/src/extantz/extantz.c @@ -524,7 +524,6 @@ EAPI_MAIN int elm_main(int argc, char **argv) // Bump the top toolbar above the windows. evas_object_raise(ourGlobals.tb); - evas_object_show(ourGlobals.mainWindow->box); _on_resize(&ourGlobals, NULL, NULL, NULL); elm_run(); diff --git a/src/extantz/files.c b/src/extantz/files.c index 6ac151d..12dcc8d 100644 --- a/src/extantz/files.c +++ b/src/extantz/files.c @@ -147,9 +147,8 @@ winFang *filesAdd(globals *ourGlobals, char *path, Eina_Bool multi, Eina_Bool sa Evas_Object *vbox, *fs, *bt, *rd = NULL, *rdg = NULL, *hoversel; me = winFangAdd(ourGlobals->mainWindow, ourGlobals->win_w - 380, ourGlobals->win_w - 530, 350, 500, "file selector", "files", ourGlobals->world); - useBox(me); - wid = widgetAdd(me, ELM_OBJ_FILESELECTOR_CLASS, me->box, NULL); + wid = widgetAdd(me, ELM_OBJ_FILESELECTOR_CLASS, me->win, NULL); fs = wid->obj; wid->data = ourGlobals; wid->on_del = _on_fs_del; @@ -159,7 +158,7 @@ winFang *filesAdd(globals *ourGlobals, char *path, Eina_Bool multi, Eina_Bool sa elm_interface_fileselector_expandable_set(EINA_TRUE), elm_interface_fileselector_folder_only_set(EINA_FALSE) ); - elm_box_pack_end(me->box, fs); + elm_layout_box_append(me->win, BOX, fs); elm_fileselector_path_set(fs, path); elm_fileselector_is_save_set(fs, save); @@ -265,9 +264,8 @@ winFang *filesAdd(globals *ourGlobals, char *path, Eina_Bool multi, Eina_Bool sa elm_box_pack_end(vbox, bt); eo_unref(bt); - elm_box_pack_end(me->box, vbox); + elm_layout_box_append(me->win, BOX, vbox); evas_object_show(vbox); - evas_object_show(me->box); eo_unref(vbox); winFangHide(me); diff --git a/src/extantz/woMan.c b/src/extantz/woMan.c index 6167cb1..7e476ea 100644 --- a/src/extantz/woMan.c +++ b/src/extantz/woMan.c @@ -160,7 +160,6 @@ winFang *woMan_add(globals *ourGlobals) int i; me = winFangAdd(ourGlobals->mainWindow, 30, 200, ourGlobals->win_w / 3, ourGlobals->win_h / 3, "virtual world manager", "woMan", ourGlobals->world); - useBox(me); // A tab thingy. tb = elm_toolbar_add(me->win); @@ -185,7 +184,7 @@ winFang *woMan_add(globals *ourGlobals) elm_menu_item_add(menu, menu_it, NULL, "debug settings", NULL, NULL); // The toolbar needs to be packed into the box AFTER the menus are added. - elm_box_pack_end(me->box, tb); + elm_layout_box_append(me->win, BOX, tb); evas_object_show(tb); gridList = elm_genlist_add(me->win); @@ -268,7 +267,7 @@ winFang *woMan_add(globals *ourGlobals) tab = viewerList; tab_it = elm_naviframe_item_push(nf, NULL, NULL, NULL, tab, NULL); elm_naviframe_item_title_enabled_set(tab_it, EINA_FALSE, EINA_TRUE); elm_toolbar_item_append(tb, NULL, "Viewers", _promote, tab_it); tab = _content_image_new(me->win, strdup(buf)); tab_it = elm_naviframe_item_push(nf, NULL, NULL, NULL, tab, NULL); elm_naviframe_item_title_enabled_set(tab_it, EINA_FALSE, EINA_TRUE); elm_toolbar_item_append(tb, NULL, "Landmarks", _promote, tab_it); tab = gridList; tab_it = elm_naviframe_item_push(nf, NULL, NULL, NULL, tab, NULL); elm_naviframe_item_title_enabled_set(tab_it, EINA_FALSE, EINA_TRUE); elm_toolbar_item_append(tb, NULL, "Grids", _promote, tab_it); - elm_box_pack_end(me->box, nf); + elm_layout_box_append(me->win, BOX, nf); bt = eo_add(ELM_OBJ_BUTTON_CLASS, me->win, // evas_obj_text_set("Login"), @@ -278,9 +277,8 @@ winFang *woMan_add(globals *ourGlobals) ); elm_object_text_set(bt, "Login"); // No eo interface for this that I can find. // evas_object_smart_callback_add(bt, "clicked", NULL, NULL); - elm_box_pack_end(me->box, bt); + elm_layout_box_append(me->win, BOX, bt); eo_unref(bt); - evas_object_show(me->box); return me; } diff --git a/src/libraries/build.lua b/src/libraries/build.lua index 4e277e1..45c436d 100755 --- a/src/libraries/build.lua +++ b/src/libraries/build.lua @@ -15,7 +15,7 @@ end LDFLAGS = '-L ' .. dir .. ' ' .. LDFLAGS -removeFiles(dir, {'LumbrJack.o', lib_d .. '/libLumbrJack.so', 'Runnr.o', lib_d .. '/libRunnr.so', 'SledjHamr.o', lib_d .. '/libSledjHamr.so', 'winFang.o', lib_d .. '/libwinFang.so'}) +removeFiles(dir, {'LumbrJack.o', lib_d .. '/libLumbrJack.so', 'Runnr.o', lib_d .. '/libRunnr.so', 'SledjHamr.o', lib_d .. '/libSledjHamr.so', '../../media/winFang.edj', 'winFang.o', lib_d .. '/libwinFang.so'}) runCommand('C libraries', dir, 'gcc ' .. CFLAGS .. ' -fPIC -c LumbrJack.c') runCommand(nil, dir, 'gcc ' .. CFLAGS .. ' -shared -Wl,-soname,libLumbrJack.so -o ' .. lib_d .. '/libLumbrJack.so LumbrJack.o') @@ -32,5 +32,6 @@ CFLAGS = CFLAGS .. ' -DPACKAGE_LOCALE_DIR=\\"' .. locale_d .. '\\"' runCommand(nil, dir, 'gcc ' .. CFLAGS .. ' -fPIC -c SledjHamr.c') runCommand(nil, dir, 'gcc ' .. CFLAGS .. ' -shared -Wl,-soname,libSledjHamr.so -o ' .. lib_d .. '/libSledjHamr.so SledjHamr.o') +runCommand(nil, dir, 'edje_cc ' .. EDJE_FLAGS .. ' winFang.edc ../../media/winFang.edj') runCommand(nil, dir, 'gcc ' .. CFLAGS .. ' -fPIC -c winFang.c') runCommand(nil, dir, 'gcc ' .. CFLAGS .. ' -shared -Wl,-soname,libwinFang.so -o ' .. lib_d .. '/libwinFang.so winFang.o') diff --git a/src/libraries/winFang.c b/src/libraries/winFang.c index 6b15a6d..2cbd04d 100644 --- a/src/libraries/winFang.c +++ b/src/libraries/winFang.c @@ -21,7 +21,7 @@ printf("%s %s\n", evas_object_type_get(objs), evas_object_name_get(objs)); static void _checkWindowBounds(winFang *win, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h) { - Evas_Object *img = elm_win_inlined_image_object_get(win->win), *test; + Evas_Object *img = win->win, *test; Eina_List *objs, *this; Evas_Coord mw, mh; int padding = 1, i = 0, overs[4][2]; @@ -80,7 +80,7 @@ static void cb_mouse_move(void *data, Evas *evas, Evas_Object *obj, void *event_ Evas_Event_Mouse_Move *ev = event_info; winFang *win = data; Evas_Coord x, y, w, h, dx = 0, dy = 0, dw = 0, dh = 0, mx, my; - Evas_Object *img = elm_win_inlined_image_object_get(win->win); + Evas_Object *img = win->win; int i; if (!ev->buttons) return; @@ -126,7 +126,7 @@ static void _onBgMove(void *data, Evas *evas, Evas_Object *obj, void *event_info { Evas_Event_Mouse_Move *ev = event_info; winFang *win = data; - Evas_Object *img = elm_win_inlined_image_object_get(win->win); + Evas_Object *img = win->win; Evas_Coord x, y, w, h; if (1 != ev->buttons) return; @@ -165,8 +165,6 @@ void winFangShow(winFang *win) winFang *winFangAdd(winFang *parent, int x, int y, int w, int h, char *title, char *name, EPhysics_World *world) { winFang *result; - Evas_Object *obj, *obj1; - Evas *obj2; char buf[PATH_MAX]; int i; @@ -182,84 +180,81 @@ winFang *winFangAdd(winFang *parent, int x, int y, int w, int h, char *title, ch result->w = w; result->h = h; - // 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"); if (result->internal) { - result->win = elm_win_add(parent->win, name, ELM_WIN_INLINED_IMAGE); eina_clist_add_head(&parent->winFangs, &result->node); - obj = elm_win_inlined_image_object_get(result->win); - evas_object_name_set(obj, "winFang"); + + result->win = elm_layout_add(parent->win); + evas_object_name_set(result->win, "winFang"); + evas_object_size_hint_weight_set(result->win, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + snprintf(buf, sizeof(buf), "%s/winFang.edj", elm_app_data_dir_get()); + elm_layout_file_set(result->win, buf, "winFang/layout"); + if (title) + elm_object_part_text_set(result->win, TITLE, title); + + result->grid = elm_grid_add(parent->win); + elm_grid_size_set(result->grid, result->w, result->h); + evas_object_size_hint_weight_set(result->grid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(result->grid, EVAS_HINT_FILL, EVAS_HINT_FILL); + elm_object_part_content_set(result->win, SWALLOW, result->grid); + evas_object_show(result->grid); + + evas_object_resize(result->win, result->w, result->h); + evas_object_move(result->win, result->x, result->y); + elm_layout_sizing_eval(result->win); + evas_object_show(result->win); + // 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(obj, EVAS_CALLBACK_MOUSE_DOWN, _cb_mouse_down_elm, result); - evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_MOVE, _onBgMove, result); - elm_win_alpha_set(result->win, EINA_TRUE); - - // 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(obj, result->x, result->y); - // Odd, it needs to be resized twice. WTF? - evas_object_resize(obj, result->w, result->h); - - obj2 = evas_object_evas_get(obj); - result->e = obj2; + evas_object_event_callback_add(result->win, EVAS_CALLBACK_MOUSE_DOWN, _cb_mouse_down_elm, result); + evas_object_event_callback_add(result->win, EVAS_CALLBACK_MOUSE_MOVE, _onBgMove, result); + + result->e = evas_object_evas_get(result->win); // Create corner handles. snprintf(buf, sizeof(buf), "%s/pt.png", elm_app_data_dir_get()); for (i = 0; i < 4; i++) { - char key[32]; int cx = result->x, cy = result->y; if (i == 1) cx += result->w; else if (i == 2) {cx += result->w; cy += result->h;} else if (i == 3) cy += result->h; - snprintf(key, sizeof(key), "h-%i\n", i); - result->hand[i] = eo_add(EVAS_OBJ_IMAGE_CLASS, obj2, + result->hand[i] = eo_add(EVAS_OBJ_IMAGE_CLASS, result->e, evas_obj_image_filled_set(EINA_TRUE), evas_obj_image_file_set(buf, NULL), evas_obj_size_set(31, 31), evas_obj_position_set(cx - 15, cy - 15), - eo_key_data_set(key, result->hand[i], NULL), evas_obj_visibility_set(EINA_TRUE) ); evas_object_event_callback_add(result->hand[i], EVAS_CALLBACK_MOUSE_MOVE, cb_mouse_move, result); eo_unref(result->hand[i]); } + } else { result->win = elm_win_add(NULL, name, ELM_WIN_BASIC); evas_object_move(result->win, result->x, result->y); evas_object_smart_callback_add(result->win, "delete,request", _on_done, NULL); - } + elm_win_title_set(result->win, title); - elm_win_title_set(result->win, title); - - snprintf(buf, sizeof(buf), "%s/sky_04.jpg", elm_app_data_dir_get()); - result->bg = eo_add(ELM_OBJ_IMAGE_CLASS, result->win, - evas_obj_size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND), - elm_obj_image_fill_outside_set(EINA_TRUE), - elm_obj_image_file_set(buf, NULL), - evas_obj_color_set(50, 0, 100, 100), - evas_obj_visibility_set(EINA_TRUE) - ); - elm_win_resize_object_add(result->win, result->bg); - - // Every window gets a free vertical box. - // TODO - Any widgets created without positon and size get packed to the end. - result->box = eo_add(ELM_OBJ_BOX_CLASS, result->win, - elm_obj_box_homogeneous_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) - ); - elm_win_resize_object_add(result->win, result->box); + snprintf(buf, sizeof(buf), "%s/sky_04.jpg", elm_app_data_dir_get()); + result->bg = eo_add(ELM_OBJ_IMAGE_CLASS, result->win, + evas_obj_size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND), + elm_obj_image_fill_outside_set(EINA_TRUE), + elm_obj_image_file_set(buf, NULL), + evas_obj_color_set(50, 0, 100, 100), + evas_obj_visibility_set(EINA_TRUE) + ); + elm_win_resize_object_add(result->win, result->bg); + evas_object_resize(result->win, result->w, result->h); + } if (result->internal) { +/* result->title = eo_add(ELM_OBJ_LABEL_CLASS, result->win, - evas_obj_size_hint_align_set(EVAS_HINT_FILL, EVAS_HINT_FILL), + evas_obj_size_hint_align_set(EVAS_HINT_FILL, 1.0), evas_obj_size_hint_weight_set(EVAS_HINT_EXPAND, 0.0), evas_obj_visibility_set(EINA_TRUE) ); @@ -268,7 +263,7 @@ winFang *winFangAdd(winFang *parent, int x, int y, int w, int h, char *title, ch elm_object_text_set(result->title, buf); elm_box_pack_end(result->box, result->title); eo_unref(result->title); - +*/ #if 0 // EPysics enable the window. if (world) @@ -284,25 +279,18 @@ winFang *winFangAdd(winFang *parent, int x, int y, int w, int h, char *title, ch } #endif +/* obj1 = eo_add(ELM_OBJ_SEPARATOR_CLASS, result->win, - evas_obj_size_hint_align_set(EVAS_HINT_FILL, EVAS_HINT_FILL), + evas_obj_size_hint_align_set(EVAS_HINT_FILL, 1.0), evas_obj_size_hint_weight_set(EVAS_HINT_EXPAND, 0.0), elm_obj_separator_horizontal_set(EINA_TRUE), evas_obj_visibility_set(EINA_TRUE) ); elm_box_pack_end(result->box, obj1); eo_unref(obj1); - - result->content = eo_add(EVAS_OBJ_RECTANGLE_CLASS, result->win, - evas_obj_size_hint_align_set(EVAS_HINT_FILL, EVAS_HINT_FILL), - evas_obj_size_hint_weight_set(EVAS_HINT_EXPAND, EVAS_HINT_EXPAND), - evas_obj_color_set(0, 0, 0, 0), - evas_obj_visibility_set(EINA_TRUE) - ); - elm_box_pack_end(result->box, result->content); +*/ } - evas_object_resize(result->win, result->w, result->h); evas_object_show(result->win); return result; @@ -315,9 +303,7 @@ void winFangDel(winFang *win) if (!win) return; - eo_unref(win->content); - eo_unref(win->box); - eo_unref(win->bg); + if (win->bg) eo_unref(win->bg); EINA_CLIST_FOR_EACH_ENTRY(wf, &win->winFangs, winFang, node) { winFangDel(wf); @@ -333,15 +319,6 @@ void winFangDel(winFang *win) evas_object_del(win->win); } -void useBox(winFang *win) -{ - eo_do(win->content, - evas_obj_visibility_set(EINA_FALSE), - evas_obj_size_hint_weight_set(EVAS_HINT_EXPAND, 0.0), - evas_obj_size_set(0, 0) - ); -} - Widget *widgetAdd(winFang *win, const Eo_Class *klass, Evas_Object *parent, char *title) { Widget *result; diff --git a/src/libraries/winFang.edc b/src/libraries/winFang.edc new file mode 100644 index 0000000..0fca7a9 --- /dev/null +++ b/src/libraries/winFang.edc @@ -0,0 +1,115 @@ +// The images we use. +images +{ + image: "bubble.png" COMP; // COMP means to use lossless compression. + image: "bubble_sh.png" COMP; + image: "logo.png" COMP; + image: "pt.png" COMP; + image: "sky_01.jpg" COMP; + image: "sky_02.jpg" COMP; + image: "sky_03.jpg" COMP; + image: "sky_04.jpg" COMP; +} + +collections { + + group { + name: "winFang/layout"; + + data { + item: "title" "Layout based internal window"; + } + + parts { + + // The first part, the black background RECTangle of the screens. + part + { name: "winFang/background"; + type: IMAGE; + // Ignore mouse events. + mouse_events: 0; + // Each part has one or more descriptions, or states. + // They all have to have at least this default state. + description + { state: "default" 0.0; + // RGBA, so this is purple, and semi transparent. +// color: 50 0 100 100; // pre multiplied R = (r * a) / 255 + color: 126 0 255 100; // r = (R * 255) / a + aspect_preference: HORIZONTAL; + image { + normal: "sky_04.jpg"; + } + } + } + + part { + name: "winFang/title"; + type: TEXT; + + description { + state: "default" 0.0; + color: 255 255 255 255; + rel1 { + relative: 0.0 0.0; + to: "winFang/background"; + } + rel2 { + relative: 1.0 0.0; + to: "winFang/background"; + offset: 0 15; + } + text { + text: "bla"; + size: 10; + font: "sans"; + min: 0 1; + max: 0 1; + } + } + } + + part { + name: "winFang/box"; + type: BOX; + + description { + state: "default" 0.0; + + box { + layout: "vertical"; + } + rel1 { + relative: 0.0 0.0; + to: "winFang/title"; + offset: 0 15; + } + rel2 { + relative: 1.0 1.0; + to: "winFang/background"; + } + } + } // winFang/box + + part { + name: "winFang/content"; + type: SWALLOW; + + description { + state: "default" 0.0; + fixed: 1 1; + + rel1 { + relative: 0.0 0.0; + to: "winFang/title"; + offset: 0 15; + } + rel2 { + relative: 1.0 1.0; + to: "winFang/background"; + } + } + } // winFang/content + + } + } +} diff --git a/src/libraries/winFang.h b/src/libraries/winFang.h index 17cf942..c614b04 100644 --- a/src/libraries/winFang.h +++ b/src/libraries/winFang.h @@ -16,6 +16,11 @@ #include +#define BOX "winFang/box" +#define TITLE "winFang/title" +#define SWALLOW "winFang/content" + + typedef struct _winFang { Evas *e; @@ -23,8 +28,7 @@ typedef struct _winFang Evas_Object *win; Evas_Object *title; Evas_Object *bg; - Evas_Object *box; - Evas_Object *content; + Evas_Object *grid; EPhysics_Body *body; Eina_Clist widgets; Eina_Clist winFangs; @@ -59,7 +63,6 @@ void winFangHide(winFang *win); void winFangShow(winFang *win); void winFangDel(winFang *win); -void useBox(winFang *win); Widget *widgetAdd(winFang *win, const Eo_Class *klass, Evas_Object *parent, char *title); #endif diff --git a/src/purkle/purkle.c b/src/purkle/purkle.c index 6538096..b1a45e1 100644 --- a/src/purkle/purkle.c +++ b/src/purkle/purkle.c @@ -20,7 +20,6 @@ static winFang *purkleAdd(winFang *parent, int w, int h, EPhysics_World *world) Evas_Object *en; me = winFangAdd(parent, 30, 590, w, h, "chatter box", "purkle", world); - useBox(me); en = eo_add(ELM_OBJ_ENTRY_CLASS, me->win, elm_obj_entry_scrollable_set(EINA_TRUE), @@ -30,7 +29,7 @@ static winFang *purkleAdd(winFang *parent, int w, int h, EPhysics_World *world) evas_obj_visibility_set(EINA_TRUE) ); elm_object_text_set(en, "History is shown here"); - elm_box_pack_end(me->box, en); + elm_layout_box_append(me->win, BOX, en); eo_unref(en); wid = widgetAdd(me, ELM_OBJ_ENTRY_CLASS, me->win, ""); @@ -39,9 +38,7 @@ static winFang *purkleAdd(winFang *parent, int w, int h, EPhysics_World *world) elm_obj_entry_scrollable_set(EINA_TRUE), elm_obj_entry_editable_set(EINA_TRUE) ); - elm_box_pack_end(me->box, wid->obj); - - evas_object_show(me->box); + elm_layout_box_append(me->win, BOX, wid->obj); return me; } -- cgit v1.1