From f15b796dc330aef45c4dca27659239b8f76b24c0 Mon Sep 17 00:00:00 2001 From: Andrii Kroitor Date: Sat, 8 Feb 2014 13:17:24 +0900 Subject: [PATCH] Elementary menu item: handling hidden icon Summary: Added noicon menu item state to default menu theme. Now you can hide icon by setting it to "" (empty string) Removed check for resetting the same icon name. This allows setting an icon after it was hidden. Reviewers: cedric, seoz, raster Reviewed By: raster CC: reutskiy.v.v Differential Revision: https://phab.enlightenment.org/D522 --- data/themes/edc/elm/menu.edc | 30 ++++++++++++++++++++++++++++-- src/lib/elm_menu.c | 5 ++--- src/lib/elm_menu_common.h | 1 + 3 files changed, 31 insertions(+), 5 deletions(-) diff --git a/data/themes/edc/elm/menu.edc b/data/themes/edc/elm/menu.edc index d180c58..2a7afc1 100644 --- a/data/themes/edc/elm/menu.edc +++ b/data/themes/edc/elm/menu.edc @@ -40,7 +40,6 @@ group { name: "elm/menu/item/default"; inherit: "default" 0.0; } } - // XXX: need to handle no icon mode part { name: "elm.swallow.content"; type: SWALLOW; mouse_events: 0; clip_to: "disabler"; scale: 1; @@ -52,6 +51,10 @@ group { name: "elm/menu/item/default"; rel2.offset: 3 -5; rel2.relative: 0.0 1.0; } + description { state: "noicon" 0.0; + inherit: "default" 0.0; + visible: 0; + } } // XXX: check/radio goes next (right of) content, no radio/check handle // XXX: need to handle no text? @@ -237,6 +240,16 @@ group { name: "elm/menu/item/default"; // set_state(PART:"elm.text2", "default", 0.0); } } + program { name: "icon_show"; + signal: "elm,state,icon,visible"; source: "elm"; + action: STATE_SET "default" 0.0; + target: "elm.swallow.content"; + } + program { name: "icon_hide"; + signal: "elm,state,icon,hidden"; source: "elm"; + action: STATE_SET "noicon" 0.0; + target: "elm.swallow.content"; + } program { name: "selected"; signal: "elm,state,selected"; source: "elm"; action: STATE_SET "active" 0.0; @@ -408,7 +421,6 @@ group { name: "elm/menu/main_menu_submenu/default"; inherit: "default" 0.0; } } - // XXX: need to handle no icon mode part { name: "elm.swallow.content"; type: SWALLOW; mouse_events: 0; clip_to: "disabler"; scale: 1; @@ -420,6 +432,10 @@ group { name: "elm/menu/main_menu_submenu/default"; rel2.offset: 3 -5; rel2.relative: 0.0 1.0; } + description { state: "noicon" 0.0; + inherit: "default" 0.0; + visible: 0; + } } // XXX: check/radio goes next (right of) content, no radio/check handle // XXX: need to handle no text? @@ -634,6 +650,16 @@ group { name: "elm/menu/main_menu_submenu/default"; // set_state(PART:"elm.text2", "default", 0.0); } } + program { name: "icon_show"; + signal: "elm,state,icon,visible"; source: "elm"; + action: STATE_SET "default" 0.0; + target: "elm.swallow.content"; + } + program { name: "icon_hide"; + signal: "elm,state,icon,hidden"; source: "elm"; + action: STATE_SET "noicon" 0.0; + target: "elm.swallow.content"; + } program { name: "selected"; signal: "elm,state,selected"; source: "elm"; action: STATE_SET "active" 0.0; diff --git a/src/lib/elm_menu.c b/src/lib/elm_menu.c index 61093a0..fd72f8c 100644 --- a/src/lib/elm_menu.c +++ b/src/lib/elm_menu.c @@ -1029,9 +1029,8 @@ elm_menu_item_icon_name_set(Elm_Object_Item *it, ELM_MENU_ITEM_CHECK_OR_RETURN(it); EINA_SAFETY_ON_NULL_RETURN(icon); - if (!*icon) return; - if ((item->icon_str) && (!strcmp(item->icon_str, icon))) return; - if ((snprintf(icon_tmp, sizeof(icon_tmp), "menu/%s", icon) > 0) && + if ((icon[0] != '\0') && + (snprintf(icon_tmp, sizeof(icon_tmp), "menu/%s", icon) > 0) && (elm_icon_standard_set(item->content, icon_tmp) || elm_icon_standard_set(item->content, icon))) { diff --git a/src/lib/elm_menu_common.h b/src/lib/elm_menu_common.h index e00793e..8eadda4 100644 --- a/src/lib/elm_menu_common.h +++ b/src/lib/elm_menu_common.h @@ -19,6 +19,7 @@ EAPI Evas_Object *elm_menu_item_object_get(const Elm_Object_Item * @param icon The name of icon object to set for the content of @p item * * Once this icon is set, any previously set icon will be deleted. + * To hide icon set it to "". * * @ingroup Menu */ -- 2.7.4