summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrii Kroitor <an.kroitor@samsung.com>2014-02-08 13:17:24 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2014-02-08 13:17:24 +0900
commitf15b796dc330aef45c4dca27659239b8f76b24c0 (patch)
tree63c14d80ffd0c64cb478d4e1dc5b4ea7adf4e8d5
parent546937e0b3df9b02846de2e275d918adbca9b50f (diff)
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
-rw-r--r--data/themes/edc/elm/menu.edc30
-rw-r--r--src/lib/elm_menu.c5
-rw-r--r--src/lib/elm_menu_common.h1
3 files changed, 31 insertions, 5 deletions
diff --git a/data/themes/edc/elm/menu.edc b/data/themes/edc/elm/menu.edc
index d180c5804..2a7afc1b1 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";
40 inherit: "default" 0.0; 40 inherit: "default" 0.0;
41 } 41 }
42 } 42 }
43 // XXX: need to handle no icon mode
44 part { name: "elm.swallow.content"; type: SWALLOW; mouse_events: 0; 43 part { name: "elm.swallow.content"; type: SWALLOW; mouse_events: 0;
45 clip_to: "disabler"; 44 clip_to: "disabler";
46 scale: 1; 45 scale: 1;
@@ -52,6 +51,10 @@ group { name: "elm/menu/item/default";
52 rel2.offset: 3 -5; 51 rel2.offset: 3 -5;
53 rel2.relative: 0.0 1.0; 52 rel2.relative: 0.0 1.0;
54 } 53 }
54 description { state: "noicon" 0.0;
55 inherit: "default" 0.0;
56 visible: 0;
57 }
55 } 58 }
56 // XXX: check/radio goes next (right of) content, no radio/check handle 59 // XXX: check/radio goes next (right of) content, no radio/check handle
57 // XXX: need to handle no text? 60 // XXX: need to handle no text?
@@ -237,6 +240,16 @@ group { name: "elm/menu/item/default";
237// set_state(PART:"elm.text2", "default", 0.0); 240// set_state(PART:"elm.text2", "default", 0.0);
238 } 241 }
239 } 242 }
243 program { name: "icon_show";
244 signal: "elm,state,icon,visible"; source: "elm";
245 action: STATE_SET "default" 0.0;
246 target: "elm.swallow.content";
247 }
248 program { name: "icon_hide";
249 signal: "elm,state,icon,hidden"; source: "elm";
250 action: STATE_SET "noicon" 0.0;
251 target: "elm.swallow.content";
252 }
240 program { name: "selected"; 253 program { name: "selected";
241 signal: "elm,state,selected"; source: "elm"; 254 signal: "elm,state,selected"; source: "elm";
242 action: STATE_SET "active" 0.0; 255 action: STATE_SET "active" 0.0;
@@ -408,7 +421,6 @@ group { name: "elm/menu/main_menu_submenu/default";
408 inherit: "default" 0.0; 421 inherit: "default" 0.0;
409 } 422 }
410 } 423 }
411 // XXX: need to handle no icon mode
412 part { name: "elm.swallow.content"; type: SWALLOW; mouse_events: 0; 424 part { name: "elm.swallow.content"; type: SWALLOW; mouse_events: 0;
413 clip_to: "disabler"; 425 clip_to: "disabler";
414 scale: 1; 426 scale: 1;
@@ -420,6 +432,10 @@ group { name: "elm/menu/main_menu_submenu/default";
420 rel2.offset: 3 -5; 432 rel2.offset: 3 -5;
421 rel2.relative: 0.0 1.0; 433 rel2.relative: 0.0 1.0;
422 } 434 }
435 description { state: "noicon" 0.0;
436 inherit: "default" 0.0;
437 visible: 0;
438 }
423 } 439 }
424 // XXX: check/radio goes next (right of) content, no radio/check handle 440 // XXX: check/radio goes next (right of) content, no radio/check handle
425 // XXX: need to handle no text? 441 // XXX: need to handle no text?
@@ -634,6 +650,16 @@ group { name: "elm/menu/main_menu_submenu/default";
634// set_state(PART:"elm.text2", "default", 0.0); 650// set_state(PART:"elm.text2", "default", 0.0);
635 } 651 }
636 } 652 }
653 program { name: "icon_show";
654 signal: "elm,state,icon,visible"; source: "elm";
655 action: STATE_SET "default" 0.0;
656 target: "elm.swallow.content";
657 }
658 program { name: "icon_hide";
659 signal: "elm,state,icon,hidden"; source: "elm";
660 action: STATE_SET "noicon" 0.0;
661 target: "elm.swallow.content";
662 }
637 program { name: "selected"; 663 program { name: "selected";
638 signal: "elm,state,selected"; source: "elm"; 664 signal: "elm,state,selected"; source: "elm";
639 action: STATE_SET "active" 0.0; 665 action: STATE_SET "active" 0.0;
diff --git a/src/lib/elm_menu.c b/src/lib/elm_menu.c
index 61093a0e7..fd72f8c9d 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,
1029 ELM_MENU_ITEM_CHECK_OR_RETURN(it); 1029 ELM_MENU_ITEM_CHECK_OR_RETURN(it);
1030 EINA_SAFETY_ON_NULL_RETURN(icon); 1030 EINA_SAFETY_ON_NULL_RETURN(icon);
1031 1031
1032 if (!*icon) return; 1032 if ((icon[0] != '\0') &&
1033 if ((item->icon_str) && (!strcmp(item->icon_str, icon))) return; 1033 (snprintf(icon_tmp, sizeof(icon_tmp), "menu/%s", icon) > 0) &&
1034 if ((snprintf(icon_tmp, sizeof(icon_tmp), "menu/%s", icon) > 0) &&
1035 (elm_icon_standard_set(item->content, icon_tmp) || 1034 (elm_icon_standard_set(item->content, icon_tmp) ||
1036 elm_icon_standard_set(item->content, icon))) 1035 elm_icon_standard_set(item->content, icon)))
1037 { 1036 {
diff --git a/src/lib/elm_menu_common.h b/src/lib/elm_menu_common.h
index e00793e3e..8eadda4c6 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
19 * @param icon The name of icon object to set for the content of @p item 19 * @param icon The name of icon object to set for the content of @p item
20 * 20 *
21 * Once this icon is set, any previously set icon will be deleted. 21 * Once this icon is set, any previously set icon will be deleted.
22 * To hide icon set it to "".
22 * 23 *
23 * @ingroup Menu 24 * @ingroup Menu
24 */ 25 */