1 #include <Elementary.h>
3 #include "els_scroller.h"
7 typedef struct _Widget_Data Widget_Data;
8 typedef struct _Elm_Toolbar_Item Elm_Toolbar_Item;
12 Evas_Object *scr, *bx, *more, *bx_more, *bx_more2;
13 Evas_Object *menu_parent;
15 Elm_Toolbar_Item *more_item, *selected_item;
16 Elm_Toolbar_Shrink_Mode shrink_mode;
17 Elm_Icon_Lookup_Order lookup_order;
19 unsigned int item_count;
20 unsigned int item_max;
22 Elm_Object_Select_Mode select_mode;
23 Eina_Bool homogeneous : 1;
24 Eina_Bool vertical : 1;
25 Eina_Bool long_press : 1;
26 Ecore_Timer *long_timer;
27 Ecore_Job *resize_job;
30 struct _Elm_Toolbar_Item
44 Eina_Bool visible : 1;
46 Eina_Bool selected : 1;
47 Eina_Bool separator : 1;
50 Eina_List *current_state;
53 #define ELM_TOOLBAR_ITEM_FROM_INLIST(item) \
54 ((item) ? EINA_INLIST_CONTAINER_GET(item, Elm_Toolbar_Item) : NULL)
56 struct _Elm_Toolbar_Item_State
65 static const char *widtype = NULL;
66 static void _item_show(Elm_Toolbar_Item *it);
67 static void _item_select(Elm_Toolbar_Item *it);
68 static void _item_unselect(Elm_Toolbar_Item *it);
69 static void _del_pre_hook(Evas_Object *obj);
70 static void _del_hook(Evas_Object *obj);
71 static void _mirrored_set(Evas_Object *obj, Eina_Bool mirrored);
72 static void _mirrored_set_item(Evas_Object *obj, Elm_Toolbar_Item *it, Eina_Bool mirrored);
73 static void _theme_hook(Evas_Object *obj);
74 static void _sizing_eval(Evas_Object *obj);
75 static void _resize(void *data, Evas *e, Evas_Object *obj, void *event_info);
76 static void _menu_move_resize(void *data, Evas *e, Evas_Object *obj, void *event_info);
77 static void _menu_hide(void *data, Evas *e, Evas_Object *obj, void *event_info);
78 static void _layout(Evas_Object *o, Evas_Object_Box_Data *priv, void *data);
79 static void _elm_toolbar_item_icon_obj_set(Evas_Object *obj, Elm_Toolbar_Item *item, Evas_Object *icon_obj, const char *icon_str, double icon_size, const char *sig);
80 static void _item_label_set(Elm_Toolbar_Item *item, const char *label, const char *sig);
82 static const char SIG_CLICKED[] = "clicked";
83 static const char SIG_LONGPRESSED[] = "longpressed";
84 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
86 static const Evas_Smart_Cb_Description _signals[] = {
88 {SIG_LONGPRESSED, ""},
89 {SIG_CLICKED_DOUBLE, ""},
94 _item_disable_hook(Elm_Object_Item *it)
97 Elm_Toolbar_Item *toolbar_it = (Elm_Toolbar_Item *)it;
99 wd = elm_widget_data_get(WIDGET(toolbar_it));
102 if (elm_widget_item_disabled_get(toolbar_it))
104 edje_object_signal_emit(VIEW(toolbar_it), "elm,state,disabled", "elm");
105 elm_widget_signal_emit(toolbar_it->icon, "elm,state,disabled", "elm");
109 edje_object_signal_emit(VIEW(toolbar_it), "elm,state,enabled", "elm");
110 elm_widget_signal_emit(toolbar_it->icon, "elm,state,enabled", "elm");
112 _resize(WIDGET(toolbar_it), NULL, NULL, NULL);
116 _item_icon_set(Evas_Object *icon_obj, const char *type, const char *icon)
120 if ((!type) || (!*type)) goto end;
121 if ((!icon) || (!*icon)) return EINA_FALSE;
122 if ((snprintf(icon_str, sizeof(icon_str), "%s%s", type, icon) > 0)
123 && (elm_icon_standard_set(icon_obj, icon_str)))
126 if (elm_icon_standard_set(icon_obj, icon))
128 WRN("couldn't find icon definition for '%s'", icon);
133 _elm_toolbar_icon_size_get(Widget_Data *wd)
135 const char *icon_size = edje_object_data_get(
136 elm_smart_scroller_edje_object_get(wd->scr), "icon_size");
138 return atoi(icon_size);
139 return _elm_config->icon_size;
143 _item_show(Elm_Toolbar_Item *it)
145 Widget_Data *wd = elm_widget_data_get(WIDGET(it));
146 Evas_Coord x, y, w, h, bx, by;
149 evas_object_geometry_get(wd->bx, &bx, &by, NULL, NULL);
150 evas_object_geometry_get(VIEW(it), &x, &y, &w, &h);
151 elm_smart_scroller_child_region_show(wd->scr, x - bx, y - by, w, h);
155 _item_unselect(Elm_Toolbar_Item *item)
158 if ((!item) || (!item->selected)) return;
159 wd = elm_widget_data_get(WIDGET(item));
161 item->selected = EINA_FALSE;
162 wd->selected_item = NULL;
163 edje_object_signal_emit(VIEW(item), "elm,state,unselected", "elm");
164 elm_widget_signal_emit(item->icon, "elm,state,unselected", "elm");
168 _item_select(Elm_Toolbar_Item *it)
170 Elm_Toolbar_Item *it2;
171 Widget_Data *wd = elm_widget_data_get(WIDGET(it));
177 if (elm_widget_item_disabled_get(it) || (it->separator) || (it->object)) return;
180 evas_object_geometry_get(it->object, NULL, NULL, &w, &h);
182 if (wd->select_mode != ELM_OBJECT_SELECT_MODE_NONE)
186 if (wd->shrink_mode == ELM_TOOLBAR_SHRINK_EXPAND)
187 if (wd->more_item == it)
189 edje_object_signal_emit(elm_layout_edje_get(wd->more), "elm,state,close", "elm");
192 if (wd->select_mode != ELM_OBJECT_SELECT_MODE_ALWAYS)
197 it2 = (Elm_Toolbar_Item *)
198 elm_toolbar_selected_item_get(WIDGET(it));
201 it->selected = EINA_TRUE;
202 wd->selected_item = it;
203 if (wd->shrink_mode == ELM_TOOLBAR_SHRINK_EXPAND)
205 if (wd->more_item == it)
207 if (!evas_object_box_children_get(wd->bx_more2))
208 edje_object_signal_emit(elm_layout_edje_get(wd->more), "elm,state,open", "elm");
210 edje_object_signal_emit(elm_layout_edje_get(wd->more), "elm,state,open2", "elm");
214 if (it->in_box != wd->bx)
216 edje_object_signal_emit(wd->VIEW(more_item), "elm,state,selected", "elm");
217 elm_widget_signal_emit(wd->more_item->icon, "elm,state,selected", "elm");
221 edje_object_signal_emit(wd->VIEW(more_item), "elm,state,unselected", "elm");
222 elm_widget_signal_emit(wd->more_item->icon, "elm,state,unselected", "elm");
224 edje_object_signal_emit(elm_layout_edje_get(wd->more), "elm,state,close", "elm");
227 edje_object_signal_emit(VIEW(it), "elm,state,selected", "elm");
228 elm_widget_signal_emit(it->icon, "elm,state,selected", "elm");
233 if (it->menu && (!sel))
235 evas_object_show(it->o_menu);
236 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_RESIZE,
237 _menu_move_resize, it);
238 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MOVE,
239 _menu_move_resize, it);
241 _menu_move_resize(it, NULL, NULL, NULL);
243 if (it->func) it->func((void *)(it->base.data), WIDGET(it), it);
244 evas_object_smart_callback_call(obj2, SIG_CLICKED, it);
248 _menu_hide(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
250 Elm_Toolbar_Item *selected;
251 Elm_Toolbar_Item *it = data;
252 selected = (Elm_Toolbar_Item *) elm_toolbar_selected_item_get(WIDGET(it));
253 _item_unselect(selected);
257 _menu_del(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
259 // avoid hide being emitted during object deletion
260 evas_object_event_callback_del_full
261 (obj, EVAS_CALLBACK_HIDE, _menu_hide, data);
265 _menu_move_resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
267 Elm_Toolbar_Item *it = data;
269 Widget_Data *wd = elm_widget_data_get(WIDGET(it));
271 if ((!wd) || (!wd->menu_parent)) return;
272 evas_object_geometry_get(VIEW(it), &x, &y, &w, &h);
273 elm_menu_move(it->o_menu, x, y+h);
277 _item_del(Elm_Toolbar_Item *it)
279 Elm_Toolbar_Item_State *it_state;
281 EINA_LIST_FREE(it->states, it_state)
283 if (it->icon == it_state->icon)
285 eina_stringshare_del(it_state->label);
286 eina_stringshare_del(it_state->icon_str);
287 if (it_state->icon) evas_object_del(it_state->icon);
290 eina_stringshare_del(it->label);
291 eina_stringshare_del(it->icon_str);
292 if (it->icon) evas_object_del(it->icon);
293 if (it->object) evas_object_del(it->object);
294 //TODO: See if checking for wd->menu_parent is necessary before deleting menu
295 if (it->o_menu) evas_object_del(it->o_menu);
299 _del_pre_hook(Evas_Object *obj)
301 Widget_Data *wd = elm_widget_data_get(obj);
302 Elm_Toolbar_Item *it, *next;
305 it = ELM_TOOLBAR_ITEM_FROM_INLIST(wd->items);
308 next = ELM_TOOLBAR_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
310 elm_widget_item_free(it);
315 _item_del(wd->more_item);
316 elm_widget_item_free(wd->more_item);
320 ecore_timer_del(wd->long_timer);
321 wd->long_timer = NULL;
326 _del_hook(Evas_Object *obj)
328 Widget_Data *wd = elm_widget_data_get(obj);
336 _mirrored_set_item(Evas_Object *obj __UNUSED__, Elm_Toolbar_Item *it, Eina_Bool mirrored)
338 edje_object_mirrored_set(VIEW(it), mirrored);
339 elm_widget_mirrored_set(it->o_menu, mirrored);
343 _theme_hook_item(Evas_Object *obj, Elm_Toolbar_Item *it, double scale, int icon_size)
345 Widget_Data *wd = elm_widget_data_get(obj);
346 Evas_Object *view = VIEW(it);
348 const char *style = elm_widget_style_get(obj);
350 _mirrored_set_item(obj, it, elm_widget_mirrored_get(obj));
351 edje_object_scale_set(view, scale);
352 if (!it->separator && !it->object)
354 _elm_theme_object_set(obj, view, "toolbar", "item", style);
357 edje_object_signal_emit(view, "elm,state,selected", "elm");
358 elm_widget_signal_emit(it->icon, "elm,state,selected", "elm");
360 if (elm_widget_item_disabled_get(it))
362 edje_object_signal_emit(view, "elm,state,disabled", "elm");
363 elm_widget_signal_emit(it->icon, "elm,state,disabled", "elm");
369 ms = ((double)icon_size * scale);
370 evas_object_size_hint_min_set(it->icon, ms, ms);
371 evas_object_size_hint_max_set(it->icon, ms, ms);
372 edje_object_part_swallow(view, "elm.swallow.icon", it->icon);
374 edje_object_part_text_escaped_set(view, "elm.text", it->label);
380 _elm_theme_object_set(obj, view, "toolbar", "separator", style);
383 evas_object_size_hint_weight_set(view, EVAS_HINT_EXPAND, -1.0);
384 evas_object_size_hint_align_set(view, EVAS_HINT_FILL, 0.5);
388 evas_object_size_hint_weight_set(view, -1.0, EVAS_HINT_EXPAND);
389 evas_object_size_hint_align_set(view, 0.5, EVAS_HINT_FILL);
394 _elm_theme_object_set(obj, view, "toolbar", "object", style);
395 edje_object_part_swallow(view, "elm.swallow.object", it->object);
400 if (!it->separator && !it->object)
401 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
402 edje_object_size_min_restricted_calc(view, &mw, &mh, mw, mh);
403 if (!it->separator && !it->object)
404 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
405 evas_object_size_hint_min_set(view, mw, mh);
409 _mirrored_set(Evas_Object *obj, Eina_Bool mirrored)
411 Widget_Data *wd = elm_widget_data_get(obj);
412 Elm_Toolbar_Item *it;
414 EINA_INLIST_FOREACH(wd->items, it)
415 _mirrored_set_item(obj, it, mirrored);
417 _mirrored_set_item(obj, wd->more_item, mirrored);
421 _theme_hook(Evas_Object *obj)
423 Widget_Data *wd = elm_widget_data_get(obj);
424 Elm_Toolbar_Item *it;
428 _elm_widget_mirrored_reload(obj);
429 elm_smart_scroller_object_theme_set(obj, wd->scr, "toolbar", "base", elm_widget_style_get(obj));
430 _mirrored_set(obj, elm_widget_mirrored_get(obj));
431 scale = (elm_widget_scale_get(obj) * _elm_config->scale);
432 edje_object_scale_set(wd->scr, scale);
433 wd->icon_size = _elm_toolbar_icon_size_get(wd);
434 EINA_INLIST_FOREACH(wd->items, it)
435 _theme_hook_item(obj, it, scale, wd->icon_size);
437 _theme_hook_item(obj, wd->more_item, scale, wd->icon_size);
442 _item_text_set_hook(Elm_Object_Item *it,
446 if (part && strcmp(part, "default")) return;
447 _item_label_set(((Elm_Toolbar_Item *)it), label, "elm,state,label_set");
451 _item_text_get_hook(const Elm_Object_Item *it, const char *part)
453 if (part && strcmp(part, "default")) return NULL;
454 return ((Elm_Toolbar_Item *)it)->label;
458 _item_content_set_hook(Elm_Object_Item *it,
460 Evas_Object *content)
464 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
465 if (part && strcmp(part, "object")) return;
466 Elm_Toolbar_Item *item = (Elm_Toolbar_Item *) it;
467 Evas_Object *obj = WIDGET(item);
468 Widget_Data *wd = elm_widget_data_get(obj);
469 if (!wd || !obj) return;
470 if (item->object == content) return;
472 if (item->object) evas_object_del(item->object);
474 item->object = content;
476 elm_widget_sub_object_add(obj, item->object);
477 scale = (elm_widget_scale_get(obj) * _elm_config->scale);
478 _theme_hook_item(obj, item, scale, wd->icon_size);
482 _item_content_get_hook(const Elm_Object_Item *it, const char *part)
484 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
485 if (part && strcmp(part, "object")) return NULL;
486 return ((Elm_Toolbar_Item *) it)->object;
490 _item_content_unset_hook(Elm_Object_Item *it, const char *part)
495 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
496 if (part && strcmp(part, "object")) return NULL;
497 Elm_Toolbar_Item *item = (Elm_Toolbar_Item *) it;
498 Evas_Object *obj = WIDGET(item);
499 Widget_Data *wd = elm_widget_data_get(obj);
501 edje_object_part_unswallow(VIEW(it), item->object);
502 elm_widget_sub_object_del(obj, item->object);
505 scale = (elm_widget_scale_get(obj) * _elm_config->scale);
506 _theme_hook_item(obj, item, scale, wd->icon_size);
511 _translate_hook(Evas_Object *obj)
513 evas_object_smart_callback_call(obj, "language,changed", NULL);
517 _sizing_eval(Evas_Object *obj)
519 Widget_Data *wd = elm_widget_data_get(obj);
520 Evas_Coord minw = -1, minh = -1, minw_bx = -1, minh_bx = -1;
521 Evas_Coord vw = 0, vh = 0;
525 evas_object_smart_need_recalculate_set(wd->bx, EINA_TRUE);
526 evas_object_smart_calculate(wd->bx);
527 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr),
529 evas_object_geometry_get(obj, NULL, NULL, &w, &h);
530 if (w < minw) w = minw;
531 if (h < minh) h = minh;
532 evas_object_resize(wd->scr, w, h);
534 evas_object_size_hint_min_get(wd->bx, &minw_bx, &minh_bx);
535 // if (wd->vertical && (h > minh)) minh = h;
536 // if ((!wd->vertical) && (w > minw)) minw = w;
537 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
538 if (wd->shrink_mode == ELM_TOOLBAR_SHRINK_NONE)
542 minw = minw_bx + (w - vw);
543 minh = minh_bx + (h - vh);
547 minw = minw_bx + (w - vw);
548 minh = minh_bx + (h - vh);
551 else if (wd->shrink_mode == ELM_TOOLBAR_SHRINK_EXPAND)
553 minw = minw_bx + (w - vw);
554 minh = minh_bx + (h - vh);
555 if (minw_bx < vw) minw_bx = vw;
556 if (minh_bx < vh) minh_bx = vh;
562 minw = minw_bx + (w - vw);
568 minh = minh_bx + (h - vh);
570 // if (wd->vertical) minh = h - vh;
571 // else minw = w - vw;
572 // minh = minh + (h - vh);
574 evas_object_resize(wd->bx, minw_bx, minh_bx);
575 evas_object_resize(wd->more, w, h);
576 evas_object_size_hint_min_set(obj, minw, minh);
577 evas_object_size_hint_max_set(obj, -1, -1);
581 _item_menu_create(Widget_Data *wd, Elm_Toolbar_Item *item)
583 item->o_menu = elm_menu_add(VIEW(item));
584 item->menu = EINA_TRUE;
586 elm_menu_parent_set(item->o_menu, wd->menu_parent);
587 evas_object_event_callback_add(item->o_menu, EVAS_CALLBACK_HIDE,
589 evas_object_event_callback_add(item->o_menu, EVAS_CALLBACK_DEL,
594 _item_menu_destroy(Elm_Toolbar_Item *item)
598 evas_object_del(item->o_menu);
601 item->menu = EINA_FALSE;
605 _toolbar_item_prio_compare_cb(const void *i1, const void *i2)
607 const Elm_Toolbar_Item *eti1 = i1;
608 const Elm_Toolbar_Item *eti2 = i2;
611 if (!eti1) return -1;
613 if (eti2->prio.priority == eti1->prio.priority)
616 return eti2->prio.priority - eti1->prio.priority;
620 _fix_items_visibility(Widget_Data *wd, Evas_Coord *iw, Evas_Coord vw)
622 Elm_Toolbar_Item *it, *prev;
623 Eina_List *sorted = NULL;
624 Evas_Coord ciw = 0, cih = 0;
626 EINA_INLIST_FOREACH(wd->items, it)
628 sorted = eina_list_sorted_insert(sorted,
629 _toolbar_item_prio_compare_cb, it);
634 evas_object_geometry_get(wd->VIEW(more_item), NULL, NULL, &ciw, &cih);
635 if (wd->vertical) *iw += cih;
638 EINA_LIST_FREE(sorted, it)
640 evas_object_geometry_get(VIEW(it), NULL, NULL, &ciw, &cih);
641 if (wd->vertical) *iw += cih;
644 it->prio.visible = (*iw <= vw);
647 prev = ELM_TOOLBAR_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
648 it->prio.visible = prev->prio.visible;
654 _fix_items_visibility_by_number(Widget_Data *wd, unsigned int *count)
656 Elm_Toolbar_Item *it, *prev, *next, *max = NULL;
657 Eina_List *sorted = NULL;
660 EINA_INLIST_FOREACH(wd->items, it)
664 prev = ELM_TOOLBAR_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
665 it->prio.priority = prev->prio.priority;
669 EINA_INLIST_FOREACH(wd->items, it)
671 sorted = eina_list_sorted_insert(sorted,
672 _toolbar_item_prio_compare_cb, it);
675 EINA_LIST_FREE(sorted, it)
678 if(*count <= wd->item_max)
680 it->prio.visible = EINA_TRUE;
682 if (*count == wd->item_max)
687 it->prio.visible = EINA_FALSE;
688 if (wd->item_count < (wd->item_max * 2) ||
689 *count <= (wd->item_count + wd->item_max) / 2)
690 it->in_box = wd->bx_more;
692 it->in_box = wd->bx_more2;
696 max->prio.visible = EINA_FALSE;
697 max->in_box = wd->bx_more;
698 next = ELM_TOOLBAR_ITEM_FROM_INLIST(EINA_INLIST_GET(max)->next);
699 if (next && next->separator)
701 next->prio.visible = max->prio.visible;
702 next->in_box = max->in_box;
711 _elm_toolbar_item_menu_cb(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
713 Elm_Toolbar_Item *it = data;
714 if (it->func) it->func((void *)(it->base.data), WIDGET(it), it);
718 _resize_job(void *data)
720 Evas_Object *obj = (Evas_Object *)data;
721 Widget_Data *wd = elm_widget_data_get(obj);
722 Evas_Coord mw, mh, vw = 0, vh = 0, w = 0, h = 0;
723 Elm_Toolbar_Item *it;
727 wd->resize_job = NULL;
728 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
729 evas_object_size_hint_min_get(wd->bx, &mw, &mh);
730 evas_object_geometry_get(wd->bx, NULL, NULL, &w, &h);
731 if (wd->shrink_mode == ELM_TOOLBAR_SHRINK_MENU)
733 Evas_Coord iw = 0, ih = 0, more_w = 0, more_h = 0;
737 evas_object_resize(wd->bx, w, vh);
738 _fix_items_visibility(wd, &ih, vh);
742 evas_object_resize(wd->bx, vw, h);
743 _fix_items_visibility(wd, &iw, vw);
745 evas_object_geometry_get(wd->VIEW(more_item), NULL, NULL,
749 if ((ih - more_h) <= vh) ih -= more_h;
753 if ((iw - more_w) <= vw) iw -= more_w;
756 /* All items are removed from the box object, since removing individual
757 * items won't trigger a resize. Items are be readded below. */
758 evas_object_box_remove_all(wd->bx, EINA_FALSE);
759 if (((wd->vertical) && (ih > vh)) ||
760 ((!wd->vertical) && (iw > vw)))
764 _item_menu_destroy(wd->more_item);
765 _item_menu_create(wd, wd->more_item);
766 menu = elm_toolbar_item_menu_get((Elm_Object_Item *)wd->more_item);
767 EINA_INLIST_FOREACH(wd->items, it)
769 if (!it->prio.visible)
772 elm_menu_item_separator_add(menu, NULL);
775 Elm_Object_Item *menu_it;
776 menu_it = elm_menu_item_add
777 (menu, NULL, it->icon_str, it->label,
778 _elm_toolbar_item_menu_cb, it);
779 elm_object_item_disabled_set
780 (menu_it, elm_widget_item_disabled_get(it));
782 elm_menu_clone(it->o_menu, menu, menu_it);
784 evas_object_hide(VIEW(it));
788 evas_object_box_append(wd->bx, VIEW(it));
789 evas_object_show(VIEW(it));
792 evas_object_box_append(wd->bx, wd->VIEW(more_item));
793 evas_object_show(wd->VIEW(more_item));
797 /* All items are visible, show them all (except for the "More"
798 * button, of course). */
799 EINA_INLIST_FOREACH(wd->items, it)
801 evas_object_show(VIEW(it));
802 evas_object_box_append(wd->bx, VIEW(it));
804 evas_object_hide(wd->VIEW(more_item));
807 else if (wd->shrink_mode == ELM_TOOLBAR_SHRINK_HIDE)
809 Evas_Coord iw = 0, ih = 0;
813 evas_object_resize(wd->bx, w, vh);
814 _fix_items_visibility(wd, &ih, vh);
818 evas_object_resize(wd->bx, vw, h);
819 _fix_items_visibility(wd, &iw, vw);
821 evas_object_box_remove_all(wd->bx, EINA_FALSE);
822 if (((wd->vertical) && (ih > vh)) ||
823 ((!wd->vertical) && (iw > vw)))
825 EINA_INLIST_FOREACH(wd->items, it)
827 if (!it->prio.visible)
828 evas_object_hide(VIEW(it));
831 evas_object_box_append(wd->bx, VIEW(it));
832 evas_object_show(VIEW(it));
838 /* All items are visible, show them all */
839 EINA_INLIST_FOREACH(wd->items, it)
841 evas_object_show(VIEW(it));
842 evas_object_box_append(wd->bx, VIEW(it));
846 else if (wd->shrink_mode == ELM_TOOLBAR_SHRINK_EXPAND)
849 if ((vw >= mw) && (vh >= mh))
850 evas_object_resize(wd->bx, vw, vh);
852 evas_object_resize(wd->bx, mw, vh);
854 evas_object_resize(wd->bx, vw, mh);
855 _fix_items_visibility_by_number(wd, &count);
857 evas_object_box_remove_all(wd->bx, EINA_FALSE);
858 evas_object_box_remove_all(wd->bx_more, EINA_FALSE);
859 evas_object_box_remove_all(wd->bx_more2, EINA_FALSE);
860 EINA_INLIST_FOREACH(wd->items, it)
864 evas_object_box_append(it->in_box, VIEW(it));
865 evas_object_show(VIEW(it));
868 if (count > wd->item_max)
870 evas_object_box_append(wd->bx, wd->VIEW(more_item));
871 evas_object_show(wd->VIEW(more_item));
874 evas_object_hide(wd->VIEW(more_item));
880 if ((vh >= mh) && (h != vh)) evas_object_resize(wd->bx, w, vh);
884 if ((vw >= mw) && (w != vw)) evas_object_resize(wd->bx, vw, h);
886 EINA_INLIST_FOREACH(wd->items, it)
896 // Remove the first or last separator since it is not neccessary
897 list = evas_object_box_children_get(wd->bx_more);
898 EINA_INLIST_FOREACH(wd->items, it)
900 if (it->separator && ((VIEW(it) == eina_list_data_get(list)) ||
901 (VIEW(it) == eina_list_nth(list, eina_list_count(list)-1))))
903 evas_object_box_remove(wd->bx_more, VIEW(it));
904 evas_object_hide(VIEW(it));
907 list = evas_object_box_children_get(wd->bx_more2);
908 EINA_INLIST_FOREACH(wd->items, it)
910 if (it->separator && ((VIEW(it) == eina_list_data_get(list)) ||
911 (VIEW(it) == eina_list_nth(list, eina_list_count(list)-1))))
913 evas_object_box_remove(wd->bx_more2, VIEW(it));
914 evas_object_hide(VIEW(it));
918 _mirrored_set(obj, elm_widget_mirrored_get(obj));
922 _resize_item(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
925 _resize(data, NULL, NULL, NULL);
929 _resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
931 Widget_Data *wd = elm_widget_data_get(data);
933 evas_object_geometry_get(data, &x, &y, NULL, &h);
934 evas_object_move(wd->more, x, y + h);
936 wd->resize_job = ecore_job_add(_resize_job, data);
940 _move(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
942 Widget_Data *wd = elm_widget_data_get(data);
944 evas_object_geometry_get(data, &x, &y, NULL, &h);
945 evas_object_move(wd->more, x, y + h);
949 _select_filter(Elm_Toolbar_Item *it, Evas_Object *obj __UNUSED__, const char *emission, const char *source __UNUSED__)
952 char buf[sizeof("elm,action,click,") + 1];
954 button = atoi(emission + sizeof("mouse,clicked,") - 1);
955 if (button == 1) return; /* regular left click event */
956 snprintf(buf, sizeof(buf), "elm,action,click,%d", button);
957 edje_object_signal_emit(VIEW(it), buf, "elm");
961 _select(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
963 Elm_Toolbar_Item *it = data;
965 if ((_elm_config->access_mode == ELM_ACCESS_MODE_OFF) ||
966 (_elm_access_2nd_click_timeout(VIEW(it))))
968 if (_elm_config->access_mode != ELM_ACCESS_MODE_OFF)
969 _elm_access_say(E_("Selected"));
975 _long_press(Elm_Toolbar_Item *it)
977 Widget_Data *wd = elm_widget_data_get(WIDGET(it));
978 wd->long_timer = NULL;
979 wd->long_press = EINA_TRUE;
980 evas_object_smart_callback_call(WIDGET(it), SIG_LONGPRESSED, it);
981 return ECORE_CALLBACK_CANCEL;
985 _mouse_down(Elm_Toolbar_Item *it, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, Evas_Event_Mouse_Down *ev)
987 Widget_Data *wd = elm_widget_data_get(WIDGET(it));
989 if (ev->button != 1) return;
990 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
991 evas_object_smart_callback_call(WIDGET(it), SIG_CLICKED_DOUBLE, it);
992 wd->long_press = EINA_FALSE;
993 if (wd->long_timer) ecore_timer_interval_set(wd->long_timer, _elm_config->longpress_timeout);
994 else wd->long_timer = ecore_timer_add(_elm_config->longpress_timeout, (Ecore_Task_Cb)_long_press, it);
998 _mouse_up(Elm_Toolbar_Item *it, Evas *evas __UNUSED__, Evas_Object *obj __UNUSED__, Evas_Event_Mouse_Up *ev)
1000 Widget_Data *wd = elm_widget_data_get(WIDGET(it));
1002 if (ev->button != 1) return;
1005 ecore_timer_del(wd->long_timer);
1006 wd->long_timer = NULL;
1011 _mouse_in(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1013 Elm_Toolbar_Item *it = data;
1014 edje_object_signal_emit(VIEW(it), "elm,state,highlighted", "elm");
1015 elm_widget_signal_emit(it->icon, "elm,state,highlighted", "elm");
1019 _mouse_out(void *data, Evas_Object *obj __UNUSED__, const char *emission __UNUSED__, const char *source __UNUSED__)
1021 Elm_Toolbar_Item *it = data;
1022 edje_object_signal_emit(VIEW(it), "elm,state,unhighlighted", "elm");
1023 elm_widget_signal_emit(it->icon, "elm,state,unhighlighted", "elm");
1027 _layout(Evas_Object *o, Evas_Object_Box_Data *priv, void *data)
1029 Evas_Object *obj = (Evas_Object *) data;
1030 Widget_Data *wd = elm_widget_data_get(obj);
1032 _els_box_layout(o, priv, !wd->vertical, wd->homogeneous,
1033 elm_widget_mirrored_get(obj));
1037 _access_info_cb(void *data __UNUSED__, Evas_Object *obj __UNUSED__, Elm_Widget_Item *item)
1039 Elm_Toolbar_Item *it = (Elm_Toolbar_Item *)item;
1040 const char *txt = item->access_info;
1041 if (!txt) txt = it->label;
1042 if (txt) return strdup(txt);
1047 _access_state_cb(void *data __UNUSED__, Evas_Object *obj __UNUSED__, Elm_Widget_Item *item __UNUSED__)
1049 Elm_Toolbar_Item *it = (Elm_Toolbar_Item *)item;
1051 return strdup(E_("Separator"));
1052 else if (elm_widget_item_disabled_get(it))
1053 return strdup(E_("State: Disabled"));
1054 else if (it->selected)
1055 return strdup(E_("State: Selected"));
1057 return strdup(E_("Has menu"));
1062 _item_del_pre_hook(Elm_Object_Item *it)
1066 Elm_Toolbar_Item *item, *next;
1067 item = (Elm_Toolbar_Item *)it;
1069 wd = elm_widget_data_get(WIDGET(item));
1070 if (!wd) return EINA_FALSE;
1072 obj2 = WIDGET(item);
1073 next = ELM_TOOLBAR_ITEM_FROM_INLIST(EINA_INLIST_GET(item)->next);
1074 wd->items = eina_inlist_remove(wd->items, EINA_INLIST_GET(item));
1076 if (!next) next = ELM_TOOLBAR_ITEM_FROM_INLIST(wd->items);
1077 if ((wd->select_mode == ELM_OBJECT_SELECT_MODE_ALWAYS) &&
1078 item->selected && next) _item_select(next);
1085 static Elm_Toolbar_Item *
1086 _item_new(Evas_Object *obj, const char *icon, const char *label, Evas_Smart_Cb func, const void *data)
1088 Widget_Data *wd = elm_widget_data_get(obj);
1089 Evas_Object *icon_obj;
1091 Elm_Toolbar_Item *it;
1093 icon_obj = elm_icon_add(obj);
1094 elm_icon_order_lookup_set(icon_obj, wd->lookup_order);
1095 if (!icon_obj) return NULL;
1096 it = elm_widget_item_new(obj, Elm_Toolbar_Item);
1099 evas_object_del(icon_obj);
1103 elm_widget_item_del_pre_hook_set(it, _item_del_pre_hook);
1104 elm_widget_item_disable_hook_set(it, _item_disable_hook);
1105 elm_widget_item_text_set_hook_set(it, _item_text_set_hook);
1106 elm_widget_item_text_get_hook_set(it, _item_text_get_hook);
1107 elm_widget_item_content_set_hook_set(it, _item_content_set_hook);
1108 elm_widget_item_content_get_hook_set(it, _item_content_get_hook);
1109 elm_widget_item_content_unset_hook_set(it, _item_content_unset_hook);
1111 it->label = eina_stringshare_add(label);
1112 it->prio.visible = 1;
1113 it->prio.priority = 0;
1115 it->separator = EINA_FALSE;
1117 it->base.data = data;
1118 VIEW(it) = edje_object_add(evas_object_evas_get(obj));
1119 _elm_access_item_register(&it->base, VIEW(it));
1120 _elm_access_text_set(_elm_access_item_get(&it->base),
1121 ELM_ACCESS_TYPE, E_("Tool Item"));
1122 _elm_access_callback_set(_elm_access_item_get(&it->base),
1123 ELM_ACCESS_INFO, _access_info_cb, it);
1124 _elm_access_callback_set(_elm_access_item_get(&it->base),
1125 ELM_ACCESS_STATE, _access_state_cb, it);
1127 if (_item_icon_set(icon_obj, "toolbar/", icon))
1129 it->icon = icon_obj;
1130 it->icon_str = eina_stringshare_add(icon);
1135 it->icon_str = NULL;
1136 evas_object_del(icon_obj);
1139 _elm_theme_object_set(obj, VIEW(it), "toolbar", "item",
1140 elm_widget_style_get(obj));
1141 edje_object_signal_callback_add(VIEW(it), "elm,action,click", "elm",
1143 edje_object_signal_callback_add(VIEW(it), "mouse,clicked,*", "*",
1144 (Edje_Signal_Cb)_select_filter, it);
1145 edje_object_signal_callback_add(VIEW(it), "elm,mouse,in", "elm",
1147 edje_object_signal_callback_add(VIEW(it), "elm,mouse,out", "elm",
1149 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MOUSE_DOWN,
1150 (Evas_Object_Event_Cb)_mouse_down, it);
1151 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MOUSE_UP,
1152 (Evas_Object_Event_Cb)_mouse_up, it);
1153 elm_widget_sub_object_add(obj, VIEW(it));
1158 ms = ((double)wd->icon_size * _elm_config->scale);
1159 evas_object_size_hint_min_set(it->icon, ms, ms);
1160 evas_object_size_hint_max_set(it->icon, ms, ms);
1161 edje_object_part_swallow(VIEW(it), "elm.swallow.icon", it->icon);
1162 edje_object_signal_emit(VIEW(it), "elm,state,icon,visible", "elm");
1163 evas_object_show(it->icon);
1164 elm_widget_sub_object_add(obj, it->icon);
1168 edje_object_part_text_escaped_set(VIEW(it), "elm.text", it->label);
1169 edje_object_signal_emit(VIEW(it), "elm,state,text,visible", "elm");
1172 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1173 edje_object_size_min_restricted_calc(VIEW(it), &mw, &mh, mw, mh);
1174 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1175 if (wd->shrink_mode != ELM_TOOLBAR_SHRINK_EXPAND)
1179 evas_object_size_hint_weight_set(VIEW(it), EVAS_HINT_EXPAND, -1.0);
1180 evas_object_size_hint_align_set(VIEW(it), EVAS_HINT_FILL, 0.5);
1184 evas_object_size_hint_weight_set(VIEW(it), -1.0, EVAS_HINT_EXPAND);
1185 evas_object_size_hint_align_set(VIEW(it), 0.5, EVAS_HINT_FILL);
1190 evas_object_size_hint_weight_set(VIEW(it), EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1191 evas_object_size_hint_align_set(VIEW(it), EVAS_HINT_FILL, EVAS_HINT_FILL);
1193 evas_object_size_hint_min_set(VIEW(it), mw, mh);
1194 evas_object_size_hint_max_set(VIEW(it), -1, -1);
1195 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_RESIZE,
1197 if ((!wd->items) && (wd->select_mode == ELM_OBJECT_SELECT_MODE_ALWAYS))
1203 _elm_toolbar_item_label_update(Elm_Toolbar_Item *item)
1205 Evas_Coord mw = -1, mh = -1;
1206 Widget_Data *wd = elm_widget_data_get(WIDGET(item));
1207 edje_object_part_text_escaped_set(VIEW(item), "elm.text", item->label);
1208 edje_object_signal_emit(VIEW(item), "elm,state,text,visible", "elm");
1210 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1211 edje_object_size_min_restricted_calc(VIEW(item), &mw, &mh, mw, mh);
1212 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1213 if (wd->shrink_mode != ELM_TOOLBAR_SHRINK_EXPAND)
1217 evas_object_size_hint_weight_set(VIEW(item), EVAS_HINT_EXPAND, -1.0);
1218 evas_object_size_hint_align_set(VIEW(item), EVAS_HINT_FILL, 0.5);
1222 evas_object_size_hint_weight_set(VIEW(item), -1.0, EVAS_HINT_EXPAND);
1223 evas_object_size_hint_align_set(VIEW(item), 0.5, EVAS_HINT_FILL);
1228 evas_object_size_hint_weight_set(VIEW(item), EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1229 evas_object_size_hint_align_set(VIEW(item), EVAS_HINT_FILL, EVAS_HINT_FILL);
1231 evas_object_size_hint_min_set(VIEW(item), mw, mh);
1235 _elm_toolbar_item_label_set_cb (void *data, Evas_Object *obj, const char *emission, const char *source)
1237 Elm_Toolbar_Item *item = data;
1238 _elm_toolbar_item_label_update(item);
1239 edje_object_signal_callback_del(obj, emission, source,
1240 _elm_toolbar_item_label_set_cb);
1241 edje_object_signal_emit (VIEW(item), "elm,state,label,reset", "elm");
1245 _item_label_set(Elm_Toolbar_Item *item, const char *label, const char *sig)
1249 if ((label) && (item->label) && (!strcmp(label, item->label))) return;
1251 eina_stringshare_replace(&item->label, label);
1252 s = edje_object_data_get(VIEW(item), "transition_animation_on");
1253 if ((s) && (atoi(s)))
1255 edje_object_part_text_escaped_set(VIEW(item), "elm.text_new", item->label);
1256 edje_object_signal_emit (VIEW(item), sig, "elm");
1257 edje_object_signal_callback_add(VIEW(item),
1258 "elm,state,label_set,done", "elm",
1259 _elm_toolbar_item_label_set_cb, item);
1262 _elm_toolbar_item_label_update(item);
1263 _resize(WIDGET(item), NULL, NULL, NULL);
1267 _elm_toolbar_item_icon_update(Elm_Toolbar_Item *item)
1269 Elm_Toolbar_Item_State *it_state;
1271 Evas_Coord mw = -1, mh = -1;
1272 Widget_Data *wd = elm_widget_data_get(WIDGET(item));
1273 Evas_Object *old_icon = edje_object_part_swallow_get(VIEW(item),
1274 "elm.swallow.icon");
1275 elm_widget_sub_object_del(VIEW(item), old_icon);
1276 evas_object_hide(old_icon);
1277 edje_object_part_swallow(VIEW(item), "elm.swallow.icon", item->icon);
1278 edje_object_signal_emit(VIEW(item), "elm,state,icon,visible", "elm");
1279 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1280 edje_object_size_min_restricted_calc(VIEW(item), &mw, &mh, mw, mh);
1281 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1282 if (wd->shrink_mode != ELM_TOOLBAR_SHRINK_EXPAND)
1286 evas_object_size_hint_weight_set(VIEW(item), EVAS_HINT_EXPAND, -1.0);
1287 evas_object_size_hint_align_set(VIEW(item), EVAS_HINT_FILL, 0.5);
1291 evas_object_size_hint_weight_set(VIEW(item), -1.0, EVAS_HINT_EXPAND);
1292 evas_object_size_hint_align_set(VIEW(item), 0.5, EVAS_HINT_FILL);
1297 evas_object_size_hint_weight_set(VIEW(item), EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1298 evas_object_size_hint_align_set(VIEW(item), EVAS_HINT_FILL, EVAS_HINT_FILL);
1300 evas_object_size_hint_min_set(VIEW(item), mw, mh);
1302 EINA_LIST_FOREACH(item->states, l, it_state)
1304 if (it_state->icon == old_icon) return;
1306 evas_object_del(old_icon);
1310 _elm_toolbar_item_icon_set_cb (void *data, Evas_Object *obj, const char *emission, const char *source)
1312 Elm_Toolbar_Item *item = data;
1313 edje_object_part_unswallow(VIEW(item), item->icon);
1314 _elm_toolbar_item_icon_update(item);
1315 edje_object_signal_callback_del(obj, emission, source,
1316 _elm_toolbar_item_icon_set_cb);
1317 edje_object_signal_emit (VIEW(item), "elm,state,icon,reset", "elm");
1321 _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)
1323 Evas_Object *old_icon;
1328 eina_stringshare_replace(&item->icon_str, icon_str);
1331 eina_stringshare_del(item->icon_str);
1332 item->icon_str = NULL;
1334 item->icon = icon_obj;
1337 ms = (icon_size * _elm_config->scale);
1338 evas_object_size_hint_min_set(item->icon, ms, ms);
1339 evas_object_size_hint_max_set(item->icon, ms, ms);
1340 evas_object_show(item->icon);
1341 elm_widget_sub_object_add(obj, item->icon);
1343 s = edje_object_data_get(VIEW(item), "transition_animation_on");
1344 if ((s) && (atoi(s)))
1346 old_icon = edje_object_part_swallow_get(VIEW(item),
1347 "elm.swallow.icon_new");
1350 elm_widget_sub_object_del(VIEW(item), old_icon);
1351 evas_object_hide(old_icon);
1353 edje_object_part_swallow(VIEW(item), "elm.swallow.icon_new",
1355 edje_object_signal_emit (VIEW(item), sig, "elm");
1356 edje_object_signal_callback_add(VIEW(item),
1357 "elm,state,icon_set,done", "elm",
1358 _elm_toolbar_item_icon_set_cb, item);
1361 _elm_toolbar_item_icon_update(item);
1362 _resize(obj, NULL, NULL, NULL);
1366 _elm_toolbar_item_state_cb(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
1368 Elm_Toolbar_Item *it = event_info;
1369 Elm_Toolbar_Item_State *it_state;
1371 it_state = eina_list_data_get(it->current_state);
1373 it_state->func((void *)it_state->data, obj, event_info);
1376 static Elm_Toolbar_Item_State *
1377 _item_state_new(const char *label, const char *icon_str, Evas_Object *icon, Evas_Smart_Cb func, const void *data)
1379 Elm_Toolbar_Item_State *it_state;
1380 it_state = ELM_NEW(Elm_Toolbar_Item_State);
1381 it_state->label = eina_stringshare_add(label);
1382 it_state->icon_str = eina_stringshare_add(icon_str);
1383 it_state->icon = icon;
1384 it_state->func = func;
1385 it_state->data = data;
1390 elm_toolbar_add(Evas_Object *parent)
1396 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
1398 ELM_SET_WIDTYPE(widtype, "toolbar");
1399 elm_widget_type_set(obj, "toolbar");
1400 elm_widget_sub_object_add(parent, obj);
1401 elm_widget_data_set(obj, wd);
1402 elm_widget_del_pre_hook_set(obj, _del_pre_hook);
1403 elm_widget_del_hook_set(obj, _del_hook);
1404 elm_widget_theme_hook_set(obj, _theme_hook);
1405 elm_widget_translate_hook_set(obj, _translate_hook);
1406 elm_widget_can_focus_set(obj, EINA_TRUE);
1408 wd->more_item = NULL;
1409 wd->selected_item = NULL;
1410 wd->item_max = 9999;
1411 wd->scr = elm_smart_scroller_add(e);
1412 elm_smart_scroller_widget_set(wd->scr, obj);
1413 elm_smart_scroller_object_theme_set(obj, wd->scr, "toolbar", "base", "default");
1414 elm_smart_scroller_bounce_allow_set(wd->scr,
1415 _elm_config->thumbscroll_bounce_enable,
1417 elm_widget_resize_object_set(obj, wd->scr);
1418 elm_smart_scroller_policy_set(wd->scr,
1419 ELM_SMART_SCROLLER_POLICY_AUTO,
1420 ELM_SMART_SCROLLER_POLICY_OFF);
1422 wd->icon_size = _elm_toolbar_icon_size_get(wd);
1425 wd->homogeneous = EINA_TRUE;
1428 wd->bx = evas_object_box_add(e);
1429 evas_object_size_hint_align_set(wd->bx, wd->align, 0.5);
1430 evas_object_box_layout_set(wd->bx, _layout, obj, NULL);
1431 elm_widget_sub_object_add(obj, wd->bx);
1432 elm_smart_scroller_child_set(wd->scr, wd->bx);
1433 evas_object_show(wd->bx);
1435 wd->more = elm_layout_add(obj);
1436 elm_layout_theme_set(wd->more, "toolbar", "more", "default");
1437 elm_widget_sub_object_add(obj, wd->more);
1438 evas_object_show(wd->more);
1440 wd->bx_more = evas_object_box_add(e);
1441 evas_object_size_hint_align_set(wd->bx_more, wd->align, 0.5);
1442 evas_object_box_layout_set(wd->bx_more, _layout, obj, NULL);
1443 elm_widget_sub_object_add(obj, wd->bx_more);
1444 elm_object_part_content_set(wd->more, "elm.swallow.content", wd->bx_more);
1445 evas_object_show(wd->bx_more);
1447 wd->bx_more2 = evas_object_box_add(e);
1448 evas_object_size_hint_align_set(wd->bx_more2, wd->align, 0.5);
1449 evas_object_box_layout_set(wd->bx_more2, _layout, obj, NULL);
1450 elm_widget_sub_object_add(obj, wd->bx_more2);
1451 elm_object_part_content_set(wd->more, "elm.swallow.content2", wd->bx_more2);
1452 evas_object_show(wd->bx_more2);
1454 elm_toolbar_shrink_mode_set(obj, _elm_config->toolbar_shrink_mode);
1455 evas_object_event_callback_add(wd->scr, EVAS_CALLBACK_RESIZE, _resize, obj);
1456 evas_object_event_callback_add(wd->scr, EVAS_CALLBACK_MOVE, _move, obj);
1457 evas_object_event_callback_add(wd->bx, EVAS_CALLBACK_RESIZE, _resize, obj);
1458 elm_toolbar_icon_order_lookup_set(obj, ELM_ICON_LOOKUP_THEME_FDO);
1460 evas_object_smart_callbacks_descriptions_set(obj, _signals);
1467 elm_toolbar_icon_size_set(Evas_Object *obj, int icon_size)
1469 ELM_CHECK_WIDTYPE(obj, widtype);
1470 Widget_Data *wd = elm_widget_data_get(obj);
1472 if (wd->icon_size == icon_size) return;
1473 wd->icon_size = icon_size;
1478 elm_toolbar_icon_size_get(const Evas_Object *obj)
1480 ELM_CHECK_WIDTYPE(obj, widtype) 0;
1481 Widget_Data *wd = elm_widget_data_get(obj);
1483 return wd->icon_size;
1486 EAPI Elm_Object_Item *
1487 elm_toolbar_item_append(Evas_Object *obj, const char *icon, const char *label, Evas_Smart_Cb func, const void *data)
1489 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1490 Widget_Data *wd = elm_widget_data_get(obj);
1491 if (!wd) return NULL;
1493 Elm_Toolbar_Item *it = _item_new(obj, icon, label, func, data);
1494 if (!it) return NULL;
1495 double scale = (elm_widget_scale_get(obj) * _elm_config->scale);
1497 wd->items = eina_inlist_append(wd->items, EINA_INLIST_GET(it));
1498 evas_object_box_append(wd->bx, VIEW(it));
1499 evas_object_show(VIEW(it));
1501 _theme_hook_item(obj, it, scale, wd->icon_size);
1505 return (Elm_Object_Item *)it;
1508 EAPI Elm_Object_Item *
1509 elm_toolbar_item_prepend(Evas_Object *obj, const char *icon, const char *label, Evas_Smart_Cb func, const void *data)
1511 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1512 Widget_Data *wd = elm_widget_data_get(obj);
1513 if (!wd) return NULL;
1515 Elm_Toolbar_Item *it = _item_new(obj, icon, label, func, data);
1516 if (!it) return NULL;
1517 double scale = (elm_widget_scale_get(obj) * _elm_config->scale);
1519 wd->items = eina_inlist_prepend(wd->items, EINA_INLIST_GET(it));
1520 evas_object_box_prepend(wd->bx, VIEW(it));
1521 evas_object_show(VIEW(it));
1522 _theme_hook_item(obj, it, scale, wd->icon_size);
1526 return (Elm_Object_Item *)it;
1529 EAPI Elm_Object_Item *
1530 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)
1532 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1533 ELM_OBJ_ITEM_CHECK_OR_RETURN(before, NULL);
1535 Elm_Toolbar_Item *it, *_before;
1537 wd = elm_widget_data_get(obj);
1538 if (!wd) return NULL;
1539 _before = (Elm_Toolbar_Item *) before;
1540 it = _item_new(obj, icon, label, func, data);
1541 if (!it) return NULL;
1542 double scale = (elm_widget_scale_get(obj) * _elm_config->scale);
1544 wd->items = eina_inlist_prepend_relative(wd->items, EINA_INLIST_GET(it),
1545 EINA_INLIST_GET(_before));
1546 evas_object_box_insert_before(wd->bx, VIEW(it), VIEW(_before));
1547 evas_object_show(VIEW(it));
1548 _theme_hook_item(obj, it, scale, wd->icon_size);
1552 return (Elm_Object_Item *)it;
1555 EAPI Elm_Object_Item *
1556 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)
1558 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1559 ELM_OBJ_ITEM_CHECK_OR_RETURN(after, NULL);
1561 Elm_Toolbar_Item *it, *_after;
1563 wd = elm_widget_data_get(obj);
1564 if (!wd) return NULL;
1565 _after = (Elm_Toolbar_Item *) after;
1566 it = _item_new(obj, icon, label, func, data);
1567 if (!it) return NULL;
1568 double scale = (elm_widget_scale_get(obj) * _elm_config->scale);
1570 wd->items = eina_inlist_append_relative(wd->items, EINA_INLIST_GET(it),
1571 EINA_INLIST_GET(_after));
1572 evas_object_box_insert_after(wd->bx, VIEW(it), VIEW(_after));
1573 evas_object_show(VIEW(it));
1574 _theme_hook_item(obj, it, scale, wd->icon_size);
1578 return (Elm_Object_Item *)it;
1581 EAPI Elm_Object_Item *
1582 elm_toolbar_first_item_get(const Evas_Object *obj)
1584 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1585 Widget_Data *wd = elm_widget_data_get(obj);
1586 if (!wd || !wd->items) return NULL;
1587 return (Elm_Object_Item *) ELM_TOOLBAR_ITEM_FROM_INLIST(wd->items);
1590 EAPI Elm_Object_Item *
1591 elm_toolbar_last_item_get(const Evas_Object *obj)
1593 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1594 Widget_Data *wd = elm_widget_data_get(obj);
1595 if (!wd || !wd->items) return NULL;
1596 return (Elm_Object_Item *) ELM_TOOLBAR_ITEM_FROM_INLIST(wd->items->last);
1599 EAPI Elm_Object_Item *
1600 elm_toolbar_item_next_get(const Elm_Object_Item *it)
1602 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
1603 return (Elm_Object_Item *) ELM_TOOLBAR_ITEM_FROM_INLIST(
1604 EINA_INLIST_GET(((Elm_Toolbar_Item *)it))->next);
1607 EAPI Elm_Object_Item *
1608 elm_toolbar_item_prev_get(const Elm_Object_Item *it)
1610 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
1611 return (Elm_Object_Item *) ELM_TOOLBAR_ITEM_FROM_INLIST(
1612 EINA_INLIST_GET(((Elm_Toolbar_Item *)it))->prev);
1616 elm_toolbar_item_priority_set(Elm_Object_Item *it, int priority)
1618 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
1619 Elm_Toolbar_Item *item = (Elm_Toolbar_Item *)it;
1620 if (item->prio.priority == priority) return;
1621 item->prio.priority = priority;
1622 _resize(WIDGET(item), NULL, NULL, NULL);
1626 elm_toolbar_item_priority_get(const Elm_Object_Item *it)
1628 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, 0);
1629 return ((Elm_Toolbar_Item *)it)->prio.priority;
1632 EAPI Elm_Object_Item *
1633 elm_toolbar_item_find_by_label(const Evas_Object *obj, const char *label)
1635 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1636 Elm_Toolbar_Item *it;
1637 Widget_Data *wd = elm_widget_data_get(obj);
1638 if (!wd) return NULL;
1640 EINA_INLIST_FOREACH(wd->items, it)
1642 if (!strcmp(it->label, label))
1643 return (Elm_Object_Item *)it;
1649 elm_toolbar_item_selected_set(Elm_Object_Item *it, Eina_Bool selected)
1651 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
1652 Elm_Toolbar_Item *item = (Elm_Toolbar_Item *)it;
1653 Widget_Data *wd = elm_widget_data_get(WIDGET(item));
1656 if (item->selected == selected) return;
1657 if (selected) _item_select(item);
1658 else _item_unselect(item);
1662 elm_toolbar_item_selected_get(const Elm_Object_Item *it)
1664 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
1665 return ((Elm_Toolbar_Item *)it)->selected;
1668 EAPI Elm_Object_Item *
1669 elm_toolbar_selected_item_get(const Evas_Object *obj)
1671 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1672 Widget_Data *wd = elm_widget_data_get(obj);
1673 if (!wd) return NULL;
1674 return (Elm_Object_Item *) wd->selected_item;
1677 EAPI Elm_Object_Item *
1678 elm_toolbar_more_item_get(const Evas_Object *obj)
1680 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1681 Widget_Data *wd = elm_widget_data_get(obj);
1682 if (!wd) return NULL;
1683 return (Elm_Object_Item *) wd->more_item;
1687 elm_toolbar_item_icon_set(Elm_Object_Item *it, const char *icon)
1689 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
1691 Evas_Object *icon_obj;
1694 Elm_Toolbar_Item * item = (Elm_Toolbar_Item *)it;
1697 wd = elm_widget_data_get(obj);
1699 if ((icon) && (item->icon_str) && (!strcmp(icon, item->icon_str))) return;
1701 icon_obj = elm_icon_add(obj);
1702 if (!icon_obj) return;
1703 if (_item_icon_set(icon_obj, "toolbar/", icon))
1704 _elm_toolbar_item_icon_obj_set(obj, item, icon_obj, icon, wd->icon_size,
1705 "elm,state,icon_set");
1708 _elm_toolbar_item_icon_obj_set(obj, item, NULL, NULL, 0,
1709 "elm,state,icon_set");
1710 evas_object_del(icon_obj);
1715 elm_toolbar_item_icon_get(const Elm_Object_Item *it)
1717 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
1718 return ((Elm_Toolbar_Item *)it)->icon_str;
1722 elm_toolbar_item_object_get(const Elm_Object_Item *it)
1724 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
1728 Elm_Toolbar_Item *item = (Elm_Toolbar_Item *)it;
1731 wd = elm_widget_data_get(obj);
1732 if (!wd) return NULL;
1738 elm_toolbar_item_icon_object_get(Elm_Object_Item *it)
1740 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
1741 return ((Elm_Toolbar_Item *)it)->icon;
1745 elm_toolbar_item_icon_memfile_set(Elm_Object_Item *it, const void *img, size_t size, const char *format, const char *key)
1747 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
1749 Evas_Object *icon_obj;
1753 Elm_Toolbar_Item *item = (Elm_Toolbar_Item *)it;
1756 wd = elm_widget_data_get(obj);
1757 if (!wd) return EINA_FALSE;
1761 icon_obj = _els_smart_icon_add(evas_object_evas_get(obj));
1762 evas_object_repeat_events_set(icon_obj, EINA_TRUE);
1763 ret = _els_smart_icon_memfile_set(icon_obj, img, size, format, key);
1766 evas_object_del(icon_obj);
1769 _elm_toolbar_item_icon_obj_set(obj, item, icon_obj, NULL, wd->icon_size,
1770 "elm,state,icon_set");
1773 _elm_toolbar_item_icon_obj_set(obj, item, NULL, NULL, 0, "elm,state,icon_set");
1778 elm_toolbar_item_icon_file_set(Elm_Object_Item *it, const char *file, const char *key)
1780 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
1782 Evas_Object *icon_obj;
1786 Elm_Toolbar_Item *item = (Elm_Toolbar_Item *)it;
1789 wd = elm_widget_data_get(obj);
1790 if (!wd) return EINA_FALSE;
1794 icon_obj = _els_smart_icon_add(evas_object_evas_get(obj));
1795 evas_object_repeat_events_set(icon_obj, EINA_TRUE);
1796 ret = _els_smart_icon_file_key_set(icon_obj, file, key);
1799 evas_object_del(icon_obj);
1802 _elm_toolbar_item_icon_obj_set(obj, item, icon_obj, NULL, wd->icon_size,
1803 "elm,state,icon_set");
1806 _elm_toolbar_item_icon_obj_set(obj, item, NULL, NULL, 0, "elm,state,icon_set");
1811 elm_toolbar_item_separator_set(Elm_Object_Item *it, Eina_Bool separator)
1813 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
1814 Elm_Toolbar_Item *item = (Elm_Toolbar_Item *)it;
1815 Evas_Object *obj = WIDGET(item);
1816 Widget_Data *wd = elm_widget_data_get(obj);
1818 if (item->separator == separator) return;
1819 item->separator = separator;
1820 scale = (elm_widget_scale_get(obj) * _elm_config->scale);
1821 _theme_hook_item(obj, item, scale, wd->icon_size);
1825 elm_toolbar_item_separator_get(const Elm_Object_Item *it)
1827 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
1828 return ((Elm_Toolbar_Item *)it)->separator;
1832 elm_toolbar_shrink_mode_set(Evas_Object *obj, Elm_Toolbar_Shrink_Mode shrink_mode)
1834 ELM_CHECK_WIDTYPE(obj, widtype);
1835 Widget_Data *wd = elm_widget_data_get(obj);
1839 wd->shrink_mode = shrink_mode;
1840 bounce = (_elm_config->thumbscroll_bounce_enable) &&
1841 (shrink_mode == ELM_TOOLBAR_SHRINK_SCROLL);
1842 elm_smart_scroller_bounce_allow_set(wd->scr, bounce, EINA_FALSE);
1846 _item_del(wd->more_item);
1847 elm_widget_item_free(wd->more_item);
1848 wd->more_item = NULL;
1851 if (shrink_mode == ELM_TOOLBAR_SHRINK_MENU)
1853 elm_smart_scroller_policy_set(wd->scr, ELM_SMART_SCROLLER_POLICY_OFF,
1854 ELM_SMART_SCROLLER_POLICY_OFF);
1855 wd->more_item = _item_new(obj, "more_menu", "More", NULL, NULL);
1857 else if (shrink_mode == ELM_TOOLBAR_SHRINK_HIDE)
1858 elm_smart_scroller_policy_set(wd->scr, ELM_SMART_SCROLLER_POLICY_OFF,
1859 ELM_SMART_SCROLLER_POLICY_OFF);
1860 else if (shrink_mode == ELM_TOOLBAR_SHRINK_EXPAND)
1862 elm_smart_scroller_policy_set(wd->scr, ELM_SMART_SCROLLER_POLICY_AUTO,
1863 ELM_SMART_SCROLLER_POLICY_OFF);
1864 wd->more_item = _item_new(obj, "more_menu", "More", NULL, NULL);
1867 elm_smart_scroller_policy_set(wd->scr, ELM_SMART_SCROLLER_POLICY_AUTO,
1868 ELM_SMART_SCROLLER_POLICY_OFF);
1872 EAPI Elm_Toolbar_Shrink_Mode
1873 elm_toolbar_shrink_mode_get(const Evas_Object *obj)
1875 ELM_CHECK_WIDTYPE(obj, widtype) ELM_TOOLBAR_SHRINK_NONE;
1876 Widget_Data *wd = elm_widget_data_get(obj);
1878 if (!wd) return ELM_TOOLBAR_SHRINK_NONE;
1879 return wd->shrink_mode;
1883 elm_toolbar_homogeneous_set(Evas_Object *obj, Eina_Bool homogeneous)
1885 ELM_CHECK_WIDTYPE(obj, widtype);
1886 Widget_Data *wd = elm_widget_data_get(obj);
1889 wd->homogeneous = !!homogeneous;
1890 evas_object_smart_calculate(wd->bx);
1894 elm_toolbar_homogeneous_get(const Evas_Object *obj)
1896 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1897 Widget_Data *wd = elm_widget_data_get(obj);
1899 if (!wd) return EINA_FALSE;
1900 return wd->homogeneous;
1904 elm_toolbar_menu_parent_set(Evas_Object *obj, Evas_Object *parent)
1906 Elm_Toolbar_Item *it;
1907 ELM_CHECK_WIDTYPE(obj, widtype);
1908 Widget_Data *wd = elm_widget_data_get(obj);
1911 EINA_SAFETY_ON_NULL_RETURN(parent);
1912 wd->menu_parent = parent;
1913 EINA_INLIST_FOREACH(wd->items, it)
1916 elm_menu_parent_set(it->o_menu, wd->menu_parent);
1918 if ((wd->more_item) && (wd->more_item->o_menu))
1919 elm_menu_parent_set(wd->more_item->o_menu, wd->menu_parent);
1923 elm_toolbar_menu_parent_get(const Evas_Object *obj)
1925 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1926 Widget_Data *wd = elm_widget_data_get(obj);
1928 if (!wd) return NULL;
1929 return wd->menu_parent;
1933 elm_toolbar_align_set(Evas_Object *obj, double align)
1935 ELM_CHECK_WIDTYPE(obj, widtype);
1936 Widget_Data *wd = elm_widget_data_get(obj);
1941 if (wd->align != align)
1942 evas_object_size_hint_align_set(wd->bx, 0.5, align);
1946 if (wd->align != align)
1947 evas_object_size_hint_align_set(wd->bx, align, 0.5);
1953 elm_toolbar_align_get(const Evas_Object *obj)
1955 ELM_CHECK_WIDTYPE(obj, widtype) 0.0;
1956 Widget_Data *wd = elm_widget_data_get(obj);
1958 if (!wd) return 0.0;
1963 elm_toolbar_item_menu_set(Elm_Object_Item *it, Eina_Bool menu)
1965 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
1966 Elm_Toolbar_Item *item = (Elm_Toolbar_Item *)it;
1967 Widget_Data *wd = elm_widget_data_get(WIDGET(item));
1970 if (item->menu == menu) return;
1971 if (menu) _item_menu_create(wd, item);
1972 else _item_menu_destroy(item);
1976 elm_toolbar_item_menu_get(const Elm_Object_Item *it)
1978 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
1979 Elm_Toolbar_Item *item = (Elm_Toolbar_Item *)it;
1980 if (!item->menu) return NULL;
1981 Widget_Data *wd = elm_widget_data_get(WIDGET(item));
1982 if (!wd) return NULL;
1983 return item->o_menu;
1986 EAPI Elm_Toolbar_Item_State *
1987 elm_toolbar_item_state_add(Elm_Object_Item *it, const char *icon, const char *label, Evas_Smart_Cb func, const void *data)
1989 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
1991 Elm_Toolbar_Item_State *it_state;
1992 Evas_Object *icon_obj;
1995 Elm_Toolbar_Item *item = (Elm_Toolbar_Item *)it;
1997 wd = elm_widget_data_get(WIDGET(item));
1998 if (!wd) return NULL;
2002 it_state = _item_state_new(item->label, item->icon_str, item->icon,
2003 item->func, item->base.data);
2004 item->states = eina_list_append(item->states, it_state);
2005 item->current_state = item->states;
2008 icon_obj = elm_icon_add(obj);
2009 elm_icon_order_lookup_set(icon_obj, wd->lookup_order);
2010 if (!icon_obj) goto error_state_add;
2012 if (!_item_icon_set(icon_obj, "toolbar/", icon))
2014 evas_object_del(icon_obj);
2019 it_state = _item_state_new(label, icon, icon_obj, func, data);
2020 item->states = eina_list_append(item->states, it_state);
2021 item->func = _elm_toolbar_item_state_cb;
2022 item->base.data = NULL;
2027 if (item->states && !eina_list_next(item->states))
2029 eina_stringshare_del(item->label);
2030 eina_stringshare_del(item->icon_str);
2031 free(eina_list_data_get(item->states));
2032 eina_list_free(item->states);
2033 item->states = NULL;
2039 elm_toolbar_item_state_del(Elm_Object_Item *it, Elm_Toolbar_Item_State *state)
2041 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
2043 Eina_List *del_state;
2044 Elm_Toolbar_Item_State *it_state;
2045 Elm_Toolbar_Item *item;
2047 if (!state) return EINA_FALSE;
2049 item = (Elm_Toolbar_Item *)it;
2050 if (!item->states) return EINA_FALSE;
2052 del_state = eina_list_data_find_list(item->states, state);
2053 if (del_state == item->states) return EINA_FALSE;
2054 if (del_state == item->current_state)
2055 elm_toolbar_item_state_unset(it);
2057 eina_stringshare_del(state->label);
2058 eina_stringshare_del(state->icon_str);
2059 if (state->icon) evas_object_del(state->icon);
2061 item->states = eina_list_remove_list(item->states, del_state);
2062 if (item->states && !eina_list_next(item->states))
2064 it_state = eina_list_data_get(item->states);
2065 item->base.data = it_state->data;
2066 item->func = it_state->func;
2067 eina_stringshare_del(it_state->label);
2068 eina_stringshare_del(it_state->icon_str);
2069 free(eina_list_data_get(item->states));
2070 eina_list_free(item->states);
2071 item->states = NULL;
2077 elm_toolbar_item_state_set(Elm_Object_Item *it, Elm_Toolbar_Item_State *state)
2079 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
2082 Eina_List *next_state;
2083 Elm_Toolbar_Item_State *it_state;
2085 Elm_Toolbar_Item *item = (Elm_Toolbar_Item *)it;
2088 wd = elm_widget_data_get(obj);
2089 if (!wd) return EINA_FALSE;
2090 if (!item->states) return EINA_FALSE;
2094 next_state = eina_list_data_find_list(item->states, state);
2095 if (!next_state) return EINA_FALSE;
2098 next_state = item->states;
2100 if (next_state == item->current_state) return EINA_TRUE;
2102 it_state = eina_list_data_get(next_state);
2103 if (eina_list_data_find(item->current_state, state))
2105 _item_label_set(item, it_state->label, "elm,state,label_set,forward");
2106 _elm_toolbar_item_icon_obj_set(obj, item, it_state->icon, it_state->icon_str,
2107 wd->icon_size, "elm,state,icon_set,forward");
2111 _item_label_set(item, it_state->label, "elm,state,label_set,backward");
2112 _elm_toolbar_item_icon_obj_set(obj,
2117 "elm,state,icon_set,backward");
2119 if (elm_widget_item_disabled_get(item))
2120 elm_widget_signal_emit(item->icon, "elm,state,disabled", "elm");
2122 elm_widget_signal_emit(item->icon, "elm,state,enabled", "elm");
2124 item->current_state = next_state;
2129 elm_toolbar_item_state_unset(Elm_Object_Item *it)
2131 elm_toolbar_item_state_set(it, NULL);
2134 EAPI Elm_Toolbar_Item_State *
2135 elm_toolbar_item_state_get(const Elm_Object_Item *it)
2137 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
2138 Elm_Toolbar_Item *item = (Elm_Toolbar_Item *)it;
2140 if ((!item->states) || (!item->current_state)) return NULL;
2141 if (item->current_state == item->states) return NULL;
2143 return eina_list_data_get(item->current_state);
2146 EAPI Elm_Toolbar_Item_State *
2147 elm_toolbar_item_state_next(Elm_Object_Item *it)
2149 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
2153 Eina_List *next_state;
2154 Elm_Toolbar_Item *item = (Elm_Toolbar_Item *)it;
2157 wd = elm_widget_data_get(obj);
2158 if (!wd) return NULL;
2159 if (!item->states) return NULL;
2161 next_state = eina_list_next(item->current_state);
2163 next_state = eina_list_next(item->states);
2164 return eina_list_data_get(next_state);
2167 EAPI Elm_Toolbar_Item_State *
2168 elm_toolbar_item_state_prev(Elm_Object_Item *it)
2170 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
2174 Eina_List *prev_state;
2175 Elm_Toolbar_Item *item = (Elm_Toolbar_Item *)it;
2178 wd = elm_widget_data_get(obj);
2179 if (!wd) return NULL;
2180 if (!item->states) return NULL;
2182 prev_state = eina_list_prev(item->current_state);
2183 if ((!prev_state) || (prev_state == item->states))
2184 prev_state = eina_list_last(item->states);
2185 return eina_list_data_get(prev_state);
2189 elm_toolbar_icon_order_lookup_set(Evas_Object *obj, Elm_Icon_Lookup_Order order)
2191 ELM_CHECK_WIDTYPE(obj, widtype);
2192 Elm_Toolbar_Item *it;
2193 Widget_Data *wd = elm_widget_data_get(obj);
2196 wd->lookup_order = order;
2197 EINA_INLIST_FOREACH(wd->items, it)
2198 elm_icon_order_lookup_set(it->icon, order);
2200 elm_icon_order_lookup_set(wd->more_item->icon, order);
2203 EAPI Elm_Icon_Lookup_Order
2204 elm_toolbar_icon_order_lookup_get(const Evas_Object *obj)
2206 ELM_CHECK_WIDTYPE(obj, widtype) ELM_ICON_LOOKUP_THEME_FDO;
2207 Widget_Data *wd = elm_widget_data_get(obj);
2208 if (!wd) return ELM_ICON_LOOKUP_THEME_FDO;
2209 return wd->lookup_order;
2213 elm_toolbar_horizontal_set(Evas_Object *obj, Eina_Bool horizontal)
2215 ELM_CHECK_WIDTYPE(obj, widtype);
2216 Widget_Data *wd = elm_widget_data_get(obj);
2218 wd->vertical = !horizontal;
2220 evas_object_size_hint_align_set(wd->bx, 0.5, wd->align);
2222 evas_object_size_hint_align_set(wd->bx, wd->align, 0.5);
2227 elm_toolbar_horizontal_get(const Evas_Object *obj)
2229 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
2230 Widget_Data *wd = elm_widget_data_get(obj);
2231 if (!wd) return EINA_FALSE;
2232 return !wd->vertical;
2236 elm_toolbar_items_count(const Evas_Object *obj)
2238 ELM_CHECK_WIDTYPE(obj, widtype) 0;
2239 Widget_Data *wd = elm_widget_data_get(obj);
2241 return wd->item_count;
2245 elm_toolbar_items_max_set(Evas_Object *obj, unsigned int max)
2247 ELM_CHECK_WIDTYPE(obj, widtype);
2248 Widget_Data *wd = elm_widget_data_get(obj);
2254 elm_toolbar_items_max_get(const Evas_Object *obj)
2256 ELM_CHECK_WIDTYPE(obj, widtype) 0;
2257 Widget_Data *wd = elm_widget_data_get(obj);
2259 return wd->item_max;
2263 elm_toolbar_select_mode_set(Evas_Object *obj, Elm_Object_Select_Mode mode)
2265 ELM_CHECK_WIDTYPE(obj, widtype);
2266 Widget_Data *wd = elm_widget_data_get(obj);
2268 if (mode >= ELM_OBJECT_SELECT_MODE_MAX)
2270 if ((mode == ELM_OBJECT_SELECT_MODE_ALWAYS) &&
2271 (wd->select_mode != ELM_OBJECT_SELECT_MODE_ALWAYS) &&
2273 _item_select(ELM_TOOLBAR_ITEM_FROM_INLIST(wd->items));
2274 if (wd->select_mode != mode)
2275 wd->select_mode = mode;
2278 EAPI Elm_Object_Select_Mode
2279 elm_toolbar_select_mode_get(const Evas_Object *obj)
2281 ELM_CHECK_WIDTYPE(obj, widtype) ELM_OBJECT_SELECT_MODE_MAX;
2282 Widget_Data *wd = elm_widget_data_get(obj);
2283 if (!wd) return ELM_OBJECT_SELECT_MODE_MAX;
2284 return wd->select_mode;