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;
52 Evas_Object * moving_obj;
53 Elm_Controlbar_Item * more_item;
54 Elm_Controlbar_Item * moving_item;
55 Elm_Controlbar_Item * pre_item;
56 Elm_Controlbar_Item * cur_item;
57 Evas_Coord x, y, w, h;
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;
82 struct _Elm_Controlbar_Item
86 Evas_Object * base_item;
88 Evas_Object * edit_item;
92 Evas_Object * edit_label;
93 Evas_Object * edit_icon;
94 const char *icon_path;
96 void (*func) (void *data, Evas_Object * obj, void *event_info);
107 typedef struct _Animation_Data Animation_Data;
109 struct _Animation_Data
120 unsigned int start_time;
122 void (*func) (void *data, Evas_Object * obj);
124 Ecore_Animator * timer;
129 static int check_bar_item_number(Widget_Data *wd);
130 static void selected_box(Elm_Controlbar_Item * it);
131 static int pressed_box(Elm_Controlbar_Item * it);
132 static void object_color_set(Evas_Object *ly, const char *color_part, const char *obj_part);
133 static void edit_item_up_cb(void *data, Evas *evas, Evas_Object *obj, void *event_info);
134 static void edit_item_move_cb(void *data, Evas *evas, Evas_Object *obj, void *event_info);
135 static void bar_item_up_cb(void *data, Evas *evas, Evas_Object *obj, void *event_info);
136 static void bar_item_move_cb(void *data, Evas *evas, Evas_Object *obj, void *event_info);
138 /////////////////////////
140 ////////////////////////
143 print_all_items(Widget_Data *wd)
146 Elm_Controlbar_Item * item;
148 EINA_LIST_FOREACH(wd->items, l, item)
150 printf("item label : %s order : %d address : %p\n", item->text, item->order, item);
154 ///////////////////////////////////////////////////////////////////
156 // Smart Object basic function
158 ////////////////////////////////////////////////////////////////////
161 _controlbar_move(void *data, Evas_Object * obj)
167 wd = elm_widget_data_get((Evas_Object *) data);
170 evas_object_geometry_get(wd->edje, &x, &y, NULL, NULL);
173 evas_object_move(wd->edje, x, y);
174 evas_object_move(wd->view, x, y);
175 evas_object_geometry_get(wd->parent, &x, &y, NULL, NULL);
176 evas_object_move(wd->edit_box, x, y);
177 evas_object_move(wd->event_box, x, y);
181 _controlbar_resize(void *data, Evas_Object * obj)
184 Elm_Controlbar_Item *item;
186 Evas_Coord y, y_, w, h, height;
189 wd = elm_widget_data_get((Evas_Object *) data);
192 evas_object_geometry_get(wd->edje, NULL, &y, &w, &h);
195 evas_object_resize(wd->edje, w, h);
196 evas_object_geometry_get(edje_object_part_object_get(wd->edje, "bg_image"),
197 NULL, NULL, NULL, &height);
198 evas_object_resize(wd->view, w, h - height + 1);
200 evas_object_geometry_get(wd->parent, NULL, &y_, NULL, NULL);
201 //evas_object_resize(wd->edit_box, w, h);
202 evas_object_resize(wd->edit_box, w, h + y - y_);
203 //evas_object_resize(wd->event_box, w, h);
204 evas_object_resize(wd->event_box, w, h + y - y_);
206 EINA_LIST_FOREACH(wd->items, l, item)
209 elm_label_wrap_width_set(item->label, (int)(wd->w/check_bar_item_number(wd))-20);
211 elm_label_wrap_width_set(item->edit_label, (int)(wd->w/check_bar_item_number(wd))-20);
216 _controlbar_object_move(void *data, Evas * e, Evas_Object * obj,
219 _controlbar_move(data, obj);
223 _controlbar_object_resize(void *data, Evas * e, Evas_Object * obj,
226 _controlbar_resize(data, obj);
230 _controlbar_object_show(void *data, Evas * e, Evas_Object * obj,
236 wd = elm_widget_data_get((Evas_Object *) data);
239 evas_object_show(wd->view);
240 evas_object_show(wd->edit_box);
241 evas_object_show(wd->edje);
242 evas_object_show(wd->box);
243 evas_object_show(wd->event_box);
247 _controlbar_object_hide(void *data, Evas * e, Evas_Object * obj,
253 wd = elm_widget_data_get((Evas_Object *) data);
256 evas_object_hide(wd->view);
257 evas_object_hide(wd->edit_box);
258 evas_object_hide(wd->edje);
259 evas_object_hide(wd->box);
260 evas_object_hide(wd->event_box);
264 _del_hook(Evas_Object * obj)
266 Widget_Data * wd = elm_widget_data_get(obj);
267 Elm_Controlbar_Item * item;
268 Evas_Object * content;
272 EINA_LIST_FREE(wd->items, item)
274 if(item == wd->more_item)
276 evas_object_del(item->view);
277 eina_stringshare_del(item->text);
279 evas_object_del(item->icon);
281 evas_object_del(item->base);
283 evas_object_del(item->base_item);
285 evas_object_del(item->edit);
287 evas_object_del(item->edit_item);
293 content = elm_layout_content_unset(wd->view, "elm.swallow.view");
294 evas_object_hide(content);
295 evas_object_del(wd->view);
300 evas_object_del(wd->edit_box);
305 evas_object_del(wd->navigation);
306 wd->navigation = NULL;
310 evas_object_del(wd->bg);
315 evas_object_del(wd->edje);
318 if (wd->selected_box)
320 evas_object_del(wd->selected_box);
325 evas_object_del(wd->box);
330 evas_object_del(wd->event_box);
331 wd->event_box = NULL;
335 elm_xml_animator_del(wd->xa);
338 if (wd->effect_timer)
340 ecore_timer_del(wd->effect_timer);
341 wd->effect_timer = NULL;
349 _theme_hook(Evas_Object * obj)
353 Elm_Controlbar_Item * item;
357 Widget_Data * wd = elm_widget_data_get(obj);
360 _elm_theme_object_set(obj, wd->edje, "controlbar", "base",
361 elm_widget_style_get(obj));
362 _elm_theme_object_set(obj, wd->bg, "controlbar", "background",
363 elm_widget_style_get(obj));
364 evas_object_color_get(wd->bg, &r, &g, &b, NULL);
365 evas_object_color_set(wd->bg, r, g, b, (int)(255 * wd->alpha / 100));
366 elm_layout_theme_set(wd->view, "controlbar", "view", elm_widget_style_get(obj));
367 _elm_theme_object_set(obj, wd->edit_box, "controlbar", "edit_box",
368 elm_widget_style_get(obj));
369 EINA_LIST_FOREACH(wd->items, l, item)
371 if (item->style != OBJECT)
373 elm_layout_theme_set(item->base, "controlbar", "item_bg",
374 elm_widget_style_get(obj));
375 //object_color_set(item->base, "elm.item.default.color", "elm.swallow.icon");
376 elm_layout_theme_set(item->edit, "controlbar", "item_bg",
377 elm_widget_style_get(obj));
382 edje_object_part_object_get(_EDJ(item->edit),
383 "elm.item.uneditable.color");
385 evas_object_color_get(color, &r, &g, &b, &a);
386 evas_object_color_set(item->edit_item, r, g, b, a);
390 //edje_object_part_text_set(_EDJ(item->base), "elm.text",
392 //edje_object_part_text_set(_EDJ(item->edit_item), "elm.text",
395 if (item->label && item->icon)
397 edje_object_signal_emit(_EDJ(item->base_item),
398 "elm,state,icon_text", "elm");
399 edje_object_signal_emit(_EDJ(item->edit_item),
400 "elm,state,icon_text", "elm");
411 _sub_del(void *data, Evas_Object * obj, void *event_info)
413 Widget_Data * wd = elm_widget_data_get(obj);
415 //Evas_Object *sub = event_info;
420 * if (sub == wd->icon)
422 * edje_object_signal_emit(wd->btn, "elm,state,icon,hidden", "elm");
423 * evas_object_event_callback_del_full(sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
424 * _changed_size_hints, obj);
426 * edje_object_message_signal_process(wd->btn);
433 _sizing_eval(Evas_Object * obj)
435 Widget_Data * wd = elm_widget_data_get(obj);
438 _controlbar_move(obj, obj);
439 _controlbar_resize(obj, obj);
442 /////////////////////////////////////////////////////////////
444 // animation function
446 /////////////////////////////////////////////////////////////
451 struct timeval timev;
453 gettimeofday(&timev, NULL);
454 return ((timev.tv_sec * 1000) + ((timev.tv_usec) / 1000));
458 set_evas_map(Evas_Object * obj, Evas_Coord x, Evas_Coord y, Evas_Coord w,
465 Evas_Map * map = evas_map_new(4);
468 evas_map_smooth_set(map, EINA_TRUE);
469 evas_map_util_points_populate_from_object_full(map, obj, 0);
470 evas_object_map_enable_set(obj, EINA_TRUE);
471 evas_map_util_3d_perspective(map, x + w / 2, y + h / 2, 0, w * 10);
472 evas_map_util_points_populate_from_geometry(map, x, y, w, h, 0);
473 evas_object_map_set(obj, map);
478 move_evas_map(void *data)
488 Animation_Data * ad = (Animation_Data *) data;
489 t = ELM_MAX(0.0, current_time_get() - ad->start_time) / 1000;
490 dx = ad->tx - ad->fx;
491 dy = ad->ty - ad->fy;
492 dw = ad->tw - ad->fw;
493 dh = ad->th - ad->fh;
496 x = (1 * sin((t / ad->time) * (M_PI / 2)) * dx);
497 y = (1 * sin((t / ad->time) * (M_PI / 2)) * dy);
498 w = (1 * sin((t / ad->time) * (M_PI / 2)) * dw);
499 h = (1 * sin((t / ad->time) * (M_PI / 2)) * dh);
512 if (x == dx && y == dy && w == dw && h == dh)
514 ecore_animator_del(ad->timer);
516 set_evas_map(ad->obj, px, py, pw, ph);
517 if (ad->func != NULL)
518 ad->func(ad->data, ad->obj);
519 return ECORE_CALLBACK_CANCEL;
523 set_evas_map(ad->obj, px, py, pw, ph);
525 return ECORE_CALLBACK_RENEW;
530 move_evas_object(void *data)
540 Animation_Data * ad = (Animation_Data *) data;
541 t = ELM_MAX(0.0, current_time_get() - ad->start_time) / 1000;
542 dx = ad->tx - ad->fx;
543 dy = ad->ty - ad->fy;
544 dw = ad->tw - ad->fw;
545 dh = ad->th - ad->fh;
548 x = (1 * sin((t / ad->time) * (M_PI / 2)) * dx);
549 y = (1 * sin((t / ad->time) * (M_PI / 2)) * dy);
550 w = (1 * sin((t / ad->time) * (M_PI / 2)) * dw);
551 h = (1 * sin((t / ad->time) * (M_PI / 2)) * dh);
564 if (x == dx && y == dy && w == dw && h == dh)
566 ecore_animator_del(ad->timer);
568 evas_object_move(ad->obj, px, py);
569 evas_object_resize(ad->obj, pw, ph);
570 evas_object_show(ad->obj);
571 if (ad->func != NULL)
572 ad->func(ad->data, ad->obj);
573 return ECORE_CALLBACK_CANCEL;
577 evas_object_move(ad->obj, px, py);
578 evas_object_resize(ad->obj, pw, ph);
579 evas_object_show(ad->obj);
581 return ECORE_CALLBACK_RENEW;
585 move_fade_out_object(void *data)
589 int dx, dy, dw, dh, da;
591 int px, py, pw, ph, pa;
597 Animation_Data * ad = (Animation_Data *) data;
598 t = ELM_MAX(0.0, current_time_get() - ad->start_time) / 1000;
599 dx = ad->tx - ad->fx;
600 dy = ad->ty - ad->fy;
601 dw = ad->tw - ad->fw;
602 dh = ad->th - ad->fh;
606 x = (1 * sin((t / ad->time) * (M_PI / 2)) * dx);
607 y = (1 * sin((t / ad->time) * (M_PI / 2)) * dy);
608 w = (1 * sin((t / ad->time) * (M_PI / 2)) * dw);
609 h = (1 * sin((t / ad->time) * (M_PI / 2)) * dh);
610 a = (1 * sin((t / ad->time) * (M_PI / 2)) * da);
625 if (x == dx && y == dy && w == dw && h == dh)
627 ecore_animator_del(ad->timer);
629 evas_object_move(ad->obj, px, py);
630 //evas_object_resize(ad->obj, 480, 600);
631 evas_object_resize(ad->obj, pw, ph);
632 evas_object_color_get(ad->obj, &r, &g, &b, &a);
633 evas_object_color_set(ad->obj, r, g, b, pa);
634 evas_object_show(ad->obj);
635 if (ad->func != NULL)
636 ad->func(ad->data, ad->obj);
637 return ECORE_CALLBACK_CANCEL;
641 evas_object_move(ad->obj, px, py);
642 //evas_object_resize(ad->obj, 480, 600);
643 evas_object_resize(ad->obj, pw, ph);
644 evas_object_color_get(ad->obj, &r, &g, &b, &a);
645 evas_object_color_set(ad->obj, r, g, b, pa);
646 evas_object_show(ad->obj);
648 return ECORE_CALLBACK_RENEW;
652 move_fade_in_object(void *data)
656 int dx, dy, dw, dh, da;
658 int px, py, pw, ph, pa;
664 Animation_Data * ad = (Animation_Data *) data;
665 t = ELM_MAX(0.0, current_time_get() - ad->start_time) / 1000;
666 dx = ad->tx - ad->fx;
667 dy = ad->ty - ad->fy;
668 dw = ad->tw - ad->fw;
669 dh = ad->th - ad->fh;
673 x = (1 * sin((t / ad->time) * (M_PI / 2)) * dx);
674 y = (1 * sin((t / ad->time) * (M_PI / 2)) * dy);
675 w = (1 * sin((t / ad->time) * (M_PI / 2)) * dw);
676 h = (1 * sin((t / ad->time) * (M_PI / 2)) * dh);
677 a = (1 * sin((t / ad->time) * (M_PI / 2)) * da);
692 if (x == dx && y == dy && w == dw && h == dh)
694 ecore_animator_del(ad->timer);
696 evas_object_move(ad->obj, px, py);
697 //evas_object_resize(ad->obj, 480, 600);
698 evas_object_resize(ad->obj, pw, ph);
699 evas_object_color_get(ad->obj, &r, &g, &b, &a);
700 evas_object_color_set(ad->obj, r, g, b, pa);
701 evas_object_show(ad->obj);
702 if (ad->func != NULL)
703 ad->func(ad->data, ad->obj);
704 return ECORE_CALLBACK_CANCEL;
708 evas_object_move(ad->obj, px, py);
709 //evas_object_resize(ad->obj, 480, 600);
710 evas_object_resize(ad->obj, pw, ph);
711 evas_object_color_get(ad->obj, &r, &g, &b, &a);
712 evas_object_color_set(ad->obj, r, g, b, pa);
713 evas_object_show(ad->obj);
715 return ECORE_CALLBACK_RENEW;
719 move_object_with_animation(Evas_Object * obj, Evas_Coord x, Evas_Coord y,
720 Evas_Coord w, Evas_Coord h, Evas_Coord x_,
721 Evas_Coord y_, Evas_Coord w_, Evas_Coord h_,
722 double time, Eina_Bool (*mv_func) (void *data),
723 void (*func) (void *data,
724 Evas_Object * obj), void *data)
726 Animation_Data * ad = (Animation_Data *) malloc(sizeof(Animation_Data));
736 ad->start_time = current_time_get();
740 ad->timer = ecore_animator_add(mv_func, ad);
744 end_item_animation_effect(void *data, Evas_Object *obj)
746 Widget_Data *wd = (Widget_Data *)data;
747 elm_xml_animator_object_del(wd->xa, obj);
751 item_animation_effect(void *data)
753 Widget_Data *wd = (Widget_Data *)data;
755 Elm_Controlbar_Item * item;
760 wd->xa = elm_xml_animator_add(wd->object);
761 elm_xml_animator_file_set(wd->xa, "/usr/share/xmls/elementary.xml");
766 EINA_LIST_FOREACH(wd->items, l, item)
769 if(rand > 65 && item->order > 0)
775 check = elm_xml_animator_object_add(wd->xa, item->base_item, "test", end_item_animation_effect, wd);
778 elm_xml_animator_object_add(wd->xa, item->base_item, "test2", end_item_animation_effect, wd);
781 elm_xml_animator_object_add(wd->xa, item->base_item, "test3", end_item_animation_effect, wd);
784 elm_xml_animator_object_add(wd->xa, item->base_item, "test4", end_item_animation_effect, wd);
793 elm_xml_animator_run(wd->xa);
795 return ECORE_CALLBACK_RENEW;
798 /////////////////////////////////////////////////////////////
802 /////////////////////////////////////////////////////////////
805 sort_cb(const void *d1, const void *d2)
807 Elm_Controlbar_Item * item1, *item2;
808 item1 = (Elm_Controlbar_Item *) d1;
809 item2 = (Elm_Controlbar_Item *) d2;
810 if (item1->order <= 0)
812 if (item2->order <= 0)
814 return item1->order > item2->order ? 1 : -1;
818 sort_reverse_cb(const void *d1, const void *d2)
820 Elm_Controlbar_Item * item1, *item2;
821 item1 = (Elm_Controlbar_Item *) d1;
822 item2 = (Elm_Controlbar_Item *) d2;
823 if (item1->order <= 0)
825 if (item2->order <= 0)
827 return item1->order > item2->order ? -1 : 1;
831 done_button_cb(void *data, Evas_Object * obj, void *event_info)
833 Widget_Data * wd = (Widget_Data *) data;
835 wd->items = eina_list_sort(wd->items, eina_list_count(wd->items), sort_cb);
837 evas_object_smart_callback_call(wd->object, "edit,end", wd->items);
839 edje_object_signal_emit(wd->edit_box, "elm,state,hide,edit_box", "elm");
840 wd->edit_mode = EINA_FALSE;
843 ///////////////////////////////////////////////////////////////////
845 // basic utility function
847 ////////////////////////////////////////////////////////////////////
850 check_bar_item_number(Widget_Data *wd)
853 Elm_Controlbar_Item * item;
856 EINA_LIST_FOREACH(wd->items, l, item)
858 if(item->order > 0) num++;
865 item_insert_in_bar(Elm_Controlbar_Item * it, int order)
869 Elm_Controlbar_Item * item;
870 Widget_Data * wd = elm_widget_data_get(it->obj);
873 if(order == 0) return;
875 EINA_LIST_FOREACH(wd->items, l, item)
877 if (item->order == order && item != it)
882 EINA_LIST_FOREACH(wd->items, l, item)
885 elm_table_unpack(wd->box, item->base);
887 EINA_LIST_FOREACH(wd->items, l, item)
891 if (item->order >= order)
893 elm_table_pack(wd->box, item->base, item->order - 1, 0, 1, 1);
894 evas_object_show(item->base);
899 elm_table_pack(wd->box, it->base, it->order - 1, 0, 1, 1);
900 evas_object_show(it->base);
904 item_delete_in_bar(Elm_Controlbar_Item * it)
907 Elm_Controlbar_Item * item;
908 Widget_Data * wd = elm_widget_data_get(it->obj);
911 EINA_LIST_FOREACH(wd->items, l, item)
917 elm_table_unpack(wd->box, it->base);
918 evas_object_hide(it->base);
923 EINA_LIST_FOREACH(wd->items, l, item)
928 elm_table_unpack(wd->box, item->base);
929 elm_table_pack(wd->box, item->base, item->order - 1, 0, 1, 1);
936 item_exchange_animation_cb(void *data, Evas_Object * obj)
938 Widget_Data * wd = (Widget_Data *) data;
940 if (wd->animating < 0)
942 printf("animation error\n");
945 evas_object_map_enable_set(obj, EINA_FALSE);
949 item_exchange_in_bar(Elm_Controlbar_Item * it1, Elm_Controlbar_Item * it2)
953 Evas_Coord x, y, w, h;
954 Evas_Coord x_, y_, w_, h_;
955 Widget_Data * wd = elm_widget_data_get(it1->obj);
956 evas_object_geometry_get(wd->moving_item->edit, &x, &y, &w, &h);
957 set_evas_map(wd->moving_obj, (wd->x + wd->w / 2), (wd->y + wd->h / 2), 0,
959 evas_object_geometry_get(it1->base, &x, &y, &w, &h);
960 evas_object_geometry_get(it2->base, &x_, &y_, &w_, &h_);
962 move_object_with_animation(it1->base, x, y, w, h, x_, y_, w_, h_, 0.25,
963 move_evas_map, item_exchange_animation_cb, wd);
965 move_object_with_animation(it2->base, x_, y_, w_, h_, x, y, w, h, 0.25,
966 move_evas_map, item_exchange_animation_cb, wd);
967 elm_table_unpack(wd->box, it1->base);
968 elm_table_unpack(wd->box, it2->base);
970 it1->order = it2->order;
972 elm_table_pack(wd->box, it1->base, it1->order - 1, 0, 1, 1);
973 elm_table_pack(wd->box, it2->base, it2->order - 1, 0, 1, 1);
977 item_change_animation_cb(void *data, Evas_Object * obj)
979 Evas_Coord x, y, w, h;
980 Widget_Data * wd = (Widget_Data *) data;
982 if (wd->animating < 0)
984 printf("animation error\n");
987 evas_object_map_enable_set(obj, EINA_FALSE);
988 evas_object_geometry_get(obj, &x, &y, &w, &h);
989 set_evas_map(obj, x, y, 0, 0);
990 evas_object_move(obj, -1000, -1000);
991 evas_object_geometry_get(wd->moving_item->base, &x, &y, &w, &h);
992 evas_object_move(wd->moving_obj, -1000, -1000);
993 evas_object_del(wd->moving_obj);
997 item_change_in_bar(Elm_Controlbar_Item * it)
999 Evas_Coord x, y, w, h;
1000 Evas_Coord x_, y_, w_, h_;
1001 Widget_Data * wd = elm_widget_data_get(it->obj);
1004 if (wd->moving_item == NULL)
1006 evas_object_geometry_get(wd->moving_item->edit, &x, &y, &w, &h);
1007 set_evas_map(wd->moving_obj, x, y, w, h);
1008 elm_table_unpack(wd->box, it->base);
1009 wd->moving_item->order = it->order;
1011 elm_table_pack(wd->box, wd->moving_item->base, wd->moving_item->order - 1,
1013 evas_object_show(wd->moving_item->base);
1014 evas_render_updates_free(evas_render_updates
1015 (evas_object_evas_get(wd->moving_item->base)));
1016 evas_object_geometry_get(it->base, &x, &y, &w, &h);
1017 evas_object_geometry_get(it->edit, &x_, &y_, &w_, &h_);
1019 move_object_with_animation(it->base, x, y, w, h, x_, y_, w_, h_, 0.25,
1020 move_evas_map, item_change_animation_cb, wd);
1021 evas_object_geometry_get(wd->moving_item->base, &x, &y, &w, &h);
1022 set_evas_map(wd->moving_item->base, x, y, w, h);
1026 hide_selected_box(void *data)
1028 Evas_Object *selected_box = (Evas_Object *)data;
1030 evas_object_hide(selected_box);
1032 return ECORE_CALLBACK_CANCEL;
1036 object_color_set(Evas_Object *ly, const char *color_part, const char *obj_part)
1042 (Evas_Object *) edje_object_part_object_get(_EDJ(ly), color_part);
1044 evas_object_color_get(color, &r, &g, &b, &a);
1046 edje_object_part_swallow_get(_EDJ(ly), obj_part);
1047 evas_object_color_set(color, r, g, b, a);
1051 _end_selected_box(void *data, Evas_Object *obj)
1053 Widget_Data * wd = (Widget_Data *)data;
1056 edje_object_signal_emit(_EDJ(wd->cur_item->base), "elm,state,selected", "elm");
1057 // item animation effect
1058 if(wd->selected_animation)
1066 edje_object_signal_emit(_EDJ(wd->cur_item->base), "elm,animation,pop", "elm");
1069 edje_object_signal_emit(_EDJ(wd->cur_item->base), "elm,animation,vibration", "elm");
1072 edje_object_signal_emit(_EDJ(wd->cur_item->base), "elm,animation,jump", "elm");
1080 if (wd->animating < 0)
1082 printf("animation error\n");
1086 ecore_idler_add(hide_selected_box, wd->selected_box);
1090 move_selected_box(Widget_Data *wd, Elm_Controlbar_Item * fit, Elm_Controlbar_Item * tit)
1092 Evas_Coord fx, fy, fw, fh, tx, ty, tw, th;
1093 Evas_Object *from, *to;
1095 if(fit->order <= 0 && wd->auto_align)
1096 fit = wd->more_item;
1098 from = (Evas_Object *)edje_object_part_object_get(_EDJ(fit->base), "bg_img");
1099 evas_object_geometry_get(from, &fx, &fy, &fw, &fh);
1101 to = (Evas_Object *)edje_object_part_object_get(_EDJ(tit->base), "bg_img");
1102 evas_object_geometry_get(to, &tx, &ty, &tw, &th);
1104 edje_object_signal_emit(_EDJ(wd->pre_item->base), "elm,state,unselected", "elm");
1105 edje_object_signal_emit(_EDJ(wd->cur_item->base), "elm,state,unselected", "elm");
1108 move_object_with_animation(wd->selected_box, fx, fy, fw, fh, tx, ty, tw, th,
1109 0.3, move_evas_object, _end_selected_box, wd);
1113 end_selected_box(void *data, Evas_Object *obj)
1115 Widget_Data * wd = (Widget_Data *)data;
1117 if(wd->pre_item) evas_object_hide(wd->pre_item->view);
1119 elm_layout_content_set(wd->view, "elm.swallow.view", obj);
1121 evas_object_show(obj);
1125 view_animation_push(Widget_Data *wd, Evas_Object *pre, Evas_Object *cur, void *data)
1127 Evas_Coord x, y, w, h;
1129 evas_object_geometry_get(pre, &x, &y, &w, &h);
1130 move_object_with_animation(pre, x, y, w, h, x+20, y, w, h, 0.5, move_fade_out_object, NULL, NULL);
1131 move_object_with_animation(cur, x+120, y, w, h, x, y, w, h, 0.5, move_fade_in_object, end_selected_box, wd);
1135 view_animation_down(Widget_Data *wd, Evas_Object *pre, Evas_Object *cur, void *data)
1137 Evas_Coord x, y, w, h;
1139 evas_object_geometry_get(pre, &x, &y, &w, &h);
1141 move_object_with_animation(cur, x, h, w, h, x, h, w, h, 0.5, move_evas_object, end_selected_box, wd);
1142 evas_object_raise(pre);
1143 move_object_with_animation(pre, x, y, w, h, x, h, w, 0, 0.5, move_evas_map, NULL, NULL);
1147 selected_box(Elm_Controlbar_Item * it)
1149 Widget_Data * wd = elm_widget_data_get(it->obj);
1151 Elm_Controlbar_Item * item, *fit = NULL;
1152 Evas_Object * content;
1154 if(wd->animating) return;
1158 if(it->style == TABBAR){
1160 content = elm_layout_content_unset(wd->view, "elm.swallow.view");
1161 EINA_LIST_FOREACH(wd->items, l, item){
1162 if(item->selected) {
1166 item->selected = EINA_FALSE;
1168 it->selected = EINA_TRUE;
1169 evas_object_smart_callback_call(it->obj, "view,change,before", it);
1170 //object_color_set(it->base, "elm.tabbar.selected.color", "elm.swallow.icon");
1172 if(fit != NULL && fit != it)
1173 move_selected_box(wd, fit, it);
1175 edje_object_signal_emit(_EDJ(it->base), "elm,state,selected", "elm");
1178 if(fit != NULL && fit != it)
1180 //view_animation_down(wd, fit->view, it->view, NULL);
1181 view_animation_push(wd, fit->view, it->view, NULL);
1182 //evas_object_hide(content);
1184 // evas_object_geometry_get(fit->view, &x, &y, &w, &h);
1185 // if(fit->order > it->order)
1187 // move_object_with_animation(fit->view, x, y, w, h, x+20, y, w, h, 0.5, move_fade_out_object, NULL, NULL);
1188 // 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);
1192 // move_object_with_animation(fit->view, x, y, w, h, x-120, y, w, h, 1.5, move_fade_out_object, NULL, NULL);
1193 // 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);
1198 end_selected_box(wd, it->view);
1201 if(wd->pre_item) evas_object_hide(wd->pre_item->view);
1202 elm_layout_content_set(wd->view, "elm.swallow.view", it->view);
1204 // elm_layout_content_set(wd->view, "elm.swallow.view", it->view);
1205 //edje_object_part_swallow(wd->view, "elm.swallow.view", it->view);
1206 // evas_object_show(it->view);
1208 }else if(it->style == TOOLBAR){
1210 it->func(it->data, it->obj, it);
1211 //object_color_set(it->base, "elm.item.default.color", "elm.swallow.icon");
1212 edje_object_signal_emit(_EDJ(it->base), "elm,state,text_unselected", "elm");
1215 evas_object_smart_callback_call(it->obj, "clicked", it);
1219 unpressed_box_cb(void *data, Evas *evas, Evas_Object *obj, void *event_info)
1221 Widget_Data * wd = (Widget_Data *) data;
1223 Evas_Event_Mouse_Up * ev = event_info;
1224 Evas_Coord x, y, w, h;
1225 Elm_Controlbar_Item * item;
1227 evas_object_event_callback_del(wd->event_box, EVAS_CALLBACK_MOUSE_UP, unpressed_box_cb);
1229 EINA_LIST_FOREACH(wd->items, l, item)
1231 if (item->style == TABBAR)
1235 //object_color_set(item->base, "elm.tabbar.selected.color", "elm.swallow.icon");
1236 edje_object_signal_emit(_EDJ(item->base), "elm,state,selected", "elm");
1240 //object_color_set(item->base, "elm.item.default.color", "elm.swallow.icon");
1241 edje_object_signal_emit(_EDJ(item->base), "elm,state,unselected", "elm");
1244 else if (item->style == TOOLBAR)
1246 //object_color_set(item->base, "elm.item.default.color", "elm.swallow.icon");
1247 edje_object_signal_emit(_EDJ(item->base), "elm,state,text_unselected", "elm");
1251 evas_object_geometry_get(wd->pre_item->base, &x, &y, &w, &h);
1252 if(ev->output.x > x && ev->output.x < x+w && ev->output.y > y && ev->output.y < y+h)
1254 selected_box(wd->pre_item);
1261 pressed_box(Elm_Controlbar_Item * it)
1263 Widget_Data * wd = elm_widget_data_get(it->obj);
1266 Elm_Controlbar_Item * item;
1268 if(wd->animating) return EXIT_FAILURE;
1270 if(it->disable) return EXIT_FAILURE;
1272 EINA_LIST_FOREACH(wd->items, l, item)
1276 if (it->style == TABBAR)
1279 //object_color_set(it->base, "elm.tabbar.selected.color", "elm.swallow.icon");
1280 edje_object_signal_emit(_EDJ(it->base), "elm,state,pressed",
1283 else if (it->style == TOOLBAR)
1286 //object_color_set(it->base, "elm.toolbar.pressed.color", "elm.swallow.icon");
1287 edje_object_signal_emit(_EDJ(it->base), "elm,state,text_selected",
1290 evas_object_event_callback_add(wd->event_box, EVAS_CALLBACK_MOUSE_UP, unpressed_box_cb, (void *)wd);
1296 return EXIT_FAILURE;
1300 return EXIT_SUCCESS;
1303 static Evas_Object *
1304 create_item_label(Evas_Object *obj, Elm_Controlbar_Item * it)
1307 label = elm_label_add(obj);
1308 elm_object_style_set(label, "controlbar");
1309 elm_label_label_set(label, it->text);
1310 elm_label_text_align_set(label, "center");
1311 elm_label_text_color_set(label, 255, 255, 255, 255);
1312 elm_label_line_wrap_set(label, EINA_TRUE);
1313 elm_label_ellipsis_set(label, EINA_TRUE);
1314 elm_label_wrap_mode_set(label, 1);
1316 elm_layout_content_set(obj, "elm.text", label);
1321 static Evas_Object *
1322 create_item_icon(Evas_Object *obj, Elm_Controlbar_Item * it)
1325 icon = elm_icon_add(obj);
1326 if(!elm_icon_standard_set(icon, it->icon_path))
1328 elm_icon_file_set(icon, it->icon_path, NULL);
1331 evas_object_size_hint_min_set(icon, 40, 40);
1332 evas_object_size_hint_max_set(icon, 100, 100);
1333 evas_object_show(icon);
1334 edje_object_part_swallow(_EDJ(obj), "elm.swallow.icon", icon);
1339 static Evas_Object *
1340 create_item_layout(Evas_Object * parent, Elm_Controlbar_Item * it, Evas_Object **item, Evas_Object **label, Evas_Object **icon)
1343 obj = elm_layout_add(parent);
1346 fprintf(stderr, "Cannot load bg edj\n");
1349 elm_layout_theme_set(obj, "controlbar", "item_bg",
1350 elm_widget_style_get(it->obj));
1351 evas_object_size_hint_weight_set(obj, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1352 evas_object_size_hint_align_set(obj, EVAS_HINT_FILL, EVAS_HINT_FILL);
1354 *item = elm_layout_add(parent);
1357 fprintf(stderr, "Cannot load bg edj\n");
1360 elm_layout_theme_set(*item, "controlbar", "item",
1361 elm_widget_style_get(it->obj));
1362 elm_layout_content_set(obj, "item", *item);
1366 *label = create_item_label(*item, it);
1370 *icon = create_item_icon(*item, it);
1372 if (*label && *icon)
1374 edje_object_signal_emit(_EDJ(*item), "elm,state,icon_text", "elm");
1375 elm_label_line_wrap_set(*label, EINA_FALSE);
1376 elm_label_wrap_mode_set(*label, 0);
1383 edit_item_down_end_cb(void *data, Evas_Object * obj)
1385 Widget_Data * wd = (Widget_Data *) data;
1387 if (wd->animating < 0)
1389 printf("animation error\n");
1395 edit_item_return_cb(void *data, Evas_Object * obj)
1397 Evas_Coord x, y, w, h;
1398 Widget_Data * wd = (Widget_Data *) data;
1399 evas_object_geometry_get(wd->moving_item->edit, &x, &y, &w, &h);
1400 set_evas_map(obj, x, y, 0, 0);
1402 evas_object_event_callback_del(wd->event_box, EVAS_CALLBACK_MOUSE_UP, edit_item_up_cb);
1403 evas_object_event_callback_del(wd->event_box, EVAS_CALLBACK_MOUSE_MOVE, edit_item_move_cb);
1405 evas_object_data_set(wd->moving_obj, "returning", 0);
1407 if (wd->animating < 0)
1409 printf("animation error\n");
1415 edit_item_move_cb(void *data, Evas *evas, Evas_Object *obj, void *event_info)
1417 Evas_Event_Mouse_Move * ev = event_info;
1419 Elm_Controlbar_Item * item;
1420 Evas_Coord x, y, w, h;
1421 Widget_Data * wd = (Widget_Data *) data;
1424 evas_object_geometry_get(wd->moving_obj, &x, &y, &w, &h);
1427 x = ev->cur.output.x - w / 2;
1428 y = ev->cur.output.y - h;
1429 set_evas_map(wd->moving_obj, x, y, w, h);
1431 EINA_LIST_FOREACH(wd->items, l, item)
1433 if (wd->moving_item->edit == item->edit || item->style == OBJECT)
1435 evas_object_geometry_get(item->base, &x, &y, &w, &h);
1436 if (ev->cur.output.x > x && ev->cur.output.x < x + w && ev->cur.output.y > y && ev->cur.output.y < y + h
1439 edje_object_signal_emit(_EDJ(item->base), "elm,state,show,glow",
1444 edje_object_signal_emit(_EDJ(item->base), "elm,state,hide,glow",
1452 edit_item_up_cb(void *data, Evas *evas, Evas_Object *obj, void *event_info)
1454 Evas_Event_Mouse_Up * ev = event_info;
1455 Evas_Coord x, y, w, h;
1456 Evas_Coord x_, y_, w_, h_;
1458 Elm_Controlbar_Item * item;
1459 Widget_Data * wd = (Widget_Data *) data;
1461 if ((int)evas_object_data_get(wd->moving_obj, "returning") == 1)
1463 evas_object_color_set(wd->moving_item->edit_item, 255, 255, 255, 255);
1465 // check which change or not
1466 EINA_LIST_FOREACH(wd->items, l, item)
1468 if (wd->moving_item->edit == item->edit)
1470 if (item->order <= 0)
1472 evas_object_geometry_get(item->base, &x, &y, &w, &h);
1473 if (ev->output.x > x && ev->output.x < x + w && ev->output.y > y && ev->output.y < y + h
1474 && item->style != OBJECT && item->editable)
1476 edje_object_signal_emit(_EDJ(item->base), "elm,state,hide,glow",
1483 if (wd->moving_item->order > 0)
1485 item_exchange_in_bar(wd->moving_item, item);
1489 item_change_in_bar(item);
1491 evas_object_event_callback_del(wd->event_box, EVAS_CALLBACK_MOUSE_UP, edit_item_up_cb);
1492 evas_object_event_callback_del(wd->event_box, EVAS_CALLBACK_MOUSE_MOVE, edit_item_move_cb);
1497 // return moving object to original location
1498 evas_object_geometry_get(wd->moving_item->edit, &x_, &y_, &w_,
1500 evas_object_geometry_get(wd->moving_obj, &x, &y, &w, &h);
1503 x = ev->output.x - w / 2;
1504 y = ev->output.y - h;
1505 evas_object_data_set(wd->moving_obj, "returning", (void *)1);
1507 move_object_with_animation(wd->moving_obj, x, y, w, h, x_, y_, w_, h_,
1508 0.25, move_evas_map, edit_item_return_cb, wd);
1514 edit_item_down_cb(void *data, Evas * evas, Evas_Object * obj,
1517 Evas_Event_Mouse_Down * ev = event_info;
1518 Evas_Coord x, y, w, h;
1519 Evas_Coord x_, y_, w_, h_;
1520 Widget_Data * wd = (Widget_Data *) data;
1523 Elm_Controlbar_Item * item;
1524 Evas_Object * color;
1529 EINA_LIST_FOREACH(wd->items, l, item)
1531 if (item->edit == obj)
1536 if (!item->editable)
1539 evas_object_event_callback_add(wd->event_box, EVAS_CALLBACK_MOUSE_UP, edit_item_up_cb, (void *)wd);
1540 evas_object_event_callback_add(wd->event_box, EVAS_CALLBACK_MOUSE_MOVE, edit_item_move_cb, (void *)wd);
1542 wd->moving_item = item;
1545 edje_object_part_object_get(_EDJ(wd->moving_item->edit),
1546 "elm.item.uneditable.color");
1548 evas_object_color_get(color, &r, &g, &b, &a);
1549 evas_object_color_set(item->edit_item, r, g, b, a);
1551 evas_object_del(wd->moving_obj);
1552 wd->moving_obj = NULL;
1553 wd->moving_obj = create_item_layout(obj, item, &(item->base_item), &(item->label), &(item->icon));
1554 evas_object_geometry_get(obj, &x, &y, &w, &h);
1555 evas_object_move(wd->moving_obj, -1000, -1000);
1556 evas_object_resize(wd->moving_obj, w, h);
1557 evas_object_show(wd->moving_obj);
1560 x_ = ev->output.x - w_ / 2;
1561 y_ = ev->output.y - h_;
1563 move_object_with_animation(wd->moving_obj, x, y, w, h, x_, y_, w_, h_, 0.1,
1564 move_evas_map, edit_item_down_end_cb, wd);
1568 bar_item_move_end_cb(void *data, Evas_Object * obj)
1570 Widget_Data * wd = (Widget_Data *) data;
1573 Elm_Controlbar_Item * item;
1574 EINA_LIST_FOREACH(wd->items, l, item)
1576 if (item->base == obj)
1580 if (wd->animating < 0)
1582 printf("animation error\n");
1585 evas_object_data_set(obj, "animating", 0);
1586 evas_object_map_enable_set(obj, EINA_FALSE);
1590 bar_item_animation_end_check(void *data)
1594 Elm_Controlbar_Item * item;
1595 Widget_Data * wd = (Widget_Data *) data;
1597 return EXIT_FAILURE;
1598 EINA_LIST_FOREACH(wd->items, l, item)
1600 if (item->base == wd->moving_obj)
1605 printf("item is NULL\n");
1609 item->order = wd->empty_num;
1611 wd->moving_obj = NULL;
1613 evas_object_event_callback_del(wd->event_box, EVAS_CALLBACK_MOUSE_UP, bar_item_up_cb);
1614 evas_object_event_callback_del(wd->event_box, EVAS_CALLBACK_MOUSE_MOVE, bar_item_move_cb);
1615 return ECORE_CALLBACK_CANCEL;
1619 bar_item_move_cb(void *data, Evas *evas, Evas_Object *obj, void *event_info)
1621 Evas_Event_Mouse_Move * ev = event_info;
1623 Elm_Controlbar_Item * item, *it;
1624 Widget_Data * wd = (Widget_Data *) data;
1625 Evas_Coord x, y, w, h, x_, y_, w_, h_;
1628 if (wd->moving_obj == NULL)
1630 printf("%s : moving_obj is NULL\n", __func__);
1633 evas_object_geometry_get(wd->moving_obj, &x, &y, &w, &h);
1634 x = ev->cur.output.x - w / 2;
1635 set_evas_map(wd->moving_obj, x, y, w, h);
1636 EINA_LIST_FOREACH(wd->items, l, item)
1638 if (item->base == wd->moving_obj)
1643 if ((int)evas_object_data_get(item->base, "animating") == 1)
1645 evas_object_geometry_get(item->base, &x, &y, &w, &h);
1646 if (ev->cur.output.x > x && ev->cur.output.x < x + w && item->editable)
1653 evas_object_geometry_get(wd->moving_obj, &x_, &y_, &w_, &h_);
1654 evas_object_move(wd->moving_obj, x, y);
1655 tmp = wd->empty_num;
1656 wd->empty_num = item->order;
1658 elm_table_unpack(wd->box, item->base);
1659 elm_table_unpack(wd->box, wd->moving_obj);
1660 elm_table_pack(wd->box, item->base, item->order - 1, 0, 1, 1);
1661 elm_table_pack(wd->box, wd->moving_obj, wd->empty_num - 1, 0, 1, 1);
1663 evas_object_data_set(item->base, "animating", (void *)1);
1664 move_object_with_animation(item->base, x, y, w, h, x_, y_, w_, h_,
1665 0.25, move_evas_map, bar_item_move_end_cb, wd);
1671 bar_item_up_cb(void *data, Evas *evas, Evas_Object *obj, void *event_info)
1673 Evas_Event_Mouse_Up * ev = event_info;
1674 Evas_Coord tx, x, y, w, h;
1675 Widget_Data * wd = (Widget_Data *) data;
1676 evas_object_geometry_get(wd->moving_obj, &x, &y, &w, &h);
1677 tx = ev->output.x - w / 2;
1679 evas_object_data_set(wd->moving_obj, "animating", (void *)1);
1680 move_object_with_animation(wd->moving_obj, tx, y, w, h, x, y, w, h, 0.25,
1681 move_evas_map, bar_item_move_end_cb, wd);
1682 ecore_timer_add(0.1, bar_item_animation_end_check, wd);
1687 bar_item_down_cb(void *data, Evas * evas, Evas_Object * obj, void *event_info)
1689 Widget_Data * wd = (Widget_Data *) data;
1691 Elm_Controlbar_Item * item;
1694 EINA_LIST_FOREACH(wd->items, l, item)
1696 if (item->base == obj)
1703 if (!item->editable)
1706 wd->moving_obj = obj;
1707 wd->empty_num = item->order;
1708 evas_object_event_callback_add(wd->event_box, EVAS_CALLBACK_MOUSE_UP, bar_item_up_cb, (void *)wd);
1709 evas_object_event_callback_add(wd->event_box, EVAS_CALLBACK_MOUSE_MOVE, bar_item_move_cb, (void *)wd);
1717 static Elm_Controlbar_Item *
1718 create_tab_item(Evas_Object * obj, const char *icon_path, const char *label,
1721 Elm_Controlbar_Item * it;
1725 fprintf(stderr, "Invalid argument: controlbar object is NULL\n");
1728 wd = elm_widget_data_get(obj);
1731 fprintf(stderr, "Cannot get smart data\n");
1734 it = ELM_NEW(Elm_Controlbar_Item);
1738 it->text = eina_stringshare_add(label);
1739 it->icon_path = icon_path;
1740 it->selected = EINA_FALSE;
1741 it->editable = EINA_TRUE;
1746 it->base = create_item_layout(wd->edje, it, &(it->base_item), &(it->label), &(it->icon));
1747 evas_object_event_callback_add(it->base, EVAS_CALLBACK_MOUSE_DOWN,
1748 bar_item_down_cb, wd);
1749 //object_color_set(it->base, "elm.item.default.color", "elm.swallow.icon");
1750 evas_object_show(it->base);
1751 it->edit = create_item_layout(wd->edje, it, &(it->edit_item), &(it->edit_label), &(it->edit_icon));
1752 evas_object_event_callback_add(it->edit, EVAS_CALLBACK_MOUSE_DOWN,
1753 edit_item_down_cb, wd);
1754 evas_object_show(it->edit);
1759 static Elm_Controlbar_Item *
1760 create_tool_item(Evas_Object * obj, const char *icon_path, const char *label,
1761 void (*func) (void *data, Evas_Object * obj,
1762 void *event_info), void *data)
1764 Elm_Controlbar_Item * it;
1768 fprintf(stderr, "Invalid argument: controlbar object is NULL\n");
1771 wd = elm_widget_data_get(obj);
1774 fprintf(stderr, "Cannot get smart data\n");
1777 it = ELM_NEW(Elm_Controlbar_Item);
1781 it->text = eina_stringshare_add(label);
1782 it->icon_path = icon_path;
1783 it->selected = EINA_FALSE;
1784 it->editable = EINA_TRUE;
1789 it->style = TOOLBAR;
1790 it->base = create_item_layout(wd->edje, it, &(it->base_item), &(it->label), &(it->icon));
1791 evas_object_event_callback_add(it->base, EVAS_CALLBACK_MOUSE_DOWN,
1792 bar_item_down_cb, wd);
1793 //edje_object_signal_callback_add(_EDJ(it->base), "elm,action,click", "elm",
1794 // clicked_box_cb, wd);
1795 //object_color_set(it->base, "elm.item.default.color", "elm.swallow.icon");
1796 evas_object_show(it->base);
1797 it->edit = create_item_layout(wd->edje, it, &(it->edit_item), &(it->edit_label), &(it->edit_icon));
1798 evas_object_event_callback_add(it->edit, EVAS_CALLBACK_MOUSE_DOWN,
1799 edit_item_down_cb, wd);
1800 evas_object_show(it->edit);
1804 static Elm_Controlbar_Item *
1805 create_object_item(Evas_Object * obj, Evas_Object * obj_item, const int sel)
1807 Elm_Controlbar_Item * it;
1811 fprintf(stderr, "Invalid argument: controlbar object is NULL\n");
1814 wd = elm_widget_data_get(obj);
1817 fprintf(stderr, "Cannot get smart data\n");
1820 it = ELM_NEW(Elm_Controlbar_Item);
1827 it->base = obj_item;
1832 set_items_position(Evas_Object * obj, Elm_Controlbar_Item * it,
1833 Elm_Controlbar_Item * mit, Eina_Bool bar)
1838 Elm_Controlbar_Item * item;
1841 int check = EINA_FALSE;
1849 fprintf(stderr, "Invalid argument: controlbar object is NULL\n");
1852 wd = elm_widget_data_get(obj);
1855 fprintf(stderr, "Cannot get smart data\n");
1859 EINA_LIST_FOREACH(wd->items, l, item)
1861 if (item == mit && item->order > 0)
1865 it->order = mit->order;
1869 if(item->order > 0){
1870 elm_table_unpack(wd->box, item->base);
1871 item->order += it->sel;
1872 elm_table_pack(wd->box, item->base, item->order - 1, 0, item->sel, 1);
1874 if (item->style != OBJECT && it->style != OBJECT)
1876 elm_table_unpack(wd->edit_table, item->edit);
1877 elm_table_pack(wd->edit_table, item->edit,
1878 i % EDIT_ROW_NUM, i / EDIT_ROW_NUM, 1, 1);
1881 if (item->style != OBJECT)
1883 if(item->order > 0) order += item->sel;
1894 if(bar) elm_table_pack(wd->box, it->base, it->order - 1, 0, it->sel, 1);
1895 else evas_object_hide(it->base);
1896 if (it->style != OBJECT)
1897 elm_table_pack(wd->edit_table, it->edit, (edit - 1) % EDIT_ROW_NUM,
1898 (edit - 1) / EDIT_ROW_NUM, 1, 1);
1902 list_clicked(void *data, Evas_Object *obj, void *event_info)
1904 Elm_Controlbar_Item *item = (Elm_Controlbar_Item *)data;
1905 Elm_Controlbar_Item *it;
1908 Evas_Object *content;
1909 Elm_List_Item *lit = (Elm_List_Item *) elm_list_selected_item_get(obj);
1910 if(lit == NULL) return;
1912 elm_list_item_selected_set(lit, 0);
1916 wd = elm_widget_data_get(item->obj);
1918 EINA_LIST_FOREACH(wd->items, l, it)
1920 it->selected = EINA_FALSE;
1923 if(item->style == TABBAR)
1925 content = elm_layout_content_unset(wd->view, "elm.swallow.view");
1926 evas_object_hide(content);
1927 item->selected = EINA_TRUE;
1928 evas_object_smart_callback_call(item->obj, "view,change,before", item);
1929 elm_layout_content_set(wd->view, "elm.swallow.view", item->view);
1932 if(item->style == TOOLBAR && item->func)
1933 item->func(item->data, item->obj, item);
1936 static Evas_Object *
1937 create_more_view(Widget_Data *wd)
1940 Elm_Controlbar_Item *item;
1943 list = elm_list_add( wd->object );
1944 elm_list_horizontal_mode_set( list, ELM_LIST_COMPRESS );
1946 EINA_LIST_FOREACH(wd->items, l, item)
1948 if(item->order <= 0)
1950 evas_object_color_set(item->icon, 0, 0, 0, 255);
1951 elm_list_item_append(list, item->text, item->icon, NULL, list_clicked, item);
1955 elm_list_go( list );
1960 static Elm_Controlbar_Item *
1961 create_more_item(Widget_Data *wd, int style)
1963 Elm_Controlbar_Item * it;
1965 it = ELM_NEW(Elm_Controlbar_Item);
1968 it->obj = wd->object;
1969 it->text = eina_stringshare_add("more");
1970 it->icon_path = CONTROLBAR_SYSTEM_ICON_MORE;
1971 it->selected = EINA_FALSE;
1974 it->view = create_more_view(wd);
1976 it->base = create_item_layout(wd->edje, it, &(it->base_item), &(it->label), &(it->icon));
1977 evas_object_event_callback_add(it->base, EVAS_CALLBACK_MOUSE_DOWN,
1978 bar_item_down_cb, wd);
1979 //object_color_set(it->base, "elm.item.default.color", "elm.swallow.icon");
1980 evas_object_show(it->base);
1981 it->edit = create_item_layout(wd->edje, it, &(it->edit_item), &(it->edit_label), &(it->edit_icon));
1982 evas_object_event_callback_add(it->edit, EVAS_CALLBACK_MOUSE_DOWN,
1983 edit_item_down_cb, wd);
1984 evas_object_show(it->edit);
1986 set_items_position(it->obj, it, NULL, EINA_TRUE);
1988 wd->items = eina_list_append(wd->items, it);
1992 elm_controlbar_item_editable_set(it, EINA_FALSE);
1994 wd->items = eina_list_sort(wd->items, eina_list_count(wd->items), sort_cb);
1999 ///////////////////////////////////////////////////////////////////
2003 ////////////////////////////////////////////////////////////////////
2006 * Add a new controlbar object
2008 * @param parent The parent object
2009 * @return The new object or NULL if it cannot be created
2011 * @ingroup Controlbar
2013 EAPI Evas_Object * elm_controlbar_add(Evas_Object * parent)
2015 Evas_Object * obj = NULL;
2016 Evas_Object * bg = NULL;
2017 Widget_Data * wd = NULL;
2018 Evas_Coord x, y, w, h;
2019 Evas_Object * r_button;
2020 wd = ELM_NEW(Widget_Data);
2021 wd->evas = evas_object_evas_get(parent);
2022 if (wd->evas == NULL)
2024 obj = elm_widget_add(wd->evas);
2027 elm_widget_type_set(obj, "controlbar");
2028 elm_widget_sub_object_add(parent, obj);
2029 elm_widget_data_set(obj, wd);
2030 elm_widget_del_hook_set(obj, _del_hook);
2031 elm_widget_theme_hook_set(obj, _theme_hook);
2034 wd->parent = parent;
2035 evas_object_geometry_get(parent, &x, &y, &w, &h);
2041 wd->mode = ELM_CONTROLBAR_MODE_DEFAULT;
2045 wd->edit_mode = EINA_FALSE;
2046 wd->auto_align = EINA_FALSE;
2047 wd->init_animation = EINA_FALSE;
2048 wd->selected_animation = EINA_FALSE;
2049 wd->view = elm_layout_add(wd->parent); //edje_object_add(wd->evas);
2050 elm_layout_theme_set(wd->view, "controlbar", "view", "default");
2051 //_elm_theme_object_set(obj, wd->view, "controlbar", "view", "default");
2052 if (wd->view == NULL)
2054 printf("Cannot load bg edj\n");
2057 evas_object_show(wd->view);
2060 wd->edit_box = edje_object_add(wd->evas);
2061 _elm_theme_object_set(obj, wd->edit_box, "controlbar", "edit_box",
2063 if (wd->edit_box == NULL)
2065 printf("Cannot load bg edj\n");
2068 evas_object_show(wd->edit_box);
2070 //instead of navigationbar
2071 /* r_button = elm_button_add(wd->edit_box);
2072 elm_button_label_set(r_button, "Done");
2073 evas_object_smart_callback_add(r_button, "clicked", done_button_cb, wd);
2074 edje_object_part_swallow(wd->edit_box, "elm.swallow.navigation", r_button);
2076 // navigationbar will contribution. but not yet
2077 wd->navigation = elm_navigationbar_add(wd->edit_box);
2078 r_button = elm_button_add(wd->navigation);
2079 elm_button_label_set(r_button, "Done");
2080 evas_object_smart_callback_add(r_button, "clicked", done_button_cb, wd);
2081 elm_navigationbar_push(wd->navigation, "Configure", NULL, r_button, NULL, NULL);
2082 edje_object_part_swallow(wd->edit_box, "elm.swallow.navigation", wd->navigation);
2084 wd->edit_table = elm_table_add(wd->edit_box);
2085 elm_table_homogenous_set(wd->edit_table, EINA_TRUE);
2086 edje_object_part_swallow(wd->edit_box, "elm.swallow.table", wd->edit_table);
2088 /* load background edj */
2089 wd->edje = edje_object_add(wd->evas);
2090 _elm_theme_object_set(obj, wd->edje, "controlbar", "base", "default");
2091 if (wd->edje == NULL)
2093 printf("Cannot load base edj\n");
2096 evas_object_show(wd->edje);
2098 wd->bg = edje_object_add(wd->evas);
2099 _elm_theme_object_set(obj, wd->bg, "controlbar", "background", "default");
2102 printf("Cannot load bg edj\n");
2105 edje_object_part_swallow(wd->edje, "bg_image", wd->bg);
2108 evas_object_event_callback_add(wd->edje, EVAS_CALLBACK_RESIZE,
2109 _controlbar_object_resize, obj);
2110 evas_object_event_callback_add(wd->edje, EVAS_CALLBACK_MOVE,
2111 _controlbar_object_move, obj);
2112 evas_object_event_callback_add(wd->edje, EVAS_CALLBACK_SHOW,
2113 _controlbar_object_show, obj);
2114 evas_object_event_callback_add(wd->edje, EVAS_CALLBACK_HIDE,
2115 _controlbar_object_hide, obj);
2116 bg = (Evas_Object *)edje_object_part_object_get(wd->edje, "bg_image");
2117 evas_object_event_callback_add(bg, EVAS_CALLBACK_MOVE, _controlbar_object_move, obj);
2118 evas_object_event_callback_add(bg, EVAS_CALLBACK_RESIZE, _controlbar_object_resize, obj);
2120 wd->selected_box = edje_object_add(wd->evas);
2121 _elm_theme_object_set(obj, wd->selected_box, "controlbar", "item_bg_move", "default");
2122 //edje_object_part_swallow(wd->edje, "elm.swallow.panel", wd->selected_box);
2123 evas_object_hide(wd->selected_box);
2126 wd->box = elm_table_add(wd->edje);
2127 elm_table_homogenous_set(wd->box, EINA_TRUE);
2128 evas_object_size_hint_weight_set(wd->box, EVAS_HINT_EXPAND,
2130 evas_object_size_hint_align_set(wd->box, EVAS_HINT_FILL, EVAS_HINT_FILL);
2131 edje_object_part_swallow(wd->edje, "elm.swallow.items", wd->box);
2132 evas_object_show(wd->box);
2134 wd->event_box = evas_object_rectangle_add(wd->evas);
2135 evas_object_color_set(wd->event_box, 255, 255, 255, 0);
2136 evas_object_repeat_events_set(wd->event_box, EINA_TRUE);
2137 evas_object_show(wd->event_box);
2140 // evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
2141 evas_object_smart_member_add(wd->view, obj);
2142 evas_object_smart_member_add(wd->edit_box, obj);
2143 elm_widget_resize_object_set(obj, wd->edje);
2144 evas_object_smart_member_add(wd->selected_box, obj);
2145 evas_object_smart_member_add(wd->box, obj);
2146 evas_object_smart_member_add(wd->event_box, obj);
2153 * Append new tab item
2155 * @param obj The controlbar object
2156 * @param icon_path The icon path of item
2157 * @param label The label of item
2158 * @param view The view of item
2159 * @return The item of controlbar
2161 * @ingroup Controlbar
2163 EAPI Elm_Controlbar_Item * elm_controlbar_tab_item_append(Evas_Object * obj,
2170 Elm_Controlbar_Item * it;
2171 Elm_Controlbar_Item * lit;
2173 it = create_tab_item(obj, icon_path, label, view);
2176 wd = elm_widget_data_get(obj);
2177 if(check_bar_item_number(wd) >= 5 && wd->auto_align){
2178 if(!wd->more_item) {
2179 lit = elm_controlbar_last_item_get(obj);
2180 elm_controlbar_item_visible_set(lit, EINA_FALSE);
2181 create_more_item(wd, TABBAR);
2183 set_items_position(obj, it, NULL, EINA_FALSE);
2186 set_items_position(obj, it, NULL, EINA_TRUE);
2188 if(wd->init_animation) evas_object_hide(it->base);
2189 wd->items = eina_list_append(wd->items, it);
2191 elm_controlbar_item_view_set(wd->more_item, create_more_view(wd));
2200 * Prepend new tab item
2202 * @param obj The controlbar object
2203 * @param icon_path The icon path of item
2204 * @param label The label of item
2205 * @param view The view of item
2206 * @return The item of controlbar
2208 * @ingroup Controlbar
2210 EAPI Elm_Controlbar_Item * elm_controlbar_tab_item_prepend(Evas_Object *
2220 Elm_Controlbar_Item * it;
2221 Elm_Controlbar_Item * lit;
2222 Elm_Controlbar_Item * item;
2223 it = create_tab_item(obj, icon_path, label, view);
2226 wd = elm_widget_data_get(obj);
2227 item = eina_list_data_get(wd->items);
2228 if(check_bar_item_number(wd) >= 5 && wd->auto_align){
2229 if(!wd->more_item) {
2230 lit = elm_controlbar_last_item_get(obj);
2231 elm_controlbar_item_visible_set(lit, EINA_FALSE);
2232 create_more_item(wd, TABBAR);
2234 lit = elm_controlbar_item_prev(wd->more_item);
2235 elm_controlbar_item_visible_set(lit, EINA_FALSE);
2236 set_items_position(obj, it, item, EINA_TRUE);
2239 set_items_position(obj, it, item, EINA_TRUE);
2241 wd->items = eina_list_prepend(wd->items, it);
2243 elm_controlbar_item_view_set(wd->more_item, create_more_view(wd));
2251 * Insert new tab item before given item
2253 * @param obj The controlbar object
2254 * @param before The given item
2255 * @param icon_path The icon path of item
2256 * @param label The label of item
2257 * @param view The view of item
2258 * @return The item of controlbar
2260 * @ingroup Controlbar
2262 EAPI Elm_Controlbar_Item *
2263 elm_controlbar_tab_item_insert_before(Evas_Object * obj,
2264 Elm_Controlbar_Item * before,
2265 const char *icon_path,
2266 const char *label, Evas_Object * view)
2269 Elm_Controlbar_Item * it;
2270 Elm_Controlbar_Item * lit;
2273 it = create_tab_item(obj, icon_path, label, view);
2276 wd = elm_widget_data_get(obj);
2277 if(check_bar_item_number(wd) >= 5 && wd->auto_align){
2280 lit = elm_controlbar_last_item_get(obj);
2281 elm_controlbar_item_visible_set(lit, EINA_FALSE);
2282 create_more_item(wd, TABBAR);
2284 if(before->order > 0)
2286 lit = elm_controlbar_item_prev(wd->more_item);
2287 elm_controlbar_item_visible_set(lit, EINA_FALSE);
2288 set_items_position(obj, it, before, EINA_TRUE);
2292 set_items_position(obj, it, before, EINA_FALSE);
2296 set_items_position(obj, it, before, EINA_TRUE);
2298 wd->items = eina_list_prepend_relative(wd->items, it, before);
2300 elm_controlbar_item_view_set(wd->more_item, create_more_view(wd));
2308 * Insert new tab item after given item
2310 * @param obj The controlbar object
2311 * @param after The given item
2312 * @param icon_path The icon path of item
2313 * @param label The label of item
2314 * @param view The view of item
2315 * @return The item of controlbar
2317 * @ingroup Controlbar
2319 EAPI Elm_Controlbar_Item *
2320 elm_controlbar_tab_item_insert_after(Evas_Object * obj,
2321 Elm_Controlbar_Item * after,
2322 const char *icon_path, const char *label,
2326 Elm_Controlbar_Item * it;
2327 Elm_Controlbar_Item * lit;
2328 Elm_Controlbar_Item * item;
2331 it = create_tab_item(obj, icon_path, label, view);
2334 wd = elm_widget_data_get(obj);
2335 item = elm_controlbar_item_next(after);
2336 if(check_bar_item_number(wd) >= 5 && wd->auto_align){
2339 lit = elm_controlbar_last_item_get(obj);
2340 elm_controlbar_item_visible_set(lit, EINA_FALSE);
2341 create_more_item(wd, TABBAR);
2345 lit = elm_controlbar_item_prev(wd->more_item);
2346 elm_controlbar_item_visible_set(lit, EINA_FALSE);
2347 set_items_position(obj, it, item, EINA_TRUE);
2351 set_items_position(obj, it, item, EINA_FALSE);
2355 set_items_position(obj, it, item, EINA_TRUE);
2357 wd->items = eina_list_append_relative(wd->items, it, after);
2359 elm_controlbar_item_view_set(wd->more_item, create_more_view(wd));
2367 * Append new tool item
2369 * @param obj The controlbar object
2370 * @param icon_path The icon path of item
2371 * @param label The label of item
2372 * @param func Callback function of item
2373 * @param data The data of callback function
2374 * @return The item of controlbar
2376 * @ingroup Controlbar
2378 EAPI Elm_Controlbar_Item * elm_controlbar_tool_item_append(Evas_Object *
2393 Elm_Controlbar_Item * it;
2395 it = create_tool_item(obj, icon_path, label, func, data);
2398 wd = elm_widget_data_get(obj);
2399 set_items_position(obj, it, NULL, EINA_TRUE);
2400 wd->items = eina_list_append(wd->items, it);
2406 * Prepend new tool item
2408 * @param obj The controlbar object
2409 * @param icon_path The icon path of item
2410 * @param label The label of item
2411 * @param func Callback function of item
2412 * @param data The data of callback function
2413 * @return The item of controlbar
2415 * @ingroup Controlbar
2417 EAPI Elm_Controlbar_Item * elm_controlbar_tool_item_prepend(Evas_Object *
2434 Elm_Controlbar_Item * it;
2435 Elm_Controlbar_Item * item;
2436 it = create_tool_item(obj, icon_path, label, func, data);
2439 wd = elm_widget_data_get(obj);
2440 item = eina_list_data_get(wd->items);
2441 set_items_position(obj, it, item, EINA_TRUE);
2442 wd->items = eina_list_prepend(wd->items, it);
2448 * Insert new tool item before given item
2450 * @param obj The controlbar object
2451 * @param before The given item
2452 * @param icon_path The icon path of item
2453 * @param label The label of item
2454 * @param func Callback function of item
2455 * @param data The data of callback function
2456 * @return The item of controlbar
2458 * @ingroup Controlbar
2460 EAPI Elm_Controlbar_Item *
2461 elm_controlbar_tool_item_insert_before(Evas_Object * obj,
2462 Elm_Controlbar_Item * before,
2463 const char *icon_path,
2465 void (*func) (void *data,
2471 Elm_Controlbar_Item * it;
2474 it = create_tool_item(obj, icon_path, label, func, data);
2477 wd = elm_widget_data_get(obj);
2478 set_items_position(obj, it, before, EINA_TRUE);
2479 wd->items = eina_list_prepend_relative(wd->items, it, before);
2485 * Insert new tool item after given item
2487 * @param obj The controlbar object
2488 * @param after The given item
2489 * @param icon_path The icon path of item
2490 * @param label The label of item
2491 * @param func Callback function of item
2492 * @param data The data of callback function
2493 * @return The item of controlbar
2495 * @ingroup Controlbar
2497 EAPI Elm_Controlbar_Item *
2498 elm_controlbar_tool_item_insert_after(Evas_Object * obj,
2499 Elm_Controlbar_Item * after,
2500 const char *icon_path,
2502 void (*func) (void *data,
2508 Elm_Controlbar_Item * it;
2509 Elm_Controlbar_Item * item;
2512 it = create_tool_item(obj, icon_path, label, func, data);
2515 wd = elm_widget_data_get(obj);
2516 item = elm_controlbar_item_next(after);
2517 set_items_position(obj, it, item, EINA_TRUE);
2518 wd->items = eina_list_append_relative(wd->items, it, after);
2524 * Append new object item
2526 * @param obj The controlbar object
2527 * @param obj_item The object of item
2528 * @param sel The number of sel occupied
2529 * @return The item of controlbar
2531 * @ingroup Controlbar
2533 EAPI Elm_Controlbar_Item * elm_controlbar_object_item_append(Evas_Object *
2540 Elm_Controlbar_Item * it;
2541 it = create_object_item(obj, obj_item, sel);
2544 wd = elm_widget_data_get(obj);
2545 set_items_position(obj, it, NULL, EINA_TRUE);
2546 wd->items = eina_list_append(wd->items, it);
2552 * Prepend new object item
2554 * @param obj The controlbar object
2555 * @param obj_item The object of item
2556 * @param sel The number of sel occupied
2557 * @return The item of controlbar
2559 * @ingroup Controlbar
2561 EAPI Elm_Controlbar_Item * elm_controlbar_object_item_prepend(Evas_Object *
2568 Elm_Controlbar_Item * it;
2569 Elm_Controlbar_Item * item;
2570 it = create_object_item(obj, obj_item, sel);
2573 wd = elm_widget_data_get(obj);
2574 item = eina_list_data_get(wd->items);
2575 set_items_position(obj, it, item, EINA_TRUE);
2576 wd->items = eina_list_prepend(wd->items, it);
2582 * Insert new object item before given item
2584 * @param obj The controlbar object
2585 * @param before The given item
2586 * @param obj_item The object of item
2587 * @param sel The number of sel occupied
2588 * @return The item of controlbar
2590 * @ingroup Controlbar
2592 EAPI Elm_Controlbar_Item *
2593 elm_controlbar_object_item_insert_before(Evas_Object * obj,
2594 Elm_Controlbar_Item * before,
2595 Evas_Object * obj_item, const int sel)
2598 Elm_Controlbar_Item * it;
2601 it = create_object_item(obj, obj_item, sel);
2604 wd = elm_widget_data_get(obj);
2605 set_items_position(obj, it, before, EINA_TRUE);
2606 wd->items = eina_list_prepend_relative(wd->items, it, before);
2612 * Insert new object item after given item
2614 * @param obj The controlbar object
2615 * @param after The given item
2616 * @param obj_item The object of item
2617 * @param sel The number of sel occupied
2618 * @return The item of controlbar
2620 * @ingroup Controlbar
2622 EAPI Elm_Controlbar_Item *
2623 elm_controlbar_object_item_insert_after(Evas_Object * obj,
2624 Elm_Controlbar_Item * after,
2625 Evas_Object * obj_item, const int sel)
2628 Elm_Controlbar_Item * it;
2629 Elm_Controlbar_Item * item;
2632 it = create_object_item(obj, obj_item, sel);
2635 wd = elm_widget_data_get(obj);
2636 item = elm_controlbar_item_next(after);
2637 set_items_position(obj, it, item, EINA_TRUE);
2638 wd->items = eina_list_append_relative(wd->items, it, after);
2644 * Delete item from controlbar
2646 * @param it The item of controlbar
2648 * @ingroup Controlbar
2651 elm_controlbar_item_del(Elm_Controlbar_Item * it)
2657 Elm_Controlbar_Item * item;
2665 if (it->obj == NULL)
2667 printf("Invalid argument: controlbar object is NULL\n");
2670 wd = elm_widget_data_get(it->obj);
2673 printf("Cannot get smart data\n");
2680 elm_table_unpack(wd->box, it->base);
2682 EINA_LIST_FOREACH(wd->items, l, item)
2686 if (item->order > it->order)
2688 elm_table_unpack(wd->box, item->base);
2690 elm_table_pack(wd->box, item->base, item->order - 1, 0,
2703 if (it->edit_item != NULL)
2705 elm_table_unpack(wd->edit_table, it->edit_item);
2706 EINA_LIST_FOREACH(wd->items, l, item)
2710 if (item->edit_item != NULL)
2712 elm_table_unpack(wd->edit_table, item->edit_item);
2713 elm_table_pack(wd->edit_table, item->edit_item,
2714 (i - 1) % 4, (i - 1) / 4, 1, 1);
2717 if (it == item && item->style != OBJECT)
2722 if (item->style != OBJECT)
2727 // delete item in list
2729 eina_stringshare_del(it->text);
2731 evas_object_del(it->label);
2733 evas_object_del(it->icon);
2736 if (it->style != OBJECT)
2737 evas_object_del(it->base);
2740 evas_object_hide(it->base);
2744 //edje_object_part_unswallow(wd->view, it->view);
2745 if(it->selected) elm_layout_content_unset(wd->view, "elm.swallow.view");
2746 evas_object_hide(it->view);
2749 evas_object_del(it->edit_item);
2750 wd->items = eina_list_remove(wd->items, it);
2751 wd->num = wd->num - 1;
2756 * Select item in controlbar
2758 * @param it The item of controlbar
2760 * @ingroup Controlbar
2763 elm_controlbar_item_select(Elm_Controlbar_Item * it)
2765 if (it->obj == NULL)
2767 Widget_Data * wd = elm_widget_data_get(it->obj);
2777 * Get the icon of item
2779 * @param it The item of controlbar
2780 * @return The icon object
2782 * @ingroup Controlbar
2784 EAPI Evas_Object * elm_controlbar_item_icon_get(Elm_Controlbar_Item * it)
2790 * Get the label of item
2792 * @param it The item of controlbar
2793 * @return The label of item
2795 * @ingroup Controlbar
2798 elm_controlbar_item_label_get(Elm_Controlbar_Item * it)
2804 * Set the label of item
2806 * @param it The item of controlbar
2807 * @param label The label of item
2809 * @ingroup Controlbar
2812 elm_controlbar_item_label_set(Elm_Controlbar_Item * it, const char *label)
2816 it->text = eina_stringshare_add(label);
2817 create_item_label(it->base, it);
2818 create_item_label(it->edit_item, it);
2820 edje_object_signal_emit(_EDJ(it->base),
2821 "elm,state,icon_text", "elm");
2822 elm_label_line_wrap_set(it->label, EINA_FALSE);
2823 elm_label_wrap_mode_set(it->label, 0);
2828 * Get the selected item
2830 * @param obj The controlbar object
2831 * @return The item of controlbar
2833 * @ingroup Controlbar
2835 EAPI Elm_Controlbar_Item * elm_controlbar_selected_item_get(Evas_Object *
2840 Elm_Controlbar_Item * item;
2843 Widget_Data * wd = elm_widget_data_get(obj);
2844 if (!wd || !wd->items)
2846 EINA_LIST_FOREACH(wd->items, l, item)
2855 * Get the first item
2857 * @param obj The controlbar object
2858 * @return The item of controlbar
2860 * @ingroup Controlbar
2862 EAPI Elm_Controlbar_Item * elm_controlbar_first_item_get(Evas_Object * obj)
2866 Widget_Data * wd = elm_widget_data_get(obj);
2867 if (!wd || !wd->items)
2869 return eina_list_data_get(wd->items);
2875 * @param obj The controlbar object
2876 * @return The item of controlbar
2878 * @ingroup Controlbar
2880 EAPI Elm_Controlbar_Item * elm_controlbar_last_item_get(Evas_Object * obj)
2884 Widget_Data * wd = elm_widget_data_get(obj);
2885 if (!wd || !wd->items)
2887 return eina_list_data_get(eina_list_last(wd->items));
2893 * @param obj The controlbar object
2894 * @return The list of the items
2896 * @ingroup Controlbar
2898 EAPI Eina_List * elm_controlbar_items_get(Evas_Object * obj)
2902 Widget_Data * wd = elm_widget_data_get(obj);
2903 if (!wd || !wd->items)
2909 * Get the previous item
2911 * @param it The item of controlbar
2912 * @return The previous item of the parameter item
2914 * @ingroup Controlbar
2916 EAPI Elm_Controlbar_Item * elm_controlbar_item_prev(Elm_Controlbar_Item *
2921 Elm_Controlbar_Item * item;
2922 if (it->obj == NULL)
2924 Widget_Data * wd = elm_widget_data_get(it->obj);
2925 if (!wd || !wd->items)
2927 EINA_LIST_FOREACH(wd->items, l, item)
2931 l = eina_list_prev(l);
2934 return eina_list_data_get(l);
2943 * @param obj The controlbar object
2944 * @return The next item of the parameter item
2946 * @ingroup Controlbar
2948 EAPI Elm_Controlbar_Item * elm_controlbar_item_next(Elm_Controlbar_Item *
2953 Elm_Controlbar_Item * item;
2954 if (it->obj == NULL)
2956 Widget_Data * wd = elm_widget_data_get(it->obj);
2957 if (!wd || !wd->items)
2959 EINA_LIST_FOREACH(wd->items, l, item)
2963 l = eina_list_next(l);
2966 return eina_list_data_get(l);
2973 elm_controlbar_edit_start(Evas_Object * obj)
2975 printf("\n==================================\n");
2976 printf("%s\n", __func__);
2977 printf("==================================\n");
2978 printf("This API is just for test.\n");
2979 printf("Please don't use it!!\n");
2980 printf("Thank you.\n");
2981 printf("==================================\n");
2986 fprintf(stderr, "Invalid argument: controlbar object is NULL\n");
2989 wd = elm_widget_data_get(obj);
2992 fprintf(stderr, "Cannot get smart data\n");
2995 edje_object_signal_emit(wd->edit_box, "elm,state,show,edit_box", "elm");
2996 wd->edit_mode = EINA_TRUE;
3000 * Set the visible status of item in bar
3002 * @param it The item of controlbar
3003 * @param bar true or false
3005 * @ingroup Controlbar
3008 elm_controlbar_item_visible_set(Elm_Controlbar_Item * it, Eina_Bool visible)
3010 Elm_Controlbar_Item *item;
3011 Eina_Bool check = EINA_TRUE;
3014 if (it->obj == NULL)
3016 Widget_Data * wd = elm_widget_data_get(it->obj);
3017 if (!wd || !wd->items)
3021 if (check == visible)
3025 item = elm_controlbar_last_item_get(it->obj);
3026 while(!elm_controlbar_item_visible_get(item)){
3027 item = elm_controlbar_item_prev(item);
3029 item_insert_in_bar(it, item->order + 1);
3033 item_delete_in_bar(it);
3035 wd->items = eina_list_sort(wd->items, eina_list_count(wd->items), sort_cb);
3036 _sizing_eval(it->obj);
3041 * Get the result which or not item is visible in bar
3043 * @param it The item of controlbar
3044 * @return true or false
3046 * @ingroup Controlbar
3049 elm_controlbar_item_visible_get(Elm_Controlbar_Item * it)
3051 if(!it) return EINA_FALSE;
3053 if (it->obj == NULL)
3055 Widget_Data * wd = elm_widget_data_get(it->obj);
3066 elm_controlbar_item_editable_set(Elm_Controlbar_Item * it, Eina_Bool editable)
3068 Evas_Object * color;
3073 if(it->editable == editable) return;
3075 it->editable = editable;
3080 (Evas_Object *) edje_object_part_object_get(_EDJ(it->edit_item),
3081 "elm.item.uneditable.color");
3083 evas_object_color_get(color, &r, &g, &b, &a);
3084 evas_object_color_set(it->edit_item, r, g, b, a);
3091 * @param it The item of controlbar
3092 * @param bar true or false
3094 * @ingroup Controlbar
3097 elm_controlbar_item_disable_set(Elm_Controlbar_Item * it, Eina_Bool disable)
3099 Evas_Object * color;
3104 if(it->disable == disable) return;
3106 it->disable = disable;
3110 (Evas_Object *) edje_object_part_object_get(_EDJ(it->base),
3111 "elm.item.disable.color");
3113 evas_object_color_get(color, &r, &g, &b, &a);
3114 evas_object_color_set(it->base_item, r, g, b, a);
3117 (Evas_Object *) edje_object_part_object_get(_EDJ(it->base),
3118 "elm.item.default.color");
3120 evas_object_color_get(color, &r, &g, &b, &a);
3121 evas_object_color_set(it->base_item, r, g, b, a);
3126 elm_controlbar_view_set(Evas_Object * obj, Evas_Object * view)
3128 printf("\n==================================\n");
3129 printf("%s\n", __func__);
3130 printf("==================================\n");
3131 printf("This API is just for test.\n");
3132 printf("Please don't use it!!\n");
3133 printf("Thank you.\n");
3134 printf("==================================\n");
3139 fprintf(stderr, "Invalid argument: controlbar object is NULL\n");
3142 wd = elm_widget_data_get(obj);
3145 fprintf(stderr, "Cannot get smart data\n");
3148 wd->view_content = view;
3149 //edje_object_part_swallow(wd->view, "elm.swallow.view", wd->view_content);
3150 elm_layout_content_set(wd->view, "elm.swallow.view", wd->view_content);
3154 * Set the view of the item
3156 * @param it The item of controlbar
3157 * @param view The view for the item
3159 * @ingroup Controlbar
3162 elm_controlbar_item_view_set(Elm_Controlbar_Item *it, Evas_Object * view)
3170 * Set the mode of the controlbar
3172 * @param obj The object of the controlbar
3173 * @param mode The mode of the controlbar
3175 * @ingroup Controlbar
3178 elm_controlbar_mode_set(Evas_Object *obj, int mode)
3183 fprintf(stderr, "Invalid argument: controlbar object is NULL\n");
3186 wd = elm_widget_data_get(obj);
3189 fprintf(stderr, "Cannot get smart data\n");
3193 if(wd->mode == mode) return;
3197 case ELM_CONTROLBAR_MODE_DEFAULT:
3198 edje_object_signal_emit(wd->edje, "elm,state,default", "elm");
3200 case ELM_CONTROLBAR_MODE_TRANSLUCENCE:
3201 elm_controlbar_alpha_set(obj, 85);
3202 //edje_object_signal_emit(wd->edje, "elm,state,translucence", "elm");
3204 case ELM_CONTROLBAR_MODE_TRANSPARENCY:
3205 elm_controlbar_alpha_set(obj, 0);
3206 //edje_object_signal_emit(wd->edje, "elm,state,transparency", "elm");
3208 case ELM_CONTROLBAR_MODE_LARGE:
3209 edje_object_signal_emit(wd->edje, "elm,state,large", "elm");
3211 case ELM_CONTROLBAR_MODE_SMALL:
3212 edje_object_signal_emit(wd->edje, "elm,state,small", "elm");
3221 * Set the alpha of the controlbar
3223 * @param obj The object of the controlbar
3224 * @param alpha The mode of the controlbar (0-100)
3226 * @ingroup Controlbar
3229 elm_controlbar_alpha_set(Evas_Object *obj, int alpha)
3235 fprintf(stderr, "Invalid argument: controlbar object is NULL\n");
3238 wd = elm_widget_data_get(obj);
3241 fprintf(stderr, "Cannot get smart data\n");
3247 else if(alpha > 100)
3252 evas_object_color_get(wd->bg, &r, &g, &b, NULL);
3253 evas_object_color_set(wd->bg, r, g, b, (int)(255 * wd->alpha / 100));
3258 * Set auto-align mode of the controlbar(It's not prepared yet)
3259 * If you set the auto-align and add items more than 5,
3260 * the "more" item will be made and the items more than 5 will be unvisible.
3262 * @param obj The object of the controlbar
3263 * @param auto_align The dicision that the controlbar use the auto-align
3265 * @ingroup Controlbar
3268 elm_controlbar_item_auto_align_set(Evas_Object *obj, Eina_Bool auto_align)
3271 Elm_Controlbar_Item *item;
3276 fprintf(stderr, "Invalid argument: controlbar object is NULL\n");
3279 wd = elm_widget_data_get(obj);
3282 fprintf(stderr, "Cannot get smart data\n");
3286 if(wd->auto_align == auto_align) return;
3290 if(check_bar_item_number(wd) >= 5 && !wd->more_item)
3293 EINA_LIST_FOREACH(wd->items, l, item)
3295 if(elm_controlbar_item_visible_get(item))
3298 item_delete_in_bar(item);
3301 item = elm_controlbar_last_item_get(obj);
3302 while(!elm_controlbar_item_visible_get(item)){
3303 item = elm_controlbar_item_prev(item);
3305 create_more_item(wd, item->style);
3313 if(wd->more_item->view)
3314 evas_object_del(wd->more_item->view);
3315 wd->items = eina_list_remove(wd->items, wd->more_item);
3316 eina_stringshare_del(wd->more_item->text);
3317 if (wd->more_item->icon)
3318 evas_object_del(wd->more_item->icon);
3319 if (wd->more_item->base)
3320 evas_object_del(wd->more_item->base);
3321 if (wd->more_item->base_item)
3322 evas_object_del(wd->more_item->base_item);
3323 if (wd->more_item->edit)
3324 evas_object_del(wd->more_item->edit);
3325 if (wd->more_item->edit_item)
3326 evas_object_del(wd->more_item->edit_item);
3327 free(wd->more_item);
3328 wd->more_item = NULL;
3330 // make all item is visible
3332 EINA_LIST_FOREACH(wd->items, l, item)
3334 if(!elm_controlbar_item_visible_get(item))
3335 item_insert_in_bar(item, i);
3340 wd->auto_align = auto_align;
3345 init_animation(void *data)
3348 Elm_Controlbar_Item * item;
3349 Widget_Data * wd = (Widget_Data *)data;
3351 wd->visible_items = eina_list_free(wd->visible_items);
3352 EINA_LIST_FOREACH(wd->items, l, item)
3356 wd->visible_items = eina_list_append(wd->visible_items, item->base);
3361 wd->ani_func(wd->ani_data, wd->object, wd->visible_items);
3363 return ECORE_CALLBACK_CANCEL;
3367 elm_controlbar_animation_set(Evas_Object *obj, void (*func) (void *data, Evas_Object *obj, void *event_info), void *data)
3369 printf("\n==================================\n");
3370 printf("%s\n", __func__);
3371 printf("==================================\n");
3372 printf("This API is just for test.\n");
3373 printf("Please don't use it!!\n");
3374 printf("Thank you.\n");
3375 printf("==================================\n");
3380 fprintf(stderr, "Invalid argument: controlbar object is NULL\n");
3383 wd = elm_widget_data_get(obj);
3386 fprintf(stderr, "Cannot get smart data\n");
3392 wd->init_animation = EINA_TRUE;
3394 wd->ani_func = func;
3395 wd->ani_data = data;
3397 ecore_idler_add(init_animation, wd);
3402 elm_controlbar_item_animation_set(Evas_Object *obj, Eina_Bool auto_animation, Eina_Bool selected_animation)
3404 printf("\n==================================\n");
3405 printf("%s\n", __func__);
3406 printf("==================================\n");
3407 printf("This API is just for test.\n");
3408 printf("Please don't use it!!\n");
3409 printf("Thank you.\n");
3410 printf("==================================\n");
3415 fprintf(stderr, "Invalid argument: controlbar object is NULL\n");
3418 wd = elm_widget_data_get(obj);
3421 fprintf(stderr, "Cannot get smart data\n");
3425 if(auto_animation && !wd->effect_timer)
3427 wd->effect_timer = ecore_timer_add(1.5, item_animation_effect, wd);
3431 if(wd->effect_timer) ecore_timer_del(wd->effect_timer);
3432 wd->effect_timer = NULL;
3435 wd->selected_animation = selected_animation;