diff --git a/legacy/elementary/data/themes/default.edc b/legacy/elementary/data/themes/default.edc index 501105c3c6..60704a5e2d 100644 --- a/legacy/elementary/data/themes/default.edc +++ b/legacy/elementary/data/themes/default.edc @@ -10071,11 +10071,13 @@ collections { images { image: "toolbar_sel.png" COMP; } + data.item: "transition_animation_on" "1"; parts { part { name: "label2"; type: TEXT; mouse_events: 0; scale: 1; + clip_to: "elm.text.clipper"; description { state: "default" 0.0; align: 0.5 1.0; fixed: 0 1; @@ -10107,6 +10109,42 @@ collections { text.min: 1 1; } } + part { name: "label2_new"; + type: TEXT; + mouse_events: 0; + scale: 1; + clip_to: "elm.text_new.clipper"; + description { state: "default" 0.0; + align: 0.5 1.0; + fixed: 0 1; + rel1.to: "elm.text_new"; + rel2.to: "elm.text_new"; + color: 0 0 0 255; + text { + font: "Sans"; + text_source: "elm.text_new"; + size: 10; + min: 1 1; + align: 0.5 0.5; + } + } + description { state: "selected" 0.0; + inherit: "default" 0.0; + visible: 0; + } + description { state: "disabled" 0.0; + inherit: "default" 0.0; + color: 0 0 0 128; + color3: 0 0 0 0; + } + description { state: "disabled_visible" 0.0; + inherit: "default" 0.0; + color: 0 0 0 128; + color3: 0 0 0 0; + visible: 1; + text.min: 1 1; + } + } part { name: "bg"; mouse_events: 0; description { state: "default" 0.0; @@ -10132,6 +10170,7 @@ collections { } part { name: "elm.swallow.icon"; type: SWALLOW; + clip_to: "elm.icon.clipper"; description { state: "default" 0.0; align: 0.5 0.5; fixed: 0 0; @@ -10149,11 +10188,79 @@ collections { color: 0 0 0 0; } } + part { name: "elm.swallow.icon_new"; + type: SWALLOW; + clip_to: "elm.icon_new.clipper"; + description { state: "default" 0.0; + align: 0.5 0.5; + fixed: 0 0; + rel1 { + relative: 0.0 0.0; + offset: 2 2; + } + rel2 { + to_y: "elm.text_new"; + relative: 1.0 0.0; + offset: -3 -1; + } + color: 0 0 0 0; + } + } part { name: "elm.text"; type: TEXT; effect: SOFT_SHADOW; mouse_events: 0; scale: 1; + clip_to: "elm.text.clipper"; + description { state: "default" 0.0; + align: 0.5 1.0; + fixed: 0 1; + rel1 { + relative: 0.0 1.0; + offset: 0 -1; + } + rel2 { + relative: 1.0 1.0; + offset: -1 -1; + } + visible: 0; + color: 224 224 224 255; + color3: 0 0 0 32; + text { + font: "Sans:style=Bold"; + size: 10; + min: 1 1; + align: 0.5 0.5; + } + } + description { state: "selected" 0.0; + inherit: "default" 0.0; + visible: 1; + } + description { state: "visible" 0.0; + inherit: "default" 0.0; + visible: 1; + text.min: 1 1; + } + description { state: "disabled" 0.0; + inherit: "default" 0.0; + color: 0 0 0 128; + color3: 0 0 0 0; + } + description { state: "disabled_visible" 0.0; + inherit: "default" 0.0; + color: 0 0 0 128; + color3: 0 0 0 0; + visible: 1; + text.min: 1 1; + } + } + part { name: "elm.text_new"; + type: TEXT; + effect: SOFT_SHADOW; + mouse_events: 0; + clip_to: "elm.text_new.clipper"; + scale: 1; description { state: "default" 0.0; align: 0.5 1.0; fixed: 0 1; @@ -10197,6 +10304,42 @@ collections { text.min: 1 1; } } + part { name: "elm.text.clipper"; + type: RECT; + description { state: "default" 0.0; + color: 255 255 255 255; + } + description { state: "animation" 0.0; + color: 255 255 255 0; + } + } + part { name: "elm.text_new.clipper"; + type: RECT; + description { state: "default" 0.0; + color: 255 255 255 0; + } + description { state: "animation" 0.0; + color: 255 255 255 255; + } + } + part { name: "elm.icon.clipper"; + type: RECT; + description { state: "default" 0.0; + color: 255 255 255 255; + } + description { state: "animation" 0.0; + color: 255 255 255 0; + } + } + part { name: "elm.icon_new.clipper"; + type: RECT; + description { state: "default" 0.0; + color: 255 255 255 0; + } + description { state: "animation" 0.0; + color: 255 255 255 255; + } + } part { name: "event"; type: RECT; mouse_events: 1; @@ -10214,6 +10357,8 @@ collections { target: "bg"; target: "elm.text"; target: "label2"; + target: "elm.text_new"; + target: "label2_new"; transition: LINEAR 0.2; } program { name: "go_passive"; @@ -10223,6 +10368,8 @@ collections { target: "bg"; target: "elm.text"; target: "label2"; + target: "elm.text_new"; + target: "label2_new"; transition: LINEAR 0.1; } program { name: "go"; @@ -10235,6 +10382,7 @@ collections { source: "elm"; action: STATE_SET "disabled" 0.0; target: "label2"; + target: "label2_new"; target: "bg"; after: "disable_text"; } @@ -10244,9 +10392,15 @@ collections { new Float:vl; get_state(PART:"elm.text", st, 30, vl); if (!strcmp(st, "visible")) - set_state(PART:"elm.text", "disabled_visible", 0.0); + { + set_state(PART:"elm.text", "disabled_visible", 0.0); + set_state(PART:"elm.text_new", "disabled_visible", 0.0); + } else - set_state(PART:"elm.text", "disabled", 0.0); + { + set_state(PART:"elm.text", "disabled", 0.0); + set_state(PART:"elm.text_new", "disabled", 0.0); + } } } program { name: "enable"; @@ -10254,6 +10408,7 @@ collections { source: "elm"; action: STATE_SET "default" 0.0; target: "label2"; + target: "label2_new"; target: "bg"; after: "enable_text"; } @@ -10263,11 +10418,55 @@ collections { new Float:vl; get_state(PART:"elm.text", st, 30, vl); if (!strcmp(st, "disabled_visible")) - set_state(PART:"elm.text", "visible", 0.0); + { + set_state(PART:"elm.text", "visible", 0.0); + set_state(PART:"elm.text_new", "visible", 0.0); + } else - set_state(PART:"elm.text", "default", 0.0); + { + set_state(PART:"elm.text", "default", 0.0); + set_state(PART:"elm.text_new", "default", 0.0); + } } } + program { name: "label_set,animation"; + signal: "elm,state,label_set"; + source: "elm"; + action: STATE_SET "animation" 0.0; + target: "elm.text.clipper"; + target: "elm.text_new.clipper"; + transition: LINEAR 0.2; + after: "label_set,animation,done"; + } + program { name: "label_set,animation,done"; + action: SIGNAL_EMIT "elm,state,label_set,done" "elm"; + } + program { name: "label,reset"; + signal: "elm,state,label,reset"; + source: "elm"; + action: STATE_SET "default" 0.0; + target: "elm.text.clipper"; + target: "elm.text_new.clipper"; + } + program { name: "icon_set,animation"; + signal: "elm,state,icon_set"; + source: "elm"; + action: STATE_SET "animation" 0.0; + target: "elm.icon.clipper"; + target: "elm.icon_new.clipper"; + transition: LINEAR 0.2; + after: "icon_set,animation,done"; + } + program { name: "icon_set,animation,done"; + action: SIGNAL_EMIT "elm,state,icon_set,done" "elm"; + } + program { name: "icon,reset"; + signal: "elm,state,icon,reset"; + source: "elm"; + action: STATE_SET "default" 0.0; + target: "elm.icon.clipper"; + target: "elm.icon_new.clipper"; + } } } diff --git a/legacy/elementary/src/lib/Elementary.h.in b/legacy/elementary/src/lib/Elementary.h.in index 9453ad1732..f7e7324ae2 100644 --- a/legacy/elementary/src/lib/Elementary.h.in +++ b/legacy/elementary/src/lib/Elementary.h.in @@ -1308,6 +1308,7 @@ extern "C" { EAPI Eina_Bool elm_toolbar_item_selected_get(const Elm_Toolbar_Item *item); EAPI void elm_toolbar_item_selected_set(Elm_Toolbar_Item *item, Eina_Bool selected); EAPI Elm_Toolbar_Item *elm_toolbar_selected_item_get(const Evas_Object *obj); + EAPI void elm_toolbar_item_icon_set(Elm_Toolbar_Item *item, const char *icon); EAPI void elm_toolbar_item_del(Elm_Toolbar_Item *item); EAPI void elm_toolbar_item_del_cb_set(Elm_Toolbar_Item *item, Evas_Smart_Cb func); EAPI Eina_Bool elm_toolbar_item_disabled_get(const Elm_Toolbar_Item *item); diff --git a/legacy/elementary/src/lib/elm_toolbar.c b/legacy/elementary/src/lib/elm_toolbar.c index 280ea45b13..ba3c7c877b 100644 --- a/legacy/elementary/src/lib/elm_toolbar.c +++ b/legacy/elementary/src/lib/elm_toolbar.c @@ -934,6 +934,30 @@ elm_toolbar_item_label_get(const Elm_Toolbar_Item *item) return item->label; } +static void +_elm_toolbar_item_label_update(Elm_Toolbar_Item *item) +{ + Evas_Coord mw = -1, mh = -1; + edje_object_part_text_set(item->base.view, "elm.text", item->label); + + elm_coords_finger_size_adjust(1, &mw, 1, &mh); + edje_object_size_min_restricted_calc(item->base.view, &mw, &mh, mw, mh); + elm_coords_finger_size_adjust(1, &mw, 1, &mh); + evas_object_size_hint_weight_set(item->base.view, -1.0, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(item->base.view, 0.5, EVAS_HINT_FILL); + evas_object_size_hint_min_set(item->base.view, mw, mh); +} + +static void +_elm_toolbar_item_label_set_cb (void *data, Evas_Object *obj, const char *emission, const char *source) +{ + Elm_Toolbar_Item *item = data; + _elm_toolbar_item_label_update(item); + edje_object_signal_callback_del(obj, emission, source, + _elm_toolbar_item_label_set_cb); + edje_object_signal_emit (item->base.view, "elm,state,label,reset", "elm"); +} + /** * Set the label associated with @p item. * @@ -945,12 +969,35 @@ elm_toolbar_item_label_get(const Elm_Toolbar_Item *item) EAPI void elm_toolbar_item_label_set(Elm_Toolbar_Item *item, const char *label) { - Evas_Coord mw = -1, mh = -1; + const char *s; ELM_TOOLBAR_ITEM_CHECK_OR_RETURN(item); - eina_stringshare_replace(&item->label, label); - edje_object_part_text_set(item->base.view, "elm.text", item->label); + if ((label) && (item->label) && (!strcmp(label, item->label))) return; + eina_stringshare_replace(&item->label, label); + s = edje_object_data_get(item->base.view, "transition_animation_on"); + if ((s) && (atoi(s))) + { + edje_object_part_text_set(item->base.view, "elm.text_new", item->label); + edje_object_signal_emit (item->base.view, "elm,state,label_set", "elm"); + edje_object_signal_callback_add(item->base.view, + "elm,state,label_set,done", "elm", + _elm_toolbar_item_label_set_cb, item); + } + else + _elm_toolbar_item_label_update(item); +} + +static void +_elm_toolbar_item_icon_update(Elm_Toolbar_Item *item) +{ + Evas_Coord mw = -1, mh = -1; + Evas_Object *old_icon = edje_object_part_swallow_get(item->base.view, + "elm.swallow.icon"); + + elm_widget_sub_object_del(item->base.view, old_icon); + evas_object_del(old_icon); + edje_object_part_swallow(item->base.view, "elm.swallow.icon", item->icon); elm_coords_finger_size_adjust(1, &mw, 1, &mh); edje_object_size_min_restricted_calc(item->base.view, &mw, &mh, mw, mh); elm_coords_finger_size_adjust(1, &mw, 1, &mh); @@ -1020,6 +1067,72 @@ elm_toolbar_selected_item_get(const Evas_Object *obj) return wd->selected_item; } +static void +_elm_toolbar_item_icon_set_cb (void *data, Evas_Object *obj, const char *emission, const char *source) +{ + Elm_Toolbar_Item *item = data; + edje_object_part_unswallow(item->base.view, item->icon); + _elm_toolbar_item_icon_update(item); + edje_object_signal_callback_del(obj, emission, source, + _elm_toolbar_item_icon_set_cb); + edje_object_signal_emit (item->base.view, "elm,state,icon,reset", "elm"); +} + +/** + * Set the icon associated with @p item. + * + * @param obj The parent of this item + * @param item The toolbar item + * @param icon The icon of @p item + * + * @ingroup Toolbar + */ +EAPI void +elm_toolbar_item_icon_set(Elm_Toolbar_Item *item, const char *icon) +{ + const char *s; + Evas_Object *icon_obj; + Widget_Data *wd; + Evas_Object *obj = item->base.widget; + + ELM_TOOLBAR_ITEM_CHECK_OR_RETURN(item); + wd = elm_widget_data_get(obj); + if (!wd) return; + if ((icon) && (item->icon_str) && (!strcmp(icon, item->icon_str))) return; + + icon_obj = elm_icon_add(obj); + if (!icon_obj) return; + if (_item_icon_set(icon_obj, "toolbar/", icon)) + { + int ms = 0; + item->icon = icon_obj; + eina_stringshare_replace(&item->icon_str, icon); + ms = ((double)wd->icon_size * _elm_config->scale); + evas_object_size_hint_min_set(item->icon, ms, ms); + evas_object_size_hint_max_set(item->icon, ms, ms); + evas_object_show(item->icon); + elm_widget_sub_object_add(obj, item->icon); + } + else + { + item->icon = NULL; + item->icon_str = NULL; + evas_object_del(icon_obj); + } + s = edje_object_data_get(item->base.view, "transition_animation_on"); + if ((s) && (atoi(s))) + { + edje_object_part_swallow(item->base.view, "elm.swallow.icon_new", + item->icon); + edje_object_signal_emit (item->base.view, "elm,state,icon_set", "elm"); + edje_object_signal_callback_add(item->base.view, + "elm,state,icon_set,done", "elm", + _elm_toolbar_item_icon_set_cb, item); + } + else + _elm_toolbar_item_icon_update(item); +} + /** * Delete a toolbar item. *