From 43ebca08357049db171c9a0c59d97f76ef930b27 Mon Sep 17 00:00:00 2001 From: Jaime Thomas Date: Tue, 9 Dec 2008 23:17:57 +0000 Subject: [PATCH] Better focus behaviour for the filelist... like sloppy focus. --- .../data/themes/default/groups/button.edc | 12 +++- .../data/themes/default/groups/entry.edc | 17 ++++-- experimental/ecdb/trunk/src/ecdb.h | 9 --- experimental/ecdb/trunk/src/ecdb_common.h | 12 ++++ experimental/ecdb/trunk/src/ecdb_gui.c | 55 +++++++++++++++++-- 5 files changed, 85 insertions(+), 20 deletions(-) diff --git a/experimental/ecdb/trunk/data/themes/default/groups/button.edc b/experimental/ecdb/trunk/data/themes/default/groups/button.edc index 244ab57c..80c09225 100644 --- a/experimental/ecdb/trunk/data/themes/default/groups/button.edc +++ b/experimental/ecdb/trunk/data/themes/default/groups/button.edc @@ -278,8 +278,7 @@ group { } program { - name: "focus_in"; - signal: "ecdb,button,in"; + name: "focus_in,mouse"; signal: "mouse,down,1"; action: STATE_SET "visible" 0.0; source: "*"; @@ -287,6 +286,15 @@ group { transition: DECELERATE 0.5; } + program { + name: "focus_in,ecdb"; + signal: "ecdb,focus,in"; + action: STATE_SET "visible" 0.0; + source: "ecdb"; + target: "focus_clip"; + transition: DECELERATE 0.5; + } + program { name: "unclick"; signal: "mouse,clicked,1"; diff --git a/experimental/ecdb/trunk/data/themes/default/groups/entry.edc b/experimental/ecdb/trunk/data/themes/default/groups/entry.edc index 6f957d07..47815ab9 100644 --- a/experimental/ecdb/trunk/data/themes/default/groups/entry.edc +++ b/experimental/ecdb/trunk/data/themes/default/groups/entry.edc @@ -90,20 +90,29 @@ group { programs { program { - name: "focus1"; + name: "focus_set"; action: FOCUS_SET; - signal: "mouse,down,*"; - source: "*"; target: "label"; } program { - name: "focus2"; + name: "focus_in,mouse"; action: STATE_SET "focused" 0.0; signal: "mouse,down,*"; source: "*"; target: "entry_focus"; transition: DECELERATE 0.5; + after: "focus_set"; + } + + program { + name: "focus_in,ecdb"; + action: STATE_SET "focused" 0.0; + signal: "ecdb,focus,in"; + source: "ecdb"; + target: "entry_focus"; + transition: DECELERATE 0.5; + after: "focus_set"; } program { diff --git a/experimental/ecdb/trunk/src/ecdb.h b/experimental/ecdb/trunk/src/ecdb.h index bd395bb8..f34d0a17 100644 --- a/experimental/ecdb/trunk/src/ecdb.h +++ b/experimental/ecdb/trunk/src/ecdb.h @@ -28,15 +28,6 @@ #include #include -#undef FREE -#define FREE(dat) \ -{ \ - if (dat) { free(dat); dat = NULL; } \ -} - -#undef __UNUSED__ -#define __UNUSED__ __attribute__ ((unused)) - /* ECDB Global Variables */ typedef struct _Ecdb_Main Ecdb_Main; struct _Ecdb_Main diff --git a/experimental/ecdb/trunk/src/ecdb_common.h b/experimental/ecdb/trunk/src/ecdb_common.h index 3c9f01f6..71a6346a 100644 --- a/experimental/ecdb/trunk/src/ecdb_common.h +++ b/experimental/ecdb/trunk/src/ecdb_common.h @@ -2,6 +2,18 @@ #ifndef ECDB_COMMON_H #define ECDB_COMMON_H +#undef FREE +#define FREE(dat) \ +{ \ + if (dat) { free(dat); dat = NULL; } \ +} + +#undef __UNUSED__ +#define __UNUSED__ __attribute__ ((unused)) + +#define IN 1 +#define OUT 2 + /* Typdefs */ typedef struct burn_source BurnSource; typedef struct burn_disc BurnDisc; diff --git a/experimental/ecdb/trunk/src/ecdb_gui.c b/experimental/ecdb/trunk/src/ecdb_gui.c index 9c94cdb8..821391e4 100644 --- a/experimental/ecdb/trunk/src/ecdb_gui.c +++ b/experimental/ecdb/trunk/src/ecdb_gui.c @@ -19,6 +19,7 @@ static void ecdb_welcome_page_show(void); static void ecdb_erase_page_show(void); static void ecdb_burn_image_page_show(void); static void ecdb_page_hide(const char *pname); +static void ecdb_filelist_focus_handle(int action, Evas_Object *fl); static void ecdb_cb_enter(Ecore_Evas *ee) @@ -47,6 +48,43 @@ ecdb_cb_resize(Ecore_Evas *ee) evas_object_resize(gui, w, h); } +static void ecdb_filelist_focus_handle(int action, Evas_Object *fl) +{ + static Evas_Object *old_focus; + Evas_Object *gui; + + if (action == IN) + { + old_focus = evas_focus_get(ecore_evas_get(em->main_win_ee)); + edje_object_signal_emit(old_focus, "ecdb,focus,out", "ecdb"); + evas_object_focus_set(fl, 1); + } + else if (old_focus) + { + edje_object_signal_emit(old_focus, "ecdb,focus,in", "ecdb"); + evas_object_focus_set(old_focus, 1); + old_focus = NULL; + + gui = evas_object_name_find(ecore_evas_get(em->main_win_ee), "gui"); + edje_object_signal_emit(gui, "ecdb,filelist_overlay,deactivate", "ecdb"); + edje_object_part_text_set(gui, "filelist_overlay_text", NULL); + } +} + +static void +_cb_filelist_mouse_in(void *data, Evas *e __UNUSED__, Evas_Object *eo, + void *ev_data __UNUSED__) +{ + ecdb_filelist_focus_handle(IN, eo); +} + +static void +_cb_filelist_mouse_out(void *data, Evas *e __UNUSED__, Evas_Object *eo, + void *ev_data __UNUSED__) +{ + ecdb_filelist_focus_handle(OUT, eo); +} + static void _cb_filelist_mouse_down(void *data, Evas *e __UNUSED__, Evas_Object *eo, void *ev_data __UNUSED__) @@ -275,7 +313,7 @@ ecdb_handle_typebuf(Evas_Object *gui) FREE(dir); } - edje_object_signal_emit(gui, "deactivate", "ecdb"); + edje_object_signal_emit(gui, "ecdb,filelist_overlay,deactivate", "ecdb"); edje_object_part_text_set(gui, "filelist_overlay_text", NULL); return; } @@ -317,13 +355,12 @@ ecdb_cb_controls_focused(void *data, Evas_Object *o, const char *emission, const char *source) { static char *old_source; - Evas_Object *unsel; + Evas_Object *eo; if ((old_source) && (strcmp(old_source, source))) { - unsel = evas_object_name_find(ecore_evas_get(em->main_win_ee), - old_source); - edje_object_signal_emit(unsel, "ecdb,focus,out", "ecdb"); + eo = evas_object_name_find(ecore_evas_get(em->main_win_ee), old_source); + edje_object_signal_emit(eo, "ecdb,focus,out", "ecdb"); FREE(old_source); old_source = strdup(source); } @@ -331,6 +368,10 @@ ecdb_cb_controls_focused(void *data, Evas_Object *o, const char *emission, { old_source = strdup(source); } + + // Send focus to the freshly clicked widget + eo = evas_object_name_find(ecore_evas_get(em->main_win_ee), source); + evas_object_focus_set(eo, 1); } static void @@ -657,6 +698,10 @@ ecdb_filelist_show(void) _cb_filelist_mouse_down, gui); evas_object_event_callback_add(swallow, EVAS_CALLBACK_KEY_DOWN, _cb_filelist_key_down, gui); + evas_object_event_callback_add(swallow, EVAS_CALLBACK_MOUSE_IN, + _cb_filelist_mouse_in, gui); + evas_object_event_callback_add(swallow, EVAS_CALLBACK_MOUSE_OUT, + _cb_filelist_mouse_out, gui); evas_object_show(swallow); }