1 #include <Elementary.h>
3 #include "els_scroller.h"
7 typedef struct _Widget_Data Widget_Data;
8 typedef struct _Elm_Toolbar_Item Elm_Toolbar_Item;
12 Evas_Object *scr, *bx, *more, *bx_more, *bx_more2;
13 Evas_Object *menu_parent;
15 Elm_Toolbar_Item *more_item, *selected_item;
16 Elm_Toolbar_Shrink_Mode shrink_mode;
17 Elm_Icon_Lookup_Order lookup_order;
19 int standard_priority;
20 unsigned int item_count;
22 Elm_Object_Select_Mode select_mode;
23 Eina_Bool homogeneous : 1;
24 Eina_Bool vertical : 1;
25 Eina_Bool long_press : 1;
26 Ecore_Timer *long_timer;
27 Ecore_Job *resize_job;
30 struct _Elm_Toolbar_Item
44 Eina_Bool visible : 1;
46 Eina_Bool selected : 1;
47 Eina_Bool separator : 1;
50 Eina_List *current_state;
53 #define ELM_TOOLBAR_ITEM_FROM_INLIST(item) \
54 ((item) ? EINA_INLIST_CONTAINER_GET(item, Elm_Toolbar_Item) : NULL)
56 struct _Elm_Toolbar_Item_State
65 static const char *widtype = NULL;
66 static void _item_show(Elm_Toolbar_Item *it);
67 static void _item_select(Elm_Toolbar_Item *it);
68 static void _item_unselect(Elm_Toolbar_Item *it);
69 static void _del_pre_hook(Evas_Object *obj);
70 static void _del_hook(Evas_Object *obj);
71 static void _mirrored_set(Evas_Object *obj, Eina_Bool mirrored);
72 static void _mirrored_set_item(Evas_Object *obj, Elm_Toolbar_Item *it, Eina_Bool mirrored);
73 static void _theme_hook(Evas_Object *obj);
74 static void _sizing_eval(Evas_Object *obj);
75 static void _resize(void *data, Evas *e, Evas_Object *obj, void *event_info);
76 static void _menu_move_resize(void *data, Evas *e, Evas_Object *obj, void *event_info);
77 static void _menu_hide(void *data, Evas *e, Evas_Object *obj, void *event_info);
78 static void _layout(Evas_Object *o, Evas_Object_Box_Data *priv, void *data);
79 static void _elm_toolbar_item_icon_obj_set(Evas_Object *obj, Elm_Toolbar_Item *item, Evas_Object *icon_obj, const char *icon_str, double icon_size, const char *sig);
80 static void _item_label_set(Elm_Toolbar_Item *item, const char *label, const char *sig);
82 static const char SIG_CLICKED[] = "clicked";
83 static const char SIG_LONGPRESSED[] = "longpressed";
84 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
86 static const Evas_Smart_Cb_Description _signals[] = {
88 {SIG_LONGPRESSED, ""},
89 {SIG_CLICKED_DOUBLE, ""},
94 _item_disable_hook(Elm_Object_Item *it)
97 Elm_Toolbar_Item *toolbar_it = (Elm_Toolbar_Item *)it;
99 wd = elm_widget_data_get(WIDGET(toolbar_it));
102 if (elm_widget_item_disabled_get(toolbar_it))
104 edje_object_signal_emit(VIEW(toolbar_it), "elm,state,disabled", "elm");
105 elm_widget_signal_emit(toolbar_it->icon, "elm,state,disabled", "elm");
109 edje_object_signal_emit(VIEW(toolbar_it), "elm,state,enabled", "elm");
110 elm_widget_signal_emit(toolbar_it->icon, "elm,state,enabled", "elm");
112 _resize(WIDGET(toolbar_it), NULL, NULL, NULL);
116 _item_icon_set(Evas_Object *icon_obj, const char *type, const char *icon)
120 if ((!type) || (!*type)) goto end;
121 if ((!icon) || (!*icon)) return EINA_FALSE;
122 if ((snprintf(icon_str, sizeof(icon_str), "%s%s", type, icon) > 0)
123 && (elm_icon_standard_set(icon_obj, icon_str)))
126 if (elm_icon_standard_set(icon_obj, icon))
128 WRN("couldn't find icon definition for '%s'", icon);
133 _elm_toolbar_icon_size_get(Widget_Data *wd)
135 const char *icon_size = edje_object_data_get(
136 elm_smart_scroller_edje_object_get(wd->scr), "icon_size");
138 return atoi(icon_size);
139 return _elm_config->icon_size;
143 _item_show(Elm_Toolbar_Item *it)
145 Widget_Data *wd = elm_widget_data_get(WIDGET(it));
146 Evas_Coord x, y, w, h, bx, by;
149 evas_object_geometry_get(wd->bx, &bx, &by, NULL, NULL);
150 evas_object_geometry_get(VIEW(it), &x, &y, &w, &h);
151 elm_smart_scroller_child_region_show(wd->scr, x - bx, y - by, w, h);
155 _item_unselect(Elm_Toolbar_Item *item)
158 if ((!item) || (!item->selected)) return;
159 wd = elm_widget_data_get(WIDGET(item));
161 item->selected = EINA_FALSE;
162 wd->selected_item = NULL;
163 edje_object_signal_emit(VIEW(item), "elm,state,unselected", "elm");
164 elm_widget_signal_emit(item->icon, "elm,state,unselected", "elm");
168 _item_select(Elm_Toolbar_Item *it)
170 Elm_Toolbar_Item *it2;
171 Widget_Data *wd = elm_widget_data_get(WIDGET(it));
174 Evas_Coord w = 0, h = 0;
177 if (elm_widget_item_disabled_get(it) || (it->separator) || (it->object)) return;
180 if (it->object) evas_object_geometry_get(it->object, NULL, NULL, &w, &h);
182 if (wd->select_mode != ELM_OBJECT_SELECT_MODE_NONE)
186 if (wd->shrink_mode == ELM_TOOLBAR_SHRINK_EXPAND)
187 if (wd->more_item == it)
189 edje_object_signal_emit(elm_layout_edje_get(wd->more), "elm,state,close", "elm");
192 if (wd->select_mode != ELM_OBJECT_SELECT_MODE_ALWAYS)
197 it2 = (Elm_Toolbar_Item *)
198 elm_toolbar_selected_item_get(WIDGET(it));
201 it->selected = EINA_TRUE;
202 wd->selected_item = it;
203 if (wd->shrink_mode == ELM_TOOLBAR_SHRINK_EXPAND)
205 if (wd->more_item == it)
207 if (!evas_object_box_children_get(wd->bx_more2))
208 edje_object_signal_emit(elm_layout_edje_get(wd->more), "elm,state,open", "elm");
210 edje_object_signal_emit(elm_layout_edje_get(wd->more), "elm,state,open2", "elm");
214 if (it->in_box != wd->bx)
216 edje_object_signal_emit(wd->VIEW(more_item), "elm,state,selected", "elm");
217 elm_widget_signal_emit(wd->more_item->icon, "elm,state,selected", "elm");
221 edje_object_signal_emit(wd->VIEW(more_item), "elm,state,unselected", "elm");
222 elm_widget_signal_emit(wd->more_item->icon, "elm,state,unselected", "elm");
224 edje_object_signal_emit(elm_layout_edje_get(wd->more), "elm,state,close", "elm");
227 edje_object_signal_emit(VIEW(it), "elm,state,selected", "elm");
228 elm_widget_signal_emit(it->icon, "elm,state,selected", "elm");
233 if (it->menu && (!sel))
235 evas_object_show(it->o_menu);
236 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_RESIZE,
237 _menu_move_resize, it);
238 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MOVE,
239 _menu_move_resize, it);
241 _menu_move_resize(it, NULL, NULL, NULL);
243 if (it->func) it->func((void *)(it->base.data), WIDGET(it), it);
244 evas_object_smart_callback_call(obj2, SIG_CLICKED, it);
248 _menu_hide(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
250 Elm_Toolbar_Item *selected;
251 Elm_Toolbar_Item *it = data;
252 selected = (Elm_Toolbar_Item *) elm_toolbar_selected_item_get(WIDGET(it));
253 _item_unselect(selected);
257 _menu_del(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
259 // avoid hide being emitted during object deletion
260 evas_object_event_callback_del_full
261 (obj, EVAS_CALLBACK_HIDE, _menu_hide, data);
265 _menu_move_resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
267 Elm_Toolbar_Item *it = data;
269 Widget_Data *wd = elm_widget_data_get(WIDGET(it));
271 if ((!wd) || (!wd->menu_parent)) return;
272 evas_object_geometry_get(VIEW(it), &x, &y, &w, &h);
273 elm_menu_move(it->o_menu, x, y+h);
277 _item_del(Elm_Toolbar_Item *it)
279 Elm_Toolbar_Item_State *it_state;
281 EINA_LIST_FREE(it->states, it_state)
283 if (it->icon == it_state->icon)
285 eina_stringshare_del(it_state->label);
286 eina_stringshare_del(it_state->icon_str);
287 if (it_state->icon) evas_object_del(it_state->icon);
290 eina_stringshare_del(it->label);
291 eina_stringshare_del(it->icon_str);
292 if (it->icon) evas_object_del(it->icon);
293 if (it->object) evas_object_del(it->object);
294 //TODO: See if checking for wd->menu_parent is necessary before deleting menu
295 if (it->o_menu) evas_object_del(it->o_menu);
299 _del_pre_hook(Evas_Object *obj)
301 Widget_Data *wd = elm_widget_data_get(obj);
302 Elm_Toolbar_Item *it, *next;
305 it = ELM_TOOLBAR_ITEM_FROM_INLIST(wd->items);
308 next = ELM_TOOLBAR_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
310 elm_widget_item_free(it);
315 _item_del(wd->more_item);
316 elm_widget_item_free(wd->more_item);
320 ecore_timer_del(wd->long_timer);
321 wd->long_timer = NULL;
326 _del_hook(Evas_Object *obj)
328 Widget_Data *wd = elm_widget_data_get(obj);
336 _mirrored_set_item(Evas_Object *obj __UNUSED__, Elm_Toolbar_Item *it, Eina_Bool mirrored)
338 edje_object_mirrored_set(VIEW(it), mirrored);
339 if (it->o_menu) elm_widget_mirrored_set(it->o_menu, mirrored);
343 _theme_hook_item(Evas_Object *obj, Elm_Toolbar_Item *it, double scale, int icon_size)
345 Widget_Data *wd = elm_widget_data_get(obj);
346 Evas_Object *view = VIEW(it);
348 const char *style = elm_widget_style_get(obj);
350 _mirrored_set_item(obj, it, elm_widget_mirrored_get(obj));
351 edje_object_scale_set(view, scale);
352 if (!it->separator && !it->object)
354 _elm_theme_object_set(obj, view, "toolbar", "item", style);
357 edje_object_signal_emit(view, "elm,state,selected", "elm");
358 elm_widget_signal_emit(it->icon, "elm,state,selected", "elm");
360 if (elm_widget_item_disabled_get(it))
362 edje_object_signal_emit(view, "elm,state,disabled", "elm");
363 elm_widget_signal_emit(it->icon, "elm,state,disabled", "elm");
369 ms = ((double)icon_size * scale);
370 evas_object_size_hint_min_set(it->icon, ms, ms);
371 evas_object_size_hint_max_set(it->icon, ms, ms);
372 edje_object_part_swallow(view, "elm.swallow.icon", it->icon);
374 edje_object_part_text_escaped_set(view, "elm.text", it->label);
380 _elm_theme_object_set(obj, view, "toolbar", "separator", style);
383 evas_object_size_hint_weight_set(view, EVAS_HINT_EXPAND, -1.0);
384 evas_object_size_hint_align_set(view, EVAS_HINT_FILL, 0.5);
388 evas_object_size_hint_weight_set(view, -1.0, EVAS_HINT_EXPAND);
389 evas_object_size_hint_align_set(view, 0.5, EVAS_HINT_FILL);
394 _elm_theme_object_set(obj, view, "toolbar", "object", style);
395 edje_object_part_swallow(view, "elm.swallow.object", it->object);
400 if (!it->separator && !it->object)
401 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
402 edje_object_size_min_restricted_calc(view, &mw, &mh, mw, mh);
403 if (!it->separator && !it->object)
404 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
405 evas_object_size_hint_min_set(view, mw, mh);
409 _mirrored_set(Evas_Object *obj, Eina_Bool mirrored)
411 Widget_Data *wd = elm_widget_data_get(obj);
412 Elm_Toolbar_Item *it;
414 EINA_INLIST_FOREACH(wd->items, it)
415 _mirrored_set_item(obj, it, mirrored);
417 _mirrored_set_item(obj, wd->more_item, mirrored);
421 _theme_hook(Evas_Object *obj)
423 Widget_Data *wd = elm_widget_data_get(obj);
424 Elm_Toolbar_Item *it;
428 _elm_widget_mirrored_reload(obj);
429 elm_smart_scroller_object_theme_set(obj, wd->scr, "toolbar", "base", elm_widget_style_get(obj));
430 _mirrored_set(obj, elm_widget_mirrored_get(obj));
431 scale = (elm_widget_scale_get(obj) * _elm_config->scale);
432 edje_object_scale_set(wd->scr, scale);
433 wd->icon_size = _elm_toolbar_icon_size_get(wd);
434 EINA_INLIST_FOREACH(wd->items, it)
435 _theme_hook_item(obj, it, scale, wd->icon_size);
437 _theme_hook_item(obj, wd->more_item, scale, wd->icon_size);
442 _item_text_set_hook(Elm_Object_Item *it,
446 if (part && strcmp(part, "default")) return;
447 _item_label_set(((Elm_Toolbar_Item *)it), label, "elm,state,label_set");
451 _item_text_get_hook(const Elm_Object_Item *it, const char *part)
453 if (part && strcmp(part, "default")) return NULL;
454 return ((Elm_Toolbar_Item *)it)->label;
458 _item_content_set_hook(Elm_Object_Item *it,
460 Evas_Object *content)
464 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
465 if (part && strcmp(part, "object")) return;
466 Elm_Toolbar_Item *item = (Elm_Toolbar_Item *) it;
467 Evas_Object *obj = WIDGET(item);
468 Widget_Data *wd = elm_widget_data_get(obj);
469 if (!wd || !obj) return;
470 if (item->object == content) return;
472 if (item->object) evas_object_del(item->object);
474 item->object = content;
476 elm_widget_sub_object_add(obj, item->object);
477 scale = (elm_widget_scale_get(obj) * _elm_config->scale);
478 _theme_hook_item(obj, item, scale, wd->icon_size);
482 _item_content_get_hook(const Elm_Object_Item *it, const char *part)
484 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
485 if (part && strcmp(part, "object")) return NULL;
486 return ((Elm_Toolbar_Item *) it)->object;
490 _item_content_unset_hook(Elm_Object_Item *it, const char *part)
495 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
496 if (part && strcmp(part, "object")) return NULL;
497 Elm_Toolbar_Item *item = (Elm_Toolbar_Item *) it;
498 Evas_Object *obj = WIDGET(item);
499 Widget_Data *wd = elm_widget_data_get(obj);
501 edje_object_part_unswallow(VIEW(it), item->object);
502 elm_widget_sub_object_del(obj, item->object);
505 scale = (elm_widget_scale_get(obj) * _elm_config->scale);
506 _theme_hook_item(obj, item, scale, wd->icon_size);
511 _translate_hook(Evas_Object *obj)
513 evas_object_smart_callback_call(obj, "language,changed", NULL);
517 _sizing_eval(Evas_Object *obj)
519 Widget_Data *wd = elm_widget_data_get(obj);
520 Evas_Coord minw = -1, minh = -1, minw_bx = -1, minh_bx = -1;
521 Evas_Coord vw = 0, vh = 0;
525 evas_object_smart_need_recalculate_set(wd->bx, EINA_TRUE);
526 evas_object_smart_calculate(wd->bx);
527 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr),
529 evas_object_geometry_get(obj, NULL, NULL, &w, &h);
530 if (w < minw) w = minw;
531 if (h < minh) h = minh;
532 evas_object_resize(wd->scr, w, h);
534 evas_object_size_hint_min_get(wd->bx, &minw_bx, &minh_bx);
535 // if (wd->vertical && (h > minh)) minh = h;
536 // if ((!wd->vertical) && (w > minw)) minw = w;
537 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
538 if (wd->shrink_mode == ELM_TOOLBAR_SHRINK_NONE)
542 minw = minw_bx + (w - vw);
543 minh = minh_bx + (h - vh);
547 minw = minw_bx + (w - vw);
548 minh = minh_bx + (h - vh);
551 else if (wd->shrink_mode == ELM_TOOLBAR_SHRINK_EXPAND)
553 minw = minw_bx + (w - vw);
554 minh = minh_bx + (h - vh);
555 if (minw_bx < vw) minw_bx = vw;
556 if (minh_bx < vh) minh_bx = vh;
562 minw = minw_bx + (w - vw);
568 minh = minh_bx + (h - vh);
570 // if (wd->vertical) minh = h - vh;
571 // else minw = w - vw;
572 // minh = minh + (h - vh);
574 evas_object_resize(wd->bx, minw_bx, minh_bx);
575 evas_object_resize(wd->more, w, h);
576 evas_object_size_hint_min_set(obj, minw, minh);
577 evas_object_size_hint_max_set(obj, -1, -1);
581 _item_menu_create(Widget_Data *wd, Elm_Toolbar_Item *item)
583 item->o_menu = elm_menu_add(WIDGET(item));
584 item->menu = EINA_TRUE;
586 elm_menu_parent_set(item->o_menu, wd->menu_parent);
587 evas_object_event_callback_add(item->o_menu, EVAS_CALLBACK_HIDE,
589 evas_object_event_callback_add(item->o_menu, EVAS_CALLBACK_DEL,
594 _item_menu_destroy(Elm_Toolbar_Item *item)
598 evas_object_del(item->o_menu);
601 item->menu = EINA_FALSE;
605 _toolbar_item_prio_compare_cb(const void *i1, const void *i2)
607 const Elm_Toolbar_Item *eti1 = i1;
608 const Elm_Toolbar_Item *eti2 = i2;
611 if (!eti1) return -1;
613 if (eti2->prio.priority == eti1->prio.priority)
616 return eti2->prio.priority - eti1->prio.priority;
620 _fix_items_visibility(Widget_Data *wd, Evas_Coord *iw, Evas_Coord vw, Eina_Bool *more)
622 Elm_Toolbar_Item *it, *prev;
623 Eina_List *sorted = NULL;
624 Evas_Coord ciw = 0, cih = 0;
625 int count = 0, i = 0;
628 EINA_INLIST_FOREACH(wd->items, it)
632 prev = ELM_TOOLBAR_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
633 it->prio.priority = prev->prio.priority;
637 EINA_INLIST_FOREACH(wd->items, it)
639 sorted = eina_list_sorted_insert(sorted,
640 _toolbar_item_prio_compare_cb, it);
645 evas_object_geometry_get(wd->VIEW(more_item), NULL, NULL, &ciw, &cih);
646 if (wd->vertical) *iw += cih;
650 EINA_LIST_FREE(sorted, it)
652 if (it->prio.priority > wd->standard_priority)
654 evas_object_geometry_get(VIEW(it), NULL, NULL, &ciw, &cih);
655 if (wd->vertical) *iw += cih;
657 it->prio.visible = (*iw <= vw);
659 if (!it->separator) count++;
663 it->prio.visible = EINA_FALSE;
664 if (!it->separator) i++;
665 if (i <= (count + 1))
666 it->in_box = wd->bx_more;
668 it->in_box = wd->bx_more2;
675 _elm_toolbar_item_menu_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
677 Elm_Toolbar_Item *it = data;
678 if (it->func) it->func((void *)(it->base.data), WIDGET(it), it);
682 _resize_job(void *data)
684 Evas_Object *obj = (Evas_Object *)data;
685 Widget_Data *wd = elm_widget_data_get(obj);
686 Evas_Coord mw, mh, vw = 0, vh = 0, w = 0, h = 0;
687 Elm_Toolbar_Item *it;
692 wd->resize_job = NULL;
693 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
694 evas_object_size_hint_min_get(wd->bx, &mw, &mh);
695 evas_object_geometry_get(wd->bx, NULL, NULL, &w, &h);
696 if (wd->shrink_mode == ELM_TOOLBAR_SHRINK_MENU)
698 Evas_Coord iw = 0, ih = 0, more_w = 0, more_h = 0;
702 evas_object_resize(wd->bx, w, vh);
703 _fix_items_visibility(wd, &ih, vh, &more);
707 evas_object_resize(wd->bx, vw, h);
708 _fix_items_visibility(wd, &iw, vw, &more);
710 evas_object_geometry_get(wd->VIEW(more_item), NULL, NULL,
714 if ((ih - more_h) <= vh) ih -= more_h;
718 if ((iw - more_w) <= vw) iw -= more_w;
721 /* All items are removed from the box object, since removing individual
722 * items won't trigger a resize. Items are be readded below. */
723 evas_object_box_remove_all(wd->bx, EINA_FALSE);
724 if (((wd->vertical) && (ih > vh)) ||
725 ((!wd->vertical) && (iw > vw)) || more)
729 _item_menu_destroy(wd->more_item);
730 _item_menu_create(wd, wd->more_item);
731 menu = elm_toolbar_item_menu_get((Elm_Object_Item *)wd->more_item);
732 EINA_INLIST_FOREACH(wd->items, it)
734 if (!it->prio.visible)
737 elm_menu_item_separator_add(menu, NULL);
740 Elm_Object_Item *menu_it;
741 menu_it = elm_menu_item_add
742 (menu, NULL, it->icon_str, it->label,
743 _elm_toolbar_item_menu_cb, it);
744 elm_object_item_disabled_set
745 (menu_it, elm_widget_item_disabled_get(it));
747 elm_menu_clone(it->o_menu, menu, menu_it);
749 evas_object_hide(VIEW(it));
753 evas_object_box_append(wd->bx, VIEW(it));
754 evas_object_show(VIEW(it));
757 evas_object_box_append(wd->bx, wd->VIEW(more_item));
758 evas_object_show(wd->VIEW(more_item));
762 /* All items are visible, show them all (except for the "More"
763 * button, of course). */
764 EINA_INLIST_FOREACH(wd->items, it)
766 evas_object_show(VIEW(it));
767 evas_object_box_append(wd->bx, VIEW(it));
769 evas_object_hide(wd->VIEW(more_item));
772 else if (wd->shrink_mode == ELM_TOOLBAR_SHRINK_HIDE)
774 Evas_Coord iw = 0, ih = 0;
778 evas_object_resize(wd->bx, w, vh);
779 _fix_items_visibility(wd, &ih, vh, &more);
783 evas_object_resize(wd->bx, vw, h);
784 _fix_items_visibility(wd, &iw, vw, &more);
786 evas_object_box_remove_all(wd->bx, EINA_FALSE);
787 if (((wd->vertical) && (ih > vh)) ||
788 ((!wd->vertical) && (iw > vw)) || more)
790 EINA_INLIST_FOREACH(wd->items, it)
792 if (!it->prio.visible)
793 evas_object_hide(VIEW(it));
796 evas_object_box_append(wd->bx, VIEW(it));
797 evas_object_show(VIEW(it));
803 /* All items are visible, show them all */
804 EINA_INLIST_FOREACH(wd->items, it)
806 evas_object_show(VIEW(it));
807 evas_object_box_append(wd->bx, VIEW(it));
811 else if (wd->shrink_mode == ELM_TOOLBAR_SHRINK_EXPAND)
813 Evas_Coord iw = 0, ih = 0;
814 if ((vw >= mw) && (vh >= mh))
815 evas_object_resize(wd->bx, vw, vh);
817 evas_object_resize(wd->bx, mw, vh);
819 evas_object_resize(wd->bx, vw, mh);
822 _fix_items_visibility(wd, &ih, vh, &more);
824 _fix_items_visibility(wd, &iw, vw, &more);
826 evas_object_box_remove_all(wd->bx, EINA_FALSE);
827 evas_object_box_remove_all(wd->bx_more, EINA_FALSE);
828 evas_object_box_remove_all(wd->bx_more2, EINA_FALSE);
829 EINA_INLIST_FOREACH(wd->items, it)
833 evas_object_box_append(it->in_box, VIEW(it));
834 evas_object_show(VIEW(it));
839 evas_object_box_append(wd->bx, wd->VIEW(more_item));
840 evas_object_show(wd->VIEW(more_item));
843 evas_object_hide(wd->VIEW(more_item));
849 if ((vh >= mh) && (h != vh)) evas_object_resize(wd->bx, w, vh);
853 if ((vw >= mw) && (w != vw)) evas_object_resize(wd->bx, vw, h);
855 EINA_INLIST_FOREACH(wd->items, it)
865 // Remove the first or last separator since it is not neccessary
866 list = evas_object_box_children_get(wd->bx_more);
867 EINA_INLIST_FOREACH(wd->items, it)
869 if (it->separator && ((VIEW(it) == eina_list_data_get(list)) ||
870 (VIEW(it) == eina_list_nth(list, eina_list_count(list)-1))))
872 evas_object_box_remove(wd->bx_more, VIEW(it));
873 evas_object_move(VIEW(it), -9999, -9999);
874 evas_object_hide(VIEW(it));
877 list = evas_object_box_children_get(wd->bx_more2);
878 EINA_INLIST_FOREACH(wd->items, it)
880 if (it->separator && ((VIEW(it) == eina_list_data_get(list)) ||
881 (VIEW(it) == eina_list_nth(list, eina_list_count(list)-1))))
883 evas_object_box_remove(wd->bx_more2, VIEW(it));
884 evas_object_move(VIEW(it), -9999, -9999);
885 evas_object_hide(VIEW(it));
889 _mirrored_set(obj, elm_widget_mirrored_get(obj));
893 _resize_item(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
896 _resize(data, NULL, NULL, NULL);
900 _resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
902 Widget_Data *wd = elm_widget_data_get(data);
904 evas_object_geometry_get(data, &x, &y, NULL, &h);
905 evas_object_move(wd->more, x, y + h);
907 wd->resize_job = ecore_job_add(_resize_job, data);
911 _move(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
913 Widget_Data *wd = elm_widget_data_get(data);
915 evas_object_geometry_get(data, &x, &y, NULL, &h);
916 evas_object_move(wd->more, x, y + h);
920 _select_filter(Elm_Toolbar_Item *it, Evas_Object *obj __UNUSED__, const char *emission, const char *source __UNUSED__)
923 char buf[sizeof("elm,action,click,") + 1];
925 button = atoi(emission + sizeof("mouse,clicked,") - 1);
926 if (button == 1) return; /* regular left click event */
927 snprintf(buf, sizeof(buf), "elm,action,click,%d", button);
928 edje_object_signal_emit(VIEW(it), buf, "elm");
932 _select(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
934 Elm_Toolbar_Item *it = data;
936 if ((_elm_config->access_mode == ELM_ACCESS_MODE_OFF) ||
937 (_elm_access_2nd_click_timeout(VIEW(it))))
939 if (_elm_config->access_mode != ELM_ACCESS_MODE_OFF)
940 _elm_access_say(E_("Selected"));
946 _long_press(Elm_Toolbar_Item *it)
948 Widget_Data *wd = elm_widget_data_get(WIDGET(it));
949 wd->long_timer = NULL;
950 wd->long_press = EINA_TRUE;
951 evas_object_smart_callback_call(WIDGET(it), SIG_LONGPRESSED, it);
952 return ECORE_CALLBACK_CANCEL;
956 _mouse_down(Elm_Toolbar_Item *it, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, Evas_Event_Mouse_Down *ev)
958 Widget_Data *wd = elm_widget_data_get(WIDGET(it));
960 if (ev->button != 1) return;
961 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
962 evas_object_smart_callback_call(WIDGET(it), SIG_CLICKED_DOUBLE, it);
963 wd->long_press = EINA_FALSE;
964 if (wd->long_timer) ecore_timer_interval_set(wd->long_timer, _elm_config->longpress_timeout);
965 else wd->long_timer = ecore_timer_add(_elm_config->longpress_timeout, (Ecore_Task_Cb)_long_press, it);
969 _mouse_up(Elm_Toolbar_Item *it, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, Evas_Event_Mouse_Up *ev)
971 Widget_Data *wd = elm_widget_data_get(WIDGET(it));
973 if (ev->button != 1) return;
976 ecore_timer_del(wd->long_timer);
977 wd->long_timer = NULL;
982 _mouse_in(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
984 Elm_Toolbar_Item *it = data;
985 edje_object_signal_emit(VIEW(it), "elm,state,highlighted", "elm");
986 elm_widget_signal_emit(it->icon, "elm,state,highlighted", "elm");
990 _mouse_out(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
992 Elm_Toolbar_Item *it = data;
993 edje_object_signal_emit(VIEW(it), "elm,state,unhighlighted", "elm");
994 elm_widget_signal_emit(it->icon, "elm,state,unhighlighted", "elm");
998 _layout(Evas_Object *o, Evas_Object_Box_Data *priv, void *data)
1000 Evas_Object *obj = (Evas_Object *) data;
1001 Widget_Data *wd = elm_widget_data_get(obj);
1003 _els_box_layout(o, priv, !wd->vertical, wd->homogeneous,
1004 elm_widget_mirrored_get(obj));
1008 _access_info_cb(void *data __UNUSED__, Evas_Object *obj __UNUSED__, Elm_Widget_Item *item)
1010 Elm_Toolbar_Item *it = (Elm_Toolbar_Item *)item;
1011 const char *txt = item->access_info;
1012 if (!txt) txt = it->label;
1013 if (txt) return strdup(txt);
1018 _access_state_cb(void *data __UNUSED__, Evas_Object *obj __UNUSED__, Elm_Widget_Item *item __UNUSED__)
1020 Elm_Toolbar_Item *it = (Elm_Toolbar_Item *)item;
1022 return strdup(E_("Separator"));
1023 else if (elm_widget_item_disabled_get(it))
1024 return strdup(E_("State: Disabled"));
1025 else if (it->selected)
1026 return strdup(E_("State: Selected"));
1028 return strdup(E_("Has menu"));
1033 _item_del_pre_hook(Elm_Object_Item *it)
1037 Elm_Toolbar_Item *item, *next;
1038 item = (Elm_Toolbar_Item *)it;
1040 wd = elm_widget_data_get(WIDGET(item));
1041 if (!wd) return EINA_FALSE;
1043 obj2 = WIDGET(item);
1044 next = ELM_TOOLBAR_ITEM_FROM_INLIST(EINA_INLIST_GET(item)->next);
1045 wd->items = eina_inlist_remove(wd->items, EINA_INLIST_GET(item));
1047 if (!next) next = ELM_TOOLBAR_ITEM_FROM_INLIST(wd->items);
1048 if ((wd->select_mode == ELM_OBJECT_SELECT_MODE_ALWAYS) &&
1049 item->selected && next) _item_select(next);
1056 static Elm_Toolbar_Item *
1057 _item_new(Evas_Object *obj, const char *icon, const char *label, Evas_Smart_Cb func, const void *data)
1059 Widget_Data *wd = elm_widget_data_get(obj);
1060 Evas_Object *icon_obj;
1062 Elm_Toolbar_Item *it;
1064 icon_obj = elm_icon_add(obj);
1065 elm_icon_order_lookup_set(icon_obj, wd->lookup_order);
1066 if (!icon_obj) return NULL;
1067 it = elm_widget_item_new(obj, Elm_Toolbar_Item);
1070 evas_object_del(icon_obj);
1074 elm_widget_item_del_pre_hook_set(it, _item_del_pre_hook);
1075 elm_widget_item_disable_hook_set(it, _item_disable_hook);
1076 elm_widget_item_text_set_hook_set(it, _item_text_set_hook);
1077 elm_widget_item_text_get_hook_set(it, _item_text_get_hook);
1078 elm_widget_item_content_set_hook_set(it, _item_content_set_hook);
1079 elm_widget_item_content_get_hook_set(it, _item_content_get_hook);
1080 elm_widget_item_content_unset_hook_set(it, _item_content_unset_hook);
1082 it->label = eina_stringshare_add(label);
1083 it->prio.visible = 1;
1084 it->prio.priority = 0;
1086 it->separator = EINA_FALSE;
1088 it->base.data = data;
1089 VIEW(it) = edje_object_add(evas_object_evas_get(obj));
1090 _elm_access_item_register(&it->base, VIEW(it));
1091 _elm_access_text_set(_elm_access_item_get(&it->base),
1092 ELM_ACCESS_TYPE, E_("Tool Item"));
1093 _elm_access_callback_set(_elm_access_item_get(&it->base),
1094 ELM_ACCESS_INFO, _access_info_cb, it);
1095 _elm_access_callback_set(_elm_access_item_get(&it->base),
1096 ELM_ACCESS_STATE, _access_state_cb, it);
1098 if (_item_icon_set(icon_obj, "toolbar/", icon))
1100 it->icon = icon_obj;
1101 it->icon_str = eina_stringshare_add(icon);
1106 it->icon_str = NULL;
1107 evas_object_del(icon_obj);
1110 _elm_theme_object_set(obj, VIEW(it), "toolbar", "item",
1111 elm_widget_style_get(obj));
1112 edje_object_signal_callback_add(VIEW(it), "elm,action,click", "elm",
1114 edje_object_signal_callback_add(VIEW(it), "mouse,clicked,*", "*",
1115 (Edje_Signal_Cb)_select_filter, it);
1116 edje_object_signal_callback_add(VIEW(it), "elm,mouse,in", "elm",
1118 edje_object_signal_callback_add(VIEW(it), "elm,mouse,out", "elm",
1120 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MOUSE_DOWN,
1121 (Evas_Object_Event_Cb)_mouse_down, it);
1122 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MOUSE_UP,
1123 (Evas_Object_Event_Cb)_mouse_up, it);
1124 elm_widget_sub_object_add(obj, VIEW(it));
1129 ms = ((double)wd->icon_size * _elm_config->scale);
1130 evas_object_size_hint_min_set(it->icon, ms, ms);
1131 evas_object_size_hint_max_set(it->icon, ms, ms);
1132 edje_object_part_swallow(VIEW(it), "elm.swallow.icon", it->icon);
1133 edje_object_signal_emit(VIEW(it), "elm,state,icon,visible", "elm");
1134 evas_object_show(it->icon);
1135 elm_widget_sub_object_add(obj, it->icon);
1139 edje_object_part_text_escaped_set(VIEW(it), "elm.text", it->label);
1140 edje_object_signal_emit(VIEW(it), "elm,state,text,visible", "elm");
1143 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1144 edje_object_size_min_restricted_calc(VIEW(it), &mw, &mh, mw, mh);
1145 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1146 if (wd->shrink_mode != ELM_TOOLBAR_SHRINK_EXPAND)
1150 evas_object_size_hint_weight_set(VIEW(it), EVAS_HINT_EXPAND, -1.0);
1151 evas_object_size_hint_align_set(VIEW(it), EVAS_HINT_FILL, 0.5);
1155 evas_object_size_hint_weight_set(VIEW(it), -1.0, EVAS_HINT_EXPAND);
1156 evas_object_size_hint_align_set(VIEW(it), 0.5, EVAS_HINT_FILL);
1161 evas_object_size_hint_weight_set(VIEW(it), EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1162 evas_object_size_hint_align_set(VIEW(it), EVAS_HINT_FILL, EVAS_HINT_FILL);
1164 evas_object_size_hint_min_set(VIEW(it), mw, mh);
1165 evas_object_size_hint_max_set(VIEW(it), -1, -1);
1166 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_RESIZE,
1168 if ((!wd->items) && (wd->select_mode == ELM_OBJECT_SELECT_MODE_ALWAYS))
1174 _elm_toolbar_item_label_update(Elm_Toolbar_Item *item)
1176 Evas_Coord mw = -1, mh = -1;
1177 Widget_Data *wd = elm_widget_data_get(WIDGET(item));
1178 edje_object_part_text_escaped_set(VIEW(item), "elm.text", item->label);
1179 edje_object_signal_emit(VIEW(item), "elm,state,text,visible", "elm");
1181 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1182 edje_object_size_min_restricted_calc(VIEW(item), &mw, &mh, mw, mh);
1183 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1184 if (wd->shrink_mode != ELM_TOOLBAR_SHRINK_EXPAND)
1188 evas_object_size_hint_weight_set(VIEW(item), EVAS_HINT_EXPAND, -1.0);
1189 evas_object_size_hint_align_set(VIEW(item), EVAS_HINT_FILL, 0.5);
1193 evas_object_size_hint_weight_set(VIEW(item), -1.0, EVAS_HINT_EXPAND);
1194 evas_object_size_hint_align_set(VIEW(item), 0.5, EVAS_HINT_FILL);
1199 evas_object_size_hint_weight_set(VIEW(item), EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1200 evas_object_size_hint_align_set(VIEW(item), EVAS_HINT_FILL, EVAS_HINT_FILL);
1202 evas_object_size_hint_min_set(VIEW(item), mw, mh);
1206 _elm_toolbar_item_label_set_cb (void *data, Evas_Object *obj, const char *emission, const char *source)
1208 Elm_Toolbar_Item *item = data;
1209 _elm_toolbar_item_label_update(item);
1210 edje_object_signal_callback_del(obj, emission, source,
1211 _elm_toolbar_item_label_set_cb);
1212 edje_object_signal_emit (VIEW(item), "elm,state,label,reset", "elm");
1216 _item_label_set(Elm_Toolbar_Item *item, const char *label, const char *sig)
1220 if ((label) && (item->label) && (!strcmp(label, item->label))) return;
1222 eina_stringshare_replace(&item->label, label);
1223 s = edje_object_data_get(VIEW(item), "transition_animation_on");
1224 if ((s) && (atoi(s)))
1226 edje_object_part_text_escaped_set(VIEW(item), "elm.text_new", item->label);
1227 edje_object_signal_emit (VIEW(item), sig, "elm");
1228 edje_object_signal_callback_add(VIEW(item),
1229 "elm,state,label_set,done", "elm",
1230 _elm_toolbar_item_label_set_cb, item);
1233 _elm_toolbar_item_label_update(item);
1234 _resize(WIDGET(item), NULL, NULL, NULL);
1238 _elm_toolbar_item_icon_update(Elm_Toolbar_Item *item)
1240 Elm_Toolbar_Item_State *it_state;
1242 Evas_Coord mw = -1, mh = -1;
1243 Widget_Data *wd = elm_widget_data_get(WIDGET(item));
1244 Evas_Object *old_icon = edje_object_part_swallow_get(VIEW(item),
1245 "elm.swallow.icon");
1246 elm_widget_sub_object_del(VIEW(item), old_icon);
1247 evas_object_hide(old_icon);
1248 edje_object_part_swallow(VIEW(item), "elm.swallow.icon", item->icon);
1249 edje_object_signal_emit(VIEW(item), "elm,state,icon,visible", "elm");
1250 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1251 edje_object_size_min_restricted_calc(VIEW(item), &mw, &mh, mw, mh);
1252 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1253 if (wd->shrink_mode != ELM_TOOLBAR_SHRINK_EXPAND)
1257 evas_object_size_hint_weight_set(VIEW(item), EVAS_HINT_EXPAND, -1.0);
1258 evas_object_size_hint_align_set(VIEW(item), EVAS_HINT_FILL, 0.5);
1262 evas_object_size_hint_weight_set(VIEW(item), -1.0, EVAS_HINT_EXPAND);
1263 evas_object_size_hint_align_set(VIEW(item), 0.5, EVAS_HINT_FILL);
1268 evas_object_size_hint_weight_set(VIEW(item), EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1269 evas_object_size_hint_align_set(VIEW(item), EVAS_HINT_FILL, EVAS_HINT_FILL);
1271 evas_object_size_hint_min_set(VIEW(item), mw, mh);
1273 EINA_LIST_FOREACH(item->states, l, it_state)
1275 if (it_state->icon == old_icon) return;
1277 evas_object_del(old_icon);
1281 _elm_toolbar_item_icon_set_cb (void *data, Evas_Object *obj, const char *emission, const char *source)
1283 Elm_Toolbar_Item *item = data;
1284 edje_object_part_unswallow(VIEW(item), item->icon);
1285 _elm_toolbar_item_icon_update(item);
1286 edje_object_signal_callback_del(obj, emission, source,
1287 _elm_toolbar_item_icon_set_cb);
1288 edje_object_signal_emit (VIEW(item), "elm,state,icon,reset", "elm");
1292 _elm_toolbar_item_icon_obj_set(Evas_Object *obj, Elm_Toolbar_Item *item, Evas_Object *icon_obj, const char *icon_str, double icon_size, const char *sig)
1294 Evas_Object *old_icon;
1299 eina_stringshare_replace(&item->icon_str, icon_str);
1302 eina_stringshare_del(item->icon_str);
1303 item->icon_str = NULL;
1305 item->icon = icon_obj;
1308 ms = (icon_size * _elm_config->scale);
1309 evas_object_size_hint_min_set(item->icon, ms, ms);
1310 evas_object_size_hint_max_set(item->icon, ms, ms);
1311 evas_object_show(item->icon);
1312 elm_widget_sub_object_add(obj, item->icon);
1314 s = edje_object_data_get(VIEW(item), "transition_animation_on");
1315 if ((s) && (atoi(s)))
1317 old_icon = edje_object_part_swallow_get(VIEW(item),
1318 "elm.swallow.icon_new");
1321 elm_widget_sub_object_del(VIEW(item), old_icon);
1322 evas_object_hide(old_icon);
1324 edje_object_part_swallow(VIEW(item), "elm.swallow.icon_new",
1326 edje_object_signal_emit (VIEW(item), sig, "elm");
1327 edje_object_signal_callback_add(VIEW(item),
1328 "elm,state,icon_set,done", "elm",
1329 _elm_toolbar_item_icon_set_cb, item);
1332 _elm_toolbar_item_icon_update(item);
1333 _resize(obj, NULL, NULL, NULL);
1337 _elm_toolbar_item_state_cb(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1339 Elm_Toolbar_Item *it = event_info;
1340 Elm_Toolbar_Item_State *it_state;
1342 it_state = eina_list_data_get(it->current_state);
1344 it_state->func((void *)it_state->data, obj, event_info);
1347 static Elm_Toolbar_Item_State *
1348 _item_state_new(const char *label, const char *icon_str, Evas_Object *icon, Evas_Smart_Cb func, const void *data)
1350 Elm_Toolbar_Item_State *it_state;
1351 it_state = ELM_NEW(Elm_Toolbar_Item_State);
1352 it_state->label = eina_stringshare_add(label);
1353 it_state->icon_str = eina_stringshare_add(icon_str);
1354 it_state->icon = icon;
1355 it_state->func = func;
1356 it_state->data = data;
1361 elm_toolbar_add(Evas_Object *parent)
1367 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
1369 ELM_SET_WIDTYPE(widtype, "toolbar");
1370 elm_widget_type_set(obj, "toolbar");
1371 elm_widget_sub_object_add(parent, obj);
1372 elm_widget_data_set(obj, wd);
1373 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
1374 elm_widget_del_hook_set(obj, _del_hook);
1375 elm_widget_theme_hook_set(obj, _theme_hook);
1376 elm_widget_translate_hook_set(obj, _translate_hook);
1377 elm_widget_can_focus_set(obj, EINA_TRUE);
1379 wd->more_item = NULL;
1380 wd->selected_item = NULL;
1381 wd->standard_priority = -99999;
1382 wd->scr = elm_smart_scroller_add(e);
1383 elm_smart_scroller_widget_set(wd->scr, obj);
1384 elm_smart_scroller_object_theme_set(obj, wd->scr, "toolbar", "base", "default");
1385 elm_smart_scroller_bounce_allow_set(wd->scr,
1386 _elm_config->thumbscroll_bounce_enable,
1388 elm_widget_resize_object_set(obj, wd->scr);
1389 elm_smart_scroller_policy_set(wd->scr,
1390 ELM_SMART_SCROLLER_POLICY_AUTO,
1391 ELM_SMART_SCROLLER_POLICY_OFF);
1393 wd->icon_size = _elm_toolbar_icon_size_get(wd);
1396 wd->homogeneous = EINA_TRUE;
1399 wd->bx = evas_object_box_add(e);
1400 evas_object_size_hint_align_set(wd->bx, wd->align, 0.5);
1401 evas_object_box_layout_set(wd->bx, _layout, obj, NULL);
1402 elm_widget_sub_object_add(obj, wd->bx);
1403 elm_smart_scroller_child_set(wd->scr, wd->bx);
1404 evas_object_show(wd->bx);
1406 wd->more = elm_layout_add(obj);
1407 elm_layout_theme_set(wd->more, "toolbar", "more", "default");
1408 elm_widget_sub_object_add(obj, wd->more);
1409 evas_object_show(wd->more);
1411 wd->bx_more = evas_object_box_add(e);
1412 evas_object_size_hint_align_set(wd->bx_more, wd->align, 0.5);
1413 evas_object_box_layout_set(wd->bx_more, _layout, obj, NULL);
1414 elm_widget_sub_object_add(obj, wd->bx_more);
1415 elm_object_part_content_set(wd->more, "elm.swallow.content", wd->bx_more);
1416 evas_object_show(wd->bx_more);
1418 wd->bx_more2 = evas_object_box_add(e);
1419 evas_object_size_hint_align_set(wd->bx_more2, wd->align, 0.5);
1420 evas_object_box_layout_set(wd->bx_more2, _layout, obj, NULL);
1421 elm_widget_sub_object_add(obj, wd->bx_more2);
1422 elm_object_part_content_set(wd->more, "elm.swallow.content2", wd->bx_more2);
1423 evas_object_show(wd->bx_more2);
1425 elm_toolbar_shrink_mode_set(obj, _elm_config->toolbar_shrink_mode);
1426 evas_object_event_callback_add(wd->scr, EVAS_CALLBACK_RESIZE, _resize, obj);
1427 evas_object_event_callback_add(wd->scr, EVAS_CALLBACK_MOVE, _move, obj);
1428 evas_object_event_callback_add(wd->bx, EVAS_CALLBACK_RESIZE, _resize, obj);
1429 elm_toolbar_icon_order_lookup_set(obj, ELM_ICON_LOOKUP_THEME_FDO);
1431 evas_object_smart_callbacks_descriptions_set(obj, _signals);
1438 elm_toolbar_icon_size_set(Evas_Object *obj, int icon_size)
1440 ELM_CHECK_WIDTYPE(obj, widtype);
1441 Widget_Data *wd = elm_widget_data_get(obj);
1443 if (wd->icon_size == icon_size) return;
1444 wd->icon_size = icon_size;
1449 elm_toolbar_icon_size_get(const Evas_Object *obj)
1451 ELM_CHECK_WIDTYPE(obj, widtype) 0;
1452 Widget_Data *wd = elm_widget_data_get(obj);
1454 return wd->icon_size;
1457 EAPI Elm_Object_Item *
1458 elm_toolbar_item_append(Evas_Object *obj, const char *icon, const char *label, Evas_Smart_Cb func, const void *data)
1460 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1461 Widget_Data *wd = elm_widget_data_get(obj);
1462 if (!wd) return NULL;
1464 Elm_Toolbar_Item *it = _item_new(obj, icon, label, func, data);
1465 if (!it) return NULL;
1466 double scale = (elm_widget_scale_get(obj) * _elm_config->scale);
1468 wd->items = eina_inlist_append(wd->items, EINA_INLIST_GET(it));
1469 evas_object_box_append(wd->bx, VIEW(it));
1470 evas_object_show(VIEW(it));
1472 _theme_hook_item(obj, it, scale, wd->icon_size);
1476 return (Elm_Object_Item *)it;
1479 EAPI Elm_Object_Item *
1480 elm_toolbar_item_prepend(Evas_Object *obj, const char *icon, const char *label, Evas_Smart_Cb func, const void *data)
1482 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1483 Widget_Data *wd = elm_widget_data_get(obj);
1484 if (!wd) return NULL;
1486 Elm_Toolbar_Item *it = _item_new(obj, icon, label, func, data);
1487 if (!it) return NULL;
1488 double scale = (elm_widget_scale_get(obj) * _elm_config->scale);
1490 wd->items = eina_inlist_prepend(wd->items, EINA_INLIST_GET(it));
1491 evas_object_box_prepend(wd->bx, VIEW(it));
1492 evas_object_show(VIEW(it));
1493 _theme_hook_item(obj, it, scale, wd->icon_size);
1497 return (Elm_Object_Item *)it;
1500 EAPI Elm_Object_Item *
1501 elm_toolbar_item_insert_before(Evas_Object *obj, Elm_Object_Item *before, const char *icon, const char *label, Evas_Smart_Cb func, const void *data)
1503 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1504 ELM_OBJ_ITEM_CHECK_OR_RETURN(before, NULL);
1506 Elm_Toolbar_Item *it, *_before;
1508 wd = elm_widget_data_get(obj);
1509 if (!wd) return NULL;
1510 _before = (Elm_Toolbar_Item *) before;
1511 it = _item_new(obj, icon, label, func, data);
1512 if (!it) return NULL;
1513 double scale = (elm_widget_scale_get(obj) * _elm_config->scale);
1515 wd->items = eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
1516 EINA_INLIST_GET(_before));
1517 evas_object_box_insert_before(wd->bx, VIEW(it), VIEW(_before));
1518 evas_object_show(VIEW(it));
1519 _theme_hook_item(obj, it, scale, wd->icon_size);
1523 return (Elm_Object_Item *)it;
1526 EAPI Elm_Object_Item *
1527 elm_toolbar_item_insert_after(Evas_Object *obj, Elm_Object_Item *after, const char *icon, const char *label, Evas_Smart_Cb func, const void *data)
1529 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1530 ELM_OBJ_ITEM_CHECK_OR_RETURN(after, NULL);
1532 Elm_Toolbar_Item *it, *_after;
1534 wd = elm_widget_data_get(obj);
1535 if (!wd) return NULL;
1536 _after = (Elm_Toolbar_Item *) after;
1537 it = _item_new(obj, icon, label, func, data);
1538 if (!it) return NULL;
1539 double scale = (elm_widget_scale_get(obj) * _elm_config->scale);
1541 wd->items = eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
1542 EINA_INLIST_GET(_after));
1543 evas_object_box_insert_after(wd->bx, VIEW(it), VIEW(_after));
1544 evas_object_show(VIEW(it));
1545 _theme_hook_item(obj, it, scale, wd->icon_size);
1549 return (Elm_Object_Item *)it;
1552 EAPI Elm_Object_Item *
1553 elm_toolbar_first_item_get(const Evas_Object *obj)
1555 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1556 Widget_Data *wd = elm_widget_data_get(obj);
1557 if (!wd || !wd->items) return NULL;
1558 return (Elm_Object_Item *) ELM_TOOLBAR_ITEM_FROM_INLIST(wd->items);
1561 EAPI Elm_Object_Item *
1562 elm_toolbar_last_item_get(const Evas_Object *obj)
1564 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1565 Widget_Data *wd = elm_widget_data_get(obj);
1566 if (!wd || !wd->items) return NULL;
1567 return (Elm_Object_Item *) ELM_TOOLBAR_ITEM_FROM_INLIST(wd->items->last);
1570 EAPI Elm_Object_Item *
1571 elm_toolbar_item_next_get(const Elm_Object_Item *it)
1573 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
1574 return (Elm_Object_Item *) ELM_TOOLBAR_ITEM_FROM_INLIST(
1575 EINA_INLIST_GET(((Elm_Toolbar_Item *)it))->next);
1578 EAPI Elm_Object_Item *
1579 elm_toolbar_item_prev_get(const Elm_Object_Item *it)
1581 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
1582 return (Elm_Object_Item *) ELM_TOOLBAR_ITEM_FROM_INLIST(
1583 EINA_INLIST_GET(((Elm_Toolbar_Item *)it))->prev);
1587 elm_toolbar_item_priority_set(Elm_Object_Item *it, int priority)
1589 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
1590 Elm_Toolbar_Item *item = (Elm_Toolbar_Item *)it;
1591 if (item->prio.priority == priority) return;
1592 item->prio.priority = priority;
1593 _resize(WIDGET(item), NULL, NULL, NULL);
1597 elm_toolbar_item_priority_get(const Elm_Object_Item *it)
1599 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, 0);
1600 return ((Elm_Toolbar_Item *)it)->prio.priority;
1603 EAPI Elm_Object_Item *
1604 elm_toolbar_item_find_by_label(const Evas_Object *obj, const char *label)
1606 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1607 Elm_Toolbar_Item *it;
1608 Widget_Data *wd = elm_widget_data_get(obj);
1609 if (!wd) return NULL;
1611 EINA_INLIST_FOREACH(wd->items, it)
1613 if (!strcmp(it->label, label))
1614 return (Elm_Object_Item *)it;
1620 elm_toolbar_item_selected_set(Elm_Object_Item *it, Eina_Bool selected)
1622 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
1623 Elm_Toolbar_Item *item = (Elm_Toolbar_Item *)it;
1624 Widget_Data *wd = elm_widget_data_get(WIDGET(item));
1627 if (item->selected == selected) return;
1628 if (selected) _item_select(item);
1629 else _item_unselect(item);
1633 elm_toolbar_item_selected_get(const Elm_Object_Item *it)
1635 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
1636 return ((Elm_Toolbar_Item *)it)->selected;
1639 EAPI Elm_Object_Item *
1640 elm_toolbar_selected_item_get(const Evas_Object *obj)
1642 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1643 Widget_Data *wd = elm_widget_data_get(obj);
1644 if (!wd) return NULL;
1645 return (Elm_Object_Item *) wd->selected_item;
1648 EAPI Elm_Object_Item *
1649 elm_toolbar_more_item_get(const Evas_Object *obj)
1651 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1652 Widget_Data *wd = elm_widget_data_get(obj);
1653 if (!wd) return NULL;
1654 return (Elm_Object_Item *) wd->more_item;
1658 elm_toolbar_item_icon_set(Elm_Object_Item *it, const char *icon)
1660 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
1662 Evas_Object *icon_obj;
1665 Elm_Toolbar_Item * item = (Elm_Toolbar_Item *)it;
1668 wd = elm_widget_data_get(obj);
1670 if ((icon) && (item->icon_str) && (!strcmp(icon, item->icon_str))) return;
1672 icon_obj = elm_icon_add(obj);
1673 if (!icon_obj) return;
1674 if (_item_icon_set(icon_obj, "toolbar/", icon))
1675 _elm_toolbar_item_icon_obj_set(obj, item, icon_obj, icon, wd->icon_size,
1676 "elm,state,icon_set");
1679 _elm_toolbar_item_icon_obj_set(obj, item, NULL, NULL, 0,
1680 "elm,state,icon_set");
1681 evas_object_del(icon_obj);
1686 elm_toolbar_item_icon_get(const Elm_Object_Item *it)
1688 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
1689 return ((Elm_Toolbar_Item *)it)->icon_str;
1693 elm_toolbar_item_object_get(const Elm_Object_Item *it)
1695 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
1699 Elm_Toolbar_Item *item = (Elm_Toolbar_Item *)it;
1702 wd = elm_widget_data_get(obj);
1703 if (!wd) return NULL;
1709 elm_toolbar_item_icon_object_get(Elm_Object_Item *it)
1711 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
1712 return ((Elm_Toolbar_Item *)it)->icon;
1716 elm_toolbar_item_icon_memfile_set(Elm_Object_Item *it, const void *img, size_t size, const char *format, const char *key)
1718 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
1720 Evas_Object *icon_obj;
1724 Elm_Toolbar_Item *item = (Elm_Toolbar_Item *)it;
1727 wd = elm_widget_data_get(obj);
1728 if (!wd) return EINA_FALSE;
1732 icon_obj = _els_smart_icon_add(evas_object_evas_get(obj));
1733 evas_object_repeat_events_set(icon_obj, EINA_TRUE);
1734 ret = _els_smart_icon_memfile_set(icon_obj, img, size, format, key);
1737 evas_object_del(icon_obj);
1740 _elm_toolbar_item_icon_obj_set(obj, item, icon_obj, NULL, wd->icon_size,
1741 "elm,state,icon_set");
1744 _elm_toolbar_item_icon_obj_set(obj, item, NULL, NULL, 0, "elm,state,icon_set");
1749 elm_toolbar_item_icon_file_set(Elm_Object_Item *it, const char *file, const char *key)
1751 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
1753 Evas_Object *icon_obj;
1757 Elm_Toolbar_Item *item = (Elm_Toolbar_Item *)it;
1760 wd = elm_widget_data_get(obj);
1761 if (!wd) return EINA_FALSE;
1765 icon_obj = _els_smart_icon_add(evas_object_evas_get(obj));
1766 evas_object_repeat_events_set(icon_obj, EINA_TRUE);
1767 ret = _els_smart_icon_file_key_set(icon_obj, file, key);
1770 evas_object_del(icon_obj);
1773 _elm_toolbar_item_icon_obj_set(obj, item, icon_obj, NULL, wd->icon_size,
1774 "elm,state,icon_set");
1777 _elm_toolbar_item_icon_obj_set(obj, item, NULL, NULL, 0, "elm,state,icon_set");
1782 elm_toolbar_item_separator_set(Elm_Object_Item *it, Eina_Bool separator)
1784 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
1785 Elm_Toolbar_Item *item = (Elm_Toolbar_Item *)it;
1786 Evas_Object *obj = WIDGET(item);
1787 Widget_Data *wd = elm_widget_data_get(obj);
1789 if (item->separator == separator) return;
1790 item->separator = separator;
1791 scale = (elm_widget_scale_get(obj) * _elm_config->scale);
1792 _theme_hook_item(obj, item, scale, wd->icon_size);
1796 elm_toolbar_item_separator_get(const Elm_Object_Item *it)
1798 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
1799 return ((Elm_Toolbar_Item *)it)->separator;
1803 elm_toolbar_shrink_mode_set(Evas_Object *obj, Elm_Toolbar_Shrink_Mode shrink_mode)
1805 ELM_CHECK_WIDTYPE(obj, widtype);
1806 Widget_Data *wd = elm_widget_data_get(obj);
1810 wd->shrink_mode = shrink_mode;
1811 bounce = (_elm_config->thumbscroll_bounce_enable) &&
1812 (shrink_mode == ELM_TOOLBAR_SHRINK_SCROLL);
1813 elm_smart_scroller_bounce_allow_set(wd->scr, bounce, EINA_FALSE);
1817 _item_del(wd->more_item);
1818 elm_widget_item_free(wd->more_item);
1819 wd->more_item = NULL;
1822 if (shrink_mode == ELM_TOOLBAR_SHRINK_MENU)
1824 elm_smart_scroller_policy_set(wd->scr, ELM_SMART_SCROLLER_POLICY_OFF,
1825 ELM_SMART_SCROLLER_POLICY_OFF);
1826 wd->more_item = _item_new(obj, "more_menu", "More", NULL, NULL);
1828 else if (shrink_mode == ELM_TOOLBAR_SHRINK_HIDE)
1829 elm_smart_scroller_policy_set(wd->scr, ELM_SMART_SCROLLER_POLICY_OFF,
1830 ELM_SMART_SCROLLER_POLICY_OFF);
1831 else if (shrink_mode == ELM_TOOLBAR_SHRINK_EXPAND)
1833 elm_smart_scroller_policy_set(wd->scr, ELM_SMART_SCROLLER_POLICY_AUTO,
1834 ELM_SMART_SCROLLER_POLICY_OFF);
1835 wd->more_item = _item_new(obj, "more_menu", "More", NULL, NULL);
1838 elm_smart_scroller_policy_set(wd->scr, ELM_SMART_SCROLLER_POLICY_AUTO,
1839 ELM_SMART_SCROLLER_POLICY_OFF);
1843 EAPI Elm_Toolbar_Shrink_Mode
1844 elm_toolbar_shrink_mode_get(const Evas_Object *obj)
1846 ELM_CHECK_WIDTYPE(obj, widtype) ELM_TOOLBAR_SHRINK_NONE;
1847 Widget_Data *wd = elm_widget_data_get(obj);
1849 if (!wd) return ELM_TOOLBAR_SHRINK_NONE;
1850 return wd->shrink_mode;
1854 elm_toolbar_homogeneous_set(Evas_Object *obj, Eina_Bool homogeneous)
1856 ELM_CHECK_WIDTYPE(obj, widtype);
1857 Widget_Data *wd = elm_widget_data_get(obj);
1860 wd->homogeneous = !!homogeneous;
1861 evas_object_smart_calculate(wd->bx);
1865 elm_toolbar_homogeneous_get(const Evas_Object *obj)
1867 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1868 Widget_Data *wd = elm_widget_data_get(obj);
1870 if (!wd) return EINA_FALSE;
1871 return wd->homogeneous;
1875 elm_toolbar_menu_parent_set(Evas_Object *obj, Evas_Object *parent)
1877 Elm_Toolbar_Item *it;
1878 ELM_CHECK_WIDTYPE(obj, widtype);
1879 Widget_Data *wd = elm_widget_data_get(obj);
1882 EINA_SAFETY_ON_NULL_RETURN(parent);
1883 wd->menu_parent = parent;
1884 EINA_INLIST_FOREACH(wd->items, it)
1887 elm_menu_parent_set(it->o_menu, wd->menu_parent);
1889 if ((wd->more_item) && (wd->more_item->o_menu))
1890 elm_menu_parent_set(wd->more_item->o_menu, wd->menu_parent);
1894 elm_toolbar_menu_parent_get(const Evas_Object *obj)
1896 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1897 Widget_Data *wd = elm_widget_data_get(obj);
1899 if (!wd) return NULL;
1900 return wd->menu_parent;
1904 elm_toolbar_align_set(Evas_Object *obj, double align)
1906 ELM_CHECK_WIDTYPE(obj, widtype);
1907 Widget_Data *wd = elm_widget_data_get(obj);
1912 if (wd->align != align)
1913 evas_object_size_hint_align_set(wd->bx, 0.5, align);
1917 if (wd->align != align)
1918 evas_object_size_hint_align_set(wd->bx, align, 0.5);
1924 elm_toolbar_align_get(const Evas_Object *obj)
1926 ELM_CHECK_WIDTYPE(obj, widtype) 0.0;
1927 Widget_Data *wd = elm_widget_data_get(obj);
1929 if (!wd) return 0.0;
1934 elm_toolbar_item_menu_set(Elm_Object_Item *it, Eina_Bool menu)
1936 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
1937 Elm_Toolbar_Item *item = (Elm_Toolbar_Item *)it;
1938 Widget_Data *wd = elm_widget_data_get(WIDGET(item));
1941 if (item->menu == menu) return;
1942 if (menu) _item_menu_create(wd, item);
1943 else _item_menu_destroy(item);
1947 elm_toolbar_item_menu_get(const Elm_Object_Item *it)
1949 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
1950 Elm_Toolbar_Item *item = (Elm_Toolbar_Item *)it;
1951 if (!item->menu) return NULL;
1952 Widget_Data *wd = elm_widget_data_get(WIDGET(item));
1953 if (!wd) return NULL;
1954 return item->o_menu;
1957 EAPI Elm_Toolbar_Item_State *
1958 elm_toolbar_item_state_add(Elm_Object_Item *it, const char *icon, const char *label, Evas_Smart_Cb func, const void *data)
1960 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
1962 Elm_Toolbar_Item_State *it_state;
1963 Evas_Object *icon_obj;
1966 Elm_Toolbar_Item *item = (Elm_Toolbar_Item *)it;
1968 wd = elm_widget_data_get(WIDGET(item));
1969 if (!wd) return NULL;
1973 it_state = _item_state_new(item->label, item->icon_str, item->icon,
1974 item->func, item->base.data);
1975 item->states = eina_list_append(item->states, it_state);
1976 item->current_state = item->states;
1979 icon_obj = elm_icon_add(obj);
1980 elm_icon_order_lookup_set(icon_obj, wd->lookup_order);
1981 if (!icon_obj) goto error_state_add;
1983 if (!_item_icon_set(icon_obj, "toolbar/", icon))
1985 evas_object_del(icon_obj);
1990 it_state = _item_state_new(label, icon, icon_obj, func, data);
1991 item->states = eina_list_append(item->states, it_state);
1992 item->func = _elm_toolbar_item_state_cb;
1993 item->base.data = NULL;
1998 if (item->states && !eina_list_next(item->states))
2000 eina_stringshare_del(item->label);
2001 eina_stringshare_del(item->icon_str);
2002 free(eina_list_data_get(item->states));
2003 eina_list_free(item->states);
2004 item->states = NULL;
2010 elm_toolbar_item_state_del(Elm_Object_Item *it, Elm_Toolbar_Item_State *state)
2012 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
2014 Eina_List *del_state;
2015 Elm_Toolbar_Item_State *it_state;
2016 Elm_Toolbar_Item *item;
2018 if (!state) return EINA_FALSE;
2020 item = (Elm_Toolbar_Item *)it;
2021 if (!item->states) return EINA_FALSE;
2023 del_state = eina_list_data_find_list(item->states, state);
2024 if (del_state == item->states) return EINA_FALSE;
2025 if (del_state == item->current_state)
2026 elm_toolbar_item_state_unset(it);
2028 eina_stringshare_del(state->label);
2029 eina_stringshare_del(state->icon_str);
2030 if (state->icon) evas_object_del(state->icon);
2032 item->states = eina_list_remove_list(item->states, del_state);
2033 if (item->states && !eina_list_next(item->states))
2035 it_state = eina_list_data_get(item->states);
2036 item->base.data = it_state->data;
2037 item->func = it_state->func;
2038 eina_stringshare_del(it_state->label);
2039 eina_stringshare_del(it_state->icon_str);
2040 free(eina_list_data_get(item->states));
2041 eina_list_free(item->states);
2042 item->states = NULL;
2048 elm_toolbar_item_state_set(Elm_Object_Item *it, Elm_Toolbar_Item_State *state)
2050 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
2053 Eina_List *next_state;
2054 Elm_Toolbar_Item_State *it_state;
2056 Elm_Toolbar_Item *item = (Elm_Toolbar_Item *)it;
2059 wd = elm_widget_data_get(obj);
2060 if (!wd) return EINA_FALSE;
2061 if (!item->states) return EINA_FALSE;
2065 next_state = eina_list_data_find_list(item->states, state);
2066 if (!next_state) return EINA_FALSE;
2069 next_state = item->states;
2071 if (next_state == item->current_state) return EINA_TRUE;
2073 it_state = eina_list_data_get(next_state);
2074 if (eina_list_data_find(item->current_state, state))
2076 _item_label_set(item, it_state->label, "elm,state,label_set,forward");
2077 _elm_toolbar_item_icon_obj_set(obj, item, it_state->icon, it_state->icon_str,
2078 wd->icon_size, "elm,state,icon_set,forward");
2082 _item_label_set(item, it_state->label, "elm,state,label_set,backward");
2083 _elm_toolbar_item_icon_obj_set(obj,
2088 "elm,state,icon_set,backward");
2090 if (elm_widget_item_disabled_get(item))
2091 elm_widget_signal_emit(item->icon, "elm,state,disabled", "elm");
2093 elm_widget_signal_emit(item->icon, "elm,state,enabled", "elm");
2095 item->current_state = next_state;
2100 elm_toolbar_item_state_unset(Elm_Object_Item *it)
2102 elm_toolbar_item_state_set(it, NULL);
2105 EAPI Elm_Toolbar_Item_State *
2106 elm_toolbar_item_state_get(const Elm_Object_Item *it)
2108 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
2109 Elm_Toolbar_Item *item = (Elm_Toolbar_Item *)it;
2111 if ((!item->states) || (!item->current_state)) return NULL;
2112 if (item->current_state == item->states) return NULL;
2114 return eina_list_data_get(item->current_state);
2117 EAPI Elm_Toolbar_Item_State *
2118 elm_toolbar_item_state_next(Elm_Object_Item *it)
2120 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
2124 Eina_List *next_state;
2125 Elm_Toolbar_Item *item = (Elm_Toolbar_Item *)it;
2128 wd = elm_widget_data_get(obj);
2129 if (!wd) return NULL;
2130 if (!item->states) return NULL;
2132 next_state = eina_list_next(item->current_state);
2134 next_state = eina_list_next(item->states);
2135 return eina_list_data_get(next_state);
2138 EAPI Elm_Toolbar_Item_State *
2139 elm_toolbar_item_state_prev(Elm_Object_Item *it)
2141 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
2145 Eina_List *prev_state;
2146 Elm_Toolbar_Item *item = (Elm_Toolbar_Item *)it;
2149 wd = elm_widget_data_get(obj);
2150 if (!wd) return NULL;
2151 if (!item->states) return NULL;
2153 prev_state = eina_list_prev(item->current_state);
2154 if ((!prev_state) || (prev_state == item->states))
2155 prev_state = eina_list_last(item->states);
2156 return eina_list_data_get(prev_state);
2160 elm_toolbar_icon_order_lookup_set(Evas_Object *obj, Elm_Icon_Lookup_Order order)
2162 ELM_CHECK_WIDTYPE(obj, widtype);
2163 Elm_Toolbar_Item *it;
2164 Widget_Data *wd = elm_widget_data_get(obj);
2167 wd->lookup_order = order;
2168 EINA_INLIST_FOREACH(wd->items, it)
2169 elm_icon_order_lookup_set(it->icon, order);
2171 elm_icon_order_lookup_set(wd->more_item->icon, order);
2174 EAPI Elm_Icon_Lookup_Order
2175 elm_toolbar_icon_order_lookup_get(const Evas_Object *obj)
2177 ELM_CHECK_WIDTYPE(obj, widtype) ELM_ICON_LOOKUP_THEME_FDO;
2178 Widget_Data *wd = elm_widget_data_get(obj);
2179 if (!wd) return ELM_ICON_LOOKUP_THEME_FDO;
2180 return wd->lookup_order;
2184 elm_toolbar_horizontal_set(Evas_Object *obj, Eina_Bool horizontal)
2186 ELM_CHECK_WIDTYPE(obj, widtype);
2187 Widget_Data *wd = elm_widget_data_get(obj);
2189 wd->vertical = !horizontal;
2191 evas_object_size_hint_align_set(wd->bx, 0.5, wd->align);
2193 evas_object_size_hint_align_set(wd->bx, wd->align, 0.5);
2198 elm_toolbar_horizontal_get(const Evas_Object *obj)
2200 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2201 Widget_Data *wd = elm_widget_data_get(obj);
2202 if (!wd) return EINA_FALSE;
2203 return !wd->vertical;
2207 elm_toolbar_items_count(const Evas_Object *obj)
2209 ELM_CHECK_WIDTYPE(obj, widtype) 0;
2210 Widget_Data *wd = elm_widget_data_get(obj);
2212 return wd->item_count;
2216 elm_toolbar_standard_priority_set(Evas_Object *obj, int priority)
2218 ELM_CHECK_WIDTYPE(obj, widtype);
2219 Widget_Data *wd = elm_widget_data_get(obj);
2221 wd->standard_priority = priority;
2222 _resize(obj, NULL, NULL, NULL);
2226 elm_toolbar_standard_priority_get(const Evas_Object *obj)
2228 ELM_CHECK_WIDTYPE(obj, widtype) 0;
2229 Widget_Data *wd = elm_widget_data_get(obj);
2231 return wd->standard_priority;
2235 elm_toolbar_select_mode_set(Evas_Object *obj, Elm_Object_Select_Mode mode)
2237 ELM_CHECK_WIDTYPE(obj, widtype);
2238 Widget_Data *wd = elm_widget_data_get(obj);
2240 if (mode >= ELM_OBJECT_SELECT_MODE_MAX)
2242 if ((mode == ELM_OBJECT_SELECT_MODE_ALWAYS) &&
2243 (wd->select_mode != ELM_OBJECT_SELECT_MODE_ALWAYS) &&
2245 _item_select(ELM_TOOLBAR_ITEM_FROM_INLIST(wd->items));
2246 if (wd->select_mode != mode)
2247 wd->select_mode = mode;
2250 EAPI Elm_Object_Select_Mode
2251 elm_toolbar_select_mode_get(const Evas_Object *obj)
2253 ELM_CHECK_WIDTYPE(obj, widtype) ELM_OBJECT_SELECT_MODE_MAX;
2254 Widget_Data *wd = elm_widget_data_get(obj);
2255 if (!wd) return ELM_OBJECT_SELECT_MODE_MAX;
2256 return wd->select_mode;