Elementary menu item: handling hidden icon
authorAndrii Kroitor <an.kroitor@samsung.com>
Sat, 8 Feb 2014 04:17:24 +0000 (13:17 +0900)
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>
Sat, 8 Feb 2014 04:17:24 +0000 (13:17 +0900)
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
src/lib/elm_menu.c
src/lib/elm_menu_common.h

index d180c58..2a7afc1 100644 (file)
@@ -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;
index 61093a0..fd72f8c 100644 (file)
@@ -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)))
      {
index e00793e..8eadda4 100644 (file)
@@ -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
  */