1 #include <Elementary.h>
4 typedef struct _Widget_Data Widget_Data;
9 Evas_Object *menu_parent;
11 Elm_Toolbar_Item *more_item, *selected_item;
12 Elm_Toolbar_Shrink_Mode shrink_mode;
13 Elm_Icon_Lookup_Order lookup_order;
16 Eina_Bool homogeneous : 1;
17 Eina_Bool no_select : 1;
18 Ecore_Job *resize_job;
21 struct _Elm_Toolbar_Item
32 Eina_Bool visible : 1;
34 Eina_Bool selected : 1;
35 Eina_Bool disabled : 1;
36 Eina_Bool separator : 1;
39 Eina_List *current_state;
42 #define ELM_TOOLBAR_ITEM_FROM_INLIST(item) \
43 ((item) ? EINA_INLIST_CONTAINER_GET(item, Elm_Toolbar_Item) : NULL)
45 struct _Elm_Toolbar_Item_State
54 static const char *widtype = NULL;
55 static void _item_show(Elm_Toolbar_Item *it);
56 static void _item_select(Elm_Toolbar_Item *it);
57 static void _item_unselect(Elm_Toolbar_Item *it);
58 static void _item_disable(Elm_Toolbar_Item *it, Eina_Bool disabled);
59 static void _del_pre_hook(Evas_Object *obj);
60 static void _del_hook(Evas_Object *obj);
61 static void _mirrored_set(Evas_Object *obj, Eina_Bool mirrored);
62 static void _mirrored_set_item(Evas_Object *obj, Elm_Toolbar_Item *it, Eina_Bool mirrored);
63 static void _theme_hook(Evas_Object *obj);
64 static void _sizing_eval(Evas_Object *obj);
65 static void _resize(void *data, Evas *e, Evas_Object *obj, void *event_info);
66 static void _menu_move_resize(void *data, Evas *e, Evas_Object *obj, void *event_info);
67 static void _menu_hide(void *data, Evas *e, Evas_Object *obj, void *event_info);
68 static void _layout(Evas_Object *o, Evas_Object_Box_Data *priv, void *data);
69 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 *signal);
70 static void _item_label_set(Elm_Toolbar_Item *item, const char *label, const char *signal);
72 static const char SIG_CLICKED[] = "clicked";
74 static const Evas_Smart_Cb_Description _signals[] = {
81 _item_icon_set(Evas_Object *icon_obj, const char *type, const char *icon)
85 if ((!type) || (!*type)) goto end;
86 if ((!icon) || (!*icon)) return EINA_FALSE;
87 if ((snprintf(icon_str, sizeof(icon_str), "%s%s", type, icon) > 0)
88 && (elm_icon_standard_set(icon_obj, icon_str)))
91 if (elm_icon_standard_set(icon_obj, icon))
93 WRN("couldn't find icon definition for '%s'", icon);
98 _elm_toolbar_icon_size_get(Widget_Data *wd)
100 const char *icon_size = edje_object_data_get(
101 elm_smart_scroller_edje_object_get(wd->scr), "icon_size");
103 return atoi(icon_size);
104 return _elm_config->icon_size;
108 _item_show(Elm_Toolbar_Item *it)
110 Widget_Data *wd = elm_widget_data_get(it->base.widget);
111 Evas_Coord x, y, w, h, bx, by;
114 evas_object_geometry_get(wd->bx, &bx, &by, NULL, NULL);
115 evas_object_geometry_get(it->base.view, &x, &y, &w, &h);
116 elm_smart_scroller_child_region_show(wd->scr, x - bx, y - by, w, h);
120 _item_unselect(Elm_Toolbar_Item *item)
123 if ((!item) || (!item->selected)) return;
124 wd = elm_widget_data_get(item->base.widget);
126 item->selected = EINA_FALSE;
127 wd->selected_item = NULL;
128 edje_object_signal_emit(item->base.view, "elm,state,unselected", "elm");
129 elm_widget_signal_emit(item->icon, "elm,state,unselected", "elm");
133 _item_select(Elm_Toolbar_Item *it)
135 Elm_Toolbar_Item *it2;
136 Widget_Data *wd = elm_widget_data_get(it->base.widget);
140 if ((it->selected) || (it->disabled) || (it->separator)) return;
144 it2 = elm_toolbar_selected_item_get(it->base.widget);
147 it->selected = EINA_TRUE;
148 wd->selected_item = it;
149 edje_object_signal_emit(it->base.view, "elm,state,selected", "elm");
150 elm_widget_signal_emit(it->icon, "elm,state,selected", "elm");
153 obj2 = it->base.widget;
156 evas_object_show(it->o_menu);
157 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_RESIZE,
158 _menu_move_resize, it);
159 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_MOVE,
160 _menu_move_resize, it);
162 _menu_move_resize(it, NULL, NULL, NULL);
164 if (it->func) it->func((void *)(it->base.data), it->base.widget, it);
165 evas_object_smart_callback_call(obj2, SIG_CLICKED, it);
169 _menu_hide(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
171 Elm_Toolbar_Item *selected;
172 Elm_Toolbar_Item *it = data;
173 selected = elm_toolbar_selected_item_get(it->base.widget);
174 _item_unselect(selected);
178 _menu_del(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
180 // avoid hide being emitted during object deletion
181 evas_object_event_callback_del_full
182 (obj, EVAS_CALLBACK_HIDE, _menu_hide, data);
186 _menu_move_resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
188 Elm_Toolbar_Item *it = data;
190 Widget_Data *wd = elm_widget_data_get(it->base.widget);
192 if ((!wd) || (!wd->menu_parent)) return;
193 evas_object_geometry_get(it->base.view, &x, &y, &w, &h);
194 elm_menu_move(it->o_menu, x, y+h);
198 _item_disable(Elm_Toolbar_Item *it, Eina_Bool disabled)
200 Widget_Data *wd = elm_widget_data_get(it->base.widget);
203 if (it->disabled == disabled) return;
204 it->disabled = !!disabled;
207 edje_object_signal_emit(it->base.view, "elm,state,disabled", "elm");
208 elm_widget_signal_emit(it->icon, "elm,state,disabled", "elm");
212 edje_object_signal_emit(it->base.view, "elm,state,enabled", "elm");
213 elm_widget_signal_emit(it->icon, "elm,state,enabled", "elm");
218 _item_del(Elm_Toolbar_Item *it)
220 Elm_Toolbar_Item_State *it_state;
222 elm_widget_item_pre_notify_del(it);
223 EINA_LIST_FREE(it->states, it_state)
225 if (it->icon == it_state->icon)
227 eina_stringshare_del(it_state->label);
228 eina_stringshare_del(it_state->icon_str);
229 if (it_state->icon) evas_object_del(it_state->icon);
232 eina_stringshare_del(it->label);
233 eina_stringshare_del(it->icon_str);
234 if (it->icon) evas_object_del(it->icon);
235 //TODO: See if checking for wd->menu_parent is necessary before deleting menu
236 if (it->o_menu) evas_object_del(it->o_menu);
237 elm_widget_item_del(it);
241 _del_pre_hook(Evas_Object *obj)
243 Widget_Data *wd = elm_widget_data_get(obj);
244 Elm_Toolbar_Item *it, *next;
247 it = ELM_TOOLBAR_ITEM_FROM_INLIST(wd->items);
250 next = ELM_TOOLBAR_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
255 _item_del(wd->more_item);
259 _del_hook(Evas_Object *obj)
261 Widget_Data *wd = elm_widget_data_get(obj);
269 _mirrored_set_item(Evas_Object *obj __UNUSED__, Elm_Toolbar_Item *it, Eina_Bool mirrored)
271 edje_object_mirrored_set(it->base.view, mirrored);
272 elm_widget_mirrored_set(it->o_menu, mirrored);
276 _theme_hook_item(Evas_Object *obj, Elm_Toolbar_Item *it, double scale, int icon_size)
278 Evas_Object *view = it->base.view;
280 const char *style = elm_widget_style_get(obj);
282 _mirrored_set_item(obj, it, elm_widget_mirrored_get(obj));
283 edje_object_scale_set(view, scale);
286 _elm_theme_object_set(obj, view, "toolbar", "item", style);
289 edje_object_signal_emit(view, "elm,state,selected", "elm");
290 elm_widget_signal_emit(it->icon, "elm,state,selected", "elm");
294 edje_object_signal_emit(view, "elm,state,disabled", "elm");
295 elm_widget_signal_emit(it->icon, "elm,state,disabled", "elm");
301 ms = ((double)icon_size * scale);
302 evas_object_size_hint_min_set(it->icon, ms, ms);
303 evas_object_size_hint_max_set(it->icon, ms, ms);
304 edje_object_part_swallow(view, "elm.swallow.icon",
307 edje_object_part_text_set(view, "elm.text", it->label);
310 _elm_theme_object_set(obj, view, "toolbar", "separator", style);
314 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
315 edje_object_size_min_restricted_calc(view, &mw, &mh, mw, mh);
317 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
318 evas_object_size_hint_min_set(view, mw, mh);
322 _mirrored_set(Evas_Object *obj, Eina_Bool mirrored)
324 Widget_Data *wd = elm_widget_data_get(obj);
325 Elm_Toolbar_Item *it;
327 EINA_INLIST_FOREACH(wd->items, it)
328 _mirrored_set_item(obj, it, mirrored);
330 _mirrored_set_item(obj, wd->more_item, mirrored);
334 _theme_hook(Evas_Object *obj)
336 Widget_Data *wd = elm_widget_data_get(obj);
337 Elm_Toolbar_Item *it;
341 _elm_widget_mirrored_reload(obj);
342 elm_smart_scroller_object_theme_set(obj, wd->scr, "toolbar", "base", elm_widget_style_get(obj));
343 _mirrored_set(obj, elm_widget_mirrored_get(obj));
344 scale = (elm_widget_scale_get(obj) * _elm_config->scale);
345 edje_object_scale_set(wd->scr, scale);
346 wd->icon_size = _elm_toolbar_icon_size_get(wd);
347 EINA_INLIST_FOREACH(wd->items, it)
348 _theme_hook_item(obj, it, scale, wd->icon_size);
350 _theme_hook_item(obj, wd->more_item, scale, wd->icon_size);
355 _sizing_eval(Evas_Object *obj)
357 Widget_Data *wd = elm_widget_data_get(obj);
358 Evas_Coord minw = -1, minh = -1, minw_bx;
359 Evas_Coord vw = 0, vh = 0;
363 evas_object_smart_calculate(wd->bx);
364 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr),
366 evas_object_geometry_get(obj, NULL, NULL, &w, &h);
367 if (w < minw) w = minw;
368 if (h < minh) h = minh;
370 evas_object_resize(wd->scr, w, h);
372 evas_object_size_hint_min_get(wd->bx, &minw, &minh);
374 if (w > minw) minw = w;
375 evas_object_resize(wd->bx, minw, minh);
376 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
377 switch (wd->shrink_mode)
379 case ELM_TOOLBAR_SHRINK_MENU: /* fallthrough */
380 case ELM_TOOLBAR_SHRINK_HIDE: /* fallthrough */
381 case ELM_TOOLBAR_SHRINK_SCROLL: minw = w - vw; break;
382 case ELM_TOOLBAR_SHRINK_NONE: minw = minw_bx + (w - vw); break;
384 minh = minh + (h - vh);
385 evas_object_size_hint_min_set(obj, minw, minh);
386 evas_object_size_hint_max_set(obj, -1, -1);
390 _item_menu_create(Widget_Data *wd, Elm_Toolbar_Item *item)
392 item->o_menu = elm_menu_add(item->base.view);
394 elm_menu_parent_set(item->o_menu, wd->menu_parent);
395 evas_object_event_callback_add(item->o_menu, EVAS_CALLBACK_HIDE,
397 evas_object_event_callback_add(item->o_menu, EVAS_CALLBACK_DEL,
402 _item_menu_destroy(Elm_Toolbar_Item *item)
406 evas_object_del(item->o_menu);
412 _toolbar_item_prio_compare_cb(const void *i1, const void *i2)
414 const Elm_Toolbar_Item *eti1 = i1;
415 const Elm_Toolbar_Item *eti2 = i2;
418 if (!eti1) return -1;
420 return eti2->prio.priority - eti1->prio.priority;
424 _fix_items_visibility(Widget_Data *wd, Evas_Coord *iw, Evas_Coord vw)
426 Elm_Toolbar_Item *it;
427 Eina_List *sorted = NULL;
430 EINA_INLIST_FOREACH(wd->items, it)
432 sorted = eina_list_sorted_insert(sorted,
433 _toolbar_item_prio_compare_cb, it);
438 evas_object_geometry_get(wd->more_item->base.view, NULL, NULL, &ciw, NULL);
441 EINA_LIST_FREE(sorted, it)
443 evas_object_geometry_get(it->base.view, NULL, NULL, &ciw, NULL);
445 it->prio.visible = (*iw <= vw);
450 _elm_toolbar_item_menu_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
452 Elm_Toolbar_Item *it = data;
453 if (it->func) it->func((void *)(it->base.data), it->base.widget, it);
457 _resize_job(void *data)
459 Widget_Data *wd = elm_widget_data_get(data);
460 Evas_Coord mw, mh, vw, vh, w, h;
461 Elm_Toolbar_Item *it;
462 Evas_Object *obj = (Evas_Object *) data;
465 wd->resize_job = NULL;
466 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
467 evas_object_size_hint_min_get(wd->bx, &mw, &mh);
468 evas_object_geometry_get(wd->bx, NULL, NULL, &w, &h);
469 if (wd->shrink_mode == ELM_TOOLBAR_SHRINK_MENU)
471 Evas_Coord iw = 0, more_w;
473 evas_object_resize(wd->bx, vw, h);
474 _fix_items_visibility(wd, &iw, vw);
475 evas_object_geometry_get(wd->more_item->base.view, NULL, NULL, &more_w, NULL);
476 if (iw - more_w <= vw)
479 /* All items are removed from the box object, since removing individual
480 * items won't trigger a resize. Items are be readded below. */
481 evas_object_box_remove_all(wd->bx, EINA_FALSE);
486 _item_menu_destroy(wd->more_item);
487 _item_menu_create(wd, wd->more_item);
488 menu = elm_toolbar_item_menu_get(wd->more_item);
490 EINA_INLIST_FOREACH(wd->items, it)
492 if (!it->prio.visible)
495 elm_menu_item_separator_add(menu, NULL);
499 item = elm_menu_item_add(menu, NULL, it->icon_str, it->label,
500 _elm_toolbar_item_menu_cb, it);
501 elm_menu_item_disabled_set(item, it->disabled);
502 if (it->o_menu) elm_menu_clone(it->o_menu, menu, item);
504 evas_object_hide(it->base.view);
508 evas_object_box_append(wd->bx, it->base.view);
509 evas_object_show(it->base.view);
513 evas_object_box_append(wd->bx, wd->more_item->base.view);
514 evas_object_show(wd->more_item->base.view);
518 /* All items are visible, show them all (except for the "More"
519 * button, of course). */
520 EINA_INLIST_FOREACH(wd->items, it)
522 evas_object_show(it->base.view);
523 evas_object_box_append(wd->bx, it->base.view);
525 evas_object_hide(wd->more_item->base.view);
528 else if (wd->shrink_mode == ELM_TOOLBAR_SHRINK_HIDE)
532 evas_object_resize(wd->bx, vw, h);
533 _fix_items_visibility(wd, &iw, vw);
534 evas_object_box_remove_all(wd->bx, EINA_FALSE);
537 EINA_INLIST_FOREACH(wd->items, it)
539 if (!it->prio.visible)
540 evas_object_hide(it->base.view);
543 evas_object_box_append(wd->bx, it->base.view);
544 evas_object_show(it->base.view);
550 /* All items are visible, show them all */
551 EINA_INLIST_FOREACH(wd->items, it)
553 evas_object_show(it->base.view);
554 evas_object_box_append(wd->bx, it->base.view);
560 if ((vw >= mw) && (w != vw)) evas_object_resize(wd->bx, vw, h);
561 EINA_INLIST_FOREACH(wd->items, it)
571 _mirrored_set(obj, elm_widget_mirrored_get(obj));
575 _resize_item(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
578 _resize(data, NULL, NULL, NULL);
582 _resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
584 Widget_Data *wd = elm_widget_data_get(data);
586 wd->resize_job = ecore_job_add(_resize_job, data);
590 _select(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
596 _mouse_in(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
598 Elm_Toolbar_Item *it = data;
599 edje_object_signal_emit(it->base.view, "elm,state,highlighted", "elm");
600 elm_widget_signal_emit(it->icon, "elm,state,highlighted", "elm");
604 _mouse_out(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
606 Elm_Toolbar_Item *it = data;
607 edje_object_signal_emit(it->base.view, "elm,state,unhighlighted", "elm");
608 elm_widget_signal_emit(it->icon, "elm,state,unhighlighted", "elm");
612 _layout(Evas_Object *o, Evas_Object_Box_Data *priv, void *data)
614 Evas_Object *obj = (Evas_Object *) data;
615 Widget_Data *wd = elm_widget_data_get(obj);
617 _els_box_layout(o, priv, 1, wd->homogeneous, elm_widget_mirrored_get(obj));
620 static Elm_Toolbar_Item *
621 _item_new(Evas_Object *obj, const char *icon, const char *label, Evas_Smart_Cb func, const void *data)
623 Widget_Data *wd = elm_widget_data_get(obj);
624 Evas_Object *icon_obj;
626 Elm_Toolbar_Item *it;
628 icon_obj = elm_icon_add(obj);
629 elm_icon_order_lookup_set(icon_obj, wd->lookup_order);
630 if (!icon_obj) return NULL;
631 it = elm_widget_item_new(obj, Elm_Toolbar_Item);
634 evas_object_del(icon_obj);
637 it->label = eina_stringshare_add(label);
638 it->prio.visible = 1;
639 it->prio.priority = 0;
641 it->separator = EINA_FALSE;
642 it->base.data = data;
643 it->base.view = edje_object_add(evas_object_evas_get(obj));
644 if (_item_icon_set(icon_obj, "toolbar/", icon))
647 it->icon_str = eina_stringshare_add(icon);
653 evas_object_del(icon_obj);
656 _elm_theme_object_set(obj, it->base.view, "toolbar", "item",
657 elm_widget_style_get(obj));
658 edje_object_signal_callback_add(it->base.view, "elm,action,click", "elm",
660 edje_object_signal_callback_add(it->base.view, "elm,mouse,in", "elm",
662 edje_object_signal_callback_add(it->base.view, "elm,mouse,out", "elm",
664 elm_widget_sub_object_add(obj, it->base.view);
669 ms = ((double)wd->icon_size * _elm_config->scale);
670 evas_object_size_hint_min_set(it->icon, ms, ms);
671 evas_object_size_hint_max_set(it->icon, ms, ms);
672 edje_object_part_swallow(it->base.view, "elm.swallow.icon", it->icon);
673 evas_object_show(it->icon);
674 elm_widget_sub_object_add(obj, it->icon);
676 edje_object_part_text_set(it->base.view, "elm.text", it->label);
678 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
679 edje_object_size_min_restricted_calc(it->base.view, &mw, &mh, mw, mh);
680 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
681 evas_object_size_hint_weight_set(it->base.view, -1.0, EVAS_HINT_EXPAND);
682 evas_object_size_hint_align_set(it->base.view, 0.5, EVAS_HINT_FILL);
683 evas_object_size_hint_min_set(it->base.view, mw, mh);
684 evas_object_event_callback_add(it->base.view, EVAS_CALLBACK_RESIZE,
690 elm_toolbar_add(Evas_Object *parent)
696 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
698 ELM_SET_WIDTYPE(widtype, "toolbar");
699 elm_widget_type_set(obj, "toolbar");
700 elm_widget_sub_object_add(parent, obj);
701 elm_widget_data_set(obj, wd);
702 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
703 elm_widget_del_hook_set(obj, _del_hook);
704 elm_widget_theme_hook_set(obj, _theme_hook);
705 elm_widget_can_focus_set(obj, EINA_FALSE);
707 wd->more_item = NULL;
708 wd->selected_item = NULL;
709 wd->scr = elm_smart_scroller_add(e);
710 elm_smart_scroller_widget_set(wd->scr, obj);
711 elm_smart_scroller_object_theme_set(obj, wd->scr, "toolbar", "base", "default");
712 elm_smart_scroller_bounce_allow_set(wd->scr,
713 _elm_config->thumbscroll_bounce_enable,
715 elm_widget_resize_object_set(obj, wd->scr);
716 elm_smart_scroller_policy_set(wd->scr,
717 ELM_SMART_SCROLLER_POLICY_AUTO,
718 ELM_SMART_SCROLLER_POLICY_OFF);
721 wd->icon_size = _elm_toolbar_icon_size_get(wd);
724 wd->homogeneous = EINA_TRUE;
727 wd->bx = evas_object_box_add(e);
728 evas_object_size_hint_align_set(wd->bx, wd->align, 0.5);
729 evas_object_box_layout_set(wd->bx, _layout, obj, NULL);
730 elm_widget_sub_object_add(obj, wd->bx);
731 elm_smart_scroller_child_set(wd->scr, wd->bx);
732 evas_object_show(wd->bx);
734 elm_toolbar_mode_shrink_set(obj, _elm_config->toolbar_shrink_mode);
735 evas_object_event_callback_add(wd->scr, EVAS_CALLBACK_RESIZE, _resize, obj);
736 evas_object_event_callback_add(wd->bx, EVAS_CALLBACK_RESIZE, _resize, obj);
737 elm_toolbar_icon_order_lookup_set(obj, ELM_ICON_LOOKUP_THEME_FDO);
739 evas_object_smart_callbacks_descriptions_set(obj, _signals);
746 elm_toolbar_icon_size_set(Evas_Object *obj, int icon_size)
748 ELM_CHECK_WIDTYPE(obj, widtype);
749 Widget_Data *wd = elm_widget_data_get(obj);
751 if (wd->icon_size == icon_size) return;
752 wd->icon_size = icon_size;
757 elm_toolbar_icon_size_get(const Evas_Object *obj)
759 ELM_CHECK_WIDTYPE(obj, widtype) 0;
760 Widget_Data *wd = elm_widget_data_get(obj);
762 return wd->icon_size;
765 EAPI Elm_Toolbar_Item *
766 elm_toolbar_item_append(Evas_Object *obj, const char *icon, const char *label, Evas_Smart_Cb func, const void *data)
768 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
769 Widget_Data *wd = elm_widget_data_get(obj);
770 if (!wd) return NULL;
772 Elm_Toolbar_Item *it = _item_new(obj, icon, label, func, data);
773 if (!it) return NULL;
775 wd->items = eina_inlist_append(wd->items, EINA_INLIST_GET(it));
776 evas_object_box_append(wd->bx, it->base.view);
777 evas_object_show(it->base.view);
784 _elm_toolbar_item_state_cb(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
786 Elm_Toolbar_Item *it = event_info;
787 Elm_Toolbar_Item_State *it_state;
789 it_state = eina_list_data_get(it->current_state);
791 it_state->func((void *)it_state->data, obj, event_info);
794 EAPI Elm_Toolbar_Item_State *
795 elm_toolbar_item_state_next(Elm_Toolbar_Item *item)
799 Eina_List *next_state;
800 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
802 obj = item->base.widget;
803 wd = elm_widget_data_get(obj);
804 if (!wd) return NULL;
805 if (!item->states) return NULL;
807 next_state = eina_list_next(item->current_state);
809 next_state = eina_list_next(item->states);
810 return eina_list_data_get(next_state);
813 EAPI Elm_Toolbar_Item_State *
814 elm_toolbar_item_state_prev(Elm_Toolbar_Item *item)
818 Eina_List *prev_state;
819 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
821 obj = item->base.widget;
822 wd = elm_widget_data_get(obj);
823 if (!wd) return NULL;
824 if (!item->states) return NULL;
826 prev_state = eina_list_prev(item->current_state);
827 if ((!prev_state) || (prev_state == item->states))
828 prev_state = eina_list_last(item->states);
829 return eina_list_data_get(prev_state);
833 elm_toolbar_item_state_unset(Elm_Toolbar_Item *it)
835 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it);
836 elm_toolbar_item_state_set(it, NULL);
840 elm_toolbar_item_state_set(Elm_Toolbar_Item *it, Elm_Toolbar_Item_State *state)
843 Eina_List *next_state;
844 Elm_Toolbar_Item_State *it_state;
846 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, EINA_FALSE);
848 obj = it->base.widget;
849 wd = elm_widget_data_get(obj);
850 if (!wd) return EINA_FALSE;
851 if (!it->states) return EINA_FALSE;
855 next_state = eina_list_data_find_list(it->states, state);
856 if (!next_state) return EINA_FALSE;
859 next_state = it->states;
861 if (next_state == it->current_state) return EINA_TRUE;
863 it_state = eina_list_data_get(next_state);
864 if (eina_list_data_find(it->current_state, state))
866 _item_label_set(it, it_state->label, "elm,state,label_set,forward");
867 _elm_toolbar_item_icon_obj_set(obj, it, it_state->icon, it_state->icon_str,
868 wd->icon_size, "elm,state,icon_set,forward");
872 _item_label_set(it, it_state->label, "elm,state,label_set,backward");
873 _elm_toolbar_item_icon_obj_set(obj, it, it_state->icon, it_state->icon_str,
874 wd->icon_size, "elm,state,icon_set,backward");
877 elm_widget_signal_emit(it->icon, "elm,state,disabled", "elm");
879 elm_widget_signal_emit(it->icon, "elm,state,enabled", "elm");
881 it->current_state = next_state;
885 EAPI Elm_Toolbar_Item_State *
886 elm_toolbar_item_state_get(const Elm_Toolbar_Item *it)
888 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(it, NULL);
889 if ((!it->states) || (!it->current_state)) return NULL;
890 if (it->current_state == it->states) return NULL;
892 return eina_list_data_get(it->current_state);
895 static Elm_Toolbar_Item_State *
896 _item_state_new(const char *label, const char *icon_str, Evas_Object *icon, Evas_Smart_Cb func, const void *data)
898 Elm_Toolbar_Item_State *it_state;
899 it_state = ELM_NEW(Elm_Toolbar_Item_State);
900 it_state->label = eina_stringshare_add(label);
901 it_state->icon_str = eina_stringshare_add(icon_str);
902 it_state->icon = icon;
903 it_state->func = func;
904 it_state->data = data;
908 EAPI Elm_Toolbar_Item_State *
909 elm_toolbar_item_state_add(Elm_Toolbar_Item *item, const char *icon, const char *label, Evas_Smart_Cb func, const void *data)
911 Elm_Toolbar_Item_State *it_state;
912 Evas_Object *icon_obj;
915 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
916 obj = item->base.widget;
917 wd = elm_widget_data_get(item->base.widget);
918 if (!wd) return NULL;
922 it_state = _item_state_new(item->label, item->icon_str, item->icon,
923 item->func, item->base.data);
924 item->states = eina_list_append(item->states, it_state);
925 item->current_state = item->states;
928 icon_obj = elm_icon_add(obj);
929 elm_icon_order_lookup_set(icon_obj, wd->lookup_order);
930 if (!icon_obj) goto error_state_add;
932 if (!_item_icon_set(icon_obj, "toolbar/", icon))
934 evas_object_del(icon_obj);
939 it_state = _item_state_new(label, icon, icon_obj, func, data);
940 item->states = eina_list_append(item->states, it_state);
941 item->func = _elm_toolbar_item_state_cb;
942 item->base.data = NULL;
947 if (item->states && !eina_list_next(item->states))
949 eina_stringshare_del(item->label);
950 eina_stringshare_del(item->icon_str);
951 free(eina_list_data_get(item->states));
952 eina_list_free(item->states);
959 elm_toolbar_item_state_del(Elm_Toolbar_Item *item, Elm_Toolbar_Item_State *state)
961 Eina_List *del_state;
962 Elm_Toolbar_Item_State *it_state;
963 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
965 if (!state) return EINA_FALSE;
966 if (!item->states) return EINA_FALSE;
968 del_state = eina_list_data_find_list(item->states, state);
969 if (del_state == item->states) return EINA_FALSE;
970 if (del_state == item->current_state)
971 elm_toolbar_item_state_unset(item);
973 eina_stringshare_del(state->label);
974 eina_stringshare_del(state->icon_str);
975 if (state->icon) evas_object_del(state->icon);
977 item->states = eina_list_remove_list(item->states, del_state);
978 if (item->states && !eina_list_next(item->states))
980 it_state = eina_list_data_get(item->states);
981 item->base.data = it_state->data;
982 item->func = it_state->func;
983 eina_stringshare_del(it_state->label);
984 eina_stringshare_del(it_state->icon_str);
985 free(eina_list_data_get(item->states));
986 eina_list_free(item->states);
992 EAPI Elm_Toolbar_Item *
993 elm_toolbar_item_prepend(Evas_Object *obj, const char *icon, const char *label, Evas_Smart_Cb func, const void *data)
995 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
996 Widget_Data *wd = elm_widget_data_get(obj);
997 if (!wd) return NULL;
999 Elm_Toolbar_Item *it = _item_new(obj, icon, label, func, data);
1000 if (!it) return NULL;
1002 wd->items = eina_inlist_prepend(wd->items, EINA_INLIST_GET(it));
1003 evas_object_box_prepend(wd->bx, it->base.view);
1004 evas_object_show(it->base.view);
1010 EAPI Elm_Toolbar_Item *
1011 elm_toolbar_item_insert_before(Evas_Object *obj, Elm_Toolbar_Item *before, const char *icon, const char *label, Evas_Smart_Cb func, const void *data)
1013 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1014 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(before, NULL);
1015 Widget_Data *wd = elm_widget_data_get(obj);
1016 if (!wd) return NULL;
1018 Elm_Toolbar_Item *it = _item_new(obj, icon, label, func, data);
1019 if (!it) return NULL;
1021 wd->items = eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
1022 EINA_INLIST_GET(before));
1023 evas_object_box_insert_before(wd->bx, it->base.view, before->base.view);
1024 evas_object_show(it->base.view);
1030 EAPI Elm_Toolbar_Item *
1031 elm_toolbar_item_insert_after(Evas_Object *obj, Elm_Toolbar_Item *after, const char *icon, const char *label, Evas_Smart_Cb func, const void *data)
1033 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1034 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(after, NULL);
1035 Widget_Data *wd = elm_widget_data_get(obj);
1036 if (!wd) return NULL;
1038 Elm_Toolbar_Item *it = _item_new(obj, icon, label, func, data);
1039 if (!it) return NULL;
1041 wd->items = eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
1042 EINA_INLIST_GET(after));
1043 evas_object_box_insert_after(wd->bx, it->base.view, after->base.view);
1044 evas_object_show(it->base.view);
1050 EAPI Elm_Toolbar_Item *
1051 elm_toolbar_first_item_get(const Evas_Object *obj)
1053 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1054 Widget_Data *wd = elm_widget_data_get(obj);
1055 if (!wd || !wd->items) return NULL;
1056 Elm_Toolbar_Item *it = ELM_TOOLBAR_ITEM_FROM_INLIST(wd->items);
1060 EAPI Elm_Toolbar_Item *
1061 elm_toolbar_last_item_get(const Evas_Object *obj)
1063 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1064 Widget_Data *wd = elm_widget_data_get(obj);
1065 if (!wd || !wd->items) return NULL;
1066 Elm_Toolbar_Item *it = ELM_TOOLBAR_ITEM_FROM_INLIST(wd->items->last);
1070 EAPI Elm_Toolbar_Item *
1071 elm_toolbar_item_next_get(const Elm_Toolbar_Item *item)
1073 Elm_Toolbar_Item *next;
1074 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
1075 next = ELM_TOOLBAR_ITEM_FROM_INLIST(EINA_INLIST_GET(item)->next);
1079 EAPI Elm_Toolbar_Item *
1080 elm_toolbar_item_prev_get(const Elm_Toolbar_Item *item)
1082 Elm_Toolbar_Item *prev;
1083 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
1084 prev = ELM_TOOLBAR_ITEM_FROM_INLIST(EINA_INLIST_GET(item)->prev);
1089 elm_toolbar_item_toolbar_get(const Elm_Toolbar_Item *item)
1091 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
1092 return item->base.widget;
1096 elm_toolbar_item_priority_set(Elm_Toolbar_Item *item, int priority)
1098 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
1099 if (item->prio.priority == priority) return;
1100 item->prio.priority = priority;
1101 _resize(item->base.widget, NULL, NULL, NULL);
1105 elm_toolbar_item_priority_get(const Elm_Toolbar_Item *item)
1107 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, 0);
1108 return item->prio.priority;
1112 elm_toolbar_item_icon_get(const Elm_Toolbar_Item *item)
1114 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
1115 return item->icon_str;
1119 elm_toolbar_item_label_get(const Elm_Toolbar_Item *item)
1121 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
1126 _elm_toolbar_item_label_update(Elm_Toolbar_Item *item)
1128 Evas_Coord mw = -1, mh = -1;
1129 edje_object_part_text_set(item->base.view, "elm.text", item->label);
1131 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1132 edje_object_size_min_restricted_calc(item->base.view, &mw, &mh, mw, mh);
1133 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1134 evas_object_size_hint_weight_set(item->base.view, -1.0, EVAS_HINT_EXPAND);
1135 evas_object_size_hint_align_set(item->base.view, 0.5, EVAS_HINT_FILL);
1136 evas_object_size_hint_min_set(item->base.view, mw, mh);
1140 _elm_toolbar_item_label_set_cb (void *data, Evas_Object *obj, const char *emission, const char *source)
1142 Elm_Toolbar_Item *item = data;
1143 _elm_toolbar_item_label_update(item);
1144 edje_object_signal_callback_del(obj, emission, source,
1145 _elm_toolbar_item_label_set_cb);
1146 edje_object_signal_emit (item->base.view, "elm,state,label,reset", "elm");
1150 _item_label_set(Elm_Toolbar_Item *item, const char *label, const char *signal)
1154 if ((label) && (item->label) && (!strcmp(label, item->label))) return;
1156 eina_stringshare_replace(&item->label, label);
1157 s = edje_object_data_get(item->base.view, "transition_animation_on");
1158 if ((s) && (atoi(s)))
1160 edje_object_part_text_set(item->base.view, "elm.text_new", item->label);
1161 edje_object_signal_emit (item->base.view, signal, "elm");
1162 edje_object_signal_callback_add(item->base.view,
1163 "elm,state,label_set,done", "elm",
1164 _elm_toolbar_item_label_set_cb, item);
1167 _elm_toolbar_item_label_update(item);
1168 _resize(item->base.widget, NULL, NULL, NULL);
1172 elm_toolbar_item_label_set(Elm_Toolbar_Item *item, const char *label)
1174 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
1175 _item_label_set(item, label, "elm,state,label_set");
1179 _elm_toolbar_item_icon_update(Elm_Toolbar_Item *item)
1181 Elm_Toolbar_Item_State *it_state;
1183 Evas_Coord mw = -1, mh = -1;
1184 Evas_Object *old_icon = edje_object_part_swallow_get(item->base.view,
1185 "elm.swallow.icon");
1186 elm_widget_sub_object_del(item->base.view, old_icon);
1187 evas_object_hide(old_icon);
1188 edje_object_part_swallow(item->base.view, "elm.swallow.icon", item->icon);
1189 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1190 edje_object_size_min_restricted_calc(item->base.view, &mw, &mh, mw, mh);
1191 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1192 evas_object_size_hint_weight_set(item->base.view, -1.0, EVAS_HINT_EXPAND);
1193 evas_object_size_hint_align_set(item->base.view, 0.5, EVAS_HINT_FILL);
1194 evas_object_size_hint_min_set(item->base.view, mw, mh);
1196 EINA_LIST_FOREACH(item->states, l, it_state)
1197 if (it_state->icon == old_icon)
1199 evas_object_del(old_icon);
1203 elm_toolbar_item_selected_get(const Elm_Toolbar_Item *item)
1205 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
1206 return item->selected;
1210 elm_toolbar_item_selected_set(Elm_Toolbar_Item *item, Eina_Bool selected)
1212 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
1213 Widget_Data *wd = elm_widget_data_get(item->base.widget);
1216 if (item->selected == selected) return;
1221 _item_unselect(item);
1224 EAPI Elm_Toolbar_Item *
1225 elm_toolbar_selected_item_get(const Evas_Object *obj)
1227 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1228 Widget_Data *wd = elm_widget_data_get(obj);
1229 if (!wd) return NULL;
1230 return wd->selected_item;
1234 _elm_toolbar_item_icon_set_cb (void *data, Evas_Object *obj, const char *emission, const char *source)
1236 Elm_Toolbar_Item *item = data;
1237 edje_object_part_unswallow(item->base.view, item->icon);
1238 _elm_toolbar_item_icon_update(item);
1239 edje_object_signal_callback_del(obj, emission, source,
1240 _elm_toolbar_item_icon_set_cb);
1241 edje_object_signal_emit (item->base.view, "elm,state,icon,reset", "elm");
1245 _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 *signal)
1247 Evas_Object *old_icon;
1252 eina_stringshare_replace(&item->icon_str, icon_str);
1255 eina_stringshare_del(item->icon_str);
1256 item->icon_str = NULL;
1258 item->icon = icon_obj;
1261 ms = (icon_size * _elm_config->scale);
1262 evas_object_size_hint_min_set(item->icon, ms, ms);
1263 evas_object_size_hint_max_set(item->icon, ms, ms);
1264 evas_object_show(item->icon);
1265 elm_widget_sub_object_add(obj, item->icon);
1267 s = edje_object_data_get(item->base.view, "transition_animation_on");
1268 if ((s) && (atoi(s)))
1270 old_icon = edje_object_part_swallow_get(item->base.view,
1271 "elm.swallow.icon_new");
1274 elm_widget_sub_object_del(item->base.view, old_icon);
1275 evas_object_hide(old_icon);
1277 edje_object_part_swallow(item->base.view, "elm.swallow.icon_new",
1279 edje_object_signal_emit (item->base.view, signal, "elm");
1280 edje_object_signal_callback_add(item->base.view,
1281 "elm,state,icon_set,done", "elm",
1282 _elm_toolbar_item_icon_set_cb, item);
1285 _elm_toolbar_item_icon_update(item);
1286 _resize(obj, NULL, NULL, NULL);
1290 elm_toolbar_item_icon_set(Elm_Toolbar_Item *item, const char *icon)
1292 Evas_Object *icon_obj;
1294 Evas_Object *obj = item->base.widget;
1296 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
1297 wd = elm_widget_data_get(obj);
1299 if ((icon) && (item->icon_str) && (!strcmp(icon, item->icon_str))) return;
1301 icon_obj = elm_icon_add(obj);
1302 if (!icon_obj) return;
1303 if (_item_icon_set(icon_obj, "toolbar/", icon))
1304 _elm_toolbar_item_icon_obj_set(obj, item, icon_obj, icon, wd->icon_size,
1305 "elm,state,icon_set");
1308 _elm_toolbar_item_icon_obj_set(obj, item, NULL, NULL, 0,
1309 "elm,state,icon_set");
1310 evas_object_del(icon_obj);
1315 elm_toolbar_item_del(Elm_Toolbar_Item *item)
1320 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
1321 wd = elm_widget_data_get(item->base.widget);
1323 obj2 = item->base.widget;
1324 wd->items = eina_inlist_remove(wd->items, EINA_INLIST_GET(item));
1330 elm_toolbar_item_del_cb_set(Elm_Toolbar_Item *item, Evas_Smart_Cb func)
1332 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
1333 elm_widget_item_del_cb_set(item, func);
1337 elm_toolbar_item_disabled_get(const Elm_Toolbar_Item *item)
1339 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
1340 return item->disabled;
1344 elm_toolbar_item_disabled_set(Elm_Toolbar_Item *item, Eina_Bool disabled)
1346 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
1347 _item_disable(item, disabled);
1348 _resize(item->base.widget, NULL, NULL, NULL);
1352 elm_toolbar_item_separator_set(Elm_Toolbar_Item *item, Eina_Bool separator)
1354 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
1355 Evas_Object *obj = item->base.widget;
1356 Widget_Data *wd = elm_widget_data_get(obj);
1358 if (item->separator == separator) return;
1359 item->separator = separator;
1360 scale = (elm_widget_scale_get(obj) * _elm_config->scale);
1361 _theme_hook_item(obj, item, scale, wd->icon_size);
1365 elm_toolbar_item_separator_get(const Elm_Toolbar_Item *item)
1367 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
1368 return item->separator;
1372 elm_toolbar_mode_shrink_set(Evas_Object *obj, Elm_Toolbar_Shrink_Mode shrink_mode)
1374 ELM_CHECK_WIDTYPE(obj, widtype);
1375 Widget_Data *wd = elm_widget_data_get(obj);
1379 wd->shrink_mode = shrink_mode;
1380 bounce = (_elm_config->thumbscroll_bounce_enable) &&
1381 (shrink_mode == ELM_TOOLBAR_SHRINK_SCROLL);
1382 elm_smart_scroller_bounce_allow_set(wd->scr, bounce, EINA_FALSE);
1386 _item_del(wd->more_item);
1387 wd->more_item = NULL;
1390 if (shrink_mode == ELM_TOOLBAR_SHRINK_MENU)
1392 elm_smart_scroller_policy_set(wd->scr, ELM_SMART_SCROLLER_POLICY_OFF, ELM_SMART_SCROLLER_POLICY_OFF);
1394 wd->more_item = _item_new(obj, "more_menu", "More",
1397 else if (shrink_mode == ELM_TOOLBAR_SHRINK_HIDE)
1398 elm_smart_scroller_policy_set(wd->scr, ELM_SMART_SCROLLER_POLICY_OFF,
1399 ELM_SMART_SCROLLER_POLICY_OFF);
1401 elm_smart_scroller_policy_set(wd->scr, ELM_SMART_SCROLLER_POLICY_AUTO,
1402 ELM_SMART_SCROLLER_POLICY_OFF);
1406 EAPI Elm_Toolbar_Shrink_Mode
1407 elm_toolbar_mode_shrink_get(const Evas_Object *obj)
1409 ELM_CHECK_WIDTYPE(obj, widtype) ELM_TOOLBAR_SHRINK_NONE;
1410 Widget_Data *wd = elm_widget_data_get(obj);
1412 if (!wd) return ELM_TOOLBAR_SHRINK_NONE;
1413 return wd->shrink_mode;
1417 elm_toolbar_homogeneous_set(Evas_Object *obj, Eina_Bool homogeneous)
1419 ELM_CHECK_WIDTYPE(obj, widtype);
1420 Widget_Data *wd = elm_widget_data_get(obj);
1423 wd->homogeneous = !!homogeneous;
1424 evas_object_smart_calculate(wd->bx);
1427 EINA_DEPRECATED EAPI void
1428 elm_toolbar_homogenous_set(Evas_Object *obj, Eina_Bool homogenous)
1430 elm_toolbar_homogeneous_set(obj, homogenous);
1434 elm_toolbar_homogeneous_get(const Evas_Object *obj)
1436 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1437 Widget_Data *wd = elm_widget_data_get(obj);
1439 if (!wd) return EINA_FALSE;
1440 return wd->homogeneous;
1443 EINA_DEPRECATED EAPI Eina_Bool
1444 elm_toolbar_homogenous_get(const Evas_Object *obj)
1446 return elm_toolbar_homogeneous_get(obj);
1450 elm_toolbar_menu_parent_set(Evas_Object *obj, Evas_Object *parent)
1452 Elm_Toolbar_Item *it;
1453 ELM_CHECK_WIDTYPE(obj, widtype);
1454 Widget_Data *wd = elm_widget_data_get(obj);
1457 EINA_SAFETY_ON_NULL_RETURN(parent);
1458 wd->menu_parent = parent;
1459 EINA_INLIST_FOREACH(wd->items, it)
1462 elm_menu_parent_set(it->o_menu, wd->menu_parent);
1464 if ((wd->more_item) && (wd->more_item->o_menu))
1465 elm_menu_parent_set(wd->more_item->o_menu, wd->menu_parent);
1469 elm_toolbar_menu_parent_get(const Evas_Object *obj)
1471 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1472 Widget_Data *wd = elm_widget_data_get(obj);
1474 if (!wd) return NULL;
1475 return wd->menu_parent;
1479 elm_toolbar_align_set(Evas_Object *obj, double align)
1481 ELM_CHECK_WIDTYPE(obj, widtype);
1482 Widget_Data *wd = elm_widget_data_get(obj);
1485 if (wd->align != align)
1486 evas_object_size_hint_align_set(wd->bx, align, 0.5);
1491 elm_toolbar_align_get(const Evas_Object *obj)
1493 ELM_CHECK_WIDTYPE(obj, widtype) 0.0;
1494 Widget_Data *wd = elm_widget_data_get(obj);
1496 if (!wd) return 0.0;
1501 elm_toolbar_item_menu_set(Elm_Toolbar_Item *item, Eina_Bool menu)
1503 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
1504 Widget_Data *wd = elm_widget_data_get(item->base.widget);
1507 if (item->menu == menu) return;
1509 if (menu) _item_menu_create(wd, item);
1510 else _item_menu_destroy(item);
1514 elm_toolbar_item_tooltip_text_set(Elm_Toolbar_Item *item, const char *text)
1516 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
1517 elm_widget_item_tooltip_text_set(item, text);
1521 elm_toolbar_item_tooltip_content_cb_set(Elm_Toolbar_Item *item, Elm_Tooltip_Item_Content_Cb func, const void *data, Evas_Smart_Cb del_cb)
1523 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
1524 elm_widget_item_tooltip_content_cb_set(item, func, data, del_cb);
1528 elm_toolbar_item_tooltip_unset(Elm_Toolbar_Item *item)
1530 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
1531 elm_widget_item_tooltip_unset(item);
1535 elm_toolbar_item_tooltip_style_set(Elm_Toolbar_Item *item, const char *style)
1537 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
1538 elm_widget_item_tooltip_style_set(item, style);
1542 elm_toolbar_item_tooltip_style_get(const Elm_Toolbar_Item *item)
1544 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
1545 return elm_widget_item_tooltip_style_get(item);
1549 elm_toolbar_item_cursor_set(Elm_Toolbar_Item *item, const char *cursor)
1551 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
1552 elm_widget_item_cursor_set(item, cursor);
1556 elm_toolbar_item_cursor_get(const Elm_Toolbar_Item *item)
1558 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
1559 return elm_widget_item_cursor_get(item);
1563 elm_toolbar_item_cursor_unset(Elm_Toolbar_Item *item)
1565 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
1566 elm_widget_item_cursor_unset(item);
1570 elm_toolbar_item_cursor_style_set(Elm_Toolbar_Item *item, const char *style)
1572 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
1573 elm_widget_item_cursor_style_set(item, style);
1577 elm_toolbar_item_cursor_style_get(const Elm_Toolbar_Item *item)
1579 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
1580 return elm_widget_item_cursor_style_get(item);
1584 elm_toolbar_item_cursor_engine_only_set(Elm_Toolbar_Item *item, Eina_Bool engine_only)
1586 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
1587 elm_widget_item_cursor_engine_only_set(item, engine_only);
1591 elm_toolbar_item_cursor_engine_only_get(const Elm_Toolbar_Item *item)
1593 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, EINA_FALSE);
1594 return elm_widget_item_cursor_engine_only_get(item);
1598 elm_toolbar_item_menu_get(Elm_Toolbar_Item *item)
1600 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
1601 Widget_Data *wd = elm_widget_data_get(item->base.widget);
1602 if (!wd) return NULL;
1603 /* FIXME: It's not ok. This function needs to be reviewed. And should
1604 * receive a const item */
1605 elm_toolbar_item_menu_set(item, 1);
1606 return item->o_menu;
1609 EAPI Elm_Toolbar_Item *
1610 elm_toolbar_item_find_by_label(const Evas_Object *obj, const char *label)
1612 Elm_Toolbar_Item *it;
1613 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1614 Widget_Data *wd = elm_widget_data_get(obj);
1616 if (!wd) return NULL;
1617 EINA_INLIST_FOREACH(wd->items, it)
1619 if (!strcmp(it->label, label)) return it;
1626 elm_toolbar_item_data_set(Elm_Toolbar_Item *item, const void *data)
1628 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item);
1629 elm_widget_item_data_set(item, data);
1633 elm_toolbar_item_data_get(const Elm_Toolbar_Item *item)
1635 ELM_WIDGET_ITEM_WIDTYPE_CHECK_OR_RETURN(item, NULL);
1636 return elm_widget_item_data_get(item);
1640 elm_toolbar_no_select_mode_set(Evas_Object *obj, Eina_Bool no_select)
1642 ELM_CHECK_WIDTYPE(obj, widtype);
1643 Widget_Data *wd = elm_widget_data_get(obj);
1645 wd->no_select = no_select;
1649 elm_toolbar_no_select_mode_get(const Evas_Object *obj)
1651 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1652 Widget_Data *wd = elm_widget_data_get(obj);
1653 if (!wd) return EINA_FALSE;
1654 return wd->no_select;
1658 elm_toolbar_icon_order_lookup_set(Evas_Object *obj, Elm_Icon_Lookup_Order order)
1660 ELM_CHECK_WIDTYPE(obj, widtype);
1661 Elm_Toolbar_Item *it;
1662 Widget_Data *wd = elm_widget_data_get(obj);
1665 wd->lookup_order = order;
1666 EINA_INLIST_FOREACH(wd->items, it)
1667 elm_icon_order_lookup_set(it->icon, order);
1669 elm_icon_order_lookup_set(wd->more_item->icon, order);
1672 EAPI Elm_Icon_Lookup_Order
1673 elm_toolbar_icon_order_lookup_get(const Evas_Object *obj)
1675 ELM_CHECK_WIDTYPE(obj, widtype) ELM_ICON_LOOKUP_THEME_FDO;
1676 Widget_Data *wd = elm_widget_data_get(obj);
1677 if (!wd) return ELM_ICON_LOOKUP_THEME_FDO;
1678 return wd->lookup_order;