From: Carsten Haitzler Date: Fri, 19 Dec 2008 04:26:24 +0000 (+0000) Subject: tests for hoversel (and photo) and toolbar and more complete toolbar. X-Git-Tag: v1.0.0~5532 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=abcf3280ca2ba51d3f6877c95e57c9b98554278b;p=platform%2Fupstream%2Felementary.git tests for hoversel (and photo) and toolbar and more complete toolbar. SVN revision: 38222 --- diff --git a/src/bin/test.c b/src/bin/test.c index 4943ebb..ce1cd75 100644 --- a/src/bin/test.c +++ b/src/bin/test.c @@ -1248,9 +1248,48 @@ my_bt_17(void *data, Evas_Object *obj, void *event_info) } static void +tb_1(void *data, Evas_Object *obj, void *event_info) +{ + char buf[PATH_MAX]; + snprintf(buf, sizeof(buf), "%s/images/panel_01.jpg", PACKAGE_DATA_DIR); + elm_photo_file_set(data, buf); +} + +static void +tb_2(void *data, Evas_Object *obj, void *event_info) +{ + char buf[PATH_MAX]; + snprintf(buf, sizeof(buf), "%s/images/rock_01.jpg", PACKAGE_DATA_DIR); + elm_photo_file_set(data, buf); +} + +static void +tb_3(void *data, Evas_Object *obj, void *event_info) +{ + char buf[PATH_MAX]; + snprintf(buf, sizeof(buf), "%s/images/wood_01.jpg", PACKAGE_DATA_DIR); + elm_photo_file_set(data, buf); +} + +static void +tb_4(void *data, Evas_Object *obj, void *event_info) +{ + char buf[PATH_MAX]; + snprintf(buf, sizeof(buf), "%s/images/sky_03.jpg", PACKAGE_DATA_DIR); + elm_photo_file_set(data, buf); +} + +static void +tb_5(void *data, Evas_Object *obj, void *event_info) +{ + elm_photo_file_set(data, NULL); +} + +static void my_bt_18(void *data, Evas_Object *obj, void *event_info) { - Evas_Object *win, *bg, *bx, *tb, *ic; + Evas_Object *win, *bg, *bx, *tb, *ic, *ph; + Evas_Object *ph1, *ph2, *ph3, *ph4; char buf[PATH_MAX]; win = elm_win_add(NULL, "toolbar", ELM_WIN_BASIC); @@ -1270,34 +1309,174 @@ my_bt_18(void *data, Evas_Object *obj, void *event_info) tb = elm_toolbar_add(win); evas_object_size_hint_weight_set(tb, 0.0, 0.0); evas_object_size_hint_align_set(tb, -1.0, 0.0); + + ph1 = elm_photo_add(win); + ph2 = elm_photo_add(win); + ph3 = elm_photo_add(win); + ph4 = elm_photo_add(win); ic = elm_icon_add(win); snprintf(buf, sizeof(buf), "%s/images/logo_small.png", PACKAGE_DATA_DIR); elm_icon_file_set(ic, buf, NULL); - elm_toolbar_item_add(tb, ic, "Hello", NULL, NULL); + elm_toolbar_item_add(tb, ic, "Hello", tb_1, ph1); ic = elm_icon_add(win); snprintf(buf, sizeof(buf), "%s/images/logo_small.png", PACKAGE_DATA_DIR); elm_icon_file_set(ic, buf, NULL); - elm_toolbar_item_add(tb, ic, "World", NULL, NULL); + elm_toolbar_item_add(tb, ic, "World", tb_2, ph1); ic = elm_icon_add(win); snprintf(buf, sizeof(buf), "%s/images/logo_small.png", PACKAGE_DATA_DIR); elm_icon_file_set(ic, buf, NULL); - elm_toolbar_item_add(tb, ic, "Here", NULL, NULL); + elm_toolbar_item_add(tb, ic, "Here", tb_3, ph4); ic = elm_icon_add(win); snprintf(buf, sizeof(buf), "%s/images/logo_small.png", PACKAGE_DATA_DIR); elm_icon_file_set(ic, buf, NULL); - elm_toolbar_item_add(tb, ic, "Comes", NULL, NULL); + elm_toolbar_item_add(tb, ic, "Comes", tb_4, ph4); ic = elm_icon_add(win); snprintf(buf, sizeof(buf), "%s/images/logo_small.png", PACKAGE_DATA_DIR); elm_icon_file_set(ic, buf, NULL); - elm_toolbar_item_add(tb, ic, "Elementary", NULL, NULL); + elm_toolbar_item_add(tb, ic, "Elementary", tb_5, ph4); elm_box_pack_end(bx, tb); evas_object_show(tb); + + tb = elm_table_add(win); +// elm_table_homogenous_set(tb, 1); + evas_object_size_hint_weight_set(tb, 0.0, 1.0); + evas_object_size_hint_align_set(tb, -1.0, -1.0); + + ph = ph1; + elm_photo_size_set(ph, 40); + snprintf(buf, sizeof(buf), "%s/images/plant_01.jpg", PACKAGE_DATA_DIR); + elm_photo_file_set(ph, buf); + evas_object_size_hint_weight_set(ph, 1.0, 1.0); + evas_object_size_hint_align_set(ph, 0.5, 0.5); + elm_table_pack(tb, ph, 0, 0, 1, 1); + evas_object_show(ph); + + ph = ph2; + elm_photo_size_set(ph, 80); + evas_object_size_hint_weight_set(ph, 1.0, 1.0); + evas_object_size_hint_align_set(ph, 0.5, 0.5); + elm_table_pack(tb, ph, 1, 0, 1, 1); + evas_object_show(ph); + + ph = ph3; + elm_photo_size_set(ph, 20); + snprintf(buf, sizeof(buf), "%s/images/sky_01.jpg", PACKAGE_DATA_DIR); + elm_photo_file_set(ph, buf); + evas_object_size_hint_weight_set(ph, 1.0, 1.0); + evas_object_size_hint_align_set(ph, 0.5, 0.5); + elm_table_pack(tb, ph, 0, 1, 1, 1); + evas_object_show(ph); + + ph = ph4; + elm_photo_size_set(ph, 60); + snprintf(buf, sizeof(buf), "%s/images/sky_02.jpg", PACKAGE_DATA_DIR); + elm_photo_file_set(ph, buf); + evas_object_size_hint_weight_set(ph, 1.0, 1.0); + evas_object_size_hint_align_set(ph, 0.5, 0.5); + elm_table_pack(tb, ph, 1, 1, 1, 1); + evas_object_show(ph); + + elm_box_pack_end(bx, tb); + evas_object_show(tb); + + evas_object_resize(win, 320, 300); + + evas_object_show(win); +} + +static void +my_bt_19(void *data, Evas_Object *obj, void *event_info) +{ + Evas_Object *win, *bg, *bx, *bt, *ic; + char buf[PATH_MAX]; + + win = elm_win_add(NULL, "hoversel", ELM_WIN_BASIC); + elm_win_title_set(win, "Hoversel"); + elm_win_autodel_set(win, 1); + + bg = elm_bg_add(win); + elm_win_resize_object_add(win, bg); + evas_object_size_hint_weight_set(bg, 1.0, 1.0); + evas_object_show(bg); + + bx = elm_box_add(win); + elm_win_resize_object_add(win, bx); + evas_object_size_hint_weight_set(bx, 1.0, 1.0); + evas_object_show(bx); + + bt = elm_hoversel_add(win); + elm_hoversel_hover_parent_set(bt, win); + elm_hoversel_label_set(bt, "Labels"); + elm_hoversel_item_add(bt, "Item 1", NULL, ELM_ICON_NONE, NULL, NULL); + elm_hoversel_item_add(bt, "Item 2", NULL, ELM_ICON_NONE, NULL, NULL); + elm_hoversel_item_add(bt, "Item 3", NULL, ELM_ICON_NONE, NULL, NULL); + elm_hoversel_item_add(bt, "Item 4", NULL, ELM_ICON_NONE, NULL, NULL); + evas_object_size_hint_weight_set(bt, 0.0, 0.0); + evas_object_size_hint_align_set(bt, 0.5, 0.5); + elm_box_pack_end(bx, bt); + evas_object_show(bt); + + bt = elm_hoversel_add(win); + elm_hoversel_hover_parent_set(bt, win); + elm_hoversel_label_set(bt, "Some Icons"); + elm_hoversel_item_add(bt, "Item 1", NULL, ELM_ICON_NONE, NULL, NULL); + elm_hoversel_item_add(bt, "Item 2", NULL, ELM_ICON_NONE, NULL, NULL); + elm_hoversel_item_add(bt, "Item 3", "home", ELM_ICON_STANDARD, NULL, NULL); + elm_hoversel_item_add(bt, "Item 4", "close", ELM_ICON_STANDARD, NULL, NULL); + evas_object_size_hint_weight_set(bt, 0.0, 0.0); + evas_object_size_hint_align_set(bt, 0.5, 0.5); + elm_box_pack_end(bx, bt); + evas_object_show(bt); + + bt = elm_hoversel_add(win); + elm_hoversel_hover_parent_set(bt, win); + elm_hoversel_label_set(bt, "All Icons"); + elm_hoversel_item_add(bt, "Item 1", "apps", ELM_ICON_STANDARD, NULL, NULL); + elm_hoversel_item_add(bt, "Item 2", "arrow_down", ELM_ICON_STANDARD, NULL, NULL); + elm_hoversel_item_add(bt, "Item 3", "home", ELM_ICON_STANDARD, NULL, NULL); + elm_hoversel_item_add(bt, "Item 4", "close", ELM_ICON_STANDARD, NULL, NULL); + evas_object_size_hint_weight_set(bt, 0.0, 0.0); + evas_object_size_hint_align_set(bt, 0.5, 0.5); + elm_box_pack_end(bx, bt); + evas_object_show(bt); + + bt = elm_hoversel_add(win); + elm_hoversel_hover_parent_set(bt, win); + elm_hoversel_label_set(bt, "All Icons"); + elm_hoversel_item_add(bt, "Item 1", "apps", ELM_ICON_STANDARD, NULL, NULL); + snprintf(buf, sizeof(buf), "%s/images/sky_02.jpg", PACKAGE_DATA_DIR); + elm_hoversel_item_add(bt, "Item 2", buf, ELM_ICON_FILE, NULL, NULL); + elm_hoversel_item_add(bt, "Item 3", "home", ELM_ICON_STANDARD, NULL, NULL); + elm_hoversel_item_add(bt, "Item 4", "close", ELM_ICON_STANDARD, NULL, NULL); + evas_object_size_hint_weight_set(bt, 0.0, 0.0); + evas_object_size_hint_align_set(bt, 0.5, 0.5); + elm_box_pack_end(bx, bt); + evas_object_show(bt); + + bt = elm_hoversel_add(win); + elm_hoversel_hover_parent_set(bt, win); + elm_hoversel_label_set(bt, "Icon + Label"); + + ic = elm_icon_add(win); + snprintf(buf, sizeof(buf), "%s/images/sky_03.jpg", PACKAGE_DATA_DIR); + elm_icon_file_set(ic, buf, NULL); + elm_hoversel_icon_set(bt, ic); + evas_object_show(ic); + + elm_hoversel_item_add(bt, "Item 1", "apps", ELM_ICON_STANDARD, NULL, NULL); + elm_hoversel_item_add(bt, "Item 2", "arrow_down", ELM_ICON_STANDARD, NULL, NULL); + elm_hoversel_item_add(bt, "Item 3", "home", ELM_ICON_STANDARD, NULL, NULL); + elm_hoversel_item_add(bt, "Item 4", "close", ELM_ICON_STANDARD, NULL, NULL); + evas_object_size_hint_weight_set(bt, 0.0, 0.0); + evas_object_size_hint_align_set(bt, 0.5, 0.5); + elm_box_pack_end(bx, bt); + evas_object_show(bt); evas_object_resize(win, 320, 300); @@ -1523,6 +1702,13 @@ my_win_main(void) elm_box_pack_end(bx, bt); evas_object_show(bt); + bt = elm_button_add(win); + elm_button_label_set(bt, "Hoversel"); + evas_object_smart_callback_add(bt, "clicked", my_bt_19, NULL); + evas_object_size_hint_align_set(bt, -1.0, 0.0); + elm_box_pack_end(bx, bt); + evas_object_show(bt); + /* set an initial window size */ evas_object_resize(win, 320, 520); /* show the window */ diff --git a/src/lib/Elementary.h.in b/src/lib/Elementary.h.in index 9898756..fdc3cab 100644 --- a/src/lib/Elementary.h.in +++ b/src/lib/Elementary.h.in @@ -380,6 +380,9 @@ extern "C" { EAPI Elm_Hoversel_Item *elm_hoversel_item_add(Evas_Object *obj, const char *label, const char *icon_file, Elm_Icon_Type icon_type, void (*func) (void *data, Evas_Object *obj, void *event_info), const void *data); EAPI void elm_hoversel_item_del(Elm_Hoversel_Item *item); /* smart callbacks called: + * "clicked" - the user clicked the hoversel button and popped up the sel + * "selected" - an item in the hoversel list is selected + * "dismissed" - the hover is dismissed */ typedef struct _Elm_Toolbar_Item Elm_Toolbar_Item; @@ -389,6 +392,7 @@ extern "C" { EAPI void elm_toolbar_item_select(Elm_Toolbar_Item *item); EAPI void elm_toolbar_scrollable_set(Evas_Object *obj, Evas_Bool scrollable); /* smart callbacks called: + * "clicked" - when the user clicks on a toolbar item and becomes selected */ //////////////////////////////////////////////////////////////////////////// @@ -400,12 +404,11 @@ extern "C" { // * left/right arrow broken with password mode for entry + utf8 chars... // * entry signal "changed" not called when deleting // * bubble doesnt handle child size changes right +// * table doesnt do homogenous properly // //// (incomplete - medium priority) // * entry selection conflicts with finger scroll (make selection start/stop work on signals?) -// -// * add test for photo widget -// * add test for hoversel + // * disabled not supported // * tab widget focusing (not useful for touchscreen tho...) // * on the fly theme changes - test (should work) @@ -436,6 +439,10 @@ extern "C" { // * dialpad widget - need one with a phone dialpad // //// (improvements - low priority) +// * use evas's new box instead of a box smart +// * use evas's table instead of a table smart +// * use ecore_evas_object_associate for win widget +// * use stack for win widget // * somehow a pdf(ps) viewer widget that doesnt make it gpl (lgpl) // * emotion widget? // * ewebkit widget diff --git a/src/lib/elc_hoversel.c b/src/lib/elc_hoversel.c index d182519..11c7c7f 100644 --- a/src/lib/elc_hoversel.c +++ b/src/lib/elc_hoversel.c @@ -72,6 +72,7 @@ _item_clicked(void *data, Evas_Object *obj, void *event_info) Item *it = data; Evas_Object *obj2 = it->obj; if (it->func) it->func(it->data, obj2, NULL); + evas_object_smart_callback_call(obj2, "selected", NULL); elm_hoversel_hover_end(obj2); } @@ -121,6 +122,7 @@ _button_clicked(void *data, Evas_Object *obj, void *event_info) evas_object_show(bx); evas_object_show(wd->hover); + evas_object_smart_callback_call(data, "clicked", NULL); } static void @@ -185,6 +187,7 @@ elm_hoversel_hover_end(Evas_Object *obj) Widget_Data *wd = elm_widget_data_get(obj); if (wd->hover) evas_object_del(wd->hover); wd->hover = NULL; + evas_object_smart_callback_call(obj, "dismissed", NULL); } EAPI Elm_Hoversel_Item * diff --git a/src/lib/elm_toolbar.c b/src/lib/elm_toolbar.c index 9535e27..0332377 100644 --- a/src/lib/elm_toolbar.c +++ b/src/lib/elm_toolbar.c @@ -26,7 +26,6 @@ struct _Item static void _del_hook(Evas_Object *obj); static void _theme_hook(Evas_Object *obj); static void _sizing_eval(Evas_Object *obj); -static void _mouse_up(void *data, Evas_Object *obj, void *event_info); static void _item_show(Item *it) @@ -40,6 +39,32 @@ _item_show(Item *it) } static void +_item_select(Item *it) +{ + Item *it2; + Widget_Data *wd = elm_widget_data_get(it->obj); + Evas_Object *obj2; + Eina_List *l; + if (it->selected) return; + for (l = wd->items; l; l = l->next) + { + it2 = l->data; + if (it2->selected) + { + it2->selected = 0; + edje_object_signal_emit(it2->base, "elm,state,unselected", "elm"); + break; + } + } + it->selected = 1; + edje_object_signal_emit(it->base, "elm,state,selected", "elm"); + _item_show(it); + obj2 = it->obj; + if (it->func) it->func(it->data, it->obj, NULL); + evas_object_smart_callback_call(obj2, "clicked", NULL); +} + +static void _del_hook(Evas_Object *obj) { Widget_Data *wd = elm_widget_data_get(obj); @@ -49,7 +74,28 @@ _del_hook(Evas_Object *obj) static void _theme_hook(Evas_Object *obj) { - // FIXME: re-eval icon and all min sizes + Widget_Data *wd = elm_widget_data_get(obj); + Eina_List *l; + Item *it; + Evas_Coord mw, mh; + for (l = wd->items; l; l = l->next) + { + it = l->data; + if (it->selected) + edje_object_signal_emit(it->base, "elm,state,selected", "elm"); + _elm_theme_set(it->base, "toolbar", "item", "default"); + if (it->icon) + { + edje_extern_object_min_size_set(it->icon, + (double)wd->icon_size * _elm_config->scale, + (double)wd->icon_size * _elm_config->scale); + edje_object_part_swallow(it->base, "elm.swallow.icon", it->icon); + } + edje_object_part_text_set(it->base, "elm.text", it->label); + edje_object_size_min_calc(it->base, &mw, &mh); + evas_object_size_hint_min_set(it->base, mw, mh); + evas_object_size_hint_max_set(it->base, 9999, mh); + } _sizing_eval(obj); } @@ -80,12 +126,6 @@ _sizing_eval(Evas_Object *obj) } static void -_mouse_up(void *data, Evas_Object *obj, void *event_info) -{ - evas_object_smart_callback_call(data, "clicked", NULL); -} - -static void _resize(void *data, Evas *e, Evas_Object *obj, void *event_info) { Widget_Data *wd = elm_widget_data_get(data); @@ -115,24 +155,7 @@ _resize(void *data, Evas *e, Evas_Object *obj, void *event_info) static void _select(void *data, Evas_Object *obj, const char *emission, const char *source) { - Item *it = data, *it2; - Widget_Data *wd = elm_widget_data_get(it->obj); - Eina_List *l; - if (it->selected) return; - for (l = wd->items; l; l = l->next) - { - it2 = l->data; - if (it2->selected) - { - it2->selected = 0; - edje_object_signal_emit(it2->base, "elm,state,unselected", "elm"); - break; - } - } - it->selected = 1; - edje_object_signal_emit(it->base, "elm,state,selected", "elm"); - _item_show(it); - if (it->func) it->func(it->data, it->obj, NULL); + _item_select(data); } EAPI Evas_Object * @@ -191,16 +214,16 @@ elm_toolbar_item_add(Evas_Object *obj, Evas_Object *icon, const char *label, voi _elm_theme_set(it->base, "toolbar", "item", "default"); edje_object_signal_callback_add(it->base, "elm,action,click", "elm", _select, it); - if (icon) + if (it->icon) { - edje_extern_object_min_size_set(icon, + edje_extern_object_min_size_set(it->icon, (double)wd->icon_size * _elm_config->scale, (double)wd->icon_size * _elm_config->scale); - edje_object_part_swallow(it->base, "elm.swallow.icon", icon); - evas_object_show(icon); + edje_object_part_swallow(it->base, "elm.swallow.icon", it->icon); + evas_object_show(it->icon); elm_widget_sub_object_add(obj, it->icon); } - edje_object_part_text_set(it->base, "elm.text", label); + edje_object_part_text_set(it->base, "elm.text", it->label); edje_object_size_min_calc(it->base, &mw, &mh); evas_object_size_hint_weight_set(it->base, 0.0, 0.0); evas_object_size_hint_align_set(it->base, -1.0, -1.0); @@ -216,14 +239,21 @@ elm_toolbar_item_add(Evas_Object *obj, Evas_Object *icon, const char *label, voi EAPI void elm_toolbar_item_del(Elm_Toolbar_Item *item) { - // FIXME: remove item + Item *it = (Item *)item; + Widget_Data *wd = elm_widget_data_get(it->obj); + Evas_Object *obj2 = it->obj; + wd->items = eina_list_remove(wd->items, it); + eina_stringshare_del(it->label); + if (it->icon) evas_object_del(it->icon); + evas_object_del(it->base); + free(it); + _theme_hook(obj2); } EAPI void elm_toolbar_item_select(Elm_Toolbar_Item *item) { - // FIXME select item - // Widget_Data *wd = elm_widget_data_get(obj); + _item_select(item); } EAPI void