2 * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
5 * @defgroup Controlbar Controlbar
8 * This is a Controlbar. It can contain label and icon objects.
9 * In edit mode, you can change the location of items.
16 #include <Elementary.h>
20 #define EAPI __attribute__ ((visibility("default")))
24 #define EDIT_ROW_NUM 4
26 #define ELM_MAX(v1, v2) (((v1) > (v2)) ? (v1) : (v2))
27 #define _EDJ(x) (Evas_Object *)elm_layout_edje_get(x)
33 // internal data structure of controlbar object
34 typedef struct _Widget_Data Widget_Data;
42 Evas_Object * view_content;
43 Evas_Object * edit_box;
44 Evas_Object * edit_table;
45 Evas_Object * navigation;
49 Evas_Object * event_box;
50 Evas_Object * selected_box;
51 Evas_Object * focused_box;
52 Evas_Object * focused_box_left;
53 Evas_Object * focused_box_right;
55 Evas_Object * moving_obj;
56 Elm_Controlbar_Item * more_item;
57 Elm_Controlbar_Item * moving_item;
58 Elm_Controlbar_Item * pre_item;
59 Elm_Controlbar_Item * cur_item;
60 Evas_Coord x, y, w, h;
69 Eina_List * visible_items;
71 Ecore_Event_Handler * move_event;
72 Ecore_Event_Handler * up_event;
73 Ecore_Event_Handler * bar_move_event;
74 Ecore_Event_Handler * bar_up_event;
76 void (*ani_func) (void *data, Evas_Object * obj, void *event_info);
78 Eina_Bool init_animation;
80 Ecore_Timer *effect_timer;
81 Eina_Bool selected_animation;
84 Elm_Xml_Animator *vxa;
86 const char *view_hide;
87 const char *view_show;
89 const char *pressed_signal;
90 const char *selected_signal;
93 struct _Elm_Controlbar_Item
97 Evas_Object * base_item;
99 Evas_Object * edit_item;
102 Evas_Object * label_shadow;
104 Evas_Object * icon_shadow;
105 Evas_Object * edit_label;
106 Evas_Object * edit_label_shadow;
107 Evas_Object * edit_icon;
108 Evas_Object * edit_icon_shadow;
109 const char *icon_path;
111 void (*func) (void *data, Evas_Object * obj, void *event_info);
122 typedef struct _Animation_Data Animation_Data;
124 struct _Animation_Data
135 unsigned int start_time;
137 void (*func) (void *data, Evas_Object * obj);
139 Ecore_Animator * timer;
144 static int check_bar_item_number(Widget_Data *wd);
145 static void selected_box(Elm_Controlbar_Item * it);
146 static int pressed_box(Elm_Controlbar_Item * it);
147 static void item_color_set(Elm_Controlbar_Item *item, const char *color_part);
148 static void edit_item_up_cb(void *data, Evas *evas, Evas_Object *obj, void *event_info);
149 static void edit_item_move_cb(void *data, Evas *evas, Evas_Object *obj, void *event_info);
150 static void bar_item_up_cb(void *data, Evas *evas, Evas_Object *obj, void *event_info);
151 static void bar_item_move_cb(void *data, Evas *evas, Evas_Object *obj, void *event_info);
153 /////////////////////////
155 ////////////////////////
158 print_all_items(Widget_Data *wd)
161 Elm_Controlbar_Item * item;
163 EINA_LIST_FOREACH(wd->items, l, item)
165 printf("item label : %s order : %d address : %p\n", item->text, item->order, item);
169 ///////////////////////////////////////////////////////////////////
171 // Smart Object basic function
173 ////////////////////////////////////////////////////////////////////
176 _controlbar_move(void *data, Evas_Object * obj)
179 Evas_Coord x, y, x_, y_, width;
182 wd = elm_widget_data_get((Evas_Object *) data);
185 evas_object_geometry_get(wd->edje, &x, &y, NULL, NULL);
188 evas_object_move(wd->edje, x, y);
189 evas_object_geometry_get(edje_object_part_object_get(wd->edje, "bg_image"), NULL, NULL, &width, NULL);
190 evas_object_geometry_get(wd->parent, &x_, &y_, NULL, NULL);
193 case ELM_CONTROLBAR_MODE_LEFT:
194 evas_object_move(wd->view, x + width, y);
196 case ELM_CONTROLBAR_MODE_RIGHT:
198 evas_object_move(wd->view, x, y);
201 evas_object_move(wd->edit_box, x_, y_);
202 evas_object_move(wd->event_box, x, y);
206 _controlbar_resize(void *data, Evas_Object * obj)
209 Elm_Controlbar_Item *item;
211 Evas_Coord x, y, x_, y_, w, h, width, height;
214 wd = elm_widget_data_get((Evas_Object *) data);
217 evas_object_geometry_get(wd->edje, &x, &y, &w, &h);
220 evas_object_resize(wd->edje, w, h);
221 evas_object_geometry_get(edje_object_part_object_get(wd->edje, "bg_image"), NULL, NULL, &width, &height);
222 evas_object_geometry_get(wd->parent, &x_, &y_, NULL, NULL);
225 case ELM_CONTROLBAR_MODE_LEFT:
226 case ELM_CONTROLBAR_MODE_RIGHT:
227 evas_object_resize(wd->view, w - width, h);
228 evas_object_resize(wd->edit_box, w + x - x_, h);
231 evas_object_resize(wd->view, w, h - height + 1);
232 evas_object_resize(wd->edit_box, w, h + y - y_);
235 evas_object_resize(wd->event_box, w, h);
237 EINA_LIST_FOREACH(wd->items, l, item)
243 elm_label_wrap_width_set(item->label, (int)(wd->w/check_bar_item_number(wd))-20);
244 elm_label_wrap_width_set(item->label_shadow, (int)(wd->w/check_bar_item_number(wd))-20);
248 elm_label_wrap_width_set(item->label, (int)(wd->w-20));
249 elm_label_wrap_width_set(item->label_shadow, (int)(wd->w-20));
254 elm_label_wrap_width_set(item->edit_label, (int)(wd->w/check_bar_item_number(wd))-20);
255 elm_label_wrap_width_set(item->edit_label_shadow, (int)(wd->w/check_bar_item_number(wd))-20);
261 _controlbar_object_move(void *data, Evas * e, Evas_Object * obj,
264 _controlbar_move(data, obj);
268 _controlbar_object_resize(void *data, Evas * e, Evas_Object * obj,
271 _controlbar_resize(data, obj);
275 _controlbar_object_show(void *data, Evas * e, Evas_Object * obj,
281 wd = elm_widget_data_get((Evas_Object *) data);
284 evas_object_show(wd->view);
285 evas_object_show(wd->edit_box);
286 evas_object_show(wd->edje);
287 evas_object_show(wd->box);
288 evas_object_show(wd->event_box);
292 _controlbar_object_hide(void *data, Evas * e, Evas_Object * obj,
298 wd = elm_widget_data_get((Evas_Object *) data);
301 evas_object_hide(wd->view);
302 evas_object_hide(wd->edit_box);
303 evas_object_hide(wd->edje);
304 evas_object_hide(wd->box);
305 evas_object_hide(wd->event_box);
309 _item_del(Elm_Controlbar_Item *it)
312 Widget_Data *wd = elm_widget_data_get(it->obj);
315 if(it == wd->more_item)
317 evas_object_del(it->view);
319 eina_stringshare_del(it->text);
321 evas_object_del(it->label);
322 if (it->label_shadow)
323 evas_object_del(it->label_shadow);
325 eina_stringshare_del(it->icon_path);
327 evas_object_del(it->icon);
329 evas_object_del(it->icon_shadow);
332 if (it->style != OBJECT)
333 evas_object_del(it->base);
336 evas_object_hide(it->base);
339 evas_object_del(it->base_item);
341 evas_object_del(it->edit);
343 evas_object_del(it->edit_item);
347 elm_layout_content_unset(wd->view, "elm.swallow.view");
348 evas_object_hide(it->view);
353 _del_hook(Evas_Object * obj)
355 Widget_Data * wd = elm_widget_data_get(obj);
356 Elm_Controlbar_Item * item;
357 Evas_Object * content;
361 EINA_LIST_FREE(wd->items, item)
369 content = elm_layout_content_unset(wd->view, "elm.swallow.view");
370 evas_object_hide(content);
371 evas_object_del(wd->view);
376 evas_object_del(wd->edit_box);
381 evas_object_del(wd->navigation);
382 wd->navigation = NULL;
386 evas_object_del(wd->bg);
391 evas_object_del(wd->edje);
394 if (wd->selected_box)
396 evas_object_del(wd->selected_box);
401 evas_object_del(wd->box);
406 evas_object_del(wd->event_box);
407 wd->event_box = NULL;
411 elm_xml_animator_del(wd->xa);
414 if (wd->effect_timer)
416 ecore_timer_del(wd->effect_timer);
417 wd->effect_timer = NULL;
425 _theme_hook(Evas_Object * obj)
429 Elm_Controlbar_Item * item;
433 Widget_Data * wd = elm_widget_data_get(obj);
436 _elm_theme_object_set(obj, wd->edje, "controlbar", "base",
437 elm_widget_style_get(obj));
438 _elm_theme_object_set(obj, wd->bg, "controlbar", "background",
439 elm_widget_style_get(obj));
440 evas_object_color_get(wd->bg, &r, &g, &b, NULL);
441 evas_object_color_set(wd->bg, r, g, b, (int)(255 * wd->alpha / 100));
442 elm_layout_theme_set(wd->view, "controlbar", "view", elm_widget_style_get(obj));
443 _elm_theme_object_set(obj, wd->edit_box, "controlbar", "edit_box",
444 elm_widget_style_get(obj));
445 EINA_LIST_FOREACH(wd->items, l, item)
447 if (item->style != OBJECT)
449 elm_layout_theme_set(item->base, "controlbar", "item_bg",
450 elm_widget_style_get(obj));
451 elm_layout_theme_set(item->edit, "controlbar", "item_bg",
452 elm_widget_style_get(obj));
457 edje_object_part_object_get(_EDJ(item->edit),
458 "elm.item.uneditable.color");
460 evas_object_color_get(color, &r, &g, &b, &a);
461 evas_object_color_set(item->edit_item, r, g, b, a);
463 if (item->label && item->icon)
465 edje_object_signal_emit(_EDJ(item->base_item),
466 "elm,state,icon_text", "elm");
467 edje_object_signal_emit(_EDJ(item->edit_item),
468 "elm,state,icon_text", "elm");
479 _sub_del(void *data, Evas_Object * obj, void *event_info)
481 Widget_Data * wd = elm_widget_data_get(obj);
483 //Evas_Object *sub = event_info;
488 * if (sub == wd->icon)
490 * edje_object_signal_emit(wd->btn, "elm,state,icon,hidden", "elm");
491 * evas_object_event_callback_del_full(sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
492 * _changed_size_hints, obj);
494 * edje_object_message_signal_process(wd->btn);
501 _sizing_eval(Evas_Object * obj)
503 Widget_Data * wd = elm_widget_data_get(obj);
506 _controlbar_move(obj, obj);
507 _controlbar_resize(obj, obj);
510 /////////////////////////////////////////////////////////////
512 // animation function
514 /////////////////////////////////////////////////////////////
519 struct timeval timev;
521 gettimeofday(&timev, NULL);
522 return ((timev.tv_sec * 1000) + ((timev.tv_usec) / 1000));
526 set_evas_map(Evas_Object * obj, Evas_Coord x, Evas_Coord y, Evas_Coord w,
533 Evas_Map * map = evas_map_new(4);
536 evas_map_smooth_set(map, EINA_TRUE);
537 evas_map_util_points_populate_from_object_full(map, obj, 0);
538 evas_object_map_enable_set(obj, EINA_TRUE);
539 evas_map_util_3d_perspective(map, x + w / 2, y + h / 2, 0, w * 10);
540 evas_map_util_points_populate_from_geometry(map, x, y, w, h, 0);
541 evas_object_map_set(obj, map);
546 move_evas_map(void *data)
556 Animation_Data * ad = (Animation_Data *) data;
557 t = ELM_MAX(0.0, current_time_get() - ad->start_time) / 1000;
558 dx = ad->tx - ad->fx;
559 dy = ad->ty - ad->fy;
560 dw = ad->tw - ad->fw;
561 dh = ad->th - ad->fh;
564 x = (1 * sin((t / ad->time) * (M_PI / 2)) * dx);
565 y = (1 * sin((t / ad->time) * (M_PI / 2)) * dy);
566 w = (1 * sin((t / ad->time) * (M_PI / 2)) * dw);
567 h = (1 * sin((t / ad->time) * (M_PI / 2)) * dh);
580 if (x == dx && y == dy && w == dw && h == dh)
582 ecore_animator_del(ad->timer);
584 set_evas_map(ad->obj, px, py, pw, ph);
585 if (ad->func != NULL)
586 ad->func(ad->data, ad->obj);
587 return ECORE_CALLBACK_CANCEL;
591 set_evas_map(ad->obj, px, py, pw, ph);
593 return ECORE_CALLBACK_RENEW;
598 move_evas_object(void *data)
608 Animation_Data * ad = (Animation_Data *) data;
609 t = ELM_MAX(0.0, current_time_get() - ad->start_time) / 1000;
610 dx = ad->tx - ad->fx;
611 dy = ad->ty - ad->fy;
612 dw = ad->tw - ad->fw;
613 dh = ad->th - ad->fh;
616 x = (1 * sin((t / ad->time) * (M_PI / 2)) * dx);
617 y = (1 * sin((t / ad->time) * (M_PI / 2)) * dy);
618 w = (1 * sin((t / ad->time) * (M_PI / 2)) * dw);
619 h = (1 * sin((t / ad->time) * (M_PI / 2)) * dh);
632 if (x == dx && y == dy && w == dw && h == dh)
634 ecore_animator_del(ad->timer);
636 evas_object_move(ad->obj, px, py);
637 evas_object_resize(ad->obj, pw, ph);
638 evas_object_show(ad->obj);
639 if (ad->func != NULL)
640 ad->func(ad->data, ad->obj);
641 return ECORE_CALLBACK_CANCEL;
645 evas_object_move(ad->obj, px, py);
646 evas_object_resize(ad->obj, pw, ph);
647 evas_object_show(ad->obj);
649 return ECORE_CALLBACK_RENEW;
653 move_fade_out_object(void *data)
657 int dx, dy, dw, dh, da;
659 int px, py, pw, ph, pa;
665 Animation_Data * ad = (Animation_Data *) data;
666 t = ELM_MAX(0.0, current_time_get() - ad->start_time) / 1000;
667 dx = ad->tx - ad->fx;
668 dy = ad->ty - ad->fy;
669 dw = ad->tw - ad->fw;
670 dh = ad->th - ad->fh;
674 x = (1 * sin((t / ad->time) * (M_PI / 2)) * dx);
675 y = (1 * sin((t / ad->time) * (M_PI / 2)) * dy);
676 w = (1 * sin((t / ad->time) * (M_PI / 2)) * dw);
677 h = (1 * sin((t / ad->time) * (M_PI / 2)) * dh);
678 a = (1 * sin((t / ad->time) * (M_PI / 2)) * da);
693 if (x == dx && y == dy && w == dw && h == dh)
695 ecore_animator_del(ad->timer);
697 evas_object_move(ad->obj, px, py);
698 //evas_object_resize(ad->obj, 480, 600);
699 evas_object_resize(ad->obj, pw, ph);
700 evas_object_color_get(ad->obj, &r, &g, &b, &a);
701 evas_object_color_set(ad->obj, r, g, b, pa);
702 evas_object_show(ad->obj);
703 if (ad->func != NULL)
704 ad->func(ad->data, ad->obj);
705 return ECORE_CALLBACK_CANCEL;
709 evas_object_move(ad->obj, px, py);
710 //evas_object_resize(ad->obj, 480, 600);
711 evas_object_resize(ad->obj, pw, ph);
712 evas_object_color_get(ad->obj, &r, &g, &b, &a);
713 evas_object_color_set(ad->obj, r, g, b, pa);
714 evas_object_show(ad->obj);
716 return ECORE_CALLBACK_RENEW;
720 move_fade_in_object(void *data)
724 int dx, dy, dw, dh, da;
726 int px, py, pw, ph, pa;
732 Animation_Data * ad = (Animation_Data *) data;
733 t = ELM_MAX(0.0, current_time_get() - ad->start_time) / 1000;
734 dx = ad->tx - ad->fx;
735 dy = ad->ty - ad->fy;
736 dw = ad->tw - ad->fw;
737 dh = ad->th - ad->fh;
741 x = (1 * sin((t / ad->time) * (M_PI / 2)) * dx);
742 y = (1 * sin((t / ad->time) * (M_PI / 2)) * dy);
743 w = (1 * sin((t / ad->time) * (M_PI / 2)) * dw);
744 h = (1 * sin((t / ad->time) * (M_PI / 2)) * dh);
745 a = (1 * sin((t / ad->time) * (M_PI / 2)) * da);
760 if (x == dx && y == dy && w == dw && h == dh)
762 ecore_animator_del(ad->timer);
764 evas_object_move(ad->obj, px, py);
765 //evas_object_resize(ad->obj, 480, 600);
766 evas_object_resize(ad->obj, pw, ph);
767 evas_object_color_get(ad->obj, &r, &g, &b, &a);
768 evas_object_color_set(ad->obj, r, g, b, pa);
769 evas_object_show(ad->obj);
770 if (ad->func != NULL)
771 ad->func(ad->data, ad->obj);
772 return ECORE_CALLBACK_CANCEL;
776 evas_object_move(ad->obj, px, py);
777 //evas_object_resize(ad->obj, 480, 600);
778 evas_object_resize(ad->obj, pw, ph);
779 evas_object_color_get(ad->obj, &r, &g, &b, &a);
780 evas_object_color_set(ad->obj, r, g, b, pa);
781 evas_object_show(ad->obj);
783 return ECORE_CALLBACK_RENEW;
787 move_object_with_animation(Evas_Object * obj, Evas_Coord x, Evas_Coord y,
788 Evas_Coord w, Evas_Coord h, Evas_Coord x_,
789 Evas_Coord y_, Evas_Coord w_, Evas_Coord h_,
790 double time, Eina_Bool (*mv_func) (void *data),
791 void (*func) (void *data,
792 Evas_Object * obj), void *data)
794 Animation_Data * ad = (Animation_Data *) malloc(sizeof(Animation_Data));
804 ad->start_time = current_time_get();
808 ad->timer = ecore_animator_add(mv_func, ad);
812 end_item_animation_effect(void *data, Evas_Object *obj)
814 Widget_Data *wd = (Widget_Data *)data;
815 elm_xml_animator_object_del(wd->xa, obj);
819 item_animation_effect(void *data)
821 Widget_Data *wd = (Widget_Data *)data;
823 Elm_Controlbar_Item * item;
827 wd->xa = elm_xml_animator_add(wd->object);
828 elm_xml_animator_file_set(wd->xa, "/usr/share/xmls/elementary.xml");
833 EINA_LIST_FOREACH(wd->items, l, item)
836 if(rand > 65 && item->order > 0)
842 elm_xml_animator_object_add(wd->xa, item->base_item, "test", end_item_animation_effect, wd);
845 elm_xml_animator_object_add(wd->xa, item->base_item, "test2", end_item_animation_effect, wd);
848 elm_xml_animator_object_add(wd->xa, item->base_item, "test3", end_item_animation_effect, wd);
851 elm_xml_animator_object_add(wd->xa, item->base_item, "test4", end_item_animation_effect, wd);
860 elm_xml_animator_run(wd->xa);
862 return ECORE_CALLBACK_RENEW;
865 /////////////////////////////////////////////////////////////
869 /////////////////////////////////////////////////////////////
872 sort_cb(const void *d1, const void *d2)
874 Elm_Controlbar_Item * item1, *item2;
875 item1 = (Elm_Controlbar_Item *) d1;
876 item2 = (Elm_Controlbar_Item *) d2;
877 if (item1->order <= 0)
879 if (item2->order <= 0)
881 return item1->order > item2->order ? 1 : -1;
885 sort_reverse_cb(const void *d1, const void *d2)
887 Elm_Controlbar_Item * item1, *item2;
888 item1 = (Elm_Controlbar_Item *) d1;
889 item2 = (Elm_Controlbar_Item *) d2;
890 if (item1->order <= 0)
892 if (item2->order <= 0)
894 return item1->order > item2->order ? -1 : 1;
898 done_button_cb(void *data, Evas_Object * obj, void *event_info)
900 Widget_Data * wd = (Widget_Data *) data;
902 wd->items = eina_list_sort(wd->items, eina_list_count(wd->items), sort_cb);
904 evas_object_smart_callback_call(wd->object, "edit,end", wd->items);
906 edje_object_signal_emit(wd->edit_box, "elm,state,hide,edit_box", "elm");
907 wd->edit_mode = EINA_FALSE;
910 ///////////////////////////////////////////////////////////////////
912 // basic utility function
914 ////////////////////////////////////////////////////////////////////
917 item_exist_check(Widget_Data *wd, Elm_Controlbar_Item *item)
920 Elm_Controlbar_Item *it;
922 EINA_LIST_FOREACH(wd->items, l, it)
924 if(it == item) return EINA_TRUE;
930 check_bar_item_number(Widget_Data *wd)
933 Elm_Controlbar_Item * item;
936 EINA_LIST_FOREACH(wd->items, l, item)
938 if(item->order > 0) num++;
945 item_insert_in_bar(Elm_Controlbar_Item * it, int order)
949 Elm_Controlbar_Item * item;
950 Widget_Data * wd = elm_widget_data_get(it->obj);
953 if(order == 0) return;
955 EINA_LIST_FOREACH(wd->items, l, item)
957 if (item->order == order && item != it)
962 EINA_LIST_FOREACH(wd->items, l, item)
965 elm_table_unpack(wd->box, item->base);
967 EINA_LIST_FOREACH(wd->items, l, item)
971 if (item->order >= order)
975 elm_table_pack(wd->box, item->base, item->order - 1, 0, 1, 1);
979 elm_table_pack(wd->box, item->base, 0, item->order - 1, 1, 1);
981 evas_object_show(item->base);
988 elm_table_pack(wd->box, it->base, it->order - 1, 0, 1, 1);
992 elm_table_pack(wd->box, it->base, 0, it->order - 1, 1, 1);
994 evas_object_show(it->base);
998 item_delete_in_bar(Elm_Controlbar_Item * it)
1001 Elm_Controlbar_Item * item;
1002 Widget_Data * wd = elm_widget_data_get(it->obj);
1005 EINA_LIST_FOREACH(wd->items, l, item)
1011 elm_table_unpack(wd->box, it->base);
1012 evas_object_hide(it->base);
1017 EINA_LIST_FOREACH(wd->items, l, item)
1019 if (item->order > i)
1022 elm_table_unpack(wd->box, item->base);
1025 elm_table_pack(wd->box, item->base, item->order - 1, 0, 1, 1);
1029 elm_table_pack(wd->box, item->base, 0, item->order - 1, 1, 1);
1037 item_exchange_animation_cb(void *data, Evas_Object * obj)
1039 Widget_Data * wd = (Widget_Data *) data;
1041 if (wd->animating < 0)
1043 printf("animation error\n");
1046 evas_object_map_enable_set(obj, EINA_FALSE);
1050 item_exchange_in_bar(Elm_Controlbar_Item * it1, Elm_Controlbar_Item * it2)
1054 Evas_Coord x, y, w, h;
1055 Evas_Coord x_, y_, w_, h_;
1056 Widget_Data * wd = elm_widget_data_get(it1->obj);
1057 evas_object_geometry_get(wd->moving_item->edit, &x, &y, &w, &h);
1058 set_evas_map(wd->moving_obj, (wd->x + wd->w / 2), (wd->y + wd->h / 2), 0,
1060 evas_object_geometry_get(it1->base, &x, &y, &w, &h);
1061 evas_object_geometry_get(it2->base, &x_, &y_, &w_, &h_);
1063 move_object_with_animation(it1->base, x, y, w, h, x_, y_, w_, h_, 0.25,
1064 move_evas_map, item_exchange_animation_cb, wd);
1066 move_object_with_animation(it2->base, x_, y_, w_, h_, x, y, w, h, 0.25,
1067 move_evas_map, item_exchange_animation_cb, wd);
1068 elm_table_unpack(wd->box, it1->base);
1069 elm_table_unpack(wd->box, it2->base);
1071 it1->order = it2->order;
1075 elm_table_pack(wd->box, it1->base, it1->order - 1, 0, 1, 1);
1076 elm_table_pack(wd->box, it2->base, it2->order - 1, 0, 1, 1);
1080 elm_table_pack(wd->box, it1->base, 0, it1->order - 1, 1, 1);
1081 elm_table_pack(wd->box, it2->base, 0, it2->order - 1, 1, 1);
1086 item_change_animation_cb(void *data, Evas_Object * obj)
1088 Evas_Coord x, y, w, h;
1089 Widget_Data * wd = (Widget_Data *) data;
1091 if (wd->animating < 0)
1093 printf("animation error\n");
1096 evas_object_map_enable_set(obj, EINA_FALSE);
1097 evas_object_geometry_get(obj, &x, &y, &w, &h);
1098 set_evas_map(obj, x, y, 0, 0);
1099 evas_object_move(obj, -1000, -1000);
1100 evas_object_geometry_get(wd->moving_item->base, &x, &y, &w, &h);
1101 evas_object_move(wd->moving_obj, -1000, -1000);
1102 evas_object_del(wd->moving_obj);
1106 item_change_in_bar(Elm_Controlbar_Item * it)
1108 Evas_Coord x, y, w, h;
1109 Evas_Coord x_, y_, w_, h_;
1110 Widget_Data * wd = elm_widget_data_get(it->obj);
1113 if (wd->moving_item == NULL)
1115 evas_object_geometry_get(wd->moving_item->edit, &x, &y, &w, &h);
1116 set_evas_map(wd->moving_obj, x, y, w, h);
1117 elm_table_unpack(wd->box, it->base);
1118 wd->moving_item->order = it->order;
1122 elm_table_pack(wd->box, wd->moving_item->base, wd->moving_item->order - 1, 0, 1, 1);
1126 elm_table_pack(wd->box, wd->moving_item->base, 0, wd->moving_item->order - 1, 1, 1);
1129 evas_object_show(wd->moving_item->base);
1130 evas_render_updates_free(evas_render_updates
1131 (evas_object_evas_get(wd->moving_item->base)));
1132 evas_object_geometry_get(it->base, &x, &y, &w, &h);
1133 evas_object_geometry_get(it->edit, &x_, &y_, &w_, &h_);
1135 move_object_with_animation(it->base, x, y, w, h, x_, y_, w_, h_, 0.25,
1136 move_evas_map, item_change_animation_cb, wd);
1137 evas_object_geometry_get(wd->moving_item->base, &x, &y, &w, &h);
1138 set_evas_map(wd->moving_item->base, x, y, w, h);
1142 hide_selected_box(void *data)
1144 Evas_Object *selected_box = (Evas_Object *)data;
1146 evas_object_hide(selected_box);
1148 return ECORE_CALLBACK_CANCEL;
1152 item_color_set(Elm_Controlbar_Item *item, const char *color_part)
1157 color = (Evas_Object *) edje_object_part_object_get(_EDJ(item->base), color_part);
1159 evas_object_color_get(color, &r, &g, &b, &a);
1160 evas_object_color_set(item->label, r, g, b, a);
1161 evas_object_color_set(item->icon, r, g, b, a);
1165 _end_selected_box(void *data, Evas_Object *obj)
1167 Widget_Data * wd = (Widget_Data *)data;
1169 edje_object_signal_emit(_EDJ(wd->cur_item->base), wd->selected_signal, "elm");
1170 edje_object_signal_emit(_EDJ(wd->cur_item->base_item), "elm,state,shadow_show", "elm");
1173 if (wd->animating < 0)
1175 printf("animation error\n");
1179 ecore_idler_add(hide_selected_box, wd->selected_box);
1183 move_selected_box(Widget_Data *wd, Elm_Controlbar_Item * fit, Elm_Controlbar_Item * tit)
1185 Evas_Coord fx, fy, fw, fh, tx, ty, tw, th;
1186 Evas_Object *from, *to;
1188 if(fit->order <= 0 && wd->auto_align)
1189 fit = wd->more_item;
1191 from = (Evas_Object *)edje_object_part_object_get(_EDJ(fit->base), "bg_img");
1192 evas_object_geometry_get(from, &fx, &fy, &fw, &fh);
1194 to = (Evas_Object *)edje_object_part_object_get(_EDJ(tit->base), "bg_img");
1195 evas_object_geometry_get(to, &tx, &ty, &tw, &th);
1197 edje_object_signal_emit(_EDJ(wd->pre_item->base), "elm,state,unselected", "elm");
1198 edje_object_signal_emit(_EDJ(wd->pre_item->base_item), "elm,state,shadow_hide", "elm");
1199 edje_object_signal_emit(_EDJ(wd->cur_item->base), "elm,state,unselected", "elm");
1202 move_object_with_animation(wd->selected_box, fx, fy, fw, fh, tx, ty, tw, th,
1203 0.3, move_evas_object, _end_selected_box, wd);
1207 end_selected_box(void *data, Evas_Object *obj)
1209 Widget_Data * wd = (Widget_Data *)data;
1211 if(wd->pre_item) evas_object_hide(wd->pre_item->view);
1213 elm_layout_content_set(wd->view, "elm.swallow.view", obj);
1215 evas_object_show(obj);
1219 view_animation_push(Widget_Data *wd, Evas_Object *pre, Evas_Object *cur, void *data)
1221 Evas_Coord x, y, w, h;
1223 evas_object_geometry_get(pre, &x, &y, &w, &h);
1224 move_object_with_animation(pre, x, y, w, h, x+20, y, w, h, 0.5, move_fade_out_object, NULL, NULL);
1225 move_object_with_animation(cur, x+120, y, w, h, x, y, w, h, 0.5, move_fade_in_object, end_selected_box, wd);
1229 view_animation_down(Widget_Data *wd, Evas_Object *pre, Evas_Object *cur, void *data)
1231 Evas_Coord x, y, w, h;
1233 evas_object_geometry_get(pre, &x, &y, &w, &h);
1235 move_object_with_animation(cur, x, h, w, h, x, h, w, h, 0.5, move_evas_object, end_selected_box, wd);
1236 evas_object_raise(pre);
1237 move_object_with_animation(pre, x, y, w, h, x, h, w, 0, 0.5, move_evas_map, NULL, NULL);
1241 end_view_animation_effect(void *data, Evas_Object *obj)
1243 Widget_Data *wd = (Widget_Data *)data;
1244 elm_xml_animator_object_del(wd->vxa, obj);
1246 evas_object_hide(wd->pre_item->view);
1248 //if(wd->cur_item) elm_layout_content_set(wd->view, "elm.swallow.view", wd->cur_item->view);
1252 selected_box(Elm_Controlbar_Item * it)
1254 Widget_Data * wd = elm_widget_data_get(it->obj);
1256 Elm_Controlbar_Item * item, *fit = NULL;
1257 Evas_Object * content;
1259 if(wd->animating) return;
1264 wd->vxa = elm_xml_animator_add(wd->object);
1265 elm_xml_animator_file_set(wd->vxa, "/usr/share/xmls/elementary.xml");
1268 if(it->style == TABBAR){
1270 content = elm_layout_content_unset(wd->view, "elm.swallow.view");
1271 EINA_LIST_FOREACH(wd->items, l, item){
1272 if(item->selected) {
1276 item->selected = EINA_FALSE;
1278 it->selected = EINA_TRUE;
1279 evas_object_smart_callback_call(it->obj, "view,change,before", it);
1281 if(fit != NULL && fit != it)
1283 move_selected_box(wd, fit, it);
1287 edje_object_signal_emit(_EDJ(it->base), wd->selected_signal, "elm");
1288 edje_object_signal_emit(_EDJ(wd->cur_item->base_item), "elm,state,shadow_show", "elm");
1292 if(fit != NULL && fit != it)
1294 //view_animation_down(wd, fit->view, it->view, NULL);
1295 view_animation_push(wd, fit->view, it->view, NULL);
1296 //evas_object_hide(content);
1298 // evas_object_geometry_get(fit->view, &x, &y, &w, &h);
1299 // if(fit->order > it->order)
1301 // move_object_with_animation(fit->view, x, y, w, h, x+20, y, w, h, 0.5, move_fade_out_object, NULL, NULL);
1302 // move_object_with_animation(it->view, x+120, y, w, h, x, y, w, h, 0.5, move_fade_in_object, end_selected_box, wd);
1306 // move_object_with_animation(fit->view, x, y, w, h, x-120, y, w, h, 1.5, move_fade_out_object, NULL, NULL);
1307 // move_object_with_animation(it->view, x-120, y, w, h, x, y, w, h, 1.5, move_fade_in_object, end_selected_box, wd);
1312 end_selected_box(wd, it->view);
1315 //if(wd->pre_item) evas_object_hide(wd->pre_item->view);
1316 elm_layout_content_set(wd->view, "elm.swallow.view", it->view);
1318 //evas_object_move(it->view, -480, 94);
1319 //evas_object_resize(it->view, 480, 620);
1320 //evas_object_show(it->view);
1322 if(wd->pre_item && wd->pre_item != it)
1325 elm_xml_animator_object_add(wd->vxa, wd->pre_item->view, wd->view_hide, end_view_animation_effect, wd);
1327 evas_object_hide(wd->pre_item->view);
1329 elm_xml_animator_object_add(wd->vxa, it->view, wd->view_show, end_view_animation_effect, wd);
1333 elm_xml_animator_run(wd->vxa);
1335 // elm_layout_content_set(wd->view, "elm.swallow.view", it->view);
1336 //edje_object_part_swallow(wd->view, "elm.swallow.view", it->view);
1337 // evas_object_show(it->view);
1339 }else if(it->style == TOOLBAR){
1342 it->func(it->data, it->obj, it);
1344 if(item_exist_check(wd, it)) edje_object_signal_emit(_EDJ(it->base), "elm,state,text_unselected", "elm");
1347 if(item_exist_check(wd, it)) evas_object_smart_callback_call(it->obj, "clicked", it);
1351 unpressed_box_cb(void *data, Evas *evas, Evas_Object *obj, void *event_info)
1353 Widget_Data * wd = (Widget_Data *) data;
1355 Evas_Event_Mouse_Up * ev = event_info;
1356 Evas_Coord x, y, w, h;
1357 Elm_Controlbar_Item * item;
1359 evas_object_event_callback_del(wd->event_box, EVAS_CALLBACK_MOUSE_UP, unpressed_box_cb);
1361 EINA_LIST_FOREACH(wd->items, l, item)
1363 if (item->style == TABBAR)
1367 edje_object_signal_emit(_EDJ(item->base), wd->selected_signal, "elm");
1371 edje_object_signal_emit(_EDJ(item->base), "elm,state,unselected", "elm");
1372 edje_object_signal_emit(_EDJ(item->base_item), "elm,state,shadow_hide", "elm");
1375 else if (item->style == TOOLBAR)
1379 edje_object_signal_emit(_EDJ(item->base), "elm,state,unselected", "elm");
1380 //item_color_set(item, "elm.item.default.color");
1385 evas_object_geometry_get(wd->pre_item->base, &x, &y, &w, &h);
1386 if(ev->output.x > x && ev->output.x < x+w && ev->output.y > y && ev->output.y < y+h)
1388 selected_box(wd->pre_item);
1395 pressed_box(Elm_Controlbar_Item * it)
1397 Widget_Data * wd = elm_widget_data_get(it->obj);
1400 Elm_Controlbar_Item * item;
1402 if(wd->animating) return EXIT_FAILURE;
1404 if(it->disable) return EXIT_FAILURE;
1406 EINA_LIST_FOREACH(wd->items, l, item)
1410 if (it->style == TABBAR)
1412 edje_object_signal_emit(_EDJ(it->base), wd->pressed_signal, "elm");
1414 else if (it->style == TOOLBAR)
1419 edje_object_signal_emit(_EDJ(it->base), "elm,state,toolbar_pressed", "elm");
1420 //item_color_set(it, "elm.toolbar.pressed.color");
1423 evas_object_event_callback_add(wd->event_box, EVAS_CALLBACK_MOUSE_UP, unpressed_box_cb, (void *)wd);
1429 return EXIT_FAILURE;
1433 return EXIT_SUCCESS;
1436 static Evas_Object *
1437 create_item_label(Evas_Object *obj, Elm_Controlbar_Item * it, char *part)
1440 label = elm_label_add(obj);
1441 elm_object_style_set(label, "controlbar");
1442 elm_label_label_set(label, it->text);
1443 elm_label_text_align_set(label, "center");
1444 elm_label_text_color_set(label, 255, 255, 255, 255);
1445 elm_label_line_wrap_set(label, EINA_TRUE);
1446 elm_label_ellipsis_set(label, EINA_TRUE);
1447 elm_label_wrap_mode_set(label, 1);
1449 elm_layout_content_set(obj, part, label);
1454 static Evas_Object *
1455 create_item_icon(Evas_Object *obj, Elm_Controlbar_Item * it, char *part)
1458 icon = elm_icon_add(obj);
1459 if(!elm_icon_standard_set(icon, it->icon_path))
1461 elm_icon_file_set(icon, it->icon_path, NULL);
1464 evas_object_size_hint_min_set(icon, 40, 40);
1465 evas_object_size_hint_max_set(icon, 100, 100);
1466 evas_object_show(icon);
1467 edje_object_part_swallow(_EDJ(obj), part, icon);
1472 static Evas_Object *
1473 create_item_layout(Evas_Object * parent, Elm_Controlbar_Item * it, Evas_Object **item, Evas_Object **label, Evas_Object **icon, Evas_Object **sicon, Evas_Object **slabel)
1476 obj = elm_layout_add(parent);
1479 fprintf(stderr, "Cannot load bg edj\n");
1482 elm_layout_theme_set(obj, "controlbar", "item_bg",
1483 elm_widget_style_get(it->obj));
1484 evas_object_size_hint_weight_set(obj, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1485 evas_object_size_hint_align_set(obj, EVAS_HINT_FILL, EVAS_HINT_FILL);
1487 *item = elm_layout_add(parent);
1490 fprintf(stderr, "Cannot load bg edj\n");
1493 elm_layout_theme_set(*item, "controlbar", "item",
1494 elm_widget_style_get(it->obj));
1495 elm_layout_content_set(obj, "item", *item);
1499 *label = create_item_label(*item, it, "elm.swallow.text");
1500 *slabel = create_item_label(*item, it, "elm.swallow.text_shadow");
1501 evas_object_color_set(*slabel, 0, 0, 0, 255);
1505 *icon = create_item_icon(*item, it, "elm.swallow.icon");
1506 *sicon = create_item_icon(*item, it, "elm.swallow.icon_shadow");
1507 evas_object_color_set(*sicon, 0, 0, 0, 255);
1509 if (*label && *icon)
1511 edje_object_signal_emit(_EDJ(*item), "elm,state,icon_text", "elm");
1512 elm_label_line_wrap_set(*label, EINA_FALSE);
1513 elm_label_wrap_mode_set(*label, 0);
1514 elm_label_line_wrap_set(*slabel, EINA_FALSE);
1515 elm_label_wrap_mode_set(*slabel, 0);
1522 edit_item_down_end_cb(void *data, Evas_Object * obj)
1524 Widget_Data * wd = (Widget_Data *) data;
1526 if (wd->animating < 0)
1528 printf("animation error\n");
1534 edit_item_return_cb(void *data, Evas_Object * obj)
1536 Evas_Coord x, y, w, h;
1537 Widget_Data * wd = (Widget_Data *) data;
1538 evas_object_geometry_get(wd->moving_item->edit, &x, &y, &w, &h);
1539 set_evas_map(obj, x, y, 0, 0);
1541 evas_object_event_callback_del(wd->event_box, EVAS_CALLBACK_MOUSE_UP, edit_item_up_cb);
1542 evas_object_event_callback_del(wd->event_box, EVAS_CALLBACK_MOUSE_MOVE, edit_item_move_cb);
1544 evas_object_data_set(wd->moving_obj, "returning", 0);
1546 if (wd->animating < 0)
1548 printf("animation error\n");
1554 edit_item_move_cb(void *data, Evas *evas, Evas_Object *obj, void *event_info)
1556 Evas_Event_Mouse_Move * ev = event_info;
1558 Elm_Controlbar_Item * item;
1559 Evas_Coord x, y, w, h;
1560 Widget_Data * wd = (Widget_Data *) data;
1563 evas_object_geometry_get(wd->moving_obj, &x, &y, &w, &h);
1566 x = ev->cur.output.x - w / 2;
1567 y = ev->cur.output.y - h;
1568 set_evas_map(wd->moving_obj, x, y, w, h);
1570 EINA_LIST_FOREACH(wd->items, l, item)
1572 if (wd->moving_item->edit == item->edit || item->style == OBJECT)
1574 evas_object_geometry_get(item->base, &x, &y, &w, &h);
1575 if (ev->cur.output.x > x && ev->cur.output.x < x + w && ev->cur.output.y > y && ev->cur.output.y < y + h
1578 edje_object_signal_emit(_EDJ(item->base), "elm,state,show,glow",
1583 edje_object_signal_emit(_EDJ(item->base), "elm,state,hide,glow",
1591 edit_item_up_cb(void *data, Evas *evas, Evas_Object *obj, void *event_info)
1593 Evas_Event_Mouse_Up * ev = event_info;
1594 Evas_Coord x, y, w, h;
1595 Evas_Coord x_, y_, w_, h_;
1597 Elm_Controlbar_Item * item;
1598 Widget_Data * wd = (Widget_Data *) data;
1600 if ((int)evas_object_data_get(wd->moving_obj, "returning") == 1)
1602 evas_object_color_set(wd->moving_item->edit_item, 255, 255, 255, 255);
1604 // check which change or not
1605 EINA_LIST_FOREACH(wd->items, l, item)
1607 if (wd->moving_item->edit == item->edit)
1609 if (item->order <= 0)
1611 evas_object_geometry_get(item->base, &x, &y, &w, &h);
1612 if (ev->output.x > x && ev->output.x < x + w && ev->output.y > y && ev->output.y < y + h
1613 && item->style != OBJECT && item->editable)
1615 edje_object_signal_emit(_EDJ(item->base), "elm,state,hide,glow",
1622 if (wd->moving_item->order > 0)
1624 item_exchange_in_bar(wd->moving_item, item);
1628 item_change_in_bar(item);
1630 evas_object_event_callback_del(wd->event_box, EVAS_CALLBACK_MOUSE_UP, edit_item_up_cb);
1631 evas_object_event_callback_del(wd->event_box, EVAS_CALLBACK_MOUSE_MOVE, edit_item_move_cb);
1636 // return moving object to original location
1637 evas_object_geometry_get(wd->moving_item->edit, &x_, &y_, &w_,
1639 evas_object_geometry_get(wd->moving_obj, &x, &y, &w, &h);
1642 x = ev->output.x - w / 2;
1643 y = ev->output.y - h;
1644 evas_object_data_set(wd->moving_obj, "returning", (void *)1);
1646 move_object_with_animation(wd->moving_obj, x, y, w, h, x_, y_, w_, h_,
1647 0.25, move_evas_map, edit_item_return_cb, wd);
1653 edit_item_down_cb(void *data, Evas * evas, Evas_Object * obj,
1656 Evas_Event_Mouse_Down * ev = event_info;
1657 Evas_Coord x, y, w, h;
1658 Evas_Coord x_, y_, w_, h_;
1659 Widget_Data * wd = (Widget_Data *) data;
1662 Elm_Controlbar_Item * item;
1663 Evas_Object * color;
1668 EINA_LIST_FOREACH(wd->items, l, item)
1670 if (item->edit == obj)
1675 if (!item->editable)
1678 evas_object_event_callback_add(wd->event_box, EVAS_CALLBACK_MOUSE_UP, edit_item_up_cb, (void *)wd);
1679 evas_object_event_callback_add(wd->event_box, EVAS_CALLBACK_MOUSE_MOVE, edit_item_move_cb, (void *)wd);
1681 wd->moving_item = item;
1684 edje_object_part_object_get(_EDJ(wd->moving_item->edit),
1685 "elm.item.uneditable.color");
1687 evas_object_color_get(color, &r, &g, &b, &a);
1688 evas_object_color_set(item->edit_item, r, g, b, a);
1690 evas_object_del(wd->moving_obj);
1691 wd->moving_obj = NULL;
1692 wd->moving_obj = create_item_layout(obj, item, &(item->base_item), &(item->label), &(item->icon), &(item->icon_shadow), &(item->label_shadow));
1693 evas_object_geometry_get(obj, &x, &y, &w, &h);
1694 evas_object_move(wd->moving_obj, -1000, -1000);
1695 evas_object_resize(wd->moving_obj, w, h);
1696 evas_object_show(wd->moving_obj);
1699 x_ = ev->output.x - w_ / 2;
1700 y_ = ev->output.y - h_;
1702 move_object_with_animation(wd->moving_obj, x, y, w, h, x_, y_, w_, h_, 0.1,
1703 move_evas_map, edit_item_down_end_cb, wd);
1707 bar_item_move_end_cb(void *data, Evas_Object * obj)
1709 Widget_Data * wd = (Widget_Data *) data;
1712 Elm_Controlbar_Item * item;
1713 EINA_LIST_FOREACH(wd->items, l, item)
1715 if (item->base == obj)
1719 if (wd->animating < 0)
1721 printf("animation error\n");
1724 evas_object_data_set(obj, "animating", 0);
1725 evas_object_map_enable_set(obj, EINA_FALSE);
1729 bar_item_animation_end_check(void *data)
1733 Elm_Controlbar_Item * item;
1734 Widget_Data * wd = (Widget_Data *) data;
1736 return EXIT_FAILURE;
1737 EINA_LIST_FOREACH(wd->items, l, item)
1739 if (item->base == wd->moving_obj)
1744 printf("item is NULL\n");
1748 item->order = wd->empty_num;
1750 wd->moving_obj = NULL;
1752 evas_object_event_callback_del(wd->event_box, EVAS_CALLBACK_MOUSE_UP, bar_item_up_cb);
1753 evas_object_event_callback_del(wd->event_box, EVAS_CALLBACK_MOUSE_MOVE, bar_item_move_cb);
1754 return ECORE_CALLBACK_CANCEL;
1758 bar_item_move_cb(void *data, Evas *evas, Evas_Object *obj, void *event_info)
1760 Evas_Event_Mouse_Move * ev = event_info;
1762 Elm_Controlbar_Item * item, *it;
1763 Widget_Data * wd = (Widget_Data *) data;
1764 Evas_Coord x, y, w, h, x_, y_, w_, h_;
1767 if (wd->moving_obj == NULL)
1769 printf("%s : moving_obj is NULL\n", __func__);
1772 evas_object_geometry_get(wd->moving_obj, &x, &y, &w, &h);
1773 x = ev->cur.output.x - w / 2;
1774 set_evas_map(wd->moving_obj, x, y, w, h);
1775 EINA_LIST_FOREACH(wd->items, l, item)
1777 if (item->base == wd->moving_obj)
1782 if ((int)evas_object_data_get(item->base, "animating") == 1)
1784 evas_object_geometry_get(item->base, &x, &y, &w, &h);
1785 if (ev->cur.output.x > x && ev->cur.output.x < x + w && item->editable)
1792 evas_object_geometry_get(wd->moving_obj, &x_, &y_, &w_, &h_);
1793 evas_object_move(wd->moving_obj, x, y);
1794 tmp = wd->empty_num;
1795 wd->empty_num = item->order;
1797 elm_table_unpack(wd->box, item->base);
1798 elm_table_unpack(wd->box, wd->moving_obj);
1801 elm_table_pack(wd->box, item->base, item->order - 1, 0, 1, 1);
1802 elm_table_pack(wd->box, wd->moving_obj, wd->empty_num - 1, 0, 1, 1);
1806 elm_table_pack(wd->box, item->base, 0, item->order - 1, 1, 1);
1807 elm_table_pack(wd->box, wd->moving_obj, 0, wd->empty_num - 1, 1, 1);
1810 evas_object_data_set(item->base, "animating", (void *)1);
1811 move_object_with_animation(item->base, x, y, w, h, x_, y_, w_, h_,
1812 0.25, move_evas_map, bar_item_move_end_cb, wd);
1818 bar_item_up_cb(void *data, Evas *evas, Evas_Object *obj, void *event_info)
1820 Evas_Event_Mouse_Up * ev = event_info;
1821 Evas_Coord tx, x, y, w, h;
1822 Widget_Data * wd = (Widget_Data *) data;
1823 evas_object_geometry_get(wd->moving_obj, &x, &y, &w, &h);
1824 tx = ev->output.x - w / 2;
1826 evas_object_data_set(wd->moving_obj, "animating", (void *)1);
1827 move_object_with_animation(wd->moving_obj, tx, y, w, h, x, y, w, h, 0.25,
1828 move_evas_map, bar_item_move_end_cb, wd);
1829 ecore_timer_add(0.1, bar_item_animation_end_check, wd);
1834 bar_item_down_cb(void *data, Evas * evas, Evas_Object * obj, void *event_info)
1836 Widget_Data * wd = (Widget_Data *) data;
1838 Elm_Controlbar_Item * item;
1841 EINA_LIST_FOREACH(wd->items, l, item)
1843 if (item->base == obj)
1850 if (!item->editable)
1853 wd->moving_obj = obj;
1854 wd->empty_num = item->order;
1855 evas_object_event_callback_add(wd->event_box, EVAS_CALLBACK_MOUSE_UP, bar_item_up_cb, (void *)wd);
1856 evas_object_event_callback_add(wd->event_box, EVAS_CALLBACK_MOUSE_MOVE, bar_item_move_cb, (void *)wd);
1864 static Elm_Controlbar_Item *
1865 create_tab_item(Evas_Object * obj, const char *icon_path, const char *label,
1868 Elm_Controlbar_Item * it;
1872 fprintf(stderr, "Invalid argument: controlbar object is NULL\n");
1875 wd = elm_widget_data_get(obj);
1878 fprintf(stderr, "Cannot get smart data\n");
1881 it = ELM_NEW(Elm_Controlbar_Item);
1885 it->text = eina_stringshare_add(label);
1886 it->icon_path = eina_stringshare_add(icon_path);
1887 it->selected = EINA_FALSE;
1888 it->editable = EINA_TRUE;
1893 it->base = create_item_layout(wd->edje, it, &(it->base_item), &(it->label), &(it->icon), &(it->icon_shadow), &(it->label_shadow));
1894 evas_object_event_callback_add(it->base, EVAS_CALLBACK_MOUSE_DOWN,
1895 bar_item_down_cb, wd);
1896 evas_object_show(it->base);
1897 it->edit = create_item_layout(wd->edje, it, &(it->edit_item), &(it->edit_label), &(it->edit_icon), &(it->edit_icon_shadow), &(it->edit_label_shadow));
1898 evas_object_event_callback_add(it->edit, EVAS_CALLBACK_MOUSE_DOWN,
1899 edit_item_down_cb, wd);
1900 evas_object_show(it->edit);
1905 static Elm_Controlbar_Item *
1906 create_tool_item(Evas_Object * obj, const char *icon_path, const char *label,
1907 void (*func) (void *data, Evas_Object * obj,
1908 void *event_info), void *data)
1910 Elm_Controlbar_Item * it;
1914 fprintf(stderr, "Invalid argument: controlbar object is NULL\n");
1917 wd = elm_widget_data_get(obj);
1920 fprintf(stderr, "Cannot get smart data\n");
1923 it = ELM_NEW(Elm_Controlbar_Item);
1927 it->text = eina_stringshare_add(label);
1928 it->icon_path = eina_stringshare_add(icon_path);
1929 it->selected = EINA_FALSE;
1930 it->editable = EINA_TRUE;
1935 it->style = TOOLBAR;
1936 it->base = create_item_layout(wd->edje, it, &(it->base_item), &(it->label), &(it->icon), &(it->icon_shadow), &(it->label_shadow));
1937 evas_object_event_callback_add(it->base, EVAS_CALLBACK_MOUSE_DOWN,
1938 bar_item_down_cb, wd);
1939 evas_object_show(it->base);
1940 it->edit = create_item_layout(wd->edje, it, &(it->edit_item), &(it->edit_label), &(it->edit_icon), &(it->edit_icon_shadow), &(it->edit_label_shadow));
1941 evas_object_event_callback_add(it->edit, EVAS_CALLBACK_MOUSE_DOWN,
1942 edit_item_down_cb, wd);
1943 evas_object_show(it->edit);
1947 static Elm_Controlbar_Item *
1948 create_object_item(Evas_Object * obj, Evas_Object * obj_item, const int sel)
1950 Elm_Controlbar_Item * it;
1954 fprintf(stderr, "Invalid argument: controlbar object is NULL\n");
1957 wd = elm_widget_data_get(obj);
1960 fprintf(stderr, "Cannot get smart data\n");
1963 it = ELM_NEW(Elm_Controlbar_Item);
1970 it->base = obj_item;
1975 repack_items(Widget_Data *wd)
1978 Elm_Controlbar_Item * item;
1980 EINA_LIST_FOREACH(wd->items, l, item)
1984 elm_table_unpack(wd->box, item->base);
1987 elm_table_pack(wd->box, item->base, item->order - 1, 0, item->sel, 1);
1991 elm_table_pack(wd->box, item->base, 0, item->order - 1, item->sel, 1);
1998 set_items_position(Evas_Object * obj, Elm_Controlbar_Item * it,
1999 Elm_Controlbar_Item * mit, Eina_Bool bar)
2004 Elm_Controlbar_Item * item;
2007 int check = EINA_FALSE;
2015 fprintf(stderr, "Invalid argument: controlbar object is NULL\n");
2018 wd = elm_widget_data_get(obj);
2021 fprintf(stderr, "Cannot get smart data\n");
2025 EINA_LIST_FOREACH(wd->items, l, item)
2027 if (item == mit && item->order > 0)
2031 it->order = mit->order;
2035 if(item->order > 0){
2036 elm_table_unpack(wd->box, item->base);
2037 item->order += it->sel;
2040 elm_table_pack(wd->box, item->base, item->order - 1, 0, item->sel, 1);
2044 elm_table_pack(wd->box, item->base, 0, item->order - 1, item->sel, 1);
2047 if (item->style != OBJECT && it->style != OBJECT)
2049 elm_table_unpack(wd->edit_table, item->edit);
2050 elm_table_pack(wd->edit_table, item->edit,
2051 i % EDIT_ROW_NUM, i / EDIT_ROW_NUM, 1, 1);
2054 if (item->style != OBJECT)
2056 if(item->order > 0) order += item->sel;
2072 elm_table_pack(wd->box, it->base, it->order - 1, 0, it->sel, 1);
2076 elm_table_pack(wd->box, it->base, 0, it->order - 1, it->sel, 1);
2079 else evas_object_hide(it->base);
2080 if (it->style != OBJECT)
2081 elm_table_pack(wd->edit_table, it->edit, (edit - 1) % EDIT_ROW_NUM,
2082 (edit - 1) / EDIT_ROW_NUM, 1, 1);
2086 list_clicked(void *data, Evas_Object *obj, void *event_info)
2088 Elm_Controlbar_Item *item = (Elm_Controlbar_Item *)data;
2089 Elm_Controlbar_Item *it;
2092 Evas_Object *content;
2093 Elm_List_Item *lit = (Elm_List_Item *) elm_list_selected_item_get(obj);
2094 if(lit == NULL) return;
2096 elm_list_item_selected_set(lit, 0);
2100 wd = elm_widget_data_get(item->obj);
2102 EINA_LIST_FOREACH(wd->items, l, it)
2104 it->selected = EINA_FALSE;
2107 if(item->style == TABBAR)
2109 content = elm_layout_content_unset(wd->view, "elm.swallow.view");
2110 evas_object_hide(content);
2111 item->selected = EINA_TRUE;
2112 evas_object_smart_callback_call(item->obj, "view,change,before", item);
2113 elm_layout_content_set(wd->view, "elm.swallow.view", item->view);
2116 if(item->style == TOOLBAR && item->func)
2117 item->func(item->data, item->obj, item);
2120 static Evas_Object *
2121 create_more_view(Widget_Data *wd)
2124 Elm_Controlbar_Item *item;
2127 list = elm_list_add( wd->object );
2128 elm_list_horizontal_mode_set( list, ELM_LIST_COMPRESS );
2130 EINA_LIST_FOREACH(wd->items, l, item)
2132 if(item->order <= 0)
2134 evas_object_color_set(item->icon, 0, 0, 0, 255);
2135 elm_list_item_append(list, item->text, item->icon, NULL, list_clicked, item);
2139 elm_list_go( list );
2144 static Elm_Controlbar_Item *
2145 create_more_item(Widget_Data *wd, int style)
2147 Elm_Controlbar_Item * it;
2149 it = ELM_NEW(Elm_Controlbar_Item);
2152 it->obj = wd->object;
2153 it->text = eina_stringshare_add("more");
2154 it->icon_path = eina_stringshare_add(CONTROLBAR_SYSTEM_ICON_MORE);
2155 it->selected = EINA_FALSE;
2158 it->view = create_more_view(wd);
2160 it->base = create_item_layout(wd->edje, it, &(it->base_item), &(it->label), &(it->icon), &(it->icon_shadow), &(it->label_shadow));
2161 evas_object_event_callback_add(it->base, EVAS_CALLBACK_MOUSE_DOWN,
2162 bar_item_down_cb, wd);
2163 evas_object_show(it->base);
2164 it->edit = create_item_layout(wd->edje, it, &(it->edit_item), &(it->edit_label), &(it->edit_icon), &(it->edit_icon_shadow), &(it->edit_label_shadow));
2165 evas_object_event_callback_add(it->edit, EVAS_CALLBACK_MOUSE_DOWN,
2166 edit_item_down_cb, wd);
2167 evas_object_show(it->edit);
2169 set_items_position(it->obj, it, NULL, EINA_TRUE);
2171 wd->items = eina_list_append(wd->items, it);
2175 elm_controlbar_item_editable_set(it, EINA_FALSE);
2177 wd->items = eina_list_sort(wd->items, eina_list_count(wd->items), sort_cb);
2182 ///////////////////////////////////////////////////////////////////
2186 ////////////////////////////////////////////////////////////////////
2189 * Add a new controlbar object
2191 * @param parent The parent object
2192 * @return The new object or NULL if it cannot be created
2194 * @ingroup Controlbar
2196 EAPI Evas_Object * elm_controlbar_add(Evas_Object * parent)
2198 Evas_Object * obj = NULL;
2199 Evas_Object * bg = NULL;
2200 Widget_Data * wd = NULL;
2201 Evas_Coord x, y, w, h;
2202 Evas_Object * r_button;
2203 wd = ELM_NEW(Widget_Data);
2204 wd->evas = evas_object_evas_get(parent);
2205 if (wd->evas == NULL)
2207 obj = elm_widget_add(wd->evas);
2210 elm_widget_type_set(obj, "controlbar");
2211 elm_widget_sub_object_add(parent, obj);
2212 elm_widget_data_set(obj, wd);
2213 elm_widget_del_hook_set(obj, _del_hook);
2214 elm_widget_theme_hook_set(obj, _theme_hook);
2217 wd->parent = parent;
2218 evas_object_geometry_get(parent, &x, &y, &w, &h);
2224 wd->mode = ELM_CONTROLBAR_MODE_DEFAULT;
2228 wd->vertical = EINA_FALSE;
2229 wd->edit_mode = EINA_FALSE;
2230 wd->auto_align = EINA_FALSE;
2231 wd->init_animation = EINA_FALSE;
2232 wd->selected_animation = EINA_FALSE;
2233 wd->pressed_signal = eina_stringshare_add("elm,state,pressed");
2234 wd->selected_signal = eina_stringshare_add("elm,state,selected");
2235 wd->view = elm_layout_add(wd->parent); //edje_object_add(wd->evas);
2236 elm_layout_theme_set(wd->view, "controlbar", "view", "default");
2237 //_elm_theme_object_set(obj, wd->view, "controlbar", "view", "default");
2238 if (wd->view == NULL)
2240 printf("Cannot load bg edj\n");
2243 evas_object_show(wd->view);
2246 wd->edit_box = edje_object_add(wd->evas);
2247 _elm_theme_object_set(obj, wd->edit_box, "controlbar", "edit_box",
2249 if (wd->edit_box == NULL)
2251 printf("Cannot load bg edj\n");
2254 evas_object_show(wd->edit_box);
2256 //instead of navigationbar
2257 /* r_button = elm_button_add(wd->edit_box);
2258 elm_button_label_set(r_button, "Done");
2259 evas_object_smart_callback_add(r_button, "clicked", done_button_cb, wd);
2260 edje_object_part_swallow(wd->edit_box, "elm.swallow.navigation", r_button);
2262 // navigationbar will contribution. but not yet
2263 wd->navigation = elm_navigationbar_add(wd->edit_box);
2264 r_button = elm_button_add(wd->navigation);
2265 elm_button_label_set(r_button, "Done");
2266 evas_object_smart_callback_add(r_button, "clicked", done_button_cb, wd);
2267 elm_navigationbar_push(wd->navigation, "Configure", NULL, r_button, NULL, NULL);
2268 edje_object_part_swallow(wd->edit_box, "elm.swallow.navigation", wd->navigation);
2270 wd->edit_table = elm_table_add(wd->edit_box);
2271 elm_table_homogenous_set(wd->edit_table, EINA_TRUE);
2272 edje_object_part_swallow(wd->edit_box, "elm.swallow.table", wd->edit_table);
2274 /* load background edj */
2275 wd->edje = edje_object_add(wd->evas);
2276 _elm_theme_object_set(obj, wd->edje, "controlbar", "base", "default");
2277 if (wd->edje == NULL)
2279 printf("Cannot load base edj\n");
2282 evas_object_show(wd->edje);
2284 wd->bg = edje_object_add(wd->evas);
2285 _elm_theme_object_set(obj, wd->bg, "controlbar", "background", "default");
2288 printf("Cannot load bg edj\n");
2291 edje_object_part_swallow(wd->edje, "bg_image", wd->bg);
2294 evas_object_event_callback_add(wd->edje, EVAS_CALLBACK_RESIZE,
2295 _controlbar_object_resize, obj);
2296 evas_object_event_callback_add(wd->edje, EVAS_CALLBACK_MOVE,
2297 _controlbar_object_move, obj);
2298 evas_object_event_callback_add(wd->edje, EVAS_CALLBACK_SHOW,
2299 _controlbar_object_show, obj);
2300 evas_object_event_callback_add(wd->edje, EVAS_CALLBACK_HIDE,
2301 _controlbar_object_hide, obj);
2302 bg = (Evas_Object *)edje_object_part_object_get(wd->edje, "bg_image");
2303 evas_object_event_callback_add(bg, EVAS_CALLBACK_MOVE, _controlbar_object_move, obj);
2304 evas_object_event_callback_add(bg, EVAS_CALLBACK_RESIZE, _controlbar_object_resize, obj);
2306 wd->selected_box = wd->focused_box = edje_object_add(wd->evas);
2307 _elm_theme_object_set(obj, wd->selected_box, "controlbar", "item_bg_move", "default");
2308 evas_object_hide(wd->focused_box);
2310 wd->focused_box_left = edje_object_add(wd->evas);
2311 _elm_theme_object_set(obj, wd->focused_box_left, "controlbar", "item_bg_move_left", "default");
2312 evas_object_hide(wd->focused_box_left);
2314 wd->focused_box_right = edje_object_add(wd->evas);
2315 _elm_theme_object_set(obj, wd->focused_box_right, "controlbar", "item_bg_move_right", "default");
2316 evas_object_hide(wd->focused_box_right);
2319 wd->box = elm_table_add(wd->edje);
2320 elm_table_homogenous_set(wd->box, EINA_TRUE);
2321 evas_object_size_hint_weight_set(wd->box, EVAS_HINT_EXPAND,
2323 evas_object_size_hint_align_set(wd->box, EVAS_HINT_FILL, EVAS_HINT_FILL);
2324 edje_object_part_swallow(wd->edje, "elm.swallow.items", wd->box);
2325 evas_object_show(wd->box);
2327 wd->event_box = evas_object_rectangle_add(wd->evas);
2328 evas_object_color_set(wd->event_box, 255, 255, 255, 0);
2329 evas_object_repeat_events_set(wd->event_box, EINA_TRUE);
2330 evas_object_show(wd->event_box);
2333 // evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
2334 evas_object_smart_member_add(wd->view, obj);
2335 evas_object_smart_member_add(wd->edit_box, obj);
2336 elm_widget_resize_object_set(obj, wd->edje);
2337 evas_object_smart_member_add(wd->focused_box, obj);
2338 evas_object_smart_member_add(wd->focused_box_left, obj);
2339 evas_object_smart_member_add(wd->focused_box_right, obj);
2340 evas_object_smart_member_add(wd->box, obj);
2341 evas_object_smart_member_add(wd->event_box, obj);
2348 * Append new tab item
2350 * @param obj The controlbar object
2351 * @param icon_path The icon path of item
2352 * @param label The label of item
2353 * @param view The view of item
2354 * @return The item of controlbar
2356 * @ingroup Controlbar
2358 EAPI Elm_Controlbar_Item * elm_controlbar_tab_item_append(Evas_Object * obj,
2365 Elm_Controlbar_Item * it;
2366 Elm_Controlbar_Item * lit;
2368 it = create_tab_item(obj, icon_path, label, view);
2371 wd = elm_widget_data_get(obj);
2372 if(check_bar_item_number(wd) >= 5 && wd->auto_align){
2373 if(!wd->more_item) {
2374 lit = elm_controlbar_last_item_get(obj);
2375 elm_controlbar_item_visible_set(lit, EINA_FALSE);
2376 create_more_item(wd, TABBAR);
2378 set_items_position(obj, it, NULL, EINA_FALSE);
2381 set_items_position(obj, it, NULL, EINA_TRUE);
2383 if(wd->init_animation) evas_object_hide(it->base);
2384 wd->items = eina_list_append(wd->items, it);
2386 elm_controlbar_item_view_set(wd->more_item, create_more_view(wd));
2395 * Prepend new tab item
2397 * @param obj The controlbar object
2398 * @param icon_path The icon path of item
2399 * @param label The label of item
2400 * @param view The view of item
2401 * @return The item of controlbar
2403 * @ingroup Controlbar
2405 EAPI Elm_Controlbar_Item * elm_controlbar_tab_item_prepend(Evas_Object *
2415 Elm_Controlbar_Item * it;
2416 Elm_Controlbar_Item * lit;
2417 Elm_Controlbar_Item * item;
2418 it = create_tab_item(obj, icon_path, label, view);
2421 wd = elm_widget_data_get(obj);
2422 item = eina_list_data_get(wd->items);
2423 if(check_bar_item_number(wd) >= 5 && wd->auto_align){
2424 if(!wd->more_item) {
2425 lit = elm_controlbar_last_item_get(obj);
2426 elm_controlbar_item_visible_set(lit, EINA_FALSE);
2427 create_more_item(wd, TABBAR);
2429 lit = elm_controlbar_item_prev(wd->more_item);
2430 elm_controlbar_item_visible_set(lit, EINA_FALSE);
2431 set_items_position(obj, it, item, EINA_TRUE);
2434 set_items_position(obj, it, item, EINA_TRUE);
2436 wd->items = eina_list_prepend(wd->items, it);
2438 elm_controlbar_item_view_set(wd->more_item, create_more_view(wd));
2446 * Insert new tab item before given item
2448 * @param obj The controlbar object
2449 * @param before The given item
2450 * @param icon_path The icon path of item
2451 * @param label The label of item
2452 * @param view The view of item
2453 * @return The item of controlbar
2455 * @ingroup Controlbar
2457 EAPI Elm_Controlbar_Item *
2458 elm_controlbar_tab_item_insert_before(Evas_Object * obj,
2459 Elm_Controlbar_Item * before,
2460 const char *icon_path,
2461 const char *label, Evas_Object * view)
2464 Elm_Controlbar_Item * it;
2465 Elm_Controlbar_Item * lit;
2468 it = create_tab_item(obj, icon_path, label, view);
2471 wd = elm_widget_data_get(obj);
2472 if(check_bar_item_number(wd) >= 5 && wd->auto_align){
2475 lit = elm_controlbar_last_item_get(obj);
2476 elm_controlbar_item_visible_set(lit, EINA_FALSE);
2477 create_more_item(wd, TABBAR);
2479 if(before->order > 0)
2481 lit = elm_controlbar_item_prev(wd->more_item);
2482 elm_controlbar_item_visible_set(lit, EINA_FALSE);
2483 set_items_position(obj, it, before, EINA_TRUE);
2487 set_items_position(obj, it, before, EINA_FALSE);
2491 set_items_position(obj, it, before, EINA_TRUE);
2493 wd->items = eina_list_prepend_relative(wd->items, it, before);
2495 elm_controlbar_item_view_set(wd->more_item, create_more_view(wd));
2503 * Insert new tab item after given item
2505 * @param obj The controlbar object
2506 * @param after The given item
2507 * @param icon_path The icon path of item
2508 * @param label The label of item
2509 * @param view The view of item
2510 * @return The item of controlbar
2512 * @ingroup Controlbar
2514 EAPI Elm_Controlbar_Item *
2515 elm_controlbar_tab_item_insert_after(Evas_Object * obj,
2516 Elm_Controlbar_Item * after,
2517 const char *icon_path, const char *label,
2521 Elm_Controlbar_Item * it;
2522 Elm_Controlbar_Item * lit;
2523 Elm_Controlbar_Item * item;
2526 it = create_tab_item(obj, icon_path, label, view);
2529 wd = elm_widget_data_get(obj);
2530 item = elm_controlbar_item_next(after);
2531 if(check_bar_item_number(wd) >= 5 && wd->auto_align){
2534 lit = elm_controlbar_last_item_get(obj);
2535 elm_controlbar_item_visible_set(lit, EINA_FALSE);
2536 create_more_item(wd, TABBAR);
2540 lit = elm_controlbar_item_prev(wd->more_item);
2541 elm_controlbar_item_visible_set(lit, EINA_FALSE);
2542 set_items_position(obj, it, item, EINA_TRUE);
2546 set_items_position(obj, it, item, EINA_FALSE);
2550 set_items_position(obj, it, item, EINA_TRUE);
2552 wd->items = eina_list_append_relative(wd->items, it, after);
2554 elm_controlbar_item_view_set(wd->more_item, create_more_view(wd));
2562 * Append new tool item
2564 * @param obj The controlbar object
2565 * @param icon_path The icon path of item
2566 * @param label The label of item
2567 * @param func Callback function of item
2568 * @param data The data of callback function
2569 * @return The item of controlbar
2571 * @ingroup Controlbar
2573 EAPI Elm_Controlbar_Item * elm_controlbar_tool_item_append(Evas_Object *
2588 Elm_Controlbar_Item * it;
2590 it = create_tool_item(obj, icon_path, label, func, data);
2593 wd = elm_widget_data_get(obj);
2594 set_items_position(obj, it, NULL, EINA_TRUE);
2595 wd->items = eina_list_append(wd->items, it);
2601 * Prepend new tool item
2603 * @param obj The controlbar object
2604 * @param icon_path The icon path of item
2605 * @param label The label of item
2606 * @param func Callback function of item
2607 * @param data The data of callback function
2608 * @return The item of controlbar
2610 * @ingroup Controlbar
2612 EAPI Elm_Controlbar_Item * elm_controlbar_tool_item_prepend(Evas_Object *
2629 Elm_Controlbar_Item * it;
2630 Elm_Controlbar_Item * item;
2631 it = create_tool_item(obj, icon_path, label, func, data);
2634 wd = elm_widget_data_get(obj);
2635 item = eina_list_data_get(wd->items);
2636 set_items_position(obj, it, item, EINA_TRUE);
2637 wd->items = eina_list_prepend(wd->items, it);
2643 * Insert new tool item before given item
2645 * @param obj The controlbar object
2646 * @param before The given item
2647 * @param icon_path The icon path of item
2648 * @param label The label of item
2649 * @param func Callback function of item
2650 * @param data The data of callback function
2651 * @return The item of controlbar
2653 * @ingroup Controlbar
2655 EAPI Elm_Controlbar_Item *
2656 elm_controlbar_tool_item_insert_before(Evas_Object * obj,
2657 Elm_Controlbar_Item * before,
2658 const char *icon_path,
2660 void (*func) (void *data,
2666 Elm_Controlbar_Item * it;
2669 it = create_tool_item(obj, icon_path, label, func, data);
2672 wd = elm_widget_data_get(obj);
2673 set_items_position(obj, it, before, EINA_TRUE);
2674 wd->items = eina_list_prepend_relative(wd->items, it, before);
2680 * Insert new tool item after given item
2682 * @param obj The controlbar object
2683 * @param after The given item
2684 * @param icon_path The icon path of item
2685 * @param label The label of item
2686 * @param func Callback function of item
2687 * @param data The data of callback function
2688 * @return The item of controlbar
2690 * @ingroup Controlbar
2692 EAPI Elm_Controlbar_Item *
2693 elm_controlbar_tool_item_insert_after(Evas_Object * obj,
2694 Elm_Controlbar_Item * after,
2695 const char *icon_path,
2697 void (*func) (void *data,
2703 Elm_Controlbar_Item * it;
2704 Elm_Controlbar_Item * item;
2707 it = create_tool_item(obj, icon_path, label, func, data);
2710 wd = elm_widget_data_get(obj);
2711 item = elm_controlbar_item_next(after);
2712 set_items_position(obj, it, item, EINA_TRUE);
2713 wd->items = eina_list_append_relative(wd->items, it, after);
2719 * Append new object item
2721 * @param obj The controlbar object
2722 * @param obj_item The object of item
2723 * @param sel The number of sel occupied
2724 * @return The item of controlbar
2726 * @ingroup Controlbar
2728 EAPI Elm_Controlbar_Item * elm_controlbar_object_item_append(Evas_Object *
2735 Elm_Controlbar_Item * it;
2736 it = create_object_item(obj, obj_item, sel);
2739 wd = elm_widget_data_get(obj);
2740 set_items_position(obj, it, NULL, EINA_TRUE);
2741 wd->items = eina_list_append(wd->items, it);
2747 * Prepend new object item
2749 * @param obj The controlbar object
2750 * @param obj_item The object of item
2751 * @param sel The number of sel occupied
2752 * @return The item of controlbar
2754 * @ingroup Controlbar
2756 EAPI Elm_Controlbar_Item * elm_controlbar_object_item_prepend(Evas_Object *
2763 Elm_Controlbar_Item * it;
2764 Elm_Controlbar_Item * item;
2765 it = create_object_item(obj, obj_item, sel);
2768 wd = elm_widget_data_get(obj);
2769 item = eina_list_data_get(wd->items);
2770 set_items_position(obj, it, item, EINA_TRUE);
2771 wd->items = eina_list_prepend(wd->items, it);
2777 * Insert new object item before given item
2779 * @param obj The controlbar object
2780 * @param before The given item
2781 * @param obj_item The object of item
2782 * @param sel The number of sel occupied
2783 * @return The item of controlbar
2785 * @ingroup Controlbar
2787 EAPI Elm_Controlbar_Item *
2788 elm_controlbar_object_item_insert_before(Evas_Object * obj,
2789 Elm_Controlbar_Item * before,
2790 Evas_Object * obj_item, const int sel)
2793 Elm_Controlbar_Item * it;
2796 it = create_object_item(obj, obj_item, sel);
2799 wd = elm_widget_data_get(obj);
2800 set_items_position(obj, it, before, EINA_TRUE);
2801 wd->items = eina_list_prepend_relative(wd->items, it, before);
2807 * Insert new object item after given item
2809 * @param obj The controlbar object
2810 * @param after The given item
2811 * @param obj_item The object of item
2812 * @param sel The number of sel occupied
2813 * @return The item of controlbar
2815 * @ingroup Controlbar
2817 EAPI Elm_Controlbar_Item *
2818 elm_controlbar_object_item_insert_after(Evas_Object * obj,
2819 Elm_Controlbar_Item * after,
2820 Evas_Object * obj_item, const int sel)
2823 Elm_Controlbar_Item * it;
2824 Elm_Controlbar_Item * item;
2827 it = create_object_item(obj, obj_item, sel);
2830 wd = elm_widget_data_get(obj);
2831 item = elm_controlbar_item_next(after);
2832 set_items_position(obj, it, item, EINA_TRUE);
2833 wd->items = eina_list_append_relative(wd->items, it, after);
2839 * Delete item from controlbar
2841 * @param it The item of controlbar
2843 * @ingroup Controlbar
2846 elm_controlbar_item_del(Elm_Controlbar_Item * it)
2852 Elm_Controlbar_Item * item;
2860 if (it->obj == NULL)
2862 printf("Invalid argument: controlbar object is NULL\n");
2865 wd = elm_widget_data_get(it->obj);
2868 printf("Cannot get smart data\n");
2875 elm_table_unpack(wd->box, it->base);
2877 EINA_LIST_FOREACH(wd->items, l, item)
2881 if (item->order > it->order)
2883 elm_table_unpack(wd->box, item->base);
2887 elm_table_pack(wd->box, item->base, item->order - 1, 0, item->sel, 1);
2891 elm_table_pack(wd->box, item->base, 0, item->order - 1, item->sel, 1);
2904 if (it->edit_item != NULL)
2906 elm_table_unpack(wd->edit_table, it->edit);
2907 EINA_LIST_FOREACH(wd->items, l, item)
2911 if (item->edit_item != NULL)
2913 elm_table_unpack(wd->edit_table, item->edit);
2914 elm_table_pack(wd->edit_table, item->edit,
2915 (i - 1) % 4, (i - 1) / 4, 1, 1);
2918 if (it == item && item->style != OBJECT)
2923 if (item->style != OBJECT)
2928 // delete item in list
2930 wd->items = eina_list_remove(wd->items, it);
2933 wd->num = wd->num - 1;
2938 * Select item in controlbar
2940 * @param it The item of controlbar
2942 * @ingroup Controlbar
2945 elm_controlbar_item_select(Elm_Controlbar_Item * it)
2947 if (it->obj == NULL)
2949 Widget_Data * wd = elm_widget_data_get(it->obj);
2959 * Set the icon of item
2961 * @param it The item of controlbar
2962 * @param icon_path The icon path of the item
2963 * @return The icon object
2965 * @ingroup Controlbar
2968 elm_controlbar_item_icon_set(Elm_Controlbar_Item * it, const char *icon_path)
2972 it->icon_path = icon_path;
2975 evas_object_del(it->icon);
2978 it->icon = create_item_icon(it->base_item, it, "elm.swallow.icon");
2979 it->icon_shadow = create_item_icon(it->base_item, it, "elm.swallow.icon_shadow");
2980 it->edit_icon = create_item_icon(it->edit_item, it, "elm.swallow.icon");
2981 it->edit_icon_shadow = create_item_icon(it->edit_item, it, "elm.swallow.icon_shadow");
2983 if(it->label && it->icon)
2985 edje_object_signal_emit(_EDJ(it->base_item), "elm,state,icon_text", "elm");
2986 elm_label_line_wrap_set(it->label, EINA_FALSE);
2987 elm_label_wrap_mode_set(it->label, 0);
2988 elm_label_line_wrap_set(it->label_shadow, EINA_FALSE);
2989 elm_label_wrap_mode_set(it->label_shadow, 0);
2991 if(it->edit_label && it->edit_icon)
2993 edje_object_signal_emit(_EDJ(it->edit_item), "elm,state,icon_text", "elm");
2994 elm_label_line_wrap_set(it->edit_label, EINA_FALSE);
2995 elm_label_wrap_mode_set(it->edit_label, 0);
2996 elm_label_line_wrap_set(it->edit_label_shadow, EINA_FALSE);
2997 elm_label_wrap_mode_set(it->edit_label_shadow, 0);
3002 * Get the icon of item
3004 * @param it The item of controlbar
3005 * @return The icon object
3007 * @ingroup Controlbar
3010 elm_controlbar_item_icon_get(Elm_Controlbar_Item * it)
3016 * Set the label of item
3018 * @param it The item of controlbar
3019 * @param label The label of item
3021 * @ingroup Controlbar
3024 elm_controlbar_item_label_set(Elm_Controlbar_Item * it, const char *label)
3028 it->text = eina_stringshare_add(label);
3029 it->label = create_item_label(it->base_item, it, "elm.swallow.text");
3030 it->edit_label = create_item_label(it->edit_item, it, "elm.swallow.text");
3032 if(it->label && it->icon){
3033 edje_object_signal_emit(_EDJ(it->base_item), "elm,state,icon_text", "elm");
3034 elm_label_line_wrap_set(it->label, EINA_FALSE);
3035 elm_label_wrap_mode_set(it->label, 0);
3036 elm_label_line_wrap_set(it->label_shadow, EINA_FALSE);
3037 elm_label_wrap_mode_set(it->label_shadow, 0);
3039 if(it->edit_label && it->edit_icon)
3041 edje_object_signal_emit(_EDJ(it->edit_item), "elm,state,icon_text", "elm");
3042 elm_label_line_wrap_set(it->edit_label, EINA_FALSE);
3043 elm_label_wrap_mode_set(it->edit_label, 0);
3044 elm_label_line_wrap_set(it->edit_label_shadow, EINA_FALSE);
3045 elm_label_wrap_mode_set(it->edit_label_shadow, 0);
3050 * Get the label of item
3052 * @param it The item of controlbar
3053 * @return The label of item
3055 * @ingroup Controlbar
3058 elm_controlbar_item_label_get(Elm_Controlbar_Item * it)
3064 * Get the selected item
3066 * @param obj The controlbar object
3067 * @return The item of controlbar
3069 * @ingroup Controlbar
3071 EAPI Elm_Controlbar_Item * elm_controlbar_selected_item_get(Evas_Object *
3076 Elm_Controlbar_Item * item;
3079 Widget_Data * wd = elm_widget_data_get(obj);
3080 if (!wd || !wd->items)
3082 EINA_LIST_FOREACH(wd->items, l, item)
3091 * Get the first item
3093 * @param obj The controlbar object
3094 * @return The item of controlbar
3096 * @ingroup Controlbar
3098 EAPI Elm_Controlbar_Item * elm_controlbar_first_item_get(Evas_Object * obj)
3102 Widget_Data * wd = elm_widget_data_get(obj);
3103 if (!wd || !wd->items)
3105 return eina_list_data_get(wd->items);
3111 * @param obj The controlbar object
3112 * @return The item of controlbar
3114 * @ingroup Controlbar
3116 EAPI Elm_Controlbar_Item * elm_controlbar_last_item_get(Evas_Object * obj)
3120 Widget_Data * wd = elm_widget_data_get(obj);
3121 if (!wd || !wd->items)
3123 return eina_list_data_get(eina_list_last(wd->items));
3129 * @param obj The controlbar object
3130 * @return The list of the items
3132 * @ingroup Controlbar
3134 EAPI Eina_List * elm_controlbar_items_get(Evas_Object * obj)
3138 Widget_Data * wd = elm_widget_data_get(obj);
3139 if (!wd || !wd->items)
3145 * Get the previous item
3147 * @param it The item of controlbar
3148 * @return The previous item of the parameter item
3150 * @ingroup Controlbar
3152 EAPI Elm_Controlbar_Item * elm_controlbar_item_prev(Elm_Controlbar_Item *
3157 Elm_Controlbar_Item * item;
3158 if (it->obj == NULL)
3160 Widget_Data * wd = elm_widget_data_get(it->obj);
3161 if (!wd || !wd->items)
3163 EINA_LIST_FOREACH(wd->items, l, item)
3167 l = eina_list_prev(l);
3170 return eina_list_data_get(l);
3179 * @param obj The controlbar object
3180 * @return The next item of the parameter item
3182 * @ingroup Controlbar
3184 EAPI Elm_Controlbar_Item * elm_controlbar_item_next(Elm_Controlbar_Item *
3189 Elm_Controlbar_Item * item;
3190 if (it->obj == NULL)
3192 Widget_Data * wd = elm_widget_data_get(it->obj);
3193 if (!wd || !wd->items)
3195 EINA_LIST_FOREACH(wd->items, l, item)
3199 l = eina_list_next(l);
3202 return eina_list_data_get(l);
3209 elm_controlbar_edit_start(Evas_Object * obj)
3211 printf("\n==================================\n");
3212 printf("%s\n", __func__);
3213 printf("==================================\n");
3214 printf("This API is just for test.\n");
3215 printf("Please don't use it!!\n");
3216 printf("Thank you.\n");
3217 printf("==================================\n");
3222 fprintf(stderr, "Invalid argument: controlbar object is NULL\n");
3225 wd = elm_widget_data_get(obj);
3228 fprintf(stderr, "Cannot get smart data\n");
3231 edje_object_signal_emit(wd->edit_box, "elm,state,show,edit_box", "elm");
3232 wd->edit_mode = EINA_TRUE;
3236 * Set the visible status of item in bar
3238 * @param it The item of controlbar
3239 * @param bar true or false
3241 * @ingroup Controlbar
3244 elm_controlbar_item_visible_set(Elm_Controlbar_Item * it, Eina_Bool visible)
3246 Elm_Controlbar_Item *item;
3247 Eina_Bool check = EINA_TRUE;
3250 if (it->obj == NULL)
3252 Widget_Data * wd = elm_widget_data_get(it->obj);
3253 if (!wd || !wd->items)
3257 if (check == visible)
3261 item = elm_controlbar_last_item_get(it->obj);
3262 while(!elm_controlbar_item_visible_get(item)){
3263 item = elm_controlbar_item_prev(item);
3265 item_insert_in_bar(it, item->order + 1);
3269 item_delete_in_bar(it);
3271 wd->items = eina_list_sort(wd->items, eina_list_count(wd->items), sort_cb);
3272 _sizing_eval(it->obj);
3277 * Get the result which or not item is visible in bar
3279 * @param it The item of controlbar
3280 * @return true or false
3282 * @ingroup Controlbar
3285 elm_controlbar_item_visible_get(Elm_Controlbar_Item * it)
3287 if(!it) return EINA_FALSE;
3289 if (it->obj == NULL)
3291 Widget_Data * wd = elm_widget_data_get(it->obj);
3302 elm_controlbar_item_editable_set(Elm_Controlbar_Item * it, Eina_Bool editable)
3304 Evas_Object * color;
3309 if(it->editable == editable) return;
3311 it->editable = editable;
3316 (Evas_Object *) edje_object_part_object_get(_EDJ(it->edit_item),
3317 "elm.item.uneditable.color");
3319 evas_object_color_get(color, &r, &g, &b, &a);
3320 evas_object_color_set(it->edit_item, r, g, b, a);
3327 * @param it The item of controlbar
3328 * @param bar true or false
3330 * @ingroup Controlbar
3333 elm_controlbar_item_disable_set(Elm_Controlbar_Item * it, Eina_Bool disable)
3337 if(it->disable == disable) return;
3339 it->disable = disable;
3343 item_color_set(it, "elm.item.disable.color");
3347 item_color_set(it, "elm.item.default.color");
3352 elm_controlbar_view_set(Evas_Object * obj, Evas_Object * view)
3354 printf("\n==================================\n");
3355 printf("%s\n", __func__);
3356 printf("==================================\n");
3357 printf("This API is just for test.\n");
3358 printf("Please don't use it!!\n");
3359 printf("Thank you.\n");
3360 printf("==================================\n");
3365 fprintf(stderr, "Invalid argument: controlbar object is NULL\n");
3368 wd = elm_widget_data_get(obj);
3371 fprintf(stderr, "Cannot get smart data\n");
3374 wd->view_content = view;
3375 //edje_object_part_swallow(wd->view, "elm.swallow.view", wd->view_content);
3376 elm_layout_content_set(wd->view, "elm.swallow.view", wd->view_content);
3380 * Set the view of the item
3382 * @param it The item of controlbar
3383 * @param view The view for the item
3385 * @ingroup Controlbar
3388 elm_controlbar_item_view_set(Elm_Controlbar_Item *it, Evas_Object * view)
3396 * Get the view of the item
3398 * @param it The item of controlbar
3399 * @return The view for the item
3401 * @ingroup Controlbar
3404 elm_controlbar_item_view_get(Elm_Controlbar_Item *it)
3412 * Set the mode of the controlbar
3414 * @param obj The object of the controlbar
3415 * @param mode The mode of the controlbar
3417 * @ingroup Controlbar
3420 elm_controlbar_mode_set(Evas_Object *obj, int mode)
3425 fprintf(stderr, "Invalid argument: controlbar object is NULL\n");
3428 wd = elm_widget_data_get(obj);
3431 fprintf(stderr, "Cannot get smart data\n");
3435 if(wd->mode == mode) return;
3441 case ELM_CONTROLBAR_MODE_DEFAULT:
3442 edje_object_signal_emit(wd->edje, "elm,state,default", "elm");
3444 case ELM_CONTROLBAR_MODE_TRANSLUCENCE:
3445 elm_controlbar_alpha_set(obj, 85);
3447 case ELM_CONTROLBAR_MODE_TRANSPARENCY:
3448 elm_controlbar_alpha_set(obj, 0);
3450 case ELM_CONTROLBAR_MODE_LARGE:
3451 edje_object_signal_emit(wd->edje, "elm,state,large", "elm");
3453 case ELM_CONTROLBAR_MODE_SMALL:
3454 edje_object_signal_emit(wd->edje, "elm,state,small", "elm");
3456 case ELM_CONTROLBAR_MODE_LEFT:
3457 wd->selected_box = wd->focused_box_left;
3458 wd->selected_signal = eina_stringshare_add("elm,state,selected_left");
3459 wd->pressed_signal = eina_stringshare_add("elm,state,pressed_left");
3460 edje_object_signal_emit(wd->edje, "elm,state,left", "elm");
3463 case ELM_CONTROLBAR_MODE_RIGHT:
3464 wd->selected_box = wd->focused_box_right;
3465 wd->selected_signal = eina_stringshare_add("elm,state,selected_right");
3466 wd->pressed_signal = eina_stringshare_add("elm,state,pressed_right");
3467 edje_object_signal_emit(wd->edje, "elm,state,right", "elm");
3474 wd->selected_box = wd->focused_box;
3475 wd->selected_signal = eina_stringshare_add("elm,state,selected");
3476 wd->pressed_signal = eina_stringshare_add("elm,state,pressed");
3481 * Set the alpha of the controlbar
3483 * @param obj The object of the controlbar
3484 * @param alpha The alpha value of the controlbar (0-100)
3486 * @ingroup Controlbar
3489 elm_controlbar_alpha_set(Evas_Object *obj, int alpha)
3495 fprintf(stderr, "Invalid argument: controlbar object is NULL\n");
3498 wd = elm_widget_data_get(obj);
3501 fprintf(stderr, "Cannot get smart data\n");
3507 else if(alpha > 100)
3512 evas_object_color_get(wd->bg, &r, &g, &b, NULL);
3513 evas_object_color_set(wd->bg, r, g, b, (int)(255 * wd->alpha / 100));
3518 * Set auto-align mode of the controlbar(It's not prepared yet)
3519 * If you set the auto-align and add items more than 5,
3520 * the "more" item will be made and the items more than 5 will be unvisible.
3522 * @param obj The object of the controlbar
3523 * @param auto_align The dicision that the controlbar use the auto-align
3525 * @ingroup Controlbar
3528 elm_controlbar_item_auto_align_set(Evas_Object *obj, Eina_Bool auto_align)
3531 Elm_Controlbar_Item *item;
3536 fprintf(stderr, "Invalid argument: controlbar object is NULL\n");
3539 wd = elm_widget_data_get(obj);
3542 fprintf(stderr, "Cannot get smart data\n");
3546 if(wd->auto_align == auto_align) return;
3550 if(check_bar_item_number(wd) >= 5 && !wd->more_item)
3553 EINA_LIST_FOREACH(wd->items, l, item)
3555 if(elm_controlbar_item_visible_get(item))
3558 item_delete_in_bar(item);
3561 item = elm_controlbar_last_item_get(obj);
3562 while(!elm_controlbar_item_visible_get(item)){
3563 item = elm_controlbar_item_prev(item);
3565 create_more_item(wd, item->style);
3573 if(wd->more_item->view)
3574 evas_object_del(wd->more_item->view);
3575 wd->items = eina_list_remove(wd->items, wd->more_item);
3576 eina_stringshare_del(wd->more_item->text);
3577 if (wd->more_item->icon)
3578 evas_object_del(wd->more_item->icon);
3579 if (wd->more_item->base)
3580 evas_object_del(wd->more_item->base);
3581 if (wd->more_item->base_item)
3582 evas_object_del(wd->more_item->base_item);
3583 if (wd->more_item->edit)
3584 evas_object_del(wd->more_item->edit);
3585 if (wd->more_item->edit_item)
3586 evas_object_del(wd->more_item->edit_item);
3587 free(wd->more_item);
3588 wd->more_item = NULL;
3590 // make all item is visible
3592 EINA_LIST_FOREACH(wd->items, l, item)
3594 if(!elm_controlbar_item_visible_get(item))
3595 item_insert_in_bar(item, i);
3600 wd->auto_align = auto_align;
3605 * Set the vertical mode of the controlbar
3607 * @param obj The object of the controlbar
3608 * @param vertical The vertical mode of the controlbar (TRUE = vertical, FALSE = horizontal)
3610 * @ingroup Controlbar
3613 elm_controlbar_vertical_set(Evas_Object *obj, Eina_Bool vertical)
3618 fprintf(stderr, "Invalid argument: controlbar object is NULL\n");
3621 wd = elm_widget_data_get(obj);
3624 fprintf(stderr, "Cannot get smart data\n");
3628 if(wd->vertical == vertical)
3630 wd->vertical = vertical;
3632 if(check_bar_item_number(wd) > 1)
3639 init_animation(void *data)
3642 Elm_Controlbar_Item * item;
3643 Widget_Data * wd = (Widget_Data *)data;
3645 wd->visible_items = eina_list_free(wd->visible_items);
3646 EINA_LIST_FOREACH(wd->items, l, item)
3650 wd->visible_items = eina_list_append(wd->visible_items, item->base);
3655 wd->ani_func(wd->ani_data, wd->object, wd->visible_items);
3657 return ECORE_CALLBACK_CANCEL;
3661 elm_controlbar_animation_set(Evas_Object *obj, void (*func) (void *data, Evas_Object *obj, void *event_info), void *data)
3663 printf("\n==================================\n");
3664 printf("%s\n", __func__);
3665 printf("==================================\n");
3666 printf("This API is just for test.\n");
3667 printf("Please don't use it!!\n");
3668 printf("Thank you.\n");
3669 printf("==================================\n");
3674 fprintf(stderr, "Invalid argument: controlbar object is NULL\n");
3677 wd = elm_widget_data_get(obj);
3680 fprintf(stderr, "Cannot get smart data\n");
3686 wd->init_animation = EINA_TRUE;
3688 wd->ani_func = func;
3689 wd->ani_data = data;
3691 ecore_idler_add(init_animation, wd);
3696 elm_controlbar_item_animation_set(Evas_Object *obj, Eina_Bool auto_animation, Eina_Bool selected_animation)
3698 printf("\n==================================\n");
3699 printf("%s\n", __func__);
3700 printf("==================================\n");
3701 printf("This API is just for test.\n");
3702 printf("Please don't use it!!\n");
3703 printf("Thank you.\n");
3704 printf("==================================\n");
3709 fprintf(stderr, "Invalid argument: controlbar object is NULL\n");
3712 wd = elm_widget_data_get(obj);
3715 fprintf(stderr, "Cannot get smart data\n");
3719 if(auto_animation && !wd->effect_timer)
3721 wd->effect_timer = ecore_timer_add(1.5, item_animation_effect, wd);
3725 if(wd->effect_timer) ecore_timer_del(wd->effect_timer);
3726 wd->effect_timer = NULL;
3729 wd->selected_animation = selected_animation;
3733 elm_controlbar_view_animation_set(Evas_Object *obj, const char *hide, const char *show)
3738 fprintf(stderr, "Invalid argument: controlbar object is NULL\n");
3741 wd = elm_widget_data_get(obj);
3744 fprintf(stderr, "Cannot get smart data\n");
3748 wd->view_hide = eina_stringshare_add(hide);
3749 wd->view_show = eina_stringshare_add(show);