summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYoungbok Shin <youngb.shin@samsung.com>2016-01-04 09:31:29 +0900
committerJaehwan Kim <jae.hwan.kim@samsung.com>2016-01-04 10:43:35 +0900
commitd1867909117123f74ac6a3561296a7bd57e5c22f (patch)
treec0ccb31cb886460275ffe0c3533dc385c6d24e99
parent4f0723d91eb2fffed4412965a531c070f3a07d64 (diff)
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
Notes
Notes: breaks toolbar layouts: before -> after https://www.enlightenment.org/ss/e-568c35d5ee6854.99441370.jpg
-rw-r--r--data/themes/edc/elm/toolbar.edc90
-rw-r--r--src/lib/elm_toolbar.c31
-rw-r--r--src/lib/elm_toolbar.eo8
3 files changed, 123 insertions, 6 deletions
diff --git a/data/themes/edc/elm/toolbar.edc b/data/themes/edc/elm/toolbar.edc
index d932ff24b..f6cb53364 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";
379#define DISABLE 4 379#define DISABLE 4
380 script { 380 script {
381 public btmode; 381 public btmode;
382 public vertical = 0;
383 public scroll = 0;
382 public eval_mode(m) { 384 public eval_mode(m) {
383 new m1 = m & MASK; 385 new m1 = m & MASK;
384 new d = m & DISABLE; 386 new d = m & DISABLE;
@@ -432,6 +434,44 @@ group { name: "elm/toolbar/item/default";
432 } 434 }
433 } 435 }
434 } 436 }
437
438 public enable_scroll() {
439 set_int(scroll, 1);
440
441 if (get_int(vertical))
442 set_state(PART:"base", "vert_scroll", 0.0);
443 else
444 set_state(PART:"base", "scroll", 0.0);
445 }
446
447 public disable_scroll() {
448 set_int(scroll, 0);
449
450 if (get_int(vertical))
451 set_state(PART:"base", "vert", 0.0);
452 else
453 set_state(PART:"base", "default", 0.0);
454 }
455
456 public enable_vertical() {
457 set_int(vertical, 1);
458
459 if (get_int(scroll))
460 set_state(PART:"base", "vert_scroll", 0.0);
461 else
462 set_state(PART:"base", "vert", 0.0);
463 set_state(PART:"bend_clip", "vert", 0.0);
464 }
465
466 public disable_vertical() {
467 set_int(vertical, 0);
468
469 if (get_int(scroll))
470 set_state(PART:"base", "scroll", 0.0);
471 else
472 set_state(PART:"base", "default", 0.0);
473 set_state(PART:"bend_clip", "default", 0.0);
474 }
435 } 475 }
436 parts { 476 parts {
437 part { name: "base"; type: SPACER; 477 part { name: "base"; type: SPACER;
@@ -441,6 +481,14 @@ group { name: "elm/toolbar/item/default";
441 rel1.offset: -1 0; 481 rel1.offset: -1 0;
442 rel2.offset: 0 -1; 482 rel2.offset: 0 -1;
443 } 483 }
484 description { state: "scroll" 0.0;
485 inherit: "default" 0.0;
486 min: 80 0;
487 }
488 description { state: "vert_scroll" 0.0;
489 inherit: "vert" 0.0;
490 min: 0 80;
491 }
444 } 492 }
445 part { name: "shadow1"; mouse_events: 0; 493 part { name: "shadow1"; mouse_events: 0;
446 description { state: "default" 0.0; 494 description { state: "default" 0.0;
@@ -810,15 +858,45 @@ group { name: "elm/toolbar/item/default";
810 programs { 858 programs {
811 program { 859 program {
812 signal: "elm,orient,horizontal"; source: "elm"; 860 signal: "elm,orient,horizontal"; source: "elm";
813 action: STATE_SET "default" 0.0; 861 script {
814 target: "base"; 862 disable_vertical();
815 target: "bend_clip"; 863 }
816 } 864 }
817 program { 865 program {
818 signal: "elm,orient,vertical"; source: "elm"; 866 signal: "elm,orient,vertical"; source: "elm";
819 action: STATE_SET "vert" 0.0; 867 script {
820 target: "base"; 868 enable_vertical();
821 target: "bend_clip"; 869 }
870 }
871 program {
872 signal: "elm,state,shrink,scroll"; source: "elm";
873 script {
874 enable_scroll();
875 }
876 }
877 program {
878 signal: "elm,state,shrink,none"; source: "elm";
879 script {
880 disable_scroll()
881 }
882 }
883 program {
884 signal: "elm,state,shrink,hide"; source: "elm";
885 script {
886 disable_scroll()
887 }
888 }
889 program {
890 signal: "elm,state,shrink,menu"; source: "elm";
891 script {
892 disable_scroll()
893 }
894 }
895 program {
896 signal: "elm,state,shrink,expand"; source: "elm";
897 script {
898 disable_scroll()
899 }
822 } 900 }
823 901
824 program { name: "st0"; 902 program { name: "st0";
diff --git a/src/lib/elm_toolbar.c b/src/lib/elm_toolbar.c
index d5aaa5020..a899bb95f 100644
--- a/src/lib/elm_toolbar.c
+++ b/src/lib/elm_toolbar.c
@@ -1224,6 +1224,31 @@ _item_del(Elm_Toolbar_Item_Data *it)
1224} 1224}
1225 1225
1226static void 1226static void
1227_item_shrink_signal_emit(Evas_Object *view, Elm_Toolbar_Shrink_Mode shrink_mode)
1228{
1229 switch (shrink_mode)
1230 {
1231 case ELM_TOOLBAR_SHRINK_HIDE:
1232 elm_layout_signal_emit(view, "elm,state,shrink,hide", "elm");
1233 break;
1234 case ELM_TOOLBAR_SHRINK_SCROLL:
1235 elm_layout_signal_emit(view, "elm,state,shrink,scroll", "elm");
1236 break;
1237 case ELM_TOOLBAR_SHRINK_MENU:
1238 elm_layout_signal_emit(view, "elm,state,shrink,menu", "elm");
1239 break;
1240 case ELM_TOOLBAR_SHRINK_EXPAND:
1241 elm_layout_signal_emit(view, "elm,state,shrink,expand", "elm");
1242 break;
1243 case ELM_TOOLBAR_SHRINK_NONE:
1244 case ELM_TOOLBAR_SHRINK_LAST:
1245 default:
1246 elm_layout_signal_emit(view, "elm,state,shrink,default", "elm");
1247 break;
1248 }
1249}
1250
1251static void
1227_item_theme_hook(Evas_Object *obj, 1252_item_theme_hook(Evas_Object *obj,
1228 Elm_Toolbar_Item_Data *it, 1253 Elm_Toolbar_Item_Data *it,
1229 double scale, 1254 double scale,
@@ -1286,6 +1311,8 @@ _item_theme_hook(Evas_Object *obj,
1286 } 1311 }
1287 } 1312 }
1288 1313
1314 _item_shrink_signal_emit(view, sd->shrink_mode);
1315
1289 if (sd->vertical) 1316 if (sd->vertical)
1290 elm_layout_signal_emit(view, "elm,orient,vertical", "elm"); 1317 elm_layout_signal_emit(view, "elm,orient,vertical", "elm");
1291 else 1318 else
@@ -3326,6 +3353,7 @@ _elm_toolbar_item_separator_get(Eo *eo_item EINA_UNUSED, Elm_Toolbar_Item_Data *
3326EOLIAN static void 3353EOLIAN static void
3327_elm_toolbar_shrink_mode_set(Eo *obj, Elm_Toolbar_Data *sd, Elm_Toolbar_Shrink_Mode shrink_mode) 3354_elm_toolbar_shrink_mode_set(Eo *obj, Elm_Toolbar_Data *sd, Elm_Toolbar_Shrink_Mode shrink_mode)
3328{ 3355{
3356 Elm_Toolbar_Item_Data *it;
3329 Eina_Bool bounce; 3357 Eina_Bool bounce;
3330 3358
3331 if (sd->shrink_mode == shrink_mode) return; 3359 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
3366 eo_do(obj, elm_interface_scrollable_policy_set 3394 eo_do(obj, elm_interface_scrollable_policy_set
3367 (ELM_SCROLLER_POLICY_AUTO, ELM_SCROLLER_POLICY_OFF)); 3395 (ELM_SCROLLER_POLICY_AUTO, ELM_SCROLLER_POLICY_OFF));
3368 3396
3397 EINA_INLIST_FOREACH(sd->items, it)
3398 _item_shrink_signal_emit(VIEW(it), sd->shrink_mode);
3399
3369 evas_object_smart_need_recalculate_set(obj, EINA_TRUE); 3400 evas_object_smart_need_recalculate_set(obj, EINA_TRUE);
3370} 3401}
3371 3402
diff --git a/src/lib/elm_toolbar.eo b/src/lib/elm_toolbar.eo
index 25e6034bc..7d27c1558 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,
125 aggregate items which didn't fit with the #ELM_TOOLBAR_SHRINK_MENU 125 aggregate items which didn't fit with the #ELM_TOOLBAR_SHRINK_MENU
126 mode. 126 mode.
127 127
128 If shrink mode is changed, Toolbar will send one of the following
129 signal to each item for informing the current shrink mode.
130 "elm,state,shrink,default"
131 "elm,state,shrink,hide"
132 "elm,state,shrink,scroll"
133 "elm,state,shrink,menu"
134 "elm,state,shrink,expand"
135
128 Warning: This function's behavior will clash with those of 136 Warning: This function's behavior will clash with those of
129 elm_scroller_policy_set(), so use either one of them, but not both.]] 137 elm_scroller_policy_set(), so use either one of them, but not both.]]
130 set { 138 set {