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;
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 unsigned int item_count;
21 Elm_Object_Select_Mode select_mode;
22 Eina_Bool homogeneous : 1;
23 Eina_Bool vertical : 1;
24 Eina_Bool long_press : 1;
25 Ecore_Timer *long_timer;
26 Ecore_Job *resize_job;
29 struct _Elm_Toolbar_Item
41 Eina_Bool visible : 1;
43 Eina_Bool selected : 1;
44 Eina_Bool separator : 1;
47 Eina_List *current_state;
50 #define ELM_TOOLBAR_ITEM_FROM_INLIST(item) \
51 ((item) ? EINA_INLIST_CONTAINER_GET(item, Elm_Toolbar_Item) : NULL)
53 struct _Elm_Toolbar_Item_State
62 static const char *widtype = NULL;
63 static void _item_show(Elm_Toolbar_Item *it);
64 static void _item_select(Elm_Toolbar_Item *it);
65 static void _item_unselect(Elm_Toolbar_Item *it);
66 static void _del_pre_hook(Evas_Object *obj);
67 static void _del_hook(Evas_Object *obj);
68 static void _mirrored_set(Evas_Object *obj, Eina_Bool mirrored);
69 static void _mirrored_set_item(Evas_Object *obj, Elm_Toolbar_Item *it, Eina_Bool mirrored);
70 static void _theme_hook(Evas_Object *obj);
71 static void _sizing_eval(Evas_Object *obj);
72 static void _resize(void *data, Evas *e, Evas_Object *obj, void *event_info);
73 static void _menu_move_resize(void *data, Evas *e, Evas_Object *obj, void *event_info);
74 static void _menu_hide(void *data, Evas *e, Evas_Object *obj, void *event_info);
75 static void _layout(Evas_Object *o, Evas_Object_Box_Data *priv, void *data);
76 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);
77 static void _item_label_set(Elm_Toolbar_Item *item, const char *label, const char *sig);
79 static const char SIG_CLICKED[] = "clicked";
80 static const char SIG_LONGPRESSED[] = "longpressed";
81 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
83 static const Evas_Smart_Cb_Description _signals[] = {
85 {SIG_LONGPRESSED, ""},
86 {SIG_CLICKED_DOUBLE, ""},
91 _item_disable_hook(Elm_Object_Item *it)
94 Elm_Toolbar_Item *toolbar_it = (Elm_Toolbar_Item *)it;
96 wd = elm_widget_data_get(WIDGET(toolbar_it));
99 if (elm_widget_item_disabled_get(toolbar_it))
101 edje_object_signal_emit(VIEW(toolbar_it), "elm,state,disabled", "elm");
102 elm_widget_signal_emit(toolbar_it->icon, "elm,state,disabled", "elm");
106 edje_object_signal_emit(VIEW(toolbar_it), "elm,state,enabled", "elm");
107 elm_widget_signal_emit(toolbar_it->icon, "elm,state,enabled", "elm");
109 _resize(WIDGET(toolbar_it), NULL, NULL, NULL);
113 _item_icon_set(Evas_Object *icon_obj, const char *type, const char *icon)
117 if ((!type) || (!*type)) goto end;
118 if ((!icon) || (!*icon)) return EINA_FALSE;
119 if ((snprintf(icon_str, sizeof(icon_str), "%s%s", type, icon) > 0)
120 && (elm_icon_standard_set(icon_obj, icon_str)))
123 if (elm_icon_standard_set(icon_obj, icon))
125 WRN("couldn't find icon definition for '%s'", icon);
130 _elm_toolbar_icon_size_get(Widget_Data *wd)
132 const char *icon_size = edje_object_data_get(
133 elm_smart_scroller_edje_object_get(wd->scr), "icon_size");
135 return atoi(icon_size);
136 return _elm_config->icon_size;
140 _item_show(Elm_Toolbar_Item *it)
142 Widget_Data *wd = elm_widget_data_get(WIDGET(it));
143 Evas_Coord x, y, w, h, bx, by;
146 evas_object_geometry_get(wd->bx, &bx, &by, NULL, NULL);
147 evas_object_geometry_get(VIEW(it), &x, &y, &w, &h);
148 elm_smart_scroller_child_region_show(wd->scr, x - bx, y - by, w, h);
152 _item_unselect(Elm_Toolbar_Item *item)
155 if ((!item) || (!item->selected)) return;
156 wd = elm_widget_data_get(WIDGET(item));
158 item->selected = EINA_FALSE;
159 wd->selected_item = NULL;
160 edje_object_signal_emit(VIEW(item), "elm,state,unselected", "elm");
161 elm_widget_signal_emit(item->icon, "elm,state,unselected", "elm");
165 _item_select(Elm_Toolbar_Item *it)
167 Elm_Toolbar_Item *it2;
168 Widget_Data *wd = elm_widget_data_get(WIDGET(it));
173 if (elm_widget_item_disabled_get(it) || (it->separator) || (it->object)) return;
176 if (wd->select_mode != ELM_OBJECT_SELECT_MODE_NONE)
180 if (wd->select_mode == ELM_OBJECT_SELECT_MODE_ALWAYS) return;
185 it2 = (Elm_Toolbar_Item *)
186 elm_toolbar_selected_item_get(WIDGET(it));
189 it->selected = EINA_TRUE;
190 wd->selected_item = it;
191 edje_object_signal_emit(VIEW(it), "elm,state,selected", "elm");
192 elm_widget_signal_emit(it->icon, "elm,state,selected", "elm");
197 if (it->menu && (!sel))
199 evas_object_show(it->o_menu);
200 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_RESIZE,
201 _menu_move_resize, it);
202 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MOVE,
203 _menu_move_resize, it);
205 _menu_move_resize(it, NULL, NULL, NULL);
207 if (it->func) it->func((void *)(it->base.data), WIDGET(it), it);
208 evas_object_smart_callback_call(obj2, SIG_CLICKED, it);
212 _menu_hide(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
214 Elm_Toolbar_Item *selected;
215 Elm_Toolbar_Item *it = data;
216 selected = (Elm_Toolbar_Item *) elm_toolbar_selected_item_get(WIDGET(it));
217 _item_unselect(selected);
221 _menu_del(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
223 // avoid hide being emitted during object deletion
224 evas_object_event_callback_del_full
225 (obj, EVAS_CALLBACK_HIDE, _menu_hide, data);
229 _menu_move_resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
231 Elm_Toolbar_Item *it = data;
233 Widget_Data *wd = elm_widget_data_get(WIDGET(it));
235 if ((!wd) || (!wd->menu_parent)) return;
236 evas_object_geometry_get(VIEW(it), &x, &y, &w, &h);
237 elm_menu_move(it->o_menu, x, y+h);
241 _item_del(Elm_Toolbar_Item *it)
243 Elm_Toolbar_Item_State *it_state;
245 EINA_LIST_FREE(it->states, it_state)
247 if (it->icon == it_state->icon)
249 eina_stringshare_del(it_state->label);
250 eina_stringshare_del(it_state->icon_str);
251 if (it_state->icon) evas_object_del(it_state->icon);
254 eina_stringshare_del(it->label);
255 eina_stringshare_del(it->icon_str);
256 if (it->icon) evas_object_del(it->icon);
257 //TODO: See if checking for wd->menu_parent is necessary before deleting menu
258 if (it->o_menu) evas_object_del(it->o_menu);
262 _del_pre_hook(Evas_Object *obj)
264 Widget_Data *wd = elm_widget_data_get(obj);
265 Elm_Toolbar_Item *it, *next;
268 it = ELM_TOOLBAR_ITEM_FROM_INLIST(wd->items);
271 next = ELM_TOOLBAR_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
273 elm_widget_item_free(it);
278 _item_del(wd->more_item);
279 elm_widget_item_free(wd->more_item);
283 ecore_timer_del(wd->long_timer);
284 wd->long_timer = NULL;
289 _del_hook(Evas_Object *obj)
291 Widget_Data *wd = elm_widget_data_get(obj);
299 _mirrored_set_item(Evas_Object *obj __UNUSED__, Elm_Toolbar_Item *it, Eina_Bool mirrored)
301 edje_object_mirrored_set(VIEW(it), mirrored);
302 elm_widget_mirrored_set(it->o_menu, mirrored);
306 _theme_hook_item(Evas_Object *obj, Elm_Toolbar_Item *it, double scale, int icon_size)
308 Widget_Data *wd = elm_widget_data_get(obj);
309 Evas_Object *view = VIEW(it);
311 const char *style = elm_widget_style_get(obj);
313 _mirrored_set_item(obj, it, elm_widget_mirrored_get(obj));
314 edje_object_scale_set(view, scale);
315 if (!it->separator && !it->object)
317 _elm_theme_object_set(obj, view, "toolbar", "item", style);
320 edje_object_signal_emit(view, "elm,state,selected", "elm");
321 elm_widget_signal_emit(it->icon, "elm,state,selected", "elm");
323 if (elm_widget_item_disabled_get(it))
325 edje_object_signal_emit(view, "elm,state,disabled", "elm");
326 elm_widget_signal_emit(it->icon, "elm,state,disabled", "elm");
332 ms = ((double)icon_size * scale);
333 evas_object_size_hint_min_set(it->icon, ms, ms);
334 evas_object_size_hint_max_set(it->icon, ms, ms);
335 edje_object_part_swallow(view, "elm.swallow.icon", it->icon);
337 edje_object_part_text_set(view, "elm.text", it->label);
343 _elm_theme_object_set(obj, view, "toolbar", "separator", style);
346 evas_object_size_hint_weight_set(view, EVAS_HINT_EXPAND, -1.0);
347 evas_object_size_hint_align_set(view, EVAS_HINT_FILL, 0.5);
351 evas_object_size_hint_weight_set(view, -1.0, EVAS_HINT_EXPAND);
352 evas_object_size_hint_align_set(view, 0.5, EVAS_HINT_FILL);
357 _elm_theme_object_set(obj, view, "toolbar", "object", style);
358 edje_object_part_swallow(view, "elm.swallow.object", it->object);
363 if (!it->separator && !it->object)
364 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
365 edje_object_size_min_restricted_calc(view, &mw, &mh, mw, mh);
366 if (!it->separator && !it->object)
367 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
368 evas_object_size_hint_min_set(view, mw, mh);
372 _mirrored_set(Evas_Object *obj, Eina_Bool mirrored)
374 Widget_Data *wd = elm_widget_data_get(obj);
375 Elm_Toolbar_Item *it;
377 EINA_INLIST_FOREACH(wd->items, it)
378 _mirrored_set_item(obj, it, mirrored);
380 _mirrored_set_item(obj, wd->more_item, mirrored);
384 _theme_hook(Evas_Object *obj)
386 Widget_Data *wd = elm_widget_data_get(obj);
387 Elm_Toolbar_Item *it;
391 _elm_widget_mirrored_reload(obj);
392 elm_smart_scroller_object_theme_set(obj, wd->scr, "toolbar", "base", elm_widget_style_get(obj));
393 _mirrored_set(obj, elm_widget_mirrored_get(obj));
394 scale = (elm_widget_scale_get(obj) * _elm_config->scale);
395 edje_object_scale_set(wd->scr, scale);
396 wd->icon_size = _elm_toolbar_icon_size_get(wd);
397 EINA_INLIST_FOREACH(wd->items, it)
398 _theme_hook_item(obj, it, scale, wd->icon_size);
400 _theme_hook_item(obj, wd->more_item, scale, wd->icon_size);
405 _item_text_set_hook(Elm_Object_Item *it,
409 if (part && strcmp(part, "default")) return;
410 _item_label_set(((Elm_Toolbar_Item *)it), label, "elm,state,label_set");
414 _item_text_get_hook(const Elm_Object_Item *it, const char *part)
416 if (part && strcmp(part, "default")) return NULL;
417 return ((Elm_Toolbar_Item *)it)->label;
421 _item_content_set_hook(Elm_Object_Item *it,
423 Evas_Object *content)
427 if (part && strcmp(part, "object")) return;
428 Elm_Toolbar_Item *item = (Elm_Toolbar_Item *) it;
429 Evas_Object *obj = WIDGET(item);
430 Widget_Data *wd = elm_widget_data_get(obj);
432 if (item->object == content) return;
433 item->object = content;
434 elm_widget_sub_object_add(obj, item->object);
435 scale = (elm_widget_scale_get(obj) * _elm_config->scale);
436 _theme_hook_item(obj, item, scale, wd->icon_size);
440 _item_content_get_hook(const Elm_Object_Item *it, const char *part)
442 if (part && strcmp(part, "object")) return NULL;
443 return ((Elm_Toolbar_Item *) it)->object;
447 _item_content_unset_hook(Elm_Object_Item *it, const char *part)
452 if (part && strcmp(part, "object")) return NULL;
453 Elm_Toolbar_Item *item = (Elm_Toolbar_Item *) it;
454 Evas_Object *obj = WIDGET(item);
455 Widget_Data *wd = elm_widget_data_get(obj);
457 edje_object_part_unswallow(VIEW(it), item->object);
458 elm_widget_sub_object_del(obj, item->object);
461 scale = (elm_widget_scale_get(obj) * _elm_config->scale);
462 _theme_hook_item(obj, item, scale, wd->icon_size);
467 _translate_hook(Evas_Object *obj)
469 evas_object_smart_callback_call(obj, "language,changed", NULL);
473 _sizing_eval(Evas_Object *obj)
475 Widget_Data *wd = elm_widget_data_get(obj);
476 Evas_Coord minw = -1, minh = -1, minw_bx = -1, minh_bx = -1;
477 Evas_Coord vw = 0, vh = 0;
481 evas_object_smart_need_recalculate_set(wd->bx, EINA_TRUE);
482 evas_object_smart_calculate(wd->bx);
483 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr),
485 evas_object_geometry_get(obj, NULL, NULL, &w, &h);
486 if (w < minw) w = minw;
487 if (h < minh) h = minh;
488 evas_object_resize(wd->scr, w, h);
490 evas_object_size_hint_min_get(wd->bx, &minw_bx, &minh_bx);
491 // if (wd->vertical && (h > minh)) minh = h;
492 // if ((!wd->vertical) && (w > minw)) minw = w;
493 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
494 if (wd->shrink_mode == ELM_TOOLBAR_SHRINK_NONE)
498 minw = minw_bx + (w - vw);
499 minh = minh_bx + (h - vh);
503 minw = minw_bx + (w - vw);
504 minh = minh_bx + (h - vh);
507 else if (wd->shrink_mode == ELM_TOOLBAR_SHRINK_EXPAND)
509 minw = minw_bx + (w - vw);
510 minh = minh_bx + (h - vh);
511 if (minw_bx < vw) minw_bx = vw;
512 if (minh_bx < vh) minh_bx = vh;
518 minw = minw_bx + (w - vw);
524 minh = minh_bx + (h - vh);
526 // if (wd->vertical) minh = h - vh;
527 // else minw = w - vw;
528 // minh = minh + (h - vh);
530 evas_object_resize(wd->bx, minw_bx, minh_bx);
531 evas_object_size_hint_min_set(obj, minw, minh);
532 evas_object_size_hint_max_set(obj, -1, -1);
536 _item_menu_create(Widget_Data *wd, Elm_Toolbar_Item *item)
538 item->o_menu = elm_menu_add(VIEW(item));
539 item->menu = EINA_TRUE;
541 elm_menu_parent_set(item->o_menu, wd->menu_parent);
542 evas_object_event_callback_add(item->o_menu, EVAS_CALLBACK_HIDE,
544 evas_object_event_callback_add(item->o_menu, EVAS_CALLBACK_DEL,
549 _item_menu_destroy(Elm_Toolbar_Item *item)
553 evas_object_del(item->o_menu);
556 item->menu = EINA_FALSE;
560 _toolbar_item_prio_compare_cb(const void *i1, const void *i2)
562 const Elm_Toolbar_Item *eti1 = i1;
563 const Elm_Toolbar_Item *eti2 = i2;
566 if (!eti1) return -1;
568 return eti2->prio.priority - eti1->prio.priority;
572 _fix_items_visibility(Widget_Data *wd, Evas_Coord *iw, Evas_Coord vw)
574 Elm_Toolbar_Item *it;
575 Eina_List *sorted = NULL;
576 Evas_Coord ciw = 0, cih = 0;
578 EINA_INLIST_FOREACH(wd->items, it)
580 sorted = eina_list_sorted_insert(sorted,
581 _toolbar_item_prio_compare_cb, it);
586 evas_object_geometry_get(wd->VIEW(more_item), NULL, NULL, &ciw, &cih);
587 if (wd->vertical) *iw += cih;
590 EINA_LIST_FREE(sorted, it)
592 evas_object_geometry_get(VIEW(it), NULL, NULL, &ciw, &cih);
593 if (wd->vertical) *iw += cih;
595 it->prio.visible = (*iw <= vw);
600 _elm_toolbar_item_menu_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
602 Elm_Toolbar_Item *it = data;
603 if (it->func) it->func((void *)(it->base.data), WIDGET(it), it);
607 _resize_job(void *data)
609 Evas_Object *obj = (Evas_Object *)data;
610 Widget_Data *wd = elm_widget_data_get(obj);
611 Evas_Coord mw, mh, vw = 0, vh = 0, w = 0, h = 0;
612 Elm_Toolbar_Item *it;
615 wd->resize_job = NULL;
616 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
617 evas_object_size_hint_min_get(wd->bx, &mw, &mh);
618 evas_object_geometry_get(wd->bx, NULL, NULL, &w, &h);
619 if (wd->shrink_mode == ELM_TOOLBAR_SHRINK_MENU)
621 Evas_Coord iw = 0, ih = 0, more_w = 0, more_h = 0;
625 evas_object_resize(wd->bx, w, vh);
626 _fix_items_visibility(wd, &ih, vh);
630 evas_object_resize(wd->bx, vw, h);
631 _fix_items_visibility(wd, &iw, vw);
633 evas_object_geometry_get(wd->VIEW(more_item), NULL, NULL,
637 if ((ih - more_h) <= vh) ih -= more_h;
641 if ((iw - more_w) <= vw) iw -= more_w;
644 /* All items are removed from the box object, since removing individual
645 * items won't trigger a resize. Items are be readded below. */
646 evas_object_box_remove_all(wd->bx, EINA_FALSE);
647 if (((wd->vertical) && (ih > vh)) ||
648 ((!wd->vertical) && (iw > vw)))
652 _item_menu_destroy(wd->more_item);
653 _item_menu_create(wd, wd->more_item);
654 menu = elm_toolbar_item_menu_get((Elm_Object_Item *)wd->more_item);
655 EINA_INLIST_FOREACH(wd->items, it)
657 if (!it->prio.visible)
660 elm_menu_item_separator_add(menu, NULL);
663 Elm_Object_Item *menu_it;
664 menu_it = elm_menu_item_add
665 (menu, NULL, it->icon_str, it->label,
666 _elm_toolbar_item_menu_cb, it);
667 elm_object_item_disabled_set
668 (menu_it, elm_widget_item_disabled_get(it));
670 elm_menu_clone(it->o_menu, menu, menu_it);
672 evas_object_hide(VIEW(it));
676 evas_object_box_append(wd->bx, VIEW(it));
677 evas_object_show(VIEW(it));
680 evas_object_box_append(wd->bx, wd->VIEW(more_item));
681 evas_object_show(wd->VIEW(more_item));
685 /* All items are visible, show them all (except for the "More"
686 * button, of course). */
687 EINA_INLIST_FOREACH(wd->items, it)
689 evas_object_show(VIEW(it));
690 evas_object_box_append(wd->bx, VIEW(it));
692 evas_object_hide(wd->VIEW(more_item));
695 else if (wd->shrink_mode == ELM_TOOLBAR_SHRINK_HIDE)
697 Evas_Coord iw = 0, ih = 0;
701 evas_object_resize(wd->bx, w, vh);
702 _fix_items_visibility(wd, &ih, vh);
706 evas_object_resize(wd->bx, vw, h);
707 _fix_items_visibility(wd, &iw, vw);
709 evas_object_box_remove_all(wd->bx, EINA_FALSE);
710 if (((wd->vertical) && (ih > vh)) ||
711 ((!wd->vertical) && (iw > vw)))
713 EINA_INLIST_FOREACH(wd->items, it)
715 if (!it->prio.visible)
716 evas_object_hide(VIEW(it));
719 evas_object_box_append(wd->bx, VIEW(it));
720 evas_object_show(VIEW(it));
726 /* All items are visible, show them all */
727 EINA_INLIST_FOREACH(wd->items, it)
729 evas_object_show(VIEW(it));
730 evas_object_box_append(wd->bx, VIEW(it));
734 else if (wd->shrink_mode == ELM_TOOLBAR_SHRINK_EXPAND)
736 if ((vw >= mw) && (vh >= mh))
737 evas_object_resize(wd->bx, vw, vh);
739 evas_object_resize(wd->bx, mw, vh);
741 evas_object_resize(wd->bx, vw, mh);
747 if ((vh >= mh) && (h != vh)) evas_object_resize(wd->bx, w, vh);
751 if ((vw >= mw) && (w != vw)) evas_object_resize(wd->bx, vw, h);
753 EINA_INLIST_FOREACH(wd->items, it)
763 _mirrored_set(obj, elm_widget_mirrored_get(obj));
767 _resize_item(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
770 _resize(data, NULL, NULL, NULL);
774 _resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
776 Widget_Data *wd = elm_widget_data_get(data);
778 wd->resize_job = ecore_job_add(_resize_job, data);
782 _select_filter(Elm_Toolbar_Item *it, Evas_Object *obj __UNUSED__, const char *emission, const char *source __UNUSED__)
785 char buf[sizeof("elm,action,click,") + 1];
787 button = atoi(emission + sizeof("mouse,clicked,") - 1);
788 if (button == 1) return; /* regular left click event */
789 snprintf(buf, sizeof(buf), "elm,action,click,%d", button);
790 edje_object_signal_emit(VIEW(it), buf, "elm");
794 _select(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
796 Elm_Toolbar_Item *it = data;
798 if ((_elm_config->access_mode == ELM_ACCESS_MODE_OFF) ||
799 (_elm_access_2nd_click_timeout(VIEW(it))))
801 if (_elm_config->access_mode != ELM_ACCESS_MODE_OFF)
802 _elm_access_say(E_("Selected"));
808 _long_press(Elm_Toolbar_Item *it)
810 Widget_Data *wd = elm_widget_data_get(WIDGET(it));
811 wd->long_timer = NULL;
812 wd->long_press = EINA_TRUE;
813 evas_object_smart_callback_call(WIDGET(it), SIG_LONGPRESSED, it);
814 return ECORE_CALLBACK_CANCEL;
818 _mouse_down(Elm_Toolbar_Item *it, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, Evas_Event_Mouse_Down *ev)
820 Widget_Data *wd = elm_widget_data_get(WIDGET(it));
822 if (ev->button != 1) return;
823 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
824 evas_object_smart_callback_call(WIDGET(it), SIG_CLICKED_DOUBLE, it);
825 wd->long_press = EINA_FALSE;
826 if (wd->long_timer) ecore_timer_interval_set(wd->long_timer, _elm_config->longpress_timeout);
827 else wd->long_timer = ecore_timer_add(_elm_config->longpress_timeout, (Ecore_Task_Cb)_long_press, it);
831 _mouse_up(Elm_Toolbar_Item *it, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, Evas_Event_Mouse_Up *ev)
833 Widget_Data *wd = elm_widget_data_get(WIDGET(it));
835 if (ev->button != 1) return;
838 ecore_timer_del(wd->long_timer);
839 wd->long_timer = NULL;
844 _mouse_in(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
846 Elm_Toolbar_Item *it = data;
847 edje_object_signal_emit(VIEW(it), "elm,state,highlighted", "elm");
848 elm_widget_signal_emit(it->icon, "elm,state,highlighted", "elm");
852 _mouse_out(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
854 Elm_Toolbar_Item *it = data;
855 edje_object_signal_emit(VIEW(it), "elm,state,unhighlighted", "elm");
856 elm_widget_signal_emit(it->icon, "elm,state,unhighlighted", "elm");
860 _layout(Evas_Object *o, Evas_Object_Box_Data *priv, void *data)
862 Evas_Object *obj = (Evas_Object *) data;
863 Widget_Data *wd = elm_widget_data_get(obj);
865 _els_box_layout(o, priv, !wd->vertical, wd->homogeneous,
866 elm_widget_mirrored_get(obj));
870 _access_info_cb(void *data __UNUSED__, Evas_Object *obj __UNUSED__, Elm_Widget_Item *item)
872 Elm_Toolbar_Item *it = (Elm_Toolbar_Item *)item;
873 const char *txt = item->access_info;
874 if (!txt) txt = it->label;
875 if (txt) return strdup(txt);
880 _access_state_cb(void *data __UNUSED__, Evas_Object *obj __UNUSED__, Elm_Widget_Item *item __UNUSED__)
882 Elm_Toolbar_Item *it = (Elm_Toolbar_Item *)item;
884 return strdup(E_("Separator"));
885 else if (elm_widget_item_disabled_get(it))
886 return strdup(E_("State: Disabled"));
887 else if (it->selected)
888 return strdup(E_("State: Selected"));
890 return strdup(E_("Has menu"));
895 _item_del_pre_hook(Elm_Object_Item *it)
899 Elm_Toolbar_Item *item, *next;
900 item = (Elm_Toolbar_Item *)it;
902 wd = elm_widget_data_get(WIDGET(item));
903 if (!wd) return EINA_FALSE;
906 next = ELM_TOOLBAR_ITEM_FROM_INLIST(EINA_INLIST_GET(item)->next);
907 wd->items = eina_inlist_remove(wd->items, EINA_INLIST_GET(item));
909 if (!next) next = ELM_TOOLBAR_ITEM_FROM_INLIST(wd->items);
910 if ((wd->select_mode == ELM_OBJECT_SELECT_MODE_ALWAYS) &&
911 item->selected && next) _item_select(next);
918 static Elm_Toolbar_Item *
919 _item_new(Evas_Object *obj, const char *icon, const char *label, Evas_Smart_Cb func, const void *data)
921 Widget_Data *wd = elm_widget_data_get(obj);
922 Evas_Object *icon_obj;
924 Elm_Toolbar_Item *it;
926 icon_obj = elm_icon_add(obj);
927 elm_icon_order_lookup_set(icon_obj, wd->lookup_order);
928 if (!icon_obj) return NULL;
929 it = elm_widget_item_new(obj, Elm_Toolbar_Item);
932 evas_object_del(icon_obj);
936 elm_widget_item_del_pre_hook_set(it, _item_del_pre_hook);
937 elm_widget_item_disable_hook_set(it, _item_disable_hook);
938 elm_widget_item_text_set_hook_set(it, _item_text_set_hook);
939 elm_widget_item_text_get_hook_set(it, _item_text_get_hook);
940 elm_widget_item_content_set_hook_set(it, _item_content_set_hook);
941 elm_widget_item_content_get_hook_set(it, _item_content_get_hook);
942 elm_widget_item_content_unset_hook_set(it, _item_content_unset_hook);
944 it->label = eina_stringshare_add(label);
945 it->prio.visible = 1;
946 it->prio.priority = 0;
948 it->separator = EINA_FALSE;
950 it->base.data = data;
951 VIEW(it) = edje_object_add(evas_object_evas_get(obj));
952 _elm_access_item_register(&it->base, VIEW(it));
953 _elm_access_text_set(_elm_access_item_get(&it->base),
954 ELM_ACCESS_TYPE, E_("Tool Item"));
955 _elm_access_callback_set(_elm_access_item_get(&it->base),
956 ELM_ACCESS_INFO, _access_info_cb, it);
957 _elm_access_callback_set(_elm_access_item_get(&it->base),
958 ELM_ACCESS_STATE, _access_state_cb, it);
960 if (_item_icon_set(icon_obj, "toolbar/", icon))
963 it->icon_str = eina_stringshare_add(icon);
969 evas_object_del(icon_obj);
972 _elm_theme_object_set(obj, VIEW(it), "toolbar", "item",
973 elm_widget_style_get(obj));
974 edje_object_signal_callback_add(VIEW(it), "elm,action,click", "elm",
976 edje_object_signal_callback_add(VIEW(it), "mouse,clicked,*", "*",
977 (Edje_Signal_Cb)_select_filter, it);
978 edje_object_signal_callback_add(VIEW(it), "elm,mouse,in", "elm",
980 edje_object_signal_callback_add(VIEW(it), "elm,mouse,out", "elm",
982 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MOUSE_DOWN,
983 (Evas_Object_Event_Cb)_mouse_down, it);
984 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MOUSE_UP,
985 (Evas_Object_Event_Cb)_mouse_up, it);
986 elm_widget_sub_object_add(obj, VIEW(it));
991 ms = ((double)wd->icon_size * _elm_config->scale);
992 evas_object_size_hint_min_set(it->icon, ms, ms);
993 evas_object_size_hint_max_set(it->icon, ms, ms);
994 edje_object_part_swallow(VIEW(it), "elm.swallow.icon", it->icon);
995 evas_object_show(it->icon);
996 elm_widget_sub_object_add(obj, it->icon);
998 edje_object_part_text_set(VIEW(it), "elm.text", it->label);
1000 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1001 edje_object_size_min_restricted_calc(VIEW(it), &mw, &mh, mw, mh);
1002 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1003 if (wd->shrink_mode != ELM_TOOLBAR_SHRINK_EXPAND)
1007 evas_object_size_hint_weight_set(VIEW(it), EVAS_HINT_EXPAND, -1.0);
1008 evas_object_size_hint_align_set(VIEW(it), EVAS_HINT_FILL, 0.5);
1012 evas_object_size_hint_weight_set(VIEW(it), -1.0, EVAS_HINT_EXPAND);
1013 evas_object_size_hint_align_set(VIEW(it), 0.5, EVAS_HINT_FILL);
1018 evas_object_size_hint_weight_set(VIEW(it), EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1019 evas_object_size_hint_align_set(VIEW(it), EVAS_HINT_FILL, EVAS_HINT_FILL);
1021 evas_object_size_hint_min_set(VIEW(it), mw, mh);
1022 evas_object_size_hint_max_set(VIEW(it), -1, -1);
1023 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_RESIZE,
1025 if ((!wd->items) && (wd->select_mode == ELM_OBJECT_SELECT_MODE_ALWAYS))
1032 _elm_toolbar_item_label_update(Elm_Toolbar_Item *item)
1034 Evas_Coord mw = -1, mh = -1;
1035 Widget_Data *wd = elm_widget_data_get(WIDGET(item));
1036 edje_object_part_text_set(VIEW(item), "elm.text", item->label);
1038 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1039 edje_object_size_min_restricted_calc(VIEW(item), &mw, &mh, mw, mh);
1040 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1041 if (wd->shrink_mode != ELM_TOOLBAR_SHRINK_EXPAND)
1045 evas_object_size_hint_weight_set(VIEW(item), EVAS_HINT_EXPAND, -1.0);
1046 evas_object_size_hint_align_set(VIEW(item), EVAS_HINT_FILL, 0.5);
1050 evas_object_size_hint_weight_set(VIEW(item), -1.0, EVAS_HINT_EXPAND);
1051 evas_object_size_hint_align_set(VIEW(item), 0.5, EVAS_HINT_FILL);
1056 evas_object_size_hint_weight_set(VIEW(item), EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1057 evas_object_size_hint_align_set(VIEW(item), EVAS_HINT_FILL, EVAS_HINT_FILL);
1059 evas_object_size_hint_min_set(VIEW(item), mw, mh);
1063 _elm_toolbar_item_label_set_cb (void *data, Evas_Object *obj, const char *emission, const char *source)
1065 Elm_Toolbar_Item *item = data;
1066 _elm_toolbar_item_label_update(item);
1067 edje_object_signal_callback_del(obj, emission, source,
1068 _elm_toolbar_item_label_set_cb);
1069 edje_object_signal_emit (VIEW(item), "elm,state,label,reset", "elm");
1073 _item_label_set(Elm_Toolbar_Item *item, const char *label, const char *sig)
1077 if ((label) && (item->label) && (!strcmp(label, item->label))) return;
1079 eina_stringshare_replace(&item->label, label);
1080 s = edje_object_data_get(VIEW(item), "transition_animation_on");
1081 if ((s) && (atoi(s)))
1083 edje_object_part_text_set(VIEW(item), "elm.text_new", item->label);
1084 edje_object_signal_emit (VIEW(item), sig, "elm");
1085 edje_object_signal_callback_add(VIEW(item),
1086 "elm,state,label_set,done", "elm",
1087 _elm_toolbar_item_label_set_cb, item);
1090 _elm_toolbar_item_label_update(item);
1091 _resize(WIDGET(item), NULL, NULL, NULL);
1095 _elm_toolbar_item_icon_update(Elm_Toolbar_Item *item)
1097 Elm_Toolbar_Item_State *it_state;
1099 Evas_Coord mw = -1, mh = -1;
1100 Widget_Data *wd = elm_widget_data_get(WIDGET(item));
1101 Evas_Object *old_icon = edje_object_part_swallow_get(VIEW(item),
1102 "elm.swallow.icon");
1103 elm_widget_sub_object_del(VIEW(item), old_icon);
1104 evas_object_hide(old_icon);
1105 edje_object_part_swallow(VIEW(item), "elm.swallow.icon", item->icon);
1106 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1107 edje_object_size_min_restricted_calc(VIEW(item), &mw, &mh, mw, mh);
1108 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1109 if (wd->shrink_mode != ELM_TOOLBAR_SHRINK_EXPAND)
1113 evas_object_size_hint_weight_set(VIEW(item), EVAS_HINT_EXPAND, -1.0);
1114 evas_object_size_hint_align_set(VIEW(item), EVAS_HINT_FILL, 0.5);
1118 evas_object_size_hint_weight_set(VIEW(item), -1.0, EVAS_HINT_EXPAND);
1119 evas_object_size_hint_align_set(VIEW(item), 0.5, EVAS_HINT_FILL);
1124 evas_object_size_hint_weight_set(VIEW(item), EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1125 evas_object_size_hint_align_set(VIEW(item), EVAS_HINT_FILL, EVAS_HINT_FILL);
1127 evas_object_size_hint_min_set(VIEW(item), mw, mh);
1129 EINA_LIST_FOREACH(item->states, l, it_state)
1131 if (it_state->icon == old_icon) return;
1133 evas_object_del(old_icon);
1137 _elm_toolbar_item_icon_set_cb (void *data, Evas_Object *obj, const char *emission, const char *source)
1139 Elm_Toolbar_Item *item = data;
1140 edje_object_part_unswallow(VIEW(item), item->icon);
1141 _elm_toolbar_item_icon_update(item);
1142 edje_object_signal_callback_del(obj, emission, source,
1143 _elm_toolbar_item_icon_set_cb);
1144 edje_object_signal_emit (VIEW(item), "elm,state,icon,reset", "elm");
1148 _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)
1150 Evas_Object *old_icon;
1155 eina_stringshare_replace(&item->icon_str, icon_str);
1158 eina_stringshare_del(item->icon_str);
1159 item->icon_str = NULL;
1161 item->icon = icon_obj;
1164 ms = (icon_size * _elm_config->scale);
1165 evas_object_size_hint_min_set(item->icon, ms, ms);
1166 evas_object_size_hint_max_set(item->icon, ms, ms);
1167 evas_object_show(item->icon);
1168 elm_widget_sub_object_add(obj, item->icon);
1170 s = edje_object_data_get(VIEW(item), "transition_animation_on");
1171 if ((s) && (atoi(s)))
1173 old_icon = edje_object_part_swallow_get(VIEW(item),
1174 "elm.swallow.icon_new");
1177 elm_widget_sub_object_del(VIEW(item), old_icon);
1178 evas_object_hide(old_icon);
1180 edje_object_part_swallow(VIEW(item), "elm.swallow.icon_new",
1182 edje_object_signal_emit (VIEW(item), sig, "elm");
1183 edje_object_signal_callback_add(VIEW(item),
1184 "elm,state,icon_set,done", "elm",
1185 _elm_toolbar_item_icon_set_cb, item);
1188 _elm_toolbar_item_icon_update(item);
1189 _resize(obj, NULL, NULL, NULL);
1193 _elm_toolbar_item_state_cb(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1195 Elm_Toolbar_Item *it = event_info;
1196 Elm_Toolbar_Item_State *it_state;
1198 it_state = eina_list_data_get(it->current_state);
1200 it_state->func((void *)it_state->data, obj, event_info);
1203 static Elm_Toolbar_Item_State *
1204 _item_state_new(const char *label, const char *icon_str, Evas_Object *icon, Evas_Smart_Cb func, const void *data)
1206 Elm_Toolbar_Item_State *it_state;
1207 it_state = ELM_NEW(Elm_Toolbar_Item_State);
1208 it_state->label = eina_stringshare_add(label);
1209 it_state->icon_str = eina_stringshare_add(icon_str);
1210 it_state->icon = icon;
1211 it_state->func = func;
1212 it_state->data = data;
1217 elm_toolbar_add(Evas_Object *parent)
1223 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
1225 ELM_SET_WIDTYPE(widtype, "toolbar");
1226 elm_widget_type_set(obj, "toolbar");
1227 elm_widget_sub_object_add(parent, obj);
1228 elm_widget_data_set(obj, wd);
1229 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
1230 elm_widget_del_hook_set(obj, _del_hook);
1231 elm_widget_theme_hook_set(obj, _theme_hook);
1232 elm_widget_translate_hook_set(obj, _translate_hook);
1233 elm_widget_can_focus_set(obj, EINA_FALSE);
1235 wd->more_item = NULL;
1236 wd->selected_item = NULL;
1237 wd->scr = elm_smart_scroller_add(e);
1238 elm_smart_scroller_widget_set(wd->scr, obj);
1239 elm_smart_scroller_object_theme_set(obj, wd->scr, "toolbar", "base", "default");
1240 elm_smart_scroller_bounce_allow_set(wd->scr,
1241 _elm_config->thumbscroll_bounce_enable,
1243 elm_widget_resize_object_set(obj, wd->scr);
1244 elm_smart_scroller_policy_set(wd->scr,
1245 ELM_SMART_SCROLLER_POLICY_AUTO,
1246 ELM_SMART_SCROLLER_POLICY_OFF);
1249 wd->icon_size = _elm_toolbar_icon_size_get(wd);
1252 wd->homogeneous = EINA_TRUE;
1255 wd->bx = evas_object_box_add(e);
1256 evas_object_size_hint_align_set(wd->bx, wd->align, 0.5);
1257 evas_object_box_layout_set(wd->bx, _layout, obj, NULL);
1258 elm_widget_sub_object_add(obj, wd->bx);
1259 elm_smart_scroller_child_set(wd->scr, wd->bx);
1260 evas_object_show(wd->bx);
1262 elm_toolbar_shrink_mode_set(obj, _elm_config->toolbar_shrink_mode);
1263 evas_object_event_callback_add(wd->scr, EVAS_CALLBACK_RESIZE, _resize, obj);
1264 evas_object_event_callback_add(wd->bx, EVAS_CALLBACK_RESIZE, _resize, obj);
1265 elm_toolbar_icon_order_lookup_set(obj, ELM_ICON_LOOKUP_THEME_FDO);
1267 evas_object_smart_callbacks_descriptions_set(obj, _signals);
1274 elm_toolbar_icon_size_set(Evas_Object *obj, int icon_size)
1276 ELM_CHECK_WIDTYPE(obj, widtype);
1277 Widget_Data *wd = elm_widget_data_get(obj);
1279 if (wd->icon_size == icon_size) return;
1280 wd->icon_size = icon_size;
1285 elm_toolbar_icon_size_get(const Evas_Object *obj)
1287 ELM_CHECK_WIDTYPE(obj, widtype) 0;
1288 Widget_Data *wd = elm_widget_data_get(obj);
1290 return wd->icon_size;
1293 EAPI Elm_Object_Item *
1294 elm_toolbar_item_append(Evas_Object *obj, const char *icon, const char *label, Evas_Smart_Cb func, const void *data)
1296 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1297 Widget_Data *wd = elm_widget_data_get(obj);
1298 if (!wd) return NULL;
1300 Elm_Toolbar_Item *it = _item_new(obj, icon, label, func, data);
1301 if (!it) return NULL;
1302 double scale = (elm_widget_scale_get(obj) * _elm_config->scale);
1304 wd->items = eina_inlist_append(wd->items, EINA_INLIST_GET(it));
1305 evas_object_box_append(wd->bx, VIEW(it));
1306 evas_object_show(VIEW(it));
1308 _theme_hook_item(obj, it, scale, wd->icon_size);
1311 return (Elm_Object_Item *)it;
1314 EAPI Elm_Object_Item *
1315 elm_toolbar_item_prepend(Evas_Object *obj, const char *icon, const char *label, Evas_Smart_Cb func, const void *data)
1317 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1318 Widget_Data *wd = elm_widget_data_get(obj);
1319 if (!wd) return NULL;
1321 Elm_Toolbar_Item *it = _item_new(obj, icon, label, func, data);
1322 if (!it) return NULL;
1323 double scale = (elm_widget_scale_get(obj) * _elm_config->scale);
1325 wd->items = eina_inlist_prepend(wd->items, EINA_INLIST_GET(it));
1326 evas_object_box_prepend(wd->bx, VIEW(it));
1327 evas_object_show(VIEW(it));
1328 _theme_hook_item(obj, it, scale, wd->icon_size);
1331 return (Elm_Object_Item *)it;
1334 EAPI Elm_Object_Item *
1335 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)
1337 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1338 ELM_OBJ_ITEM_CHECK_OR_RETURN(before, NULL);
1340 Elm_Toolbar_Item *it, *_before;
1342 wd = elm_widget_data_get(obj);
1343 if (!wd) return NULL;
1344 _before = (Elm_Toolbar_Item *) before;
1345 it = _item_new(obj, icon, label, func, data);
1346 if (!it) return NULL;
1347 double scale = (elm_widget_scale_get(obj) * _elm_config->scale);
1349 wd->items = eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
1350 EINA_INLIST_GET(_before));
1351 evas_object_box_insert_before(wd->bx, VIEW(it), VIEW(_before));
1352 evas_object_show(VIEW(it));
1353 _theme_hook_item(obj, it, scale, wd->icon_size);
1356 return (Elm_Object_Item *)it;
1359 EAPI Elm_Object_Item *
1360 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)
1362 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1363 ELM_OBJ_ITEM_CHECK_OR_RETURN(after, NULL);
1365 Elm_Toolbar_Item *it, *_after;
1367 wd = elm_widget_data_get(obj);
1368 if (!wd) return NULL;
1369 _after = (Elm_Toolbar_Item *) after;
1370 it = _item_new(obj, icon, label, func, data);
1371 if (!it) return NULL;
1372 double scale = (elm_widget_scale_get(obj) * _elm_config->scale);
1374 wd->items = eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
1375 EINA_INLIST_GET(_after));
1376 evas_object_box_insert_after(wd->bx, VIEW(it), VIEW(_after));
1377 evas_object_show(VIEW(it));
1378 _theme_hook_item(obj, it, scale, wd->icon_size);
1381 return (Elm_Object_Item *)it;
1384 EAPI Elm_Object_Item *
1385 elm_toolbar_first_item_get(const Evas_Object *obj)
1387 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1388 Widget_Data *wd = elm_widget_data_get(obj);
1389 if (!wd || !wd->items) return NULL;
1390 return (Elm_Object_Item *) ELM_TOOLBAR_ITEM_FROM_INLIST(wd->items);
1393 EAPI Elm_Object_Item *
1394 elm_toolbar_last_item_get(const Evas_Object *obj)
1396 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1397 Widget_Data *wd = elm_widget_data_get(obj);
1398 if (!wd || !wd->items) return NULL;
1399 return (Elm_Object_Item *) ELM_TOOLBAR_ITEM_FROM_INLIST(wd->items->last);
1402 EAPI Elm_Object_Item *
1403 elm_toolbar_item_next_get(const Elm_Object_Item *it)
1405 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
1406 return (Elm_Object_Item *) ELM_TOOLBAR_ITEM_FROM_INLIST(
1407 EINA_INLIST_GET(((Elm_Toolbar_Item *)it))->next);
1410 EAPI Elm_Object_Item *
1411 elm_toolbar_item_prev_get(const Elm_Object_Item *it)
1413 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
1414 return (Elm_Object_Item *) ELM_TOOLBAR_ITEM_FROM_INLIST(
1415 EINA_INLIST_GET(((Elm_Toolbar_Item *)it))->prev);
1419 elm_toolbar_item_toolbar_get(const Elm_Object_Item *it)
1421 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
1422 return elm_object_item_widget_get(it);
1426 elm_toolbar_item_priority_set(Elm_Object_Item *it, int priority)
1428 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
1429 Elm_Toolbar_Item *item = (Elm_Toolbar_Item *)it;
1430 if (item->prio.priority == priority) return;
1431 item->prio.priority = priority;
1432 _resize(WIDGET(item), NULL, NULL, NULL);
1436 elm_toolbar_item_priority_get(const Elm_Object_Item *it)
1438 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, 0);
1439 return ((Elm_Toolbar_Item *)it)->prio.priority;
1443 elm_toolbar_item_label_get(const Elm_Object_Item *it)
1445 return _item_text_get_hook(it, NULL);
1449 elm_toolbar_item_label_set(Elm_Object_Item *it, const char *label)
1451 _item_text_set_hook(it, NULL, label);
1455 elm_toolbar_item_data_get(const Elm_Object_Item *it)
1457 return elm_object_item_data_get(it);
1461 elm_toolbar_item_data_set(Elm_Object_Item *it, const void *data)
1463 elm_object_item_data_set(it, (void *) data);
1466 EAPI Elm_Object_Item *
1467 elm_toolbar_item_find_by_label(const Evas_Object *obj, const char *label)
1469 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1470 Elm_Toolbar_Item *it;
1471 Widget_Data *wd = elm_widget_data_get(obj);
1472 if (!wd) return NULL;
1474 EINA_INLIST_FOREACH(wd->items, it)
1476 if (!strcmp(it->label, label))
1477 return (Elm_Object_Item *)it;
1483 elm_toolbar_item_selected_set(Elm_Object_Item *it, Eina_Bool selected)
1485 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
1486 Elm_Toolbar_Item *item = (Elm_Toolbar_Item *)it;
1487 Widget_Data *wd = elm_widget_data_get(WIDGET(item));
1490 if (item->selected == selected) return;
1491 if (selected) _item_select(item);
1492 else _item_unselect(item);
1496 elm_toolbar_item_selected_get(const Elm_Object_Item *it)
1498 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
1499 return ((Elm_Toolbar_Item *)it)->selected;
1502 EAPI Elm_Object_Item *
1503 elm_toolbar_selected_item_get(const Evas_Object *obj)
1505 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1506 Widget_Data *wd = elm_widget_data_get(obj);
1507 if (!wd) return NULL;
1508 return (Elm_Object_Item *) wd->selected_item;
1512 elm_toolbar_item_icon_set(Elm_Object_Item *it, const char *icon)
1514 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
1516 Evas_Object *icon_obj;
1519 Elm_Toolbar_Item * item = (Elm_Toolbar_Item *)it;
1522 wd = elm_widget_data_get(obj);
1524 if ((icon) && (item->icon_str) && (!strcmp(icon, item->icon_str))) return;
1526 icon_obj = elm_icon_add(obj);
1527 if (!icon_obj) return;
1528 if (_item_icon_set(icon_obj, "toolbar/", icon))
1529 _elm_toolbar_item_icon_obj_set(obj, item, icon_obj, icon, wd->icon_size,
1530 "elm,state,icon_set");
1533 _elm_toolbar_item_icon_obj_set(obj, item, NULL, NULL, 0,
1534 "elm,state,icon_set");
1535 evas_object_del(icon_obj);
1540 elm_toolbar_item_icon_get(const Elm_Object_Item *it)
1542 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
1543 return ((Elm_Toolbar_Item *)it)->icon_str;
1547 elm_toolbar_item_object_get(const Elm_Object_Item *it)
1549 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
1553 Elm_Toolbar_Item *item = (Elm_Toolbar_Item *)it;
1556 wd = elm_widget_data_get(obj);
1557 if (!wd) return NULL;
1563 elm_toolbar_item_icon_object_get(Elm_Object_Item *it)
1565 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
1566 return ((Elm_Toolbar_Item *)it)->icon;
1570 elm_toolbar_item_icon_memfile_set(Elm_Object_Item *it, const void *img, size_t size, const char *format, const char *key)
1572 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
1574 Evas_Object *icon_obj;
1578 Elm_Toolbar_Item *item = (Elm_Toolbar_Item *)it;
1581 wd = elm_widget_data_get(obj);
1582 if (!wd) return EINA_FALSE;
1586 icon_obj = _els_smart_icon_add(evas_object_evas_get(obj));
1587 evas_object_repeat_events_set(icon_obj, EINA_TRUE);
1588 ret = _els_smart_icon_memfile_set(icon_obj, img, size, format, key);
1591 evas_object_del(icon_obj);
1594 _elm_toolbar_item_icon_obj_set(obj, item, icon_obj, NULL, wd->icon_size,
1595 "elm,state,icon_set");
1598 _elm_toolbar_item_icon_obj_set(obj, item, NULL, NULL, 0, "elm,state,icon_set");
1603 elm_toolbar_item_icon_file_set(Elm_Object_Item *it, const char *file, const char *key)
1605 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
1607 Evas_Object *icon_obj;
1611 Elm_Toolbar_Item *item = (Elm_Toolbar_Item *)it;
1614 wd = elm_widget_data_get(obj);
1615 if (!wd) return EINA_FALSE;
1619 icon_obj = _els_smart_icon_add(evas_object_evas_get(obj));
1620 evas_object_repeat_events_set(icon_obj, EINA_TRUE);
1621 ret = _els_smart_icon_file_key_set(icon_obj, file, key);
1624 evas_object_del(icon_obj);
1627 _elm_toolbar_item_icon_obj_set(obj, item, icon_obj, NULL, wd->icon_size,
1628 "elm,state,icon_set");
1631 _elm_toolbar_item_icon_obj_set(obj, item, NULL, NULL, 0, "elm,state,icon_set");
1636 elm_toolbar_item_del(Elm_Object_Item *it)
1638 elm_object_item_del(it);
1642 elm_toolbar_item_del_cb_set(Elm_Object_Item *it, Evas_Smart_Cb func)
1644 elm_object_item_del_cb_set(it, func);
1648 elm_toolbar_item_disabled_get(const Elm_Object_Item *it)
1650 return elm_object_item_disabled_get(it);
1654 elm_toolbar_item_disabled_set(Elm_Object_Item *it, Eina_Bool disabled)
1656 elm_object_item_disabled_set(it, disabled);
1660 elm_toolbar_item_separator_set(Elm_Object_Item *it, Eina_Bool separator)
1662 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
1663 Elm_Toolbar_Item *item = (Elm_Toolbar_Item *)it;
1664 Evas_Object *obj = WIDGET(item);
1665 Widget_Data *wd = elm_widget_data_get(obj);
1667 if (item->separator == separator) return;
1668 item->separator = separator;
1669 scale = (elm_widget_scale_get(obj) * _elm_config->scale);
1670 _theme_hook_item(obj, item, scale, wd->icon_size);
1674 elm_toolbar_item_separator_get(const Elm_Object_Item *it)
1676 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
1677 return ((Elm_Toolbar_Item *)it)->separator;
1681 elm_toolbar_shrink_mode_set(Evas_Object *obj, Elm_Toolbar_Shrink_Mode shrink_mode)
1683 ELM_CHECK_WIDTYPE(obj, widtype);
1684 Widget_Data *wd = elm_widget_data_get(obj);
1688 wd->shrink_mode = shrink_mode;
1689 bounce = (_elm_config->thumbscroll_bounce_enable) &&
1690 (shrink_mode == ELM_TOOLBAR_SHRINK_SCROLL);
1691 elm_smart_scroller_bounce_allow_set(wd->scr, bounce, EINA_FALSE);
1695 _item_del(wd->more_item);
1696 elm_widget_item_free(wd->more_item);
1697 wd->more_item = NULL;
1700 if (shrink_mode == ELM_TOOLBAR_SHRINK_MENU)
1702 elm_smart_scroller_policy_set(wd->scr, ELM_SMART_SCROLLER_POLICY_OFF,
1703 ELM_SMART_SCROLLER_POLICY_OFF);
1704 wd->more_item = _item_new(obj, "more_menu", "More", NULL, NULL);
1706 else if (shrink_mode == ELM_TOOLBAR_SHRINK_HIDE)
1707 elm_smart_scroller_policy_set(wd->scr, ELM_SMART_SCROLLER_POLICY_OFF,
1708 ELM_SMART_SCROLLER_POLICY_OFF);
1710 elm_smart_scroller_policy_set(wd->scr, ELM_SMART_SCROLLER_POLICY_AUTO,
1711 ELM_SMART_SCROLLER_POLICY_OFF);
1715 EAPI Elm_Toolbar_Shrink_Mode
1716 elm_toolbar_shrink_mode_get(const Evas_Object *obj)
1718 ELM_CHECK_WIDTYPE(obj, widtype) ELM_TOOLBAR_SHRINK_NONE;
1719 Widget_Data *wd = elm_widget_data_get(obj);
1721 if (!wd) return ELM_TOOLBAR_SHRINK_NONE;
1722 return wd->shrink_mode;
1726 elm_toolbar_homogeneous_set(Evas_Object *obj, Eina_Bool homogeneous)
1728 ELM_CHECK_WIDTYPE(obj, widtype);
1729 Widget_Data *wd = elm_widget_data_get(obj);
1732 wd->homogeneous = !!homogeneous;
1733 evas_object_smart_calculate(wd->bx);
1737 elm_toolbar_homogeneous_get(const Evas_Object *obj)
1739 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1740 Widget_Data *wd = elm_widget_data_get(obj);
1742 if (!wd) return EINA_FALSE;
1743 return wd->homogeneous;
1747 elm_toolbar_menu_parent_set(Evas_Object *obj, Evas_Object *parent)
1749 Elm_Toolbar_Item *it;
1750 ELM_CHECK_WIDTYPE(obj, widtype);
1751 Widget_Data *wd = elm_widget_data_get(obj);
1754 EINA_SAFETY_ON_NULL_RETURN(parent);
1755 wd->menu_parent = parent;
1756 EINA_INLIST_FOREACH(wd->items, it)
1759 elm_menu_parent_set(it->o_menu, wd->menu_parent);
1761 if ((wd->more_item) && (wd->more_item->o_menu))
1762 elm_menu_parent_set(wd->more_item->o_menu, wd->menu_parent);
1766 elm_toolbar_menu_parent_get(const Evas_Object *obj)
1768 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1769 Widget_Data *wd = elm_widget_data_get(obj);
1771 if (!wd) return NULL;
1772 return wd->menu_parent;
1776 elm_toolbar_align_set(Evas_Object *obj, double align)
1778 ELM_CHECK_WIDTYPE(obj, widtype);
1779 Widget_Data *wd = elm_widget_data_get(obj);
1784 if (wd->align != align)
1785 evas_object_size_hint_align_set(wd->bx, 0.5, align);
1789 if (wd->align != align)
1790 evas_object_size_hint_align_set(wd->bx, align, 0.5);
1796 elm_toolbar_align_get(const Evas_Object *obj)
1798 ELM_CHECK_WIDTYPE(obj, widtype) 0.0;
1799 Widget_Data *wd = elm_widget_data_get(obj);
1801 if (!wd) return 0.0;
1806 elm_toolbar_item_menu_set(Elm_Object_Item *it, Eina_Bool menu)
1808 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
1809 Elm_Toolbar_Item *item = (Elm_Toolbar_Item *)it;
1810 Widget_Data *wd = elm_widget_data_get(WIDGET(item));
1813 if (item->menu == menu) return;
1814 if (menu) _item_menu_create(wd, item);
1815 else _item_menu_destroy(item);
1819 elm_toolbar_item_menu_get(const Elm_Object_Item *it)
1821 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
1822 Elm_Toolbar_Item *item = (Elm_Toolbar_Item *)it;
1823 if (!item->menu) return NULL;
1824 Widget_Data *wd = elm_widget_data_get(WIDGET(item));
1825 if (!wd) return NULL;
1826 return item->o_menu;
1829 EAPI Elm_Toolbar_Item_State *
1830 elm_toolbar_item_state_add(Elm_Object_Item *it, const char *icon, const char *label, Evas_Smart_Cb func, const void *data)
1832 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
1834 Elm_Toolbar_Item_State *it_state;
1835 Evas_Object *icon_obj;
1838 Elm_Toolbar_Item *item = (Elm_Toolbar_Item *)it;
1840 wd = elm_widget_data_get(WIDGET(item));
1841 if (!wd) return NULL;
1845 it_state = _item_state_new(item->label, item->icon_str, item->icon,
1846 item->func, item->base.data);
1847 item->states = eina_list_append(item->states, it_state);
1848 item->current_state = item->states;
1851 icon_obj = elm_icon_add(obj);
1852 elm_icon_order_lookup_set(icon_obj, wd->lookup_order);
1853 if (!icon_obj) goto error_state_add;
1855 if (!_item_icon_set(icon_obj, "toolbar/", icon))
1857 evas_object_del(icon_obj);
1862 it_state = _item_state_new(label, icon, icon_obj, func, data);
1863 item->states = eina_list_append(item->states, it_state);
1864 item->func = _elm_toolbar_item_state_cb;
1865 item->base.data = NULL;
1870 if (item->states && !eina_list_next(item->states))
1872 eina_stringshare_del(item->label);
1873 eina_stringshare_del(item->icon_str);
1874 free(eina_list_data_get(item->states));
1875 eina_list_free(item->states);
1876 item->states = NULL;
1882 elm_toolbar_item_state_del(Elm_Object_Item *it, Elm_Toolbar_Item_State *state)
1884 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
1886 Eina_List *del_state;
1887 Elm_Toolbar_Item_State *it_state;
1888 Elm_Toolbar_Item *item;
1890 if (!state) return EINA_FALSE;
1892 item = (Elm_Toolbar_Item *)it;
1893 if (!item->states) return EINA_FALSE;
1895 del_state = eina_list_data_find_list(item->states, state);
1896 if (del_state == item->states) return EINA_FALSE;
1897 if (del_state == item->current_state)
1898 elm_toolbar_item_state_unset(it);
1900 eina_stringshare_del(state->label);
1901 eina_stringshare_del(state->icon_str);
1902 if (state->icon) evas_object_del(state->icon);
1904 item->states = eina_list_remove_list(item->states, del_state);
1905 if (item->states && !eina_list_next(item->states))
1907 it_state = eina_list_data_get(item->states);
1908 item->base.data = it_state->data;
1909 item->func = it_state->func;
1910 eina_stringshare_del(it_state->label);
1911 eina_stringshare_del(it_state->icon_str);
1912 free(eina_list_data_get(item->states));
1913 eina_list_free(item->states);
1914 item->states = NULL;
1920 elm_toolbar_item_state_set(Elm_Object_Item *it, Elm_Toolbar_Item_State *state)
1922 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
1925 Eina_List *next_state;
1926 Elm_Toolbar_Item_State *it_state;
1928 Elm_Toolbar_Item *item = (Elm_Toolbar_Item *)it;
1931 wd = elm_widget_data_get(obj);
1932 if (!wd) return EINA_FALSE;
1933 if (!item->states) return EINA_FALSE;
1937 next_state = eina_list_data_find_list(item->states, state);
1938 if (!next_state) return EINA_FALSE;
1941 next_state = item->states;
1943 if (next_state == item->current_state) return EINA_TRUE;
1945 it_state = eina_list_data_get(next_state);
1946 if (eina_list_data_find(item->current_state, state))
1948 _item_label_set(item, it_state->label, "elm,state,label_set,forward");
1949 _elm_toolbar_item_icon_obj_set(obj, item, it_state->icon, it_state->icon_str,
1950 wd->icon_size, "elm,state,icon_set,forward");
1954 _item_label_set(item, it_state->label, "elm,state,label_set,backward");
1955 _elm_toolbar_item_icon_obj_set(obj,
1960 "elm,state,icon_set,backward");
1962 if (elm_widget_item_disabled_get(item))
1963 elm_widget_signal_emit(item->icon, "elm,state,disabled", "elm");
1965 elm_widget_signal_emit(item->icon, "elm,state,enabled", "elm");
1967 item->current_state = next_state;
1972 elm_toolbar_item_state_unset(Elm_Object_Item *it)
1974 elm_toolbar_item_state_set(it, NULL);
1977 EAPI Elm_Toolbar_Item_State *
1978 elm_toolbar_item_state_get(const Elm_Object_Item *it)
1980 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
1981 Elm_Toolbar_Item *item = (Elm_Toolbar_Item *)it;
1983 if ((!item->states) || (!item->current_state)) return NULL;
1984 if (item->current_state == item->states) return NULL;
1986 return eina_list_data_get(item->current_state);
1989 EAPI Elm_Toolbar_Item_State *
1990 elm_toolbar_item_state_next(Elm_Object_Item *it)
1992 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
1996 Eina_List *next_state;
1997 Elm_Toolbar_Item *item = (Elm_Toolbar_Item *)it;
2000 wd = elm_widget_data_get(obj);
2001 if (!wd) return NULL;
2002 if (!item->states) return NULL;
2004 next_state = eina_list_next(item->current_state);
2006 next_state = eina_list_next(item->states);
2007 return eina_list_data_get(next_state);
2010 EAPI Elm_Toolbar_Item_State *
2011 elm_toolbar_item_state_prev(Elm_Object_Item *it)
2013 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
2017 Eina_List *prev_state;
2018 Elm_Toolbar_Item *item = (Elm_Toolbar_Item *)it;
2021 wd = elm_widget_data_get(obj);
2022 if (!wd) return NULL;
2023 if (!item->states) return NULL;
2025 prev_state = eina_list_prev(item->current_state);
2026 if ((!prev_state) || (prev_state == item->states))
2027 prev_state = eina_list_last(item->states);
2028 return eina_list_data_get(prev_state);
2032 elm_toolbar_item_tooltip_text_set(Elm_Object_Item *it, const char *text)
2034 elm_object_item_tooltip_text_set(it, text);
2038 elm_toolbar_item_tooltip_content_cb_set(Elm_Object_Item *it, Elm_Tooltip_Item_Content_Cb func, const void *data, Evas_Smart_Cb del_cb)
2040 elm_object_item_tooltip_content_cb_set(it, func, data, del_cb);
2044 elm_toolbar_item_tooltip_unset(Elm_Object_Item *it)
2046 elm_object_item_tooltip_unset(it);
2050 elm_toolbar_item_tooltip_style_set(Elm_Object_Item *it, const char *style)
2052 elm_object_item_tooltip_style_set(it, style);
2056 elm_toolbar_item_tooltip_style_get(const Elm_Object_Item *it)
2058 return elm_object_item_tooltip_style_get(it);
2062 elm_toolbar_item_cursor_set(Elm_Object_Item *it, const char *cursor)
2064 elm_object_item_cursor_set(it, cursor);
2068 elm_toolbar_item_cursor_get(const Elm_Object_Item *it)
2070 return elm_object_item_cursor_get(it);
2074 elm_toolbar_item_cursor_unset(Elm_Object_Item *it)
2076 elm_object_item_cursor_unset(it);
2080 elm_toolbar_item_cursor_style_set(Elm_Object_Item *it, const char *style)
2082 elm_object_item_cursor_style_set(it, style);
2086 elm_toolbar_item_cursor_style_get(const Elm_Object_Item *it)
2088 return elm_object_item_cursor_style_get(it);
2092 elm_toolbar_item_cursor_engine_only_set(Elm_Object_Item *it, Eina_Bool engine_only)
2094 elm_object_item_cursor_engine_only_set(it, engine_only);
2098 elm_toolbar_item_cursor_engine_only_get(const Elm_Object_Item *it)
2100 return elm_object_item_cursor_engine_only_get(it);
2103 EINA_DEPRECATED EAPI void
2104 elm_toolbar_always_select_mode_set(Evas_Object *obj, Eina_Bool always_select)
2106 ELM_CHECK_WIDTYPE(obj, widtype);
2107 Widget_Data *wd = elm_widget_data_get(obj);
2110 elm_toolbar_select_mode_set(obj, ELM_OBJECT_SELECT_MODE_ALWAYS);
2113 Elm_Object_Select_Mode oldmode = elm_toolbar_select_mode_get(obj);
2114 if (oldmode == ELM_OBJECT_SELECT_MODE_ALWAYS)
2115 elm_toolbar_select_mode_set(obj, ELM_OBJECT_SELECT_MODE_DEFAULT);
2119 EINA_DEPRECATED EAPI Eina_Bool
2120 elm_toolbar_always_select_mode_get(const Evas_Object *obj)
2122 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2123 Widget_Data *wd = elm_widget_data_get(obj);
2124 if (!wd) return EINA_FALSE;
2125 Elm_Object_Select_Mode oldmode = elm_toolbar_select_mode_get(obj);
2126 if (oldmode == ELM_OBJECT_SELECT_MODE_ALWAYS)
2132 EINA_DEPRECATED EAPI void
2133 elm_toolbar_no_select_mode_set(Evas_Object *obj, Eina_Bool no_select)
2135 ELM_CHECK_WIDTYPE(obj, widtype);
2136 Widget_Data *wd = elm_widget_data_get(obj);
2139 elm_toolbar_select_mode_set(obj, ELM_OBJECT_SELECT_MODE_NONE);
2142 Elm_Object_Select_Mode oldmode = elm_toolbar_select_mode_get(obj);
2143 if (oldmode == ELM_OBJECT_SELECT_MODE_NONE)
2144 elm_toolbar_select_mode_set(obj, ELM_OBJECT_SELECT_MODE_DEFAULT);
2148 EINA_DEPRECATED EAPI Eina_Bool
2149 elm_toolbar_no_select_mode_get(const Evas_Object *obj)
2151 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2152 Widget_Data *wd = elm_widget_data_get(obj);
2153 if (!wd) return EINA_FALSE;
2154 Elm_Object_Select_Mode oldmode = elm_toolbar_select_mode_get(obj);
2155 if (oldmode == ELM_OBJECT_SELECT_MODE_NONE)
2162 elm_toolbar_icon_order_lookup_set(Evas_Object *obj, Elm_Icon_Lookup_Order order)
2164 ELM_CHECK_WIDTYPE(obj, widtype);
2165 Elm_Toolbar_Item *it;
2166 Widget_Data *wd = elm_widget_data_get(obj);
2169 wd->lookup_order = order;
2170 EINA_INLIST_FOREACH(wd->items, it)
2171 elm_icon_order_lookup_set(it->icon, order);
2173 elm_icon_order_lookup_set(wd->more_item->icon, order);
2176 EAPI Elm_Icon_Lookup_Order
2177 elm_toolbar_icon_order_lookup_get(const Evas_Object *obj)
2179 ELM_CHECK_WIDTYPE(obj, widtype) ELM_ICON_LOOKUP_THEME_FDO;
2180 Widget_Data *wd = elm_widget_data_get(obj);
2181 if (!wd) return ELM_ICON_LOOKUP_THEME_FDO;
2182 return wd->lookup_order;
2185 EINA_DEPRECATED EAPI void
2186 elm_toolbar_orientation_set(Evas_Object *obj, Eina_Bool vertical)
2188 elm_toolbar_horizontal_set(obj, !vertical);
2191 EINA_DEPRECATED EAPI Eina_Bool
2192 elm_toolbar_orientation_get(const Evas_Object *obj)
2194 return !elm_toolbar_horizontal_get(obj);
2198 elm_toolbar_horizontal_set(Evas_Object *obj, Eina_Bool horizontal)
2200 ELM_CHECK_WIDTYPE(obj, widtype);
2201 Widget_Data *wd = elm_widget_data_get(obj);
2203 wd->vertical = !horizontal;
2205 evas_object_size_hint_align_set(wd->bx, 0.5, wd->align);
2207 evas_object_size_hint_align_set(wd->bx, wd->align, 0.5);
2212 elm_toolbar_horizontal_get(const Evas_Object *obj)
2214 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2215 Widget_Data *wd = elm_widget_data_get(obj);
2216 if (!wd) return EINA_FALSE;
2217 return !wd->vertical;
2221 elm_toolbar_items_count(const Evas_Object *obj)
2223 ELM_CHECK_WIDTYPE(obj, widtype) 0;
2224 Widget_Data *wd = elm_widget_data_get(obj);
2226 return wd->item_count;
2229 EINA_DEPRECATED EAPI void
2230 elm_toolbar_mode_shrink_set(Evas_Object *obj, Elm_Toolbar_Shrink_Mode shrink_mode)
2232 elm_toolbar_shrink_mode_set(obj, shrink_mode);
2235 EINA_DEPRECATED EAPI Elm_Toolbar_Shrink_Mode
2236 elm_toolbar_mode_shrink_get(const Evas_Object *obj)
2238 return elm_toolbar_shrink_mode_get(obj);
2242 elm_toolbar_select_mode_set(Evas_Object *obj, Elm_Object_Select_Mode mode)
2244 ELM_CHECK_WIDTYPE(obj, widtype);
2245 Widget_Data *wd = elm_widget_data_get(obj);
2247 if (mode >= ELM_OBJECT_SELECT_MODE_MAX)
2249 if ((mode == ELM_OBJECT_SELECT_MODE_ALWAYS) &&
2250 (wd->select_mode != ELM_OBJECT_SELECT_MODE_ALWAYS) &&
2252 _item_select(ELM_TOOLBAR_ITEM_FROM_INLIST(wd->items));
2253 if (wd->select_mode != mode)
2254 wd->select_mode = mode;
2257 EAPI Elm_Object_Select_Mode
2258 elm_toolbar_select_mode_get(const Evas_Object *obj)
2260 ELM_CHECK_WIDTYPE(obj, widtype) ELM_OBJECT_SELECT_MODE_MAX;
2261 Widget_Data *wd = elm_widget_data_get(obj);
2262 if (!wd) return ELM_OBJECT_SELECT_MODE_MAX;
2263 return wd->select_mode;