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;
48 Evas_Object * event_box;
49 Evas_Object * selected_box;
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;
63 Eina_List * visible_items;
65 Ecore_Event_Handler * move_event;
66 Ecore_Event_Handler * up_event;
67 Ecore_Event_Handler * bar_move_event;
68 Ecore_Event_Handler * bar_up_event;
70 void (*ani_func) (void *data, Evas_Object * obj, void *event_info);
72 Eina_Bool init_animation;
74 Ecore_Timer *effect_timer;
75 Eina_Bool selected_animation;
78 struct _Elm_Controlbar_Item
82 Evas_Object * edit_item;
85 const char *icon_path;
87 void (*func) (void *data, Evas_Object * obj, void *event_info);
97 typedef struct _Animation_Data Animation_Data;
99 struct _Animation_Data
110 unsigned int start_time;
112 void (*func) (void *data, Evas_Object * obj);
114 Ecore_Animator * timer;
119 static void selected_box(Elm_Controlbar_Item * it);
120 static int pressed_box(Elm_Controlbar_Item * it);
121 static void object_color_set(Evas_Object *ly, const char *color_part, const char *obj_part);
122 static void edit_item_up_cb(void *data, Evas *evas, Evas_Object *obj, void *event_info);
123 static void edit_item_move_cb(void *data, Evas *evas, Evas_Object *obj, void *event_info);
124 static void bar_item_up_cb(void *data, Evas *evas, Evas_Object *obj, void *event_info);
125 static void bar_item_move_cb(void *data, Evas *evas, Evas_Object *obj, void *event_info);
127 /////////////////////////
129 ////////////////////////
132 print_all_items(Widget_Data *wd)
135 Elm_Controlbar_Item * item;
137 EINA_LIST_FOREACH(wd->items, l, item)
139 printf("item label : %s order : %d address : %p\n", item->label, item->order, item);
143 ///////////////////////////////////////////////////////////////////
145 // Smart Object basic function
147 ////////////////////////////////////////////////////////////////////
150 _controlbar_move(void *data, Evas_Object * obj)
156 wd = elm_widget_data_get((Evas_Object *) data);
159 evas_object_geometry_get(wd->edje, &x, &y, NULL, NULL);
162 evas_object_move(wd->edje, x, y);
163 evas_object_move(wd->view, x, y);
164 evas_object_geometry_get(wd->parent, &x, &y, NULL, NULL);
165 evas_object_move(wd->edit_box, x, y);
166 evas_object_move(wd->event_box, x, y);
170 _controlbar_resize(void *data, Evas_Object * obj)
173 Evas_Coord y, y_, w, h, height;
176 wd = elm_widget_data_get((Evas_Object *) data);
179 evas_object_geometry_get(wd->edje, NULL, &y, &w, &h);
182 evas_object_resize(wd->edje, w, h);
183 evas_object_geometry_get(edje_object_part_object_get(wd->edje, "bg_image"),
184 NULL, NULL, NULL, &height);
185 evas_object_resize(wd->view, w, h - height + 1);
187 evas_object_geometry_get(wd->parent, NULL, &y_, NULL, NULL);
188 //evas_object_resize(wd->edit_box, w, h);
189 evas_object_resize(wd->edit_box, w, h + y - y_);
190 //evas_object_resize(wd->event_box, w, h);
191 evas_object_resize(wd->event_box, w, h + y - y_);
195 _controlbar_object_move(void *data, Evas * e, Evas_Object * obj,
198 _controlbar_move(data, obj);
202 _controlbar_object_resize(void *data, Evas * e, Evas_Object * obj,
205 _controlbar_resize(data, obj);
209 _controlbar_object_show(void *data, Evas * e, Evas_Object * obj,
215 wd = elm_widget_data_get((Evas_Object *) data);
218 evas_object_show(wd->view);
219 evas_object_show(wd->edit_box);
220 evas_object_show(wd->edje);
221 evas_object_show(wd->box);
222 evas_object_show(wd->event_box);
226 _controlbar_object_hide(void *data, Evas * e, Evas_Object * obj,
232 wd = elm_widget_data_get((Evas_Object *) data);
235 evas_object_hide(wd->view);
236 evas_object_hide(wd->edit_box);
237 evas_object_hide(wd->edje);
238 evas_object_hide(wd->box);
239 evas_object_hide(wd->event_box);
243 _del_hook(Evas_Object * obj)
245 Widget_Data * wd = elm_widget_data_get(obj);
246 Elm_Controlbar_Item * item;
247 Evas_Object * content;
251 EINA_LIST_FREE(wd->items, item)
253 if(item == wd->more_item)
255 evas_object_del(item->view);
256 eina_stringshare_del(item->label);
258 evas_object_del(item->icon);
260 evas_object_del(item->base);
262 evas_object_del(item->edit_item);
268 content = elm_layout_content_unset(wd->view, "elm.swallow.view");
269 evas_object_hide(content);
270 evas_object_del(wd->view);
275 evas_object_del(wd->edit_box);
280 evas_object_del(wd->navigation);
281 wd->navigation = NULL;
285 evas_object_del(wd->edje);
288 if (wd->selected_box)
290 evas_object_del(wd->selected_box);
295 evas_object_del(wd->box);
300 evas_object_del(wd->event_box);
301 wd->event_box = NULL;
303 if (wd->effect_timer)
305 ecore_timer_del(wd->effect_timer);
306 wd->effect_timer = NULL;
314 _theme_hook(Evas_Object * obj)
318 Elm_Controlbar_Item * item;
322 Widget_Data * wd = elm_widget_data_get(obj);
325 _elm_theme_object_set(obj, wd->edje, "controlbar", "base",
326 elm_widget_style_get(obj));
327 elm_layout_theme_set(wd->view, "controlbar", "view", elm_widget_style_get(obj));
328 //_elm_theme_object_set(obj, wd->view, "controlbar", "view",
329 // elm_widget_style_get(obj));
330 _elm_theme_object_set(obj, wd->edit_box, "controlbar", "edit_box",
331 elm_widget_style_get(obj));
332 EINA_LIST_FOREACH(wd->items, l, item)
334 if (item->style != OBJECT)
336 elm_layout_theme_set(item->base, "controlbar", "item",
337 elm_widget_style_get(obj));
338 object_color_set(item->base, "elm.tabbar.default.color", "elm.swallow.icon");
339 elm_layout_theme_set(item->edit_item, "controlbar", "item",
340 elm_widget_style_get(obj));
345 edje_object_part_object_get(_EDJ(item->edit_item),
346 "elm.edit.item.color");
348 evas_object_color_get(color, &r, &g, &b, &a);
349 evas_object_color_set(item->edit_item, r, g, b, a);
353 edje_object_part_text_set(_EDJ(item->base), "elm.text",
355 edje_object_part_text_set(_EDJ(item->edit_item), "elm.text",
358 if (item->label && item->icon)
360 edje_object_signal_emit(_EDJ(item->base),
361 "elm,state,icon_text", "elm");
362 edje_object_signal_emit(_EDJ(item->edit_item),
363 "elm,state,icon_text", "elm");
374 _sub_del(void *data, Evas_Object * obj, void *event_info)
376 Widget_Data * wd = elm_widget_data_get(obj);
378 //Evas_Object *sub = event_info;
383 * if (sub == wd->icon)
385 * edje_object_signal_emit(wd->btn, "elm,state,icon,hidden", "elm");
386 * evas_object_event_callback_del_full(sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
387 * _changed_size_hints, obj);
389 * edje_object_message_signal_process(wd->btn);
396 _sizing_eval(Evas_Object * obj)
398 Widget_Data * wd = elm_widget_data_get(obj);
401 _controlbar_move(obj, obj);
402 _controlbar_resize(obj, obj);
405 /////////////////////////////////////////////////////////////
407 // animation function
409 /////////////////////////////////////////////////////////////
414 struct timeval timev;
416 gettimeofday(&timev, NULL);
417 return ((timev.tv_sec * 1000) + ((timev.tv_usec) / 1000));
421 set_evas_map(Evas_Object * obj, Evas_Coord x, Evas_Coord y, Evas_Coord w,
428 Evas_Map * map = evas_map_new(4);
431 evas_map_smooth_set(map, EINA_TRUE);
432 evas_map_util_points_populate_from_object_full(map, obj, 0);
433 evas_object_map_enable_set(obj, EINA_TRUE);
434 evas_map_util_3d_perspective(map, x + w / 2, y + h / 2, 0, w * 10);
435 evas_map_util_points_populate_from_geometry(map, x, y, w, h, 0);
436 evas_object_map_set(obj, map);
441 move_evas_map(void *data)
451 Animation_Data * ad = (Animation_Data *) data;
452 t = ELM_MAX(0.0, current_time_get() - ad->start_time) / 1000;
453 dx = ad->tx - ad->fx;
454 dy = ad->ty - ad->fy;
455 dw = ad->tw - ad->fw;
456 dh = ad->th - ad->fh;
459 x = (1 * sin((t / ad->time) * (M_PI / 2)) * dx);
460 y = (1 * sin((t / ad->time) * (M_PI / 2)) * dy);
461 w = (1 * sin((t / ad->time) * (M_PI / 2)) * dw);
462 h = (1 * sin((t / ad->time) * (M_PI / 2)) * dh);
475 if (x == dx && y == dy && w == dw && h == dh)
477 ecore_animator_del(ad->timer);
479 set_evas_map(ad->obj, px, py, pw, ph);
480 if (ad->func != NULL)
481 ad->func(ad->data, ad->obj);
485 set_evas_map(ad->obj, px, py, pw, ph);
492 move_evas_object(void *data)
502 Animation_Data * ad = (Animation_Data *) data;
503 t = ELM_MAX(0.0, current_time_get() - ad->start_time) / 1000;
504 dx = ad->tx - ad->fx;
505 dy = ad->ty - ad->fy;
506 dw = ad->tw - ad->fw;
507 dh = ad->th - ad->fh;
510 x = (1 * sin((t / ad->time) * (M_PI / 2)) * dx);
511 y = (1 * sin((t / ad->time) * (M_PI / 2)) * dy);
512 w = (1 * sin((t / ad->time) * (M_PI / 2)) * dw);
513 h = (1 * sin((t / ad->time) * (M_PI / 2)) * dh);
526 if (x == dx && y == dy && w == dw && h == dh)
528 ecore_animator_del(ad->timer);
530 evas_object_move(ad->obj, px, py);
531 evas_object_resize(ad->obj, pw, ph);
532 evas_object_show(ad->obj);
533 if (ad->func != NULL)
534 ad->func(ad->data, ad->obj);
538 evas_object_move(ad->obj, px, py);
539 evas_object_resize(ad->obj, pw, ph);
540 evas_object_show(ad->obj);
546 move_fade_out_object(void *data)
550 int dx, dy, dw, dh, da;
552 int px, py, pw, ph, pa;
558 Animation_Data * ad = (Animation_Data *) data;
559 t = ELM_MAX(0.0, current_time_get() - ad->start_time) / 1000;
560 dx = ad->tx - ad->fx;
561 dy = ad->ty - ad->fy;
562 dw = ad->tw - ad->fw;
563 dh = ad->th - ad->fh;
567 x = (1 * sin((t / ad->time) * (M_PI / 2)) * dx);
568 y = (1 * sin((t / ad->time) * (M_PI / 2)) * dy);
569 w = (1 * sin((t / ad->time) * (M_PI / 2)) * dw);
570 h = (1 * sin((t / ad->time) * (M_PI / 2)) * dh);
571 a = (1 * sin((t / ad->time) * (M_PI / 2)) * da);
586 if (x == dx && y == dy && w == dw && h == dh)
588 ecore_animator_del(ad->timer);
590 evas_object_move(ad->obj, px, py);
591 //evas_object_resize(ad->obj, 480, 600);
592 evas_object_resize(ad->obj, pw, ph);
593 evas_object_color_get(ad->obj, &r, &g, &b, &a);
594 evas_object_color_set(ad->obj, r, g, b, pa);
595 evas_object_show(ad->obj);
596 if (ad->func != NULL)
597 ad->func(ad->data, ad->obj);
601 evas_object_move(ad->obj, px, py);
602 //evas_object_resize(ad->obj, 480, 600);
603 evas_object_resize(ad->obj, pw, ph);
604 evas_object_color_get(ad->obj, &r, &g, &b, &a);
605 evas_object_color_set(ad->obj, r, g, b, pa);
606 evas_object_show(ad->obj);
612 move_fade_in_object(void *data)
616 int dx, dy, dw, dh, da;
618 int px, py, pw, ph, pa;
624 Animation_Data * ad = (Animation_Data *) data;
625 t = ELM_MAX(0.0, current_time_get() - ad->start_time) / 1000;
626 dx = ad->tx - ad->fx;
627 dy = ad->ty - ad->fy;
628 dw = ad->tw - ad->fw;
629 dh = ad->th - ad->fh;
633 x = (1 * sin((t / ad->time) * (M_PI / 2)) * dx);
634 y = (1 * sin((t / ad->time) * (M_PI / 2)) * dy);
635 w = (1 * sin((t / ad->time) * (M_PI / 2)) * dw);
636 h = (1 * sin((t / ad->time) * (M_PI / 2)) * dh);
637 a = (1 * sin((t / ad->time) * (M_PI / 2)) * da);
652 if (x == dx && y == dy && w == dw && h == dh)
654 ecore_animator_del(ad->timer);
656 evas_object_move(ad->obj, px, py);
657 //evas_object_resize(ad->obj, 480, 600);
658 evas_object_resize(ad->obj, pw, ph);
659 evas_object_color_get(ad->obj, &r, &g, &b, &a);
660 evas_object_color_set(ad->obj, r, g, b, pa);
661 evas_object_show(ad->obj);
662 if (ad->func != NULL)
663 ad->func(ad->data, ad->obj);
667 evas_object_move(ad->obj, px, py);
668 //evas_object_resize(ad->obj, 480, 600);
669 evas_object_resize(ad->obj, pw, ph);
670 evas_object_color_get(ad->obj, &r, &g, &b, &a);
671 evas_object_color_set(ad->obj, r, g, b, pa);
672 evas_object_show(ad->obj);
678 move_object_with_animation(Evas_Object * obj, Evas_Coord x, Evas_Coord y,
679 Evas_Coord w, Evas_Coord h, Evas_Coord x_,
680 Evas_Coord y_, Evas_Coord w_, Evas_Coord h_,
681 double time, int (*mv_func) (void *data),
682 void (*func) (void *data,
683 Evas_Object * obj), void *data)
685 Animation_Data * ad = (Animation_Data *) malloc(sizeof(Animation_Data));
695 ad->start_time = current_time_get();
699 ad->timer = ecore_animator_add(mv_func, ad);
704 item_animation_effect(void *data)
706 Widget_Data *wd = (Widget_Data *)data;
708 Elm_Controlbar_Item * item;
713 EINA_LIST_FOREACH(wd->items, l, item)
716 // printf("rand :: %d\n", rand);
717 if(rand > 65 && item->order > 0)
723 edje_object_signal_emit(_EDJ(item->base), "elm,animation,pop", "elm");
726 edje_object_signal_emit(_EDJ(item->base), "elm,animation,vibration", "elm");
729 edje_object_signal_emit(_EDJ(item->base), "elm,animation,jump", "elm");
740 /////////////////////////////////////////////////////////////
744 /////////////////////////////////////////////////////////////
747 sort_cb(const void *d1, const void *d2)
749 Elm_Controlbar_Item * item1, *item2;
750 item1 = (Elm_Controlbar_Item *) d1;
751 item2 = (Elm_Controlbar_Item *) d2;
752 if (item1->order <= 0)
754 if (item2->order <= 0)
756 return item1->order > item2->order ? 1 : -1;
760 sort_reverse_cb(const void *d1, const void *d2)
762 Elm_Controlbar_Item * item1, *item2;
763 item1 = (Elm_Controlbar_Item *) d1;
764 item2 = (Elm_Controlbar_Item *) d2;
765 if (item1->order <= 0)
767 if (item2->order <= 0)
769 return item1->order > item2->order ? -1 : 1;
773 done_button_cb(void *data, Evas_Object * obj, void *event_info)
775 Widget_Data * wd = (Widget_Data *) data;
777 wd->items = eina_list_sort(wd->items, eina_list_count(wd->items), sort_cb);
779 evas_object_smart_callback_call(wd->object, "edit,end", wd->items);
781 edje_object_signal_emit(wd->edit_box, "elm,state,hide,edit_box", "elm");
782 wd->edit_mode = EINA_FALSE;
785 ///////////////////////////////////////////////////////////////////
787 // basic utility function
789 ////////////////////////////////////////////////////////////////////
792 check_bar_item_number(Widget_Data *wd)
795 Elm_Controlbar_Item * item;
798 EINA_LIST_FOREACH(wd->items, l, item)
800 if(item->order > 0) num++;
807 item_insert_in_bar(Elm_Controlbar_Item * it, int order)
811 Elm_Controlbar_Item * item;
812 Widget_Data * wd = elm_widget_data_get(it->obj);
815 if(order == 0) return;
817 EINA_LIST_FOREACH(wd->items, l, item)
819 if (item->order == order && item != it)
824 EINA_LIST_FOREACH(wd->items, l, item)
827 elm_table_unpack(wd->box, item->base);
829 EINA_LIST_FOREACH(wd->items, l, item)
833 if (item->order >= order)
835 elm_table_pack(wd->box, item->base, item->order - 1, 0, 1, 1);
836 evas_object_show(item->base);
841 elm_table_pack(wd->box, it->base, it->order - 1, 0, 1, 1);
842 evas_object_show(it->base);
846 item_delete_in_bar(Elm_Controlbar_Item * it)
849 Elm_Controlbar_Item * item;
850 Widget_Data * wd = elm_widget_data_get(it->obj);
853 EINA_LIST_FOREACH(wd->items, l, item)
859 elm_table_unpack(wd->box, it->base);
860 evas_object_hide(it->base);
865 EINA_LIST_FOREACH(wd->items, l, item)
870 elm_table_unpack(wd->box, item->base);
871 elm_table_pack(wd->box, item->base, item->order - 1, 0, 1, 1);
878 item_exchange_animation_cb(void *data, Evas_Object * obj)
880 Widget_Data * wd = (Widget_Data *) data;
882 if (wd->animating < 0)
884 printf("animation error\n");
887 evas_object_map_enable_set(obj, EINA_FALSE);
891 item_exchange_in_bar(Elm_Controlbar_Item * it1, Elm_Controlbar_Item * it2)
895 Evas_Coord x, y, w, h;
896 Evas_Coord x_, y_, w_, h_;
897 Widget_Data * wd = elm_widget_data_get(it1->obj);
898 evas_object_geometry_get(wd->moving_item->edit_item, &x, &y, &w, &h);
899 set_evas_map(wd->moving_obj, (wd->x + wd->w / 2), (wd->y + wd->h / 2), 0,
901 evas_object_geometry_get(it1->base, &x, &y, &w, &h);
902 evas_object_geometry_get(it2->base, &x_, &y_, &w_, &h_);
904 move_object_with_animation(it1->base, x, y, w, h, x_, y_, w_, h_, 0.25,
905 move_evas_map, item_exchange_animation_cb, wd);
907 move_object_with_animation(it2->base, x_, y_, w_, h_, x, y, w, h, 0.25,
908 move_evas_map, item_exchange_animation_cb, wd);
909 elm_table_unpack(wd->box, it1->base);
910 elm_table_unpack(wd->box, it2->base);
912 it1->order = it2->order;
914 elm_table_pack(wd->box, it1->base, it1->order - 1, 0, 1, 1);
915 elm_table_pack(wd->box, it2->base, it2->order - 1, 0, 1, 1);
919 item_change_animation_cb(void *data, Evas_Object * obj)
921 Evas_Coord x, y, w, h;
922 Widget_Data * wd = (Widget_Data *) data;
924 if (wd->animating < 0)
926 printf("animation error\n");
929 evas_object_map_enable_set(obj, EINA_FALSE);
930 evas_object_geometry_get(obj, &x, &y, &w, &h);
931 set_evas_map(obj, x, y, 0, 0);
932 evas_object_move(obj, -1000, -1000);
933 evas_object_geometry_get(wd->moving_item->base, &x, &y, &w, &h);
934 evas_object_move(wd->moving_obj, -1000, -1000);
935 evas_object_del(wd->moving_obj);
939 item_change_in_bar(Elm_Controlbar_Item * it)
941 Evas_Coord x, y, w, h;
942 Evas_Coord x_, y_, w_, h_;
943 Widget_Data * wd = elm_widget_data_get(it->obj);
946 if (wd->moving_item == NULL)
948 evas_object_geometry_get(wd->moving_item->edit_item, &x, &y, &w, &h);
949 set_evas_map(wd->moving_obj, x, y, w, h);
950 elm_table_unpack(wd->box, it->base);
951 wd->moving_item->order = it->order;
953 elm_table_pack(wd->box, wd->moving_item->base, wd->moving_item->order - 1,
955 evas_object_show(wd->moving_item->base);
956 evas_render_updates_free(evas_render_updates
957 (evas_object_evas_get(wd->moving_item->base)));
958 evas_object_geometry_get(it->base, &x, &y, &w, &h);
959 evas_object_geometry_get(it->edit_item, &x_, &y_, &w_, &h_);
961 move_object_with_animation(it->base, x, y, w, h, x_, y_, w_, h_, 0.25,
962 move_evas_map, item_change_animation_cb, wd);
963 evas_object_geometry_get(wd->moving_item->base, &x, &y, &w, &h);
964 set_evas_map(wd->moving_item->base, x, y, w, h);
968 hide_selected_box(void *data)
970 Evas_Object *selected_box = (Evas_Object *)data;
972 evas_object_hide(selected_box);
978 object_color_set(Evas_Object *ly, const char *color_part, const char *obj_part)
984 (Evas_Object *) edje_object_part_object_get(_EDJ(ly), color_part);
986 evas_object_color_get(color, &r, &g, &b, &a);
988 edje_object_part_swallow_get(_EDJ(ly), obj_part);
989 evas_object_color_set(color, r, g, b, a);
993 _end_selected_box(void *data, Evas_Object *obj)
995 Widget_Data * wd = (Widget_Data *)data;
998 edje_object_signal_emit(_EDJ(wd->cur_item->base), "elm,state,selected", "elm");
999 // item animation effect
1000 if(wd->selected_animation)
1008 edje_object_signal_emit(_EDJ(wd->cur_item->base), "elm,animation,pop", "elm");
1011 edje_object_signal_emit(_EDJ(wd->cur_item->base), "elm,animation,vibration", "elm");
1014 edje_object_signal_emit(_EDJ(wd->cur_item->base), "elm,animation,jump", "elm");
1022 if (wd->animating < 0)
1024 printf("animation error\n");
1028 ecore_idler_add(hide_selected_box, wd->selected_box);
1032 move_selected_box(Widget_Data *wd, Elm_Controlbar_Item * fit, Elm_Controlbar_Item * tit)
1034 Evas_Coord fx, fy, fw, fh, tx, ty, tw, th;
1035 Evas_Object *from, *to;
1037 if(fit->order <= 0 && wd->auto_align)
1038 fit = wd->more_item;
1040 from = (Evas_Object *)edje_object_part_object_get(_EDJ(fit->base), "bg_img");
1041 evas_object_geometry_get(from, &fx, &fy, &fw, &fh);
1043 to = (Evas_Object *)edje_object_part_object_get(_EDJ(tit->base), "bg_img");
1044 evas_object_geometry_get(to, &tx, &ty, &tw, &th);
1046 edje_object_signal_emit(_EDJ(wd->pre_item->base), "elm,state,unselected", "elm");
1047 edje_object_signal_emit(_EDJ(wd->cur_item->base), "elm,state,unselected", "elm");
1050 move_object_with_animation(wd->selected_box, fx, fy, fw, fh, tx, ty, tw, th,
1051 0.3, move_evas_object, _end_selected_box, wd);
1055 end_selected_box(void *data, Evas_Object *obj)
1057 Widget_Data * wd = (Widget_Data *)data;
1059 if(wd->pre_item) evas_object_hide(wd->pre_item->view);
1061 elm_layout_content_set(wd->view, "elm.swallow.view", obj);
1063 evas_object_show(obj);
1067 view_animation_push(Widget_Data *wd, Evas_Object *pre, Evas_Object *cur, void *data)
1069 Evas_Coord x, y, w, h;
1071 evas_object_geometry_get(pre, &x, &y, &w, &h);
1072 move_object_with_animation(pre, x, y, w, h, x+20, y, w, h, 0.5, move_fade_out_object, NULL, NULL);
1073 move_object_with_animation(cur, x+120, y, w, h, x, y, w, h, 0.5, move_fade_in_object, end_selected_box, wd);
1077 view_animation_down(Widget_Data *wd, Evas_Object *pre, Evas_Object *cur, void *data)
1079 Evas_Coord x, y, w, h;
1081 evas_object_geometry_get(pre, &x, &y, &w, &h);
1083 move_object_with_animation(cur, x, h, w, h, x, h, w, h, 0.5, move_evas_object, end_selected_box, wd);
1084 evas_object_raise(pre);
1085 move_object_with_animation(pre, x, y, w, h, x, h, w, 0, 0.5, move_evas_map, NULL, NULL);
1089 selected_box(Elm_Controlbar_Item * it)
1091 Widget_Data * wd = elm_widget_data_get(it->obj);
1093 Elm_Controlbar_Item * item, *fit = NULL;
1094 Evas_Object * content;
1096 if(wd->animating) return;
1100 if(it->style == TABBAR){
1102 content = elm_layout_content_unset(wd->view, "elm.swallow.view");
1103 EINA_LIST_FOREACH(wd->items, l, item){
1104 if(item->selected) {
1108 item->selected = EINA_FALSE;
1110 it->selected = EINA_TRUE;
1111 evas_object_smart_callback_call(it->obj, "view,change,before", it);
1112 object_color_set(it->base, "elm.tabbar.selected.color", "elm.swallow.icon");
1114 if(fit != NULL && fit != it)
1115 move_selected_box(wd, fit, it);
1117 edje_object_signal_emit(_EDJ(it->base), "elm,state,selected", "elm");
1120 if(fit != NULL && fit != it)
1122 //view_animation_down(wd, fit->view, it->view, NULL);
1123 view_animation_push(wd, fit->view, it->view, NULL);
1124 //evas_object_hide(content);
1126 // evas_object_geometry_get(fit->view, &x, &y, &w, &h);
1127 // if(fit->order > it->order)
1129 // move_object_with_animation(fit->view, x, y, w, h, x+20, y, w, h, 0.5, move_fade_out_object, NULL, NULL);
1130 // 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);
1134 // move_object_with_animation(fit->view, x, y, w, h, x-120, y, w, h, 1.5, move_fade_out_object, NULL, NULL);
1135 // 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);
1140 end_selected_box(wd, it->view);
1143 if(wd->pre_item) evas_object_hide(wd->pre_item->view);
1144 elm_layout_content_set(wd->view, "elm.swallow.view", it->view);
1146 // elm_layout_content_set(wd->view, "elm.swallow.view", it->view);
1147 //edje_object_part_swallow(wd->view, "elm.swallow.view", it->view);
1148 // evas_object_show(it->view);
1150 }else if(it->style == TOOLBAR){
1152 it->func(it->data, it->obj, it);
1153 object_color_set(it->base, "elm.tabbar.default.color", "elm.swallow.icon");
1154 edje_object_signal_emit(_EDJ(it->base), "elm,state,text_unselected", "elm");
1157 evas_object_smart_callback_call(it->obj, "clicked", it);
1161 unpressed_box_cb(void *data, Evas *evas, Evas_Object *obj, void *event_info)
1163 Widget_Data * wd = (Widget_Data *) data;
1165 Evas_Event_Mouse_Up * ev = event_info;
1166 Evas_Coord x, y, w, h;
1168 Elm_Controlbar_Item * item;
1169 EINA_LIST_FOREACH(wd->items, l, item)
1171 if (item->style == TABBAR)
1175 object_color_set(item->base, "elm.tabbar.selected.color", "elm.swallow.icon");
1176 edje_object_signal_emit(_EDJ(item->base), "elm,state,selected", "elm");
1180 object_color_set(item->base, "elm.tabbar.default.color", "elm.swallow.icon");
1181 edje_object_signal_emit(_EDJ(item->base), "elm,state,unselected", "elm");
1184 else if (item->style == TOOLBAR)
1186 object_color_set(item->base, "elm.tabbar.default.color", "elm.swallow.icon");
1187 edje_object_signal_emit(_EDJ(item->base), "elm,state,text_unselected", "elm");
1191 evas_object_geometry_get(wd->pre_item->base, &x, &y, &w, &h);
1192 if(ev->output.x > x && ev->output.x < x+w && ev->output.y > y && ev->output.y < y+h)
1194 selected_box(wd->pre_item);
1197 evas_object_event_callback_del(wd->event_box, EVAS_CALLBACK_MOUSE_UP, unpressed_box_cb);
1203 pressed_box(Elm_Controlbar_Item * it)
1205 Widget_Data * wd = elm_widget_data_get(it->obj);
1208 Elm_Controlbar_Item * item;
1210 if(wd->animating) return EXIT_FAILURE;
1212 EINA_LIST_FOREACH(wd->items, l, item)
1216 if (it->style == TABBAR)
1219 object_color_set(it->base, "elm.tabbar.selected.color", "elm.swallow.icon");
1220 edje_object_signal_emit(_EDJ(it->base), "elm,state,pressed",
1223 else if (it->style == TOOLBAR)
1226 object_color_set(it->base, "elm.toolbar.pressed.color", "elm.swallow.icon");
1227 edje_object_signal_emit(_EDJ(it->base), "elm,state,text_selected",
1230 evas_object_event_callback_add(wd->event_box, EVAS_CALLBACK_MOUSE_UP, unpressed_box_cb, (void *)wd);
1236 return EXIT_FAILURE;
1240 return EXIT_SUCCESS;
1243 static Evas_Object *
1244 create_item_layout(Evas_Object * parent, Elm_Controlbar_Item * it)
1248 obj = elm_layout_add(parent);
1251 fprintf(stderr, "Cannot load bg edj\n");
1254 elm_layout_theme_set(obj, "controlbar", "item",
1255 elm_widget_style_get(it->obj));
1256 evas_object_size_hint_weight_set(obj, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1257 evas_object_size_hint_align_set(obj, EVAS_HINT_FILL, EVAS_HINT_FILL);
1260 edje_object_part_text_set(_EDJ(obj), "elm.text", it->label);
1264 icon = elm_icon_add(obj);
1265 if(!elm_icon_standard_set(icon, it->icon_path))
1267 elm_icon_file_set(icon, it->icon_path, NULL);
1270 evas_object_size_hint_min_set(icon, 40, 40);
1271 evas_object_size_hint_max_set(icon, 100, 100);
1272 evas_object_show(icon);
1273 edje_object_part_swallow(_EDJ(obj), "elm.swallow.icon", icon);
1276 if (it->label && it->icon)
1278 edje_object_signal_emit(_EDJ(obj), "elm,state,icon_text", "elm");
1284 edit_item_down_end_cb(void *data, Evas_Object * obj)
1286 Widget_Data * wd = (Widget_Data *) data;
1288 if (wd->animating < 0)
1290 printf("animation error\n");
1296 edit_item_return_cb(void *data, Evas_Object * obj)
1298 Evas_Coord x, y, w, h;
1299 Widget_Data * wd = (Widget_Data *) data;
1300 evas_object_geometry_get(wd->moving_item->edit_item, &x, &y, &w, &h);
1301 set_evas_map(obj, x, y, 0, 0);
1303 evas_object_event_callback_del(wd->event_box, EVAS_CALLBACK_MOUSE_UP, edit_item_up_cb);
1304 evas_object_event_callback_del(wd->event_box, EVAS_CALLBACK_MOUSE_MOVE, edit_item_move_cb);
1306 evas_object_data_set(wd->moving_obj, "returning", 0);
1308 if (wd->animating < 0)
1310 printf("animation error\n");
1316 edit_item_move_cb(void *data, Evas *evas, Evas_Object *obj, void *event_info)
1318 Evas_Event_Mouse_Move * ev = event_info;
1320 Elm_Controlbar_Item * item;
1321 Evas_Coord x, y, w, h;
1322 Widget_Data * wd = (Widget_Data *) data;
1325 evas_object_geometry_get(wd->moving_obj, &x, &y, &w, &h);
1328 x = ev->cur.output.x - w / 2;
1329 y = ev->cur.output.y - h;
1330 set_evas_map(wd->moving_obj, x, y, w, h);
1332 EINA_LIST_FOREACH(wd->items, l, item)
1334 if (wd->moving_item->edit_item == item->edit_item || item->style == OBJECT)
1336 evas_object_geometry_get(item->base, &x, &y, &w, &h);
1337 if (ev->cur.output.x > x && ev->cur.output.x < x + w && ev->cur.output.y > y && ev->cur.output.y < y + h
1340 edje_object_signal_emit(_EDJ(item->base), "elm,state,show,glow",
1345 edje_object_signal_emit(_EDJ(item->base), "elm,state,hide,glow",
1353 edit_item_up_cb(void *data, Evas *evas, Evas_Object *obj, void *event_info)
1355 Evas_Event_Mouse_Up * ev = event_info;
1356 Evas_Coord x, y, w, h;
1357 Evas_Coord x_, y_, w_, h_;
1359 Elm_Controlbar_Item * item;
1360 Widget_Data * wd = (Widget_Data *) data;
1362 if ((int)evas_object_data_get(wd->moving_obj, "returning") == 1)
1364 evas_object_color_set(wd->moving_item->edit_item, 255, 255, 255, 255);
1366 // check which change or not
1367 EINA_LIST_FOREACH(wd->items, l, item)
1369 if (wd->moving_item->edit_item == item->edit_item)
1371 if (item->order <= 0)
1373 evas_object_geometry_get(item->base, &x, &y, &w, &h);
1374 if (ev->output.x > x && ev->output.x < x + w && ev->output.y > y && ev->output.y < y + h
1375 && item->style != OBJECT && item->editable)
1377 edje_object_signal_emit(_EDJ(item->base), "elm,state,hide,glow",
1384 if (wd->moving_item->order > 0)
1386 item_exchange_in_bar(wd->moving_item, item);
1390 item_change_in_bar(item);
1392 evas_object_event_callback_del(wd->event_box, EVAS_CALLBACK_MOUSE_UP, edit_item_up_cb);
1393 evas_object_event_callback_del(wd->event_box, EVAS_CALLBACK_MOUSE_MOVE, edit_item_move_cb);
1398 // return moving object to original location
1399 evas_object_geometry_get(wd->moving_item->edit_item, &x_, &y_, &w_,
1401 evas_object_geometry_get(wd->moving_obj, &x, &y, &w, &h);
1404 x = ev->output.x - w / 2;
1405 y = ev->output.y - h;
1406 evas_object_data_set(wd->moving_obj, "returning", (void *)1);
1408 move_object_with_animation(wd->moving_obj, x, y, w, h, x_, y_, w_, h_,
1409 0.25, move_evas_map, edit_item_return_cb, wd);
1415 edit_item_down_cb(void *data, Evas * evas, Evas_Object * obj,
1418 Evas_Event_Mouse_Down * ev = event_info;
1419 Evas_Coord x, y, w, h;
1420 Evas_Coord x_, y_, w_, h_;
1421 Widget_Data * wd = (Widget_Data *) data;
1424 Elm_Controlbar_Item * item;
1425 Evas_Object * color;
1430 EINA_LIST_FOREACH(wd->items, l, item)
1432 if (item->edit_item == obj)
1437 if (!item->editable)
1440 evas_object_event_callback_add(wd->event_box, EVAS_CALLBACK_MOUSE_UP, edit_item_up_cb, (void *)wd);
1441 evas_object_event_callback_add(wd->event_box, EVAS_CALLBACK_MOUSE_MOVE, edit_item_move_cb, (void *)wd);
1443 wd->moving_item = item;
1446 edje_object_part_object_get(_EDJ(wd->moving_item->edit_item),
1447 "elm.edit.item.color");
1449 evas_object_color_get(color, &r, &g, &b, &a);
1450 evas_object_color_set(item->edit_item, r, g, b, a);
1452 evas_object_del(wd->moving_obj);
1453 wd->moving_obj = NULL;
1454 wd->moving_obj = create_item_layout(obj, item);
1455 evas_object_geometry_get(obj, &x, &y, &w, &h);
1456 evas_object_move(wd->moving_obj, -1000, -1000);
1457 evas_object_resize(wd->moving_obj, w, h);
1458 evas_object_show(wd->moving_obj);
1461 x_ = ev->output.x - w_ / 2;
1462 y_ = ev->output.y - h_;
1464 move_object_with_animation(wd->moving_obj, x, y, w, h, x_, y_, w_, h_, 0.1,
1465 move_evas_map, edit_item_down_end_cb, wd);
1469 bar_item_move_end_cb(void *data, Evas_Object * obj)
1471 Widget_Data * wd = (Widget_Data *) data;
1474 Elm_Controlbar_Item * item;
1475 EINA_LIST_FOREACH(wd->items, l, item)
1477 if (item->base == obj)
1481 if (wd->animating < 0)
1483 printf("animation error\n");
1486 evas_object_data_set(obj, "animating", 0);
1487 evas_object_map_enable_set(obj, EINA_FALSE);
1491 bar_item_animation_end_check(void *data)
1495 Elm_Controlbar_Item * item;
1496 Widget_Data * wd = (Widget_Data *) data;
1498 return EXIT_FAILURE;
1499 EINA_LIST_FOREACH(wd->items, l, item)
1501 if (item->base == wd->moving_obj)
1506 printf("item is NULL\n");
1510 item->order = wd->empty_num;
1512 wd->moving_obj = NULL;
1514 evas_object_event_callback_del(wd->event_box, EVAS_CALLBACK_MOUSE_UP, bar_item_up_cb);
1515 evas_object_event_callback_del(wd->event_box, EVAS_CALLBACK_MOUSE_MOVE, bar_item_move_cb);
1516 return EXIT_SUCCESS;
1520 bar_item_move_cb(void *data, Evas *evas, Evas_Object *obj, void *event_info)
1522 Evas_Event_Mouse_Move * ev = event_info;
1524 Elm_Controlbar_Item * item, *it;
1525 Widget_Data * wd = (Widget_Data *) data;
1526 Evas_Coord x, y, w, h, x_, y_, w_, h_;
1529 if (wd->moving_obj == NULL)
1531 printf("%s : moving_obj is NULL\n", __func__);
1534 evas_object_geometry_get(wd->moving_obj, &x, &y, &w, &h);
1535 x = ev->cur.output.x - w / 2;
1536 set_evas_map(wd->moving_obj, x, y, w, h);
1537 EINA_LIST_FOREACH(wd->items, l, item)
1539 if (item->base == wd->moving_obj)
1544 if ((int)evas_object_data_get(item->base, "animating") == 1)
1546 evas_object_geometry_get(item->base, &x, &y, &w, &h);
1547 if (ev->cur.output.x > x && ev->cur.output.x < x + w && item->editable)
1554 evas_object_geometry_get(wd->moving_obj, &x_, &y_, &w_, &h_);
1555 evas_object_move(wd->moving_obj, x, y);
1556 tmp = wd->empty_num;
1557 wd->empty_num = item->order;
1559 elm_table_unpack(wd->box, item->base);
1560 elm_table_unpack(wd->box, wd->moving_obj);
1561 elm_table_pack(wd->box, item->base, item->order - 1, 0, 1, 1);
1562 elm_table_pack(wd->box, wd->moving_obj, wd->empty_num - 1, 0, 1, 1);
1564 evas_object_data_set(item->base, "animating", (void *)1);
1565 move_object_with_animation(item->base, x, y, w, h, x_, y_, w_, h_,
1566 0.25, move_evas_map, bar_item_move_end_cb, wd);
1572 bar_item_up_cb(void *data, Evas *evas, Evas_Object *obj, void *event_info)
1574 Evas_Event_Mouse_Up * ev = event_info;
1575 Evas_Coord tx, x, y, w, h;
1576 Widget_Data * wd = (Widget_Data *) data;
1577 evas_object_geometry_get(wd->moving_obj, &x, &y, &w, &h);
1578 tx = ev->output.x - w / 2;
1580 evas_object_data_set(wd->moving_obj, "animating", (void *)1);
1581 move_object_with_animation(wd->moving_obj, tx, y, w, h, x, y, w, h, 0.25,
1582 move_evas_map, bar_item_move_end_cb, wd);
1583 ecore_timer_add(0.1, bar_item_animation_end_check, wd);
1588 bar_item_down_cb(void *data, Evas * evas, Evas_Object * obj, void *event_info)
1590 Widget_Data * wd = (Widget_Data *) data;
1592 Elm_Controlbar_Item * item;
1595 EINA_LIST_FOREACH(wd->items, l, item)
1597 if (item->base == obj)
1604 if (!item->editable)
1607 wd->moving_obj = obj;
1608 wd->empty_num = item->order;
1609 evas_object_event_callback_add(wd->event_box, EVAS_CALLBACK_MOUSE_UP, bar_item_up_cb, (void *)wd);
1610 evas_object_event_callback_add(wd->event_box, EVAS_CALLBACK_MOUSE_MOVE, bar_item_move_cb, (void *)wd);
1618 static Elm_Controlbar_Item *
1619 create_tab_item(Evas_Object * obj, const char *icon_path, const char *label,
1622 Elm_Controlbar_Item * it;
1626 fprintf(stderr, "Invalid argument: controlbar object is NULL\n");
1629 wd = elm_widget_data_get(obj);
1632 fprintf(stderr, "Cannot get smart data\n");
1635 it = ELM_NEW(Elm_Controlbar_Item);
1639 it->label = eina_stringshare_add(label);
1640 it->icon_path = icon_path;
1641 it->selected = EINA_FALSE;
1642 it->editable = EINA_TRUE;
1647 it->base = create_item_layout(wd->edje, it);
1648 evas_object_event_callback_add(it->base, EVAS_CALLBACK_MOUSE_DOWN,
1649 bar_item_down_cb, wd);
1650 //edje_object_signal_callback_add(_EDJ(it->base), "elm,action,click", "elm",
1651 // clicked_box_cb, wd);
1652 object_color_set(it->base, "elm.tabbar.default.color", "elm.swallow.icon");
1653 evas_object_show(it->base);
1654 it->edit_item = create_item_layout(wd->edje, it);
1655 evas_object_event_callback_add(it->edit_item, EVAS_CALLBACK_MOUSE_DOWN,
1656 edit_item_down_cb, wd);
1657 evas_object_show(it->edit_item);
1662 static Elm_Controlbar_Item *
1663 create_tool_item(Evas_Object * obj, const char *icon_path, const char *label,
1664 void (*func) (void *data, Evas_Object * obj,
1665 void *event_info), void *data)
1667 Elm_Controlbar_Item * it;
1671 fprintf(stderr, "Invalid argument: controlbar object is NULL\n");
1674 wd = elm_widget_data_get(obj);
1677 fprintf(stderr, "Cannot get smart data\n");
1680 it = ELM_NEW(Elm_Controlbar_Item);
1684 it->label = eina_stringshare_add(label);
1685 it->icon_path = icon_path;
1686 it->selected = EINA_FALSE;
1687 it->editable = EINA_TRUE;
1692 it->style = TOOLBAR;
1693 it->base = create_item_layout(wd->edje, it);
1694 evas_object_event_callback_add(it->base, EVAS_CALLBACK_MOUSE_DOWN,
1695 bar_item_down_cb, wd);
1696 //edje_object_signal_callback_add(_EDJ(it->base), "elm,action,click", "elm",
1697 // clicked_box_cb, wd);
1698 object_color_set(it->base, "elm.tabbar.default.color", "elm.swallow.icon");
1699 evas_object_show(it->base);
1700 it->edit_item = create_item_layout(wd->edje, it);
1701 evas_object_event_callback_add(it->edit_item, EVAS_CALLBACK_MOUSE_DOWN,
1702 edit_item_down_cb, wd);
1703 evas_object_show(it->edit_item);
1707 static Elm_Controlbar_Item *
1708 create_object_item(Evas_Object * obj, Evas_Object * obj_item, const int sel)
1710 Elm_Controlbar_Item * it;
1714 fprintf(stderr, "Invalid argument: controlbar object is NULL\n");
1717 wd = elm_widget_data_get(obj);
1720 fprintf(stderr, "Cannot get smart data\n");
1723 it = ELM_NEW(Elm_Controlbar_Item);
1730 it->base = obj_item;
1735 set_items_position(Evas_Object * obj, Elm_Controlbar_Item * it,
1736 Elm_Controlbar_Item * mit, Eina_Bool bar)
1741 Elm_Controlbar_Item * item;
1744 int check = EINA_FALSE;
1752 fprintf(stderr, "Invalid argument: controlbar object is NULL\n");
1755 wd = elm_widget_data_get(obj);
1758 fprintf(stderr, "Cannot get smart data\n");
1762 EINA_LIST_FOREACH(wd->items, l, item)
1764 if (item == mit && item->order > 0)
1768 it->order = mit->order;
1772 if(item->order > 0){
1773 // printf("%s +_+_+_+_+_+ %d \n", item->label, item->order);
1774 elm_table_unpack(wd->box, item->base);
1775 item->order += it->sel;
1776 elm_table_pack(wd->box, item->base, item->order - 1, 0, item->sel, 1);
1778 if (item->style != OBJECT && it->style != OBJECT)
1780 // printf("%s +_+_+_+_+_+ edit :: %d\n", item->label, i);
1781 elm_table_unpack(wd->edit_table, item->edit_item);
1782 elm_table_pack(wd->edit_table, item->edit_item,
1783 i % EDIT_ROW_NUM, i / EDIT_ROW_NUM, 1, 1);
1786 if (item->style != OBJECT)
1788 if(item->order > 0) order += item->sel;
1799 if(bar) elm_table_pack(wd->box, it->base, it->order - 1, 0, it->sel, 1);
1800 else evas_object_hide(it->base);
1801 if (it->style != OBJECT)
1802 elm_table_pack(wd->edit_table, it->edit_item, (edit - 1) % EDIT_ROW_NUM,
1803 (edit - 1) / EDIT_ROW_NUM, 1, 1);
1807 list_clicked(void *data, Evas_Object *obj, void *event_info)
1809 Elm_Controlbar_Item *item = (Elm_Controlbar_Item *)data;
1810 Elm_Controlbar_Item *it;
1813 Evas_Object *content;
1814 Elm_List_Item *lit = (Elm_List_Item *) elm_list_selected_item_get(obj);
1815 if(lit == NULL) return;
1817 elm_list_item_selected_set(lit, 0);
1821 wd = elm_widget_data_get(item->obj);
1823 EINA_LIST_FOREACH(wd->items, l, it)
1825 it->selected = EINA_FALSE;
1828 if(item->style == TABBAR)
1830 content = elm_layout_content_unset(wd->view, "elm.swallow.view");
1831 evas_object_hide(content);
1832 item->selected = EINA_TRUE;
1833 evas_object_smart_callback_call(item->obj, "view,change,before", item);
1834 elm_layout_content_set(wd->view, "elm.swallow.view", item->view);
1837 if(item->style == TOOLBAR && item->func)
1838 item->func(item->data, item->obj, item);
1841 static Evas_Object *
1842 create_more_view(Widget_Data *wd)
1845 Elm_Controlbar_Item *item;
1848 list = elm_list_add( wd->object );
1849 elm_list_horizontal_mode_set( list, ELM_LIST_COMPRESS );
1851 EINA_LIST_FOREACH(wd->items, l, item)
1853 if(item->order <= 0)
1855 evas_object_color_set(item->icon, 0, 0, 0, 255);
1856 elm_list_item_append(list, item->label, item->icon, NULL, list_clicked, item);
1860 elm_list_go( list );
1865 static Elm_Controlbar_Item *
1866 create_more_item(Widget_Data *wd, int style)
1868 Elm_Controlbar_Item * it;
1870 it = ELM_NEW(Elm_Controlbar_Item);
1873 it->obj = wd->object;
1874 it->label = eina_stringshare_add("more");
1875 it->icon_path = CONTROLBAR_SYSTEM_ICON_MORE;
1876 it->selected = EINA_FALSE;
1879 it->view = create_more_view(wd);
1881 it->base = create_item_layout(wd->edje, it);
1882 evas_object_event_callback_add(it->base, EVAS_CALLBACK_MOUSE_DOWN,
1883 bar_item_down_cb, wd);
1884 object_color_set(it->base, "elm.tabbar.default.color", "elm.swallow.icon");
1885 evas_object_show(it->base);
1886 it->edit_item = create_item_layout(wd->edje, it);
1887 evas_object_event_callback_add(it->edit_item, EVAS_CALLBACK_MOUSE_DOWN,
1888 edit_item_down_cb, wd);
1889 evas_object_show(it->edit_item);
1891 set_items_position(it->obj, it, NULL, EINA_TRUE);
1893 wd->items = eina_list_append(wd->items, it);
1897 elm_controlbar_item_editable_set(it, EINA_FALSE);
1899 wd->items = eina_list_sort(wd->items, eina_list_count(wd->items), sort_cb);
1904 ///////////////////////////////////////////////////////////////////
1908 ////////////////////////////////////////////////////////////////////
1911 * Add a new controlbar object
1913 * @param parent The parent object
1914 * @return The new object or NULL if it cannot be created
1916 * @ingroup Controlbar
1918 EAPI Evas_Object * elm_controlbar_add(Evas_Object * parent)
1920 Evas_Object * obj = NULL;
1921 Evas_Object * bg = NULL;
1922 Widget_Data * wd = NULL;
1923 Evas_Coord x, y, w, h;
1924 Evas_Object * r_button;
1925 wd = ELM_NEW(Widget_Data);
1926 wd->evas = evas_object_evas_get(parent);
1927 if (wd->evas == NULL)
1929 obj = elm_widget_add(wd->evas);
1932 elm_widget_type_set(obj, "controlbar");
1933 elm_widget_sub_object_add(parent, obj);
1934 elm_widget_data_set(obj, wd);
1935 elm_widget_del_hook_set(obj, _del_hook);
1936 elm_widget_theme_hook_set(obj, _theme_hook);
1939 wd->parent = parent;
1940 evas_object_geometry_get(parent, &x, &y, &w, &h);
1946 wd->mode = ELM_CONTROLBAR_MODE_DEFAULT;
1949 wd->edit_mode = EINA_FALSE;
1950 wd->auto_align = EINA_FALSE;
1951 wd->init_animation = EINA_FALSE;
1952 wd->selected_animation = EINA_FALSE;
1953 wd->view = elm_layout_add(wd->parent); //edje_object_add(wd->evas);
1954 elm_layout_theme_set(wd->view, "controlbar", "view", "default");
1955 //_elm_theme_object_set(obj, wd->view, "controlbar", "view", "default");
1956 if (wd->view == NULL)
1958 printf("Cannot load bg edj\n");
1961 evas_object_show(wd->view);
1964 wd->edit_box = edje_object_add(wd->evas);
1965 _elm_theme_object_set(obj, wd->edit_box, "controlbar", "edit_box",
1967 if (wd->edit_box == NULL)
1969 printf("Cannot load bg edj\n");
1972 evas_object_show(wd->edit_box);
1974 //instead of navigationbar
1975 /* r_button = elm_button_add(wd->edit_box);
1976 elm_button_label_set(r_button, "Done");
1977 evas_object_smart_callback_add(r_button, "clicked", done_button_cb, wd);
1978 edje_object_part_swallow(wd->edit_box, "elm.swallow.navigation", r_button);
1980 // navigationbar will contribution. but not yet
1981 wd->navigation = elm_navigationbar_add(wd->edit_box);
1982 r_button = elm_button_add(wd->navigation);
1983 elm_button_label_set(r_button, "Done");
1984 evas_object_smart_callback_add(r_button, "clicked", done_button_cb, wd);
1985 elm_navigationbar_push(wd->navigation, "Configure", NULL, r_button, NULL, NULL);
1986 edje_object_part_swallow(wd->edit_box, "elm.swallow.navigation", wd->navigation);
1988 wd->edit_table = elm_table_add(wd->edit_box);
1989 elm_table_homogenous_set(wd->edit_table, EINA_TRUE);
1990 edje_object_part_swallow(wd->edit_box, "elm.swallow.table", wd->edit_table);
1992 /* load background edj */
1993 wd->edje = edje_object_add(wd->evas);
1994 _elm_theme_object_set(obj, wd->edje, "controlbar", "base", "default");
1995 if (wd->edje == NULL)
1997 printf("Cannot load bg edj\n");
2000 evas_object_show(wd->edje);
2003 evas_object_event_callback_add(wd->edje, EVAS_CALLBACK_RESIZE,
2004 _controlbar_object_resize, obj);
2005 evas_object_event_callback_add(wd->edje, EVAS_CALLBACK_MOVE,
2006 _controlbar_object_move, obj);
2007 evas_object_event_callback_add(wd->edje, EVAS_CALLBACK_SHOW,
2008 _controlbar_object_show, obj);
2009 evas_object_event_callback_add(wd->edje, EVAS_CALLBACK_HIDE,
2010 _controlbar_object_hide, obj);
2011 bg = (Evas_Object *)edje_object_part_object_get(wd->edje, "bg_image");
2012 evas_object_event_callback_add(bg, EVAS_CALLBACK_MOVE, _controlbar_object_move, obj);
2013 evas_object_event_callback_add(bg, EVAS_CALLBACK_RESIZE, _controlbar_object_resize, obj);
2015 wd->selected_box = edje_object_add(wd->evas);
2016 _elm_theme_object_set(obj, wd->selected_box, "controlbar", "item_bg", "default");
2017 //edje_object_part_swallow(wd->edje, "elm.swallow.panel", wd->selected_box);
2018 evas_object_hide(wd->selected_box);
2021 wd->box = elm_table_add(wd->edje);
2022 elm_table_homogenous_set(wd->box, EINA_TRUE);
2023 evas_object_size_hint_weight_set(wd->box, EVAS_HINT_EXPAND,
2025 evas_object_size_hint_align_set(wd->box, EVAS_HINT_FILL, EVAS_HINT_FILL);
2026 edje_object_part_swallow(wd->edje, "elm.swallow.items", wd->box);
2027 evas_object_show(wd->box);
2029 wd->event_box = evas_object_rectangle_add(wd->evas);
2030 evas_object_color_set(wd->event_box, 255, 255, 255, 0);
2031 evas_object_repeat_events_set(wd->event_box, EINA_TRUE);
2032 evas_object_show(wd->event_box);
2035 // evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
2036 evas_object_smart_member_add(wd->view, obj);
2037 evas_object_smart_member_add(wd->edit_box, obj);
2038 elm_widget_resize_object_set(obj, wd->edje);
2039 evas_object_smart_member_add(wd->selected_box, obj);
2040 evas_object_smart_member_add(wd->box, obj);
2041 evas_object_smart_member_add(wd->event_box, obj);
2048 * Append new tab item
2050 * @param obj The controlbar object
2051 * @param icon_path The icon path of item
2052 * @param label The label of item
2053 * @param view The view of item
2054 * @return The item of controlbar
2056 * @ingroup Controlbar
2058 EAPI Elm_Controlbar_Item * elm_controlbar_tab_item_append(Evas_Object * obj,
2065 Elm_Controlbar_Item * it;
2066 Elm_Controlbar_Item * lit;
2068 it = create_tab_item(obj, icon_path, label, view);
2071 wd = elm_widget_data_get(obj);
2072 if(check_bar_item_number(wd) >= 5 && wd->auto_align){
2073 if(!wd->more_item) {
2074 lit = elm_controlbar_last_item_get(obj);
2075 elm_controlbar_item_visible_set(lit, EINA_FALSE);
2076 create_more_item(wd, TABBAR);
2078 set_items_position(obj, it, NULL, EINA_FALSE);
2081 set_items_position(obj, it, NULL, EINA_TRUE);
2083 if(wd->init_animation) evas_object_hide(it->base);
2084 wd->items = eina_list_append(wd->items, it);
2086 elm_controlbar_item_view_set(wd->more_item, create_more_view(wd));
2094 * Prepend new tab item
2096 * @param obj The controlbar object
2097 * @param icon_path The icon path of item
2098 * @param label The label of item
2099 * @param view The view of item
2100 * @return The item of controlbar
2102 * @ingroup Controlbar
2104 EAPI Elm_Controlbar_Item * elm_controlbar_tab_item_prepend(Evas_Object *
2114 Elm_Controlbar_Item * it;
2115 Elm_Controlbar_Item * lit;
2116 Elm_Controlbar_Item * item;
2117 it = create_tab_item(obj, icon_path, label, view);
2120 wd = elm_widget_data_get(obj);
2121 item = eina_list_data_get(wd->items);
2122 if(check_bar_item_number(wd) >= 5 && wd->auto_align){
2123 if(!wd->more_item) {
2124 lit = elm_controlbar_last_item_get(obj);
2125 elm_controlbar_item_visible_set(lit, EINA_FALSE);
2126 create_more_item(wd, TABBAR);
2128 lit = elm_controlbar_item_prev(wd->more_item);
2129 elm_controlbar_item_visible_set(lit, EINA_FALSE);
2130 set_items_position(obj, it, item, EINA_TRUE);
2133 set_items_position(obj, it, item, EINA_TRUE);
2135 wd->items = eina_list_prepend(wd->items, it);
2137 elm_controlbar_item_view_set(wd->more_item, create_more_view(wd));
2145 * Insert new tab item before given item
2147 * @param obj The controlbar object
2148 * @param before The given item
2149 * @param icon_path The icon path of item
2150 * @param label The label of item
2151 * @param view The view of item
2152 * @return The item of controlbar
2154 * @ingroup Controlbar
2156 EAPI Elm_Controlbar_Item *
2157 elm_controlbar_tab_item_insert_before(Evas_Object * obj,
2158 Elm_Controlbar_Item * before,
2159 const char *icon_path,
2160 const char *label, Evas_Object * view)
2163 Elm_Controlbar_Item * it;
2164 Elm_Controlbar_Item * lit;
2167 it = create_tab_item(obj, icon_path, label, view);
2170 wd = elm_widget_data_get(obj);
2171 if(check_bar_item_number(wd) >= 5 && wd->auto_align){
2174 lit = elm_controlbar_last_item_get(obj);
2175 elm_controlbar_item_visible_set(lit, EINA_FALSE);
2176 create_more_item(wd, TABBAR);
2178 if(before->order > 0)
2180 lit = elm_controlbar_item_prev(wd->more_item);
2181 elm_controlbar_item_visible_set(lit, EINA_FALSE);
2182 set_items_position(obj, it, before, EINA_TRUE);
2186 set_items_position(obj, it, before, EINA_FALSE);
2190 set_items_position(obj, it, before, EINA_TRUE);
2192 wd->items = eina_list_prepend_relative(wd->items, it, before);
2194 elm_controlbar_item_view_set(wd->more_item, create_more_view(wd));
2202 * Insert new tab item after given item
2204 * @param obj The controlbar object
2205 * @param after The given item
2206 * @param icon_path The icon path of item
2207 * @param label The label of item
2208 * @param view The view of item
2209 * @return The item of controlbar
2211 * @ingroup Controlbar
2213 EAPI Elm_Controlbar_Item *
2214 elm_controlbar_tab_item_insert_after(Evas_Object * obj,
2215 Elm_Controlbar_Item * after,
2216 const char *icon_path, const char *label,
2220 Elm_Controlbar_Item * it;
2221 Elm_Controlbar_Item * lit;
2222 Elm_Controlbar_Item * item;
2225 it = create_tab_item(obj, icon_path, label, view);
2228 wd = elm_widget_data_get(obj);
2229 item = elm_controlbar_item_next(after);
2230 if(check_bar_item_number(wd) >= 5 && wd->auto_align){
2233 lit = elm_controlbar_last_item_get(obj);
2234 elm_controlbar_item_visible_set(lit, EINA_FALSE);
2235 create_more_item(wd, TABBAR);
2239 lit = elm_controlbar_item_prev(wd->more_item);
2240 elm_controlbar_item_visible_set(lit, EINA_FALSE);
2241 set_items_position(obj, it, item, EINA_TRUE);
2245 set_items_position(obj, it, item, EINA_FALSE);
2249 set_items_position(obj, it, item, EINA_TRUE);
2251 wd->items = eina_list_append_relative(wd->items, it, after);
2253 elm_controlbar_item_view_set(wd->more_item, create_more_view(wd));
2261 * Append new tool item
2263 * @param obj The controlbar object
2264 * @param icon_path The icon path of item
2265 * @param label The label of item
2266 * @param func Callback function of item
2267 * @param data The data of callback function
2268 * @return The item of controlbar
2270 * @ingroup Controlbar
2272 EAPI Elm_Controlbar_Item * elm_controlbar_tool_item_append(Evas_Object *
2287 Elm_Controlbar_Item * it;
2289 it = create_tool_item(obj, icon_path, label, func, data);
2292 wd = elm_widget_data_get(obj);
2293 set_items_position(obj, it, NULL, EINA_TRUE);
2294 wd->items = eina_list_append(wd->items, it);
2300 * Prepend new tool item
2302 * @param obj The controlbar object
2303 * @param icon_path The icon path of item
2304 * @param label The label of item
2305 * @param func Callback function of item
2306 * @param data The data of callback function
2307 * @return The item of controlbar
2309 * @ingroup Controlbar
2311 EAPI Elm_Controlbar_Item * elm_controlbar_tool_item_prepend(Evas_Object *
2328 Elm_Controlbar_Item * it;
2329 Elm_Controlbar_Item * item;
2330 it = create_tool_item(obj, icon_path, label, func, data);
2333 wd = elm_widget_data_get(obj);
2334 item = eina_list_data_get(wd->items);
2335 set_items_position(obj, it, item, EINA_TRUE);
2336 wd->items = eina_list_prepend(wd->items, it);
2342 * Insert new tool item before given item
2344 * @param obj The controlbar object
2345 * @param before The given item
2346 * @param icon_path The icon path of item
2347 * @param label The label of item
2348 * @param func Callback function of item
2349 * @param data The data of callback function
2350 * @return The item of controlbar
2352 * @ingroup Controlbar
2354 EAPI Elm_Controlbar_Item *
2355 elm_controlbar_tool_item_insert_before(Evas_Object * obj,
2356 Elm_Controlbar_Item * before,
2357 const char *icon_path,
2359 void (*func) (void *data,
2365 Elm_Controlbar_Item * it;
2368 it = create_tool_item(obj, icon_path, label, func, data);
2371 wd = elm_widget_data_get(obj);
2372 set_items_position(obj, it, before, EINA_TRUE);
2373 wd->items = eina_list_prepend_relative(wd->items, it, before);
2379 * Insert new tool item after given item
2381 * @param obj The controlbar object
2382 * @param after The given item
2383 * @param icon_path The icon path of item
2384 * @param label The label of item
2385 * @param func Callback function of item
2386 * @param data The data of callback function
2387 * @return The item of controlbar
2389 * @ingroup Controlbar
2391 EAPI Elm_Controlbar_Item *
2392 elm_controlbar_tool_item_insert_after(Evas_Object * obj,
2393 Elm_Controlbar_Item * after,
2394 const char *icon_path,
2396 void (*func) (void *data,
2402 Elm_Controlbar_Item * it;
2403 Elm_Controlbar_Item * item;
2406 it = create_tool_item(obj, icon_path, label, func, data);
2409 wd = elm_widget_data_get(obj);
2410 item = elm_controlbar_item_next(after);
2411 set_items_position(obj, it, item, EINA_TRUE);
2412 wd->items = eina_list_append_relative(wd->items, it, after);
2418 * Append new object item
2420 * @param obj The controlbar object
2421 * @param obj_item The object of item
2422 * @param sel The number of sel occupied
2423 * @return The item of controlbar
2425 * @ingroup Controlbar
2427 EAPI Elm_Controlbar_Item * elm_controlbar_object_item_append(Evas_Object *
2434 Elm_Controlbar_Item * it;
2435 it = create_object_item(obj, obj_item, sel);
2438 wd = elm_widget_data_get(obj);
2439 set_items_position(obj, it, NULL, EINA_TRUE);
2440 wd->items = eina_list_append(wd->items, it);
2446 * Prepend new object item
2448 * @param obj The controlbar object
2449 * @param obj_item The object of item
2450 * @param sel The number of sel occupied
2451 * @return The item of controlbar
2453 * @ingroup Controlbar
2455 EAPI Elm_Controlbar_Item * elm_controlbar_object_item_prepend(Evas_Object *
2462 Elm_Controlbar_Item * it;
2463 Elm_Controlbar_Item * item;
2464 it = create_object_item(obj, obj_item, sel);
2467 wd = elm_widget_data_get(obj);
2468 item = eina_list_data_get(wd->items);
2469 set_items_position(obj, it, item, EINA_TRUE);
2470 wd->items = eina_list_prepend(wd->items, it);
2476 * Insert new object item before given item
2478 * @param obj The controlbar object
2479 * @param before The given item
2480 * @param obj_item The object of item
2481 * @param sel The number of sel occupied
2482 * @return The item of controlbar
2484 * @ingroup Controlbar
2486 EAPI Elm_Controlbar_Item *
2487 elm_controlbar_object_item_insert_before(Evas_Object * obj,
2488 Elm_Controlbar_Item * before,
2489 Evas_Object * obj_item, const int sel)
2492 Elm_Controlbar_Item * it;
2495 it = create_object_item(obj, obj_item, sel);
2498 wd = elm_widget_data_get(obj);
2499 set_items_position(obj, it, before, EINA_TRUE);
2500 wd->items = eina_list_prepend_relative(wd->items, it, before);
2506 * Insert new object item after given item
2508 * @param obj The controlbar object
2509 * @param after The given item
2510 * @param obj_item The object of item
2511 * @param sel The number of sel occupied
2512 * @return The item of controlbar
2514 * @ingroup Controlbar
2516 EAPI Elm_Controlbar_Item *
2517 elm_controlbar_object_item_insert_after(Evas_Object * obj,
2518 Elm_Controlbar_Item * after,
2519 Evas_Object * obj_item, const int sel)
2522 Elm_Controlbar_Item * it;
2523 Elm_Controlbar_Item * item;
2526 it = create_object_item(obj, obj_item, sel);
2529 wd = elm_widget_data_get(obj);
2530 item = elm_controlbar_item_next(after);
2531 set_items_position(obj, it, item, EINA_TRUE);
2532 wd->items = eina_list_append_relative(wd->items, it, after);
2538 * Delete item from controlbar
2540 * @param it The item of controlbar
2542 * @ingroup Controlbar
2545 elm_controlbar_item_del(Elm_Controlbar_Item * it)
2551 Elm_Controlbar_Item * item;
2559 if (it->obj == NULL)
2561 printf("Invalid argument: controlbar object is NULL\n");
2564 wd = elm_widget_data_get(it->obj);
2567 printf("Cannot get smart data\n");
2574 elm_table_unpack(wd->box, it->base);
2576 EINA_LIST_FOREACH(wd->items, l, item)
2580 if (item->order > it->order)
2582 elm_table_unpack(wd->box, item->base);
2584 elm_table_pack(wd->box, item->base, item->order - 1, 0,
2597 if (it->edit_item != NULL)
2599 elm_table_unpack(wd->edit_table, it->edit_item);
2600 EINA_LIST_FOREACH(wd->items, l, item)
2604 if (item->edit_item != NULL)
2606 elm_table_unpack(wd->edit_table, item->edit_item);
2607 elm_table_pack(wd->edit_table, item->edit_item,
2608 (i - 1) % 4, (i - 1) / 4, 1, 1);
2611 if (it == item && item->style != OBJECT)
2616 if (item->style != OBJECT)
2621 // delete item in list
2623 eina_stringshare_del(it->label);
2625 evas_object_del(it->icon);
2628 if (it->style != OBJECT)
2629 evas_object_del(it->base);
2632 evas_object_hide(it->base);
2636 //edje_object_part_unswallow(wd->view, it->view);
2637 if(it->selected) elm_layout_content_unset(wd->view, "elm.swallow.view");
2638 evas_object_hide(it->view);
2641 evas_object_del(it->edit_item);
2642 wd->items = eina_list_remove(wd->items, it);
2643 wd->num = wd->num - 1;
2648 * Select item in controlbar
2650 * @param it The item of controlbar
2652 * @ingroup Controlbar
2655 elm_controlbar_item_select(Elm_Controlbar_Item * it)
2657 if (it->obj == NULL)
2659 Widget_Data * wd = elm_widget_data_get(it->obj);
2669 * Get the icon of item
2671 * @param it The item of controlbar
2672 * @return The icon object
2674 * @ingroup Controlbar
2676 EAPI Evas_Object * elm_controlbar_item_icon_get(Elm_Controlbar_Item * it)
2682 * Get the label of item
2684 * @param it The item of controlbar
2685 * @return The label of item
2687 * @ingroup Controlbar
2690 elm_controlbar_item_label_get(Elm_Controlbar_Item * it)
2696 * Set the label of item
2698 * @param it The item of controlbar
2699 * @param label The label of item
2701 * @ingroup Controlbar
2704 elm_controlbar_item_label_set(Elm_Controlbar_Item * it, const char *label)
2708 edje_object_part_text_set(it->base, "elm.text", label);
2712 * Get the selected item.
2714 * @param obj The controlbar object
2715 * @return The item of controlbar
2717 * @ingroup Controlbar
2719 EAPI Elm_Controlbar_Item * elm_controlbar_selected_item_get(Evas_Object *
2724 Elm_Controlbar_Item * item;
2727 Widget_Data * wd = elm_widget_data_get(obj);
2728 if (!wd || !wd->items)
2730 EINA_LIST_FOREACH(wd->items, l, item)
2739 * Get the first item.
2741 * @param obj The controlbar object
2742 * @return The item of controlbar
2744 * @ingroup Controlbar
2746 EAPI Elm_Controlbar_Item * elm_controlbar_first_item_get(Evas_Object * obj)
2750 Widget_Data * wd = elm_widget_data_get(obj);
2751 if (!wd || !wd->items)
2753 return eina_list_data_get(wd->items);
2757 * Get the last item.
2759 * @param obj The controlbar object
2760 * @return The item of controlbar
2762 * @ingroup Controlbar
2764 EAPI Elm_Controlbar_Item * elm_controlbar_last_item_get(Evas_Object * obj)
2768 Widget_Data * wd = elm_widget_data_get(obj);
2769 if (!wd || !wd->items)
2771 return eina_list_data_get(eina_list_last(wd->items));
2777 * @param obj The controlbar object
2778 * @return The list of the items
2780 * @ingroup Controlbar
2782 EAPI Eina_List * elm_controlbar_items_get(Evas_Object * obj)
2786 Widget_Data * wd = elm_widget_data_get(obj);
2787 if (!wd || !wd->items)
2793 * Get the previous item.
2795 * @param it The item of controlbar
2796 * @return The previous item of the parameter item
2798 * @ingroup Controlbar
2800 EAPI Elm_Controlbar_Item * elm_controlbar_item_prev(Elm_Controlbar_Item *
2805 Elm_Controlbar_Item * item;
2806 if (it->obj == NULL)
2808 Widget_Data * wd = elm_widget_data_get(it->obj);
2809 if (!wd || !wd->items)
2811 EINA_LIST_FOREACH(wd->items, l, item)
2815 l = eina_list_prev(l);
2818 return eina_list_data_get(l);
2825 * Get the next item.
2827 * @param obj The controlbar object
2828 * @return The next item of the parameter item
2830 * @ingroup Controlbar
2832 EAPI Elm_Controlbar_Item * elm_controlbar_item_next(Elm_Controlbar_Item *
2837 Elm_Controlbar_Item * item;
2838 if (it->obj == NULL)
2840 Widget_Data * wd = elm_widget_data_get(it->obj);
2841 if (!wd || !wd->items)
2843 EINA_LIST_FOREACH(wd->items, l, item)
2847 l = eina_list_next(l);
2850 return eina_list_data_get(l);
2857 * Start edit mode(Don't use this API)
2859 * @param The controlbar object
2861 * @ingroup Controlbar
2864 elm_controlbar_edit_start(Evas_Object * obj)
2866 printf("\n==================================\n");
2867 printf("%s\n", __func__);
2868 printf("==================================\n");
2869 printf("This API is just for test.\n");
2870 printf("Please don't use it!!\n");
2871 printf("Thank you.\n");
2872 printf("==================================\n");
2877 fprintf(stderr, "Invalid argument: controlbar object is NULL\n");
2880 wd = elm_widget_data_get(obj);
2883 fprintf(stderr, "Cannot get smart data\n");
2886 edje_object_signal_emit(wd->edit_box, "elm,state,show,edit_box", "elm");
2887 wd->edit_mode = EINA_TRUE;
2893 * @param it The item of controlbar
2894 * @param bar true or false
2896 * @ingroup Controlbar
2899 elm_controlbar_item_visible_set(Elm_Controlbar_Item * it, Eina_Bool visible)
2901 Elm_Controlbar_Item *item;
2902 Eina_Bool check = EINA_TRUE;
2903 if (it->obj == NULL)
2905 Widget_Data * wd = elm_widget_data_get(it->obj);
2906 if (!wd || !wd->items)
2910 if (check == visible)
2914 item = elm_controlbar_last_item_get(it->obj);
2915 while(!elm_controlbar_item_visible_get(item)){
2916 item = elm_controlbar_item_prev(item);
2918 item_insert_in_bar(it, item->order + 1);
2922 item_delete_in_bar(it);
2924 wd->items = eina_list_sort(wd->items, eina_list_count(wd->items), sort_cb);
2925 _sizing_eval(it->obj);
2930 * Get the result which or not item is in bar
2932 * @param it The item of controlbar
2933 * @return true or false
2935 * @ingroup Controlbar
2938 elm_controlbar_item_visible_get(Elm_Controlbar_Item * it)
2940 if (it->obj == NULL)
2942 Widget_Data * wd = elm_widget_data_get(it->obj);
2955 * @param it The item of controlbar
2956 * @param bar true or false
2958 * @ingroup Controlbar
2961 elm_controlbar_item_editable_set(Elm_Controlbar_Item * it, Eina_Bool editable)
2963 Evas_Object * color;
2966 it->editable = editable;
2968 (Evas_Object *) edje_object_part_object_get(_EDJ(it->edit_item),
2969 "elm.edit.item.color");
2971 evas_object_color_get(color, &r, &g, &b, &a);
2972 evas_object_color_set(it->edit_item, r, g, b, a);
2976 * Set the default view(Don't use this API)
2978 * @param obj The controlbar object
2979 * @param view The default view
2981 * @ingroup Controlbar
2984 elm_controlbar_view_set(Evas_Object * obj, Evas_Object * view)
2986 printf("\n==================================\n");
2987 printf("%s\n", __func__);
2988 printf("==================================\n");
2989 printf("This API is just for test.\n");
2990 printf("Please don't use it!!\n");
2991 printf("Thank you.\n");
2992 printf("==================================\n");
2997 fprintf(stderr, "Invalid argument: controlbar object is NULL\n");
3000 wd = elm_widget_data_get(obj);
3003 fprintf(stderr, "Cannot get smart data\n");
3006 wd->view_content = view;
3007 //edje_object_part_swallow(wd->view, "elm.swallow.view", wd->view_content);
3008 elm_layout_content_set(wd->view, "elm.swallow.view", wd->view_content);
3012 * Set the view of the item
3014 * @param it The item of controlbar
3015 * @param view The view for the item
3017 * @ingroup Controlbar
3020 elm_controlbar_item_view_set(Elm_Controlbar_Item *it, Evas_Object * view)
3026 * Set the mode of the controlbar
3028 * @param obj The object of the controlbar
3029 * @param mode The mode of the controlbar
3031 * @ingroup Controlbar
3034 elm_controlbar_mode_set(Evas_Object *obj, int mode)
3039 fprintf(stderr, "Invalid argument: controlbar object is NULL\n");
3042 wd = elm_widget_data_get(obj);
3045 fprintf(stderr, "Cannot get smart data\n");
3049 if(wd->mode == mode) return;
3053 case ELM_CONTROLBAR_MODE_DEFAULT:
3054 edje_object_signal_emit(wd->edje, "elm,state,default", "elm");
3056 case ELM_CONTROLBAR_MODE_TRANSLUCENCE:
3057 edje_object_signal_emit(wd->edje, "elm,state,translucence", "elm");
3059 case ELM_CONTROLBAR_MODE_TRANSPARENCY:
3060 edje_object_signal_emit(wd->edje, "elm,state,transparency", "elm");
3062 case ELM_CONTROLBAR_MODE_LARGE:
3063 edje_object_signal_emit(wd->edje, "elm,state,large", "elm");
3065 case ELM_CONTROLBAR_MODE_SMALL:
3066 edje_object_signal_emit(wd->edje, "elm,state,small", "elm");
3075 * Set auto-align mode of the controlbar(It's not prepared yet)
3076 * If you set the auto-align and add items more than 5,
3077 * the "more" item will be made and the items more than 5 will be unvisible.
3079 * @param obj The object of the controlbar
3080 * @param auto_align The dicision that the controlbar use the auto-align
3082 * @ingroup Controlbar
3085 elm_controlbar_item_auto_align_set(Evas_Object *obj, Eina_Bool auto_align)
3088 Elm_Controlbar_Item *item;
3093 fprintf(stderr, "Invalid argument: controlbar object is NULL\n");
3096 wd = elm_widget_data_get(obj);
3099 fprintf(stderr, "Cannot get smart data\n");
3103 if(wd->auto_align == auto_align) return;
3107 if(check_bar_item_number(wd) >= 5 && !wd->more_item)
3110 EINA_LIST_FOREACH(wd->items, l, item)
3112 if(elm_controlbar_item_visible_get(item))
3115 item_delete_in_bar(item);
3118 item = elm_controlbar_last_item_get(obj);
3119 while(!elm_controlbar_item_visible_get(item)){
3120 item = elm_controlbar_item_prev(item);
3122 create_more_item(wd, item->style);
3130 if(wd->more_item->view)
3131 evas_object_del(wd->more_item->view);
3132 wd->items = eina_list_remove(wd->items, wd->more_item);
3133 eina_stringshare_del(wd->more_item->label);
3134 if (wd->more_item->icon)
3135 evas_object_del(wd->more_item->icon);
3136 if (wd->more_item->base)
3137 evas_object_del(wd->more_item->base);
3138 if (wd->more_item->edit_item)
3139 evas_object_del(wd->more_item->edit_item);
3140 free(wd->more_item);
3141 wd->more_item = NULL;
3143 // make all item is visible
3145 EINA_LIST_FOREACH(wd->items, l, item)
3147 if(!elm_controlbar_item_visible_get(item))
3148 item_insert_in_bar(item, i);
3153 wd->auto_align = auto_align;
3158 init_animation(void *data)
3161 Elm_Controlbar_Item * item;
3162 Widget_Data * wd = (Widget_Data *)data;
3164 wd->visible_items = eina_list_free(wd->visible_items);
3165 EINA_LIST_FOREACH(wd->items, l, item)
3169 wd->visible_items = eina_list_append(wd->visible_items, item->base);
3174 wd->ani_func(wd->ani_data, wd->object, wd->visible_items);
3176 return EXIT_SUCCESS;
3181 * Set the animation of the controlbar(Don't use this API)
3183 * @param obj The object of the controlbar
3184 * @param func The function for start animation
3185 * @param data The data for function
3187 * @ingroup Controlbar
3190 elm_controlbar_animation_set(Evas_Object *obj, void (*func) (void *data, Evas_Object *obj, void *event_info), void *data)
3192 printf("\n==================================\n");
3193 printf("%s\n", __func__);
3194 printf("==================================\n");
3195 printf("This API is just for test.\n");
3196 printf("Please don't use it!!\n");
3197 printf("Thank you.\n");
3198 printf("==================================\n");
3203 fprintf(stderr, "Invalid argument: controlbar object is NULL\n");
3206 wd = elm_widget_data_get(obj);
3209 fprintf(stderr, "Cannot get smart data\n");
3215 wd->init_animation = EINA_TRUE;
3217 wd->ani_func = func;
3218 wd->ani_data = data;
3220 ecore_idler_add(init_animation, wd);
3225 * Set the animation of the controlbar(Don't use this API)
3227 * @param obj The object of the controlbar
3228 * @param auto_animation The dicision that items move automatically
3229 * @param selected_animation The dicision that the selected item move automatically
3231 * @ingroup Controlbar
3234 elm_controlbar_item_animation_set(Evas_Object *obj, Eina_Bool auto_animation, Eina_Bool selected_animation)
3236 printf("\n==================================\n");
3237 printf("%s\n", __func__);
3238 printf("==================================\n");
3239 printf("This API is just for test.\n");
3240 printf("Please don't use it!!\n");
3241 printf("Thank you.\n");
3242 printf("==================================\n");
3247 fprintf(stderr, "Invalid argument: controlbar object is NULL\n");
3250 wd = elm_widget_data_get(obj);
3253 fprintf(stderr, "Cannot get smart data\n");
3257 if(auto_animation && !wd->effect_timer)
3259 wd->effect_timer = ecore_timer_add(1, item_animation_effect, wd);
3263 if(wd->effect_timer) ecore_timer_del(wd->effect_timer);
3264 wd->effect_timer = NULL;
3267 wd->selected_animation = selected_animation;