1 #include <Elementary.h>
3 #include "elm_widget_toolbar.h"
5 EAPI const char ELM_TOOLBAR_SMART_NAME[] = "elm_toolbar";
7 #define ELM_TOOLBAR_ITEM_FROM_INLIST(item) \
8 ((item) ? EINA_INLIST_CONTAINER_GET(item, Elm_Toolbar_Item) : NULL)
10 static const char SIG_CLICKED[] = "clicked";
11 static const char SIG_LONGPRESSED[] = "longpressed";
12 static const char SIG_CLICKED_DOUBLE[] = "clicked,double";
13 static const char SIG_LANG_CHANGED[] = "language,changed";
14 static const Evas_Smart_Cb_Description _smart_callbacks[] = {
16 {SIG_LONGPRESSED, ""},
17 {SIG_CLICKED_DOUBLE, ""},
18 {SIG_LANG_CHANGED, ""},
22 static const Evas_Smart_Interface *_smart_interfaces[] =
24 (Evas_Smart_Interface *)&ELM_SCROLLABLE_IFACE, NULL
27 EVAS_SMART_SUBCLASS_IFACE_NEW
28 (ELM_TOOLBAR_SMART_NAME, _elm_toolbar, Elm_Toolbar_Smart_Class,
29 Elm_Widget_Smart_Class, elm_widget_smart_class_get, _smart_callbacks,
33 _toolbar_item_prio_compare_cb(const void *i1,
36 const Elm_Toolbar_Item *eti1 = i1;
37 const Elm_Toolbar_Item *eti2 = i2;
42 if (eti2->prio.priority == eti1->prio.priority)
45 return eti2->prio.priority - eti1->prio.priority;
49 _items_visibility_fix(Elm_Toolbar_Smart_Data *sd,
54 Elm_Toolbar_Item *it, *prev;
55 Evas_Coord ciw = 0, cih = 0;
56 Eina_List *sorted = NULL;
61 EINA_INLIST_FOREACH(sd->items, it)
65 prev = ELM_TOOLBAR_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
66 if (prev) it->prio.priority = prev->prio.priority;
70 EINA_INLIST_FOREACH(sd->items, it)
72 sorted = eina_list_sorted_insert
73 (sorted, _toolbar_item_prio_compare_cb, it);
78 evas_object_geometry_get(sd->VIEW(more_item), NULL, NULL, &ciw, &cih);
79 if (sd->vertical) *iw += cih;
83 EINA_LIST_FREE(sorted, it)
85 if (it->prio.priority > sd->standard_priority)
87 evas_object_geometry_get(VIEW(it), NULL, NULL, &ciw, &cih);
88 if (sd->vertical) *iw += cih;
90 it->prio.visible = (*iw <= vw);
92 if (!it->separator) count++;
96 it->prio.visible = EINA_FALSE;
97 if (!it->separator) i++;
99 it->in_box = sd->bx_more;
101 it->in_box = sd->bx_more2;
108 _item_menu_destroy(Elm_Toolbar_Item *item)
112 evas_object_del(item->o_menu);
115 item->menu = EINA_FALSE;
119 _item_unselect(Elm_Toolbar_Item *item)
121 if ((!item) || (!item->selected)) return;
123 ELM_TOOLBAR_DATA_GET(WIDGET(item), sd);
125 item->selected = EINA_FALSE;
126 sd->selected_item = NULL;
127 edje_object_signal_emit(VIEW(item), "elm,state,unselected", "elm");
128 elm_widget_signal_emit(item->icon, "elm,state,unselected", "elm");
132 _menu_hide(void *data,
134 Evas_Object *obj __UNUSED__,
135 void *event_info __UNUSED__)
137 Elm_Toolbar_Item *selected;
138 Elm_Toolbar_Item *it = data;
140 selected = (Elm_Toolbar_Item *)elm_toolbar_selected_item_get(WIDGET(it));
141 _item_unselect(selected);
145 _menu_del(void *data,
148 void *event_info __UNUSED__)
150 // avoid hide being emitted during object deletion
151 evas_object_event_callback_del_full
152 (obj, EVAS_CALLBACK_HIDE, _menu_hide, data);
156 _item_menu_create(Elm_Toolbar_Smart_Data *sd,
157 Elm_Toolbar_Item *item)
159 item->o_menu = elm_menu_add(elm_widget_parent_get(WIDGET(item)));
160 item->menu = EINA_TRUE;
163 elm_menu_parent_set(item->o_menu, sd->menu_parent);
165 evas_object_event_callback_add
166 (item->o_menu, EVAS_CALLBACK_HIDE, _menu_hide, item);
167 evas_object_event_callback_add
168 (item->o_menu, EVAS_CALLBACK_DEL, _menu_del, item);
172 _elm_toolbar_item_menu_cb(void *data,
173 Evas_Object *obj __UNUSED__,
174 void *event_info __UNUSED__)
176 Elm_Toolbar_Item *it = data;
178 if (it->func) it->func((void *)(it->base.data), WIDGET(it), it);
182 _item_show(Elm_Toolbar_Item *it)
184 Evas_Coord x, y, w, h, bx, by;
186 ELM_TOOLBAR_DATA_GET(WIDGET(it), sd);
188 evas_object_geometry_get(sd->bx, &bx, &by, NULL, NULL);
189 evas_object_geometry_get(VIEW(it), &x, &y, &w, &h);
190 sd->s_iface->content_region_show
191 (ELM_WIDGET_DATA(sd)->obj, x - bx, y - by, w, h);
195 _item_mirrored_set(Evas_Object *obj __UNUSED__,
196 Elm_Toolbar_Item *it,
199 edje_object_mirrored_set(VIEW(it), mirrored);
200 if (it->o_menu) elm_widget_mirrored_set(it->o_menu, mirrored);
204 _mirrored_set(Evas_Object *obj,
207 Elm_Toolbar_Item *it;
209 ELM_TOOLBAR_DATA_GET(obj, sd);
211 EINA_INLIST_FOREACH(sd->items, it)
212 _item_mirrored_set(obj, it, mirrored);
214 _item_mirrored_set(obj, sd->more_item, mirrored);
218 _items_size_fit(Evas_Object *obj, Evas_Coord *bl, Evas_Coord view)
220 Elm_Toolbar_Item *it, *prev;
221 Eina_Bool full = EINA_FALSE, more = EINA_FALSE;
222 Evas_Coord min, mw, mh;
223 int sumf = 0, sumb = 0, prev_min = 0;
225 ELM_TOOLBAR_DATA_GET(obj, sd);
227 EINA_INLIST_FOREACH(sd->items, it)
230 if (it->in_box && it->in_box == sd->bx)
232 if (!it->separator && !it->object)
233 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
234 edje_object_size_min_restricted_calc(VIEW(it), &mw, &mh, mw, mh);
235 if (!it->separator && !it->object)
236 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
241 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
242 edje_object_size_min_restricted_calc(sd->VIEW(more_item), &mw, &mh, mw, mh);
243 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
246 if (mw != -1 || mh != -1)
248 if (sd->vertical) min = mh;
251 if ((!full) && ((sumf + min) > view))
253 prev = ELM_TOOLBAR_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->prev);
254 if (prev && prev->separator)
262 if (!full) sumf += min;
267 if (sumf != 0) *bl = (Evas_Coord)(((sumf + sumb) * view) / sumf);
271 _elm_toolbar_item_coordinates_calc(Elm_Object_Item *item,
272 Elm_Toolbar_Item_Scrollto_Type type,
278 Evas_Coord ix, iy, iw, ih, bx, by, vw, vh;
280 ELM_TOOLBAR_DATA_GET(WIDGET(item), sd);
282 sd->s_iface->content_viewport_size_get(WIDGET(item), &vw, &vh);
283 evas_object_geometry_get(sd->bx, &bx, &by, NULL, NULL);
284 evas_object_geometry_get(VIEW(item), &ix, &iy, &iw, &ih);
288 case ELM_TOOLBAR_ITEM_SCROLLTO_IN:
295 case ELM_TOOLBAR_ITEM_SCROLLTO_FIRST:
302 case ELM_TOOLBAR_ITEM_SCROLLTO_MIDDLE:
303 *x = ix - bx + (iw / 2) - (vw / 2);
304 *y = iy - by + (ih / 2) - (vh / 2);
309 case ELM_TOOLBAR_ITEM_SCROLLTO_LAST:
310 *x = ix - bx + iw - vw;
311 *y = iy - by + ih - vh;
324 _resize_job(void *data)
326 Evas_Object *obj = (Evas_Object *)data;
327 Evas_Coord mw, mh, vw = 0, vh = 0, w = 0, h = 0;
328 Elm_Toolbar_Item *it;
329 Evas_Object *o; // TIZEN ONLY
330 Eina_List *l; // TIZEN ONLY
334 ELM_TOOLBAR_DATA_GET(obj, sd);
336 sd->resize_job = NULL;
337 sd->s_iface->content_viewport_size_get(obj, &vw, &vh);
338 evas_object_size_hint_min_get(sd->bx, &mw, &mh);
339 evas_object_geometry_get(sd->bx, NULL, NULL, &w, &h);
341 if (sd->shrink_mode == ELM_TOOLBAR_SHRINK_MENU)
343 Evas_Coord iw = 0, ih = 0, more_w = 0, more_h = 0;
348 _items_visibility_fix(sd, &ih, vh, &more);
353 _items_visibility_fix(sd, &iw, vw, &more);
355 evas_object_geometry_get
356 (sd->VIEW(more_item), NULL, NULL, &more_w, &more_h);
360 if ((ih - more_h) <= vh) ih -= more_h;
364 if ((iw - more_w) <= vw) iw -= more_w;
367 /* All items are removed from the box object, since removing
368 * individual items won't trigger a resize. Items are be
370 evas_object_box_remove_all(sd->bx, EINA_FALSE);
371 if (((sd->vertical) && (ih > vh)) ||
372 ((!sd->vertical) && (iw > vw)) || more)
376 _item_menu_destroy(sd->more_item);
377 _item_menu_create(sd, sd->more_item);
379 elm_toolbar_item_menu_get((Elm_Object_Item *)sd->more_item);
380 EINA_INLIST_FOREACH(sd->items, it)
382 if (!it->prio.visible)
385 elm_menu_item_separator_add(menu, NULL);
388 Elm_Object_Item *menu_it;
390 menu_it = elm_menu_item_add
391 (menu, NULL, it->icon_str, it->label,
392 _elm_toolbar_item_menu_cb, it);
393 elm_object_item_disabled_set
394 (menu_it, elm_widget_item_disabled_get(it));
396 elm_menu_clone(it->o_menu, menu, menu_it);
398 evas_object_hide(VIEW(it));
402 evas_object_box_append(sd->bx, VIEW(it));
403 evas_object_show(VIEW(it));
406 evas_object_box_append(sd->bx, sd->VIEW(more_item));
407 evas_object_show(sd->VIEW(more_item));
411 /* All items are visible, show them all (except for the
412 * "More" button, of course). */
413 EINA_INLIST_FOREACH(sd->items, it)
415 evas_object_show(VIEW(it));
416 evas_object_box_append(sd->bx, VIEW(it));
418 evas_object_hide(sd->VIEW(more_item));
421 else if (sd->shrink_mode == ELM_TOOLBAR_SHRINK_HIDE)
423 Evas_Coord iw = 0, ih = 0;
428 _items_visibility_fix(sd, &ih, vh, &more);
433 _items_visibility_fix(sd, &iw, vw, &more);
435 evas_object_box_remove_all(sd->bx, EINA_FALSE);
436 if (((sd->vertical) && (ih > vh)) ||
437 ((!sd->vertical) && (iw > vw)) || more)
439 EINA_INLIST_FOREACH(sd->items, it)
441 if (!it->prio.visible)
442 evas_object_hide(VIEW(it));
445 evas_object_box_append(sd->bx, VIEW(it));
446 evas_object_show(VIEW(it));
452 /* All items are visible, show them all */
453 EINA_INLIST_FOREACH(sd->items, it)
455 evas_object_show(VIEW(it));
456 evas_object_box_append(sd->bx, VIEW(it));
460 else if (sd->shrink_mode == ELM_TOOLBAR_SHRINK_EXPAND)
462 Evas_Coord iw = 0, ih = 0;
465 h = (vh >= mh) ? vh : mh;
467 w = (vw >= mw) ? vw : mw;
470 _items_visibility_fix(sd, &ih, vh, &more);
472 _items_visibility_fix(sd, &iw, vw, &more);
474 evas_object_box_remove_all(sd->bx, EINA_FALSE);
475 evas_object_box_remove_all(sd->bx_more, EINA_FALSE);
476 evas_object_box_remove_all(sd->bx_more2, EINA_FALSE);
478 EINA_INLIST_FOREACH(sd->items, it)
482 evas_object_box_append(it->in_box, VIEW(it));
483 evas_object_show(VIEW(it));
488 evas_object_box_append(sd->bx, sd->VIEW(more_item));
489 evas_object_show(sd->VIEW(more_item));
492 evas_object_hide(sd->VIEW(more_item));
496 if (h > vh) _items_size_fit(obj, &h, vh);
497 if (sd->item_count - sd->separator_count > 0)
498 sd->s_iface->paging_set(obj, 0.0, 0.0, 0, (h / (sd->item_count - sd->separator_count)));
502 if (w > vw) _items_size_fit(obj, &w, vw);
503 if (sd->item_count - sd->separator_count > 0)
504 sd->s_iface->paging_set(obj, 0.0, 0.0, (w / (sd->item_count - sd->separator_count)), 0);
511 if ((vh >= mh) && (h != vh)) h = vh;
515 if ((vw >= mw) && (w != vw)) w = vw;
517 EINA_INLIST_FOREACH(sd->items, it)
527 if (sd->transverse_expanded)
535 evas_object_resize(sd->bx, w, h);
538 list = evas_object_box_children_get(sd->bx);
539 EINA_LIST_FOREACH(list, l, o)
541 if (o == eina_list_nth(list, 0))
542 edje_object_signal_emit(o, "elm,order,first,item", "elm");
543 else if (o == eina_list_nth(list, eina_list_count(list)-1))
544 edje_object_signal_emit(o, "elm,order,last,item", "elm");
546 edje_object_signal_emit(o, "elm,order,default,item", "elm");
550 // Remove the first or last separator since it is not neccessary
551 list = evas_object_box_children_get(sd->bx_more);
552 EINA_INLIST_FOREACH(sd->items, it)
555 ((VIEW(it) == eina_list_data_get(list)) ||
556 (VIEW(it) == eina_list_nth(list, eina_list_count(list) - 1))))
558 evas_object_box_remove(sd->bx_more, VIEW(it));
559 evas_object_move(VIEW(it), -9999, -9999);
560 evas_object_hide(VIEW(it));
563 list = evas_object_box_children_get(sd->bx_more2);
564 EINA_INLIST_FOREACH(sd->items, it)
567 ((VIEW(it) == eina_list_data_get(list)) ||
568 (VIEW(it) == eina_list_nth(list, eina_list_count(list) - 1))))
570 evas_object_box_remove(sd->bx_more2, VIEW(it));
571 evas_object_move(VIEW(it), -9999, -9999);
572 evas_object_hide(VIEW(it));
576 _mirrored_set(obj, elm_widget_mirrored_get(obj));
580 _elm_toolbar_smart_on_focus(Evas_Object *obj)
582 ELM_TOOLBAR_DATA_GET(obj, sd);
584 if (elm_widget_focus_get(obj))
585 evas_object_focus_set(ELM_WIDGET_DATA(sd)->resize_obj, EINA_TRUE);
587 evas_object_focus_set(ELM_WIDGET_DATA(sd)->resize_obj, EINA_FALSE);
593 _elm_toolbar_smart_event(Evas_Object *obj __UNUSED__,
594 Evas_Object *src __UNUSED__,
595 Evas_Callback_Type type __UNUSED__,
598 Evas_Event_Key_Down *ev = event_info;
600 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE;
602 // Key Down Event precess for toolbar.
604 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
610 _resize_cb(void *data,
612 Evas_Object *obj __UNUSED__,
613 void *event_info __UNUSED__)
617 ELM_TOOLBAR_DATA_GET(data, sd);
619 evas_object_geometry_get(data, &x, &y, NULL, &h);
620 evas_object_move(sd->more, x, y + h);
623 sd->resize_job = ecore_job_add(_resize_job, data);
627 _item_disable_hook(Elm_Object_Item *it)
629 Elm_Toolbar_Item *toolbar_it = (Elm_Toolbar_Item *)it;
631 if (elm_widget_item_disabled_get(toolbar_it))
633 edje_object_signal_emit(VIEW(toolbar_it), "elm,state,disabled", "elm");
634 elm_widget_signal_emit(toolbar_it->icon, "elm,state,disabled", "elm");
638 edje_object_signal_emit(VIEW(toolbar_it), "elm,state,enabled", "elm");
639 elm_widget_signal_emit(toolbar_it->icon, "elm,state,enabled", "elm");
642 _resize_cb(WIDGET(toolbar_it), NULL, NULL, NULL);
646 _item_icon_set(Evas_Object *icon_obj,
652 if ((!type) || (!*type)) goto end;
653 if ((!icon) || (!*icon)) return EINA_FALSE;
654 if ((snprintf(icon_str, sizeof(icon_str), "%s%s", type, icon) > 0)
655 && (elm_icon_standard_set(icon_obj, icon_str)))
658 if (elm_icon_standard_set(icon_obj, icon))
661 WRN("couldn't find icon definition for '%s'", icon);
666 _elm_toolbar_icon_size_get(Elm_Toolbar_Smart_Data *sd)
668 const char *icon_size = edje_object_data_get
669 (ELM_WIDGET_DATA(sd)->resize_obj, "icon_size");
671 if (icon_size) return atoi(icon_size);
673 return _elm_config->icon_size;
677 _menu_move_resize_cb(void *data,
679 Evas_Object *obj __UNUSED__,
680 void *event_info __UNUSED__)
682 Elm_Toolbar_Item *it = data;
685 ELM_TOOLBAR_DATA_GET(WIDGET(it), sd);
687 if (!sd->menu_parent) return;
688 evas_object_geometry_get(VIEW(it), &x, &y, NULL, &h);
689 elm_menu_move(it->o_menu, x, y + h);
693 _item_select(Elm_Toolbar_Item *it)
695 Elm_Toolbar_Item *it2;
699 ELM_TOOLBAR_DATA_GET(WIDGET(it), sd);
701 if (elm_widget_item_disabled_get(it) || (it->separator) || (it->object))
705 if (sd->select_mode != ELM_OBJECT_SELECT_MODE_NONE)
709 if (sd->shrink_mode == ELM_TOOLBAR_SHRINK_EXPAND)
711 if (sd->more_item == it)
713 elm_layout_signal_emit
714 (sd->more, "elm,state,close", "elm");
718 if (sd->select_mode != ELM_OBJECT_SELECT_MODE_ALWAYS)
723 it2 = (Elm_Toolbar_Item *)
724 elm_toolbar_selected_item_get(WIDGET(it));
727 it->selected = EINA_TRUE;
728 sd->selected_item = it;
729 if (sd->shrink_mode == ELM_TOOLBAR_SHRINK_EXPAND)
731 if (sd->more_item == it)
733 if (!evas_object_box_children_get(sd->bx_more2))
734 elm_layout_signal_emit
735 (sd->more, "elm,state,open", "elm");
737 elm_layout_signal_emit
738 (sd->more, "elm,state,open2", "elm");
742 if (it->in_box != sd->bx)
744 edje_object_signal_emit
745 (sd->VIEW(more_item), "elm,state,selected",
747 elm_widget_signal_emit
748 (sd->more_item->icon, "elm,state,selected",
753 edje_object_signal_emit
754 (sd->VIEW(more_item), "elm,state,unselected",
756 elm_widget_signal_emit
757 (sd->more_item->icon, "elm,state,unselected",
760 elm_layout_signal_emit
761 (sd->more, "elm,state,close", "elm");
764 edje_object_signal_emit(VIEW(it), "elm,state,selected", "elm");
765 elm_widget_signal_emit(it->icon, "elm,state,selected", "elm");
771 if (it->menu && (!sel))
773 evas_object_show(it->o_menu);
774 evas_object_event_callback_add
775 (VIEW(it), EVAS_CALLBACK_RESIZE, _menu_move_resize_cb, it);
776 evas_object_event_callback_add
777 (VIEW(it), EVAS_CALLBACK_MOVE, _menu_move_resize_cb, it);
779 _menu_move_resize_cb(it, NULL, NULL, NULL);
782 if ((!sel) || (sd->select_mode == ELM_OBJECT_SELECT_MODE_ALWAYS))
784 if (it->func) it->func((void *)(it->base.data), WIDGET(it), it);
786 evas_object_smart_callback_call(obj2, SIG_CLICKED, it);
790 _item_del(Elm_Toolbar_Item *it)
792 Elm_Toolbar_Item_State *it_state;
796 EINA_LIST_FREE(it->states, it_state)
798 if (it->icon == it_state->icon)
800 eina_stringshare_del(it_state->label);
801 eina_stringshare_del(it_state->icon_str);
802 if (it_state->icon) evas_object_del(it_state->icon);
806 eina_stringshare_del(it->label);
808 edje_object_signal_emit(VIEW(it), "elm,state,text,hidden", "elm");
809 eina_stringshare_del(it->icon_str);
813 edje_object_signal_emit(VIEW(it), "elm,state,icon,hidden", "elm");
814 evas_object_del(it->icon);
817 if (it->object) evas_object_del(it->object);
818 //TODO: See if checking for sd->menu_parent is necessary before
820 if (it->o_menu) evas_object_del(it->o_menu);
824 _item_theme_hook(Evas_Object *obj,
825 Elm_Toolbar_Item *it,
829 Evas_Coord mw, mh, minw, minh;
830 Evas_Object *view = VIEW(it);
833 ELM_TOOLBAR_DATA_GET(obj, sd);
835 style = elm_widget_style_get(obj);
837 _item_mirrored_set(obj, it, elm_widget_mirrored_get(obj));
838 edje_object_scale_set(view, scale);
840 if (!it->separator && !it->object)
842 elm_widget_theme_object_set(obj, view, "toolbar", "item", style);
845 edje_object_signal_emit(view, "elm,state,selected", "elm");
846 elm_widget_signal_emit(it->icon, "elm,state,selected", "elm");
848 if (elm_widget_item_disabled_get(it))
850 edje_object_signal_emit(view, "elm,state,disabled", "elm");
851 elm_widget_signal_emit(it->icon, "elm,state,disabled", "elm");
857 ms = ((double)icon_size * scale);
858 evas_object_size_hint_min_set(it->icon, ms, ms);
859 evas_object_size_hint_max_set(it->icon, ms, ms);
860 edje_object_part_swallow(view, "elm.swallow.icon", it->icon);
861 edje_object_signal_emit
862 (VIEW(it), "elm,state,icon,visible", "elm");
866 edje_object_part_text_escaped_set(view, "elm.text", it->label);
867 edje_object_signal_emit(VIEW(it), "elm,state,text,visible", "elm");
874 elm_widget_theme_object_set
875 (obj, view, "toolbar", "separator", style);
878 evas_object_size_hint_weight_set
879 (view, EVAS_HINT_EXPAND, -1.0);
880 evas_object_size_hint_align_set
881 (view, EVAS_HINT_FILL, EVAS_HINT_FILL);
885 evas_object_size_hint_weight_set
886 (view, -1.0, EVAS_HINT_EXPAND);
887 evas_object_size_hint_align_set
888 (view, EVAS_HINT_FILL, EVAS_HINT_FILL);
893 elm_widget_theme_object_set
894 (obj, view, "toolbar", "object", style);
895 edje_object_part_swallow(view, "elm.swallow.object", it->object);
899 mw = mh = minw = minh = -1;
900 if (!it->separator && !it->object)
901 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
903 // If the min size is changed by edje signal in edc,
904 //the below function should be called before the calculation.
905 edje_object_message_signal_process(view);
906 edje_object_size_min_restricted_calc(view, &mw, &mh, mw, mh);
907 if (!it->separator && !it->object)
908 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
909 evas_object_size_hint_min_set(view, mw, mh);
913 _inform_item_number(Evas_Object *obj)
915 ELM_TOOLBAR_DATA_GET(obj, sd);
916 Elm_Toolbar_Item *it;
917 char buf[sizeof("elm,action,click,") + 3];
918 static int scount = 0;
921 EINA_INLIST_FOREACH(sd->items, it)
923 if (!it->separator) count++;
928 sprintf(buf, "elm,number,item,%d", count);
930 EINA_INLIST_FOREACH(sd->items, it)
932 if (!it->separator && !it->object)
933 edje_object_signal_emit(VIEW(it), buf, "elm");
939 _sizing_eval(Evas_Object *obj)
941 Evas_Coord minw = -1, minh = -1, minw_bx = -1, minh_bx = -1;
942 Evas_Coord vw = 0, vh = 0;
945 ELM_TOOLBAR_DATA_GET(obj, sd);
947 evas_object_smart_need_recalculate_set(sd->bx, EINA_TRUE);
948 evas_object_smart_calculate(sd->bx);
949 edje_object_size_min_calc(ELM_WIDGET_DATA(sd)->resize_obj, &minw, &minh);
950 evas_object_geometry_get(obj, NULL, NULL, &w, &h);
952 if (w < minw) w = minw;
953 if (h < minh) h = minh;
955 evas_object_resize(ELM_WIDGET_DATA(sd)->resize_obj, w, h);
957 evas_object_size_hint_min_get(sd->bx, &minw_bx, &minh_bx);
958 sd->s_iface->content_viewport_size_get(obj, &vw, &vh);
960 if (sd->shrink_mode == ELM_TOOLBAR_SHRINK_NONE)
962 minw = minw_bx + (w - vw);
963 minh = minh_bx + (h - vh);
965 else if (sd->shrink_mode == ELM_TOOLBAR_SHRINK_EXPAND)
969 minw = minw_bx + (w - vw);
970 if (minh_bx <= vh) minh_bx = vh;
971 else _items_size_fit(obj, &minh_bx, vh);
975 minh = minh_bx + (h - vh);
976 if (minw_bx <= vw) minw_bx = vw;
977 else _items_size_fit(obj, &minw_bx, vw);
984 minw = minw_bx + (w - vw);
990 minh = minh_bx + (h - vh);
994 if (sd->transverse_expanded)
1002 evas_object_resize(sd->bx, minw_bx, minh_bx);
1003 evas_object_resize(sd->more, minw_bx, minh_bx);
1004 evas_object_size_hint_min_set(obj, minw, minh);
1005 evas_object_size_hint_max_set(obj, -1, -1);
1007 _inform_item_number(obj);
1011 _elm_toolbar_smart_theme(Evas_Object *obj)
1013 Elm_Toolbar_Item *it;
1016 ELM_TOOLBAR_DATA_GET(obj, sd);
1018 if (sd->on_deletion)
1021 if (!ELM_WIDGET_CLASS(_elm_toolbar_parent_sc)->theme(obj))
1024 elm_widget_theme_object_set
1025 (obj, ELM_WIDGET_DATA(sd)->resize_obj, "toolbar", "base",
1026 elm_widget_style_get(obj));
1028 elm_layout_theme_set
1029 (sd->more, "toolbar", "more", elm_widget_style_get(obj));
1031 _mirrored_set(obj, elm_widget_mirrored_get(obj));
1033 sd->theme_icon_size = _elm_toolbar_icon_size_get(sd);
1034 if (sd->priv_icon_size) sd->icon_size = sd->priv_icon_size;
1035 else sd->icon_size = sd->theme_icon_size;
1037 EINA_INLIST_FOREACH(sd->items, it)
1038 _item_theme_hook(obj, it, scale, sd->icon_size);
1041 _item_theme_hook(obj, sd->more_item, scale, sd->icon_size);
1049 _elm_toolbar_item_label_update(Elm_Toolbar_Item *item)
1051 Evas_Coord mw = -1, mh = -1, minw = -1, minh = -1;
1053 ELM_TOOLBAR_DATA_GET(WIDGET(item), sd);
1055 edje_object_part_text_escaped_set(VIEW(item), "elm.text", item->label);
1057 edje_object_signal_emit(VIEW(item), "elm,state,text,visible", "elm");
1059 edje_object_signal_emit(VIEW(item), "elm,state,text,hidden", "elm");
1061 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1062 // If the min size is changed by edje signal in edc,
1063 //the below function should be called before the calculation.
1064 edje_object_message_signal_process(VIEW(item));
1065 edje_object_size_min_restricted_calc(VIEW(item), &mw, &mh, mw, mh);
1066 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1067 if (sd->shrink_mode != ELM_TOOLBAR_SHRINK_EXPAND)
1071 evas_object_size_hint_weight_set
1072 (VIEW(item), EVAS_HINT_EXPAND, -1.0);
1073 evas_object_size_hint_align_set
1074 (VIEW(item), EVAS_HINT_FILL, EVAS_HINT_FILL);
1078 evas_object_size_hint_weight_set
1079 (VIEW(item), -1.0, EVAS_HINT_EXPAND);
1080 evas_object_size_hint_align_set
1081 (VIEW(item), EVAS_HINT_FILL, EVAS_HINT_FILL);
1086 evas_object_size_hint_weight_set
1087 (VIEW(item), EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1088 evas_object_size_hint_align_set
1089 (VIEW(item), EVAS_HINT_FILL, EVAS_HINT_FILL);
1092 evas_object_size_hint_min_get(VIEW(item), &minw, &minh);
1093 if ((minw < mw) && (minh < mh))
1094 evas_object_size_hint_min_set(VIEW(item), mw, mh);
1095 else if ((minw < mw) && (minh > mh))
1096 evas_object_size_hint_min_set(VIEW(item), mw, minh);
1097 else if ((minw > mw) && (minh < mh))
1098 evas_object_size_hint_min_set(VIEW(item), minw, mh);
1102 _elm_toolbar_item_label_set_cb(void *data,
1104 const char *emission,
1107 Elm_Toolbar_Item *item = data;
1109 _elm_toolbar_item_label_update(item);
1110 edje_object_signal_callback_del
1111 (obj, emission, source, _elm_toolbar_item_label_set_cb);
1112 edje_object_signal_emit(VIEW(item), "elm,state,label,reset", "elm");
1116 _item_label_set(Elm_Toolbar_Item *item,
1122 if ((label) && (item->label) && (!strcmp(label, item->label))) return;
1124 eina_stringshare_replace(&item->label, label);
1125 s = edje_object_data_get(VIEW(item), "transition_animation_on");
1126 if ((s) && (atoi(s)))
1128 edje_object_part_text_escaped_set
1129 (VIEW(item), "elm.text_new", item->label);
1130 edje_object_signal_emit(VIEW(item), sig, "elm");
1131 edje_object_signal_callback_add
1132 (VIEW(item), "elm,state,label_set,done", "elm",
1133 _elm_toolbar_item_label_set_cb, item);
1136 _elm_toolbar_item_label_update(item);
1138 _resize_cb(WIDGET(item), NULL, NULL, NULL);
1142 _item_text_set_hook(Elm_Object_Item *it,
1146 Elm_Toolbar_Item *item;
1148 item = (Elm_Toolbar_Item *)it;
1150 if ((!part) || (!strcmp(part, "default")) ||
1151 (!strcmp(part, "elm.text")))
1153 _item_label_set(((Elm_Toolbar_Item *)it), label, "elm,state,label_set");
1159 snprintf(buf, sizeof(buf), "elm,state,%s,visible", part);
1160 edje_object_signal_emit(VIEW(item), buf, "elm");
1164 snprintf(buf, sizeof(buf), "elm,state,%s,hidden", part);
1165 edje_object_signal_emit(VIEW(item), buf, "elm");
1167 edje_object_part_text_escaped_set(VIEW(item), part, label);
1172 _item_text_get_hook(const Elm_Object_Item *it,
1177 if (!part || !strcmp(part, "default"))
1178 snprintf(buf, sizeof(buf), "elm.text");
1180 snprintf(buf, sizeof(buf), "%s", part);
1182 return edje_object_part_text_get(VIEW(it), buf);
1186 _item_content_set_hook(Elm_Object_Item *it,
1188 Evas_Object *content)
1190 Elm_Toolbar_Item *item = (Elm_Toolbar_Item *)it;
1191 Evas_Object *obj = WIDGET(item);
1194 ELM_TOOLBAR_DATA_GET(obj, sd);
1196 if (part && strcmp(part, "object")) return;
1197 if (item->object == content) return;
1199 if (item->object) evas_object_del(item->object);
1201 item->object = content;
1203 elm_widget_sub_object_add(obj, item->object);
1205 scale = (elm_widget_scale_get(obj) * elm_config_scale_get());
1206 _item_theme_hook(obj, item, scale, sd->icon_size);
1209 static Evas_Object *
1210 _item_content_get_hook(const Elm_Object_Item *it,
1213 if (part && strcmp(part, "object")) return NULL;
1214 return ((Elm_Toolbar_Item *)it)->object;
1217 static Evas_Object *
1218 _item_content_unset_hook(Elm_Object_Item *it,
1221 Elm_Toolbar_Item *item = (Elm_Toolbar_Item *)it;
1222 Evas_Object *obj = WIDGET(item);
1226 ELM_TOOLBAR_DATA_GET(obj, sd);
1228 if (part && strcmp(part, "object")) return NULL;
1230 edje_object_part_unswallow(VIEW(it), item->object);
1231 elm_widget_sub_object_del(obj, item->object);
1233 item->object = NULL;
1234 scale = (elm_widget_scale_get(obj) * elm_config_scale_get());
1235 _item_theme_hook(obj, item, scale, sd->icon_size);
1241 _elm_toolbar_smart_translate(Evas_Object *obj)
1243 evas_object_smart_callback_call(obj, SIG_LANG_CHANGED, NULL);
1249 _item_resize(void *data,
1251 Evas_Object *obj __UNUSED__,
1252 void *event_info __UNUSED__)
1255 _resize_cb(data, NULL, NULL, NULL);
1259 _move_cb(void *data,
1261 Evas_Object *obj __UNUSED__,
1262 void *event_info __UNUSED__)
1266 ELM_TOOLBAR_DATA_GET(data, sd);
1267 evas_object_geometry_get(data, &x, &y, NULL, &h);
1268 evas_object_move(sd->more, x, y + h);
1272 _select_filter_cb(Elm_Toolbar_Item *it,
1273 Evas_Object *obj __UNUSED__,
1274 const char *emission,
1275 const char *source __UNUSED__)
1278 char buf[sizeof("elm,action,click,") + 1];
1280 button = atoi(emission + sizeof("mouse,clicked,") - 1);
1281 if (button == 1) return; /* regular left click event */
1282 snprintf(buf, sizeof(buf), "elm,action,click,%d", button);
1283 edje_object_signal_emit(VIEW(it), buf, "elm");
1287 _select_cb(void *data,
1288 Evas_Object *obj __UNUSED__,
1289 const char *emission __UNUSED__,
1290 const char *source __UNUSED__)
1292 Elm_Toolbar_Item *it = data;
1294 if ((_elm_config->access_mode == ELM_ACCESS_MODE_OFF) ||
1295 (_elm_access_2nd_click_timeout(VIEW(it))))
1297 if (_elm_config->access_mode != ELM_ACCESS_MODE_OFF)
1298 _elm_access_say(E_("Selected"));
1304 _item_move_cb(void *data,
1306 Evas_Object *obj __UNUSED__,
1307 void *event_info __UNUSED__)
1309 Elm_Toolbar_Item *item = data;
1311 item->on_move = EINA_FALSE;
1313 evas_object_event_callback_del_full
1314 (VIEW(item), EVAS_CALLBACK_MOVE, _item_move_cb, data);
1318 _items_change(Elm_Toolbar_Item *reorder_from, Elm_Toolbar_Item *reorder_to)
1320 Elm_Toolbar_Item *prev = NULL, *next = NULL;
1323 if (!reorder_from || !reorder_to) return;
1325 ELM_TOOLBAR_DATA_GET(WIDGET(reorder_from), sd);
1326 if (reorder_from == reorder_to) return;
1328 if ((!reorder_from->separator) && (!reorder_to->separator))
1330 prev = ELM_TOOLBAR_ITEM_FROM_INLIST
1331 (EINA_INLIST_GET(reorder_from)->prev);
1332 if (prev == reorder_to)
1333 prev = reorder_from;
1335 next = ELM_TOOLBAR_ITEM_FROM_INLIST
1336 (EINA_INLIST_GET(reorder_from)->next);
1337 if (next == reorder_to)
1340 sd->items = eina_inlist_remove
1341 (sd->items, EINA_INLIST_GET(reorder_from));
1342 sd->items = eina_inlist_append_relative
1343 (sd->items, EINA_INLIST_GET(reorder_from),
1344 EINA_INLIST_GET(reorder_to));
1346 sd->items = eina_inlist_remove
1347 (sd->items, EINA_INLIST_GET(reorder_to));
1349 sd->items = eina_inlist_append_relative
1350 (sd->items, EINA_INLIST_GET(reorder_to),
1351 EINA_INLIST_GET(prev));
1353 sd->items = eina_inlist_prepend_relative
1354 (sd->items, EINA_INLIST_GET(reorder_to),
1355 EINA_INLIST_GET(next));
1357 sd->items = eina_inlist_prepend
1358 (sd->items, EINA_INLIST_GET(reorder_to));
1360 evas_object_box_remove(sd->bx, VIEW(reorder_from));
1361 evas_object_box_insert_after(sd->bx, VIEW(reorder_from),
1363 evas_object_box_remove(sd->bx, VIEW(reorder_to));
1365 evas_object_box_insert_after(sd->bx, VIEW(reorder_to),
1368 evas_object_box_insert_before(sd->bx, VIEW(reorder_to),
1371 evas_object_box_prepend(sd->bx, VIEW(reorder_to));
1373 tmp = reorder_from->prio.priority;
1374 reorder_from->prio.priority = reorder_to->prio.priority;
1375 reorder_to->prio.priority = tmp;
1377 reorder_from->on_move = EINA_TRUE;
1378 reorder_to->on_move = EINA_TRUE;
1380 evas_object_event_callback_add
1381 (VIEW(reorder_from), EVAS_CALLBACK_MOVE,
1382 _item_move_cb, reorder_from);
1383 evas_object_event_callback_add
1384 (VIEW(reorder_to), EVAS_CALLBACK_MOVE,
1385 _item_move_cb, reorder_to);
1388 _resize_cb(WIDGET(reorder_from), NULL, NULL, NULL);
1392 _transit_del_cb(void *data, Elm_Transit *transit __UNUSED__)
1394 Elm_Toolbar_Item *it, *item = data;
1395 ELM_TOOLBAR_DATA_GET(WIDGET(item), sd);
1397 if (item->reorder_to)
1399 if (item->reorder_to == sd->reorder_empty)
1400 sd->reorder_empty = item;
1401 else if (item == sd->reorder_empty)
1402 sd->reorder_empty = item->reorder_to;
1404 _items_change(item->reorder_to, item);
1406 EINA_INLIST_FOREACH(sd->items, it)
1410 if (it->reorder_to == item)
1411 it->reorder_to = item->reorder_to;
1412 else if (it->reorder_to == item->reorder_to)
1413 it->reorder_to = item;
1419 evas_object_image_source_visible_set(elm_image_object_get(item->proxy), EINA_TRUE);
1420 evas_object_del(item->proxy);
1425 if (item->reorder_to)
1427 EINA_INLIST_FOREACH(sd->items, it)
1428 if (it->trans) break;
1430 if (!it) sd->reorder_empty = sd->reorder_item;
1432 item->reorder_to = NULL;
1436 _item_transition_start
1437 (Elm_Toolbar_Item *it, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h)
1440 Evas_Object *obj = WIDGET(it);
1441 ELM_TOOLBAR_DATA_GET(obj, sd);
1443 it->proxy = elm_image_add(obj);
1444 elm_image_aspect_fixed_set(it->proxy, EINA_FALSE);
1445 evas_object_image_source_set(elm_image_object_get(it->proxy), VIEW(it));
1446 evas_object_image_source_visible_set(elm_image_object_get(it->proxy), EINA_FALSE);
1448 it->trans = elm_transit_add();
1449 elm_transit_object_add(it->trans, it->proxy);
1450 evas_object_geometry_get(VIEW(sd->reorder_empty), &tx, &ty, NULL, NULL);
1451 evas_object_move(it->proxy, x, y);
1452 evas_object_resize(it->proxy, w, h);
1453 evas_object_show(it->proxy);
1455 elm_transit_effect_translation_add(it->trans, 0, 0, tx - x, 0);
1456 elm_transit_duration_set(it->trans, 0.3);
1457 elm_transit_del_cb_set(it->trans, _transit_del_cb, it);
1458 elm_transit_go(it->trans);
1460 it->reorder_to = sd->reorder_empty;
1464 _animate_missed_items(Elm_Toolbar_Item *prev, Elm_Toolbar_Item *next)
1466 ELM_TOOLBAR_DATA_GET(WIDGET(prev), sd);
1467 Elm_Toolbar_Item *it, *it2;
1468 Eina_List *list, *l;
1470 Eina_Bool reverse = EINA_FALSE;
1471 Evas_Coord fx, fy, fw, fh;
1473 list = evas_object_box_children_get(sd->bx);
1475 EINA_LIST_FOREACH(list, l, o)
1477 if (o == VIEW(prev))
1479 else if (o == VIEW(next))
1480 reverse = EINA_TRUE;
1484 l = eina_list_next(l);
1486 l = eina_list_prev(l);
1488 while (VIEW(next) != eina_list_data_get(l))
1490 EINA_INLIST_FOREACH(sd->items, it)
1492 if (VIEW(it) == eina_list_data_get(l))
1494 if (!it->trans && it != sd->reorder_item)
1496 evas_object_geometry_get(VIEW(sd->reorder_empty), &fx, &fy, &fw, &fh);
1497 _item_transition_start(it, fx, fy, fw, fh);
1498 sd->reorder_empty = it;
1500 EINA_INLIST_FOREACH(sd->items, it2)
1502 if (it == it2->reorder_to) break;
1506 it2->reorder_to = NULL;
1507 evas_object_geometry_get(it2->proxy, &fx, &fy, &fw, &fh);
1508 if (it2->trans) elm_transit_del(it2->trans);
1509 _item_transition_start(it2, fx, fy, fw, fh);
1510 sd->reorder_empty = it;
1515 l = eina_list_next(l);
1517 l = eina_list_prev(l);
1522 _mouse_move_reorder(Elm_Toolbar_Item *item,
1523 Evas *evas __UNUSED__,
1524 Evas_Object *obj __UNUSED__,
1525 Evas_Event_Mouse_Move *ev)
1527 Evas_Coord x, y, w, h;
1528 Evas_Coord fx, fy, fw, fh;
1529 Elm_Toolbar_Item *it, *it2;
1531 ELM_TOOLBAR_DATA_GET(WIDGET(item), sd);
1533 evas_object_geometry_get(VIEW(item), &x, &y, &w, &h);
1535 evas_object_move(item->proxy, x, ev->cur.canvas.y - (h / 2));
1537 evas_object_move(item->proxy, ev->cur.canvas.x - (w / 2), y);
1538 evas_object_show(item->proxy);
1540 if (sd->reorder_empty->on_move) return;
1542 evas_object_geometry_get(sd->VIEW(reorder_empty), &x, &y, &w, &h);
1543 if (ev->cur.canvas.x < x || ev->cur.canvas.x > x + w)
1545 EINA_INLIST_FOREACH(sd->items, it)
1547 if (it->on_move) continue;
1548 evas_object_geometry_get(VIEW(it), &x, &y, &w, &h);
1549 if (ev->cur.canvas.x > x && ev->cur.canvas.x < x + w) break;
1551 if (it && (it != sd->reorder_empty))
1553 _animate_missed_items(sd->reorder_empty, it);
1554 if (!it->trans && it != item)
1556 evas_object_geometry_get(VIEW(it), &fx, &fy, &fw, &fh);
1557 _item_transition_start(it, fx, fy, fw, fh);
1558 sd->reorder_empty = it;
1560 EINA_INLIST_FOREACH(sd->items, it2)
1562 if (it == it2->reorder_to) break;
1566 it2->reorder_to = NULL;
1567 evas_object_geometry_get(it2->proxy, &fx, &fy, &fw, &fh);
1568 if (it2->trans) elm_transit_del(it2->trans);
1569 _item_transition_start(it2, fx, fy, fw, fh);
1570 sd->reorder_empty = it;
1577 _mouse_up_reorder(Elm_Toolbar_Item *it,
1578 Evas *evas __UNUSED__,
1580 Evas_Event_Mouse_Up *ev __UNUSED__)
1582 ELM_TOOLBAR_DATA_GET(WIDGET(it), sd);
1584 evas_object_event_callback_del_full
1585 (obj, EVAS_CALLBACK_MOUSE_MOVE,
1586 (Evas_Object_Event_Cb)_mouse_move_reorder, it);
1587 evas_object_event_callback_del_full
1588 (sd->more, EVAS_CALLBACK_MOUSE_MOVE,
1589 (Evas_Object_Event_Cb)_mouse_move_reorder, it);
1590 evas_object_event_callback_del_full
1591 (VIEW(it), EVAS_CALLBACK_MOUSE_MOVE,
1592 (Evas_Object_Event_Cb)_mouse_move_reorder, it);
1593 evas_object_event_callback_del_full
1594 (obj, EVAS_CALLBACK_MOUSE_UP,
1595 (Evas_Object_Event_Cb)_mouse_up_reorder, it);
1596 evas_object_event_callback_del_full
1597 (sd->more, EVAS_CALLBACK_MOUSE_UP,
1598 (Evas_Object_Event_Cb)_mouse_up_reorder, it);
1602 evas_object_image_source_visible_set(elm_image_object_get(it->proxy), EINA_TRUE);
1603 evas_object_del(it->proxy);
1606 sd->s_iface->hold_set(obj, EINA_FALSE);
1610 _item_reorder_start(Elm_Toolbar_Item *item)
1612 Evas_Object *obj = WIDGET(item);
1613 Evas_Coord x, y, w, h;
1615 ELM_TOOLBAR_DATA_GET(obj, sd);
1617 sd->reorder_empty = sd->reorder_item = item;
1619 item->proxy = elm_image_add(obj);
1620 elm_image_aspect_fixed_set(item->proxy, EINA_FALSE);
1621 evas_object_image_source_set(elm_image_object_get(item->proxy), VIEW(item));
1622 evas_object_image_source_visible_set(elm_image_object_get(item->proxy), EINA_FALSE);
1623 evas_object_layer_set(item->proxy, 100);
1624 edje_object_signal_emit(VIEW(item), "elm,state,moving", "elm");
1626 evas_object_event_callback_add
1627 (obj, EVAS_CALLBACK_MOUSE_MOVE,
1628 (Evas_Object_Event_Cb)_mouse_move_reorder, item);
1630 evas_object_event_callback_add
1631 (sd->more, EVAS_CALLBACK_MOUSE_MOVE,
1632 (Evas_Object_Event_Cb)_mouse_move_reorder, item);
1634 evas_object_event_callback_add
1635 (item->proxy, EVAS_CALLBACK_MOUSE_MOVE,
1636 (Evas_Object_Event_Cb)_mouse_move_reorder, item);
1638 evas_object_event_callback_add
1639 (obj, EVAS_CALLBACK_MOUSE_UP,
1640 (Evas_Object_Event_Cb)_mouse_up_reorder, item);
1642 evas_object_event_callback_add
1643 (sd->more, EVAS_CALLBACK_MOUSE_UP,
1644 (Evas_Object_Event_Cb)_mouse_up_reorder, item);
1646 evas_object_geometry_get(VIEW(item), &x, &y, &w, &h);
1647 evas_object_resize(item->proxy, w, h);
1648 evas_object_move(item->proxy, x, y);
1649 evas_object_show(item->proxy);
1651 sd->s_iface->hold_set(WIDGET(item), EINA_TRUE);
1655 _long_press_cb(void *data)
1657 Elm_Toolbar_Item *it = data;
1658 ELM_TOOLBAR_DATA_GET(WIDGET(it), sd);
1660 sd->long_timer = NULL;
1661 sd->long_press = EINA_TRUE;
1663 if (sd->reorder_mode)
1664 _item_reorder_start(it);
1666 evas_object_smart_callback_call(WIDGET(it), SIG_LONGPRESSED, it);
1668 return ECORE_CALLBACK_CANCEL;
1672 _drag_start_cb(Evas_Object *obj, void *data __UNUSED__)
1674 ELM_TOOLBAR_DATA_GET(obj, sd);
1678 ecore_timer_del(sd->long_timer);
1679 sd->long_timer = NULL;
1684 _mouse_move_cb(Elm_Toolbar_Item *it,
1685 Evas *evas __UNUSED__,
1686 Evas_Object *obj __UNUSED__,
1687 Evas_Event_Mouse_Move *ev)
1689 Evas_Coord x, y, w, h;
1691 ELM_TOOLBAR_DATA_GET(WIDGET(it), sd);
1692 evas_object_geometry_get(VIEW(it), &x, &y, &w, &h);
1694 if ((sd->long_timer) &&
1695 ((x > ev->cur.canvas.x) || (ev->cur.canvas.x > x + w) ||
1696 (y > ev->cur.canvas.y) || (ev->cur.canvas.y > y + h)))
1698 ecore_timer_del(sd->long_timer);
1699 sd->long_timer = NULL;
1704 _mouse_down_cb(Elm_Toolbar_Item *it,
1705 Evas *evas __UNUSED__,
1706 Evas_Object *obj __UNUSED__,
1707 Evas_Event_Mouse_Down *ev)
1709 ELM_TOOLBAR_DATA_GET(WIDGET(it), sd);
1711 if (ev->button != 1) return;
1712 if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
1713 evas_object_smart_callback_call(WIDGET(it), SIG_CLICKED_DOUBLE, it);
1714 sd->long_press = EINA_FALSE;
1716 ecore_timer_interval_set
1717 (sd->long_timer, _elm_config->longpress_timeout);
1719 sd->long_timer = ecore_timer_add
1720 (_elm_config->longpress_timeout, _long_press_cb, it);
1722 evas_object_event_callback_add(VIEW(it), EVAS_CALLBACK_MOUSE_MOVE,
1723 (Evas_Object_Event_Cb)_mouse_move_cb, it);
1727 _mouse_up_cb(Elm_Toolbar_Item *it,
1728 Evas *evas __UNUSED__,
1729 Evas_Object *obj __UNUSED__,
1730 Evas_Event_Mouse_Up *ev)
1732 ELM_TOOLBAR_DATA_GET(WIDGET(it), sd);
1734 if (ev->button != 1) return;
1737 ecore_timer_del(sd->long_timer);
1738 sd->long_timer = NULL;
1740 evas_object_event_callback_del_full
1741 (VIEW(it), EVAS_CALLBACK_MOUSE_MOVE,
1742 (Evas_Object_Event_Cb)_mouse_move_cb, it);
1746 _mouse_in_cb(void *data,
1747 Evas_Object *obj __UNUSED__,
1748 const char *emission __UNUSED__,
1749 const char *source __UNUSED__)
1751 Elm_Toolbar_Item *it = data;
1753 edje_object_signal_emit(VIEW(it), "elm,state,highlighted", "elm");
1754 elm_widget_signal_emit(it->icon, "elm,state,highlighted", "elm");
1758 _mouse_out_cb(void *data,
1759 Evas_Object *obj __UNUSED__,
1760 const char *emission __UNUSED__,
1761 const char *source __UNUSED__)
1763 Elm_Toolbar_Item *it = data;
1765 edje_object_signal_emit(VIEW(it), "elm,state,unhighlighted", "elm");
1766 elm_widget_signal_emit(it->icon, "elm,state,unhighlighted", "elm");
1770 _layout(Evas_Object *o,
1771 Evas_Object_Box_Data *priv,
1774 Evas_Object *obj = (Evas_Object *)data;
1776 ELM_TOOLBAR_DATA_GET(obj, sd);
1778 (o, priv, !sd->vertical, sd->homogeneous, elm_widget_mirrored_get(obj));
1782 _access_info_cb(void *data, Evas_Object *obj __UNUSED__)
1784 Elm_Toolbar_Item *it = (Elm_Toolbar_Item *)data;
1785 const char *txt = ((Elm_Widget_Item *)it)->access_info;
1787 if (!txt) txt = it->label;
1788 if (txt) return strdup(txt);
1794 _access_state_cb(void *data, Evas_Object *obj __UNUSED__)
1796 Elm_Toolbar_Item *it = (Elm_Toolbar_Item *)data;
1799 return strdup(E_("Separator"));
1800 else if (elm_widget_item_disabled_get(it))
1801 return strdup(E_("State: Disabled"));
1802 else if (it->selected)
1803 return strdup(E_("State: Selected"));
1805 return strdup(E_("Has menu"));
1811 _item_del_pre_hook(Elm_Object_Item *it)
1813 Elm_Toolbar_Item *item, *next = NULL;
1816 item = (Elm_Toolbar_Item *)it;
1818 ELM_TOOLBAR_DATA_GET(WIDGET(item), sd);
1822 if (item != sd->more_item) /* more item does not get in the list */
1824 if (!sd->on_deletion)
1825 next = ELM_TOOLBAR_ITEM_FROM_INLIST(EINA_INLIST_GET(item)->next);
1826 sd->items = eina_inlist_remove(sd->items, EINA_INLIST_GET(item));
1828 if (!sd->on_deletion)
1830 if (!next) next = ELM_TOOLBAR_ITEM_FROM_INLIST(sd->items);
1831 if ((sd->select_mode == ELM_OBJECT_SELECT_MODE_ALWAYS) &&
1832 item->selected && next) _item_select(next);
1838 if (item != sd->more_item)
1839 _elm_toolbar_smart_theme(obj);
1845 _access_activate_cb(void *data __UNUSED__,
1846 Evas_Object *part_obj __UNUSED__,
1847 Elm_Object_Item *item)
1849 Elm_Toolbar_Item *it;
1850 it = (Elm_Toolbar_Item *)item;
1852 if (elm_widget_item_disabled_get(it)) return;
1856 _elm_access_say(E_("Selected"));
1862 _access_widget_item_register(Elm_Toolbar_Item *it)
1864 Elm_Access_Info *ai;
1865 _elm_access_widget_item_register((Elm_Widget_Item *)it);
1866 ai = _elm_access_object_get(it->base.access_obj);
1868 _elm_access_text_set(ai, ELM_ACCESS_TYPE, E_("Toolbar Item"));
1869 _elm_access_callback_set(ai, ELM_ACCESS_INFO, _access_info_cb, it);
1870 _elm_access_callback_set(ai, ELM_ACCESS_STATE, _access_state_cb, it);
1871 _elm_access_activate_callback_set(ai, _access_activate_cb, NULL);
1874 static Elm_Toolbar_Item *
1875 _item_new(Evas_Object *obj,
1881 Evas_Object *icon_obj;
1882 Elm_Toolbar_Item *it;
1885 ELM_TOOLBAR_DATA_GET(obj, sd);
1887 icon_obj = elm_icon_add(obj);
1888 elm_icon_order_lookup_set(icon_obj, sd->lookup_order);
1889 if (!icon_obj) return NULL;
1891 it = elm_widget_item_new(obj, Elm_Toolbar_Item);
1894 evas_object_del(icon_obj);
1898 elm_widget_item_del_pre_hook_set(it, _item_del_pre_hook);
1899 elm_widget_item_disable_hook_set(it, _item_disable_hook);
1900 elm_widget_item_text_set_hook_set(it, _item_text_set_hook);
1901 elm_widget_item_text_get_hook_set(it, _item_text_get_hook);
1902 elm_widget_item_content_set_hook_set(it, _item_content_set_hook);
1903 elm_widget_item_content_get_hook_set(it, _item_content_get_hook);
1904 elm_widget_item_content_unset_hook_set(it, _item_content_unset_hook);
1906 it->label = eina_stringshare_add(label);
1907 it->prio.visible = 1;
1908 it->prio.priority = 0;
1910 it->separator = EINA_FALSE;
1912 it->base.data = data;
1914 VIEW(it) = edje_object_add(evas_object_evas_get(obj));
1916 if (_elm_config->access_mode == ELM_ACCESS_MODE_ON)
1917 _access_widget_item_register(it);
1919 if (_item_icon_set(icon_obj, "toolbar/", icon))
1921 it->icon = icon_obj;
1922 it->icon_str = eina_stringshare_add(icon);
1927 it->icon_str = NULL;
1928 evas_object_del(icon_obj);
1931 elm_widget_theme_object_set
1932 (obj, VIEW(it), "toolbar", "item", elm_widget_style_get(obj));
1933 edje_object_signal_callback_add
1934 (VIEW(it), "elm,action,click", "elm", _select_cb, it);
1935 edje_object_signal_callback_add
1936 (VIEW(it), "mouse,clicked,*", "*", (Edje_Signal_Cb)_select_filter_cb, it);
1937 edje_object_signal_callback_add
1938 (VIEW(it), "elm,mouse,in", "elm", _mouse_in_cb, it);
1939 edje_object_signal_callback_add
1940 (VIEW(it), "elm,mouse,out", "elm", _mouse_out_cb, it);
1941 evas_object_event_callback_add
1942 (VIEW(it), EVAS_CALLBACK_MOUSE_DOWN, (Evas_Object_Event_Cb)_mouse_down_cb,
1944 evas_object_event_callback_add
1945 (VIEW(it), EVAS_CALLBACK_MOUSE_UP, (Evas_Object_Event_Cb)_mouse_up_cb, it);
1946 elm_widget_sub_object_add(obj, VIEW(it));
1952 ms = ((double)sd->icon_size * elm_config_scale_get());
1953 evas_object_size_hint_min_set(it->icon, ms, ms);
1954 evas_object_size_hint_max_set(it->icon, ms, ms);
1955 edje_object_part_swallow(VIEW(it), "elm.swallow.icon", it->icon);
1956 edje_object_signal_emit(VIEW(it), "elm,state,icon,visible", "elm");
1957 evas_object_show(it->icon);
1958 elm_widget_sub_object_add(obj, it->icon);
1962 edje_object_part_text_escaped_set(VIEW(it), "elm.text", it->label);
1963 edje_object_signal_emit(VIEW(it), "elm,state,text,visible", "elm");
1967 if (!it->separator && !it->object)
1968 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1969 // If the min size is changed by edje signal in edc,
1970 //the below function should be called before the calculation.
1971 edje_object_message_signal_process(VIEW(it));
1972 edje_object_size_min_restricted_calc(VIEW(it), &mw, &mh, mw, mh);
1973 if (!it->separator && !it->object)
1974 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
1975 if (sd->shrink_mode != ELM_TOOLBAR_SHRINK_EXPAND)
1979 evas_object_size_hint_weight_set(VIEW(it), EVAS_HINT_EXPAND, -1.0);
1980 evas_object_size_hint_align_set
1981 (VIEW(it), EVAS_HINT_FILL, EVAS_HINT_FILL);
1985 evas_object_size_hint_weight_set(VIEW(it), -1.0, EVAS_HINT_EXPAND);
1986 evas_object_size_hint_align_set
1987 (VIEW(it), EVAS_HINT_FILL, EVAS_HINT_FILL);
1992 evas_object_size_hint_weight_set
1993 (VIEW(it), EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1994 evas_object_size_hint_align_set
1995 (VIEW(it), EVAS_HINT_FILL, EVAS_HINT_FILL);
1998 evas_object_size_hint_min_set(VIEW(it), mw, mh);
1999 evas_object_size_hint_max_set(VIEW(it), -1, -1);
2000 evas_object_event_callback_add
2001 (VIEW(it), EVAS_CALLBACK_RESIZE, _item_resize, obj);
2003 if ((!sd->items) && (sd->select_mode == ELM_OBJECT_SELECT_MODE_ALWAYS))
2009 _elm_toolbar_item_icon_update(Elm_Toolbar_Item *item)
2011 Evas_Coord mw = -1, mh = -1, minw = -1, minh = -1;
2012 Elm_Toolbar_Item_State *it_state;
2013 Evas_Object *old_icon =
2014 edje_object_part_swallow_get(VIEW(item), "elm.swallow.icon");
2017 ELM_TOOLBAR_DATA_GET(WIDGET(item), sd);
2019 elm_widget_sub_object_del(VIEW(item), old_icon);
2020 edje_object_part_swallow(VIEW(item), "elm.swallow.icon", item->icon);
2022 edje_object_signal_emit(VIEW(item), "elm,state,icon,visible", "elm");
2024 edje_object_signal_emit(VIEW(item), "elm,state,icon,hidden", "elm");
2025 evas_object_hide(old_icon);
2026 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
2027 // If the min size is changed by edje signal in edc,
2028 //the below function should be called before the calculation.
2029 edje_object_message_signal_process(VIEW(item));
2030 edje_object_size_min_restricted_calc(VIEW(item), &mw, &mh, mw, mh);
2031 elm_coords_finger_size_adjust(1, &mw, 1, &mh);
2032 if (sd->shrink_mode != ELM_TOOLBAR_SHRINK_EXPAND)
2036 evas_object_size_hint_weight_set
2037 (VIEW(item), EVAS_HINT_EXPAND, -1.0);
2038 evas_object_size_hint_align_set
2039 (VIEW(item), EVAS_HINT_FILL, EVAS_HINT_FILL);
2043 evas_object_size_hint_weight_set
2044 (VIEW(item), -1.0, EVAS_HINT_EXPAND);
2045 evas_object_size_hint_align_set
2046 (VIEW(item), EVAS_HINT_FILL, EVAS_HINT_FILL);
2051 evas_object_size_hint_weight_set
2052 (VIEW(item), EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2053 evas_object_size_hint_align_set
2054 (VIEW(item), EVAS_HINT_FILL, EVAS_HINT_FILL);
2057 evas_object_size_hint_min_get(VIEW(item), &minw, &minh);
2058 if ((minw < mw) && (minh < mh))
2059 evas_object_size_hint_min_set(VIEW(item), mw, mh);
2060 else if ((minw < mw) && (minh > mh))
2061 evas_object_size_hint_min_set(VIEW(item), mw, minh);
2062 else if ((minw > mw) && (minh < mh))
2063 evas_object_size_hint_min_set(VIEW(item), minw, mh);
2065 EINA_LIST_FOREACH(item->states, l, it_state)
2067 if (it_state->icon == old_icon) return;
2069 evas_object_del(old_icon);
2073 _elm_toolbar_item_icon_set_cb(void *data,
2075 const char *emission,
2078 Elm_Toolbar_Item *item = data;
2080 edje_object_part_unswallow(VIEW(item), item->icon);
2081 _elm_toolbar_item_icon_update(item);
2082 edje_object_signal_callback_del
2083 (obj, emission, source, _elm_toolbar_item_icon_set_cb);
2084 edje_object_signal_emit(VIEW(item), "elm,state,icon,reset", "elm");
2088 _elm_toolbar_item_icon_obj_set(Evas_Object *obj,
2089 Elm_Toolbar_Item *item,
2090 Evas_Object *icon_obj,
2091 const char *icon_str,
2095 Evas_Object *old_icon;
2100 eina_stringshare_replace(&item->icon_str, icon_str);
2103 eina_stringshare_del(item->icon_str);
2104 item->icon_str = NULL;
2106 item->icon = icon_obj;
2109 ms = (icon_size * elm_config_scale_get());
2110 evas_object_size_hint_min_set(item->icon, ms, ms);
2111 evas_object_size_hint_max_set(item->icon, ms, ms);
2112 evas_object_show(item->icon);
2113 elm_widget_sub_object_add(obj, item->icon);
2115 s = edje_object_data_get(VIEW(item), "transition_animation_on");
2116 if ((s) && (atoi(s)))
2118 old_icon = edje_object_part_swallow_get
2119 (VIEW(item), "elm.swallow.icon_new");
2122 elm_widget_sub_object_del(VIEW(item), old_icon);
2123 evas_object_hide(old_icon);
2125 edje_object_part_swallow
2126 (VIEW(item), "elm.swallow.icon_new", item->icon);
2127 edje_object_signal_emit(VIEW(item), sig, "elm");
2128 edje_object_signal_callback_add
2129 (VIEW(item), "elm,state,icon_set,done", "elm",
2130 _elm_toolbar_item_icon_set_cb, item);
2133 _elm_toolbar_item_icon_update(item);
2135 _resize_cb(obj, NULL, NULL, NULL);
2139 _elm_toolbar_item_state_cb(void *data __UNUSED__,
2140 Evas_Object *obj __UNUSED__,
2143 Elm_Toolbar_Item *it = event_info;
2144 Elm_Toolbar_Item_State *it_state;
2146 it_state = eina_list_data_get(it->current_state);
2148 it_state->func((void *)it_state->data, obj, event_info);
2151 static Elm_Toolbar_Item_State *
2152 _item_state_new(const char *label,
2153 const char *icon_str,
2158 Elm_Toolbar_Item_State *it_state;
2160 it_state = ELM_NEW(Elm_Toolbar_Item_State);
2161 it_state->label = eina_stringshare_add(label);
2162 it_state->icon_str = eina_stringshare_add(icon_str);
2163 it_state->icon = icon;
2164 it_state->func = func;
2165 it_state->data = data;
2171 _elm_toolbar_action_left_cb(void *data,
2172 Evas_Object *o __UNUSED__,
2173 const char *sig __UNUSED__,
2174 const char *src __UNUSED__)
2176 Evas_Object *obj = data;
2177 Elm_Toolbar_Item *it, *it2;
2178 Eina_Bool done = EINA_FALSE;
2180 ELM_TOOLBAR_DATA_GET(obj, sd);
2182 EINA_INLIST_FOREACH(sd->items, it)
2186 Eina_Bool found = EINA_FALSE;
2188 EINA_INLIST_REVERSE_FOREACH(sd->items, it2)
2190 if (elm_object_item_disabled_get((Elm_Object_Item *)it2))
2197 if (!found) continue;
2198 if (it2->separator) continue;
2209 EINA_INLIST_FOREACH(sd->items, it)
2211 if (elm_object_item_disabled_get((Elm_Object_Item *)it)) continue;
2212 if (it->separator) continue;
2220 _elm_toolbar_action_right_cb(void *data,
2221 Evas_Object *o __UNUSED__,
2222 const char *sig __UNUSED__,
2223 const char *src __UNUSED__)
2225 Evas_Object *obj = data;
2226 Elm_Toolbar_Item *it, *it2;
2227 Eina_Bool done = EINA_FALSE;
2229 ELM_TOOLBAR_DATA_GET(obj, sd);
2231 EINA_INLIST_FOREACH(sd->items, it)
2235 Eina_Bool found = EINA_FALSE;
2237 EINA_INLIST_FOREACH(sd->items, it2)
2239 if (elm_object_item_disabled_get((Elm_Object_Item *)it2))
2246 if (!found) continue;
2247 if (it2->separator) continue;
2258 EINA_INLIST_REVERSE_FOREACH(sd->items, it)
2260 if (elm_object_item_disabled_get((Elm_Object_Item *)it)) continue;
2261 if (it->separator) continue;
2269 _elm_toolbar_action_up_cb(void *data,
2274 _elm_toolbar_action_left_cb(data, o, sig, src);
2278 _elm_toolbar_action_down_cb(void *data,
2283 _elm_toolbar_action_right_cb(data, o, sig, src);
2287 _elm_toolbar_smart_add(Evas_Object *obj)
2289 EVAS_SMART_DATA_ALLOC(obj, Elm_Toolbar_Smart_Data);
2291 ELM_WIDGET_DATA(priv)->resize_obj =
2292 edje_object_add(evas_object_evas_get(obj));
2294 ELM_WIDGET_CLASS(_elm_toolbar_parent_sc)->base.add(obj);
2296 elm_widget_theme_object_set
2297 (obj, ELM_WIDGET_DATA(priv)->resize_obj, "toolbar", "base",
2298 elm_widget_style_get(obj));
2300 priv->hit_rect = evas_object_rectangle_add(evas_object_evas_get(obj));
2301 evas_object_smart_member_add(priv->hit_rect, obj);
2302 elm_widget_sub_object_add(obj, priv->hit_rect);
2304 /* common scroller hit rectangle setup */
2305 evas_object_color_set(priv->hit_rect, 0, 0, 0, 0);
2306 evas_object_show(priv->hit_rect);
2307 evas_object_repeat_events_set(priv->hit_rect, EINA_TRUE);
2309 elm_widget_can_focus_set(obj, EINA_TRUE);
2311 priv->s_iface = evas_object_smart_interface_get
2312 (obj, ELM_SCROLLABLE_IFACE_NAME);
2314 priv->s_iface->objects_set
2315 (obj, ELM_WIDGET_DATA(priv)->resize_obj, priv->hit_rect);
2317 priv->more_item = NULL;
2318 priv->selected_item = NULL;
2319 priv->standard_priority = -99999;
2321 priv->s_iface->bounce_allow_set
2322 (obj, _elm_config->thumbscroll_bounce_enable, EINA_FALSE);
2323 priv->s_iface->policy_set
2324 (obj, ELM_SCROLLER_POLICY_AUTO, ELM_SCROLLER_POLICY_OFF);
2325 priv->s_iface->drag_start_cb_set(obj, _drag_start_cb);
2327 edje_object_signal_callback_add
2328 (ELM_WIDGET_DATA(priv)->resize_obj, "elm,action,left", "elm",
2329 _elm_toolbar_action_left_cb, obj);
2330 edje_object_signal_callback_add
2331 (ELM_WIDGET_DATA(priv)->resize_obj, "elm,action,right", "elm",
2332 _elm_toolbar_action_right_cb, obj);
2333 edje_object_signal_callback_add
2334 (ELM_WIDGET_DATA(priv)->resize_obj, "elm,action,up", "elm",
2335 _elm_toolbar_action_up_cb, obj);
2336 edje_object_signal_callback_add
2337 (ELM_WIDGET_DATA(priv)->resize_obj, "elm,action,down", "elm",
2338 _elm_toolbar_action_down_cb, obj);
2340 priv->shrink_mode = ELM_TOOLBAR_SHRINK_NONE;
2341 priv->priv_icon_size = 0; // unset
2342 priv->theme_icon_size = _elm_toolbar_icon_size_get(priv);
2343 if (priv->priv_icon_size) priv->icon_size = priv->priv_icon_size;
2344 else priv->icon_size = priv->theme_icon_size;
2346 priv->homogeneous = EINA_TRUE;
2349 priv->bx = evas_object_box_add(evas_object_evas_get(obj));
2350 evas_object_size_hint_align_set(priv->bx, priv->align, 0.5);
2351 evas_object_box_layout_set(priv->bx, _layout, obj, NULL);
2352 elm_widget_sub_object_add(obj, priv->bx);
2353 priv->s_iface->content_set(obj, priv->bx);
2354 evas_object_show(priv->bx);
2356 priv->more = elm_layout_add(obj);
2357 elm_layout_theme_set(priv->more, "toolbar", "more", "default");
2358 elm_widget_sub_object_add(obj, priv->more);
2359 evas_object_show(priv->more);
2361 priv->bx_more = evas_object_box_add(evas_object_evas_get(obj));
2362 evas_object_size_hint_align_set(priv->bx_more, priv->align, 0.5);
2363 evas_object_box_layout_set(priv->bx_more, _layout, obj, NULL);
2364 elm_widget_sub_object_add(obj, priv->bx_more);
2365 elm_layout_content_set
2366 (priv->more, "elm.swallow.content", priv->bx_more);
2367 evas_object_show(priv->bx_more);
2369 priv->bx_more2 = evas_object_box_add(evas_object_evas_get(obj));
2370 evas_object_size_hint_align_set(priv->bx_more2, priv->align, 0.5);
2371 evas_object_box_layout_set(priv->bx_more2, _layout, obj, NULL);
2372 elm_widget_sub_object_add(obj, priv->bx_more2);
2373 elm_layout_content_set
2374 (priv->more, "elm.swallow.content2", priv->bx_more2);
2375 evas_object_show(priv->bx_more2);
2377 elm_toolbar_shrink_mode_set(obj, _elm_config->toolbar_shrink_mode);
2378 evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE, _resize_cb, obj);
2379 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOVE, _move_cb, obj);
2380 evas_object_event_callback_add
2381 (priv->bx, EVAS_CALLBACK_RESIZE, _resize_cb, obj);
2382 elm_toolbar_icon_order_lookup_set(obj, ELM_ICON_LOOKUP_THEME_FDO);
2388 _elm_toolbar_smart_del(Evas_Object *obj)
2390 Elm_Toolbar_Item *it, *next;
2392 ELM_TOOLBAR_DATA_GET(obj, sd);
2394 sd->on_deletion = EINA_TRUE;
2397 ecore_job_del(sd->resize_job);
2399 sd->resize_job = NULL;
2401 it = ELM_TOOLBAR_ITEM_FROM_INLIST(sd->items);
2404 next = ELM_TOOLBAR_ITEM_FROM_INLIST(EINA_INLIST_GET(it)->next);
2405 elm_widget_item_del(it);
2410 elm_widget_item_del(sd->more_item);
2411 sd->more_item = NULL;
2415 ecore_timer_del(sd->long_timer);
2416 sd->long_timer = NULL;
2419 ELM_WIDGET_CLASS(_elm_toolbar_parent_sc)->base.del(obj);
2423 _elm_toolbar_smart_move(Evas_Object *obj,
2427 ELM_TOOLBAR_DATA_GET(obj, sd);
2429 ELM_WIDGET_CLASS(_elm_toolbar_parent_sc)->base.move(obj, x, y);
2431 evas_object_move(sd->hit_rect, x, y);
2435 _elm_toolbar_smart_resize(Evas_Object *obj,
2439 ELM_TOOLBAR_DATA_GET(obj, sd);
2441 ELM_WIDGET_CLASS(_elm_toolbar_parent_sc)->base.resize(obj, w, h);
2443 evas_object_resize(sd->hit_rect, w, h);
2447 _elm_toolbar_smart_member_add(Evas_Object *obj,
2448 Evas_Object *member)
2450 ELM_TOOLBAR_DATA_GET(obj, sd);
2452 ELM_WIDGET_CLASS(_elm_toolbar_parent_sc)->base.member_add(obj, member);
2455 evas_object_raise(sd->hit_rect);
2459 _access_item_find_append(const Evas_Object *obj,
2463 Elm_Toolbar_Item *it;
2466 ELM_TOOLBAR_DATA_GET(obj, sd);
2468 list = evas_object_box_children_get(bx);
2469 if (!list) return items;
2471 EINA_INLIST_FOREACH (sd->items, it)
2473 if (it->separator) continue;
2474 if (eina_list_data_find(list, it->base.view))
2475 items = eina_list_append(items, it->base.access_obj);
2482 _elm_toolbar_smart_focus_next(const Evas_Object *obj,
2483 Elm_Focus_Direction dir,
2486 Eina_List *items = NULL;
2488 ELM_TOOLBAR_DATA_GET(obj, sd);
2490 if (sd->more_item && sd->more_item->selected)
2492 items = _access_item_find_append(obj, sd->bx_more, items);
2493 items = _access_item_find_append(obj, sd->bx_more2, items);
2494 items = eina_list_append(items, sd->more_item->base.access_obj);
2498 items = _access_item_find_append(obj, sd->bx, items);
2499 if (sd->more_item &&
2500 eina_list_data_find(evas_object_box_children_get(sd->bx),
2501 sd->more_item->base.view))
2502 items = eina_list_append(items, sd->more_item->base.access_obj);
2505 return elm_widget_focus_list_next_get
2506 (obj, items, eina_list_data_get, dir, next);
2510 _access_obj_process(Elm_Toolbar_Smart_Data * sd, Eina_Bool is_access)
2512 Elm_Toolbar_Item *it;
2514 EINA_INLIST_FOREACH (sd->items, it)
2516 if (is_access) _access_widget_item_register(it);
2517 else _elm_access_widget_item_unregister((Elm_Widget_Item *)it);
2522 _elm_toolbar_smart_access(Evas_Object *obj, Eina_Bool is_access)
2524 ELM_TOOLBAR_CHECK(obj);
2525 ELM_TOOLBAR_DATA_GET(obj, sd);
2528 ELM_WIDGET_CLASS(ELM_WIDGET_DATA(sd)->api)->focus_next =
2529 _elm_toolbar_smart_focus_next;
2531 ELM_WIDGET_CLASS(ELM_WIDGET_DATA(sd)->api)->focus_next = NULL;
2532 _access_obj_process(sd, is_access);
2536 _elm_toolbar_smart_set_user(Elm_Toolbar_Smart_Class *sc)
2538 ELM_WIDGET_CLASS(sc)->base.add = _elm_toolbar_smart_add;
2539 ELM_WIDGET_CLASS(sc)->base.del = _elm_toolbar_smart_del;
2540 ELM_WIDGET_CLASS(sc)->base.move = _elm_toolbar_smart_move;
2541 ELM_WIDGET_CLASS(sc)->base.resize = _elm_toolbar_smart_resize;
2542 ELM_WIDGET_CLASS(sc)->base.member_add = _elm_toolbar_smart_member_add;
2544 ELM_WIDGET_CLASS(sc)->on_focus = _elm_toolbar_smart_on_focus;
2545 ELM_WIDGET_CLASS(sc)->event = _elm_toolbar_smart_event;
2546 ELM_WIDGET_CLASS(sc)->theme = _elm_toolbar_smart_theme;
2547 ELM_WIDGET_CLASS(sc)->translate = _elm_toolbar_smart_translate;
2549 if (_elm_config->access_mode != ELM_ACCESS_MODE_OFF)
2550 ELM_WIDGET_CLASS(sc)->focus_next = _elm_toolbar_smart_focus_next;
2552 ELM_WIDGET_CLASS(sc)->access = _elm_toolbar_smart_access;
2555 EAPI const Elm_Toolbar_Smart_Class *
2556 elm_toolbar_smart_class_get(void)
2558 static Elm_Toolbar_Smart_Class _sc =
2559 ELM_TOOLBAR_SMART_CLASS_INIT_NAME_VERSION(ELM_TOOLBAR_SMART_NAME);
2560 static const Elm_Toolbar_Smart_Class *class = NULL;
2561 Evas_Smart_Class *esc = (Evas_Smart_Class *)&_sc;
2566 _elm_toolbar_smart_set(&_sc);
2567 esc->callbacks = _smart_callbacks;
2574 elm_toolbar_add(Evas_Object *parent)
2578 EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL);
2580 obj = elm_widget_add(_elm_toolbar_smart_class_new(), parent);
2581 if (!obj) return NULL;
2583 if (!elm_widget_sub_object_add(parent, obj))
2584 ERR("could not add %p as sub object of %p", obj, parent);
2590 elm_toolbar_icon_size_set(Evas_Object *obj,
2593 ELM_TOOLBAR_CHECK(obj);
2594 ELM_TOOLBAR_DATA_GET(obj, sd);
2596 if (sd->priv_icon_size == icon_size) return;
2597 sd->priv_icon_size = icon_size;
2599 if (sd->priv_icon_size) sd->icon_size = sd->priv_icon_size;
2600 else sd->icon_size = sd->theme_icon_size;
2602 _elm_toolbar_smart_theme(obj);
2606 elm_toolbar_icon_size_get(const Evas_Object *obj)
2608 ELM_TOOLBAR_CHECK(obj) 0;
2609 ELM_TOOLBAR_DATA_GET(obj, sd);
2611 return sd->priv_icon_size;
2614 EAPI Elm_Object_Item *
2615 elm_toolbar_item_append(Evas_Object *obj,
2621 Elm_Toolbar_Item *it;
2624 ELM_TOOLBAR_CHECK(obj) NULL;
2625 ELM_TOOLBAR_DATA_GET(obj, sd);
2627 it = _item_new(obj, icon, label, func, data);
2628 if (!it) return NULL;
2629 scale = (elm_widget_scale_get(obj) * elm_config_scale_get());
2631 sd->items = eina_inlist_append(sd->items, EINA_INLIST_GET(it));
2632 evas_object_box_append(sd->bx, VIEW(it));
2633 evas_object_show(VIEW(it));
2635 _item_theme_hook(obj, it, scale, sd->icon_size);
2639 return (Elm_Object_Item *)it;
2642 EAPI Elm_Object_Item *
2643 elm_toolbar_item_prepend(Evas_Object *obj,
2649 Elm_Toolbar_Item *it;
2652 ELM_TOOLBAR_CHECK(obj) NULL;
2653 ELM_TOOLBAR_DATA_GET(obj, sd);
2655 it = _item_new(obj, icon, label, func, data);
2656 if (!it) return NULL;
2657 scale = (elm_widget_scale_get(obj) * elm_config_scale_get());
2659 sd->items = eina_inlist_prepend(sd->items, EINA_INLIST_GET(it));
2660 evas_object_box_prepend(sd->bx, VIEW(it));
2661 evas_object_show(VIEW(it));
2662 _item_theme_hook(obj, it, scale, sd->icon_size);
2666 return (Elm_Object_Item *)it;
2669 EAPI Elm_Object_Item *
2670 elm_toolbar_item_insert_before(Evas_Object *obj,
2671 Elm_Object_Item *before,
2677 Elm_Toolbar_Item *it, *_before;
2680 ELM_TOOLBAR_CHECK(obj) NULL;
2681 ELM_TOOLBAR_ITEM_CHECK_OR_RETURN(before, NULL);
2682 ELM_TOOLBAR_DATA_GET(obj, sd);
2684 _before = (Elm_Toolbar_Item *)before;
2685 it = _item_new(obj, icon, label, func, data);
2686 if (!it) return NULL;
2687 scale = (elm_widget_scale_get(obj) * elm_config_scale_get());
2689 sd->items = eina_inlist_prepend_relative
2690 (sd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(_before));
2691 evas_object_box_insert_before(sd->bx, VIEW(it), VIEW(_before));
2692 evas_object_show(VIEW(it));
2693 _item_theme_hook(obj, it, scale, sd->icon_size);
2697 return (Elm_Object_Item *)it;
2700 EAPI Elm_Object_Item *
2701 elm_toolbar_item_insert_after(Evas_Object *obj,
2702 Elm_Object_Item *after,
2708 Elm_Toolbar_Item *it, *_after;
2711 ELM_TOOLBAR_CHECK(obj) NULL;
2712 ELM_TOOLBAR_ITEM_CHECK_OR_RETURN(after, NULL);
2714 ELM_TOOLBAR_DATA_GET(obj, sd);
2715 _after = (Elm_Toolbar_Item *)after;
2716 it = _item_new(obj, icon, label, func, data);
2717 if (!it) return NULL;
2718 scale = (elm_widget_scale_get(obj) * elm_config_scale_get());
2720 sd->items = eina_inlist_append_relative
2721 (sd->items, EINA_INLIST_GET(it), EINA_INLIST_GET(_after));
2722 evas_object_box_insert_after(sd->bx, VIEW(it), VIEW(_after));
2723 evas_object_show(VIEW(it));
2724 _item_theme_hook(obj, it, scale, sd->icon_size);
2728 return (Elm_Object_Item *)it;
2731 EAPI Elm_Object_Item *
2732 elm_toolbar_first_item_get(const Evas_Object *obj)
2734 ELM_TOOLBAR_CHECK(obj) NULL;
2735 ELM_TOOLBAR_DATA_GET(obj, sd);
2737 if (!sd->items) return NULL;
2738 return (Elm_Object_Item *)ELM_TOOLBAR_ITEM_FROM_INLIST(sd->items);
2741 EAPI Elm_Object_Item *
2742 elm_toolbar_last_item_get(const Evas_Object *obj)
2744 ELM_TOOLBAR_CHECK(obj) NULL;
2745 ELM_TOOLBAR_DATA_GET(obj, sd);
2747 if (!sd->items) return NULL;
2749 return (Elm_Object_Item *)ELM_TOOLBAR_ITEM_FROM_INLIST(sd->items->last);
2752 EAPI Elm_Object_Item *
2753 elm_toolbar_item_next_get(const Elm_Object_Item *it)
2755 ELM_TOOLBAR_ITEM_CHECK_OR_RETURN(it, NULL);
2757 return (Elm_Object_Item *)ELM_TOOLBAR_ITEM_FROM_INLIST(
2758 EINA_INLIST_GET(((Elm_Toolbar_Item *)it))->next);
2761 EAPI Elm_Object_Item *
2762 elm_toolbar_item_prev_get(const Elm_Object_Item *it)
2764 ELM_TOOLBAR_ITEM_CHECK_OR_RETURN(it, NULL);
2766 return (Elm_Object_Item *)ELM_TOOLBAR_ITEM_FROM_INLIST(
2767 EINA_INLIST_GET(((Elm_Toolbar_Item *)it))->prev);
2771 elm_toolbar_item_priority_set(Elm_Object_Item *it,
2774 Elm_Toolbar_Item *item = (Elm_Toolbar_Item *)it;
2776 ELM_TOOLBAR_ITEM_CHECK_OR_RETURN(it);
2778 if (item->prio.priority == priority) return;
2779 item->prio.priority = priority;
2780 _resize_cb(WIDGET(item), NULL, NULL, NULL);
2784 elm_toolbar_item_priority_get(const Elm_Object_Item *it)
2786 ELM_TOOLBAR_ITEM_CHECK_OR_RETURN(it, 0);
2788 return ((Elm_Toolbar_Item *)it)->prio.priority;
2791 EAPI Elm_Object_Item *
2792 elm_toolbar_item_find_by_label(const Evas_Object *obj,
2795 Elm_Toolbar_Item *it;
2797 ELM_TOOLBAR_CHECK(obj) NULL;
2798 ELM_TOOLBAR_DATA_GET(obj, sd);
2800 EINA_INLIST_FOREACH(sd->items, it)
2802 if (!strcmp(it->label, label))
2803 return (Elm_Object_Item *)it;
2810 elm_toolbar_item_selected_set(Elm_Object_Item *it,
2813 Elm_Toolbar_Item *item = (Elm_Toolbar_Item *)it;
2815 ELM_TOOLBAR_ITEM_CHECK_OR_RETURN(it);
2817 if (item->selected == selected) return;
2818 if (selected) _item_select(item);
2819 else _item_unselect(item);
2823 elm_toolbar_item_selected_get(const Elm_Object_Item *it)
2825 ELM_TOOLBAR_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
2827 return ((Elm_Toolbar_Item *)it)->selected;
2830 EAPI Elm_Object_Item *
2831 elm_toolbar_selected_item_get(const Evas_Object *obj)
2833 ELM_TOOLBAR_CHECK(obj) NULL;
2834 ELM_TOOLBAR_DATA_GET(obj, sd);
2836 return (Elm_Object_Item *)sd->selected_item;
2839 EAPI Elm_Object_Item *
2840 elm_toolbar_more_item_get(const Evas_Object *obj)
2842 ELM_TOOLBAR_CHECK(obj) NULL;
2843 ELM_TOOLBAR_DATA_GET(obj, sd);
2845 return (Elm_Object_Item *)sd->more_item;
2849 elm_toolbar_item_icon_set(Elm_Object_Item *it,
2853 Evas_Object *icon_obj;
2854 Elm_Toolbar_Item *item = (Elm_Toolbar_Item *)it;
2856 ELM_TOOLBAR_ITEM_CHECK_OR_RETURN(it);
2859 ELM_TOOLBAR_DATA_GET(obj, sd);
2860 if ((icon) && (item->icon_str) && (!strcmp(icon, item->icon_str))) return;
2862 icon_obj = elm_icon_add(obj);
2863 if (!icon_obj) return;
2864 if (_item_icon_set(icon_obj, "toolbar/", icon))
2865 _elm_toolbar_item_icon_obj_set
2866 (obj, item, icon_obj, icon, sd->icon_size, "elm,state,icon_set");
2869 _elm_toolbar_item_icon_obj_set
2870 (obj, item, NULL, NULL, 0, "elm,state,icon_set");
2871 evas_object_del(icon_obj);
2876 elm_toolbar_item_icon_get(const Elm_Object_Item *it)
2878 ELM_TOOLBAR_ITEM_CHECK_OR_RETURN(it, NULL);
2880 return ((Elm_Toolbar_Item *)it)->icon_str;
2884 elm_toolbar_item_object_get(const Elm_Object_Item *it)
2886 Elm_Toolbar_Item *item = (Elm_Toolbar_Item *)it;
2888 ELM_TOOLBAR_ITEM_CHECK_OR_RETURN(it, NULL);
2894 elm_toolbar_item_icon_object_get(Elm_Object_Item *it)
2896 ELM_TOOLBAR_ITEM_CHECK_OR_RETURN(it, NULL);
2898 return ((Elm_Toolbar_Item *)it)->icon;
2902 elm_toolbar_item_icon_memfile_set(Elm_Object_Item *it,
2908 Elm_Toolbar_Item *item = (Elm_Toolbar_Item *)it;
2909 Evas_Object *icon_obj;
2913 ELM_TOOLBAR_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
2916 ELM_TOOLBAR_DATA_GET(obj, sd);
2920 icon_obj = elm_icon_add(obj);
2921 evas_object_repeat_events_set(icon_obj, EINA_TRUE);
2922 ret = elm_image_memfile_set(icon_obj, img, size, format, key);
2925 evas_object_del(icon_obj);
2928 _elm_toolbar_item_icon_obj_set
2929 (obj, item, icon_obj, NULL, sd->icon_size, "elm,state,icon_set");
2932 _elm_toolbar_item_icon_obj_set
2933 (obj, item, NULL, NULL, 0, "elm,state,icon_set");
2938 elm_toolbar_item_icon_file_set(Elm_Object_Item *it,
2942 Elm_Toolbar_Item *item = (Elm_Toolbar_Item *)it;
2943 Evas_Object *icon_obj;
2947 ELM_TOOLBAR_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
2950 ELM_TOOLBAR_DATA_GET(obj, sd);
2954 icon_obj = elm_icon_add(obj);
2955 evas_object_repeat_events_set(icon_obj, EINA_TRUE);
2956 ret = elm_image_file_set(icon_obj, file, key);
2959 evas_object_del(icon_obj);
2962 _elm_toolbar_item_icon_obj_set
2963 (obj, item, icon_obj, NULL, sd->icon_size, "elm,state,icon_set");
2966 _elm_toolbar_item_icon_obj_set
2967 (obj, item, NULL, NULL, 0, "elm,state,icon_set");
2972 elm_toolbar_item_separator_set(Elm_Object_Item *it,
2973 Eina_Bool separator)
2975 Elm_Toolbar_Item *item = (Elm_Toolbar_Item *)it;
2976 Evas_Object *obj = WIDGET(item);
2979 ELM_TOOLBAR_ITEM_CHECK_OR_RETURN(it);
2980 ELM_TOOLBAR_DATA_GET(obj, sd);
2982 if (item->separator == separator) return;
2983 item->separator = separator;
2984 scale = (elm_widget_scale_get(obj) * elm_config_scale_get());
2985 _item_theme_hook(obj, item, scale, sd->icon_size);
2986 evas_object_size_hint_min_set(VIEW(item), -1, -1);
2987 if (separator) sd->separator_count++;
2988 else sd->separator_count--;
2992 elm_toolbar_item_separator_get(const Elm_Object_Item *it)
2994 ELM_TOOLBAR_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
2996 return ((Elm_Toolbar_Item *)it)->separator;
3000 elm_toolbar_shrink_mode_set(Evas_Object *obj,
3001 Elm_Toolbar_Shrink_Mode shrink_mode)
3005 ELM_TOOLBAR_CHECK(obj);
3006 ELM_TOOLBAR_DATA_GET(obj, sd);
3008 if (sd->shrink_mode == shrink_mode) return;
3009 sd->shrink_mode = shrink_mode;
3010 bounce = (_elm_config->thumbscroll_bounce_enable) &&
3011 (shrink_mode == ELM_TOOLBAR_SHRINK_SCROLL);
3012 sd->s_iface->bounce_allow_set(obj, bounce, EINA_FALSE);
3016 elm_widget_item_del(sd->more_item);
3017 sd->more_item = NULL;
3020 if (shrink_mode == ELM_TOOLBAR_SHRINK_MENU)
3022 elm_toolbar_homogeneous_set(obj, EINA_FALSE);
3023 sd->s_iface->policy_set
3024 (obj, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
3025 sd->more_item = _item_new(obj, "more_menu", "More", NULL, NULL);
3027 else if (shrink_mode == ELM_TOOLBAR_SHRINK_HIDE)
3029 elm_toolbar_homogeneous_set(obj, EINA_FALSE);
3030 sd->s_iface->policy_set
3031 (obj, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
3033 else if (shrink_mode == ELM_TOOLBAR_SHRINK_EXPAND)
3035 elm_toolbar_homogeneous_set(obj, EINA_FALSE);
3036 sd->s_iface->policy_set
3037 (obj, ELM_SCROLLER_POLICY_AUTO, ELM_SCROLLER_POLICY_OFF);
3038 sd->more_item = _item_new(obj, "more_menu", "More", NULL, NULL);
3041 sd->s_iface->policy_set
3042 (obj, ELM_SCROLLER_POLICY_AUTO, ELM_SCROLLER_POLICY_OFF);
3047 EAPI Elm_Toolbar_Shrink_Mode
3048 elm_toolbar_shrink_mode_get(const Evas_Object *obj)
3050 ELM_TOOLBAR_CHECK(obj) ELM_TOOLBAR_SHRINK_NONE;
3051 ELM_TOOLBAR_DATA_GET(obj, sd);
3053 return sd->shrink_mode;
3057 elm_toolbar_transverse_expanded_set(Evas_Object *obj, Eina_Bool transverse_expanded)
3059 ELM_TOOLBAR_CHECK(obj);
3060 ELM_TOOLBAR_DATA_GET(obj, sd);
3062 if (sd->transverse_expanded == transverse_expanded) return;
3063 sd->transverse_expanded = transverse_expanded;
3069 elm_toolbar_transverse_expanded_get(const Evas_Object *obj)
3071 ELM_TOOLBAR_CHECK(obj) EINA_FALSE;
3072 ELM_TOOLBAR_DATA_GET(obj, sd);
3074 return sd->transverse_expanded;
3078 elm_toolbar_homogeneous_set(Evas_Object *obj,
3079 Eina_Bool homogeneous)
3081 ELM_TOOLBAR_CHECK(obj);
3082 ELM_TOOLBAR_DATA_GET(obj, sd);
3084 homogeneous = !!homogeneous;
3085 if (homogeneous == sd->homogeneous) return;
3086 sd->homogeneous = homogeneous;
3087 if (homogeneous) elm_toolbar_shrink_mode_set(obj, ELM_TOOLBAR_SHRINK_NONE);
3088 evas_object_smart_calculate(sd->bx);
3092 elm_toolbar_homogeneous_get(const Evas_Object *obj)
3094 ELM_TOOLBAR_CHECK(obj) EINA_FALSE;
3095 ELM_TOOLBAR_DATA_GET(obj, sd);
3097 return sd->homogeneous;
3101 elm_toolbar_menu_parent_set(Evas_Object *obj,
3102 Evas_Object *parent)
3104 Elm_Toolbar_Item *it;
3106 ELM_TOOLBAR_CHECK(obj);
3107 ELM_TOOLBAR_DATA_GET(obj, sd);
3108 EINA_SAFETY_ON_NULL_RETURN(parent);
3110 sd->menu_parent = parent;
3111 EINA_INLIST_FOREACH(sd->items, it)
3114 elm_menu_parent_set(it->o_menu, sd->menu_parent);
3116 if ((sd->more_item) && (sd->more_item->o_menu))
3117 elm_menu_parent_set(sd->more_item->o_menu, sd->menu_parent);
3121 elm_toolbar_menu_parent_get(const Evas_Object *obj)
3123 ELM_TOOLBAR_CHECK(obj) NULL;
3124 ELM_TOOLBAR_DATA_GET(obj, sd);
3126 return sd->menu_parent;
3130 elm_toolbar_align_set(Evas_Object *obj,
3133 ELM_TOOLBAR_CHECK(obj);
3134 ELM_TOOLBAR_DATA_GET(obj, sd);
3138 if (sd->align != align)
3139 evas_object_size_hint_align_set(sd->bx, 0.5, align);
3143 if (sd->align != align)
3144 evas_object_size_hint_align_set(sd->bx, align, 0.5);
3150 elm_toolbar_align_get(const Evas_Object *obj)
3152 ELM_TOOLBAR_CHECK(obj) 0.0;
3153 ELM_TOOLBAR_DATA_GET(obj, sd);
3159 elm_toolbar_item_menu_set(Elm_Object_Item *it,
3162 Elm_Toolbar_Item *item = (Elm_Toolbar_Item *)it;
3164 ELM_TOOLBAR_ITEM_CHECK_OR_RETURN(it);
3165 ELM_TOOLBAR_DATA_GET(WIDGET(item), sd);
3167 if (item->menu == menu) return;
3168 if (menu) _item_menu_create(sd, item);
3169 else _item_menu_destroy(item);
3173 elm_toolbar_item_menu_get(const Elm_Object_Item *it)
3175 Elm_Toolbar_Item *item = (Elm_Toolbar_Item *)it;
3177 ELM_TOOLBAR_ITEM_CHECK_OR_RETURN(it, NULL);
3179 if (!item->menu) return NULL;
3180 return item->o_menu;
3183 EAPI Elm_Toolbar_Item_State *
3184 elm_toolbar_item_state_add(Elm_Object_Item *it,
3190 Elm_Toolbar_Item *item = (Elm_Toolbar_Item *)it;
3191 Elm_Toolbar_Item_State *it_state;
3192 Evas_Object *icon_obj;
3195 ELM_TOOLBAR_ITEM_CHECK_OR_RETURN(it, NULL);
3198 ELM_TOOLBAR_DATA_GET(WIDGET(item), sd);
3202 it_state = _item_state_new
3203 (item->label, item->icon_str, item->icon, item->func,
3205 item->states = eina_list_append(item->states, it_state);
3206 item->current_state = item->states;
3209 icon_obj = elm_icon_add(obj);
3210 elm_icon_order_lookup_set(icon_obj, sd->lookup_order);
3211 if (!icon_obj) goto error_state_add;
3213 if (!_item_icon_set(icon_obj, "toolbar/", icon))
3215 evas_object_del(icon_obj);
3220 it_state = _item_state_new(label, icon, icon_obj, func, data);
3221 item->states = eina_list_append(item->states, it_state);
3222 item->func = _elm_toolbar_item_state_cb;
3223 item->base.data = NULL;
3228 if (item->states && !eina_list_next(item->states))
3230 eina_stringshare_del(item->label);
3231 eina_stringshare_del(item->icon_str);
3232 free(eina_list_data_get(item->states));
3233 eina_list_free(item->states);
3234 item->states = NULL;
3240 elm_toolbar_item_state_del(Elm_Object_Item *it,
3241 Elm_Toolbar_Item_State *state)
3243 Elm_Toolbar_Item_State *it_state;
3244 Elm_Toolbar_Item *item;
3245 Eina_List *del_state;
3247 ELM_TOOLBAR_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
3249 if (!state) return EINA_FALSE;
3251 item = (Elm_Toolbar_Item *)it;
3252 if (!item->states) return EINA_FALSE;
3254 del_state = eina_list_data_find_list(item->states, state);
3255 if (del_state == item->states) return EINA_FALSE;
3256 if (del_state == item->current_state)
3257 elm_toolbar_item_state_unset(it);
3259 eina_stringshare_del(state->label);
3260 eina_stringshare_del(state->icon_str);
3261 if (state->icon) evas_object_del(state->icon);
3264 item->states = eina_list_remove_list(item->states, del_state);
3265 if (item->states && !eina_list_next(item->states))
3267 it_state = eina_list_data_get(item->states);
3268 item->base.data = it_state->data;
3269 item->func = it_state->func;
3270 eina_stringshare_del(it_state->label);
3271 eina_stringshare_del(it_state->icon_str);
3272 free(eina_list_data_get(item->states));
3273 eina_list_free(item->states);
3274 item->states = NULL;
3281 elm_toolbar_item_state_set(Elm_Object_Item *it,
3282 Elm_Toolbar_Item_State *state)
3284 Elm_Toolbar_Item *item = (Elm_Toolbar_Item *)it;
3285 Elm_Toolbar_Item_State *it_state;
3286 Eina_List *next_state;
3289 ELM_TOOLBAR_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
3292 ELM_TOOLBAR_DATA_GET(obj, sd);
3293 if (!item->states) return EINA_FALSE;
3297 next_state = eina_list_data_find_list(item->states, state);
3298 if (!next_state) return EINA_FALSE;
3301 next_state = item->states;
3303 if (next_state == item->current_state) return EINA_TRUE;
3305 it_state = eina_list_data_get(next_state);
3306 if (eina_list_data_find(item->current_state, state))
3308 _item_label_set(item, it_state->label, "elm,state,label_set,forward");
3309 _elm_toolbar_item_icon_obj_set
3310 (obj, item, it_state->icon, it_state->icon_str,
3311 sd->icon_size, "elm,state,icon_set,forward");
3315 _item_label_set(item, it_state->label, "elm,state,label_set,backward");
3316 _elm_toolbar_item_icon_obj_set
3317 (obj, item, it_state->icon, it_state->icon_str,
3318 sd->icon_size, "elm,state,icon_set,backward");
3320 if (elm_widget_item_disabled_get(item))
3321 elm_widget_signal_emit(item->icon, "elm,state,disabled", "elm");
3323 elm_widget_signal_emit(item->icon, "elm,state,enabled", "elm");
3325 item->current_state = next_state;
3331 elm_toolbar_item_state_unset(Elm_Object_Item *it)
3333 elm_toolbar_item_state_set(it, NULL);
3336 EAPI Elm_Toolbar_Item_State *
3337 elm_toolbar_item_state_get(const Elm_Object_Item *it)
3339 Elm_Toolbar_Item *item = (Elm_Toolbar_Item *)it;
3341 ELM_TOOLBAR_ITEM_CHECK_OR_RETURN(it, NULL);
3343 if ((!item->states) || (!item->current_state)) return NULL;
3344 if (item->current_state == item->states) return NULL;
3346 return eina_list_data_get(item->current_state);
3349 EAPI Elm_Toolbar_Item_State *
3350 elm_toolbar_item_state_next(Elm_Object_Item *it)
3352 Eina_List *next_state;
3353 Elm_Toolbar_Item *item = (Elm_Toolbar_Item *)it;
3355 ELM_TOOLBAR_ITEM_CHECK_OR_RETURN(it, NULL);
3357 if (!item->states) return NULL;
3359 next_state = eina_list_next(item->current_state);
3361 next_state = eina_list_next(item->states);
3362 return eina_list_data_get(next_state);
3365 EAPI Elm_Toolbar_Item_State *
3366 elm_toolbar_item_state_prev(Elm_Object_Item *it)
3368 Eina_List *prev_state;
3369 Elm_Toolbar_Item *item = (Elm_Toolbar_Item *)it;
3371 ELM_TOOLBAR_ITEM_CHECK_OR_RETURN(it, NULL);
3373 if (!item->states) return NULL;
3375 prev_state = eina_list_prev(item->current_state);
3376 if ((!prev_state) || (prev_state == item->states))
3377 prev_state = eina_list_last(item->states);
3378 return eina_list_data_get(prev_state);
3382 elm_toolbar_icon_order_lookup_set(Evas_Object *obj,
3383 Elm_Icon_Lookup_Order order)
3385 Elm_Toolbar_Item *it;
3387 ELM_TOOLBAR_CHECK(obj);
3388 ELM_TOOLBAR_DATA_GET(obj, sd);
3390 if (sd->lookup_order == order) return;
3391 sd->lookup_order = order;
3392 EINA_INLIST_FOREACH(sd->items, it)
3393 elm_icon_order_lookup_set(it->icon, order);
3395 elm_icon_order_lookup_set(sd->more_item->icon, order);
3398 EAPI Elm_Icon_Lookup_Order
3399 elm_toolbar_icon_order_lookup_get(const Evas_Object *obj)
3401 ELM_TOOLBAR_CHECK(obj) ELM_ICON_LOOKUP_THEME_FDO;
3402 ELM_TOOLBAR_DATA_GET(obj, sd);
3404 return sd->lookup_order;
3408 elm_toolbar_horizontal_set(Evas_Object *obj,
3409 Eina_Bool horizontal)
3411 ELM_TOOLBAR_CHECK(obj);
3412 ELM_TOOLBAR_DATA_GET(obj, sd);
3414 horizontal = !!horizontal;
3415 if (!horizontal == sd->vertical) return;
3416 sd->vertical = !horizontal;
3418 evas_object_size_hint_align_set(sd->bx, 0.5, sd->align);
3420 evas_object_size_hint_align_set(sd->bx, sd->align, 0.5);
3426 elm_toolbar_horizontal_get(const Evas_Object *obj)
3428 ELM_TOOLBAR_CHECK(obj) EINA_FALSE;
3429 ELM_TOOLBAR_DATA_GET(obj, sd);
3431 return !sd->vertical;
3435 elm_toolbar_items_count(const Evas_Object *obj)
3437 ELM_TOOLBAR_CHECK(obj) 0;
3438 ELM_TOOLBAR_DATA_GET(obj, sd);
3440 return sd->item_count;
3444 elm_toolbar_standard_priority_set(Evas_Object *obj,
3447 ELM_TOOLBAR_CHECK(obj);
3448 ELM_TOOLBAR_DATA_GET(obj, sd);
3450 if (sd->standard_priority == priority) return;
3451 sd->standard_priority = priority;
3452 _resize_cb(obj, NULL, NULL, NULL);
3456 elm_toolbar_standard_priority_get(const Evas_Object *obj)
3458 ELM_TOOLBAR_CHECK(obj) 0;
3459 ELM_TOOLBAR_DATA_GET(obj, sd);
3461 return sd->standard_priority;
3465 elm_toolbar_select_mode_set(Evas_Object *obj,
3466 Elm_Object_Select_Mode mode)
3468 ELM_TOOLBAR_CHECK(obj);
3469 ELM_TOOLBAR_DATA_GET(obj, sd);
3471 if (mode >= ELM_OBJECT_SELECT_MODE_MAX)
3474 if (sd->select_mode == mode) return;
3476 if ((mode == ELM_OBJECT_SELECT_MODE_ALWAYS) &&
3477 (sd->select_mode != ELM_OBJECT_SELECT_MODE_ALWAYS) &&
3479 _item_select(ELM_TOOLBAR_ITEM_FROM_INLIST(sd->items));
3481 if (sd->select_mode != mode)
3482 sd->select_mode = mode;
3485 EAPI Elm_Object_Select_Mode
3486 elm_toolbar_select_mode_get(const Evas_Object *obj)
3488 ELM_TOOLBAR_CHECK(obj) ELM_OBJECT_SELECT_MODE_MAX;
3489 ELM_TOOLBAR_DATA_GET(obj, sd);
3491 return sd->select_mode;
3495 elm_toolbar_reorder_mode_set(Evas_Object *obj,
3496 Eina_Bool reorder_mode)
3498 ELM_TOOLBAR_CHECK(obj);
3499 ELM_TOOLBAR_DATA_GET(obj, sd);
3501 sd->reorder_mode = !!reorder_mode;
3505 elm_toolbar_reorder_mode_get(const Evas_Object *obj)
3507 ELM_TOOLBAR_CHECK(obj) EINA_FALSE;
3508 ELM_TOOLBAR_DATA_GET(obj, sd);
3510 return sd->reorder_mode;
3514 elm_toolbar_item_show(Elm_Object_Item *it, Elm_Toolbar_Item_Scrollto_Type type)
3516 Evas_Coord x, y, w, h;
3517 Elm_Toolbar_Item *item = (Elm_Toolbar_Item *)it;
3519 ELM_TOOLBAR_ITEM_CHECK_OR_RETURN(it);
3520 ELM_TOOLBAR_DATA_GET(WIDGET(item), sd);
3522 if (_elm_toolbar_item_coordinates_calc(it, type, &x, &y, &w, &h))
3523 sd->s_iface->content_region_show(WIDGET(item), x, y, w, h);
3527 elm_toolbar_item_bring_in(Elm_Object_Item *it, Elm_Toolbar_Item_Scrollto_Type type)
3529 Evas_Coord x, y, w, h;
3530 Elm_Toolbar_Item *item = (Elm_Toolbar_Item *)it;
3532 ELM_TOOLBAR_ITEM_CHECK_OR_RETURN(it);
3533 ELM_TOOLBAR_DATA_GET(WIDGET(item), sd);
3535 if (_elm_toolbar_item_coordinates_calc(it, type, &x, &y, &w, &h))
3536 sd->s_iface->region_bring_in(WIDGET(item), x, y, w, h);