From: Enlightenment S. <no-...@en...> - 2009-04-25 12:40:03
|
Log: better container for the thumbnails Author: urandom Date: 2009-04-25 05:39:58 -0700 (Sat, 25 Apr 2009) New Revision: 40368 Modified: trunk/PROTO/image-viewer/data/theme/default.edc trunk/PROTO/image-viewer/src/bin/main.c Modified: trunk/PROTO/image-viewer/data/theme/default.edc =================================================================== --- trunk/PROTO/image-viewer/data/theme/default.edc 2009-04-25 12:23:56 UTC (rev 40367) +++ trunk/PROTO/image-viewer/data/theme/default.edc 2009-04-25 12:39:58 UTC (rev 40368) @@ -5,7 +5,6 @@ group { name: "iv/main"; script { public controls_visible; - public previews_visible; } parts { part { name: "iv.swallow.image"; @@ -111,59 +110,13 @@ source: ""; script { set_int(controls_visible, 0); - set_int(previews_visible, 0); } } - program { name: "set_previews_show"; - script { - set_int(previews_visible, 1); - } - } - program { name: "set_previews_hide"; - script { - set_int(previews_visible, 0); - } - } program { name: "upper_edge_in"; signal: "mouse,in"; source: "upper_edge"; - action: SIGNAL_EMIT "upper_edge_in" "iv"; - after: "upper_edge_in_1"; + action: SIGNAL_EMIT "iv,state,toggle_previews" "iv"; } - program { name: "upper_edge_in_1"; - script { - if (get_int(previews_visible) == 0) { - run_program(PROGRAM:"show_previews"); - } - } - } - program { name: "toggle_previews"; - signal: "iv,state,toggle_previews"; - source: "iv"; - script { - if (get_int(previews_visible) == 0) { - run_program(PROGRAM:"show_previews"); - } else { - run_program(PROGRAM:"hide_previews"); - } - } - } - program { name: "show_previews"; - signal: "iv,state,show_previews"; - source: "iv"; - transition: ACCELERATE 0.2; - action: STATE_SET "active" 0.0; - target: "iv.swallow.previews"; - after: "set_previews_show"; - } - program { name: "hide_previews"; - signal: "iv,state,hide_previews"; - source: "iv"; - action: STATE_SET "default" 0.0; - transition: DECELERATE 0.1; - target: "iv.swallow.previews"; - after: "set_previews_hide"; - } program { name: "set_controls_show"; script { @@ -178,10 +131,6 @@ program { name: "lower_edge_in"; signal: "mouse,in"; source: "lower_edge"; - action: SIGNAL_EMIT "lower_edge_in" "iv"; - after: "lower_edge_in_1"; - } - program { name: "lower_edge_in_1"; script { if (get_int(controls_visible) == 0) { run_program(PROGRAM:"show_controls"); @@ -487,6 +436,36 @@ } } + group { name: "iv/preview/box"; + parts { + part { name: "iv.box.content"; + type: BOX; + description { state: "default" 0.0; + box { + align: 0.0 0.0; + layout: "horizontal_flow"; + min: 1 1; + } + } + } + } + } + + group { name: "iv/preview/thumb/border"; + min: 90 60; + max: 90 60; + parts { + part { name :"iv.swallow.icon"; + type: SWALLOW; + description { state: "default" 0.0; + min: 80 53; + max: 80 53; + align: 0.5 0.5; + } + } + } + } + group { name: "elm/win/inwin/shadow"; images { image: "inwin_base.png" COMP; @@ -563,6 +542,81 @@ } } } + group { name: "elm/win/inwin/shadow_fill"; + images { + image: "inwin_base.png" COMP; + image: "inwin_hilight.png" COMP; + } + parts { + part { name: "base"; + type: RECT; + mouse_events: 1; + description { state: "default" 0.0; + color: 0 0 0 0; + } + description { state: "visible" 0.0; + inherit: "default" 1.0; + color: 0 0 0 128; + } + } + part { name: "pop"; + mouse_events: 1; + description { state: "default" 0.0; + rel1.to: "elm.swallow.content"; + rel1.offset: -15 -15; + rel2.to: "elm.swallow.content"; + rel2.offset: 14 14; + image { + normal: "inwin_base.png"; + border: 14 14 14 14; + } + color: 255 255 255 200; + image.middle: SOLID; + } + } + part { name: "popover"; + mouse_events: 0; + description { state: "default" 0.0; + rel1 { + offset: 10 10; + to: "pop"; + } + rel2 { + relative: 1.0 0.5; + offset: -11 0; + to: "pop"; + } + image { + normal: "inwin_hilight.png"; + border: 4 4 4 0; + } + } + } + part { name: "elm.swallow.content"; + type: SWALLOW; + description { state: "default" 0.0; + rel1.relative: 0.1 0.1; + rel2.relative: 0.9 0.9; + } + } + } + programs { + program { name: "show"; + signal: "elm,action,show"; + source: "elm"; + action: STATE_SET "visible" 0.0; +// transition: DECELERATE 0.5; + target: "base"; + } + program { name: "hide"; + signal: "elm,action,hide"; + source: "elm"; + action: STATE_SET "default" 0.0; +// transition: DECELERATE 0.5; + target: "base"; + } + } + } group { name: "elm/bg/base/checkers"; images { image: "bg.png" COMP; Modified: trunk/PROTO/image-viewer/src/bin/main.c =================================================================== --- trunk/PROTO/image-viewer/src/bin/main.c 2009-04-25 12:23:56 UTC (rev 40367) +++ trunk/PROTO/image-viewer/src/bin/main.c 2009-04-25 12:39:58 UTC (rev 40368) @@ -1,5 +1,5 @@ /* - * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2,t0,(0 + * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2,t0,(0,W4 */ #include <Eet.h> #include <Ecore.h> @@ -55,16 +55,11 @@ Ecore_Timer *slideshow_timer; struct { - Evas_Object *win, *ly, *img, *scroller; - Evas_Object *prev_img, *next_img, *bg; - Evas_Object *controls, *file_label; - Evas_Object *next_bt, *prev_bt; - Evas_Object *hoversel; - Evas_Object *settings_bt, *slideshow_bt; - Evas_Object *settings_win; + Evas_Object *win, *ly, *img, *scroller, *prev_img, *next_img, *bg; + Evas_Object *controls, *file_label, *next_bt, *prev_bt; + Evas_Object *hoversel, *settings_bt, *slideshow_bt, *settings_win; #ifdef HAVE_ETHUMB - /* XXX: Replace with carousel when ready */ - Evas_Object *toolbar; + Evas_Object *preview_win, *preview_scroller, *preview_box; #endif } gui; @@ -95,8 +90,6 @@ Eina_List *preview_files; Eina_Hash *preview_items; Ethumb *ethumb; - - Eina_Bool thumb_generator; #endif }; @@ -563,12 +556,11 @@ } static void -on_toolbar_change(void *data, Evas_Object *obj, void *event_info) +on_thumb_click(void *data, Evas_Object *obj, void *event_info) { #ifdef HAVE_ETHUMB - Evas_Object *thumb = data; - IV *iv = evas_object_data_get(thumb, "iv"); - const char *file = evas_object_data_get(thumb, "iv_file"); + IV *iv = data; + const char *file = evas_object_data_get(obj, "iv_file"); if (iv->flags.ignore_preview_change) { @@ -602,7 +594,6 @@ iv->idler = ecore_idler_add(on_idler, iv); iv->flags.add_previews = (iv->preview_files->next) ? EINA_TRUE : EINA_FALSE; - iv->thumb_generator = EINA_FALSE; #endif } @@ -690,14 +681,25 @@ iv->idler = ecore_idler_add(on_idler, iv); } +static void +preview_box_size(IV *iv) +{ +#ifdef HAVE_ETHUMB + Evas_Coord w, ww, hh; + + evas_object_size_hint_min_get( + edje_object_part_object_get(iv->gui.preview_box, "iv.box.content"), + &ww, &hh); + if (ww && hh) + evas_object_size_hint_min_set(iv->gui.preview_box, ww, hh); +#endif +} + static int on_idler(void *data) { IV *iv = data; Eina_Bool renew = EINA_FALSE; -#ifdef HAVE_ETHUMB - Elm_Toolbar_Item *item; -#endif if (iv->dirs) { @@ -770,38 +772,49 @@ } #ifdef HAVE_ETHUMB - if (!iv->thumb_generator && iv->thumb_path) + if (iv->thumb_path && iv->gui.preview_box) { Evas_Object *thumb; IV_Thumb_Info *info; EINA_LIST_FREE(iv->thumb_path, info) { - Elm_Toolbar_Item *item; + Evas_Object *o; + Evas_Coord w, h; - thumb = elm_icon_add(iv->gui.toolbar); + thumb = elm_icon_add(iv->gui.preview_win); elm_icon_file_set(thumb, info->thumb_path, NULL); - evas_object_data_set(thumb, "iv", iv); evas_object_data_set(thumb, "iv_file", info->file); - evas_object_show(thumb); - item = elm_toolbar_item_add(iv->gui.toolbar, thumb, NULL, on_toolbar_change, thumb); - eina_hash_add(iv->preview_items, info->file, item); + evas_object_smart_callback_add(thumb, "clicked", + on_thumb_click, iv); + o = edje_object_add(evas_object_evas_get(iv->gui.preview_win)); + edje_object_file_set(o, iv->theme_file, "iv/preview/thumb/border"); + edje_object_part_swallow(o, "iv.swallow.icon", thumb); + evas_object_show(o); + edje_object_size_min_get(o, &w, &h); + evas_object_resize(o, w, h); + + edje_object_part_box_append(iv->gui.preview_box, "iv.box.content", o); + eina_hash_add(iv->preview_items, info->file, thumb); + if (iv->flags.first_preview) { iv->flags.ignore_preview_change = EINA_TRUE; - elm_toolbar_item_select(item); + //elm_toolbar_item_select(item); iv->flags.first_preview = EINA_FALSE; } eina_stringshare_del(info->thumb_path); free(info); } - + preview_box_size(iv); } if (iv->flags.add_previews) { + Eina_List *l; + const char *file; int rc; if (!iv->preview_files) @@ -810,25 +823,21 @@ iv->flags.first_preview = EINA_TRUE; } - if (!iv->thumb_generator) + EINA_LIST_FOREACH(iv->preview_files, l, file) { - Eina_List *l; - const char *file; + if (l->next) + iv->preview_files = l->next; - iv->thumb_generator = EINA_TRUE; - EINA_LIST_FOREACH(iv->preview_files, l, file) - { - iv->preview_files = l; + if (!ethumb_file_set(iv->ethumb, file, NULL)) + continue; - if ((!ethumb_file_set(iv->ethumb, file, NULL)) || - (ethumb_exists(iv->ethumb))) - continue; + if (ethumb_exists(iv->ethumb)) + on_thumb_generate(iv->ethumb, iv); + else if (!ethumb_generate(iv->ethumb, on_thumb_generate, iv)) + continue; - ethumb_generate(iv->ethumb, on_thumb_generate, iv); - - break; - } - + renew = EINA_TRUE; + break; } } #endif @@ -869,9 +878,11 @@ #ifdef HAVE_ETHUMB iv->flags.ignore_preview_change = EINA_TRUE; + /* item = eina_hash_find(iv->preview_items, iv->files->data); if (item) elm_toolbar_item_select(item); + */ #endif } } @@ -906,9 +917,11 @@ #ifdef HAVE_ETHUMB iv->flags.ignore_preview_change = EINA_TRUE; + /* item = eina_hash_find(iv->preview_items, iv->files->data); if (item) elm_toolbar_item_select(item); + */ #endif } } @@ -989,6 +1002,40 @@ } } +static void +toggle_previews(IV *iv) +{ +#ifdef HAVE_ETHUMB + if (!iv->gui.preview_win) + { + iv->gui.preview_win = elm_win_inwin_add(iv->gui.win); + elm_object_style_set(iv->gui.preview_win, "shadow_fill"); + evas_object_size_hint_weight_set(elm_bg_add(iv->gui.preview_win), 1.0, 1.0); + + iv->gui.preview_scroller = elm_scroller_add(iv->gui.preview_win); + evas_object_size_hint_weight_set(iv->gui.preview_scroller, 1.0, 1.0); + evas_object_show(iv->gui.preview_scroller); + + iv->gui.preview_box = edje_object_add(evas_object_evas_get(iv->gui.win)); + edje_object_file_set(iv->gui.preview_box, iv->theme_file, "iv/preview/box"); + elm_scroller_content_set(iv->gui.preview_scroller, iv->gui.preview_box); + evas_object_show(iv->gui.preview_box); + + elm_win_inwin_content_set(iv->gui.preview_win, iv->gui.preview_scroller); + } + + if (evas_object_visible_get(iv->gui.preview_win)) + evas_object_hide(iv->gui.preview_win); + else + { + elm_win_inwin_activate(iv->gui.preview_win); + preview_box_size(iv); + if (!iv->idler) + iv->idler = ecore_idler_add(on_idler, iv); + } +#endif +} + static int on_slideshow_tick(void *data) { @@ -1196,8 +1243,7 @@ #ifdef HAVE_ETHUMB if (!strcmp(ev->keyname, "F9")) - edje_object_signal_emit(elm_layout_edje_get(iv->gui.ly), - "iv,state,toggle_previews", "iv"); + toggle_previews(iv); #endif if (iv->flags.slideshow) @@ -1257,15 +1303,6 @@ elm_layout_content_set(iv->gui.ly, "iv.swallow.image", o); iv->gui.scroller = o; -#ifdef HAVE_ETHUMB - o = elm_toolbar_add(iv->gui.ly); - evas_object_size_hint_weight_set(o, 0.0, 0.0); - evas_object_size_hint_align_set(o, -1.0, 0.0); - elm_layout_content_set(iv->gui.ly, "iv.swallow.previews", o); - evas_object_show(o); - iv->gui.toolbar = o; -#endif - o = elm_layout_add(iv->gui.ly); elm_layout_file_set(o, buf, "iv/controls"); evas_object_size_hint_weight_set(o, 1.0, 1.0); |