From a9e9965cdb4e112836a3b9e46277b24b4d2577dd Mon Sep 17 00:00:00 2001 From: Jaime Thomas Date: Sat, 20 Sep 2008 01:00:13 +0000 Subject: [PATCH] Buttons are pretty decent looking now, with focus too. --- .../trunk/data/themes/default/default.edc | 1 + .../data/themes/default/groups/icons.edc | 127 ++++++++++++++++++ experimental/ecdb/trunk/src/ecdb_gui.c | 36 +++-- experimental/ecdb/trunk/src/ecdb_misc.c | 10 +- 4 files changed, 161 insertions(+), 13 deletions(-) create mode 100644 experimental/ecdb/trunk/data/themes/default/groups/icons.edc diff --git a/experimental/ecdb/trunk/data/themes/default/default.edc b/experimental/ecdb/trunk/data/themes/default/default.edc index b838cb0b..f0f43890 100644 --- a/experimental/ecdb/trunk/data/themes/default/default.edc +++ b/experimental/ecdb/trunk/data/themes/default/default.edc @@ -9,4 +9,5 @@ collections { #include "groups/window.edc" #include "groups/welcome_page.edc" #include "groups/button.edc" + #include "groups/icons.edc" } diff --git a/experimental/ecdb/trunk/data/themes/default/groups/icons.edc b/experimental/ecdb/trunk/data/themes/default/groups/icons.edc new file mode 100644 index 00000000..7b0aecbd --- /dev/null +++ b/experimental/ecdb/trunk/data/themes/default/groups/icons.edc @@ -0,0 +1,127 @@ +group { + name: "ecdb/burn_data"; + min: 32 32; + + parts { + part { + name: "image"; + type: IMAGE; + + description { + state: "default" 0.0; + min: 32 32; + max: 32 32; + + rel1 { + relative: 0.0 0.0; + offset: 0 0; + } + + rel2 { + relative: 1.0 1.0; + offset: -1 -1; + } + + image { + normal: "drive_optical.png"; + } + } + } + } +} + +group { + name: "ecdb/burn_audio"; + min: 32 32; + + parts { + part { + name: "image"; + type: IMAGE; + + description { + state: "default" 0.0; + min: 32 32; + max: 32 32; + + rel1 { + relative: 0.0 0.0; + offset: 0 0; + } + + rel2 { + relative: 1.0 1.0; + offset: -1 -1; + } + + image { + normal: "audio.png"; + } + } + } + } +} + +group { + name: "ecdb/erase"; + min: 32 32; + + parts { + part { + name: "image"; + type: IMAGE; + + description { + state: "default" 0.0; + min: 32 32; + max: 32 32; + + rel1 { + relative: 0.0 0.0; + offset: 0 0; + } + + rel2 { + relative: 1.0 1.0; + offset: -1 -1; + } + + image { + normal: "clear.png"; + } + } + } + } +} + +group { + name: "ecdb/burn_image"; + min: 32 32; + + parts { + part { + name: "image"; + type: IMAGE; + + description { + state: "default" 0.0; + min: 32 32; + max: 32 32; + + rel1 { + relative: 0.0 0.0; + offset: 0 0; + } + + rel2 { + relative: 1.0 1.0; + offset: -1 -1; + } + + image { + normal: "iso.png"; + } + } + } + } +} diff --git a/experimental/ecdb/trunk/src/ecdb_gui.c b/experimental/ecdb/trunk/src/ecdb_gui.c index b597fd9d..16a322fc 100644 --- a/experimental/ecdb/trunk/src/ecdb_gui.c +++ b/experimental/ecdb/trunk/src/ecdb_gui.c @@ -120,7 +120,11 @@ _cb_filelist_key_down(void *data, Evas *e __UNUSED__, else if ((ek->keyname) && (*ek->keyname) && (!ek->key[1])) append = ek->keyname; else + { + if (text) + free(text); return; + } if (!text) text = strdup(append); @@ -202,7 +206,7 @@ ecdb_create_main_gui(void) edje_object_part_geometry_get(gui, "filelist", &x, &y, &w, &h); evas_object_move(swallow, x, y); - evas_object_resize(swallow, x, y); + evas_object_resize(swallow, w, h); edje_object_part_swallow(gui, "filelist", swallow); evas_object_event_callback_add(swallow, EVAS_CALLBACK_MOUSE_DOWN, _cb_filelist_mouse_down, gui); @@ -229,23 +233,24 @@ ecdb_create_main_gui(void) int i; char *names[] = {"b1","b2","b3","b4"}; char *labels[] = {"Burn Data CD", "Burn Audio CD", "Copy Disc", - "Erase Re-writable disc"}; - char *icons[] = {"drive_optical.png", "audio.png", "iso.png", - "clear.png"}; + "Erase Re-writable Disc"}; + char *icons[] = {"ecdb/burn_data", "ecdb/burn_audio", "ecdb/burn_image", + "ecdb/erase"}; for (i = 0; i < 4; i++) { b = edje_object_add(ecore_evas_get(em->main_win_ee)); evas_object_name_set(b, names[i]); edje_object_file_set(b, em->theme_path, "ecdb/button"); - edje_object_part_geometry_get(welcome_page, names[i], - &x, &y, &w, &h); + edje_object_part_geometry_get(welcome_page, names[i], &x, &y, &w, &h); edje_object_part_text_set(b, "label", labels[i]); - ecdb_button_icon_swallow(ecore_evas_get(em->main_win_ee), b, - icons[i]); evas_object_move(b, x, y); evas_object_resize(b, w, h); edje_object_part_swallow(welcome_page, names[i], b); evas_object_show(b); + + /* Place this after */ + ecdb_button_icon_swallow(ecore_evas_get(em->main_win_ee), b, + icons[i]); } return TRUE; @@ -393,6 +398,17 @@ static void ecdb_cb_welcome_page(void *data, Evas_Object *o, const char *emission, const char *source) { - printf("callback from %s\n", source); - printf("callback %s\n", emission); + static char *old_source; + Evas_Object *unsel; + + 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,button,focus,out", "ecdb"); + free(old_source); + old_source = strdup(source); + } + else if (!old_source) + old_source = strdup(source); } diff --git a/experimental/ecdb/trunk/src/ecdb_misc.c b/experimental/ecdb/trunk/src/ecdb_misc.c index 26991ffe..6e25f547 100644 --- a/experimental/ecdb/trunk/src/ecdb_misc.c +++ b/experimental/ecdb/trunk/src/ecdb_misc.c @@ -127,11 +127,15 @@ void ecdb_button_icon_swallow(Evas *e, Evas_Object *b, const char *iname) { Evas_Object *icon; + Evas_Coord x, y, w, h; - icon = evas_object_image_add(e); - - evas_object_image_file_set(icon, em->theme_path, iname); + icon = edje_object_add(e); + edje_object_file_set(icon, em->theme_path, iname); + edje_object_part_geometry_get(b, "icon", &x, &y, &w, &h); + evas_object_move(icon, x, y); + evas_object_resize(icon, w, h); edje_object_part_swallow(b, "icon", icon); + evas_object_show(icon); }