2 * @defgroup Controlbar Controlbar
5 * This is a Controlbar. It can contain label and icon objects.
6 * In edit mode, you can change the location of items.
12 #include <Elementary.h>
16 #define EAPI __attribute__ ((visibility("default")))
20 #define EDIT_ROW_NUM 4
22 #define ELM_MAX(v1, v2) (((v1) > (v2)) ? (v1) : (v2))
23 #define _EDJ(x) (Evas_Object *)elm_layout_edje_get(x)
29 // internal data structure of controlbar object
30 typedef struct _Widget_Data Widget_Data;
38 Evas_Object * view_content;
39 // Evas_Object * edit_box;
40 // Evas_Object * edit_table;
41 // Evas_Object * navigation;
45 Evas_Object * event_box;
46 Evas_Object * selected_box;
47 Evas_Object * focused_box;
48 Evas_Object * focused_box_left;
49 Evas_Object * focused_box_right;
51 Evas_Object * moving_obj;
52 Elm_Controlbar_Item * more_item;
53 Elm_Controlbar_Item * moving_item;
54 Elm_Controlbar_Item * pre_item;
55 Elm_Controlbar_Item * cur_item;
56 Evas_Coord x, y, w, h;
58 // Eina_Bool edit_mode;
65 Eina_List * visible_items;
67 Ecore_Event_Handler * move_event;
68 Ecore_Event_Handler * up_event;
69 Ecore_Event_Handler * bar_move_event;
70 Ecore_Event_Handler * bar_up_event;
72 void (*ani_func) (void *data, Evas_Object * obj, void *event_info);
74 Eina_Bool init_animation;
76 Ecore_Timer *effect_timer;
77 Eina_Bool selected_animation;
80 Elm_Xml_Animator *vxa;
82 const char *view_hide;
83 const char *view_show;
85 const char *pressed_signal;
86 const char *selected_signal;
89 struct _Elm_Controlbar_Item
93 Evas_Object * base_item;
94 // Evas_Object * edit;
95 // Evas_Object * edit_item;
98 Evas_Object * label_shadow;
100 Evas_Object * icon_shadow;
101 // Evas_Object * edit_label;
102 // Evas_Object * edit_label_shadow;
103 // Evas_Object * edit_icon;
104 // Evas_Object * edit_icon_shadow;
105 const char *icon_path;
107 void (*func) (void *data, Evas_Object * obj, void *event_info);
114 // Eina_Bool editable;
118 typedef struct _Animation_Data Animation_Data;
120 struct _Animation_Data
131 unsigned int start_time;
133 void (*func) (void *data, Evas_Object * obj);
135 Ecore_Animator * timer;
138 static const char *widtype = NULL;
140 static int check_bar_item_number(Widget_Data *wd);
141 static void selected_box(Elm_Controlbar_Item * it);
142 static int pressed_box(Elm_Controlbar_Item * it);
143 static void item_color_set(Elm_Controlbar_Item *item, const char *color_part);
144 //static void edit_item_up_cb(void *data, Evas *evas, Evas_Object *obj, void *event_info);
145 //static void edit_item_move_cb(void *data, Evas *evas, Evas_Object *obj, void *event_info);
146 //static void bar_item_up_cb(void *data, Evas *evas, Evas_Object *obj, void *event_info);
147 //static void bar_item_move_cb(void *data, Evas *evas, Evas_Object *obj, void *event_info);
149 /////////////////////////
151 ////////////////////////
154 print_all_items(Widget_Data *wd)
157 Elm_Controlbar_Item * item;
159 EINA_LIST_FOREACH(wd->items, l, item)
161 printf("item label : %s order : %d address : %p\n", item->text, item->order, item);
165 ///////////////////////////////////////////////////////////////////
167 // Smart Object basic function
169 ////////////////////////////////////////////////////////////////////
172 _controlbar_move(void *data, Evas_Object * obj)
175 Evas_Coord x, y, x_, y_, width;
178 wd = elm_widget_data_get((Evas_Object *) data);
181 evas_object_geometry_get(wd->edje, &x, &y, NULL, NULL);
184 evas_object_move(wd->edje, x, y);
185 evas_object_geometry_get(edje_object_part_object_get(wd->edje, "bg_image"), NULL, NULL, &width, NULL);
186 evas_object_geometry_get(wd->parent, &x_, &y_, NULL, NULL);
189 case ELM_CONTROLBAR_MODE_LEFT:
190 evas_object_move(wd->view, x + width, y);
192 case ELM_CONTROLBAR_MODE_RIGHT:
194 evas_object_move(wd->view, x, y);
197 // evas_object_move(wd->edit_box, x_, y_);
198 evas_object_move(wd->event_box, x, y);
202 _controlbar_resize(void *data, Evas_Object * obj)
205 Elm_Controlbar_Item *item;
207 Evas_Coord x, y, x_, y_, w, h, width, height;
210 wd = elm_widget_data_get((Evas_Object *) data);
213 evas_object_geometry_get(wd->edje, &x, &y, &w, &h);
216 evas_object_resize(wd->edje, w, h);
217 evas_object_geometry_get(edje_object_part_object_get(wd->edje, "bg_image"), NULL, NULL, &width, &height);
218 evas_object_geometry_get(wd->parent, &x_, &y_, NULL, NULL);
221 case ELM_CONTROLBAR_MODE_LEFT:
222 case ELM_CONTROLBAR_MODE_RIGHT:
223 evas_object_resize(wd->view, w - width, h);
224 // evas_object_resize(wd->edit_box, w + x - x_, h);
227 evas_object_resize(wd->view, w, h - height + 1);
228 // evas_object_resize(wd->edit_box, w, h + y - y_);
231 evas_object_resize(wd->event_box, w, h);
233 EINA_LIST_FOREACH(wd->items, l, item)
239 elm_label_wrap_width_set(item->label, (int)(wd->w/check_bar_item_number(wd))-20);
240 // elm_label_wrap_width_set(item->label_shadow, (int)(wd->w/check_bar_item_number(wd))-20);
244 elm_label_wrap_width_set(item->label, (int)(wd->w-20));
245 // elm_label_wrap_width_set(item->label_shadow, (int)(wd->w-20));
248 /* if(item->edit_label)
250 elm_label_wrap_width_set(item->edit_label, (int)(wd->w/check_bar_item_number(wd))-20);
251 elm_label_wrap_width_set(item->edit_label_shadow, (int)(wd->w/check_bar_item_number(wd))-20);
257 _controlbar_object_move(void *data, Evas * e, Evas_Object * obj,
260 _controlbar_move(data, obj);
264 _controlbar_object_resize(void *data, Evas * e, Evas_Object * obj,
267 _controlbar_resize(data, obj);
271 _controlbar_object_show(void *data, Evas * e, Evas_Object * obj,
277 wd = elm_widget_data_get((Evas_Object *) data);
280 evas_object_show(wd->view);
281 // evas_object_show(wd->edit_box);
282 evas_object_show(wd->edje);
283 evas_object_show(wd->box);
284 evas_object_show(wd->event_box);
288 _controlbar_object_hide(void *data, Evas * e, Evas_Object * obj,
294 wd = elm_widget_data_get((Evas_Object *) data);
297 evas_object_hide(wd->view);
298 // evas_object_hide(wd->edit_box);
299 evas_object_hide(wd->edje);
300 evas_object_hide(wd->box);
301 evas_object_hide(wd->event_box);
305 _item_del(Elm_Controlbar_Item *it)
308 Widget_Data *wd = elm_widget_data_get(it->obj);
311 if(it == wd->more_item)
313 evas_object_del(it->view);
315 eina_stringshare_del(it->text);
317 evas_object_del(it->label);
318 if (it->label_shadow)
319 evas_object_del(it->label_shadow);
321 eina_stringshare_del(it->icon_path);
323 evas_object_del(it->icon);
325 evas_object_del(it->icon_shadow);
328 if (it->style != OBJECT)
329 evas_object_del(it->base);
332 evas_object_hide(it->base);
335 evas_object_del(it->base_item);
337 // evas_object_del(it->edit);
338 // if (it->edit_item)
339 // evas_object_del(it->edit_item);
342 evas_object_hide(it->view);
347 _del_hook(Evas_Object * obj)
349 Widget_Data * wd = elm_widget_data_get(obj);
350 Elm_Controlbar_Item * item;
351 Evas_Object * content;
355 EINA_LIST_FREE(wd->items, item)
364 content = elm_layout_content_unset(wd->view, "elm.swallow.view");
365 evas_object_hide(content);
366 evas_object_del(wd->view);
371 evas_object_del(wd->edit_box);
375 // if (wd->navigation)
377 // evas_object_del(wd->navigation);
378 // wd->navigation = NULL;
382 evas_object_del(wd->bg);
388 evas_object_del(wd->edje);
393 evas_object_del(wd->focused_box);
396 if (wd->focused_box_left)
398 evas_object_del(wd->focused_box_left);
401 if (wd->focused_box_right)
403 evas_object_del(wd->focused_box_right);
408 evas_object_del(wd->box);
413 evas_object_del(wd->event_box);
414 wd->event_box = NULL;
419 elm_xml_animator_del(wd->xa);
422 if (wd->effect_timer)
424 ecore_timer_del(wd->effect_timer);
425 wd->effect_timer = NULL;
433 _theme_hook(Evas_Object * obj)
437 Elm_Controlbar_Item * item;
441 Widget_Data * wd = elm_widget_data_get(obj);
444 _elm_theme_object_set(obj, wd->edje, "controlbar", "base",
445 elm_widget_style_get(obj));
446 _elm_theme_object_set(obj, wd->bg, "controlbar", "background",
447 elm_widget_style_get(obj));
448 evas_object_color_get(wd->bg, &r, &g, &b, NULL);
449 evas_object_color_set(wd->bg, r, g, b, (int)(255 * wd->alpha / 100));
450 elm_layout_theme_set(wd->view, "controlbar", "view", elm_widget_style_get(obj));
451 // _elm_theme_object_set(obj, wd->edit_box, "controlbar", "edit_box",
452 // elm_widget_style_get(obj));
453 _elm_theme_object_set(obj, wd->focused_box, "controlbar", "item_bg_move", elm_widget_style_get(obj));
454 _elm_theme_object_set(obj, wd->focused_box_left, "controlbar", "item_bg_move", elm_widget_style_get(obj));
455 _elm_theme_object_set(obj, wd->focused_box_right, "controlbar", "item_bg_move", elm_widget_style_get(obj));
456 EINA_LIST_FOREACH(wd->items, l, item)
458 if (item->style != OBJECT)
460 elm_layout_theme_set(item->base, "controlbar", "item_bg",
461 elm_widget_style_get(obj));
462 // elm_layout_theme_set(item->edit, "controlbar", "item_bg",
463 // elm_widget_style_get(obj));
464 // if (!item->editable)
468 // edje_object_part_object_get(_EDJ(item->edit),
469 // "elm.item.uneditable.color");
471 // evas_object_color_get(color, &r, &g, &b, &a);
472 // evas_object_color_set(item->edit_item, r, g, b, a);
474 if (item->label && item->icon)
476 edje_object_signal_emit(_EDJ(item->base_item),
477 "elm,state,icon_text", "elm");
478 // edje_object_signal_emit(_EDJ(item->edit_item),
479 // "elm,state,icon_text", "elm");
490 _sub_del(void *data, Evas_Object * obj, void *event_info)
492 Widget_Data *wd = elm_widget_data_get(obj);
493 Evas_Object *sub = event_info;
494 Evas_Object *content;
499 content = elm_layout_content_unset(wd->view, "elm.swallow.view");
500 evas_object_hide(content);
505 _sizing_eval(Evas_Object * obj)
507 Widget_Data * wd = elm_widget_data_get(obj);
510 _controlbar_move(obj, obj);
511 _controlbar_resize(obj, obj);
514 /////////////////////////////////////////////////////////////
516 // animation function
518 /////////////////////////////////////////////////////////////
523 struct timeval timev;
525 gettimeofday(&timev, NULL);
526 return ((timev.tv_sec * 1000) + ((timev.tv_usec) / 1000));
530 set_evas_map(Evas_Object * obj, Evas_Coord x, Evas_Coord y, Evas_Coord w,
537 Evas_Map * map = evas_map_new(4);
540 evas_map_smooth_set(map, EINA_TRUE);
541 evas_map_util_points_populate_from_object_full(map, obj, 0);
542 evas_object_map_enable_set(obj, EINA_TRUE);
543 evas_map_util_3d_perspective(map, x + w / 2, y + h / 2, 0, w * 10);
544 evas_map_util_points_populate_from_geometry(map, x, y, w, h, 0);
545 evas_object_map_set(obj, map);
550 move_evas_map(void *data)
560 Animation_Data * ad = (Animation_Data *) data;
561 t = ELM_MAX(0.0, current_time_get() - ad->start_time) / 1000;
562 dx = ad->tx - ad->fx;
563 dy = ad->ty - ad->fy;
564 dw = ad->tw - ad->fw;
565 dh = ad->th - ad->fh;
568 x = (1 * sin((t / ad->time) * (M_PI / 2)) * dx);
569 y = (1 * sin((t / ad->time) * (M_PI / 2)) * dy);
570 w = (1 * sin((t / ad->time) * (M_PI / 2)) * dw);
571 h = (1 * sin((t / ad->time) * (M_PI / 2)) * dh);
584 if (x == dx && y == dy && w == dw && h == dh)
586 ecore_animator_del(ad->timer);
588 set_evas_map(ad->obj, px, py, pw, ph);
589 if (ad->func != NULL)
590 ad->func(ad->data, ad->obj);
591 return ECORE_CALLBACK_CANCEL;
595 set_evas_map(ad->obj, px, py, pw, ph);
597 return ECORE_CALLBACK_RENEW;
602 move_evas_object(void *data)
612 Animation_Data * ad = (Animation_Data *) data;
613 t = ELM_MAX(0.0, current_time_get() - ad->start_time) / 1000;
614 dx = ad->tx - ad->fx;
615 dy = ad->ty - ad->fy;
616 dw = ad->tw - ad->fw;
617 dh = ad->th - ad->fh;
620 x = (1 * sin((t / ad->time) * (M_PI / 2)) * dx);
621 y = (1 * sin((t / ad->time) * (M_PI / 2)) * dy);
622 w = (1 * sin((t / ad->time) * (M_PI / 2)) * dw);
623 h = (1 * sin((t / ad->time) * (M_PI / 2)) * dh);
636 if (x == dx && y == dy && w == dw && h == dh)
638 ecore_animator_del(ad->timer);
640 evas_object_move(ad->obj, px, py);
641 evas_object_resize(ad->obj, pw, ph);
642 evas_object_show(ad->obj);
643 if (ad->func != NULL)
644 ad->func(ad->data, ad->obj);
645 return ECORE_CALLBACK_CANCEL;
649 evas_object_move(ad->obj, px, py);
650 evas_object_resize(ad->obj, pw, ph);
651 evas_object_show(ad->obj);
653 return ECORE_CALLBACK_RENEW;
657 move_fade_out_object(void *data)
661 int dx, dy, dw, dh, da;
663 int px, py, pw, ph, pa;
669 Animation_Data * ad = (Animation_Data *) data;
670 t = ELM_MAX(0.0, current_time_get() - ad->start_time) / 1000;
671 dx = ad->tx - ad->fx;
672 dy = ad->ty - ad->fy;
673 dw = ad->tw - ad->fw;
674 dh = ad->th - ad->fh;
678 x = (1 * sin((t / ad->time) * (M_PI / 2)) * dx);
679 y = (1 * sin((t / ad->time) * (M_PI / 2)) * dy);
680 w = (1 * sin((t / ad->time) * (M_PI / 2)) * dw);
681 h = (1 * sin((t / ad->time) * (M_PI / 2)) * dh);
682 a = (1 * sin((t / ad->time) * (M_PI / 2)) * da);
697 if (x == dx && y == dy && w == dw && h == dh)
699 ecore_animator_del(ad->timer);
701 evas_object_move(ad->obj, px, py);
702 //evas_object_resize(ad->obj, 480, 600);
703 evas_object_resize(ad->obj, pw, ph);
704 evas_object_color_get(ad->obj, &r, &g, &b, &a);
705 evas_object_color_set(ad->obj, r, g, b, pa);
706 evas_object_show(ad->obj);
707 if (ad->func != NULL)
708 ad->func(ad->data, ad->obj);
709 return ECORE_CALLBACK_CANCEL;
713 evas_object_move(ad->obj, px, py);
714 //evas_object_resize(ad->obj, 480, 600);
715 evas_object_resize(ad->obj, pw, ph);
716 evas_object_color_get(ad->obj, &r, &g, &b, &a);
717 evas_object_color_set(ad->obj, r, g, b, pa);
718 evas_object_show(ad->obj);
720 return ECORE_CALLBACK_RENEW;
724 move_fade_in_object(void *data)
728 int dx, dy, dw, dh, da;
730 int px, py, pw, ph, pa;
736 Animation_Data * ad = (Animation_Data *) data;
737 t = ELM_MAX(0.0, current_time_get() - ad->start_time) / 1000;
738 dx = ad->tx - ad->fx;
739 dy = ad->ty - ad->fy;
740 dw = ad->tw - ad->fw;
741 dh = ad->th - ad->fh;
745 x = (1 * sin((t / ad->time) * (M_PI / 2)) * dx);
746 y = (1 * sin((t / ad->time) * (M_PI / 2)) * dy);
747 w = (1 * sin((t / ad->time) * (M_PI / 2)) * dw);
748 h = (1 * sin((t / ad->time) * (M_PI / 2)) * dh);
749 a = (1 * sin((t / ad->time) * (M_PI / 2)) * da);
764 if (x == dx && y == dy && w == dw && h == dh)
766 ecore_animator_del(ad->timer);
768 evas_object_move(ad->obj, px, py);
769 //evas_object_resize(ad->obj, 480, 600);
770 evas_object_resize(ad->obj, pw, ph);
771 evas_object_color_get(ad->obj, &r, &g, &b, &a);
772 evas_object_color_set(ad->obj, r, g, b, pa);
773 evas_object_show(ad->obj);
774 if (ad->func != NULL)
775 ad->func(ad->data, ad->obj);
776 return ECORE_CALLBACK_CANCEL;
780 evas_object_move(ad->obj, px, py);
781 //evas_object_resize(ad->obj, 480, 600);
782 evas_object_resize(ad->obj, pw, ph);
783 evas_object_color_get(ad->obj, &r, &g, &b, &a);
784 evas_object_color_set(ad->obj, r, g, b, pa);
785 evas_object_show(ad->obj);
787 return ECORE_CALLBACK_RENEW;
791 move_object_with_animation(Evas_Object * obj, Evas_Coord x, Evas_Coord y,
792 Evas_Coord w, Evas_Coord h, Evas_Coord x_,
793 Evas_Coord y_, Evas_Coord w_, Evas_Coord h_,
794 double time, Eina_Bool (*mv_func) (void *data),
795 void (*func) (void *data,
796 Evas_Object * obj), void *data)
798 Animation_Data * ad = (Animation_Data *) malloc(sizeof(Animation_Data));
808 ad->start_time = current_time_get();
812 ad->timer = ecore_animator_add(mv_func, ad);
816 end_item_animation_effect(void *data, Evas_Object *obj)
818 Widget_Data *wd = (Widget_Data *)data;
819 elm_xml_animator_object_del(wd->xa, obj);
823 item_animation_effect(void *data)
825 Widget_Data *wd = (Widget_Data *)data;
827 Elm_Controlbar_Item * item;
831 wd->xa = elm_xml_animator_add(wd->object);
832 elm_xml_animator_file_set(wd->xa, "/usr/share/xmls/elementary.xml");
837 EINA_LIST_FOREACH(wd->items, l, item)
840 if(rand > 65 && item->order > 0)
846 elm_xml_animator_object_add(wd->xa, item->base_item, "test", end_item_animation_effect, wd);
849 elm_xml_animator_object_add(wd->xa, item->base_item, "test2", end_item_animation_effect, wd);
852 elm_xml_animator_object_add(wd->xa, item->base_item, "test3", end_item_animation_effect, wd);
855 elm_xml_animator_object_add(wd->xa, item->base_item, "test4", end_item_animation_effect, wd);
864 elm_xml_animator_run(wd->xa);
866 return ECORE_CALLBACK_RENEW;
869 /////////////////////////////////////////////////////////////
873 /////////////////////////////////////////////////////////////
876 sort_cb(const void *d1, const void *d2)
878 Elm_Controlbar_Item * item1, *item2;
879 item1 = (Elm_Controlbar_Item *) d1;
880 item2 = (Elm_Controlbar_Item *) d2;
881 if (item1->order <= 0)
883 if (item2->order <= 0)
885 return item1->order > item2->order ? 1 : -1;
889 sort_reverse_cb(const void *d1, const void *d2)
891 Elm_Controlbar_Item * item1, *item2;
892 item1 = (Elm_Controlbar_Item *) d1;
893 item2 = (Elm_Controlbar_Item *) d2;
894 if (item1->order <= 0)
896 if (item2->order <= 0)
898 return item1->order > item2->order ? -1 : 1;
902 done_button_cb(void *data, Evas_Object * obj, void *event_info)
904 Widget_Data * wd = (Widget_Data *) data;
906 wd->items = eina_list_sort(wd->items, eina_list_count(wd->items), sort_cb);
908 evas_object_smart_callback_call(wd->object, "edit,end", wd->items);
910 edje_object_signal_emit(wd->edit_box, "elm,state,hide,edit_box", "elm");
911 wd->edit_mode = EINA_FALSE;
914 ///////////////////////////////////////////////////////////////////
916 // basic utility function
918 ////////////////////////////////////////////////////////////////////
921 item_exist_check(Widget_Data *wd, Elm_Controlbar_Item *item)
924 Elm_Controlbar_Item *it;
926 EINA_LIST_FOREACH(wd->items, l, it)
928 if(it == item) return EINA_TRUE;
934 check_bar_item_number(Widget_Data *wd)
937 Elm_Controlbar_Item * item;
940 EINA_LIST_FOREACH(wd->items, l, item)
942 if(item->order > 0) num++;
949 item_insert_in_bar(Elm_Controlbar_Item * it, int order)
953 Elm_Controlbar_Item * item;
954 Widget_Data * wd = elm_widget_data_get(it->obj);
957 if(order == 0) return;
959 EINA_LIST_FOREACH(wd->items, l, item)
961 if (item->order == order && item != it)
966 EINA_LIST_FOREACH(wd->items, l, item)
969 elm_table_unpack(wd->box, item->base);
971 EINA_LIST_FOREACH(wd->items, l, item)
975 if (item->order >= order)
979 elm_table_pack(wd->box, item->base, item->order - 1, 0, 1, 1);
983 elm_table_pack(wd->box, item->base, 0, item->order - 1, 1, 1);
985 evas_object_show(item->base);
992 elm_table_pack(wd->box, it->base, it->order - 1, 0, 1, 1);
996 elm_table_pack(wd->box, it->base, 0, it->order - 1, 1, 1);
998 evas_object_show(it->base);
1002 item_delete_in_bar(Elm_Controlbar_Item * it)
1005 Elm_Controlbar_Item * item;
1006 Widget_Data * wd = elm_widget_data_get(it->obj);
1009 EINA_LIST_FOREACH(wd->items, l, item)
1015 elm_table_unpack(wd->box, it->base);
1016 evas_object_hide(it->base);
1021 EINA_LIST_FOREACH(wd->items, l, item)
1023 if (item->order > i)
1026 elm_table_unpack(wd->box, item->base);
1029 elm_table_pack(wd->box, item->base, item->order - 1, 0, 1, 1);
1033 elm_table_pack(wd->box, item->base, 0, item->order - 1, 1, 1);
1041 item_visible_set(Elm_Controlbar_Item *it, Eina_Bool visible)
1043 Elm_Controlbar_Item *item;
1044 Eina_Bool check = EINA_TRUE;
1047 if (it->obj == NULL)
1049 Widget_Data * wd = elm_widget_data_get(it->obj);
1050 if (!wd || !wd->items)
1054 if (check == visible)
1058 item = elm_controlbar_last_item_get(it->obj);
1059 while(!elm_controlbar_item_visible_get(item)){
1060 item = elm_controlbar_item_prev(item);
1062 item_insert_in_bar(it, item->order + 1);
1066 item_delete_in_bar(it);
1068 wd->items = eina_list_sort(wd->items, eina_list_count(wd->items), sort_cb);
1069 _sizing_eval(it->obj);
1073 item_exchange_animation_cb(void *data, Evas_Object * obj)
1075 Widget_Data * wd = (Widget_Data *) data;
1077 if (wd->animating < 0)
1079 printf("animation error\n");
1082 evas_object_map_enable_set(obj, EINA_FALSE);
1086 item_exchange_in_bar(Elm_Controlbar_Item * it1, Elm_Controlbar_Item * it2)
1090 Evas_Coord x, y, w, h;
1091 Evas_Coord x_, y_, w_, h_;
1092 Widget_Data * wd = elm_widget_data_get(it1->obj);
1093 evas_object_geometry_get(wd->moving_item->edit, &x, &y, &w, &h);
1094 set_evas_map(wd->moving_obj, (wd->x + wd->w / 2), (wd->y + wd->h / 2), 0,
1096 evas_object_geometry_get(it1->base, &x, &y, &w, &h);
1097 evas_object_geometry_get(it2->base, &x_, &y_, &w_, &h_);
1099 move_object_with_animation(it1->base, x, y, w, h, x_, y_, w_, h_, 0.25,
1100 move_evas_map, item_exchange_animation_cb, wd);
1102 move_object_with_animation(it2->base, x_, y_, w_, h_, x, y, w, h, 0.25,
1103 move_evas_map, item_exchange_animation_cb, wd);
1104 elm_table_unpack(wd->box, it1->base);
1105 elm_table_unpack(wd->box, it2->base);
1107 it1->order = it2->order;
1111 elm_table_pack(wd->box, it1->base, it1->order - 1, 0, 1, 1);
1112 elm_table_pack(wd->box, it2->base, it2->order - 1, 0, 1, 1);
1116 elm_table_pack(wd->box, it1->base, 0, it1->order - 1, 1, 1);
1117 elm_table_pack(wd->box, it2->base, 0, it2->order - 1, 1, 1);
1122 item_change_animation_cb(void *data, Evas_Object * obj)
1124 Evas_Coord x, y, w, h;
1125 Widget_Data * wd = (Widget_Data *) data;
1127 if (wd->animating < 0)
1129 printf("animation error\n");
1132 evas_object_map_enable_set(obj, EINA_FALSE);
1133 evas_object_geometry_get(obj, &x, &y, &w, &h);
1134 set_evas_map(obj, x, y, 0, 0);
1135 evas_object_move(obj, -1000, -1000);
1136 evas_object_geometry_get(wd->moving_item->base, &x, &y, &w, &h);
1137 evas_object_move(wd->moving_obj, -1000, -1000);
1138 evas_object_del(wd->moving_obj);
1142 item_change_in_bar(Elm_Controlbar_Item * it)
1144 Evas_Coord x, y, w, h;
1145 Evas_Coord x_, y_, w_, h_;
1146 Widget_Data * wd = elm_widget_data_get(it->obj);
1149 if (wd->moving_item == NULL)
1151 evas_object_geometry_get(wd->moving_item->edit, &x, &y, &w, &h);
1152 set_evas_map(wd->moving_obj, x, y, w, h);
1153 elm_table_unpack(wd->box, it->base);
1154 wd->moving_item->order = it->order;
1158 elm_table_pack(wd->box, wd->moving_item->base, wd->moving_item->order - 1, 0, 1, 1);
1162 elm_table_pack(wd->box, wd->moving_item->base, 0, wd->moving_item->order - 1, 1, 1);
1165 evas_object_show(wd->moving_item->base);
1166 evas_render_updates_free(evas_render_updates
1167 (evas_object_evas_get(wd->moving_item->base)));
1168 evas_object_geometry_get(it->base, &x, &y, &w, &h);
1169 evas_object_geometry_get(it->edit, &x_, &y_, &w_, &h_);
1171 move_object_with_animation(it->base, x, y, w, h, x_, y_, w_, h_, 0.25,
1172 move_evas_map, item_change_animation_cb, wd);
1173 evas_object_geometry_get(wd->moving_item->base, &x, &y, &w, &h);
1174 set_evas_map(wd->moving_item->base, x, y, w, h);
1178 hide_selected_box(void *data)
1180 Evas_Object *selected_box = (Evas_Object *)data;
1182 evas_object_hide(selected_box);
1184 return ECORE_CALLBACK_CANCEL;
1188 item_color_set(Elm_Controlbar_Item *item, const char *color_part)
1193 color = (Evas_Object *) edje_object_part_object_get(_EDJ(item->base), color_part);
1195 evas_object_color_get(color, &r, &g, &b, &a);
1196 evas_object_color_set(item->label, r, g, b, a);
1197 evas_object_color_set(item->icon, r, g, b, a);
1201 _end_selected_box(void *data, Evas_Object *obj)
1203 Widget_Data * wd = (Widget_Data *)data;
1205 edje_object_signal_emit(_EDJ(wd->cur_item->base), wd->selected_signal, "elm");
1206 edje_object_signal_emit(_EDJ(wd->cur_item->base_item), "elm,state,shadow_show", "elm");
1209 if (wd->animating < 0)
1211 printf("animation error\n");
1215 ecore_idler_add(hide_selected_box, wd->selected_box);
1219 move_selected_box(Widget_Data *wd, Elm_Controlbar_Item * fit, Elm_Controlbar_Item * tit)
1221 Evas_Coord fx, fy, fw, fh, tx, ty, tw, th;
1222 Evas_Object *from, *to;
1224 if(fit->order <= 0 && wd->auto_align)
1225 fit = wd->more_item;
1227 from = (Evas_Object *)edje_object_part_object_get(_EDJ(fit->base), "bg_img");
1228 evas_object_geometry_get(from, &fx, &fy, &fw, &fh);
1230 to = (Evas_Object *)edje_object_part_object_get(_EDJ(tit->base), "bg_img");
1231 evas_object_geometry_get(to, &tx, &ty, &tw, &th);
1233 edje_object_signal_emit(_EDJ(wd->pre_item->base), "elm,state,unselected", "elm");
1234 edje_object_signal_emit(_EDJ(wd->pre_item->base_item), "elm,state,shadow_hide", "elm");
1235 edje_object_signal_emit(_EDJ(wd->cur_item->base), "elm,state,unselected", "elm");
1238 move_object_with_animation(wd->selected_box, fx, fy, fw, fh, tx, ty, tw, th,
1239 0.3, move_evas_object, _end_selected_box, wd);
1243 end_selected_box(void *data, Evas_Object *obj)
1245 Widget_Data * wd = (Widget_Data *)data;
1247 if(wd->pre_item) evas_object_hide(wd->pre_item->view);
1249 elm_layout_content_set(wd->view, "elm.swallow.view", obj);
1251 evas_object_show(obj);
1255 view_animation_push(Widget_Data *wd, Evas_Object *pre, Evas_Object *cur, void *data)
1257 Evas_Coord x, y, w, h;
1259 evas_object_geometry_get(pre, &x, &y, &w, &h);
1260 move_object_with_animation(pre, x, y, w, h, x+20, y, w, h, 0.5, move_fade_out_object, NULL, NULL);
1261 move_object_with_animation(cur, x+120, y, w, h, x, y, w, h, 0.5, move_fade_in_object, end_selected_box, wd);
1265 view_animation_down(Widget_Data *wd, Evas_Object *pre, Evas_Object *cur, void *data)
1267 Evas_Coord x, y, w, h;
1269 evas_object_geometry_get(pre, &x, &y, &w, &h);
1271 move_object_with_animation(cur, x, h, w, h, x, h, w, h, 0.5, move_evas_object, end_selected_box, wd);
1272 evas_object_raise(pre);
1273 move_object_with_animation(pre, x, y, w, h, x, h, w, 0, 0.5, move_evas_map, NULL, NULL);
1277 end_view_animation_effect(void *data, Evas_Object *obj)
1279 Widget_Data *wd = (Widget_Data *)data;
1280 elm_xml_animator_object_del(wd->vxa, obj);
1282 evas_object_hide(wd->pre_item->view);
1284 //if(wd->cur_item) elm_layout_content_set(wd->view, "elm.swallow.view", wd->cur_item->view);
1288 selected_box(Elm_Controlbar_Item * it)
1290 Widget_Data * wd = elm_widget_data_get(it->obj);
1292 Elm_Controlbar_Item * item, *fit = NULL;
1293 Evas_Object * content;
1295 if(wd->animating) return;
1300 wd->vxa = elm_xml_animator_add(wd->object);
1301 elm_xml_animator_file_set(wd->vxa, "/usr/share/xmls/elementary.xml");
1304 if(it->style == TABBAR){
1306 content = elm_layout_content_unset(wd->view, "elm.swallow.view");
1307 EINA_LIST_FOREACH(wd->items, l, item){
1308 if(item->selected) {
1312 item->selected = EINA_FALSE;
1314 it->selected = EINA_TRUE;
1316 if(wd->more_item != it)
1317 evas_object_smart_callback_call(it->obj, "view,change,before", it);
1319 if(fit != NULL && fit != it)
1321 move_selected_box(wd, fit, it);
1325 edje_object_signal_emit(_EDJ(it->base), wd->selected_signal, "elm");
1326 edje_object_signal_emit(_EDJ(wd->cur_item->base_item), "elm,state,shadow_show", "elm");
1330 if(fit != NULL && fit != it)
1332 //view_animation_down(wd, fit->view, it->view, NULL);
1333 view_animation_push(wd, fit->view, it->view, NULL);
1334 //evas_object_hide(content);
1336 // evas_object_geometry_get(fit->view, &x, &y, &w, &h);
1337 // if(fit->order > it->order)
1339 // move_object_with_animation(fit->view, x, y, w, h, x+20, y, w, h, 0.5, move_fade_out_object, NULL, NULL);
1340 // 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);
1344 // move_object_with_animation(fit->view, x, y, w, h, x-120, y, w, h, 1.5, move_fade_out_object, NULL, NULL);
1345 // 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);
1350 end_selected_box(wd, it->view);
1353 //if(wd->pre_item) evas_object_hide(wd->pre_item->view);
1354 elm_layout_content_set(wd->view, "elm.swallow.view", it->view);
1356 //evas_object_move(it->view, -480, 94);
1357 //evas_object_resize(it->view, 480, 620);
1358 //evas_object_show(it->view);
1360 if(wd->pre_item && wd->pre_item != it)
1363 elm_xml_animator_object_add(wd->vxa, wd->pre_item->view, wd->view_hide, end_view_animation_effect, wd);
1365 evas_object_hide(wd->pre_item->view);
1367 elm_xml_animator_object_add(wd->vxa, it->view, wd->view_show, end_view_animation_effect, wd);
1371 elm_xml_animator_run(wd->vxa);
1373 // elm_layout_content_set(wd->view, "elm.swallow.view", it->view);
1374 //edje_object_part_swallow(wd->view, "elm.swallow.view", it->view);
1375 // evas_object_show(it->view);
1377 }else if(it->style == TOOLBAR){
1380 it->func(it->data, it->obj, it);
1382 if(item_exist_check(wd, it)) edje_object_signal_emit(_EDJ(it->base), "elm,state,text_unselected", "elm");
1385 if(item_exist_check(wd, it)) evas_object_smart_callback_call(it->obj, "clicked", it);
1389 unpressed_box_cb(void *data, Evas *evas, Evas_Object *obj, void *event_info)
1391 Widget_Data * wd = (Widget_Data *) data;
1393 Evas_Event_Mouse_Up * ev = event_info;
1394 Evas_Coord x, y, w, h;
1395 Elm_Controlbar_Item * item;
1397 evas_object_event_callback_del(wd->event_box, EVAS_CALLBACK_MOUSE_UP, unpressed_box_cb);
1399 EINA_LIST_FOREACH(wd->items, l, item)
1401 if (item->style == TABBAR)
1405 edje_object_signal_emit(_EDJ(item->base), wd->selected_signal, "elm");
1409 edje_object_signal_emit(_EDJ(item->base), "elm,state,unselected", "elm");
1410 edje_object_signal_emit(_EDJ(item->base_item), "elm,state,shadow_hide", "elm");
1413 else if (item->style == TOOLBAR)
1417 edje_object_signal_emit(_EDJ(item->base), "elm,state,unselected", "elm");
1418 //item_color_set(item, "elm.item.default.color");
1423 if(item_exist_check(wd, wd->pre_item))
1425 evas_object_geometry_get(wd->pre_item->base, &x, &y, &w, &h);
1426 if(ev->output.x > x && ev->output.x < x+w && ev->output.y > y && ev->output.y < y+h)
1428 selected_box(wd->pre_item);
1435 pressed_box(Elm_Controlbar_Item * it)
1437 Widget_Data * wd = elm_widget_data_get(it->obj);
1440 Elm_Controlbar_Item * item;
1442 if(wd->animating) return EXIT_FAILURE;
1444 if(it->disable) return EXIT_FAILURE;
1446 EINA_LIST_FOREACH(wd->items, l, item)
1450 if (it->style == TABBAR)
1452 edje_object_signal_emit(_EDJ(it->base), wd->pressed_signal, "elm");
1454 else if (it->style == TOOLBAR)
1459 edje_object_signal_emit(_EDJ(it->base), "elm,state,toolbar_pressed", "elm");
1460 //item_color_set(it, "elm.toolbar.pressed.color");
1463 evas_object_event_callback_add(wd->event_box, EVAS_CALLBACK_MOUSE_UP, unpressed_box_cb, (void *)wd);
1469 return EXIT_FAILURE;
1473 return EXIT_SUCCESS;
1476 static Evas_Object *
1477 create_item_label(Evas_Object *obj, Elm_Controlbar_Item * it, char *part)
1481 label = elm_label_add(obj);
1482 elm_object_style_set(label, "controlbar");
1483 elm_label_label_set(label, it->text);
1484 elm_label_text_align_set(label, "center");
1485 elm_label_text_color_set(label, 255, 255, 255, 255);
1486 elm_label_line_wrap_set(label, EINA_TRUE);
1487 elm_label_ellipsis_set(label, EINA_TRUE);
1488 elm_label_wrap_mode_set(label, 1);
1490 elm_layout_content_set(obj, part, label);
1495 static Evas_Object *
1496 create_item_icon(Evas_Object *obj, Elm_Controlbar_Item * it, char *part)
1500 icon = elm_icon_add(obj);
1501 if(!elm_icon_standard_set(icon, it->icon_path))
1503 elm_icon_file_set(icon, it->icon_path, NULL);
1506 evas_object_size_hint_min_set(icon, 40, 40);
1507 evas_object_size_hint_max_set(icon, 100, 100);
1508 evas_object_show(icon);
1510 elm_layout_content_set(obj, part, icon);
1515 static Evas_Object *
1516 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)
1520 obj = elm_layout_add(parent);
1523 fprintf(stderr, "Cannot load bg edj\n");
1526 elm_layout_theme_set(obj, "controlbar", "item_bg",
1527 elm_widget_style_get(it->obj));
1528 evas_object_size_hint_weight_set(obj, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1529 evas_object_size_hint_align_set(obj, EVAS_HINT_FILL, EVAS_HINT_FILL);
1531 *item = elm_layout_add(parent);
1534 fprintf(stderr, "Cannot load bg edj\n");
1537 elm_layout_theme_set(*item, "controlbar", "item",
1538 elm_widget_style_get(it->obj));
1539 elm_layout_content_set(obj, "item", *item);
1543 *label = create_item_label(*item, it, "elm.swallow.text");
1544 // *slabel = create_item_label(*item, it, "elm.swallow.text_shadow");
1545 // evas_object_color_set(*slabel, 0, 0, 0, 255);
1549 *icon = create_item_icon(*item, it, "elm.swallow.icon");
1550 *sicon = create_item_icon(*item, it, "elm.swallow.icon_shadow");
1551 evas_object_color_set(*sicon, 0, 0, 0, 255);
1553 if (*label && *icon)
1555 edje_object_signal_emit(_EDJ(*item), "elm,state,icon_text", "elm");
1556 elm_label_line_wrap_set(*label, EINA_FALSE);
1557 elm_label_wrap_mode_set(*label, 0);
1558 // elm_label_line_wrap_set(*slabel, EINA_FALSE);
1559 // elm_label_wrap_mode_set(*slabel, 0);
1566 edit_item_down_end_cb(void *data, Evas_Object * obj)
1568 Widget_Data * wd = (Widget_Data *) data;
1570 if (wd->animating < 0)
1572 printf("animation error\n");
1578 edit_item_return_cb(void *data, Evas_Object * obj)
1580 Evas_Coord x, y, w, h;
1581 Widget_Data * wd = (Widget_Data *) data;
1582 evas_object_geometry_get(wd->moving_item->edit, &x, &y, &w, &h);
1583 set_evas_map(obj, x, y, 0, 0);
1585 evas_object_event_callback_del(wd->event_box, EVAS_CALLBACK_MOUSE_UP, edit_item_up_cb);
1586 evas_object_event_callback_del(wd->event_box, EVAS_CALLBACK_MOUSE_MOVE, edit_item_move_cb);
1588 evas_object_data_set(wd->moving_obj, "returning", 0);
1590 if (wd->animating < 0)
1592 printf("animation error\n");
1598 edit_item_move_cb(void *data, Evas *evas, Evas_Object *obj, void *event_info)
1600 Evas_Event_Mouse_Move * ev = event_info;
1602 Elm_Controlbar_Item * item;
1603 Evas_Coord x, y, w, h;
1604 Widget_Data * wd = (Widget_Data *) data;
1607 evas_object_geometry_get(wd->moving_obj, &x, &y, &w, &h);
1610 x = ev->cur.output.x - w / 2;
1611 y = ev->cur.output.y - h;
1612 set_evas_map(wd->moving_obj, x, y, w, h);
1614 EINA_LIST_FOREACH(wd->items, l, item)
1616 if (wd->moving_item->edit == item->edit || item->style == OBJECT)
1618 evas_object_geometry_get(item->base, &x, &y, &w, &h);
1619 if (ev->cur.output.x > x && ev->cur.output.x < x + w && ev->cur.output.y > y && ev->cur.output.y < y + h
1622 edje_object_signal_emit(_EDJ(item->base), "elm,state,show,glow",
1627 edje_object_signal_emit(_EDJ(item->base), "elm,state,hide,glow",
1635 edit_item_up_cb(void *data, Evas *evas, Evas_Object *obj, void *event_info)
1637 Evas_Event_Mouse_Up * ev = event_info;
1638 Evas_Coord x, y, w, h;
1639 Evas_Coord x_, y_, w_, h_;
1641 Elm_Controlbar_Item * item;
1642 Widget_Data * wd = (Widget_Data *) data;
1644 if ((int)evas_object_data_get(wd->moving_obj, "returning") == 1)
1646 evas_object_color_set(wd->moving_item->edit_item, 255, 255, 255, 255);
1648 // check which change or not
1649 EINA_LIST_FOREACH(wd->items, l, item)
1651 if (wd->moving_item->edit == item->edit)
1653 if (item->order <= 0)
1655 evas_object_geometry_get(item->base, &x, &y, &w, &h);
1656 if (ev->output.x > x && ev->output.x < x + w && ev->output.y > y && ev->output.y < y + h
1657 && item->style != OBJECT && item->editable)
1659 edje_object_signal_emit(_EDJ(item->base), "elm,state,hide,glow",
1666 if (wd->moving_item->order > 0)
1668 item_exchange_in_bar(wd->moving_item, item);
1672 item_change_in_bar(item);
1674 evas_object_event_callback_del(wd->event_box, EVAS_CALLBACK_MOUSE_UP, edit_item_up_cb);
1675 evas_object_event_callback_del(wd->event_box, EVAS_CALLBACK_MOUSE_MOVE, edit_item_move_cb);
1680 // return moving object to original location
1681 evas_object_geometry_get(wd->moving_item->edit, &x_, &y_, &w_,
1683 evas_object_geometry_get(wd->moving_obj, &x, &y, &w, &h);
1686 x = ev->output.x - w / 2;
1687 y = ev->output.y - h;
1688 evas_object_data_set(wd->moving_obj, "returning", (void *)1);
1690 move_object_with_animation(wd->moving_obj, x, y, w, h, x_, y_, w_, h_,
1691 0.25, move_evas_map, edit_item_return_cb, wd);
1697 edit_item_down_cb(void *data, Evas * evas, Evas_Object * obj,
1700 Evas_Event_Mouse_Down * ev = event_info;
1701 Evas_Coord x, y, w, h;
1702 Evas_Coord x_, y_, w_, h_;
1703 Widget_Data * wd = (Widget_Data *) data;
1706 Elm_Controlbar_Item * item;
1707 Evas_Object * color;
1712 EINA_LIST_FOREACH(wd->items, l, item)
1714 if (item->edit == obj)
1719 if (!item->editable)
1722 evas_object_event_callback_add(wd->event_box, EVAS_CALLBACK_MOUSE_UP, edit_item_up_cb, (void *)wd);
1723 evas_object_event_callback_add(wd->event_box, EVAS_CALLBACK_MOUSE_MOVE, edit_item_move_cb, (void *)wd);
1725 wd->moving_item = item;
1728 edje_object_part_object_get(_EDJ(wd->moving_item->edit),
1729 "elm.item.uneditable.color");
1731 evas_object_color_get(color, &r, &g, &b, &a);
1732 evas_object_color_set(item->edit_item, r, g, b, a);
1734 evas_object_del(wd->moving_obj);
1735 wd->moving_obj = NULL;
1736 wd->moving_obj = create_item_layout(obj, item, &(item->base_item), &(item->label), &(item->icon), &(item->icon_shadow), &(item->label_shadow));
1737 evas_object_geometry_get(obj, &x, &y, &w, &h);
1738 evas_object_move(wd->moving_obj, -1000, -1000);
1739 evas_object_resize(wd->moving_obj, w, h);
1740 evas_object_show(wd->moving_obj);
1743 x_ = ev->output.x - w_ / 2;
1744 y_ = ev->output.y - h_;
1746 move_object_with_animation(wd->moving_obj, x, y, w, h, x_, y_, w_, h_, 0.1,
1747 move_evas_map, edit_item_down_end_cb, wd);
1751 bar_item_move_end_cb(void *data, Evas_Object * obj)
1753 Widget_Data * wd = (Widget_Data *) data;
1756 Elm_Controlbar_Item * item;
1757 EINA_LIST_FOREACH(wd->items, l, item)
1759 if (item->base == obj)
1763 if (wd->animating < 0)
1765 printf("animation error\n");
1768 evas_object_data_set(obj, "animating", 0);
1769 evas_object_map_enable_set(obj, EINA_FALSE);
1773 bar_item_animation_end_check(void *data)
1777 Elm_Controlbar_Item * item;
1778 Widget_Data * wd = (Widget_Data *) data;
1780 return EXIT_FAILURE;
1781 EINA_LIST_FOREACH(wd->items, l, item)
1783 if (item->base == wd->moving_obj)
1788 printf("item is NULL\n");
1792 item->order = wd->empty_num;
1794 wd->moving_obj = NULL;
1796 evas_object_event_callback_del(wd->event_box, EVAS_CALLBACK_MOUSE_UP, bar_item_up_cb);
1797 evas_object_event_callback_del(wd->event_box, EVAS_CALLBACK_MOUSE_MOVE, bar_item_move_cb);
1798 return ECORE_CALLBACK_CANCEL;
1802 bar_item_move_cb(void *data, Evas *evas, Evas_Object *obj, void *event_info)
1804 Evas_Event_Mouse_Move * ev = event_info;
1806 Elm_Controlbar_Item * item, *it;
1807 Widget_Data * wd = (Widget_Data *) data;
1808 Evas_Coord x, y, w, h, x_, y_, w_, h_;
1811 if (wd->moving_obj == NULL)
1813 printf("%s : moving_obj is NULL\n", __func__);
1816 evas_object_geometry_get(wd->moving_obj, &x, &y, &w, &h);
1817 x = ev->cur.output.x - w / 2;
1818 set_evas_map(wd->moving_obj, x, y, w, h);
1819 EINA_LIST_FOREACH(wd->items, l, item)
1821 if (item->base == wd->moving_obj)
1826 if ((int)evas_object_data_get(item->base, "animating") == 1)
1828 evas_object_geometry_get(item->base, &x, &y, &w, &h);
1829 if (ev->cur.output.x > x && ev->cur.output.x < x + w && item->editable)
1836 evas_object_geometry_get(wd->moving_obj, &x_, &y_, &w_, &h_);
1837 evas_object_move(wd->moving_obj, x, y);
1838 tmp = wd->empty_num;
1839 wd->empty_num = item->order;
1841 elm_table_unpack(wd->box, item->base);
1842 elm_table_unpack(wd->box, wd->moving_obj);
1845 elm_table_pack(wd->box, item->base, item->order - 1, 0, 1, 1);
1846 elm_table_pack(wd->box, wd->moving_obj, wd->empty_num - 1, 0, 1, 1);
1850 elm_table_pack(wd->box, item->base, 0, item->order - 1, 1, 1);
1851 elm_table_pack(wd->box, wd->moving_obj, 0, wd->empty_num - 1, 1, 1);
1854 evas_object_data_set(item->base, "animating", (void *)1);
1855 move_object_with_animation(item->base, x, y, w, h, x_, y_, w_, h_,
1856 0.25, move_evas_map, bar_item_move_end_cb, wd);
1862 bar_item_up_cb(void *data, Evas *evas, Evas_Object *obj, void *event_info)
1864 Evas_Event_Mouse_Up * ev = event_info;
1865 Evas_Coord tx, x, y, w, h;
1866 Widget_Data * wd = (Widget_Data *) data;
1867 evas_object_geometry_get(wd->moving_obj, &x, &y, &w, &h);
1868 tx = ev->output.x - w / 2;
1870 evas_object_data_set(wd->moving_obj, "animating", (void *)1);
1871 move_object_with_animation(wd->moving_obj, tx, y, w, h, x, y, w, h, 0.25,
1872 move_evas_map, bar_item_move_end_cb, wd);
1873 ecore_timer_add(0.1, bar_item_animation_end_check, wd);
1879 bar_item_down_cb(void *data, Evas * evas, Evas_Object * obj, void *event_info)
1881 Widget_Data * wd = (Widget_Data *) data;
1883 Elm_Controlbar_Item * item;
1886 EINA_LIST_FOREACH(wd->items, l, item)
1888 if (item->base == obj)
1893 /* if (wd->edit_mode)
1895 if (!item->editable)
1898 wd->moving_obj = obj;
1899 wd->empty_num = item->order;
1900 evas_object_event_callback_add(wd->event_box, EVAS_CALLBACK_MOUSE_UP, bar_item_up_cb, (void *)wd);
1901 evas_object_event_callback_add(wd->event_box, EVAS_CALLBACK_MOUSE_MOVE, bar_item_move_cb, (void *)wd);
1909 static Elm_Controlbar_Item *
1910 create_tab_item(Evas_Object * obj, const char *icon_path, const char *label,
1913 Elm_Controlbar_Item * it;
1917 fprintf(stderr, "Invalid argument: controlbar object is NULL\n");
1920 wd = elm_widget_data_get(obj);
1923 fprintf(stderr, "Cannot get smart data\n");
1926 it = ELM_NEW(Elm_Controlbar_Item);
1930 it->text = eina_stringshare_add(label);
1931 it->icon_path = eina_stringshare_add(icon_path);
1932 it->selected = EINA_FALSE;
1933 // it->editable = EINA_TRUE;
1938 it->base = create_item_layout(wd->edje, it, &(it->base_item), &(it->label), &(it->icon), &(it->icon_shadow), &(it->label_shadow));
1939 evas_object_event_callback_add(it->base, EVAS_CALLBACK_MOUSE_DOWN,
1940 bar_item_down_cb, wd);
1941 evas_object_show(it->base);
1942 // 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));
1943 // evas_object_event_callback_add(it->edit, EVAS_CALLBACK_MOUSE_DOWN,
1944 // edit_item_down_cb, wd);
1945 // evas_object_show(it->edit);
1950 static Elm_Controlbar_Item *
1951 create_tool_item(Evas_Object * obj, const char *icon_path, const char *label,
1952 void (*func) (void *data, Evas_Object * obj,
1953 void *event_info), void *data)
1956 Elm_Controlbar_Item * it;
1960 fprintf(stderr, "Invalid argument: controlbar object is NULL\n");
1963 wd = elm_widget_data_get(obj);
1966 fprintf(stderr, "Cannot get smart data\n");
1969 it = ELM_NEW(Elm_Controlbar_Item);
1973 it->text = eina_stringshare_add(label);
1974 it->icon_path = eina_stringshare_add(icon_path);
1975 it->selected = EINA_FALSE;
1976 // it->editable = EINA_TRUE;
1981 it->style = TOOLBAR;
1982 it->base = create_item_layout(wd->edje, it, &(it->base_item), &(it->label), &(it->icon), &(it->icon_shadow), &(it->label_shadow));
1983 evas_object_event_callback_add(it->base, EVAS_CALLBACK_MOUSE_DOWN,
1984 bar_item_down_cb, wd);
1985 evas_object_show(it->base);
1986 //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));
1987 // evas_object_event_callback_add(it->edit, EVAS_CALLBACK_MOUSE_DOWN,
1988 // edit_item_down_cb, wd);
1989 // evas_object_show(it->edit);
1994 static Elm_Controlbar_Item *
1995 create_object_item(Evas_Object * obj, Evas_Object * obj_item, const int sel)
1997 Elm_Controlbar_Item * it;
2001 fprintf(stderr, "Invalid argument: controlbar object is NULL\n");
2004 wd = elm_widget_data_get(obj);
2007 fprintf(stderr, "Cannot get smart data\n");
2010 it = ELM_NEW(Elm_Controlbar_Item);
2017 it->base = obj_item;
2022 repack_items(Widget_Data *wd)
2025 Elm_Controlbar_Item * item;
2027 EINA_LIST_FOREACH(wd->items, l, item)
2031 elm_table_unpack(wd->box, item->base);
2034 elm_table_pack(wd->box, item->base, item->order - 1, 0, item->sel, 1);
2038 elm_table_pack(wd->box, item->base, 0, item->order - 1, item->sel, 1);
2045 set_items_position(Evas_Object * obj, Elm_Controlbar_Item * it,
2046 Elm_Controlbar_Item * mit, Eina_Bool bar)
2051 Elm_Controlbar_Item * item;
2054 int check = EINA_FALSE;
2062 fprintf(stderr, "Invalid argument: controlbar object is NULL\n");
2065 wd = elm_widget_data_get(obj);
2068 fprintf(stderr, "Cannot get smart data\n");
2072 EINA_LIST_FOREACH(wd->items, l, item)
2074 if (item == mit && item->order > 0)
2078 it->order = mit->order;
2082 if(item->order > 0){
2083 elm_table_unpack(wd->box, item->base);
2084 item->order += it->sel;
2087 elm_table_pack(wd->box, item->base, item->order - 1, 0, item->sel, 1);
2091 elm_table_pack(wd->box, item->base, 0, item->order - 1, item->sel, 1);
2094 // if (item->style != OBJECT && it->style != OBJECT)
2096 // elm_table_unpack(wd->edit_table, item->edit);
2097 // elm_table_pack(wd->edit_table, item->edit,
2098 // i % EDIT_ROW_NUM, i / EDIT_ROW_NUM, 1, 1);
2101 if (item->style != OBJECT)
2103 if(item->order > 0) order += item->sel;
2119 elm_table_pack(wd->box, it->base, it->order - 1, 0, it->sel, 1);
2123 elm_table_pack(wd->box, it->base, 0, it->order - 1, it->sel, 1);
2126 else evas_object_hide(it->base);
2127 // if (it->style != OBJECT)
2128 // elm_table_pack(wd->edit_table, it->edit, (edit - 1) % EDIT_ROW_NUM,
2129 // (edit - 1) / EDIT_ROW_NUM, 1, 1);
2133 list_clicked(void *data, Evas_Object *obj, void *event_info)
2135 Elm_Controlbar_Item *item = (Elm_Controlbar_Item *)data;
2136 Elm_Controlbar_Item *it;
2139 Evas_Object *content;
2140 Elm_List_Item *lit = (Elm_List_Item *) elm_list_selected_item_get(obj);
2141 if(lit == NULL) return;
2143 elm_list_item_selected_set(lit, 0);
2147 wd = elm_widget_data_get(item->obj);
2149 EINA_LIST_FOREACH(wd->items, l, it)
2151 it->selected = EINA_FALSE;
2154 if(item->style == TABBAR)
2156 content = elm_layout_content_unset(wd->view, "elm.swallow.view");
2157 evas_object_hide(content);
2158 item->selected = EINA_TRUE;
2159 evas_object_smart_callback_call(item->obj, "view,change,before", item);
2160 elm_layout_content_set(wd->view, "elm.swallow.view", item->view);
2163 if(item->style == TOOLBAR && item->func)
2164 item->func(item->data, item->obj, item);
2167 static Evas_Object *
2168 create_more_view(Widget_Data *wd)
2171 Elm_Controlbar_Item *item;
2175 list = elm_list_add( wd->object );
2176 elm_list_horizontal_mode_set( list, ELM_LIST_COMPRESS );
2178 EINA_LIST_FOREACH(wd->items, l, item)
2180 if(item->order <= 0)
2185 icon = create_item_icon(list, item, NULL);
2186 evas_object_color_set(icon, 0, 0, 0, 255);
2188 elm_list_item_append(list, item->text, icon, NULL, list_clicked, item);
2192 elm_list_go( list );
2197 static void _ctxpopup_cb(void *data, Evas_Object *obj, void *event_info)
2199 Elm_Controlbar_Item *it;
2201 Evas_Object *ctxpopup = obj;
2202 Widget_Data *wd = (Widget_Data *)data;
2204 EINA_LIST_FOREACH(wd->items, l, it)
2206 if(!strcmp(it->text, elm_ctxpopup_item_label_get((Elm_Ctxpopup_Item *) event_info))) break;
2211 it->func(it->data, it->obj, it);
2214 if(item_exist_check(wd, it)) evas_object_smart_callback_call(it->obj, "clicked", it);
2216 evas_object_del(ctxpopup);
2220 static void _ctxpopup_hide_cb(void *data, Evas_Object *obj, void *event_info)
2222 Evas_Object *ctxpopup = obj;
2224 evas_object_del(ctxpopup);
2229 create_more_func(void *data, Evas_Object *obj, void *event_info)
2231 Evas_Object *ctxpopup;
2232 Elm_Controlbar_Item *item;
2235 Evas_Coord x, y, w, h;
2236 Widget_Data *wd = elm_widget_data_get(obj);
2239 ctxpopup = elm_ctxpopup_add(wd->parent);
2240 evas_object_smart_callback_add( ctxpopup, "hide", _ctxpopup_hide_cb, wd);
2242 EINA_LIST_FOREACH(wd->items, l, item)
2244 if(item->order <= 0)
2249 icon = create_item_icon(ctxpopup, item, NULL);
2250 evas_object_color_set(icon, 0, 0, 0, 255);
2252 elm_ctxpopup_item_add(ctxpopup, icon, item->text, _ctxpopup_cb, wd);
2256 evas_object_geometry_get(wd->more_item->base, &x, &y, &w, &h);
2257 evas_object_move(ctxpopup, x + w/2, y + h/2);
2259 evas_object_show(ctxpopup);
2262 static Elm_Controlbar_Item *
2263 create_more_item(Widget_Data *wd, int style)
2265 Elm_Controlbar_Item * it;
2267 it = ELM_NEW(Elm_Controlbar_Item);
2270 it->obj = wd->object;
2271 it->text = eina_stringshare_add("more");
2272 it->icon_path = eina_stringshare_add(CONTROLBAR_SYSTEM_ICON_MORE);
2273 it->selected = EINA_FALSE;
2276 it->view = create_more_view(wd);
2277 it->func = create_more_func;
2279 it->base = create_item_layout(wd->edje, it, &(it->base_item), &(it->label), &(it->icon), &(it->icon_shadow), &(it->label_shadow));
2280 evas_object_event_callback_add(it->base, EVAS_CALLBACK_MOUSE_DOWN,
2281 bar_item_down_cb, wd);
2282 evas_object_show(it->base);
2283 // 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));
2284 // evas_object_event_callback_add(it->edit, EVAS_CALLBACK_MOUSE_DOWN,
2285 // edit_item_down_cb, wd);
2286 // evas_object_show(it->edit);
2288 set_items_position(it->obj, it, NULL, EINA_TRUE);
2290 wd->items = eina_list_append(wd->items, it);
2294 // elm_controlbar_item_editable_set(it, EINA_FALSE);
2296 wd->items = eina_list_sort(wd->items, eina_list_count(wd->items), sort_cb);
2301 ///////////////////////////////////////////////////////////////////
2305 ////////////////////////////////////////////////////////////////////
2308 * Add a new controlbar object
2310 * @param parent The parent object
2311 * @return The new object or NULL if it cannot be created
2313 * @ingroup Controlbar
2315 EAPI Evas_Object * elm_controlbar_add(Evas_Object * parent)
2317 Evas_Object * obj = NULL;
2318 Evas_Object * bg = NULL;
2319 Widget_Data * wd = NULL;
2320 Evas_Coord x, y, w, h;
2321 Evas_Object * r_button;
2322 wd = ELM_NEW(Widget_Data);
2323 wd->evas = evas_object_evas_get(parent);
2324 if (wd->evas == NULL)
2326 obj = elm_widget_add(wd->evas);
2329 ELM_SET_WIDTYPE(widtype, "controlbar");
2330 elm_widget_type_set(obj, "controlbar");
2331 elm_widget_sub_object_add(parent, obj);
2332 elm_widget_data_set(obj, wd);
2333 elm_widget_del_hook_set(obj, _del_hook);
2334 elm_widget_theme_hook_set(obj, _theme_hook);
2337 wd->parent = parent;
2338 evas_object_geometry_get(parent, &x, &y, &w, &h);
2344 wd->mode = ELM_CONTROLBAR_MODE_DEFAULT;
2348 wd->vertical = EINA_FALSE;
2349 // wd->edit_mode = EINA_FALSE;
2350 wd->auto_align = EINA_FALSE;
2351 wd->init_animation = EINA_FALSE;
2352 wd->selected_animation = EINA_FALSE;
2353 wd->pressed_signal = eina_stringshare_add("elm,state,pressed");
2354 wd->selected_signal = eina_stringshare_add("elm,state,selected");
2355 wd->view = elm_layout_add(wd->parent); //edje_object_add(wd->evas);
2356 elm_layout_theme_set(wd->view, "controlbar", "view", "default");
2357 //_elm_theme_object_set(obj, wd->view, "controlbar", "view", "default");
2358 if (wd->view == NULL)
2360 printf("Cannot load bg edj\n");
2363 evas_object_show(wd->view);
2366 /* wd->edit_box = edje_object_add(wd->evas);
2367 _elm_theme_object_set(obj, wd->edit_box, "controlbar", "edit_box",
2369 if (wd->edit_box == NULL)
2371 printf("Cannot load bg edj\n");
2374 evas_object_show(wd->edit_box);
2376 // navigationbar will contribution. but not yet
2377 wd->navigation = elm_navigationbar_add(wd->edit_box);
2378 r_button = elm_button_add(wd->navigation);
2379 elm_button_label_set(r_button, "Done");
2380 evas_object_smart_callback_add(r_button, "clicked", done_button_cb, wd);
2381 elm_navigationbar_push(wd->navigation, "Configure", NULL, r_button, NULL, NULL);
2382 edje_object_part_swallow(wd->edit_box, "elm.swallow.navigation", wd->navigation);
2384 wd->edit_table = elm_table_add(wd->edit_box);
2385 elm_table_homogenous_set(wd->edit_table, EINA_TRUE);
2386 edje_object_part_swallow(wd->edit_box, "elm.swallow.table", wd->edit_table);
2389 /* load background edj */
2390 wd->edje = edje_object_add(wd->evas);
2391 _elm_theme_object_set(obj, wd->edje, "controlbar", "base", "default");
2392 if (wd->edje == NULL)
2394 printf("Cannot load base edj\n");
2397 evas_object_show(wd->edje);
2399 wd->bg = edje_object_add(wd->evas);
2400 _elm_theme_object_set(obj, wd->bg, "controlbar", "background", "default");
2403 printf("Cannot load bg edj\n");
2406 edje_object_part_swallow(wd->edje, "bg_image", wd->bg);
2409 evas_object_event_callback_add(wd->edje, EVAS_CALLBACK_RESIZE,
2410 _controlbar_object_resize, obj);
2411 evas_object_event_callback_add(wd->edje, EVAS_CALLBACK_MOVE,
2412 _controlbar_object_move, obj);
2413 evas_object_event_callback_add(wd->edje, EVAS_CALLBACK_SHOW,
2414 _controlbar_object_show, obj);
2415 evas_object_event_callback_add(wd->edje, EVAS_CALLBACK_HIDE,
2416 _controlbar_object_hide, obj);
2417 bg = (Evas_Object *)edje_object_part_object_get(wd->edje, "bg_image");
2418 evas_object_event_callback_add(bg, EVAS_CALLBACK_MOVE, _controlbar_object_move, obj);
2419 evas_object_event_callback_add(bg, EVAS_CALLBACK_RESIZE, _controlbar_object_resize, obj);
2421 wd->selected_box = wd->focused_box = edje_object_add(wd->evas);
2422 _elm_theme_object_set(obj, wd->focused_box, "controlbar", "item_bg_move", "default");
2423 evas_object_hide(wd->focused_box);
2425 wd->focused_box_left = edje_object_add(wd->evas);
2426 _elm_theme_object_set(obj, wd->focused_box_left, "controlbar", "item_bg_move_left", "default");
2427 evas_object_hide(wd->focused_box_left);
2429 wd->focused_box_right = edje_object_add(wd->evas);
2430 _elm_theme_object_set(obj, wd->focused_box_right, "controlbar", "item_bg_move_right", "default");
2431 evas_object_hide(wd->focused_box_right);
2434 wd->box = elm_table_add(wd->edje);
2435 elm_table_homogenous_set(wd->box, EINA_TRUE);
2436 evas_object_size_hint_weight_set(wd->box, EVAS_HINT_EXPAND,
2438 evas_object_size_hint_align_set(wd->box, EVAS_HINT_FILL, EVAS_HINT_FILL);
2439 edje_object_part_swallow(wd->edje, "elm.swallow.items", wd->box);
2440 evas_object_show(wd->box);
2442 wd->event_box = evas_object_rectangle_add(wd->evas);
2443 evas_object_color_set(wd->event_box, 255, 255, 255, 0);
2444 evas_object_repeat_events_set(wd->event_box, EINA_TRUE);
2445 evas_object_show(wd->event_box);
2447 evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
2449 evas_object_smart_member_add(wd->view, obj);
2450 // evas_object_smart_member_add(wd->edit_box, obj);
2451 elm_widget_resize_object_set(obj, wd->edje);
2452 evas_object_smart_member_add(wd->focused_box, obj);
2453 evas_object_smart_member_add(wd->focused_box_left, obj);
2454 evas_object_smart_member_add(wd->focused_box_right, obj);
2455 evas_object_smart_member_add(wd->box, obj);
2456 evas_object_smart_member_add(wd->event_box, obj);
2464 * Append new tab item
2466 * @param obj The controlbar object
2467 * @param icon_path The icon path of item
2468 * @param label The label of item
2469 * @param view The view of item
2470 * @return The item of controlbar
2472 * @ingroup Controlbar
2474 EAPI Elm_Controlbar_Item * elm_controlbar_tab_item_append(Evas_Object * obj,
2481 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2482 Elm_Controlbar_Item * it;
2483 Elm_Controlbar_Item * lit;
2485 it = create_tab_item(obj, icon_path, label, view);
2488 wd = elm_widget_data_get(obj);
2489 if(check_bar_item_number(wd) >= 5 && wd->auto_align){
2490 if(!wd->more_item) {
2491 lit = elm_controlbar_last_item_get(obj);
2492 item_visible_set(lit, EINA_FALSE);
2493 create_more_item(wd, TABBAR);
2495 set_items_position(obj, it, NULL, EINA_FALSE);
2498 set_items_position(obj, it, NULL, EINA_TRUE);
2500 if(wd->init_animation) evas_object_hide(it->base);
2501 wd->items = eina_list_append(wd->items, it);
2503 elm_controlbar_item_view_set(wd->more_item, create_more_view(wd));
2512 * Prepend new tab item
2514 * @param obj The controlbar object
2515 * @param icon_path The icon path of item
2516 * @param label The label of item
2517 * @param view The view of item
2518 * @return The item of controlbar
2520 * @ingroup Controlbar
2522 EAPI Elm_Controlbar_Item * elm_controlbar_tab_item_prepend(Evas_Object *
2531 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2533 Elm_Controlbar_Item * it;
2534 Elm_Controlbar_Item * lit;
2535 Elm_Controlbar_Item * item;
2536 it = create_tab_item(obj, icon_path, label, view);
2539 wd = elm_widget_data_get(obj);
2540 item = eina_list_data_get(wd->items);
2541 if(check_bar_item_number(wd) >= 5 && wd->auto_align){
2542 if(!wd->more_item) {
2543 lit = elm_controlbar_last_item_get(obj);
2544 item_visible_set(lit, EINA_FALSE);
2545 create_more_item(wd, TABBAR);
2547 lit = elm_controlbar_item_prev(wd->more_item);
2548 item_visible_set(lit, EINA_FALSE);
2549 set_items_position(obj, it, item, EINA_TRUE);
2552 set_items_position(obj, it, item, EINA_TRUE);
2554 wd->items = eina_list_prepend(wd->items, it);
2556 elm_controlbar_item_view_set(wd->more_item, create_more_view(wd));
2564 * Insert new tab item before given item
2566 * @param obj The controlbar object
2567 * @param before The given item
2568 * @param icon_path The icon path of item
2569 * @param label The label of item
2570 * @param view The view of item
2571 * @return The item of controlbar
2573 * @ingroup Controlbar
2575 EAPI Elm_Controlbar_Item *
2576 elm_controlbar_tab_item_insert_before(Evas_Object * obj,
2577 Elm_Controlbar_Item * before,
2578 const char *icon_path,
2579 const char *label, Evas_Object * view)
2581 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2583 Elm_Controlbar_Item * it;
2584 Elm_Controlbar_Item * lit;
2587 it = create_tab_item(obj, icon_path, label, view);
2590 wd = elm_widget_data_get(obj);
2591 if(check_bar_item_number(wd) >= 5 && wd->auto_align){
2594 lit = elm_controlbar_last_item_get(obj);
2595 item_visible_set(lit, EINA_FALSE);
2596 create_more_item(wd, TABBAR);
2598 before = wd->more_item;
2599 if(before->order > 0)
2601 lit = elm_controlbar_item_prev(wd->more_item);
2602 item_visible_set(lit, EINA_FALSE);
2603 set_items_position(obj, it, before, EINA_TRUE);
2607 set_items_position(obj, it, before, EINA_FALSE);
2611 set_items_position(obj, it, before, EINA_TRUE);
2613 wd->items = eina_list_prepend_relative(wd->items, it, before);
2615 elm_controlbar_item_view_set(wd->more_item, create_more_view(wd));
2623 * Insert new tab item after given item
2625 * @param obj The controlbar object
2626 * @param after The given item
2627 * @param icon_path The icon path of item
2628 * @param label The label of item
2629 * @param view The view of item
2630 * @return The item of controlbar
2632 * @ingroup Controlbar
2634 EAPI Elm_Controlbar_Item *
2635 elm_controlbar_tab_item_insert_after(Evas_Object * obj,
2636 Elm_Controlbar_Item * after,
2637 const char *icon_path, const char *label,
2640 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2642 Elm_Controlbar_Item * it;
2643 Elm_Controlbar_Item * lit;
2644 Elm_Controlbar_Item * item;
2647 it = create_tab_item(obj, icon_path, label, view);
2650 wd = elm_widget_data_get(obj);
2651 item = elm_controlbar_item_next(after);
2652 if(check_bar_item_number(wd) >= 5 && wd->auto_align){
2655 lit = elm_controlbar_last_item_get(obj);
2656 item_visible_set(lit, EINA_FALSE);
2657 create_more_item(wd, TABBAR);
2659 lit = elm_controlbar_item_prev(wd->more_item);
2660 if(lit != after && item->order > 0)
2662 item_visible_set(lit, EINA_FALSE);
2663 set_items_position(obj, it, item, EINA_TRUE);
2667 set_items_position(obj, it, NULL, EINA_FALSE);
2671 set_items_position(obj, it, item, EINA_TRUE);
2673 wd->items = eina_list_append_relative(wd->items, it, after);
2675 elm_controlbar_item_view_set(wd->more_item, create_more_view(wd));
2683 * Append new tool item
2685 * @param obj The controlbar object
2686 * @param icon_path The icon path of item
2687 * @param label The label of item
2688 * @param func Callback function of item
2689 * @param data The data of callback function
2690 * @return The item of controlbar
2692 * @ingroup Controlbar
2694 EAPI Elm_Controlbar_Item * elm_controlbar_tool_item_append(Evas_Object *
2709 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2710 Elm_Controlbar_Item * it;
2711 Elm_Controlbar_Item * lit;
2713 it = create_tool_item(obj, icon_path, label, func, data);
2716 wd = elm_widget_data_get(obj);
2717 if(check_bar_item_number(wd) >= 5 && wd->auto_align){
2718 if(!wd->more_item) {
2719 lit = elm_controlbar_last_item_get(obj);
2720 item_visible_set(lit, EINA_FALSE);
2721 create_more_item(wd, TOOLBAR);
2723 set_items_position(obj, it, NULL, EINA_FALSE);
2726 set_items_position(obj, it, NULL, EINA_TRUE);
2728 wd->items = eina_list_append(wd->items, it);
2734 * Prepend new tool item
2736 * @param obj The controlbar object
2737 * @param icon_path The icon path of item
2738 * @param label The label of item
2739 * @param func Callback function of item
2740 * @param data The data of callback function
2741 * @return The item of controlbar
2743 * @ingroup Controlbar
2745 EAPI Elm_Controlbar_Item * elm_controlbar_tool_item_prepend(Evas_Object *
2761 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2763 Elm_Controlbar_Item * it;
2764 Elm_Controlbar_Item * lit;
2765 Elm_Controlbar_Item * item;
2766 it = create_tool_item(obj, icon_path, label, func, data);
2769 wd = elm_widget_data_get(obj);
2770 item = eina_list_data_get(wd->items);
2771 if(check_bar_item_number(wd) >= 5 && wd->auto_align){
2772 if(!wd->more_item) {
2773 lit = elm_controlbar_last_item_get(obj);
2774 item_visible_set(lit, EINA_FALSE);
2775 create_more_item(wd, TOOLBAR);
2777 lit = elm_controlbar_item_prev(wd->more_item);
2778 item_visible_set(lit, EINA_FALSE);
2779 set_items_position(obj, it, item, EINA_TRUE);
2782 set_items_position(obj, it, item, EINA_TRUE);
2784 wd->items = eina_list_prepend(wd->items, it);
2790 * Insert new tool item before given item
2792 * @param obj The controlbar object
2793 * @param before The given item
2794 * @param icon_path The icon path of item
2795 * @param label The label of item
2796 * @param func Callback function of item
2797 * @param data The data of callback function
2798 * @return The item of controlbar
2800 * @ingroup Controlbar
2802 EAPI Elm_Controlbar_Item *
2803 elm_controlbar_tool_item_insert_before(Evas_Object * obj,
2804 Elm_Controlbar_Item * before,
2805 const char *icon_path,
2807 void (*func) (void *data,
2812 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2814 Elm_Controlbar_Item * it;
2815 Elm_Controlbar_Item * lit;
2818 it = create_tool_item(obj, icon_path, label, func, data);
2821 wd = elm_widget_data_get(obj);
2822 if(check_bar_item_number(wd) >= 5 && wd->auto_align){
2825 lit = elm_controlbar_last_item_get(obj);
2826 item_visible_set(lit, EINA_FALSE);
2827 create_more_item(wd, TOOLBAR);
2829 before = wd->more_item;
2830 if(before->order > 0)
2832 lit = elm_controlbar_item_prev(wd->more_item);
2833 item_visible_set(lit, EINA_FALSE);
2834 set_items_position(obj, it, before, EINA_TRUE);
2838 set_items_position(obj, it, before, EINA_FALSE);
2842 set_items_position(obj, it, before, EINA_TRUE);
2844 wd->items = eina_list_prepend_relative(wd->items, it, before);
2850 * Insert new tool item after given item
2852 * @param obj The controlbar object
2853 * @param after The given item
2854 * @param icon_path The icon path of item
2855 * @param label The label of item
2856 * @param func Callback function of item
2857 * @param data The data of callback function
2858 * @return The item of controlbar
2860 * @ingroup Controlbar
2862 EAPI Elm_Controlbar_Item *
2863 elm_controlbar_tool_item_insert_after(Evas_Object * obj,
2864 Elm_Controlbar_Item * after,
2865 const char *icon_path,
2867 void (*func) (void *data,
2872 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2874 Elm_Controlbar_Item * it;
2875 Elm_Controlbar_Item * lit;
2876 Elm_Controlbar_Item * item;
2879 it = create_tool_item(obj, icon_path, label, func, data);
2882 wd = elm_widget_data_get(obj);
2883 item = elm_controlbar_item_next(after);
2884 if(check_bar_item_number(wd) >= 5 && wd->auto_align){
2887 lit = elm_controlbar_last_item_get(obj);
2888 item_visible_set(lit, EINA_FALSE);
2889 create_more_item(wd, TOOLBAR);
2891 lit = elm_controlbar_item_prev(wd->more_item);
2892 if(lit != after && item->order > 0)
2894 item_visible_set(lit, EINA_FALSE);
2895 set_items_position(obj, it, item, EINA_TRUE);
2899 set_items_position(obj, it, NULL, EINA_FALSE);
2903 set_items_position(obj, it, item, EINA_TRUE);
2905 wd->items = eina_list_append_relative(wd->items, it, after);
2911 * Append new object item
2913 * @param obj The controlbar object
2914 * @param obj_item The object of item
2915 * @param sel The number of sel occupied
2916 * @return The item of controlbar
2918 * @ingroup Controlbar
2920 EAPI Elm_Controlbar_Item * elm_controlbar_object_item_append(Evas_Object *
2926 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2928 Elm_Controlbar_Item * it;
2929 it = create_object_item(obj, obj_item, sel);
2932 wd = elm_widget_data_get(obj);
2933 set_items_position(obj, it, NULL, EINA_TRUE);
2934 wd->items = eina_list_append(wd->items, it);
2940 * Prepend new object item
2942 * @param obj The controlbar object
2943 * @param obj_item The object of item
2944 * @param sel The number of sel occupied
2945 * @return The item of controlbar
2947 * @ingroup Controlbar
2949 EAPI Elm_Controlbar_Item * elm_controlbar_object_item_prepend(Evas_Object *
2955 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2957 Elm_Controlbar_Item * it;
2958 Elm_Controlbar_Item * item;
2959 it = create_object_item(obj, obj_item, sel);
2962 wd = elm_widget_data_get(obj);
2963 item = eina_list_data_get(wd->items);
2964 set_items_position(obj, it, item, EINA_TRUE);
2965 wd->items = eina_list_prepend(wd->items, it);
2971 * Insert new object item before given item
2973 * @param obj The controlbar object
2974 * @param before The given item
2975 * @param obj_item The object of item
2976 * @param sel The number of sel occupied
2977 * @return The item of controlbar
2979 * @ingroup Controlbar
2981 EAPI Elm_Controlbar_Item *
2982 elm_controlbar_object_item_insert_before(Evas_Object * obj,
2983 Elm_Controlbar_Item * before,
2984 Evas_Object * obj_item, const int sel)
2986 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
2988 Elm_Controlbar_Item * it;
2991 it = create_object_item(obj, obj_item, sel);
2994 wd = elm_widget_data_get(obj);
2995 set_items_position(obj, it, before, EINA_TRUE);
2996 wd->items = eina_list_prepend_relative(wd->items, it, before);
3002 * Insert new object item after given item
3004 * @param obj The controlbar object
3005 * @param after The given item
3006 * @param obj_item The object of item
3007 * @param sel The number of sel occupied
3008 * @return The item of controlbar
3010 * @ingroup Controlbar
3012 EAPI Elm_Controlbar_Item *
3013 elm_controlbar_object_item_insert_after(Evas_Object * obj,
3014 Elm_Controlbar_Item * after,
3015 Evas_Object * obj_item, const int sel)
3017 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3019 Elm_Controlbar_Item * it;
3020 Elm_Controlbar_Item * item;
3023 it = create_object_item(obj, obj_item, sel);
3026 wd = elm_widget_data_get(obj);
3027 item = elm_controlbar_item_next(after);
3028 set_items_position(obj, it, item, EINA_TRUE);
3029 wd->items = eina_list_append_relative(wd->items, it, after);
3035 * Delete item from controlbar
3037 * @param it The item of controlbar
3039 * @ingroup Controlbar
3042 elm_controlbar_item_del(Elm_Controlbar_Item * it)
3048 Elm_Controlbar_Item * item;
3056 if (it->obj == NULL)
3058 printf("Invalid argument: controlbar object is NULL\n");
3061 wd = elm_widget_data_get(it->obj);
3064 printf("Cannot get smart data\n");
3071 elm_table_unpack(wd->box, it->base);
3073 EINA_LIST_FOREACH(wd->items, l, item)
3077 if (item->order > it->order)
3079 elm_table_unpack(wd->box, item->base);
3083 elm_table_pack(wd->box, item->base, item->order - 1, 0, item->sel, 1);
3087 elm_table_pack(wd->box, item->base, 0, item->order - 1, item->sel, 1);
3100 if (it->edit_item != NULL)
3102 elm_table_unpack(wd->edit_table, it->edit);
3103 EINA_LIST_FOREACH(wd->items, l, item)
3107 if (item->edit_item != NULL)
3109 elm_table_unpack(wd->edit_table, item->edit);
3110 elm_table_pack(wd->edit_table, item->edit,
3111 (i - 1) % 4, (i - 1) / 4, 1, 1);
3114 if (it == item && item->style != OBJECT)
3119 if (item->style != OBJECT)
3124 // delete item in list
3126 wd->items = eina_list_remove(wd->items, it);
3129 wd->num = wd->num - 1;
3134 * Select item in controlbar
3136 * @param it The item of controlbar
3138 * @ingroup Controlbar
3141 elm_controlbar_item_select(Elm_Controlbar_Item * it)
3143 if (it == NULL) return;
3144 if (it->obj == NULL) return;
3145 Widget_Data * wd = elm_widget_data_get(it->obj);
3148 // if (!wd->edit_mode)
3155 * Set the icon of item
3157 * @param it The item of controlbar
3158 * @param icon_path The icon path of the item
3159 * @return The icon object
3161 * @ingroup Controlbar
3164 elm_controlbar_item_icon_set(Elm_Controlbar_Item * it, const char *icon_path)
3169 eina_stringshare_del(it->icon_path);
3170 it->icon_path = eina_stringshare_add(icon_path);
3174 evas_object_del(it->icon);
3179 evas_object_del(it->icon_shadow);
3180 it->icon_shadow = NULL;
3182 /* if(it->edit_icon)
3184 evas_object_del(it->edit_icon);
3185 it->edit_icon = NULL;
3187 if(it->edit_icon_shadow)
3189 evas_object_del(it->edit_icon_shadow);
3190 it->edit_icon_shadow = NULL;
3193 it->icon = create_item_icon(it->base_item, it, "elm.swallow.icon");
3194 it->icon_shadow = create_item_icon(it->base_item, it, "elm.swallow.icon_shadow");
3195 // it->edit_icon = create_item_icon(it->edit_item, it, "elm.swallow.icon");
3196 // it->edit_icon_shadow = create_item_icon(it->edit_item, it, "elm.swallow.icon_shadow");
3198 if(it->label && it->icon)
3200 edje_object_signal_emit(_EDJ(it->base_item), "elm,state,icon_text", "elm");
3201 elm_label_line_wrap_set(it->label, EINA_FALSE);
3202 elm_label_wrap_mode_set(it->label, 0);
3203 // elm_label_line_wrap_set(it->label_shadow, EINA_FALSE);
3204 // elm_label_wrap_mode_set(it->label_shadow, 0);
3206 /* if(it->edit_label && it->edit_icon)
3208 edje_object_signal_emit(_EDJ(it->edit_item), "elm,state,icon_text", "elm");
3209 elm_label_line_wrap_set(it->edit_label, EINA_FALSE);
3210 elm_label_wrap_mode_set(it->edit_label, 0);
3211 elm_label_line_wrap_set(it->edit_label_shadow, EINA_FALSE);
3212 elm_label_wrap_mode_set(it->edit_label_shadow, 0);
3217 * Get the icon of item
3219 * @param it The item of controlbar
3220 * @return The icon object
3222 * @ingroup Controlbar
3225 elm_controlbar_item_icon_get(Elm_Controlbar_Item * it)
3231 * Set the label of item
3233 * @param it The item of controlbar
3234 * @param label The label of item
3236 * @ingroup Controlbar
3239 elm_controlbar_item_label_set(Elm_Controlbar_Item * it, const char *label)
3243 it->text = eina_stringshare_add(label);
3244 it->label = create_item_label(it->base_item, it, "elm.swallow.text");
3245 // it->edit_label = create_item_label(it->edit_item, it, "elm.swallow.text");
3247 if(it->label && it->icon){
3248 edje_object_signal_emit(_EDJ(it->base_item), "elm,state,icon_text", "elm");
3249 elm_label_line_wrap_set(it->label, EINA_FALSE);
3250 elm_label_wrap_mode_set(it->label, 0);
3251 // elm_label_line_wrap_set(it->label_shadow, EINA_FALSE);
3252 // elm_label_wrap_mode_set(it->label_shadow, 0);
3254 /* if(it->edit_label && it->edit_icon)
3256 edje_object_signal_emit(_EDJ(it->edit_item), "elm,state,icon_text", "elm");
3257 elm_label_line_wrap_set(it->edit_label, EINA_FALSE);
3258 elm_label_wrap_mode_set(it->edit_label, 0);
3259 elm_label_line_wrap_set(it->edit_label_shadow, EINA_FALSE);
3260 elm_label_wrap_mode_set(it->edit_label_shadow, 0);
3265 * Get the label of item
3267 * @param it The item of controlbar
3268 * @return The label of item
3270 * @ingroup Controlbar
3273 elm_controlbar_item_label_get(Elm_Controlbar_Item * it)
3279 * Get the selected item
3281 * @param obj The controlbar object
3282 * @return The item of controlbar
3284 * @ingroup Controlbar
3286 EAPI Elm_Controlbar_Item * elm_controlbar_selected_item_get(Evas_Object *
3289 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3292 Elm_Controlbar_Item * item;
3295 Widget_Data * wd = elm_widget_data_get(obj);
3296 if (!wd || !wd->items)
3298 EINA_LIST_FOREACH(wd->items, l, item)
3307 * Get the first item
3309 * @param obj The controlbar object
3310 * @return The item of controlbar
3312 * @ingroup Controlbar
3314 EAPI Elm_Controlbar_Item * elm_controlbar_first_item_get(Evas_Object * obj)
3316 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3317 Widget_Data * wd = elm_widget_data_get(obj);
3318 if (!wd || !wd->items)
3320 return eina_list_data_get(wd->items);
3326 * @param obj The controlbar object
3327 * @return The item of controlbar
3329 * @ingroup Controlbar
3331 EAPI Elm_Controlbar_Item * elm_controlbar_last_item_get(Evas_Object * obj)
3333 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3334 Widget_Data * wd = elm_widget_data_get(obj);
3335 if (!wd || !wd->items)
3337 return eina_list_data_get(eina_list_last(wd->items));
3343 * @param obj The controlbar object
3344 * @return The list of the items
3346 * @ingroup Controlbar
3348 EAPI Eina_List * elm_controlbar_items_get(Evas_Object * obj)
3350 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3351 Widget_Data * wd = elm_widget_data_get(obj);
3352 if (!wd || !wd->items)
3358 * Get the previous item
3360 * @param it The item of controlbar
3361 * @return The previous item of the parameter item
3363 * @ingroup Controlbar
3365 EAPI Elm_Controlbar_Item * elm_controlbar_item_prev(Elm_Controlbar_Item *
3370 Elm_Controlbar_Item * item;
3371 if (it->obj == NULL)
3373 Widget_Data * wd = elm_widget_data_get(it->obj);
3374 if (!wd || !wd->items)
3376 EINA_LIST_FOREACH(wd->items, l, item)
3380 l = eina_list_prev(l);
3383 return eina_list_data_get(l);
3392 * @param obj The controlbar object
3393 * @return The next item of the parameter item
3395 * @ingroup Controlbar
3397 EAPI Elm_Controlbar_Item * elm_controlbar_item_next(Elm_Controlbar_Item *
3402 Elm_Controlbar_Item * item;
3403 if (it->obj == NULL)
3405 Widget_Data * wd = elm_widget_data_get(it->obj);
3406 if (!wd || !wd->items)
3408 EINA_LIST_FOREACH(wd->items, l, item)
3412 l = eina_list_next(l);
3415 return eina_list_data_get(l);
3422 elm_controlbar_edit_start(Evas_Object * obj)
3424 printf("\n==================================\n");
3425 printf("%s\n", __func__);
3426 printf("==================================\n");
3427 printf("This API is just for test.\n");
3428 printf("Please don't use it!!\n");
3429 printf("Thank you.\n");
3430 printf("==================================\n");
3432 ELM_CHECK_WIDTYPE(obj, widtype);
3433 Widget_Data *wd = elm_widget_data_get(obj);
3436 fprintf(stderr, "Cannot get smart data\n");
3439 edje_object_signal_emit(wd->edit_box, "elm,state,show,edit_box", "elm");
3440 wd->edit_mode = EINA_TRUE;
3444 * Set the visible status of item in bar
3446 * @param it The item of controlbar
3447 * @param bar EINA_TRUE or EINA_FALSE
3449 * @ingroup Controlbar
3452 elm_controlbar_item_visible_set(Elm_Controlbar_Item * it, Eina_Bool visible)
3455 if (it->obj == NULL)
3457 Widget_Data * wd = elm_widget_data_get(it->obj);
3462 item_visible_set(it, visible);
3466 * Get the result which or not item is visible in bar
3468 * @param it The item of controlbar
3469 * @return EINA_TRUE or EINA_FALSE
3471 * @ingroup Controlbar
3474 elm_controlbar_item_visible_get(Elm_Controlbar_Item * it)
3476 if(!it) return EINA_FALSE;
3478 if (it->obj == NULL)
3480 Widget_Data * wd = elm_widget_data_get(it->obj);
3491 elm_controlbar_item_editable_set(Elm_Controlbar_Item * it, Eina_Bool editable)
3493 Evas_Object * color;
3498 if(it->editable == editable) return;
3500 it->editable = editable;
3505 (Evas_Object *) edje_object_part_object_get(_EDJ(it->edit_item),
3506 "elm.item.uneditable.color");
3508 evas_object_color_get(color, &r, &g, &b, &a);
3509 evas_object_color_set(it->edit_item, r, g, b, a);
3516 * @param it The item of controlbar
3517 * @param bar EINA_TRUE or EINA_FALSE
3519 * @ingroup Controlbar
3522 elm_controlbar_item_disable_set(Elm_Controlbar_Item * it, Eina_Bool disable)
3526 if(it->disable == disable) return;
3528 it->disable = disable;
3532 item_color_set(it, "elm.item.disable.color");
3536 item_color_set(it, "elm.item.default.color");
3541 elm_controlbar_view_set(Evas_Object * obj, Evas_Object * view)
3543 printf("\n==================================\n");
3544 printf("%s\n", __func__);
3545 printf("==================================\n");
3546 printf("This API is just for test.\n");
3547 printf("Please don't use it!!\n");
3548 printf("Thank you.\n");
3549 printf("==================================\n");
3551 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
3552 Widget_Data *wd = elm_widget_data_get(obj);
3555 fprintf(stderr, "Cannot get smart data\n");
3558 wd->view_content = view;
3559 //edje_object_part_swallow(wd->view, "elm.swallow.view", wd->view_content);
3560 elm_layout_content_set(wd->view, "elm.swallow.view", wd->view_content);
3564 * Set the view of the item
3566 * @param it The item of controlbar
3567 * @param view The view for the item
3569 * @ingroup Controlbar
3572 elm_controlbar_item_view_set(Elm_Controlbar_Item *it, Evas_Object * view)
3580 * Get the view of the item
3582 * @param it The item of controlbar
3583 * @return The view for the item
3585 * @ingroup Controlbar
3588 elm_controlbar_item_view_get(Elm_Controlbar_Item *it)
3590 if(!it) return NULL;
3596 * Set the mode of the controlbar
3598 * @param obj The object of the controlbar
3599 * @param mode The mode of the controlbar
3601 * @ingroup Controlbar
3604 elm_controlbar_mode_set(Evas_Object *obj, int mode)
3606 ELM_CHECK_WIDTYPE(obj, widtype);
3607 Widget_Data *wd = elm_widget_data_get(obj);
3610 fprintf(stderr, "Cannot get smart data\n");
3614 if(wd->mode == mode) return;
3620 case ELM_CONTROLBAR_MODE_DEFAULT:
3621 edje_object_signal_emit(wd->edje, "elm,state,default", "elm");
3623 case ELM_CONTROLBAR_MODE_TRANSLUCENCE:
3624 elm_controlbar_alpha_set(obj, 85);
3626 case ELM_CONTROLBAR_MODE_TRANSPARENCY:
3627 elm_controlbar_alpha_set(obj, 0);
3629 case ELM_CONTROLBAR_MODE_LARGE:
3630 edje_object_signal_emit(wd->edje, "elm,state,large", "elm");
3632 case ELM_CONTROLBAR_MODE_SMALL:
3633 edje_object_signal_emit(wd->edje, "elm,state,small", "elm");
3635 case ELM_CONTROLBAR_MODE_LEFT:
3636 wd->selected_box = wd->focused_box_left;
3637 wd->selected_signal = eina_stringshare_add("elm,state,selected_left");
3638 wd->pressed_signal = eina_stringshare_add("elm,state,pressed_left");
3639 edje_object_signal_emit(wd->edje, "elm,state,left", "elm");
3642 case ELM_CONTROLBAR_MODE_RIGHT:
3643 wd->selected_box = wd->focused_box_right;
3644 wd->selected_signal = eina_stringshare_add("elm,state,selected_right");
3645 wd->pressed_signal = eina_stringshare_add("elm,state,pressed_right");
3646 edje_object_signal_emit(wd->edje, "elm,state,right", "elm");
3653 wd->selected_box = wd->focused_box;
3654 wd->selected_signal = eina_stringshare_add("elm,state,selected");
3655 wd->pressed_signal = eina_stringshare_add("elm,state,pressed");
3660 * Set the alpha of the controlbar
3662 * @param obj The object of the controlbar
3663 * @param alpha The alpha value of the controlbar (0-100)
3665 * @ingroup Controlbar
3668 elm_controlbar_alpha_set(Evas_Object *obj, int alpha)
3670 ELM_CHECK_WIDTYPE(obj, widtype);
3672 Widget_Data *wd = elm_widget_data_get(obj);
3675 fprintf(stderr, "Cannot get smart data\n");
3681 else if(alpha > 100)
3686 evas_object_color_get(wd->bg, &r, &g, &b, NULL);
3687 evas_object_color_set(wd->bg, r, g, b, (int)(255 * wd->alpha / 100));
3692 * Set auto-align mode of the controlbar(It's not prepared yet)
3693 * If you set the auto-align and add items more than 5,
3694 * the "more" item will be made and the items more than 5 will be unvisible.
3696 * @param obj The object of the controlbar
3697 * @param auto_align The dicision that the controlbar use the auto-align
3699 * @ingroup Controlbar
3702 elm_controlbar_item_auto_align_set(Evas_Object *obj, Eina_Bool auto_align)
3704 ELM_CHECK_WIDTYPE(obj, widtype);
3705 Widget_Data *wd = elm_widget_data_get(obj);
3706 Elm_Controlbar_Item *item;
3711 fprintf(stderr, "Cannot get smart data\n");
3715 if(wd->auto_align == auto_align) return;
3719 if(check_bar_item_number(wd) >= 5 && !wd->more_item)
3722 EINA_LIST_FOREACH(wd->items, l, item)
3724 if(elm_controlbar_item_visible_get(item))
3727 item_delete_in_bar(item);
3730 item = elm_controlbar_last_item_get(obj);
3731 while(!elm_controlbar_item_visible_get(item)){
3732 item = elm_controlbar_item_prev(item);
3734 create_more_item(wd, item->style);
3742 if(wd->more_item->view)
3743 evas_object_del(wd->more_item->view);
3744 wd->items = eina_list_remove(wd->items, wd->more_item);
3745 eina_stringshare_del(wd->more_item->text);
3746 if (wd->more_item->icon)
3747 evas_object_del(wd->more_item->icon);
3748 if (wd->more_item->base)
3749 evas_object_del(wd->more_item->base);
3750 if (wd->more_item->base_item)
3751 evas_object_del(wd->more_item->base_item);
3752 // if (wd->more_item->edit)
3753 // evas_object_del(wd->more_item->edit);
3754 // if (wd->more_item->edit_item)
3755 // evas_object_del(wd->more_item->edit_item);
3756 free(wd->more_item);
3757 wd->more_item = NULL;
3759 // make all item is visible
3761 EINA_LIST_FOREACH(wd->items, l, item)
3763 if(!elm_controlbar_item_visible_get(item))
3764 item_insert_in_bar(item, i);
3769 wd->auto_align = auto_align;
3774 * Set the vertical mode of the controlbar
3776 * @param obj The object of the controlbar
3777 * @param vertical The vertical mode of the controlbar (TRUE = vertical, FALSE = horizontal)
3779 * @ingroup Controlbar
3782 elm_controlbar_vertical_set(Evas_Object *obj, Eina_Bool vertical)
3784 ELM_CHECK_WIDTYPE(obj, widtype);
3785 Widget_Data *wd = elm_widget_data_get(obj);
3788 fprintf(stderr, "Cannot get smart data\n");
3792 if(wd->vertical == vertical)
3794 wd->vertical = vertical;
3796 if(check_bar_item_number(wd) > 1)
3803 init_animation(void *data)
3806 Elm_Controlbar_Item * item;
3807 Widget_Data * wd = (Widget_Data *)data;
3809 wd->visible_items = eina_list_free(wd->visible_items);
3810 EINA_LIST_FOREACH(wd->items, l, item)
3814 wd->visible_items = eina_list_append(wd->visible_items, item->base);
3819 wd->ani_func(wd->ani_data, wd->object, wd->visible_items);
3821 return ECORE_CALLBACK_CANCEL;
3825 elm_controlbar_animation_set(Evas_Object *obj, void (*func) (void *data, Evas_Object *obj, void *event_info), void *data)
3827 printf("\n==================================\n");
3828 printf("%s\n", __func__);
3829 printf("==================================\n");
3830 printf("This API is just for test.\n");
3831 printf("Please don't use it!!\n");
3832 printf("Thank you.\n");
3833 printf("==================================\n");
3835 ELM_CHECK_WIDTYPE(obj, widtype);
3836 Widget_Data *wd = elm_widget_data_get(obj);
3839 fprintf(stderr, "Cannot get smart data\n");
3845 wd->init_animation = EINA_TRUE;
3847 wd->ani_func = func;
3848 wd->ani_data = data;
3850 ecore_idler_add(init_animation, wd);
3855 elm_controlbar_item_animation_set(Evas_Object *obj, Eina_Bool auto_animation, Eina_Bool selected_animation)
3857 printf("\n==================================\n");
3858 printf("%s\n", __func__);
3859 printf("==================================\n");
3860 printf("This API is just for test.\n");
3861 printf("Please don't use it!!\n");
3862 printf("Thank you.\n");
3863 printf("==================================\n");
3865 ELM_CHECK_WIDTYPE(obj, widtype);
3866 Widget_Data *wd = elm_widget_data_get(obj);
3869 fprintf(stderr, "Cannot get smart data\n");
3873 if(auto_animation && !wd->effect_timer)
3875 wd->effect_timer = ecore_timer_add(1.5, item_animation_effect, wd);
3879 if(wd->effect_timer) ecore_timer_del(wd->effect_timer);
3880 wd->effect_timer = NULL;
3883 wd->selected_animation = selected_animation;
3887 elm_controlbar_view_animation_set(Evas_Object *obj, const char *hide, const char *show)
3889 ELM_CHECK_WIDTYPE(obj, widtype);
3890 Widget_Data *wd = elm_widget_data_get(obj);
3893 fprintf(stderr, "Cannot get smart data\n");
3897 wd->view_hide = eina_stringshare_add(hide);
3898 wd->view_show = eina_stringshare_add(show);