4 #include <Elementary.h>
8 #define EAPI __attribute__ ((visibility("default")))
11 #define ELM_MAX(v1, v2) (((v1) > (v2)) ? (v1) : (v2))
12 #define _EDJ(x) (Evas_Object *)elm_layout_edje_get(x)
18 typedef struct _Animation_Data Animation_Data;
20 struct _Animation_Data
33 void (*func) (void *data, Evas_Object * obj);
35 Ecore_Animator * timer;
38 // internal data structure of controlbar object
39 typedef struct _Widget_Data Widget_Data;
50 Elm_Controlbar_Item * more_item;
51 Elm_Controlbar_Item * pre_item;
52 Elm_Controlbar_Item * cur_item;
53 Evas_Coord x, y, w, h;
62 Eina_List * visible_items;
64 void (*ani_func) (void *data, Evas_Object * obj, void *event_info);
66 Ecore_Timer *effect_timer;
67 Eina_Bool selected_animation;
70 const char *pressed_signal;
71 const char *selected_signal;
74 struct _Elm_Controlbar_Item
79 Evas_Object * base_item;
82 const char *icon_path;
84 void (*func) (void *data, Evas_Object * obj, void *event_info);
93 static const char *widtype = NULL;
95 static void _sizing_eval(Evas_Object * obj);
96 static int _check_bar_item_number(Widget_Data *wd);
97 static void _select_box(Elm_Controlbar_Item * it);
98 static void _cancel_selected_box(Widget_Data *wd);
99 static void _check_toolbar_line(Widget_Data *wd);
100 static Eina_Bool _press_box(Elm_Controlbar_Item * it);
102 ///////////////////////////////////////////////////////////////////
104 // Smart Object basic function
106 ////////////////////////////////////////////////////////////////////
109 _controlbar_move(void *data, Evas_Object * obj __UNUSED__)
112 Evas_Coord x, y, x_, y_, width;
114 wd = elm_widget_data_get((Evas_Object *) data);
116 evas_object_geometry_get(wd->edje, &x, &y, NULL, NULL);
119 evas_object_move(wd->edje, x, y);
120 evas_object_geometry_get(elm_object_part_content_get(wd->edje, "bg_image"), NULL, NULL, &width, NULL);
121 evas_object_geometry_get(wd->edje, &x_, &y_, NULL, NULL);
125 _controlbar_resize(void *data, Evas_Object * obj __UNUSED__)
128 Evas_Coord x, y, x_, y_, w, h, width, height;
130 wd = elm_widget_data_get((Evas_Object *) data);
132 evas_object_geometry_get(wd->edje, &x, &y, &w, &h);
135 evas_object_resize(wd->edje, w, h);
136 evas_object_geometry_get(elm_object_part_content_get(wd->edje, "bg_image"), NULL, NULL, &width, &height);
137 evas_object_geometry_get(wd->edje, &x_, &y_, NULL, NULL);
141 _controlbar_object_move(void *data, Evas * e __UNUSED__, Evas_Object * obj,
142 void *event_info __UNUSED__)
144 _controlbar_move(data, obj);
148 _controlbar_object_resize(void *data, Evas * e __UNUSED__, Evas_Object * obj,
149 void *event_info __UNUSED__)
151 _controlbar_resize(data, obj);
155 _controlbar_object_show(void *data, Evas * e __UNUSED__, Evas_Object * obj __UNUSED__,
156 void *event_info __UNUSED__)
160 wd = elm_widget_data_get((Evas_Object *) data);
162 evas_object_show(wd->edje);
163 evas_object_show(wd->box);
167 _controlbar_object_hide(void *data, Evas * e __UNUSED__, Evas_Object * obj __UNUSED__,
168 void *event_info __UNUSED__)
172 wd = elm_widget_data_get((Evas_Object *) data);
174 evas_object_hide(wd->edje);
175 evas_object_hide(wd->box);
177 _cancel_selected_box(wd);
181 _item_del(Elm_Controlbar_Item *it)
184 Widget_Data *wd = elm_widget_data_get(it->obj);
188 eina_stringshare_del(it->text);
190 eina_stringshare_del(it->icon_path);
192 evas_object_del(it->icon);
194 evas_object_del(it->base);
196 evas_object_del(it->base_item);
198 evas_object_del(it->view);
202 _del_hook(Evas_Object * obj)
204 Widget_Data * wd = elm_widget_data_get(obj);
205 Elm_Controlbar_Item * item;
208 EINA_LIST_FREE(wd->items, item)
216 evas_object_del(wd->bg);
221 evas_object_del(wd->box);
226 evas_object_del(wd->edje);
229 if (wd->effect_timer)
231 ecore_timer_del(wd->effect_timer);
232 wd->effect_timer = NULL;
236 if (wd->ad->timer) ecore_animator_del(wd->ad->timer);
237 wd->ad->timer = NULL;
247 _theme_hook(Evas_Object * obj)
251 Elm_Controlbar_Item * item;
254 Widget_Data * wd = elm_widget_data_get(obj);
256 elm_layout_theme_set(wd->edje, "controlbar", "base",
257 elm_widget_style_get(obj));
258 elm_layout_theme_set(wd->bg, "controlbar", "background",
259 elm_widget_style_get(obj));
260 evas_object_color_get(wd->bg, &r, &g, &b, NULL);
261 evas_object_color_set(wd->bg, r, g, b, (int)(255 * wd->alpha / 100));
262 EINA_LIST_FOREACH(wd->items, l, item)
264 elm_layout_theme_set(item->base, "controlbar", "item_bg", elm_widget_style_get(obj));
268 elm_controlbar_mode_set(obj, wd->mode);
269 _check_toolbar_line(wd);
273 _disable_hook(Evas_Object * obj)
275 Widget_Data * wd = elm_widget_data_get(obj);
278 Elm_Controlbar_Item * item;
281 wd->disabled = elm_widget_disabled_get(obj);
283 EINA_LIST_FOREACH(wd->items, l, item)
286 disabled = wd->disabled;
288 disabled = item->disabled;
290 if (item->base_item) elm_widget_disabled_set(item->base_item, disabled);
295 _sub_del(void *data __UNUSED__, Evas_Object * obj, void *event_info)
300 _sizing_eval(Evas_Object * obj)
302 Widget_Data * wd = elm_widget_data_get(obj);
304 _controlbar_move(obj, obj);
305 _controlbar_resize(obj, obj);
308 /////////////////////////////////////////////////////////////
310 // animation function
312 /////////////////////////////////////////////////////////////
315 _move_evas_object(void *data)
317 const Evas_Object *bg_image;
318 double t = 0.0, vx = 0.0, vy = 0.0, vw = 0.0, vh = 0.0;
319 int dx = 0 , dy = 0, dw = 0, dh = 0;
320 int px = 0, py = 0, pw = 0, ph = 0;
321 int ox = 0, oy = 0, ow = 0, oh = 0;
322 int x = 0, y = 0, w = 0, h = 0;
324 Animation_Data * ad = (Animation_Data *) data;
325 bg_image = edje_object_part_object_get(_EDJ(ad->obj), "bg_image");
326 if (bg_image) evas_object_geometry_get(bg_image, &ox, &oy, &ow, &oh);
327 t = ELM_MAX(0.0, ecore_loop_time_get() - ad->start_time);
328 dx = ad->tx - ad->fx;
329 dy = ad->ty - ad->fy;
330 dw = ad->tw - ad->fw;
331 dh = ad->th - ad->fh;
334 x = (1 * sin((t / ad->time) * (M_PI / 2)) * dx);
335 y = (1 * sin((t / ad->time) * (M_PI / 2)) * dy);
336 w = (1 * sin((t / ad->time) * (M_PI / 2)) * dw);
337 h = (1 * sin((t / ad->time) * (M_PI / 2)) * dh);
354 vx = (double)(px - ox) / (double)(ow - pw);
358 vy = (double)(py - oy) / (double)(oh - ph);
359 vw = (double)pw / (double)ow;
360 vh = (double)ph / (double)oh;
362 if ((x == dx) && (y == dy) && (w == dw) && (h == dh))
364 if (ad->timer) ecore_animator_del(ad->timer);
366 edje_object_part_drag_size_set(_EDJ(ad->obj), "elm.dragable.box", vw, vh);
367 edje_object_part_drag_value_set(_EDJ(ad->obj), "elm.dragable.box", vx, vy);
368 if (ad->func != NULL)
369 ad->func(ad->data, ad->obj);
370 return ECORE_CALLBACK_CANCEL;
374 edje_object_part_drag_size_set(_EDJ(ad->obj), "elm.dragable.box", vw, vh);
375 edje_object_part_drag_value_set(_EDJ(ad->obj), "elm.dragable.box", vx, vy);
377 return ECORE_CALLBACK_RENEW;
380 static Animation_Data*
381 _move_object_with_animation(Evas_Object * obj, Evas_Coord x, Evas_Coord y,
382 Evas_Coord w, Evas_Coord h, Evas_Coord x_,
383 Evas_Coord y_, Evas_Coord w_, Evas_Coord h_,
384 double time, Eina_Bool (*mv_func) (void *data),
385 void (*func) (void *data,
386 Evas_Object * obj), void *data)
388 Animation_Data * ad = (Animation_Data *) malloc(sizeof(Animation_Data));
389 if (!ad) return NULL;
399 ad->start_time = ecore_loop_time_get();
403 ad->timer = ecore_animator_add(mv_func, ad);
408 /////////////////////////////////////////////////////////////
412 /////////////////////////////////////////////////////////////
415 _sort_cb(const void *d1, const void *d2)
417 Elm_Controlbar_Item * item1, *item2;
418 item1 = (Elm_Controlbar_Item *) d1;
419 item2 = (Elm_Controlbar_Item *) d2;
420 if (item1->order <= 0) return 1;
421 if (item2->order <= 0) return -1;
422 return item1->order > item2->order ? 1 : -1;
425 ///////////////////////////////////////////////////////////////////
427 // basic utility function
429 ////////////////////////////////////////////////////////////////////
432 _check_item(Widget_Data *wd, Elm_Controlbar_Item *item)
435 Elm_Controlbar_Item *it;
437 if (!wd) return EINA_FALSE;
438 if (!wd->items) return EINA_FALSE;
440 EINA_LIST_FOREACH(wd->items, l, it)
441 if (it == item) return EINA_TRUE;
447 _check_background(Widget_Data *wd)
451 Elm_Controlbar_Item *it;
453 EINA_LIST_FOREACH(wd->items, l, it)
455 if (it->style == TABBAR)
457 if (wd->mode == ELM_CONTROLBAR_MODE_LEFT)
458 edje_object_signal_emit(_EDJ(wd->bg), "elm,state,tabbar_left", "elm");
459 else if (wd->mode == ELM_CONTROLBAR_MODE_RIGHT)
460 edje_object_signal_emit(_EDJ(wd->bg), "elm,state,tabbar_right", "elm");
462 edje_object_signal_emit(_EDJ(wd->bg), "elm,state,tabbar", "elm");
466 edje_object_signal_emit(_EDJ(wd->bg), "elm,state,toolbar", "elm");
470 _check_toolbar_line(Widget_Data *wd)
474 Elm_Controlbar_Item *it, *it2;
476 EINA_LIST_FOREACH(wd->items, l, it)
478 it2 = elm_controlbar_item_prev(it);
480 if (it->style != TOOLBAR || it2->style != TOOLBAR) continue;
484 edje_object_signal_emit(_EDJ(it2->base), "elm,state,right_line_hide", "elm");
485 edje_object_signal_emit(_EDJ(it->base), "elm,state,left_line_hide", "elm");
487 if ((it->icon || it->text) && (it2->icon || it2->text))
489 edje_object_signal_emit(_EDJ(it2->base), "elm,state,bottom_line_show", "elm");
490 edje_object_signal_emit(_EDJ(it->base), "elm,state,top_line_show", "elm");
494 edje_object_signal_emit(_EDJ(it2->base), "elm,state,bottom_line_hide", "elm");
495 edje_object_signal_emit(_EDJ(it->base), "elm,state,top_line_hide", "elm");
500 edje_object_signal_emit(_EDJ(it2->base), "elm,state,bottom_line_hide", "elm");
501 edje_object_signal_emit(_EDJ(it->base), "elm,state,top_line_hide", "elm");
503 if ((it->icon || it->text) && (it2->icon || it2->text))
505 edje_object_signal_emit(_EDJ(it2->base), "elm,state,right_line_show", "elm");
506 edje_object_signal_emit(_EDJ(it->base), "elm,state,left_line_show", "elm");
510 edje_object_signal_emit(_EDJ(it2->base), "elm,state,right_line_hide", "elm");
511 edje_object_signal_emit(_EDJ(it->base), "elm,state,left_line_hide", "elm");
518 _check_bar_item_number(Widget_Data *wd)
521 Elm_Controlbar_Item * item;
524 EINA_LIST_FOREACH(wd->items, l, item)
525 if (item->order > 0) num++;
531 _insert_item_in_bar(Elm_Controlbar_Item * it, int order)
534 Elm_Controlbar_Item * item;
535 Widget_Data * wd = elm_widget_data_get(it->obj);
539 if (order == 0) return;
541 EINA_LIST_FOREACH(wd->items, l, item)
543 if ((item->order == order) && (item != it))
548 EINA_LIST_FOREACH(wd->items, l, item)
551 elm_table_unpack(wd->box, item->base);
553 EINA_LIST_FOREACH(wd->items, l, item)
557 if (item->order >= order)
560 elm_table_pack(wd->box, item->base, item->order - 1, 0, 1, 1);
562 elm_table_pack(wd->box, item->base, 0, item->order - 1, 1, 1);
563 evas_object_show(item->base);
569 elm_table_pack(wd->box, it->base, it->order - 1, 0, 1, 1);
571 elm_table_pack(wd->box, it->base, 0, it->order - 1, 1, 1);
572 evas_object_show(it->base);
576 _delete_item_in_bar(Elm_Controlbar_Item * it)
579 Elm_Controlbar_Item * item;
580 Widget_Data * wd = elm_widget_data_get(it->obj);
584 EINA_LIST_FOREACH(wd->items, l, item)
590 elm_table_unpack(wd->box, it->base);
591 evas_object_hide(it->base);
596 EINA_LIST_FOREACH(wd->items, l, item)
601 elm_table_unpack(wd->box, item->base);
603 elm_table_pack(wd->box, item->base, item->order - 1, 0, 1, 1);
605 elm_table_pack(wd->box, item->base, 0, item->order - 1, 1, 1);
612 _set_item_visible(Elm_Controlbar_Item *it, Eina_Bool visible)
614 Elm_Controlbar_Item *item;
615 Eina_Bool check = EINA_TRUE;
618 if (it->obj == NULL) return;
619 Widget_Data * wd = elm_widget_data_get(it->obj);
620 if (!wd || !wd->items) return;
621 if (it->order <= 0) check = EINA_FALSE;
622 if (check == visible) return;
625 item = elm_controlbar_last_item_get(it->obj);
627 while (!elm_controlbar_item_visible_get(item)){
628 item = elm_controlbar_item_prev(item);
630 _insert_item_in_bar(it, item->order + 1);
634 _delete_item_in_bar(it);
636 wd->items = eina_list_sort(wd->items, eina_list_count(wd->items), _sort_cb);
637 _sizing_eval(it->obj);
641 _hide_selected_box(void *data)
643 Evas_Object *base = (Evas_Object *)data;
645 edje_object_part_drag_size_set(_EDJ(base), "elm.dragable.box", 0.0, 0.0);
647 return ECORE_CALLBACK_CANCEL;
651 _end_selected_box(void *data, Evas_Object *obj __UNUSED__)
653 Widget_Data * wd = (Widget_Data *)data;
655 if (_check_item(wd, wd->cur_item))
657 edje_object_signal_emit(_EDJ(wd->cur_item->base), wd->selected_signal, "elm");
661 if (wd->animating < 0)
663 printf("animation error\n");
667 ecore_idler_add(_hide_selected_box, wd->edje);
671 _move_selected_box(Widget_Data *wd, Elm_Controlbar_Item * fit, Elm_Controlbar_Item * tit)
673 Evas_Coord fx, fy, fw, fh, tx, ty, tw, th;
674 Evas_Object *from, *to;
676 if ((fit->order <= 0) && (wd->auto_align))
679 from = (Evas_Object *) edje_object_part_object_get(_EDJ(fit->base), "bg_img");
680 evas_object_geometry_get(from, &fx, &fy, &fw, &fh);
682 to = (Evas_Object *) edje_object_part_object_get(_EDJ(tit->base), "bg_img");
683 evas_object_geometry_get(to, &tx, &ty, &tw, &th);
685 if (_check_item(wd, wd->pre_item))
687 edje_object_signal_emit(_EDJ(wd->pre_item->base), "elm,state,unselected", "elm");
689 if (_check_item(wd, wd->cur_item))
690 edje_object_signal_emit(_EDJ(wd->cur_item->base), "elm,state,unselected", "elm");
695 if (wd->ad->timer) ecore_animator_del(wd->ad->timer);
696 wd->ad->timer = NULL;
700 wd->ad = _move_object_with_animation(wd->edje, fx, fy, fw, fh, tx, ty, tw, th,
701 0.3, _move_evas_object, _end_selected_box, wd);
705 _select_box(Elm_Controlbar_Item * it)
708 Widget_Data * wd = elm_widget_data_get(it->obj);
711 Elm_Controlbar_Item * item, *fit = NULL;
712 Evas_Object * content;
714 if (wd->animating) return;
718 if (it->style == TABBAR)
720 content = elm_object_part_content_unset(wd->edje, "elm.swallow.view");
721 if (content) evas_object_hide(content);
723 EINA_LIST_FOREACH(wd->items, l, item){
724 if (item->selected) {
728 item->selected = EINA_FALSE;
730 it->selected = EINA_TRUE;
732 if ((fit != NULL) && (fit != it))
734 _move_selected_box(wd, fit, it);
738 edje_object_signal_emit(_EDJ(it->base), wd->selected_signal, "elm");
743 if (wd->more_item != it)
744 evas_object_smart_callback_call(it->obj, "view,change,before", it);
747 elm_object_part_content_set(wd->edje, "elm.swallow.view", it->view);
749 else if (it->style == TOOLBAR)
751 edje_object_signal_emit(_EDJ(it->base), "elm,state,text_unselected", "elm");
753 it->func(it->data, it->obj, it);
758 _cancel_selected_box(Widget_Data *wd)
761 Elm_Controlbar_Item * item;
763 EINA_LIST_FOREACH(wd->items, l, item)
765 if (item->style == TABBAR)
769 edje_object_signal_emit(_EDJ(item->base), wd->selected_signal, "elm");
773 edje_object_signal_emit(_EDJ(item->base), "elm,state,unselected", "elm");
776 else if (item->style == TOOLBAR)
778 edje_object_signal_emit(_EDJ(item->base), "elm,state,unselected", "elm");
784 _unpress_box_cb(void *data, Evas_Object *obj, void *event_info)
786 Widget_Data * wd = (Widget_Data *) data;
789 _cancel_selected_box(wd);
793 _clicked_box_cb(void *data, Evas_Object *obj, void *event_info)
795 Widget_Data * wd = (Widget_Data *) data;
798 _select_box(wd->pre_item);
802 _press_box(Elm_Controlbar_Item * it)
804 Widget_Data * wd = elm_widget_data_get(it->obj);
805 if (!wd) return EINA_FALSE;
808 Elm_Controlbar_Item * item;
810 if (wd->animating) return EINA_FALSE;
812 if (wd->disabled || it->disabled) return EINA_FALSE;
814 EINA_LIST_FOREACH(wd->items, l, item)
818 if (it->style == TABBAR)
820 edje_object_signal_emit(_EDJ(it->base), wd->pressed_signal, "elm");
822 else if (it->style == TOOLBAR)
824 edje_object_signal_emit(_EDJ(it->base), "elm,state,toolbar_pressed", "elm");
839 _create_item_icon(Evas_Object *obj, Elm_Controlbar_Item * it, char *part)
843 icon = elm_icon_add(obj);
844 if (!elm_icon_standard_set(icon, it->icon_path))
846 elm_icon_file_set(icon, it->icon_path, NULL);
849 evas_object_size_hint_min_set(icon, 40, 40);
850 evas_object_size_hint_max_set(icon, 100, 100);
851 evas_object_show(icon);
853 elm_object_content_set(obj, icon);
859 _create_item_layout(Evas_Object * parent, Elm_Controlbar_Item * it, Evas_Object **item, Evas_Object **icon)
863 obj = elm_layout_add(parent);
866 fprintf(stderr, "Cannot load bg edj\n");
869 elm_layout_theme_set(obj, "controlbar", "item_bg",
870 elm_widget_style_get(it->obj));
871 evas_object_size_hint_weight_set(obj, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
872 evas_object_size_hint_align_set(obj, EVAS_HINT_FILL, EVAS_HINT_FILL);
874 *item = elm_button_add(parent);
875 if (*item == NULL) return NULL;
876 elm_object_style_set(*item, "controlbar/vertical");
877 elm_object_part_content_set(obj, "item", *item);
880 elm_object_text_set(*item, it->text);
882 *icon = _create_item_icon(*item, it, "elm.swallow.icon");
888 _bar_item_down_cb(void *data, Evas_Object * obj, void *event_info __UNUSED__)
890 Widget_Data * wd = (Widget_Data *) data;
892 Elm_Controlbar_Item * item;
893 if (wd->animating) return;
895 EINA_LIST_FOREACH(wd->items, l, item)
896 if (item->base_item == obj) break;
898 if (item == NULL) return;
903 static Elm_Controlbar_Item *
904 _create_tab_item(Evas_Object * obj, const char *icon_path, const char *label,
907 Elm_Controlbar_Item * it;
911 fprintf(stderr, "Invalid argument: controlbar object is NULL\n");
914 wd = elm_widget_data_get(obj);
917 fprintf(stderr, "Cannot get smart data\n");
920 it = ELM_NEW(Elm_Controlbar_Item);
921 if (!it) return NULL;
924 it->text = eina_stringshare_add(label);
925 it->icon_path = eina_stringshare_add(icon_path);
926 it->selected = EINA_FALSE;
930 it->base = _create_item_layout(wd->edje, it, &(it->base_item), &(it->icon));
931 evas_object_smart_callback_add(it->base_item, "pressed",
932 _bar_item_down_cb, wd);
933 evas_object_smart_callback_add(it->base_item, "unpressed", _unpress_box_cb, wd);
934 evas_object_smart_callback_add(it->base_item, "clicked", _clicked_box_cb, wd);
935 evas_object_show(it->base);
940 static Elm_Controlbar_Item *
941 _create_tool_item(Evas_Object * obj, const char *icon_path, const char *label,
942 void (*func) (void *data, Evas_Object * obj,
943 void *event_info), void *data)
946 Elm_Controlbar_Item * it;
950 fprintf(stderr, "Invalid argument: controlbar object is NULL\n");
953 wd = elm_widget_data_get(obj);
956 fprintf(stderr, "Cannot get smart data\n");
959 it = ELM_NEW(Elm_Controlbar_Item);
964 it->text = eina_stringshare_add(label);
965 it->icon_path = eina_stringshare_add(icon_path);
966 it->selected = EINA_FALSE;
971 it->base = _create_item_layout(wd->edje, it, &(it->base_item), &(it->icon));
972 evas_object_smart_callback_add(it->base_item, "pressed",
973 _bar_item_down_cb, wd);
974 evas_object_smart_callback_add(it->base_item, "unpressed", _unpress_box_cb, wd);
975 evas_object_smart_callback_add(it->base_item, "clicked", _clicked_box_cb, wd);
976 evas_object_show(it->base);
981 static Elm_Controlbar_Item *
982 _create_object_item(Evas_Object * obj, Evas_Object * obj_item, const int sel)
984 Elm_Controlbar_Item * it;
988 fprintf(stderr, "Invalid argument: controlbar object is NULL\n");
991 wd = elm_widget_data_get(obj);
994 fprintf(stderr, "Cannot get smart data\n");
997 it = ELM_NEW(Elm_Controlbar_Item);
1004 it->base = elm_layout_add(wd->edje);
1005 elm_layout_theme_set(it->base, "controlbar", "item_bg",
1006 elm_widget_style_get(it->obj));
1007 evas_object_size_hint_weight_set(it->base, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1008 evas_object_size_hint_align_set(it->base, EVAS_HINT_FILL, EVAS_HINT_FILL);
1009 it->base_item = obj_item;
1010 elm_object_part_content_set(it->base, "item", it->base_item);
1011 evas_object_show(it->base);
1016 _repack_items(Widget_Data *wd)
1019 Elm_Controlbar_Item * item;
1021 EINA_LIST_FOREACH(wd->items, l, item)
1023 if (item->order > 0)
1025 elm_table_unpack(wd->box, item->base);
1027 elm_table_pack(wd->box, item->base, item->order - 1, 0, item->sel, 1);
1029 elm_table_pack(wd->box, item->base, 0, item->order - 1, item->sel, 1);
1035 _set_items_position(Evas_Object * obj, Elm_Controlbar_Item * it,
1036 Elm_Controlbar_Item * mit, Eina_Bool bar)
1040 Elm_Controlbar_Item * item;
1041 int check = EINA_FALSE;
1046 fprintf(stderr, "Invalid argument: controlbar object is NULL\n");
1049 wd = elm_widget_data_get(obj);
1052 fprintf(stderr, "Cannot get smart data\n");
1056 EINA_LIST_FOREACH(wd->items, l, item)
1058 if ((item == mit) && (item->order > 0))
1061 it->order = mit->order;
1065 if (item->order > 0)
1067 elm_table_unpack(wd->box, item->base);
1068 item->order += it->sel;
1070 elm_table_pack(wd->box, item->base, item->order - 1, 0, item->sel, 1);
1072 elm_table_pack(wd->box, item->base, 0, item->order - 1, item->sel, 1);
1075 if (item->order > 0) order += item->sel;
1089 elm_table_pack(wd->box, it->base, it->order - 1, 0, it->sel, 1);
1091 elm_table_pack(wd->box, it->base, 0, it->order - 1, it->sel, 1);
1094 evas_object_hide(it->base);
1098 _list_clicked(void *data, Evas_Object *obj, void *event_info __UNUSED__)
1100 Elm_Controlbar_Item *item = (Elm_Controlbar_Item *)data;
1101 Elm_Controlbar_Item *it;
1104 Evas_Object *content;
1105 Elm_List_Item *lit = (Elm_List_Item *) elm_list_selected_item_get(obj);
1108 elm_list_item_selected_set(lit, 0);
1112 wd = elm_widget_data_get(item->obj);
1115 EINA_LIST_FOREACH(wd->items, l, it)
1117 it->selected = EINA_FALSE;
1120 if (item->style == TABBAR)
1122 content = elm_object_part_content_unset(wd->edje, "elm.swallow.view");
1123 evas_object_hide(content);
1124 item->selected = EINA_TRUE;
1125 evas_object_smart_callback_call(item->obj, "view,change,before", item);
1126 elm_object_part_content_set(wd->edje, "elm.swallow.view", item->view);
1129 if ((item->style == TOOLBAR) && (item->func))
1130 item->func(item->data, item->obj, item);
1133 static Evas_Object *
1134 _create_more_view(Widget_Data *wd)
1137 Elm_Controlbar_Item *item;
1141 list = elm_list_add( wd->object );
1142 elm_list_mode_set( list, ELM_LIST_COMPRESS );
1144 EINA_LIST_FOREACH(wd->items, l, item)
1146 if (item->order <= 0)
1149 if (item->icon_path)
1151 icon = _create_item_icon(list, item, NULL);
1152 evas_object_color_set(icon, 0, 0, 0, 255);
1154 elm_list_item_append(list, item->text, icon, NULL, _list_clicked, item);
1158 elm_list_go( list );
1163 static void _ctxpopup_cb(void *data, Evas_Object *obj, void *event_info)
1165 Elm_Controlbar_Item *it;
1167 Evas_Object *ctxpopup = obj;
1169 Widget_Data *wd = (Widget_Data *)data;
1171 EINA_LIST_FOREACH(wd->items, l, it)
1173 label = elm_ctxpopup_item_label_get((Elm_Ctxpopup_Item *) event_info);
1174 if ((label) && (!strcmp(it->text, label))) break;
1178 it->func(it->data, it->obj, it);
1180 if (_check_item(wd, it)) evas_object_smart_callback_call(it->obj, "clicked", it);
1182 evas_object_del(ctxpopup);
1186 static void _ctxpopup_dismissed_cb(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1188 Evas_Object *ctxpopup = obj;
1190 evas_object_del(ctxpopup);
1195 _create_more_func(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1197 Evas_Object *ctxpopup;
1198 Elm_Controlbar_Item *item;
1201 Evas_Coord x, y, w, h;
1202 Widget_Data *wd = elm_widget_data_get(obj);
1205 ctxpopup = elm_ctxpopup_add(wd->parent);
1206 evas_object_smart_callback_add( ctxpopup, "dismissed", _ctxpopup_dismissed_cb, wd);
1208 EINA_LIST_FOREACH(wd->items, l, item)
1210 if (item->order <= 0)
1213 if (item->icon_path)
1215 icon = _create_item_icon(ctxpopup, item, NULL);
1216 evas_object_color_set(icon, 0, 0, 0, 255);
1218 elm_ctxpopup_item_append(ctxpopup, item->text, icon, _ctxpopup_cb, wd);
1222 evas_object_geometry_get(wd->more_item->base, &x, &y, &w, &h);
1223 evas_object_move(ctxpopup, x + w/2, y + h/2);
1225 evas_object_show(ctxpopup);
1228 static Elm_Controlbar_Item *
1229 _create_more_item(Widget_Data *wd, int style)
1231 Elm_Controlbar_Item * it;
1233 it = ELM_NEW(Elm_Controlbar_Item);
1234 if (!it) return NULL;
1235 it->obj = wd->object;
1236 it->text = eina_stringshare_add("more");
1237 it->icon_path = eina_stringshare_add(CONTROLBAR_SYSTEM_ICON_MORE);
1238 it->selected = EINA_FALSE;
1240 it->view = _create_more_view(wd);
1241 it->func = _create_more_func;
1243 it->base = _create_item_layout(wd->edje, it, &(it->base_item), &(it->icon));
1244 evas_object_smart_callback_add(it->base_item, "pressed",
1245 _bar_item_down_cb, wd);
1246 evas_object_smart_callback_add(it->base_item, "unpressed", _unpress_box_cb, wd);
1247 evas_object_smart_callback_add(it->base_item, "clicked", _clicked_box_cb, wd);
1248 evas_object_show(it->base);
1250 _set_items_position(it->obj, it, NULL, EINA_TRUE);
1251 wd->items = eina_list_append(wd->items, it);
1253 wd->items = eina_list_sort(wd->items, eina_list_count(wd->items), _sort_cb);
1258 EAPI Evas_Object * elm_controlbar_add(Evas_Object * parent)
1260 if (parent == NULL) return NULL;
1261 Evas_Object * obj = NULL;
1262 Evas_Object * bg = NULL;
1263 Widget_Data * wd = NULL;
1264 Evas_Coord x, y, w, h;
1266 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
1267 ELM_SET_WIDTYPE(widtype, "controlbar");
1268 elm_widget_type_set(obj, "controlbar");
1269 elm_widget_sub_object_add(parent, obj);
1270 elm_widget_data_set(obj, wd);
1271 elm_widget_del_hook_set(obj, _del_hook);
1272 elm_widget_can_focus_set(obj, EINA_FALSE);
1273 elm_widget_theme_hook_set(obj, _theme_hook);
1274 elm_widget_disable_hook_set(obj, _disable_hook);
1277 wd->parent = parent;
1278 evas_object_geometry_get(parent, &x, &y, &w, &h);
1284 wd->mode = ELM_CONTROLBAR_MODE_DEFAULT;
1288 wd->vertical = EINA_FALSE;
1289 wd->auto_align = EINA_FALSE;
1290 wd->selected_animation = EINA_FALSE;
1291 wd->pressed_signal = eina_stringshare_add("elm,state,pressed");
1292 wd->selected_signal = eina_stringshare_add("elm,state,selected");
1294 /* load background edj */
1295 wd->edje = elm_layout_add(obj);
1296 elm_layout_theme_set(wd->edje, "controlbar", "base", "default");
1297 if (wd->edje == NULL)
1299 printf("Cannot load base edj\n");
1302 evas_object_show(wd->edje);
1304 wd->bg = elm_layout_add(wd->edje);
1305 elm_layout_theme_set(wd->bg, "controlbar", "background", "default");
1308 printf("Cannot load bg edj\n");
1311 elm_object_part_content_set(wd->edje, "bg_image", wd->bg);
1314 evas_object_event_callback_add(wd->edje, EVAS_CALLBACK_RESIZE,
1315 _controlbar_object_resize, obj);
1316 evas_object_event_callback_add(wd->edje, EVAS_CALLBACK_MOVE,
1317 _controlbar_object_move, obj);
1318 evas_object_event_callback_add(wd->edje, EVAS_CALLBACK_SHOW,
1319 _controlbar_object_show, obj);
1320 evas_object_event_callback_add(wd->edje, EVAS_CALLBACK_HIDE,
1321 _controlbar_object_hide, obj);
1323 bg = elm_object_part_content_get(wd->edje, "bg_image");
1324 evas_object_event_callback_add(bg, EVAS_CALLBACK_MOVE, _controlbar_object_move, obj);
1325 evas_object_event_callback_add(bg, EVAS_CALLBACK_RESIZE, _controlbar_object_resize, obj);
1328 wd->box = elm_table_add(wd->edje);
1329 elm_table_homogeneous_set(wd->box, EINA_TRUE);
1330 evas_object_size_hint_weight_set(wd->box, EVAS_HINT_EXPAND,
1332 evas_object_size_hint_align_set(wd->box, EVAS_HINT_FILL, EVAS_HINT_FILL);
1333 elm_object_part_content_set(wd->edje, "elm.swallow.items", wd->box);
1334 evas_object_show(wd->box);
1336 evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
1338 elm_widget_resize_object_set(obj, wd->edje);
1345 EAPI Elm_Controlbar_Item * elm_controlbar_tab_item_append(Evas_Object * obj,
1352 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1353 Elm_Controlbar_Item * it;
1354 Elm_Controlbar_Item * lit;
1356 it = _create_tab_item(obj, icon_path, label, view);
1357 if (!it) return NULL;
1358 wd = elm_widget_data_get(obj);
1359 if ((_check_bar_item_number(wd) >= 5) && (wd->auto_align))
1361 if (!wd->more_item) {
1362 lit = elm_controlbar_last_item_get(obj);
1363 _set_item_visible(lit, EINA_FALSE);
1364 _create_more_item(wd, TABBAR);
1366 _set_items_position(obj, it, NULL, EINA_FALSE);
1369 _set_items_position(obj, it, NULL, EINA_TRUE);
1371 wd->items = eina_list_append(wd->items, it);
1373 elm_controlbar_item_view_set(wd->more_item, _create_more_view(wd));
1375 _check_background(wd);
1380 EAPI Elm_Controlbar_Item * elm_controlbar_tab_item_prepend(Evas_Object *
1389 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1391 Elm_Controlbar_Item * it;
1392 Elm_Controlbar_Item * lit;
1393 Elm_Controlbar_Item * item;
1394 it = _create_tab_item(obj, icon_path, label, view);
1395 if (!it) return NULL;
1396 wd = elm_widget_data_get(obj);
1397 item = eina_list_data_get(wd->items);
1398 if ((_check_bar_item_number(wd) >= 5) && (wd->auto_align))
1400 if (!wd->more_item) {
1401 lit = elm_controlbar_last_item_get(obj);
1402 _set_item_visible(lit, EINA_FALSE);
1403 _create_more_item(wd, TABBAR);
1405 lit = elm_controlbar_item_prev(wd->more_item);
1406 _set_item_visible(lit, EINA_FALSE);
1407 _set_items_position(obj, it, item, EINA_TRUE);
1410 _set_items_position(obj, it, item, EINA_TRUE);
1412 wd->items = eina_list_prepend(wd->items, it);
1414 elm_controlbar_item_view_set(wd->more_item, _create_more_view(wd));
1416 _check_background(wd);
1421 EAPI Elm_Controlbar_Item *
1422 elm_controlbar_tab_item_insert_before(Evas_Object * obj,
1423 Elm_Controlbar_Item * before,
1424 const char *icon_path,
1425 const char *label, Evas_Object * view)
1427 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1429 Elm_Controlbar_Item * it;
1430 Elm_Controlbar_Item * lit;
1431 if (!before) return NULL;
1432 it = _create_tab_item(obj, icon_path, label, view);
1433 if (!it) return NULL;
1434 wd = elm_widget_data_get(obj);
1435 if ((_check_bar_item_number(wd) >= 5) && (wd->auto_align))
1439 lit = elm_controlbar_last_item_get(obj);
1440 _set_item_visible(lit, EINA_FALSE);
1441 _create_more_item(wd, TABBAR);
1443 before = wd->more_item;
1444 if (before->order > 0)
1446 lit = elm_controlbar_item_prev(wd->more_item);
1447 _set_item_visible(lit, EINA_FALSE);
1448 _set_items_position(obj, it, before, EINA_TRUE);
1452 _set_items_position(obj, it, before, EINA_FALSE);
1456 _set_items_position(obj, it, before, EINA_TRUE);
1458 wd->items = eina_list_prepend_relative(wd->items, it, before);
1460 elm_controlbar_item_view_set(wd->more_item, _create_more_view(wd));
1462 _check_background(wd);
1467 EAPI Elm_Controlbar_Item *
1468 elm_controlbar_tab_item_insert_after(Evas_Object * obj,
1469 Elm_Controlbar_Item * after,
1470 const char *icon_path, const char *label,
1473 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1475 Elm_Controlbar_Item * it;
1476 Elm_Controlbar_Item * lit;
1477 Elm_Controlbar_Item * item;
1478 if (!after) return NULL;
1479 it = _create_tab_item(obj, icon_path, label, view);
1480 if (!it) return NULL;
1481 wd = elm_widget_data_get(obj);
1482 item = elm_controlbar_item_next(after);
1483 if ((_check_bar_item_number(wd) >= 5) && (wd->auto_align))
1487 lit = elm_controlbar_last_item_get(obj);
1488 _set_item_visible(lit, EINA_FALSE);
1489 _create_more_item(wd, TABBAR);
1491 lit = elm_controlbar_item_prev(wd->more_item);
1492 if ((lit != after) && (item->order > 0))
1494 _set_item_visible(lit, EINA_FALSE);
1495 _set_items_position(obj, it, item, EINA_TRUE);
1499 _set_items_position(obj, it, NULL, EINA_FALSE);
1503 _set_items_position(obj, it, item, EINA_TRUE);
1505 wd->items = eina_list_append_relative(wd->items, it, after);
1507 elm_controlbar_item_view_set(wd->more_item, _create_more_view(wd));
1509 _check_background(wd);
1514 EAPI Elm_Controlbar_Item * elm_controlbar_tool_item_append(Evas_Object *
1529 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1530 Elm_Controlbar_Item * it;
1531 Elm_Controlbar_Item * lit;
1533 it = _create_tool_item(obj, icon_path, label, func, data);
1534 if (!it) return NULL;
1535 wd = elm_widget_data_get(obj);
1536 if ((_check_bar_item_number(wd) >= 5) && (wd->auto_align))
1538 if (!wd->more_item) {
1539 lit = elm_controlbar_last_item_get(obj);
1540 _set_item_visible(lit, EINA_FALSE);
1541 _create_more_item(wd, TOOLBAR);
1543 _set_items_position(obj, it, NULL, EINA_FALSE);
1546 _set_items_position(obj, it, NULL, EINA_TRUE);
1548 wd->items = eina_list_append(wd->items, it);
1549 _check_toolbar_line(wd);
1554 EAPI Elm_Controlbar_Item * elm_controlbar_tool_item_prepend(Evas_Object *
1570 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1572 Elm_Controlbar_Item * it;
1573 Elm_Controlbar_Item * lit;
1574 Elm_Controlbar_Item * item;
1575 it = _create_tool_item(obj, icon_path, label, func, data);
1576 if (!it) return NULL;
1577 wd = elm_widget_data_get(obj);
1578 item = eina_list_data_get(wd->items);
1579 if ((_check_bar_item_number(wd) >= 5) && (wd->auto_align))
1581 if (!wd->more_item) {
1582 lit = elm_controlbar_last_item_get(obj);
1583 _set_item_visible(lit, EINA_FALSE);
1584 _create_more_item(wd, TOOLBAR);
1586 lit = elm_controlbar_item_prev(wd->more_item);
1587 _set_item_visible(lit, EINA_FALSE);
1588 _set_items_position(obj, it, item, EINA_TRUE);
1591 _set_items_position(obj, it, item, EINA_TRUE);
1593 wd->items = eina_list_prepend(wd->items, it);
1594 _check_toolbar_line(wd);
1599 EAPI Elm_Controlbar_Item *
1600 elm_controlbar_tool_item_insert_before(Evas_Object * obj,
1601 Elm_Controlbar_Item * before,
1602 const char *icon_path,
1604 void (*func) (void *data,
1609 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1611 Elm_Controlbar_Item * it;
1612 Elm_Controlbar_Item * lit;
1613 if (!before) return NULL;
1614 it = _create_tool_item(obj, icon_path, label, func, data);
1615 if (!it) return NULL;
1616 wd = elm_widget_data_get(obj);
1617 if ((_check_bar_item_number(wd) >= 5) && (wd->auto_align))
1621 lit = elm_controlbar_last_item_get(obj);
1622 _set_item_visible(lit, EINA_FALSE);
1623 _create_more_item(wd, TOOLBAR);
1625 before = wd->more_item;
1626 if (before->order > 0)
1628 lit = elm_controlbar_item_prev(wd->more_item);
1629 _set_item_visible(lit, EINA_FALSE);
1630 _set_items_position(obj, it, before, EINA_TRUE);
1634 _set_items_position(obj, it, before, EINA_FALSE);
1638 _set_items_position(obj, it, before, EINA_TRUE);
1640 wd->items = eina_list_prepend_relative(wd->items, it, before);
1641 _check_toolbar_line(wd);
1646 EAPI Elm_Controlbar_Item *
1647 elm_controlbar_tool_item_insert_after(Evas_Object * obj,
1648 Elm_Controlbar_Item * after,
1649 const char *icon_path,
1651 void (*func) (void *data,
1656 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1658 Elm_Controlbar_Item * it;
1659 Elm_Controlbar_Item * lit;
1660 Elm_Controlbar_Item * item;
1661 if (!after) return NULL;
1662 it = _create_tool_item(obj, icon_path, label, func, data);
1663 if (!it) return NULL;
1664 wd = elm_widget_data_get(obj);
1665 item = elm_controlbar_item_next(after);
1666 if ((_check_bar_item_number(wd) >= 5) && (wd->auto_align))
1670 lit = elm_controlbar_last_item_get(obj);
1671 _set_item_visible(lit, EINA_FALSE);
1672 _create_more_item(wd, TOOLBAR);
1674 lit = elm_controlbar_item_prev(wd->more_item);
1675 if ((lit != after) && (item->order > 0))
1677 _set_item_visible(lit, EINA_FALSE);
1678 _set_items_position(obj, it, item, EINA_TRUE);
1682 _set_items_position(obj, it, NULL, EINA_FALSE);
1686 _set_items_position(obj, it, item, EINA_TRUE);
1688 wd->items = eina_list_append_relative(wd->items, it, after);
1689 _check_toolbar_line(wd);
1694 EAPI Elm_Controlbar_Item * elm_controlbar_object_item_append(Evas_Object *
1700 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1702 Elm_Controlbar_Item * it;
1703 wd = elm_widget_data_get(obj);
1704 if (!wd) return NULL;
1705 it = _create_object_item(obj, obj_item, sel);
1706 if (!it) return NULL;
1707 _set_items_position(obj, it, NULL, EINA_TRUE);
1708 wd->items = eina_list_append(wd->items, it);
1713 EAPI Elm_Controlbar_Item * elm_controlbar_object_item_prepend(Evas_Object *
1719 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1721 Elm_Controlbar_Item * it;
1722 Elm_Controlbar_Item * item;
1723 wd = elm_widget_data_get(obj);
1724 if (!wd) return NULL;
1725 it = _create_object_item(obj, obj_item, sel);
1726 if (!it) return NULL;
1727 item = eina_list_data_get(wd->items);
1728 _set_items_position(obj, it, item, EINA_TRUE);
1729 wd->items = eina_list_prepend(wd->items, it);
1734 EAPI Elm_Controlbar_Item *
1735 elm_controlbar_object_item_insert_before(Evas_Object * obj,
1736 Elm_Controlbar_Item * before,
1737 Evas_Object * obj_item, const int sel)
1739 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1741 Elm_Controlbar_Item * it;
1742 wd = elm_widget_data_get(obj);
1743 if (!wd) return NULL;
1744 if (!before) return NULL;
1745 it = _create_object_item(obj, obj_item, sel);
1746 if (!it) return NULL;
1747 _set_items_position(obj, it, before, EINA_TRUE);
1748 wd->items = eina_list_prepend_relative(wd->items, it, before);
1753 EAPI Elm_Controlbar_Item *
1754 elm_controlbar_object_item_insert_after(Evas_Object * obj,
1755 Elm_Controlbar_Item * after,
1756 Evas_Object * obj_item, const int sel)
1758 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1760 Elm_Controlbar_Item * it;
1761 Elm_Controlbar_Item * item;
1762 wd = elm_widget_data_get(obj);
1763 if (!wd) return NULL;
1764 if (!after) return NULL;
1765 it = _create_object_item(obj, obj_item, sel);
1766 if (!it) return NULL;
1767 item = elm_controlbar_item_next(after);
1768 _set_items_position(obj, it, item, EINA_TRUE);
1769 wd->items = eina_list_append_relative(wd->items, it, after);
1775 elm_controlbar_object_item_object_get(const Elm_Controlbar_Item * it)
1777 if (!it) return NULL;
1778 if (it->style != OBJECT) return NULL;
1779 if (!it->base_item) return NULL;
1780 return it->base_item;
1784 elm_controlbar_item_del(Elm_Controlbar_Item * it)
1790 Elm_Controlbar_Item * item;
1797 if (it->obj == NULL)
1799 printf("Invalid argument: controlbar object is NULL\n");
1802 wd = elm_widget_data_get(it->obj);
1805 printf("Cannot get smart data\n");
1813 elm_table_unpack(wd->box, it->base);
1815 EINA_LIST_FOREACH(wd->items, l, item)
1819 if (item->order > it->order)
1822 elm_table_unpack(wd->box, item->base);
1825 elm_table_pack(wd->box, item->base, item->order - 1, 0, item->sel, 1);
1827 elm_table_pack(wd->box, item->base, 0, item->order - 1, item->sel, 1);
1833 // delete item in list
1835 wd->items = eina_list_remove(wd->items, it);
1838 wd->num = wd->num - 1;
1843 elm_controlbar_item_select(Elm_Controlbar_Item * it)
1846 if (it->obj == NULL) return;
1847 Widget_Data * wd = elm_widget_data_get(it->obj);
1854 elm_controlbar_item_icon_set(Elm_Controlbar_Item * it, const char *icon_path)
1857 if (it->style == OBJECT) return;
1860 eina_stringshare_del(it->icon_path);
1861 it->icon_path = NULL;
1865 evas_object_del(it->icon);
1868 if (icon_path != NULL)
1870 it->icon_path = eina_stringshare_add(icon_path);
1871 it->icon = _create_item_icon(it->base_item, it, "elm.swallow.icon");
1873 if (it->wd->disabled || it->disabled)
1874 elm_widget_disabled_set(it->base_item, EINA_TRUE);
1876 elm_widget_disabled_set(it->base_item, EINA_FALSE);
1880 elm_controlbar_item_icon_get(const Elm_Controlbar_Item * it)
1882 if (!it) return NULL;
1887 elm_controlbar_item_label_set(Elm_Controlbar_Item * it, const char *label)
1890 if (it->style == OBJECT) return;
1893 eina_stringshare_del(it->text);
1898 it->text = eina_stringshare_add(label);
1899 elm_object_text_set(it->base_item, it->text);
1901 if (it->wd->disabled || it->disabled)
1902 elm_widget_disabled_set(it->base_item, EINA_TRUE);
1904 elm_widget_disabled_set(it->base_item, EINA_FALSE);
1908 elm_controlbar_item_label_get(const Elm_Controlbar_Item * it)
1910 if (!it) return NULL;
1914 EAPI Elm_Controlbar_Item * elm_controlbar_selected_item_get(const Evas_Object *
1917 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1920 Elm_Controlbar_Item * item;
1921 if (obj == NULL) return NULL;
1922 Widget_Data * wd = elm_widget_data_get(obj);
1923 if (!wd || !wd->items) return NULL;
1924 EINA_LIST_FOREACH(wd->items, l, item)
1926 if (item->selected) return item;
1931 EAPI Elm_Controlbar_Item * elm_controlbar_first_item_get(const Evas_Object * obj)
1933 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1934 Widget_Data * wd = elm_widget_data_get(obj);
1935 if (!wd || !wd->items) return NULL;
1936 return eina_list_data_get(wd->items);
1939 EAPI Elm_Controlbar_Item * elm_controlbar_last_item_get(const Evas_Object * obj)
1941 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1942 Widget_Data * wd = elm_widget_data_get(obj);
1943 if (!wd || !wd->items) return NULL;
1944 return eina_list_data_get(eina_list_last(wd->items));
1947 EAPI const Eina_List * elm_controlbar_items_get(const Evas_Object * obj)
1949 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1950 Widget_Data * wd = elm_widget_data_get(obj);
1951 if (!wd || !wd->items) return NULL;
1955 EAPI Elm_Controlbar_Item * elm_controlbar_item_prev(Elm_Controlbar_Item *
1958 if (!it) return NULL;
1961 Elm_Controlbar_Item * item;
1962 if (it->obj == NULL) return NULL;
1963 Widget_Data * wd = elm_widget_data_get(it->obj);
1964 if (!wd || !wd->items) return NULL;
1965 EINA_LIST_FOREACH(wd->items, l, item)
1969 l = eina_list_prev(l);
1970 if (!l) return NULL;
1971 return eina_list_data_get(l);
1977 EAPI Elm_Controlbar_Item * elm_controlbar_item_next(Elm_Controlbar_Item *
1980 if (!it) return NULL;
1983 Elm_Controlbar_Item * item;
1984 if (it->obj == NULL) return NULL;
1985 Widget_Data * wd = elm_widget_data_get(it->obj);
1986 if (!wd || !wd->items) return NULL;
1987 EINA_LIST_FOREACH(wd->items, l, item)
1991 l = eina_list_next(l);
1992 if (!l) return NULL;
1993 return eina_list_data_get(l);
2000 elm_controlbar_item_visible_set(Elm_Controlbar_Item * it, Eina_Bool visible)
2003 if (it->obj == NULL) return;
2004 Widget_Data * wd = elm_widget_data_get(it->obj);
2007 if (!wd->auto_align)
2008 _set_item_visible(it, visible);
2012 elm_controlbar_item_visible_get(const Elm_Controlbar_Item * it)
2014 if (!it) return EINA_FALSE;
2015 if (it->obj == NULL) return EINA_FALSE;
2016 Widget_Data * wd = elm_widget_data_get(it->obj);
2017 if (!wd) return EINA_FALSE;
2018 if (it->order <= 0) return EINA_FALSE;
2024 elm_controlbar_item_disabled_set(Elm_Controlbar_Item * it, Eina_Bool disabled)
2028 if (it->disabled == disabled) return;
2030 it->disabled = disabled;
2032 if ((it->wd) && (it->wd->disabled)) return;
2034 if (it->base_item) elm_widget_disabled_set(it->base_item, disabled);
2038 elm_controlbar_item_disabled_get(const Elm_Controlbar_Item * it)
2040 if (!it) return EINA_FALSE;
2042 return it->disabled;
2046 elm_controlbar_item_view_set(Elm_Controlbar_Item *it, Evas_Object * view)
2049 if (it->view == view) return;
2051 evas_object_del(it->view);
2056 elm_controlbar_item_view_get(const Elm_Controlbar_Item *it)
2058 if (!it) return NULL;
2064 elm_controlbar_item_view_unset(Elm_Controlbar_Item *it)
2066 if (!it) return NULL;
2067 if (it->obj == NULL) return NULL;
2068 Widget_Data * wd = elm_widget_data_get(it->obj);
2069 if (!wd) return NULL;
2070 Evas_Object *content;
2072 if (it->view == elm_object_part_content_get(wd->edje, "elm.swallow.view"))
2074 content = elm_object_part_content_unset(wd->edje, "elm.swallow.view");
2075 if (content) evas_object_hide(content);
2086 elm_controlbar_mode_set(Evas_Object *obj, int mode)
2088 ELM_CHECK_WIDTYPE(obj, widtype);
2089 Widget_Data *wd = elm_widget_data_get(obj);
2092 fprintf(stderr, "Cannot get smart data\n");
2095 Evas_Object *selected_box;
2101 case ELM_CONTROLBAR_MODE_DEFAULT:
2102 edje_object_signal_emit(_EDJ(wd->edje), "elm,state,default", "elm");
2104 case ELM_CONTROLBAR_MODE_TRANSLUCENCE:
2105 elm_controlbar_alpha_set(obj, 85);
2107 case ELM_CONTROLBAR_MODE_TRANSPARENCY:
2108 elm_controlbar_alpha_set(obj, 0);
2110 case ELM_CONTROLBAR_MODE_LARGE:
2111 edje_object_signal_emit(_EDJ(wd->edje), "elm,state,large", "elm");
2113 case ELM_CONTROLBAR_MODE_SMALL:
2114 edje_object_signal_emit(_EDJ(wd->edje), "elm,state,small", "elm");
2116 case ELM_CONTROLBAR_MODE_LEFT:
2117 selected_box = elm_object_part_content_get(wd->edje, "elm.dragable.box");
2118 if (selected_box) edje_object_signal_emit(_EDJ(selected_box), "elm,state,left", "elm");
2119 wd->selected_signal = eina_stringshare_add("elm,state,selected_left");
2120 wd->pressed_signal = eina_stringshare_add("elm,state,pressed_left");
2121 edje_object_signal_emit(_EDJ(wd->edje), "elm,state,left", "elm");
2122 _check_background(wd);
2125 case ELM_CONTROLBAR_MODE_RIGHT:
2126 selected_box = elm_object_part_content_get(wd->edje, "elm.dragable.box");
2127 if (selected_box) edje_object_signal_emit(_EDJ(selected_box), "elm,state,right", "elm");
2128 wd->selected_signal = eina_stringshare_add("elm,state,selected_right");
2129 wd->pressed_signal = eina_stringshare_add("elm,state,pressed_right");
2130 edje_object_signal_emit(_EDJ(wd->edje), "elm,state,right", "elm");
2131 _check_background(wd);
2137 selected_box = elm_object_part_content_get(wd->edje, "elm.dragable.box");
2138 if (selected_box) edje_object_signal_emit(_EDJ(selected_box), "elm,state,default", "elm");
2139 wd->selected_signal = eina_stringshare_add("elm,state,selected");
2140 wd->pressed_signal = eina_stringshare_add("elm,state,pressed");
2141 _check_background(wd);
2146 elm_controlbar_alpha_set(Evas_Object *obj, int alpha)
2148 ELM_CHECK_WIDTYPE(obj, widtype);
2150 Widget_Data *wd = elm_widget_data_get(obj);
2153 fprintf(stderr, "Cannot get smart data\n");
2157 if (alpha < 0) wd->alpha = 0;
2158 else if (alpha > 100) wd->alpha = 100;
2159 else wd->alpha = alpha;
2161 evas_object_color_get(wd->bg, &r, &g, &b, NULL);
2162 evas_object_color_set(wd->bg, r, g, b, (int)(255 * wd->alpha / 100));
2166 elm_controlbar_item_auto_align_set(Evas_Object *obj, Eina_Bool auto_align)
2168 ELM_CHECK_WIDTYPE(obj, widtype);
2169 Widget_Data *wd = elm_widget_data_get(obj);
2170 Elm_Controlbar_Item *item;
2175 fprintf(stderr, "Cannot get smart data\n");
2179 if (wd->auto_align == auto_align) return;
2183 if ((_check_bar_item_number(wd)) >= 5 && (!wd->more_item))
2186 EINA_LIST_FOREACH(wd->items, l, item)
2188 if (elm_controlbar_item_visible_get(item))
2191 _delete_item_in_bar(item);
2194 item = elm_controlbar_last_item_get(obj);
2195 while (!elm_controlbar_item_visible_get(item)){
2196 item = elm_controlbar_item_prev(item);
2198 _create_more_item(wd, item->style);
2206 if (wd->more_item->view)
2207 evas_object_del(wd->more_item->view);
2208 wd->items = eina_list_remove(wd->items, wd->more_item);
2209 eina_stringshare_del(wd->more_item->text);
2210 if (wd->more_item->icon)
2211 evas_object_del(wd->more_item->icon);
2212 if (wd->more_item->base)
2213 evas_object_del(wd->more_item->base);
2214 if (wd->more_item->base_item)
2215 evas_object_del(wd->more_item->base_item);
2216 free(wd->more_item);
2217 wd->more_item = NULL;
2219 // make all item is visible
2221 EINA_LIST_FOREACH(wd->items, l, item)
2223 if (!elm_controlbar_item_visible_get(item))
2224 _insert_item_in_bar(item, i);
2229 wd->auto_align = auto_align;
2234 elm_controlbar_vertical_set(Evas_Object *obj, Eina_Bool vertical)
2236 ELM_CHECK_WIDTYPE(obj, widtype);
2237 Widget_Data *wd = elm_widget_data_get(obj);
2240 fprintf(stderr, "Cannot get smart data\n");
2244 if (wd->vertical == vertical) return;
2245 wd->vertical = vertical;
2247 if (_check_bar_item_number(wd) > 1)
2251 _check_toolbar_line(wd);
2255 elm_controlbar_item_button_get(const Elm_Controlbar_Item *it)
2257 if (!it) return NULL;
2258 if (it->style == OBJECT) return NULL;
2260 if (it->base_item) return it->base_item;