From a0f30eea71e05f114e6a708b07768995c884914c Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Mon, 12 May 2014 02:47:54 +1000 Subject: Fix up winFang move and resize. Still more to fix here though. --- src/extantz/files.c | 4 +-- src/extantz/woMan.c | 6 ++-- src/libraries/winFang.c | 75 ++++++++++++++++++++++++++++------------------- src/libraries/winFang.edc | 22 ++++++++++++++ src/libraries/winFang.h | 8 +++-- src/purkle/purkle.c | 4 +-- 6 files changed, 79 insertions(+), 40 deletions(-) diff --git a/src/extantz/files.c b/src/extantz/files.c index 12dcc8d..799f1ac 100644 --- a/src/extantz/files.c +++ b/src/extantz/files.c @@ -158,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_layout_box_append(me->win, BOX, fs); + elm_layout_box_append(me->win, WF_BOX, fs); elm_fileselector_path_set(fs, path); elm_fileselector_is_save_set(fs, save); @@ -264,7 +264,7 @@ winFang *filesAdd(globals *ourGlobals, char *path, Eina_Bool multi, Eina_Bool sa elm_box_pack_end(vbox, bt); eo_unref(bt); - elm_layout_box_append(me->win, BOX, vbox); + elm_layout_box_append(me->win, WF_BOX, vbox); evas_object_show(vbox); eo_unref(vbox); diff --git a/src/extantz/woMan.c b/src/extantz/woMan.c index 7e476ea..b2f7ee3 100644 --- a/src/extantz/woMan.c +++ b/src/extantz/woMan.c @@ -184,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_layout_box_append(me->win, BOX, tb); + elm_layout_box_append(me->win, WF_BOX, tb); evas_object_show(tb); gridList = elm_genlist_add(me->win); @@ -267,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_layout_box_append(me->win, BOX, nf); + elm_layout_box_append(me->win, WF_BOX, nf); bt = eo_add(ELM_OBJ_BUTTON_CLASS, me->win, // evas_obj_text_set("Login"), @@ -277,7 +277,7 @@ 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_layout_box_append(me->win, BOX, bt); + elm_layout_box_append(me->win, WF_BOX, bt); eo_unref(bt); return me; diff --git a/src/libraries/winFang.c b/src/libraries/winFang.c index d17d732..cd83291 100644 --- a/src/libraries/winFang.c +++ b/src/libraries/winFang.c @@ -1,24 +1,6 @@ #include "winFang.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) -{ - winFang *win = data; - Evas_Event_Mouse_Down *ev = event_info; - - if (1 == ev->button) - { - Evas_Object *objs = evas_object_top_at_pointer_get(win->e); - -// TODO - This always returns the elm_win. So how the hell do you tell what got clicked on? -printf("%s %s\n", evas_object_type_get(objs), evas_object_name_get(objs)); - - elm_object_focus_set(obj, EINA_TRUE); - } -} - static void _checkWindowBounds(winFang *win, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h) { Evas_Object *img = win->win, *test; @@ -40,7 +22,7 @@ static void _checkWindowBounds(winFang *win, Evas_Coord x, Evas_Coord y, Evas_Co EINA_LIST_FOREACH(objs, this, test) { const char * name = evas_object_name_get(test); - if (name && (strcmp("winFang", name) == 0)) + if (name && (strcmp(WF_LAYOUT, name) == 0)) i++; } if (2 <= i) @@ -72,7 +54,6 @@ static void _checkWindowBounds(winFang *win, Evas_Coord x, Evas_Coord y, Evas_Co else if (i == 3) cy += win->h; evas_object_move(win->hand[i], cx - 15, cy - 15); } - // TODO - This just stretches everything, we don't really want that. } static void cb_mouse_move(void *data, Evas *evas, Evas_Object *obj, void *event_info) @@ -139,6 +120,28 @@ static void _onBgMove(void *data, Evas *evas, Evas_Object *obj, void *event_info _checkWindowBounds(win, x, y, w, h); } +static void _onBgUnclick(void *data, Evas *evas, Evas_Object *obj, void *event_info) +{ + Evas_Event_Mouse_Down *ev = event_info; + + if (1 == ev->button) + { + evas_object_event_callback_del(obj, EVAS_CALLBACK_MOUSE_UP, _onBgUnclick); + evas_object_event_callback_del(obj, EVAS_CALLBACK_MOUSE_MOVE, _onBgMove); + } +} + +static void _onBgClick(void *data, Evas *evas, Evas_Object *obj, void *event_info) +{ + Evas_Event_Mouse_Down *ev = event_info; + + if (1 == ev->button) + { + evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_UP, _onBgUnclick, data); + evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_MOVE, _onBgMove, data); + } +} + static void _on_done(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) { elm_exit(); @@ -165,6 +168,7 @@ 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; char buf[PATH_MAX]; int i; @@ -186,17 +190,28 @@ winFang *winFangAdd(winFang *parent, int x, int y, int w, int h, char *title, ch result->win = eo_add(ELM_OBJ_LAYOUT_CLASS, parent->win, evas_obj_size_set(result->w, result->h), evas_obj_position_set(result->x, result->y), - evas_obj_name_set("winFang"), - elm_obj_layout_file_set(buf, "winFang/layout"), + evas_obj_name_set(WF_LAYOUT), + elm_obj_layout_file_set(buf, WF_LAYOUT), evas_obj_visibility_set(EINA_TRUE) ); result->e = evas_object_evas_get(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(result->win, EVAS_CALLBACK_MOUSE_DOWN, _cb_mouse_down_elm, result); - evas_object_event_callback_add(result->win, EVAS_CALLBACK_MOUSE_MOVE, _onBgMove, result); + // Something to catch clicks on the background, for moving the window. + // Cov Elm is uncooperative with this sort of thing, so we need to stick in a rectangle. + obj = 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_name_set(WF_UNDERLAY), + evas_obj_color_set(0, 0, 0, 0), + evas_obj_visibility_set(EINA_TRUE) + ); + elm_object_part_content_set(result->win, WF_UNDERLAY, obj); + evas_object_event_callback_add(obj, EVAS_CALLBACK_MOUSE_DOWN, _onBgClick, result); + eo_unref(obj); + + if (title) + elm_object_part_text_set(result->win, WF_TITLE, title); /* result->title = eo_add(ELM_OBJ_LABEL_CLASS, result->win, evas_obj_size_hint_align_set(EVAS_HINT_FILL, 1.0), @@ -209,6 +224,7 @@ winFang *winFangAdd(winFang *parent, int x, int y, int w, int h, char *title, ch elm_box_pack_end(result->box, result->title); eo_unref(result->title); */ + /* obj1 = eo_add(ELM_OBJ_SEPARATOR_CLASS, result->win, evas_obj_size_hint_align_set(EVAS_HINT_FILL, 1.0), @@ -220,17 +236,15 @@ winFang *winFangAdd(winFang *parent, int x, int y, int w, int h, char *title, ch eo_unref(obj1); */ - if (title) - elm_object_part_text_set(result->win, TITLE, title); - result->grid = eo_add(ELM_OBJ_GRID_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_name_set(WF_SWALLOW), // TODO - Actually, this should be minus the size of the title stuff. elm_obj_grid_size_set(result->w, result->h), evas_obj_visibility_set(EINA_TRUE) ); - elm_object_part_content_set(result->win, SWALLOW, result->grid); + elm_object_part_content_set(result->win, WF_SWALLOW, result->grid); elm_layout_sizing_eval(result->win); @@ -341,6 +355,7 @@ Widget *widgetAdd(winFang *win, const Eo_Class *klass, Evas_Object *parent, char { result->label = strdup(title); elm_object_text_set(result->obj, result->label); + evas_object_name_set(result->obj, title); } } diff --git a/src/libraries/winFang.edc b/src/libraries/winFang.edc index 0fca7a9..7705a0b 100644 --- a/src/libraries/winFang.edc +++ b/src/libraries/winFang.edc @@ -43,8 +43,28 @@ collections { } part { + name: "winFang/underlay"; + type: SWALLOW; + mouse_events: 1; + + description { + state: "default" 0.0; + + rel1 { + relative: 0.0 0.0; + to: "winFang/background"; + } + rel2 { + relative: 1.0 1.0; + to: "winFang/background"; + } + } + } // winFang/underlay + + part { name: "winFang/title"; type: TEXT; + mouse_events: 0; description { state: "default" 0.0; @@ -71,6 +91,7 @@ collections { part { name: "winFang/box"; type: BOX; + mouse_events: 1; description { state: "default" 0.0; @@ -93,6 +114,7 @@ collections { part { name: "winFang/content"; type: SWALLOW; + mouse_events: 1; description { state: "default" 0.0; diff --git a/src/libraries/winFang.h b/src/libraries/winFang.h index d2e03cf..c55a75e 100644 --- a/src/libraries/winFang.h +++ b/src/libraries/winFang.h @@ -16,9 +16,11 @@ #include -#define BOX "winFang/box" -#define TITLE "winFang/title" -#define SWALLOW "winFang/content" +#define WF_LAYOUT "winFang/layout" +#define WF_UNDERLAY "winFang/underlay" +#define WF_TITLE "winFang/title" +#define WF_BOX "winFang/box" +#define WF_SWALLOW "winFang/content" typedef struct _winFang diff --git a/src/purkle/purkle.c b/src/purkle/purkle.c index b1a45e1..98bfd13 100644 --- a/src/purkle/purkle.c +++ b/src/purkle/purkle.c @@ -29,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_layout_box_append(me->win, BOX, en); + elm_layout_box_append(me->win, WF_BOX, en); eo_unref(en); wid = widgetAdd(me, ELM_OBJ_ENTRY_CLASS, me->win, ""); @@ -38,7 +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_layout_box_append(me->win, BOX, wid->obj); + elm_layout_box_append(me->win, WF_BOX, wid->obj); return me; } -- cgit v1.1