summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmitesh Singh <amitesh.sh@samsung.com>2014-03-24 15:49:51 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2014-03-24 15:55:46 +0900
commit844392da17219d53619fbe2518985391688ee388 (patch)
tree03dfa41c396e6bc85a557a99a618d4d8f9d553e7
parent25beba7851bdac02d70b7c4f6934183dc2826958 (diff)
toolbar: Check disabled status of an item in nearest visible item.
Summary: Also - corrected the code for getting the toolbar item from the list. - added a test for it. Test Plan: elementary_test -> "Toolbar Focus" Reviewers: seoz CC: seoz Differential Revision: https://phab.enlightenment.org/D653
-rw-r--r--src/bin/test_toolbar.c23
-rw-r--r--src/lib/elm_toolbar.c34
2 files changed, 46 insertions, 11 deletions
diff --git a/src/bin/test_toolbar.c b/src/bin/test_toolbar.c
index 44723b9b6..8ce562a62 100644
--- a/src/bin/test_toolbar.c
+++ b/src/bin/test_toolbar.c
@@ -1099,18 +1099,25 @@ _focus_timer_cb(void *data)
1099} 1099}
1100 1100
1101static void 1101static void
1102_test_toolbar_focus_item_set_btn_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, 1102_test_toolbar_focus_item_set_btn_cb(void *data, Evas_Object *obj EINA_UNUSED,
1103 void *event_info EINA_UNUSED) 1103 void *event_info EINA_UNUSED)
1104{ 1104{
1105 ecore_timer_del(timer); 1105 ecore_timer_del(timer);
1106 timer = ecore_timer_add(1.5, _focus_timer_cb, data); 1106 timer = ecore_timer_add(1.5, _focus_timer_cb, data);
1107} 1107}
1108 1108
1109static void
1110_test_toolbar_focus_disable_item_btn_cb(void *data, Evas_Object *obj EINA_UNUSED,
1111 void *event_info EINA_UNUSED)
1112{
1113 elm_object_item_disabled_set(data, EINA_TRUE);
1114}
1115
1109void 1116void
1110test_toolbar_focus(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) 1117test_toolbar_focus(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
1111{ 1118{
1112 Evas_Object *win, *bx, *toolbar, *fr, *btn, *bx_opt, *chk; 1119 Evas_Object *win, *bx, *toolbar, *fr, *btn, *bx_opt, *chk;
1113 Elm_Object_Item *tb_it, *it_3; 1120 Elm_Object_Item *tb_it, *it_0, *it_3;
1114 1121
1115 win = elm_win_util_standard_add("toolbar-focus", "Toolbar Focus"); 1122 win = elm_win_util_standard_add("toolbar-focus", "Toolbar Focus");
1116 elm_win_autodel_set(win, EINA_TRUE); 1123 elm_win_autodel_set(win, EINA_TRUE);
@@ -1132,7 +1139,7 @@ test_toolbar_focus(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *e
1132 toolbar = elm_toolbar_add(win); 1139 toolbar = elm_toolbar_add(win);
1133 elm_toolbar_shrink_mode_set(toolbar, ELM_TOOLBAR_SHRINK_SCROLL); 1140 elm_toolbar_shrink_mode_set(toolbar, ELM_TOOLBAR_SHRINK_SCROLL);
1134 evas_object_size_hint_align_set(toolbar, EVAS_HINT_FILL, 0.0); 1141 evas_object_size_hint_align_set(toolbar, EVAS_HINT_FILL, 0.0);
1135 elm_toolbar_item_append(toolbar, "document-print", "Print", NULL, NULL); 1142 it_0 = elm_toolbar_item_append(toolbar, "document-print", "Print", NULL, NULL);
1136 elm_toolbar_item_append(toolbar, "folder-new", "Folder", NULL, NULL); 1143 elm_toolbar_item_append(toolbar, "folder-new", "Folder", NULL, NULL);
1137 it_3 = elm_toolbar_item_append(toolbar, "clock", "Clock", NULL, NULL); 1144 it_3 = elm_toolbar_item_append(toolbar, "clock", "Clock", NULL, NULL);
1138 elm_toolbar_item_append(toolbar, "refresh", "Update", NULL, NULL); 1145 elm_toolbar_item_append(toolbar, "refresh", "Update", NULL, NULL);
@@ -1213,6 +1220,16 @@ test_toolbar_focus(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *e
1213 _test_toolbar_focus_item_set_btn_cb, 1220 _test_toolbar_focus_item_set_btn_cb,
1214 it_3); 1221 it_3);
1215 1222
1223 btn = elm_button_add(bx_opt);
1224 elm_object_text_set(btn, "Disable 1st item.");
1225 evas_object_size_hint_weight_set(btn, 0.0, EVAS_HINT_EXPAND);
1226 evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
1227 elm_box_pack_end(bx_opt, btn);
1228 evas_object_show(btn);
1229 evas_object_smart_callback_add(btn, "clicked",
1230 _test_toolbar_focus_disable_item_btn_cb,
1231 it_0);
1232
1216 evas_object_resize(win, 420, 200); 1233 evas_object_resize(win, 420, 200);
1217 evas_object_show(win); 1234 evas_object_show(win);
1218} 1235}
diff --git a/src/lib/elm_toolbar.c b/src/lib/elm_toolbar.c
index e5ea35aa6..adf17e107 100644
--- a/src/lib/elm_toolbar.c
+++ b/src/lib/elm_toolbar.c
@@ -646,25 +646,38 @@ _elm_toolbar_nearest_visible_item_get(Evas_Object *obj, Elm_Object_Item *it)
646 Eina_List *item_list = NULL; 646 Eina_List *item_list = NULL;
647 Elm_Object_Item *item = NULL; 647 Elm_Object_Item *item = NULL;
648 ELM_TOOLBAR_DATA_GET(obj, sd); 648 ELM_TOOLBAR_DATA_GET(obj, sd);
649 Eina_Bool search_next = EINA_FALSE;
650 Evas_Object *it_obj;
649 651
650 if (!it) return NULL; 652 if (!it) return NULL;
651 653
652 evas_object_geometry_get(obj, &vx, &vy, &vw, &vh); 654 evas_object_geometry_get(obj, &vx, &vy, &vw, &vh);
653 evas_object_geometry_get(VIEW(it), &ix, &iy, &iw, &ih); 655 evas_object_geometry_get(VIEW(it), &ix, &iy, &iw, &ih);
654 656
655 if (ELM_RECTS_INCLUDE(vx, vy, vw, vh, ix, iy, iw, ih))
656 return it;
657
658 item_list = evas_object_box_children_get(sd->bx); 657 item_list = evas_object_box_children_get(sd->bx);
659 658
659 if (ELM_RECTS_INCLUDE(vx, vy, vw, vh, ix, iy, iw, ih))
660 {
661 if (!elm_object_item_disabled_get(it))
662 return it;
663 else
664 search_next = EINA_TRUE;
665 }
666
660 if ((sd->vertical && (iy < vy)) || 667 if ((sd->vertical && (iy < vy)) ||
661 (!sd->vertical && (iw < vw))) 668 (!sd->vertical && (iw < vw)) ||
669 search_next)
662 { 670 {
663 while ((item_list = eina_list_next(item_list))) 671 while ((item_list = eina_list_next(item_list)))
664 { 672 {
665 item = eina_list_data_get(item_list); 673 it_obj = eina_list_data_get(item_list);
674 if (it_obj)
675 item = evas_object_data_get(it_obj, "item");
676 if (!item)
677 break;
666 evas_object_geometry_get(VIEW(item), &cx, &cy, &cw, &ch); 678 evas_object_geometry_get(VIEW(item), &cx, &cy, &cw, &ch);
667 if (ELM_RECTS_INCLUDE(vx, vy, vw, vh, cx, cy, cw, ch)) 679 if (ELM_RECTS_INCLUDE(vx, vy, vw, vh, cx, cy, cw, ch) &&
680 !elm_object_item_disabled_get(item))
668 return item; 681 return item;
669 } 682 }
670 } 683 }
@@ -672,9 +685,14 @@ _elm_toolbar_nearest_visible_item_get(Evas_Object *obj, Elm_Object_Item *it)
672 { 685 {
673 while ((item_list = eina_list_prev(item_list))) 686 while ((item_list = eina_list_prev(item_list)))
674 { 687 {
675 item = eina_list_data_get(item_list); 688 it_obj = eina_list_data_get(item_list);
689 if (it_obj)
690 item = evas_object_data_get(it_obj, "item");
691 if (!item)
692 break;
676 evas_object_geometry_get(VIEW(item), &cx, &cy, &cw, &ch); 693 evas_object_geometry_get(VIEW(item), &cx, &cy, &cw, &ch);
677 if (ELM_RECTS_INCLUDE(vx, vy, vw, vh, cx, cy, cw, ch)) 694 if (ELM_RECTS_INCLUDE(vx, vy, vw, vh, cx, cy, cw, ch) &&
695 !elm_object_item_disabled_get(item))
678 return item; 696 return item;
679 } 697 }
680 } 698 }