summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWooHyun Jung <wh0705.jung@samsung.com>2017-11-25 18:19:47 +0900
committerWooHyun Jung <wh0705.jung@samsung.com>2017-11-25 18:19:47 +0900
commit7837195d752a49176d236b840309992317941d9f (patch)
tree4fe5d051dfcc2e450c1e96cb46b15f96b16ec39c
parentbbbaa56a7c8b35616e1bd7b384f721d80cd6e8d2 (diff)
efl_ui_toolbar: code cleaningdevs/woohyun/efl_ui_toolbar
-rw-r--r--src/lib/elementary/efl_ui_toolbar.c152
-rw-r--r--src/lib/elementary/efl_ui_toolbar.eo27
-rw-r--r--src/lib/elementary/efl_ui_toolbar_item.eo1
-rw-r--r--src/lib/elementary/efl_ui_toolbar_private.h1
4 files changed, 36 insertions, 145 deletions
diff --git a/src/lib/elementary/efl_ui_toolbar.c b/src/lib/elementary/efl_ui_toolbar.c
index e041aee186..541b30badb 100644
--- a/src/lib/elementary/efl_ui_toolbar.c
+++ b/src/lib/elementary/efl_ui_toolbar.c
@@ -67,14 +67,6 @@ _item_unselect(Efl_Ui_Toolbar_Item_Data *item)
67} 67}
68 68
69static void 69static void
70_item_mirrored_set(Evas_Object *obj EINA_UNUSED,
71 Efl_Ui_Toolbar_Item_Data *it,
72 Eina_Bool mirrored)
73{
74 efl_ui_mirrored_set(VIEW(it), mirrored);
75}
76
77static void
78_mirrored_set(Evas_Object *obj, 70_mirrored_set(Evas_Object *obj,
79 Eina_Bool mirrored) 71 Eina_Bool mirrored)
80{ 72{
@@ -83,7 +75,7 @@ _mirrored_set(Evas_Object *obj,
83 EFL_UI_TOOLBAR_DATA_GET(obj, sd); 75 EFL_UI_TOOLBAR_DATA_GET(obj, sd);
84 76
85 EINA_INLIST_FOREACH(sd->items, it) 77 EINA_INLIST_FOREACH(sd->items, it)
86 _item_mirrored_set(obj, it, mirrored); 78 efl_ui_mirrored_set(VIEW(it), mirrored);
87} 79}
88 80
89static void 81static void
@@ -94,9 +86,7 @@ _efl_ui_toolbar_item_focused(Elm_Object_Item *eo_it)
94 EFL_UI_TOOLBAR_DATA_GET(obj, sd); 86 EFL_UI_TOOLBAR_DATA_GET(obj, sd);
95 const char *focus_raise; 87 const char *focus_raise;
96 88
97 if ((!sd) || (sd->select_mode == ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY) || 89 if (!sd || (eo_it == sd->focused_item)) return;
98 (eo_it == sd->focused_item))
99 return;
100 90
101 sd->focused_item = eo_it; 91 sd->focused_item = eo_it;
102 92
@@ -123,11 +113,9 @@ _efl_ui_toolbar_item_unfocused(Elm_Object_Item *eo_it)
123 Evas_Object *obj = WIDGET(it); 113 Evas_Object *obj = WIDGET(it);
124 EFL_UI_TOOLBAR_DATA_GET(obj, sd); 114 EFL_UI_TOOLBAR_DATA_GET(obj, sd);
125 115
126 if ((!sd) || !sd->focused_item || 116 if ((!sd) || !sd->focused_item || (eo_it != sd->focused_item))
127 (eo_it != sd->focused_item))
128 return;
129 if (sd->select_mode == ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY)
130 return; 117 return;
118
131 if (elm_widget_focus_highlight_enabled_get(obj)) 119 if (elm_widget_focus_highlight_enabled_get(obj))
132 { 120 {
133 EFL_UI_TOOLBAR_ITEM_DATA_GET(sd->focused_item, focus_it); 121 EFL_UI_TOOLBAR_ITEM_DATA_GET(sd->focused_item, focus_it);
@@ -256,13 +244,6 @@ _resizing_eval_item(Efl_Ui_Toolbar_Item_Data *it)
256} 244}
257 245
258EOLIAN static void 246EOLIAN static void
259_efl_ui_toolbar_item_elm_widget_item_disabled_set(Eo *eo_id, Efl_Ui_Toolbar_Item_Data *sd, Eina_Bool disabled)
260{
261 elm_wdg_item_disabled_set(efl_super(eo_id, EFL_UI_TOOLBAR_ITEM_CLASS), disabled);
262 efl_ui_focus_composition_dirty(WIDGET(sd));
263}
264
265EOLIAN static void
266_efl_ui_toolbar_item_elm_widget_item_disable(Eo *eo_toolbar, Efl_Ui_Toolbar_Item_Data *toolbar_it) 247_efl_ui_toolbar_item_elm_widget_item_disable(Eo *eo_toolbar, Efl_Ui_Toolbar_Item_Data *toolbar_it)
267{ 248{
268 const char* emission; 249 const char* emission;
@@ -309,50 +290,30 @@ end:
309static void 290static void
310_item_select(Efl_Ui_Toolbar_Item_Data *it) 291_item_select(Efl_Ui_Toolbar_Item_Data *it)
311{ 292{
312 Evas_Object *obj;
313 Eina_Bool sel;
314
315 EFL_UI_TOOLBAR_DATA_GET(WIDGET(it), sd); 293 EFL_UI_TOOLBAR_DATA_GET(WIDGET(it), sd);
316 294
317 if (elm_wdg_item_disabled_get(EO_OBJ(it)) || (it->object)) 295 if (elm_wdg_item_disabled_get(EO_OBJ(it)) || (it->object))
318 return; 296 return;
319 297
320 sel = it->selected; 298 if (!it->selected)
321
322 if ((sd->select_mode != ELM_OBJECT_SELECT_MODE_NONE) &&
323 (sd->select_mode != ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY))
324 { 299 {
325 if (sel) 300 Elm_Object_Item *eo_it2 =
326 { 301 efl_ui_menu_selected_item_get(WIDGET(it));
327 if (sd->select_mode != ELM_OBJECT_SELECT_MODE_ALWAYS) 302 EFL_UI_TOOLBAR_ITEM_DATA_GET(eo_it2, it2);
328 _item_unselect(it); 303 _item_unselect(it2);
329 }
330 else
331 {
332 Elm_Object_Item *eo_it2 =
333 efl_ui_menu_selected_item_get(WIDGET(it));
334 EFL_UI_TOOLBAR_ITEM_DATA_GET(eo_it2, it2);
335 _item_unselect(it2);
336
337 it->selected = EINA_TRUE;
338 sd->selected_item = EO_OBJ(it);
339 304
340 elm_layout_signal_emit(VIEW(it), "elm,state,selected", "elm"); 305 it->selected = EINA_TRUE;
341 if (it->icon) 306 sd->selected_item = EO_OBJ(it);
342 elm_widget_signal_emit(it->icon, "elm,state,selected", "elm");
343 }
344 }
345 307
346 obj = WIDGET(it); 308 elm_layout_signal_emit(VIEW(it), "elm,state,selected", "elm");
309 if (it->icon)
310 elm_widget_signal_emit(it->icon, "elm,state,selected", "elm");
347 311
348 if ((!sel) || (sd->select_mode == ELM_OBJECT_SELECT_MODE_ALWAYS))
349 {
350 if (it->func) it->func((void *)(WIDGET_ITEM_DATA_GET(EO_OBJ(it))), WIDGET(it), EO_OBJ(it)); 312 if (it->func) it->func((void *)(WIDGET_ITEM_DATA_GET(EO_OBJ(it))), WIDGET(it), EO_OBJ(it));
313 efl_event_callback_legacy_call(WIDGET(it), EFL_UI_EVENT_SELECTED, EO_OBJ(it));
314 if (_elm_config->atspi_mode)
315 efl_access_state_changed_signal_emit(EO_OBJ(it), EFL_ACCESS_STATE_SELECTED, EINA_TRUE);
351 } 316 }
352
353 efl_event_callback_legacy_call(obj, EFL_UI_EVENT_SELECTED, EO_OBJ(it));
354 if (_elm_config->atspi_mode)
355 efl_access_state_changed_signal_emit(EO_OBJ(it), EFL_ACCESS_STATE_SELECTED, EINA_TRUE);
356} 317}
357 318
358/* Send order signals when item is added/deleted. 319/* Send order signals when item is added/deleted.
@@ -489,7 +450,7 @@ _item_theme_hook(Evas_Object *obj,
489 450
490 style = elm_widget_style_get(obj); 451 style = elm_widget_style_get(obj);
491 452
492 _item_mirrored_set(obj, it, efl_ui_mirrored_get(obj)); 453 efl_ui_mirrored_set(VIEW(it), efl_ui_mirrored_get(obj));
493 edje_object_scale_set(elm_layout_edje_get(view), scale); 454 edje_object_scale_set(elm_layout_edje_get(view), scale);
494 455
495 if (!it->object) 456 if (!it->object)
@@ -869,29 +830,12 @@ _access_state_cb(void *data, Evas_Object *obj EINA_UNUSED)
869EOLIAN static void 830EOLIAN static void
870_efl_ui_toolbar_item_efl_object_destructor(Eo *eo_item, Efl_Ui_Toolbar_Item_Data *item) 831_efl_ui_toolbar_item_efl_object_destructor(Eo *eo_item, Efl_Ui_Toolbar_Item_Data *item)
871{ 832{
872 Efl_Ui_Toolbar_Item_Data *next = NULL;
873 Evas_Object *obj;
874
875 EFL_UI_TOOLBAR_DATA_GET(WIDGET(item), sd); 833 EFL_UI_TOOLBAR_DATA_GET(WIDGET(item), sd);
876 834
877 obj = WIDGET(item);
878
879
880 if (!sd->delete_me)
881 next = EFL_UI_TOOLBAR_ITEM_FROM_INLIST(EINA_INLIST_GET(item)->next);
882 sd->items = eina_inlist_remove(sd->items, EINA_INLIST_GET(item)); 835 sd->items = eina_inlist_remove(sd->items, EINA_INLIST_GET(item));
883 sd->item_count--; 836 sd->item_count--;
884 if (!sd->delete_me)
885 {
886 if (!next) next = EFL_UI_TOOLBAR_ITEM_FROM_INLIST(sd->items);
887 if ((sd->select_mode == ELM_OBJECT_SELECT_MODE_ALWAYS) &&
888 item->selected && next) _item_select(next);
889 }
890
891 efl_ui_focus_composition_dirty(WIDGET(item));
892
893 _item_del(item); 837 _item_del(item);
894 efl_ui_widget_theme_apply(obj); 838 efl_ui_widget_theme_apply(WIDGET(item));
895 839
896 efl_destructor(efl_super(eo_item, EFL_UI_TOOLBAR_ITEM_CLASS)); 840 efl_destructor(efl_super(eo_item, EFL_UI_TOOLBAR_ITEM_CLASS));
897} 841}
@@ -902,11 +846,9 @@ _access_activate_cb(void *data EINA_UNUSED,
902 Elm_Object_Item *item) 846 Elm_Object_Item *item)
903{ 847{
904 EFL_UI_TOOLBAR_ITEM_DATA_GET(item, it); 848 EFL_UI_TOOLBAR_ITEM_DATA_GET(item, it);
905 EFL_UI_TOOLBAR_DATA_GET(WIDGET(it), sd);
906
907 if (elm_wdg_item_disabled_get(item)) return; 849 if (elm_wdg_item_disabled_get(item)) return;
908 850
909 if (it->selected && (sd->select_mode != ELM_OBJECT_SELECT_MODE_ALWAYS)) 851 if (it->selected)
910 { 852 {
911 _elm_access_say(E_("Unselected")); 853 _elm_access_say(E_("Unselected"));
912 _item_unselect(it); 854 _item_unselect(it);
@@ -1031,11 +973,9 @@ _item_new(Evas_Object *obj,
1031 973
1032 edje_object_message_signal_process(elm_layout_edje_get(VIEW(it))); 974 edje_object_message_signal_process(elm_layout_edje_get(VIEW(it)));
1033 975
1034 if ((!sd->items) && (sd->select_mode == ELM_OBJECT_SELECT_MODE_ALWAYS)) 976 if (!sd->items) _item_select(it);
1035 _item_select(it);
1036 977
1037 if (_elm_config->atspi_mode) 978 if (_elm_config->atspi_mode) efl_access_added(eo_it);
1038 efl_access_added(eo_it);
1039 979
1040 return it; 980 return it;
1041} 981}
@@ -1151,12 +1091,6 @@ _efl_ui_toolbar_efl_gfx_size_set(Eo *obj, Efl_Ui_Toolbar_Data *sd EINA_UNUSED, E
1151 efl_gfx_size_set(efl_super(obj, MY_CLASS), sz); 1091 efl_gfx_size_set(efl_super(obj, MY_CLASS), sz);
1152} 1092}
1153 1093
1154EOLIAN static void
1155_efl_ui_toolbar_efl_canvas_group_group_member_add(Eo *obj, Efl_Ui_Toolbar_Data *sd EINA_UNUSED, Evas_Object *member)
1156{
1157 efl_canvas_group_member_add(efl_super(obj, MY_CLASS), member);
1158}
1159
1160static Eina_Bool _efl_ui_toolbar_smart_focus_next_enable = EINA_FALSE; 1094static Eina_Bool _efl_ui_toolbar_smart_focus_next_enable = EINA_FALSE;
1161 1095
1162static void 1096static void
@@ -1560,28 +1494,6 @@ _efl_ui_toolbar_items_count(const Eo *obj EINA_UNUSED, Efl_Ui_Toolbar_Data *sd)
1560 return sd->item_count; 1494 return sd->item_count;
1561} 1495}
1562 1496
1563EOLIAN static void
1564_efl_ui_toolbar_select_mode_set(Eo *obj EINA_UNUSED, Efl_Ui_Toolbar_Data *sd, Elm_Object_Select_Mode mode)
1565{
1566 if (mode >= ELM_OBJECT_SELECT_MODE_MAX)
1567 return;
1568
1569 if (sd->select_mode == mode) return;
1570 sd->select_mode = mode;
1571
1572 if ((mode == ELM_OBJECT_SELECT_MODE_ALWAYS) &&
1573 (sd->select_mode != ELM_OBJECT_SELECT_MODE_ALWAYS) &&
1574 sd->items)
1575 _item_select(EFL_UI_TOOLBAR_ITEM_FROM_INLIST(sd->items));
1576
1577}
1578
1579EOLIAN static Elm_Object_Select_Mode
1580_efl_ui_toolbar_select_mode_get(Eo *obj EINA_UNUSED, Efl_Ui_Toolbar_Data *sd)
1581{
1582 return sd->select_mode;
1583}
1584
1585EOLIAN static const char* 1497EOLIAN static const char*
1586_efl_ui_toolbar_item_efl_access_name_get(Eo *eo_item, Efl_Ui_Toolbar_Item_Data *item) 1498_efl_ui_toolbar_item_efl_access_name_get(Eo *eo_item, Efl_Ui_Toolbar_Item_Data *item)
1587{ 1499{
@@ -1727,17 +1639,15 @@ EOLIAN Eina_Bool
1727_efl_ui_toolbar_efl_access_selection_child_deselect(Eo *obj EINA_UNUSED, Efl_Ui_Toolbar_Data *pd, int child_index) 1639_efl_ui_toolbar_efl_access_selection_child_deselect(Eo *obj EINA_UNUSED, Efl_Ui_Toolbar_Data *pd, int child_index)
1728{ 1640{
1729 Efl_Ui_Toolbar_Item_Data *item; 1641 Efl_Ui_Toolbar_Item_Data *item;
1730 if (pd->select_mode != ELM_OBJECT_SELECT_MODE_NONE) 1642
1731 { 1643 EINA_INLIST_FOREACH(pd->items, item)
1732 EINA_INLIST_FOREACH(pd->items, item) 1644 {
1733 { 1645 if (child_index-- == 0)
1734 if (child_index-- == 0) 1646 {
1735 { 1647 efl_ui_item_selected_set(EO_OBJ(item), EINA_FALSE);
1736 efl_ui_item_selected_set(EO_OBJ(item), EINA_FALSE); 1648 return EINA_TRUE;
1737 return EINA_TRUE; 1649 }
1738 } 1650 }
1739 }
1740 }
1741 return EINA_FALSE; 1651 return EINA_FALSE;
1742} 1652}
1743 1653
diff --git a/src/lib/elementary/efl_ui_toolbar.eo b/src/lib/elementary/efl_ui_toolbar.eo
index 970d581d8e..26980a3486 100644
--- a/src/lib/elementary/efl_ui_toolbar.eo
+++ b/src/lib/elementary/efl_ui_toolbar.eo
@@ -4,28 +4,12 @@ class Efl.Ui.Toolbar (Efl.Ui.Layout, Efl.Ui.Focus.Composition, Efl.Ui.Direction,
4 Efl.Access.Widget.Action, Efl.Access.Selection, 4 Efl.Access.Widget.Action, Efl.Access.Selection,
5 Efl.Ui.Clickable, Efl.Ui.Selectable, Efl.Ui.Menu) 5 Efl.Ui.Clickable, Efl.Ui.Selectable, Efl.Ui.Menu)
6{ 6{
7 [[Toolbar widget class]] 7 [[Toolbar widget
8
9 A toolbar displays a list of items inside.
10 Among them, only one can be selected at a time.
11 ]]
8 methods { 12 methods {
9 @property select_mode {
10 [[Control the toolbar select mode.
11
12 elm_toolbar_select_mode_set() changes item select mode in the toolbar widget.
13 - #ELM_OBJECT_SELECT_MODE_DEFAULT : Items will only call their selection func and
14 callback when first becoming selected. Any further clicks will
15 do nothing, unless you set always select mode.
16 - #ELM_OBJECT_SELECT_MODE_ALWAYS : This means that, even if selected,
17 every click will make the selected callbacks be called.
18 - #ELM_OBJECT_SELECT_MODE_NONE : This will turn off the ability to select items
19 entirely and they will neither appear selected nor call selected
20 callback functions.]]
21 set {
22 }
23 get {
24 }
25 values {
26 mode: Elm.Object.Select_Mode(Elm.Object.Select_Mode.max); [[The select mode If getting mode fails, it returns #ELM_OBJECT_SELECT_MODE_MAX]]
27 }
28 }
29 item_insert_before { 13 item_insert_before {
30 [[Insert a new item into the toolbar object before item $before. 14 [[Insert a new item into the toolbar object before item $before.
31 15
@@ -172,7 +156,6 @@ class Efl.Ui.Toolbar (Efl.Ui.Layout, Efl.Ui.Focus.Composition, Efl.Ui.Direction,
172 Efl.Gfx.position { set; } 156 Efl.Gfx.position { set; }
173 Efl.Gfx.size { set; } 157 Efl.Gfx.size { set; }
174 Efl.Canvas.Group.group_calculate; 158 Efl.Canvas.Group.group_calculate;
175 Efl.Canvas.Group.group_member_add;
176 Elm.Widget.on_access_update; 159 Elm.Widget.on_access_update;
177 Elm.Widget.theme_apply; 160 Elm.Widget.theme_apply;
178 Elm.Widget.on_focus_update; 161 Elm.Widget.on_focus_update;
diff --git a/src/lib/elementary/efl_ui_toolbar_item.eo b/src/lib/elementary/efl_ui_toolbar_item.eo
index e2a3abb061..0e016b3234 100644
--- a/src/lib/elementary/efl_ui_toolbar_item.eo
+++ b/src/lib/elementary/efl_ui_toolbar_item.eo
@@ -65,7 +65,6 @@ class Efl.Ui.Toolbar.Item(Elm.Widget.Item, Efl.Ui.Item, Efl.Ui.Focus.Object)
65 Efl.Object.constructor; 65 Efl.Object.constructor;
66 Efl.Object.destructor; 66 Efl.Object.destructor;
67 Elm.Widget.Item.disable; 67 Elm.Widget.Item.disable;
68 Elm.Widget.Item.disabled { set; }
69 Elm.Widget.Item.focus { get; set; } 68 Elm.Widget.Item.focus { get; set; }
70 Elm.Widget.Item.signal_emit; 69 Elm.Widget.Item.signal_emit;
71 Elm.Widget.Item.part_text { get; set; } 70 Elm.Widget.Item.part_text { get; set; }
diff --git a/src/lib/elementary/efl_ui_toolbar_private.h b/src/lib/elementary/efl_ui_toolbar_private.h
index e45157ff20..30809f75aa 100644
--- a/src/lib/elementary/efl_ui_toolbar_private.h
+++ b/src/lib/elementary/efl_ui_toolbar_private.h
@@ -32,7 +32,6 @@ struct _Efl_Ui_Toolbar_Data
32 Elm_Object_Item *focused_item; /**< a focused item by keypad arrow or mouse. This is set to NULL if widget looses focus. */ 32 Elm_Object_Item *focused_item; /**< a focused item by keypad arrow or mouse. This is set to NULL if widget looses focus. */
33 Elm_Object_Item *last_focused_item; /**< This records the last focused item when widget looses focus. This is required to set the focus on last focused item when widgets gets focus. */ 33 Elm_Object_Item *last_focused_item; /**< This records the last focused item when widget looses focus. This is required to set the focus on last focused item when widgets gets focus. */
34 unsigned int item_count; 34 unsigned int item_count;
35 Elm_Object_Select_Mode select_mode;
36 Efl_Ui_Dir dir; 35 Efl_Ui_Dir dir;
37 36
38 Eina_Bool delete_me : 1; 37 Eina_Bool delete_me : 1;