jaehwan pushed a commit to branch master.

http://git.enlightenment.org/core/elementary.git/commit/?id=d1867909117123f74ac6a3561296a7bd57e5c22f

commit d1867909117123f74ac6a3561296a7bd57e5c22f
Author: Youngbok Shin <youngb.s...@samsung.com>
Date:   Mon Jan 4 09:31:29 2016 +0900

    toolbar: Send a signal when shrink mode is changed.
    
    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
---
 data/themes/edc/elm/toolbar.edc | 90 ++++++++++++++++++++++++++++++++++++++---
 src/lib/elm_toolbar.c           | 31 ++++++++++++++
 src/lib/elm_toolbar.eo          |  8 ++++
 3 files changed, 123 insertions(+), 6 deletions(-)

diff --git a/data/themes/edc/elm/toolbar.edc b/data/themes/edc/elm/toolbar.edc
index d932ff2..f6cb533 100644
--- a/data/themes/edc/elm/toolbar.edc
+++ b/data/themes/edc/elm/toolbar.edc
@@ -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";
diff --git a/src/lib/elm_toolbar.c b/src/lib/elm_toolbar.c
index d5aaa50..a899bb9 100644
--- a/src/lib/elm_toolbar.c
+++ b/src/lib/elm_toolbar.c
@@ -1224,6 +1224,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,
@@ -1286,6 +1311,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
@@ -3326,6 +3353,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;
@@ -3366,6 +3394,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);
 }
 
diff --git a/src/lib/elm_toolbar.eo b/src/lib/elm_toolbar.eo
index 25e6034..7d27c15 100644
--- a/src/lib/elm_toolbar.eo
+++ b/src/lib/elm_toolbar.eo
@@ -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 {

-- 


Reply via email to