toolbar: Send a signal when shrink mode is changed. 90/56090/1
authorYoungbok Shin <youngb.shin@samsung.com>
Mon, 4 Jan 2016 00:31:29 +0000 (09:31 +0900)
committerYoungbok Shin <youngb.shin@samsung.com>
Mon, 4 Jan 2016 08:14:58 +0000 (17:14 +0900)
Summary:
It is useful for changing item's state according to shrink mode.
@feature

Test Plan:
It includes a use case for the patch in toolbar default theme.
Run "elementary_test -to toolbar2".

Reviewers: jaehwan, woohyun, cedric, raster

Subscribers: eagleeye

Differential Revision: https://phab.enlightenment.org/D3481

Change-Id: I10bc02a92e2a2efe587c0110cca33d14c51f7647

data/themes/edc/elm/toolbar.edc
src/lib/elm_toolbar.c
src/lib/elm_toolbar.eo

index d932ff2..f6cb533 100644 (file)
@@ -379,6 +379,8 @@ group { name: "elm/toolbar/item/default";
 #define DISABLE  4
    script {   
       public btmode;
+      public vertical = 0;
+      public scroll = 0;
       public eval_mode(m) {
          new m1 = m & MASK;
          new d = m & DISABLE;
@@ -432,6 +434,44 @@ group { name: "elm/toolbar/item/default";
             }
          }
       }
+
+      public enable_scroll() {
+         set_int(scroll, 1);
+
+         if (get_int(vertical))
+            set_state(PART:"base", "vert_scroll", 0.0);
+         else
+            set_state(PART:"base", "scroll", 0.0);
+      }
+
+      public disable_scroll() {
+         set_int(scroll, 0);
+
+         if (get_int(vertical))
+            set_state(PART:"base", "vert", 0.0);
+         else
+            set_state(PART:"base", "default", 0.0);
+      }
+
+      public enable_vertical() {
+         set_int(vertical, 1);
+
+         if (get_int(scroll))
+            set_state(PART:"base", "vert_scroll", 0.0);
+         else
+            set_state(PART:"base", "vert", 0.0);
+         set_state(PART:"bend_clip", "vert", 0.0);
+      }
+
+      public disable_vertical() {
+         set_int(vertical, 0);
+
+         if (get_int(scroll))
+            set_state(PART:"base", "scroll", 0.0);
+         else
+            set_state(PART:"base", "default", 0.0);
+         set_state(PART:"bend_clip", "default", 0.0);
+      }
    }
    parts {
       part { name: "base"; type: SPACER;
@@ -441,6 +481,14 @@ group { name: "elm/toolbar/item/default";
             rel1.offset: -1 0;
             rel2.offset: 0 -1;
          }
+         description { state: "scroll" 0.0;
+            inherit: "default" 0.0;
+            min: 80 0;
+         }
+         description { state: "vert_scroll" 0.0;
+            inherit: "vert" 0.0;
+            min: 0 80;
+         }
       }
       part { name: "shadow1"; mouse_events: 0;
          description { state: "default" 0.0;
@@ -810,15 +858,45 @@ group { name: "elm/toolbar/item/default";
    programs {
       program {
          signal: "elm,orient,horizontal"; source: "elm";
-         action: STATE_SET "default" 0.0;
-         target: "base";
-         target: "bend_clip";
+         script {
+            disable_vertical();
+         }
       }
       program {
          signal: "elm,orient,vertical"; source: "elm";
-         action: STATE_SET "vert" 0.0;
-         target: "base";
-         target: "bend_clip";
+         script {
+            enable_vertical();
+         }
+      }
+      program {
+         signal: "elm,state,shrink,scroll"; source: "elm";
+         script {
+            enable_scroll();
+         }
+      }
+      program {
+         signal: "elm,state,shrink,none"; source: "elm";
+         script {
+            disable_scroll()
+         }
+      }
+      program {
+         signal: "elm,state,shrink,hide"; source: "elm";
+         script {
+            disable_scroll()
+         }
+      }
+      program {
+         signal: "elm,state,shrink,menu"; source: "elm";
+         script {
+            disable_scroll()
+         }
+      }
+      program {
+         signal: "elm,state,shrink,expand"; source: "elm";
+         script {
+            disable_scroll()
+         }
       }
       
       program { name: "st0";
index 5d46d1f..625f966 100644 (file)
@@ -1215,6 +1215,31 @@ _item_del(Elm_Toolbar_Item_Data *it)
 }
 
 static void
+_item_shrink_signal_emit(Evas_Object *view, Elm_Toolbar_Shrink_Mode shrink_mode)
+{
+   switch (shrink_mode)
+     {
+      case ELM_TOOLBAR_SHRINK_HIDE:
+         elm_layout_signal_emit(view, "elm,state,shrink,hide", "elm");
+         break;
+      case ELM_TOOLBAR_SHRINK_SCROLL:
+         elm_layout_signal_emit(view, "elm,state,shrink,scroll", "elm");
+         break;
+      case ELM_TOOLBAR_SHRINK_MENU:
+         elm_layout_signal_emit(view, "elm,state,shrink,menu", "elm");
+         break;
+      case ELM_TOOLBAR_SHRINK_EXPAND:
+         elm_layout_signal_emit(view, "elm,state,shrink,expand", "elm");
+         break;
+      case ELM_TOOLBAR_SHRINK_NONE:
+      case ELM_TOOLBAR_SHRINK_LAST:
+      default:
+         elm_layout_signal_emit(view, "elm,state,shrink,default", "elm");
+         break;
+     }
+}
+
+static void
 _item_theme_hook(Evas_Object *obj,
                  Elm_Toolbar_Item_Data *it,
                  double scale,
@@ -1277,6 +1302,8 @@ _item_theme_hook(Evas_Object *obj,
           }
      }
 
+   _item_shrink_signal_emit(view, sd->shrink_mode);
+
    if (sd->vertical)
      elm_layout_signal_emit(view, "elm,orient,vertical", "elm");
    else
@@ -3323,6 +3350,7 @@ _elm_toolbar_item_separator_get(Eo *eo_item EINA_UNUSED, Elm_Toolbar_Item_Data *
 EOLIAN static void
 _elm_toolbar_shrink_mode_set(Eo *obj, Elm_Toolbar_Data *sd, Elm_Toolbar_Shrink_Mode shrink_mode)
 {
+   Elm_Toolbar_Item_Data *it;
    Eina_Bool bounce;
 
    if (sd->shrink_mode == shrink_mode) return;
@@ -3363,6 +3391,9 @@ _elm_toolbar_shrink_mode_set(Eo *obj, Elm_Toolbar_Data *sd, Elm_Toolbar_Shrink_M
       eo_do(obj, elm_interface_scrollable_policy_set
             (ELM_SCROLLER_POLICY_AUTO, ELM_SCROLLER_POLICY_OFF));
 
+   EINA_INLIST_FOREACH(sd->items, it)
+      _item_shrink_signal_emit(VIEW(it), sd->shrink_mode);
+
    evas_object_smart_need_recalculate_set(obj, EINA_TRUE);
 }
 
index 25e6034..7d27c15 100644 (file)
@@ -125,6 +125,14 @@ class Elm.Toolbar (Elm.Widget, Elm_Interface_Scrollable,
            aggregate items which didn't fit with the #ELM_TOOLBAR_SHRINK_MENU
            mode.
 
+           If shrink mode is changed, Toolbar will send one of the following
+           signal to each item for informing the current shrink mode.
+             "elm,state,shrink,default"
+             "elm,state,shrink,hide"
+             "elm,state,shrink,scroll"
+             "elm,state,shrink,menu"
+             "elm,state,shrink,expand"
+
            Warning: This function's behavior will clash with those of
            elm_scroller_policy_set(), so use either one of them, but not both.]]
          set {