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);
98 typedef struct _Animation_Data Animation_Data;
100 struct _Animation_Data
111 unsigned int start_time;
113 void (*func) (void *data, Evas_Object * obj);
115 Ecore_Animator * timer;
120 static void selected_box(Elm_Controlbar_Item * it);
121 static int pressed_box(Elm_Controlbar_Item * it);
122 static void object_color_set(Evas_Object *ly, const char *color_part, const char *obj_part);
123 static void edit_item_up_cb(void *data, Evas *evas, Evas_Object *obj, void *event_info);
124 static void edit_item_move_cb(void *data, Evas *evas, Evas_Object *obj, void *event_info);
125 static void bar_item_up_cb(void *data, Evas *evas, Evas_Object *obj, void *event_info);
126 static void bar_item_move_cb(void *data, Evas *evas, Evas_Object *obj, void *event_info);
128 /////////////////////////
130 ////////////////////////
133 print_all_items(Widget_Data *wd)
136 Elm_Controlbar_Item * item;
138 EINA_LIST_FOREACH(wd->items, l, item)
140 printf("item label : %s order : %d address : %p\n", item->label, item->order, item);
144 ///////////////////////////////////////////////////////////////////
146 // Smart Object basic function
148 ////////////////////////////////////////////////////////////////////
151 _controlbar_move(void *data, Evas_Object * obj)
157 wd = elm_widget_data_get((Evas_Object *) data);
160 evas_object_geometry_get(wd->edje, &x, &y, NULL, NULL);
163 evas_object_move(wd->edje, x, y);
164 evas_object_move(wd->view, x, y);
165 evas_object_geometry_get(wd->parent, &x, &y, NULL, NULL);
166 evas_object_move(wd->edit_box, x, y);
167 evas_object_move(wd->event_box, x, y);
171 _controlbar_resize(void *data, Evas_Object * obj)
174 Evas_Coord y, y_, w, h, height;
177 wd = elm_widget_data_get((Evas_Object *) data);
180 evas_object_geometry_get(wd->edje, NULL, &y, &w, &h);
183 evas_object_resize(wd->edje, w, h);
184 evas_object_geometry_get(edje_object_part_object_get(wd->edje, "bg_image"),
185 NULL, NULL, NULL, &height);
186 evas_object_resize(wd->view, w, h - height + 1);
188 evas_object_geometry_get(wd->parent, NULL, &y_, NULL, NULL);
189 //evas_object_resize(wd->edit_box, w, h);
190 evas_object_resize(wd->edit_box, w, h + y - y_);
191 //evas_object_resize(wd->event_box, w, h);
192 evas_object_resize(wd->event_box, w, h + y - y_);
196 _controlbar_object_move(void *data, Evas * e, Evas_Object * obj,
199 _controlbar_move(data, obj);
203 _controlbar_object_resize(void *data, Evas * e, Evas_Object * obj,
206 _controlbar_resize(data, obj);
210 _controlbar_object_show(void *data, Evas * e, Evas_Object * obj,
216 wd = elm_widget_data_get((Evas_Object *) data);
219 evas_object_show(wd->view);
220 evas_object_show(wd->edit_box);
221 evas_object_show(wd->edje);
222 evas_object_show(wd->box);
223 evas_object_show(wd->event_box);
227 _controlbar_object_hide(void *data, Evas * e, Evas_Object * obj,
233 wd = elm_widget_data_get((Evas_Object *) data);
236 evas_object_hide(wd->view);
237 evas_object_hide(wd->edit_box);
238 evas_object_hide(wd->edje);
239 evas_object_hide(wd->box);
240 evas_object_hide(wd->event_box);
244 _del_hook(Evas_Object * obj)
246 Widget_Data * wd = elm_widget_data_get(obj);
247 Elm_Controlbar_Item * item;
248 Evas_Object * content;
252 EINA_LIST_FREE(wd->items, item)
254 if(item == wd->more_item)
256 evas_object_del(item->view);
257 eina_stringshare_del(item->label);
259 evas_object_del(item->icon);
261 evas_object_del(item->base);
263 evas_object_del(item->edit_item);
269 content = elm_layout_content_unset(wd->view, "elm.swallow.view");
270 evas_object_hide(content);
271 evas_object_del(wd->view);
276 evas_object_del(wd->edit_box);
281 evas_object_del(wd->navigation);
282 wd->navigation = NULL;
286 evas_object_del(wd->edje);
289 if (wd->selected_box)
291 evas_object_del(wd->selected_box);
296 evas_object_del(wd->box);
301 evas_object_del(wd->event_box);
302 wd->event_box = NULL;
304 if (wd->effect_timer)
306 ecore_timer_del(wd->effect_timer);
307 wd->effect_timer = NULL;
315 _theme_hook(Evas_Object * obj)
319 Elm_Controlbar_Item * item;
323 Widget_Data * wd = elm_widget_data_get(obj);
326 _elm_theme_object_set(obj, wd->edje, "controlbar", "base",
327 elm_widget_style_get(obj));
328 elm_layout_theme_set(wd->view, "controlbar", "view", elm_widget_style_get(obj));
329 //_elm_theme_object_set(obj, wd->view, "controlbar", "view",
330 // elm_widget_style_get(obj));
331 _elm_theme_object_set(obj, wd->edit_box, "controlbar", "edit_box",
332 elm_widget_style_get(obj));
333 EINA_LIST_FOREACH(wd->items, l, item)
335 if (item->style != OBJECT)
337 elm_layout_theme_set(item->base, "controlbar", "item",
338 elm_widget_style_get(obj));
339 object_color_set(item->base, "elm.item.default.color", "elm.swallow.icon");
340 elm_layout_theme_set(item->edit_item, "controlbar", "item",
341 elm_widget_style_get(obj));
346 edje_object_part_object_get(_EDJ(item->edit_item),
347 "elm.item.uneditable.color");
349 evas_object_color_get(color, &r, &g, &b, &a);
350 evas_object_color_set(item->edit_item, r, g, b, a);
354 edje_object_part_text_set(_EDJ(item->base), "elm.text",
356 edje_object_part_text_set(_EDJ(item->edit_item), "elm.text",
359 if (item->label && item->icon)
361 edje_object_signal_emit(_EDJ(item->base),
362 "elm,state,icon_text", "elm");
363 edje_object_signal_emit(_EDJ(item->edit_item),
364 "elm,state,icon_text", "elm");
368 printf("call selected_box 2\n");
376 _sub_del(void *data, Evas_Object * obj, void *event_info)
378 Widget_Data * wd = elm_widget_data_get(obj);
380 //Evas_Object *sub = event_info;
385 * if (sub == wd->icon)
387 * edje_object_signal_emit(wd->btn, "elm,state,icon,hidden", "elm");
388 * evas_object_event_callback_del_full(sub, EVAS_CALLBACK_CHANGED_SIZE_HINTS,
389 * _changed_size_hints, obj);
391 * edje_object_message_signal_process(wd->btn);
398 _sizing_eval(Evas_Object * obj)
400 Widget_Data * wd = elm_widget_data_get(obj);
403 _controlbar_move(obj, obj);
404 _controlbar_resize(obj, obj);
407 /////////////////////////////////////////////////////////////
409 // animation function
411 /////////////////////////////////////////////////////////////
416 struct timeval timev;
418 gettimeofday(&timev, NULL);
419 return ((timev.tv_sec * 1000) + ((timev.tv_usec) / 1000));
423 set_evas_map(Evas_Object * obj, Evas_Coord x, Evas_Coord y, Evas_Coord w,
430 Evas_Map * map = evas_map_new(4);
433 evas_map_smooth_set(map, EINA_TRUE);
434 evas_map_util_points_populate_from_object_full(map, obj, 0);
435 evas_object_map_enable_set(obj, EINA_TRUE);
436 evas_map_util_3d_perspective(map, x + w / 2, y + h / 2, 0, w * 10);
437 evas_map_util_points_populate_from_geometry(map, x, y, w, h, 0);
438 evas_object_map_set(obj, map);
443 move_evas_map(void *data)
453 Animation_Data * ad = (Animation_Data *) data;
454 t = ELM_MAX(0.0, current_time_get() - ad->start_time) / 1000;
455 dx = ad->tx - ad->fx;
456 dy = ad->ty - ad->fy;
457 dw = ad->tw - ad->fw;
458 dh = ad->th - ad->fh;
461 x = (1 * sin((t / ad->time) * (M_PI / 2)) * dx);
462 y = (1 * sin((t / ad->time) * (M_PI / 2)) * dy);
463 w = (1 * sin((t / ad->time) * (M_PI / 2)) * dw);
464 h = (1 * sin((t / ad->time) * (M_PI / 2)) * dh);
477 if (x == dx && y == dy && w == dw && h == dh)
479 ecore_animator_del(ad->timer);
481 set_evas_map(ad->obj, px, py, pw, ph);
482 if (ad->func != NULL)
483 ad->func(ad->data, ad->obj);
484 return ECORE_CALLBACK_CANCEL;
488 set_evas_map(ad->obj, px, py, pw, ph);
490 return ECORE_CALLBACK_RENEW;
495 move_evas_object(void *data)
505 Animation_Data * ad = (Animation_Data *) data;
506 t = ELM_MAX(0.0, current_time_get() - ad->start_time) / 1000;
507 dx = ad->tx - ad->fx;
508 dy = ad->ty - ad->fy;
509 dw = ad->tw - ad->fw;
510 dh = ad->th - ad->fh;
513 x = (1 * sin((t / ad->time) * (M_PI / 2)) * dx);
514 y = (1 * sin((t / ad->time) * (M_PI / 2)) * dy);
515 w = (1 * sin((t / ad->time) * (M_PI / 2)) * dw);
516 h = (1 * sin((t / ad->time) * (M_PI / 2)) * dh);
529 if (x == dx && y == dy && w == dw && h == dh)
531 ecore_animator_del(ad->timer);
533 evas_object_move(ad->obj, px, py);
534 evas_object_resize(ad->obj, pw, ph);
535 evas_object_show(ad->obj);
536 if (ad->func != NULL)
537 ad->func(ad->data, ad->obj);
538 return ECORE_CALLBACK_CANCEL;
542 evas_object_move(ad->obj, px, py);
543 evas_object_resize(ad->obj, pw, ph);
544 evas_object_show(ad->obj);
546 return ECORE_CALLBACK_RENEW;
550 move_fade_out_object(void *data)
554 int dx, dy, dw, dh, da;
556 int px, py, pw, ph, pa;
562 Animation_Data * ad = (Animation_Data *) data;
563 t = ELM_MAX(0.0, current_time_get() - ad->start_time) / 1000;
564 dx = ad->tx - ad->fx;
565 dy = ad->ty - ad->fy;
566 dw = ad->tw - ad->fw;
567 dh = ad->th - ad->fh;
571 x = (1 * sin((t / ad->time) * (M_PI / 2)) * dx);
572 y = (1 * sin((t / ad->time) * (M_PI / 2)) * dy);
573 w = (1 * sin((t / ad->time) * (M_PI / 2)) * dw);
574 h = (1 * sin((t / ad->time) * (M_PI / 2)) * dh);
575 a = (1 * sin((t / ad->time) * (M_PI / 2)) * da);
590 if (x == dx && y == dy && w == dw && h == dh)
592 ecore_animator_del(ad->timer);
594 evas_object_move(ad->obj, px, py);
595 //evas_object_resize(ad->obj, 480, 600);
596 evas_object_resize(ad->obj, pw, ph);
597 evas_object_color_get(ad->obj, &r, &g, &b, &a);
598 evas_object_color_set(ad->obj, r, g, b, pa);
599 evas_object_show(ad->obj);
600 if (ad->func != NULL)
601 ad->func(ad->data, ad->obj);
602 return ECORE_CALLBACK_CANCEL;
606 evas_object_move(ad->obj, px, py);
607 //evas_object_resize(ad->obj, 480, 600);
608 evas_object_resize(ad->obj, pw, ph);
609 evas_object_color_get(ad->obj, &r, &g, &b, &a);
610 evas_object_color_set(ad->obj, r, g, b, pa);
611 evas_object_show(ad->obj);
613 return ECORE_CALLBACK_RENEW;
617 move_fade_in_object(void *data)
621 int dx, dy, dw, dh, da;
623 int px, py, pw, ph, pa;
629 Animation_Data * ad = (Animation_Data *) data;
630 t = ELM_MAX(0.0, current_time_get() - ad->start_time) / 1000;
631 dx = ad->tx - ad->fx;
632 dy = ad->ty - ad->fy;
633 dw = ad->tw - ad->fw;
634 dh = ad->th - ad->fh;
638 x = (1 * sin((t / ad->time) * (M_PI / 2)) * dx);
639 y = (1 * sin((t / ad->time) * (M_PI / 2)) * dy);
640 w = (1 * sin((t / ad->time) * (M_PI / 2)) * dw);
641 h = (1 * sin((t / ad->time) * (M_PI / 2)) * dh);
642 a = (1 * sin((t / ad->time) * (M_PI / 2)) * da);
657 if (x == dx && y == dy && w == dw && h == dh)
659 ecore_animator_del(ad->timer);
661 evas_object_move(ad->obj, px, py);
662 //evas_object_resize(ad->obj, 480, 600);
663 evas_object_resize(ad->obj, pw, ph);
664 evas_object_color_get(ad->obj, &r, &g, &b, &a);
665 evas_object_color_set(ad->obj, r, g, b, pa);
666 evas_object_show(ad->obj);
667 if (ad->func != NULL)
668 ad->func(ad->data, ad->obj);
669 return ECORE_CALLBACK_CANCEL;
673 evas_object_move(ad->obj, px, py);
674 //evas_object_resize(ad->obj, 480, 600);
675 evas_object_resize(ad->obj, pw, ph);
676 evas_object_color_get(ad->obj, &r, &g, &b, &a);
677 evas_object_color_set(ad->obj, r, g, b, pa);
678 evas_object_show(ad->obj);
680 return ECORE_CALLBACK_RENEW;
684 move_object_with_animation(Evas_Object * obj, Evas_Coord x, Evas_Coord y,
685 Evas_Coord w, Evas_Coord h, Evas_Coord x_,
686 Evas_Coord y_, Evas_Coord w_, Evas_Coord h_,
687 double time, Eina_Bool (*mv_func) (void *data),
688 void (*func) (void *data,
689 Evas_Object * obj), void *data)
691 Animation_Data * ad = (Animation_Data *) malloc(sizeof(Animation_Data));
701 ad->start_time = current_time_get();
705 ad->timer = ecore_animator_add(mv_func, ad);
710 item_animation_effect(void *data)
712 Widget_Data *wd = (Widget_Data *)data;
714 Elm_Controlbar_Item * item;
719 EINA_LIST_FOREACH(wd->items, l, item)
722 // printf("rand :: %d\n", rand);
723 if(rand > 65 && item->order > 0)
729 edje_object_signal_emit(_EDJ(item->base), "elm,animation,pop", "elm");
730 return ECORE_CALLBACK_RENEW;
732 edje_object_signal_emit(_EDJ(item->base), "elm,animation,vibration", "elm");
733 return ECORE_CALLBACK_RENEW;
735 edje_object_signal_emit(_EDJ(item->base), "elm,animation,jump", "elm");
736 return ECORE_CALLBACK_RENEW;
738 return ECORE_CALLBACK_RENEW;
743 return ECORE_CALLBACK_RENEW;
746 /////////////////////////////////////////////////////////////
750 /////////////////////////////////////////////////////////////
753 sort_cb(const void *d1, const void *d2)
755 Elm_Controlbar_Item * item1, *item2;
756 item1 = (Elm_Controlbar_Item *) d1;
757 item2 = (Elm_Controlbar_Item *) d2;
758 if (item1->order <= 0)
760 if (item2->order <= 0)
762 return item1->order > item2->order ? 1 : -1;
766 sort_reverse_cb(const void *d1, const void *d2)
768 Elm_Controlbar_Item * item1, *item2;
769 item1 = (Elm_Controlbar_Item *) d1;
770 item2 = (Elm_Controlbar_Item *) d2;
771 if (item1->order <= 0)
773 if (item2->order <= 0)
775 return item1->order > item2->order ? -1 : 1;
779 done_button_cb(void *data, Evas_Object * obj, void *event_info)
781 Widget_Data * wd = (Widget_Data *) data;
783 wd->items = eina_list_sort(wd->items, eina_list_count(wd->items), sort_cb);
785 evas_object_smart_callback_call(wd->object, "edit,end", wd->items);
787 edje_object_signal_emit(wd->edit_box, "elm,state,hide,edit_box", "elm");
788 wd->edit_mode = EINA_FALSE;
791 ///////////////////////////////////////////////////////////////////
793 // basic utility function
795 ////////////////////////////////////////////////////////////////////
798 check_bar_item_number(Widget_Data *wd)
801 Elm_Controlbar_Item * item;
804 EINA_LIST_FOREACH(wd->items, l, item)
806 if(item->order > 0) num++;
813 item_insert_in_bar(Elm_Controlbar_Item * it, int order)
817 Elm_Controlbar_Item * item;
818 Widget_Data * wd = elm_widget_data_get(it->obj);
821 if(order == 0) return;
823 EINA_LIST_FOREACH(wd->items, l, item)
825 if (item->order == order && item != it)
830 EINA_LIST_FOREACH(wd->items, l, item)
833 elm_table_unpack(wd->box, item->base);
835 EINA_LIST_FOREACH(wd->items, l, item)
839 if (item->order >= order)
841 elm_table_pack(wd->box, item->base, item->order - 1, 0, 1, 1);
842 evas_object_show(item->base);
847 elm_table_pack(wd->box, it->base, it->order - 1, 0, 1, 1);
848 evas_object_show(it->base);
852 item_delete_in_bar(Elm_Controlbar_Item * it)
855 Elm_Controlbar_Item * item;
856 Widget_Data * wd = elm_widget_data_get(it->obj);
859 EINA_LIST_FOREACH(wd->items, l, item)
865 elm_table_unpack(wd->box, it->base);
866 evas_object_hide(it->base);
871 EINA_LIST_FOREACH(wd->items, l, item)
876 elm_table_unpack(wd->box, item->base);
877 elm_table_pack(wd->box, item->base, item->order - 1, 0, 1, 1);
884 item_exchange_animation_cb(void *data, Evas_Object * obj)
886 Widget_Data * wd = (Widget_Data *) data;
888 if (wd->animating < 0)
890 printf("animation error\n");
893 evas_object_map_enable_set(obj, EINA_FALSE);
897 item_exchange_in_bar(Elm_Controlbar_Item * it1, Elm_Controlbar_Item * it2)
901 Evas_Coord x, y, w, h;
902 Evas_Coord x_, y_, w_, h_;
903 Widget_Data * wd = elm_widget_data_get(it1->obj);
904 evas_object_geometry_get(wd->moving_item->edit_item, &x, &y, &w, &h);
905 set_evas_map(wd->moving_obj, (wd->x + wd->w / 2), (wd->y + wd->h / 2), 0,
907 evas_object_geometry_get(it1->base, &x, &y, &w, &h);
908 evas_object_geometry_get(it2->base, &x_, &y_, &w_, &h_);
910 move_object_with_animation(it1->base, x, y, w, h, x_, y_, w_, h_, 0.25,
911 move_evas_map, item_exchange_animation_cb, wd);
913 move_object_with_animation(it2->base, x_, y_, w_, h_, x, y, w, h, 0.25,
914 move_evas_map, item_exchange_animation_cb, wd);
915 elm_table_unpack(wd->box, it1->base);
916 elm_table_unpack(wd->box, it2->base);
918 it1->order = it2->order;
920 elm_table_pack(wd->box, it1->base, it1->order - 1, 0, 1, 1);
921 elm_table_pack(wd->box, it2->base, it2->order - 1, 0, 1, 1);
925 item_change_animation_cb(void *data, Evas_Object * obj)
927 Evas_Coord x, y, w, h;
928 Widget_Data * wd = (Widget_Data *) data;
930 if (wd->animating < 0)
932 printf("animation error\n");
935 evas_object_map_enable_set(obj, EINA_FALSE);
936 evas_object_geometry_get(obj, &x, &y, &w, &h);
937 set_evas_map(obj, x, y, 0, 0);
938 evas_object_move(obj, -1000, -1000);
939 evas_object_geometry_get(wd->moving_item->base, &x, &y, &w, &h);
940 evas_object_move(wd->moving_obj, -1000, -1000);
941 evas_object_del(wd->moving_obj);
945 item_change_in_bar(Elm_Controlbar_Item * it)
947 Evas_Coord x, y, w, h;
948 Evas_Coord x_, y_, w_, h_;
949 Widget_Data * wd = elm_widget_data_get(it->obj);
952 if (wd->moving_item == NULL)
954 evas_object_geometry_get(wd->moving_item->edit_item, &x, &y, &w, &h);
955 set_evas_map(wd->moving_obj, x, y, w, h);
956 elm_table_unpack(wd->box, it->base);
957 wd->moving_item->order = it->order;
959 elm_table_pack(wd->box, wd->moving_item->base, wd->moving_item->order - 1,
961 evas_object_show(wd->moving_item->base);
962 evas_render_updates_free(evas_render_updates
963 (evas_object_evas_get(wd->moving_item->base)));
964 evas_object_geometry_get(it->base, &x, &y, &w, &h);
965 evas_object_geometry_get(it->edit_item, &x_, &y_, &w_, &h_);
967 move_object_with_animation(it->base, x, y, w, h, x_, y_, w_, h_, 0.25,
968 move_evas_map, item_change_animation_cb, wd);
969 evas_object_geometry_get(wd->moving_item->base, &x, &y, &w, &h);
970 set_evas_map(wd->moving_item->base, x, y, w, h);
974 hide_selected_box(void *data)
976 Evas_Object *selected_box = (Evas_Object *)data;
978 printf("hide selected box\n");
979 evas_object_hide(selected_box);
981 return ECORE_CALLBACK_CANCEL;
985 object_color_set(Evas_Object *ly, const char *color_part, const char *obj_part)
991 (Evas_Object *) edje_object_part_object_get(_EDJ(ly), color_part);
993 evas_object_color_get(color, &r, &g, &b, &a);
995 edje_object_part_swallow_get(_EDJ(ly), obj_part);
996 evas_object_color_set(color, r, g, b, a);
1000 _end_selected_box(void *data, Evas_Object *obj)
1002 Widget_Data * wd = (Widget_Data *)data;
1005 edje_object_signal_emit(_EDJ(wd->cur_item->base), "elm,state,selected", "elm");
1006 // item animation effect
1007 if(wd->selected_animation)
1015 edje_object_signal_emit(_EDJ(wd->cur_item->base), "elm,animation,pop", "elm");
1018 edje_object_signal_emit(_EDJ(wd->cur_item->base), "elm,animation,vibration", "elm");
1021 edje_object_signal_emit(_EDJ(wd->cur_item->base), "elm,animation,jump", "elm");
1029 if (wd->animating < 0)
1031 printf("animation error\n");
1035 ecore_idler_add(hide_selected_box, wd->selected_box);
1039 move_selected_box(Widget_Data *wd, Elm_Controlbar_Item * fit, Elm_Controlbar_Item * tit)
1041 Evas_Coord fx, fy, fw, fh, tx, ty, tw, th;
1042 Evas_Object *from, *to;
1044 if(fit->order <= 0 && wd->auto_align)
1045 fit = wd->more_item;
1047 from = (Evas_Object *)edje_object_part_object_get(_EDJ(fit->base), "bg_img");
1048 evas_object_geometry_get(from, &fx, &fy, &fw, &fh);
1050 to = (Evas_Object *)edje_object_part_object_get(_EDJ(tit->base), "bg_img");
1051 evas_object_geometry_get(to, &tx, &ty, &tw, &th);
1053 printf("unselected all items\n");
1054 edje_object_signal_emit(_EDJ(wd->pre_item->base), "elm,state,unselected", "elm");
1055 edje_object_signal_emit(_EDJ(wd->cur_item->base), "elm,state,unselected", "elm");
1058 move_object_with_animation(wd->selected_box, fx, fy, fw, fh, tx, ty, tw, th,
1059 0.3, move_evas_object, _end_selected_box, wd);
1063 end_selected_box(void *data, Evas_Object *obj)
1065 Widget_Data * wd = (Widget_Data *)data;
1067 if(wd->pre_item) evas_object_hide(wd->pre_item->view);
1069 elm_layout_content_set(wd->view, "elm.swallow.view", obj);
1071 evas_object_show(obj);
1075 view_animation_push(Widget_Data *wd, Evas_Object *pre, Evas_Object *cur, void *data)
1077 Evas_Coord x, y, w, h;
1079 evas_object_geometry_get(pre, &x, &y, &w, &h);
1080 move_object_with_animation(pre, x, y, w, h, x+20, y, w, h, 0.5, move_fade_out_object, NULL, NULL);
1081 move_object_with_animation(cur, x+120, y, w, h, x, y, w, h, 0.5, move_fade_in_object, end_selected_box, wd);
1085 view_animation_down(Widget_Data *wd, Evas_Object *pre, Evas_Object *cur, void *data)
1087 Evas_Coord x, y, w, h;
1089 evas_object_geometry_get(pre, &x, &y, &w, &h);
1091 move_object_with_animation(cur, x, h, w, h, x, h, w, h, 0.5, move_evas_object, end_selected_box, wd);
1092 evas_object_raise(pre);
1093 move_object_with_animation(pre, x, y, w, h, x, h, w, 0, 0.5, move_evas_map, NULL, NULL);
1097 selected_box(Elm_Controlbar_Item * it)
1099 Widget_Data * wd = elm_widget_data_get(it->obj);
1101 Elm_Controlbar_Item * item, *fit = NULL;
1102 Evas_Object * content;
1104 if(wd->animating) return;
1108 printf("%s selected\n", it->label);
1109 if(it->style == TABBAR){
1111 content = elm_layout_content_unset(wd->view, "elm.swallow.view");
1112 EINA_LIST_FOREACH(wd->items, l, item){
1113 if(item->selected) {
1117 item->selected = EINA_FALSE;
1119 it->selected = EINA_TRUE;
1120 evas_object_smart_callback_call(it->obj, "view,change,before", it);
1121 object_color_set(it->base, "elm.tabbar.selected.color", "elm.swallow.icon");
1123 if(fit != NULL && fit != it)
1124 move_selected_box(wd, fit, it);
1126 edje_object_signal_emit(_EDJ(it->base), "elm,state,selected", "elm");
1129 if(fit != NULL && fit != it)
1131 //view_animation_down(wd, fit->view, it->view, NULL);
1132 view_animation_push(wd, fit->view, it->view, NULL);
1133 //evas_object_hide(content);
1135 // evas_object_geometry_get(fit->view, &x, &y, &w, &h);
1136 // if(fit->order > it->order)
1138 // move_object_with_animation(fit->view, x, y, w, h, x+20, y, w, h, 0.5, move_fade_out_object, NULL, NULL);
1139 // 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);
1143 // move_object_with_animation(fit->view, x, y, w, h, x-120, y, w, h, 1.5, move_fade_out_object, NULL, NULL);
1144 // 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);
1149 end_selected_box(wd, it->view);
1152 if(wd->pre_item) evas_object_hide(wd->pre_item->view);
1153 elm_layout_content_set(wd->view, "elm.swallow.view", it->view);
1155 // elm_layout_content_set(wd->view, "elm.swallow.view", it->view);
1156 //edje_object_part_swallow(wd->view, "elm.swallow.view", it->view);
1157 // evas_object_show(it->view);
1159 }else if(it->style == TOOLBAR){
1161 it->func(it->data, it->obj, it);
1162 object_color_set(it->base, "elm.item.default.color", "elm.swallow.icon");
1163 edje_object_signal_emit(_EDJ(it->base), "elm,state,text_unselected", "elm");
1166 evas_object_smart_callback_call(it->obj, "clicked", it);
1170 unpressed_box_cb(void *data, Evas *evas, Evas_Object *obj, void *event_info)
1172 Widget_Data * wd = (Widget_Data *) data;
1174 Evas_Event_Mouse_Up * ev = event_info;
1175 Evas_Coord x, y, w, h;
1177 Elm_Controlbar_Item * item;
1178 EINA_LIST_FOREACH(wd->items, l, item)
1180 if (item->style == TABBAR)
1184 object_color_set(item->base, "elm.tabbar.selected.color", "elm.swallow.icon");
1185 edje_object_signal_emit(_EDJ(item->base), "elm,state,selected", "elm");
1189 object_color_set(item->base, "elm.item.default.color", "elm.swallow.icon");
1190 edje_object_signal_emit(_EDJ(item->base), "elm,state,unselected", "elm");
1193 else if (item->style == TOOLBAR)
1195 object_color_set(item->base, "elm.item.default.color", "elm.swallow.icon");
1196 edje_object_signal_emit(_EDJ(item->base), "elm,state,text_unselected", "elm");
1200 evas_object_geometry_get(wd->pre_item->base, &x, &y, &w, &h);
1201 if(ev->output.x > x && ev->output.x < x+w && ev->output.y > y && ev->output.y < y+h)
1203 printf("call selected_box\n");
1204 selected_box(wd->pre_item);
1207 evas_object_event_callback_del(wd->event_box, EVAS_CALLBACK_MOUSE_UP, unpressed_box_cb);
1213 pressed_box(Elm_Controlbar_Item * it)
1215 Widget_Data * wd = elm_widget_data_get(it->obj);
1218 Elm_Controlbar_Item * item;
1220 if(wd->animating) return EXIT_FAILURE;
1222 if(it->disable) return EXIT_FAILURE;
1224 EINA_LIST_FOREACH(wd->items, l, item)
1228 if (it->style == TABBAR)
1231 object_color_set(it->base, "elm.tabbar.selected.color", "elm.swallow.icon");
1232 edje_object_signal_emit(_EDJ(it->base), "elm,state,pressed",
1235 else if (it->style == TOOLBAR)
1238 object_color_set(it->base, "elm.toolbar.pressed.color", "elm.swallow.icon");
1239 edje_object_signal_emit(_EDJ(it->base), "elm,state,text_selected",
1242 evas_object_event_callback_add(wd->event_box, EVAS_CALLBACK_MOUSE_UP, unpressed_box_cb, (void *)wd);
1248 return EXIT_FAILURE;
1252 return EXIT_SUCCESS;
1255 static Evas_Object *
1256 create_item_layout(Evas_Object * parent, Elm_Controlbar_Item * it)
1260 obj = elm_layout_add(parent);
1263 fprintf(stderr, "Cannot load bg edj\n");
1266 elm_layout_theme_set(obj, "controlbar", "item",
1267 elm_widget_style_get(it->obj));
1268 evas_object_size_hint_weight_set(obj, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1269 evas_object_size_hint_align_set(obj, EVAS_HINT_FILL, EVAS_HINT_FILL);
1272 edje_object_part_text_set(_EDJ(obj), "elm.text", it->label);
1276 icon = elm_icon_add(obj);
1277 if(!elm_icon_standard_set(icon, it->icon_path))
1279 elm_icon_file_set(icon, it->icon_path, NULL);
1282 evas_object_size_hint_min_set(icon, 40, 40);
1283 evas_object_size_hint_max_set(icon, 100, 100);
1284 evas_object_show(icon);
1285 edje_object_part_swallow(_EDJ(obj), "elm.swallow.icon", icon);
1288 if (it->label && it->icon)
1290 edje_object_signal_emit(_EDJ(obj), "elm,state,icon_text", "elm");
1296 edit_item_down_end_cb(void *data, Evas_Object * obj)
1298 Widget_Data * wd = (Widget_Data *) data;
1300 if (wd->animating < 0)
1302 printf("animation error\n");
1308 edit_item_return_cb(void *data, Evas_Object * obj)
1310 Evas_Coord x, y, w, h;
1311 Widget_Data * wd = (Widget_Data *) data;
1312 evas_object_geometry_get(wd->moving_item->edit_item, &x, &y, &w, &h);
1313 set_evas_map(obj, x, y, 0, 0);
1315 evas_object_event_callback_del(wd->event_box, EVAS_CALLBACK_MOUSE_UP, edit_item_up_cb);
1316 evas_object_event_callback_del(wd->event_box, EVAS_CALLBACK_MOUSE_MOVE, edit_item_move_cb);
1318 evas_object_data_set(wd->moving_obj, "returning", 0);
1320 if (wd->animating < 0)
1322 printf("animation error\n");
1328 edit_item_move_cb(void *data, Evas *evas, Evas_Object *obj, void *event_info)
1330 Evas_Event_Mouse_Move * ev = event_info;
1332 Elm_Controlbar_Item * item;
1333 Evas_Coord x, y, w, h;
1334 Widget_Data * wd = (Widget_Data *) data;
1337 evas_object_geometry_get(wd->moving_obj, &x, &y, &w, &h);
1340 x = ev->cur.output.x - w / 2;
1341 y = ev->cur.output.y - h;
1342 set_evas_map(wd->moving_obj, x, y, w, h);
1344 EINA_LIST_FOREACH(wd->items, l, item)
1346 if (wd->moving_item->edit_item == item->edit_item || item->style == OBJECT)
1348 evas_object_geometry_get(item->base, &x, &y, &w, &h);
1349 if (ev->cur.output.x > x && ev->cur.output.x < x + w && ev->cur.output.y > y && ev->cur.output.y < y + h
1352 edje_object_signal_emit(_EDJ(item->base), "elm,state,show,glow",
1357 edje_object_signal_emit(_EDJ(item->base), "elm,state,hide,glow",
1365 edit_item_up_cb(void *data, Evas *evas, Evas_Object *obj, void *event_info)
1367 Evas_Event_Mouse_Up * ev = event_info;
1368 Evas_Coord x, y, w, h;
1369 Evas_Coord x_, y_, w_, h_;
1371 Elm_Controlbar_Item * item;
1372 Widget_Data * wd = (Widget_Data *) data;
1374 if ((int)evas_object_data_get(wd->moving_obj, "returning") == 1)
1376 evas_object_color_set(wd->moving_item->edit_item, 255, 255, 255, 255);
1378 // check which change or not
1379 EINA_LIST_FOREACH(wd->items, l, item)
1381 if (wd->moving_item->edit_item == item->edit_item)
1383 if (item->order <= 0)
1385 evas_object_geometry_get(item->base, &x, &y, &w, &h);
1386 if (ev->output.x > x && ev->output.x < x + w && ev->output.y > y && ev->output.y < y + h
1387 && item->style != OBJECT && item->editable)
1389 edje_object_signal_emit(_EDJ(item->base), "elm,state,hide,glow",
1396 if (wd->moving_item->order > 0)
1398 item_exchange_in_bar(wd->moving_item, item);
1402 item_change_in_bar(item);
1404 evas_object_event_callback_del(wd->event_box, EVAS_CALLBACK_MOUSE_UP, edit_item_up_cb);
1405 evas_object_event_callback_del(wd->event_box, EVAS_CALLBACK_MOUSE_MOVE, edit_item_move_cb);
1410 // return moving object to original location
1411 evas_object_geometry_get(wd->moving_item->edit_item, &x_, &y_, &w_,
1413 evas_object_geometry_get(wd->moving_obj, &x, &y, &w, &h);
1416 x = ev->output.x - w / 2;
1417 y = ev->output.y - h;
1418 evas_object_data_set(wd->moving_obj, "returning", (void *)1);
1420 move_object_with_animation(wd->moving_obj, x, y, w, h, x_, y_, w_, h_,
1421 0.25, move_evas_map, edit_item_return_cb, wd);
1427 edit_item_down_cb(void *data, Evas * evas, Evas_Object * obj,
1430 Evas_Event_Mouse_Down * ev = event_info;
1431 Evas_Coord x, y, w, h;
1432 Evas_Coord x_, y_, w_, h_;
1433 Widget_Data * wd = (Widget_Data *) data;
1436 Elm_Controlbar_Item * item;
1437 Evas_Object * color;
1442 EINA_LIST_FOREACH(wd->items, l, item)
1444 if (item->edit_item == obj)
1449 if (!item->editable)
1452 evas_object_event_callback_add(wd->event_box, EVAS_CALLBACK_MOUSE_UP, edit_item_up_cb, (void *)wd);
1453 evas_object_event_callback_add(wd->event_box, EVAS_CALLBACK_MOUSE_MOVE, edit_item_move_cb, (void *)wd);
1455 wd->moving_item = item;
1458 edje_object_part_object_get(_EDJ(wd->moving_item->edit_item),
1459 "elm.item.uneditable.color");
1461 evas_object_color_get(color, &r, &g, &b, &a);
1462 evas_object_color_set(item->edit_item, r, g, b, a);
1464 evas_object_del(wd->moving_obj);
1465 wd->moving_obj = NULL;
1466 wd->moving_obj = create_item_layout(obj, item);
1467 evas_object_geometry_get(obj, &x, &y, &w, &h);
1468 evas_object_move(wd->moving_obj, -1000, -1000);
1469 evas_object_resize(wd->moving_obj, w, h);
1470 evas_object_show(wd->moving_obj);
1473 x_ = ev->output.x - w_ / 2;
1474 y_ = ev->output.y - h_;
1476 move_object_with_animation(wd->moving_obj, x, y, w, h, x_, y_, w_, h_, 0.1,
1477 move_evas_map, edit_item_down_end_cb, wd);
1481 bar_item_move_end_cb(void *data, Evas_Object * obj)
1483 Widget_Data * wd = (Widget_Data *) data;
1486 Elm_Controlbar_Item * item;
1487 EINA_LIST_FOREACH(wd->items, l, item)
1489 if (item->base == obj)
1493 if (wd->animating < 0)
1495 printf("animation error\n");
1498 evas_object_data_set(obj, "animating", 0);
1499 evas_object_map_enable_set(obj, EINA_FALSE);
1503 bar_item_animation_end_check(void *data)
1507 Elm_Controlbar_Item * item;
1508 Widget_Data * wd = (Widget_Data *) data;
1510 return EXIT_FAILURE;
1511 EINA_LIST_FOREACH(wd->items, l, item)
1513 if (item->base == wd->moving_obj)
1518 printf("item is NULL\n");
1522 item->order = wd->empty_num;
1524 wd->moving_obj = NULL;
1526 evas_object_event_callback_del(wd->event_box, EVAS_CALLBACK_MOUSE_UP, bar_item_up_cb);
1527 evas_object_event_callback_del(wd->event_box, EVAS_CALLBACK_MOUSE_MOVE, bar_item_move_cb);
1528 return ECORE_CALLBACK_CANCEL;
1532 bar_item_move_cb(void *data, Evas *evas, Evas_Object *obj, void *event_info)
1534 Evas_Event_Mouse_Move * ev = event_info;
1536 Elm_Controlbar_Item * item, *it;
1537 Widget_Data * wd = (Widget_Data *) data;
1538 Evas_Coord x, y, w, h, x_, y_, w_, h_;
1541 if (wd->moving_obj == NULL)
1543 printf("%s : moving_obj is NULL\n", __func__);
1546 evas_object_geometry_get(wd->moving_obj, &x, &y, &w, &h);
1547 x = ev->cur.output.x - w / 2;
1548 set_evas_map(wd->moving_obj, x, y, w, h);
1549 EINA_LIST_FOREACH(wd->items, l, item)
1551 if (item->base == wd->moving_obj)
1556 if ((int)evas_object_data_get(item->base, "animating") == 1)
1558 evas_object_geometry_get(item->base, &x, &y, &w, &h);
1559 if (ev->cur.output.x > x && ev->cur.output.x < x + w && item->editable)
1566 evas_object_geometry_get(wd->moving_obj, &x_, &y_, &w_, &h_);
1567 evas_object_move(wd->moving_obj, x, y);
1568 tmp = wd->empty_num;
1569 wd->empty_num = item->order;
1571 elm_table_unpack(wd->box, item->base);
1572 elm_table_unpack(wd->box, wd->moving_obj);
1573 elm_table_pack(wd->box, item->base, item->order - 1, 0, 1, 1);
1574 elm_table_pack(wd->box, wd->moving_obj, wd->empty_num - 1, 0, 1, 1);
1576 evas_object_data_set(item->base, "animating", (void *)1);
1577 move_object_with_animation(item->base, x, y, w, h, x_, y_, w_, h_,
1578 0.25, move_evas_map, bar_item_move_end_cb, wd);
1584 bar_item_up_cb(void *data, Evas *evas, Evas_Object *obj, void *event_info)
1586 Evas_Event_Mouse_Up * ev = event_info;
1587 Evas_Coord tx, x, y, w, h;
1588 Widget_Data * wd = (Widget_Data *) data;
1589 evas_object_geometry_get(wd->moving_obj, &x, &y, &w, &h);
1590 tx = ev->output.x - w / 2;
1592 evas_object_data_set(wd->moving_obj, "animating", (void *)1);
1593 move_object_with_animation(wd->moving_obj, tx, y, w, h, x, y, w, h, 0.25,
1594 move_evas_map, bar_item_move_end_cb, wd);
1595 ecore_timer_add(0.1, bar_item_animation_end_check, wd);
1600 bar_item_down_cb(void *data, Evas * evas, Evas_Object * obj, void *event_info)
1602 Widget_Data * wd = (Widget_Data *) data;
1604 Elm_Controlbar_Item * item;
1607 EINA_LIST_FOREACH(wd->items, l, item)
1609 if (item->base == obj)
1616 if (!item->editable)
1619 wd->moving_obj = obj;
1620 wd->empty_num = item->order;
1621 evas_object_event_callback_add(wd->event_box, EVAS_CALLBACK_MOUSE_UP, bar_item_up_cb, (void *)wd);
1622 evas_object_event_callback_add(wd->event_box, EVAS_CALLBACK_MOUSE_MOVE, bar_item_move_cb, (void *)wd);
1630 static Elm_Controlbar_Item *
1631 create_tab_item(Evas_Object * obj, const char *icon_path, const char *label,
1634 Elm_Controlbar_Item * it;
1638 fprintf(stderr, "Invalid argument: controlbar object is NULL\n");
1641 wd = elm_widget_data_get(obj);
1644 fprintf(stderr, "Cannot get smart data\n");
1647 it = ELM_NEW(Elm_Controlbar_Item);
1651 it->label = eina_stringshare_add(label);
1652 it->icon_path = icon_path;
1653 it->selected = EINA_FALSE;
1654 it->editable = EINA_TRUE;
1659 it->base = create_item_layout(wd->edje, it);
1660 evas_object_event_callback_add(it->base, EVAS_CALLBACK_MOUSE_DOWN,
1661 bar_item_down_cb, wd);
1662 //edje_object_signal_callback_add(_EDJ(it->base), "elm,action,click", "elm",
1663 // clicked_box_cb, wd);
1664 object_color_set(it->base, "elm.item.default.color", "elm.swallow.icon");
1665 evas_object_show(it->base);
1666 it->edit_item = create_item_layout(wd->edje, it);
1667 evas_object_event_callback_add(it->edit_item, EVAS_CALLBACK_MOUSE_DOWN,
1668 edit_item_down_cb, wd);
1669 evas_object_show(it->edit_item);
1674 static Elm_Controlbar_Item *
1675 create_tool_item(Evas_Object * obj, const char *icon_path, const char *label,
1676 void (*func) (void *data, Evas_Object * obj,
1677 void *event_info), void *data)
1679 Elm_Controlbar_Item * it;
1683 fprintf(stderr, "Invalid argument: controlbar object is NULL\n");
1686 wd = elm_widget_data_get(obj);
1689 fprintf(stderr, "Cannot get smart data\n");
1692 it = ELM_NEW(Elm_Controlbar_Item);
1696 it->label = eina_stringshare_add(label);
1697 it->icon_path = icon_path;
1698 it->selected = EINA_FALSE;
1699 it->editable = EINA_TRUE;
1704 it->style = TOOLBAR;
1705 it->base = create_item_layout(wd->edje, it);
1706 evas_object_event_callback_add(it->base, EVAS_CALLBACK_MOUSE_DOWN,
1707 bar_item_down_cb, wd);
1708 //edje_object_signal_callback_add(_EDJ(it->base), "elm,action,click", "elm",
1709 // clicked_box_cb, wd);
1710 object_color_set(it->base, "elm.item.default.color", "elm.swallow.icon");
1711 evas_object_show(it->base);
1712 it->edit_item = create_item_layout(wd->edje, it);
1713 evas_object_event_callback_add(it->edit_item, EVAS_CALLBACK_MOUSE_DOWN,
1714 edit_item_down_cb, wd);
1715 evas_object_show(it->edit_item);
1719 static Elm_Controlbar_Item *
1720 create_object_item(Evas_Object * obj, Evas_Object * obj_item, const int sel)
1722 Elm_Controlbar_Item * it;
1726 fprintf(stderr, "Invalid argument: controlbar object is NULL\n");
1729 wd = elm_widget_data_get(obj);
1732 fprintf(stderr, "Cannot get smart data\n");
1735 it = ELM_NEW(Elm_Controlbar_Item);
1742 it->base = obj_item;
1747 set_items_position(Evas_Object * obj, Elm_Controlbar_Item * it,
1748 Elm_Controlbar_Item * mit, Eina_Bool bar)
1753 Elm_Controlbar_Item * item;
1756 int check = EINA_FALSE;
1764 fprintf(stderr, "Invalid argument: controlbar object is NULL\n");
1767 wd = elm_widget_data_get(obj);
1770 fprintf(stderr, "Cannot get smart data\n");
1774 EINA_LIST_FOREACH(wd->items, l, item)
1776 if (item == mit && item->order > 0)
1780 it->order = mit->order;
1784 if(item->order > 0){
1785 // printf("%s +_+_+_+_+_+ %d \n", item->label, item->order);
1786 elm_table_unpack(wd->box, item->base);
1787 item->order += it->sel;
1788 elm_table_pack(wd->box, item->base, item->order - 1, 0, item->sel, 1);
1790 if (item->style != OBJECT && it->style != OBJECT)
1792 // printf("%s +_+_+_+_+_+ edit :: %d\n", item->label, i);
1793 elm_table_unpack(wd->edit_table, item->edit_item);
1794 elm_table_pack(wd->edit_table, item->edit_item,
1795 i % EDIT_ROW_NUM, i / EDIT_ROW_NUM, 1, 1);
1798 if (item->style != OBJECT)
1800 if(item->order > 0) order += item->sel;
1811 if(bar) elm_table_pack(wd->box, it->base, it->order - 1, 0, it->sel, 1);
1812 else evas_object_hide(it->base);
1813 if (it->style != OBJECT)
1814 elm_table_pack(wd->edit_table, it->edit_item, (edit - 1) % EDIT_ROW_NUM,
1815 (edit - 1) / EDIT_ROW_NUM, 1, 1);
1819 list_clicked(void *data, Evas_Object *obj, void *event_info)
1821 Elm_Controlbar_Item *item = (Elm_Controlbar_Item *)data;
1822 Elm_Controlbar_Item *it;
1825 Evas_Object *content;
1826 Elm_List_Item *lit = (Elm_List_Item *) elm_list_selected_item_get(obj);
1827 if(lit == NULL) return;
1829 elm_list_item_selected_set(lit, 0);
1833 wd = elm_widget_data_get(item->obj);
1835 EINA_LIST_FOREACH(wd->items, l, it)
1837 it->selected = EINA_FALSE;
1840 if(item->style == TABBAR)
1842 content = elm_layout_content_unset(wd->view, "elm.swallow.view");
1843 evas_object_hide(content);
1844 item->selected = EINA_TRUE;
1845 evas_object_smart_callback_call(item->obj, "view,change,before", item);
1846 elm_layout_content_set(wd->view, "elm.swallow.view", item->view);
1849 if(item->style == TOOLBAR && item->func)
1850 item->func(item->data, item->obj, item);
1853 static Evas_Object *
1854 create_more_view(Widget_Data *wd)
1857 Elm_Controlbar_Item *item;
1860 list = elm_list_add( wd->object );
1861 elm_list_horizontal_mode_set( list, ELM_LIST_COMPRESS );
1863 EINA_LIST_FOREACH(wd->items, l, item)
1865 if(item->order <= 0)
1867 evas_object_color_set(item->icon, 0, 0, 0, 255);
1868 elm_list_item_append(list, item->label, item->icon, NULL, list_clicked, item);
1872 elm_list_go( list );
1877 static Elm_Controlbar_Item *
1878 create_more_item(Widget_Data *wd, int style)
1880 Elm_Controlbar_Item * it;
1882 it = ELM_NEW(Elm_Controlbar_Item);
1885 it->obj = wd->object;
1886 it->label = eina_stringshare_add("more");
1887 it->icon_path = CONTROLBAR_SYSTEM_ICON_MORE;
1888 it->selected = EINA_FALSE;
1891 it->view = create_more_view(wd);
1893 it->base = create_item_layout(wd->edje, it);
1894 evas_object_event_callback_add(it->base, EVAS_CALLBACK_MOUSE_DOWN,
1895 bar_item_down_cb, wd);
1896 object_color_set(it->base, "elm.item.default.color", "elm.swallow.icon");
1897 evas_object_show(it->base);
1898 it->edit_item = create_item_layout(wd->edje, it);
1899 evas_object_event_callback_add(it->edit_item, EVAS_CALLBACK_MOUSE_DOWN,
1900 edit_item_down_cb, wd);
1901 evas_object_show(it->edit_item);
1903 set_items_position(it->obj, it, NULL, EINA_TRUE);
1905 wd->items = eina_list_append(wd->items, it);
1909 elm_controlbar_item_editable_set(it, EINA_FALSE);
1911 wd->items = eina_list_sort(wd->items, eina_list_count(wd->items), sort_cb);
1916 ///////////////////////////////////////////////////////////////////
1920 ////////////////////////////////////////////////////////////////////
1923 * Add a new controlbar object
1925 * @param parent The parent object
1926 * @return The new object or NULL if it cannot be created
1928 * @ingroup Controlbar
1930 EAPI Evas_Object * elm_controlbar_add(Evas_Object * parent)
1932 Evas_Object * obj = NULL;
1933 Evas_Object * bg = NULL;
1934 Widget_Data * wd = NULL;
1935 Evas_Coord x, y, w, h;
1936 Evas_Object * r_button;
1937 wd = ELM_NEW(Widget_Data);
1938 wd->evas = evas_object_evas_get(parent);
1939 if (wd->evas == NULL)
1941 obj = elm_widget_add(wd->evas);
1944 elm_widget_type_set(obj, "controlbar");
1945 elm_widget_sub_object_add(parent, obj);
1946 elm_widget_data_set(obj, wd);
1947 elm_widget_del_hook_set(obj, _del_hook);
1948 elm_widget_theme_hook_set(obj, _theme_hook);
1951 wd->parent = parent;
1952 evas_object_geometry_get(parent, &x, &y, &w, &h);
1958 wd->mode = ELM_CONTROLBAR_MODE_DEFAULT;
1961 wd->edit_mode = EINA_FALSE;
1962 wd->auto_align = EINA_FALSE;
1963 wd->init_animation = EINA_FALSE;
1964 wd->selected_animation = EINA_FALSE;
1965 wd->view = elm_layout_add(wd->parent); //edje_object_add(wd->evas);
1966 elm_layout_theme_set(wd->view, "controlbar", "view", "default");
1967 //_elm_theme_object_set(obj, wd->view, "controlbar", "view", "default");
1968 if (wd->view == NULL)
1970 printf("Cannot load bg edj\n");
1973 evas_object_show(wd->view);
1976 wd->edit_box = edje_object_add(wd->evas);
1977 _elm_theme_object_set(obj, wd->edit_box, "controlbar", "edit_box",
1979 if (wd->edit_box == NULL)
1981 printf("Cannot load bg edj\n");
1984 evas_object_show(wd->edit_box);
1986 //instead of navigationbar
1987 /* r_button = elm_button_add(wd->edit_box);
1988 elm_button_label_set(r_button, "Done");
1989 evas_object_smart_callback_add(r_button, "clicked", done_button_cb, wd);
1990 edje_object_part_swallow(wd->edit_box, "elm.swallow.navigation", r_button);
1992 // navigationbar will contribution. but not yet
1993 wd->navigation = elm_navigationbar_add(wd->edit_box);
1994 r_button = elm_button_add(wd->navigation);
1995 elm_button_label_set(r_button, "Done");
1996 evas_object_smart_callback_add(r_button, "clicked", done_button_cb, wd);
1997 elm_navigationbar_push(wd->navigation, "Configure", NULL, r_button, NULL, NULL);
1998 edje_object_part_swallow(wd->edit_box, "elm.swallow.navigation", wd->navigation);
2000 wd->edit_table = elm_table_add(wd->edit_box);
2001 elm_table_homogenous_set(wd->edit_table, EINA_TRUE);
2002 edje_object_part_swallow(wd->edit_box, "elm.swallow.table", wd->edit_table);
2004 /* load background edj */
2005 wd->edje = edje_object_add(wd->evas);
2006 _elm_theme_object_set(obj, wd->edje, "controlbar", "base", "default");
2007 if (wd->edje == NULL)
2009 printf("Cannot load bg edj\n");
2012 evas_object_show(wd->edje);
2015 evas_object_event_callback_add(wd->edje, EVAS_CALLBACK_RESIZE,
2016 _controlbar_object_resize, obj);
2017 evas_object_event_callback_add(wd->edje, EVAS_CALLBACK_MOVE,
2018 _controlbar_object_move, obj);
2019 evas_object_event_callback_add(wd->edje, EVAS_CALLBACK_SHOW,
2020 _controlbar_object_show, obj);
2021 evas_object_event_callback_add(wd->edje, EVAS_CALLBACK_HIDE,
2022 _controlbar_object_hide, obj);
2023 bg = (Evas_Object *)edje_object_part_object_get(wd->edje, "bg_image");
2024 evas_object_event_callback_add(bg, EVAS_CALLBACK_MOVE, _controlbar_object_move, obj);
2025 evas_object_event_callback_add(bg, EVAS_CALLBACK_RESIZE, _controlbar_object_resize, obj);
2027 wd->selected_box = edje_object_add(wd->evas);
2028 _elm_theme_object_set(obj, wd->selected_box, "controlbar", "item_bg", "default");
2029 //edje_object_part_swallow(wd->edje, "elm.swallow.panel", wd->selected_box);
2030 evas_object_hide(wd->selected_box);
2033 wd->box = elm_table_add(wd->edje);
2034 elm_table_homogenous_set(wd->box, EINA_TRUE);
2035 evas_object_size_hint_weight_set(wd->box, EVAS_HINT_EXPAND,
2037 evas_object_size_hint_align_set(wd->box, EVAS_HINT_FILL, EVAS_HINT_FILL);
2038 edje_object_part_swallow(wd->edje, "elm.swallow.items", wd->box);
2039 evas_object_show(wd->box);
2041 wd->event_box = evas_object_rectangle_add(wd->evas);
2042 evas_object_color_set(wd->event_box, 255, 255, 255, 0);
2043 evas_object_repeat_events_set(wd->event_box, EINA_TRUE);
2044 evas_object_show(wd->event_box);
2047 // evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
2048 evas_object_smart_member_add(wd->view, obj);
2049 evas_object_smart_member_add(wd->edit_box, obj);
2050 elm_widget_resize_object_set(obj, wd->edje);
2051 evas_object_smart_member_add(wd->selected_box, obj);
2052 evas_object_smart_member_add(wd->box, obj);
2053 evas_object_smart_member_add(wd->event_box, obj);
2060 * Append new tab item
2062 * @param obj The controlbar object
2063 * @param icon_path The icon path of item
2064 * @param label The label of item
2065 * @param view The view of item
2066 * @return The item of controlbar
2068 * @ingroup Controlbar
2070 EAPI Elm_Controlbar_Item * elm_controlbar_tab_item_append(Evas_Object * obj,
2077 Elm_Controlbar_Item * it;
2078 Elm_Controlbar_Item * lit;
2080 it = create_tab_item(obj, icon_path, label, view);
2083 wd = elm_widget_data_get(obj);
2084 if(check_bar_item_number(wd) >= 5 && wd->auto_align){
2085 if(!wd->more_item) {
2086 lit = elm_controlbar_last_item_get(obj);
2087 elm_controlbar_item_visible_set(lit, EINA_FALSE);
2088 create_more_item(wd, TABBAR);
2090 set_items_position(obj, it, NULL, EINA_FALSE);
2093 set_items_position(obj, it, NULL, EINA_TRUE);
2095 if(wd->init_animation) evas_object_hide(it->base);
2096 wd->items = eina_list_append(wd->items, it);
2098 elm_controlbar_item_view_set(wd->more_item, create_more_view(wd));
2106 * Prepend new tab item
2108 * @param obj The controlbar object
2109 * @param icon_path The icon path of item
2110 * @param label The label of item
2111 * @param view The view of item
2112 * @return The item of controlbar
2114 * @ingroup Controlbar
2116 EAPI Elm_Controlbar_Item * elm_controlbar_tab_item_prepend(Evas_Object *
2126 Elm_Controlbar_Item * it;
2127 Elm_Controlbar_Item * lit;
2128 Elm_Controlbar_Item * item;
2129 it = create_tab_item(obj, icon_path, label, view);
2132 wd = elm_widget_data_get(obj);
2133 item = eina_list_data_get(wd->items);
2134 if(check_bar_item_number(wd) >= 5 && wd->auto_align){
2135 if(!wd->more_item) {
2136 lit = elm_controlbar_last_item_get(obj);
2137 elm_controlbar_item_visible_set(lit, EINA_FALSE);
2138 create_more_item(wd, TABBAR);
2140 lit = elm_controlbar_item_prev(wd->more_item);
2141 elm_controlbar_item_visible_set(lit, EINA_FALSE);
2142 set_items_position(obj, it, item, EINA_TRUE);
2145 set_items_position(obj, it, item, EINA_TRUE);
2147 wd->items = eina_list_prepend(wd->items, it);
2149 elm_controlbar_item_view_set(wd->more_item, create_more_view(wd));
2157 * Insert new tab item before given item
2159 * @param obj The controlbar object
2160 * @param before The given item
2161 * @param icon_path The icon path of item
2162 * @param label The label of item
2163 * @param view The view of item
2164 * @return The item of controlbar
2166 * @ingroup Controlbar
2168 EAPI Elm_Controlbar_Item *
2169 elm_controlbar_tab_item_insert_before(Evas_Object * obj,
2170 Elm_Controlbar_Item * before,
2171 const char *icon_path,
2172 const char *label, Evas_Object * view)
2175 Elm_Controlbar_Item * it;
2176 Elm_Controlbar_Item * lit;
2179 it = create_tab_item(obj, icon_path, label, view);
2182 wd = elm_widget_data_get(obj);
2183 if(check_bar_item_number(wd) >= 5 && wd->auto_align){
2186 lit = elm_controlbar_last_item_get(obj);
2187 elm_controlbar_item_visible_set(lit, EINA_FALSE);
2188 create_more_item(wd, TABBAR);
2190 if(before->order > 0)
2192 lit = elm_controlbar_item_prev(wd->more_item);
2193 elm_controlbar_item_visible_set(lit, EINA_FALSE);
2194 set_items_position(obj, it, before, EINA_TRUE);
2198 set_items_position(obj, it, before, EINA_FALSE);
2202 set_items_position(obj, it, before, EINA_TRUE);
2204 wd->items = eina_list_prepend_relative(wd->items, it, before);
2206 elm_controlbar_item_view_set(wd->more_item, create_more_view(wd));
2214 * Insert new tab item after given item
2216 * @param obj The controlbar object
2217 * @param after The given item
2218 * @param icon_path The icon path of item
2219 * @param label The label of item
2220 * @param view The view of item
2221 * @return The item of controlbar
2223 * @ingroup Controlbar
2225 EAPI Elm_Controlbar_Item *
2226 elm_controlbar_tab_item_insert_after(Evas_Object * obj,
2227 Elm_Controlbar_Item * after,
2228 const char *icon_path, const char *label,
2232 Elm_Controlbar_Item * it;
2233 Elm_Controlbar_Item * lit;
2234 Elm_Controlbar_Item * item;
2237 it = create_tab_item(obj, icon_path, label, view);
2240 wd = elm_widget_data_get(obj);
2241 item = elm_controlbar_item_next(after);
2242 if(check_bar_item_number(wd) >= 5 && wd->auto_align){
2245 lit = elm_controlbar_last_item_get(obj);
2246 elm_controlbar_item_visible_set(lit, EINA_FALSE);
2247 create_more_item(wd, TABBAR);
2251 lit = elm_controlbar_item_prev(wd->more_item);
2252 elm_controlbar_item_visible_set(lit, EINA_FALSE);
2253 set_items_position(obj, it, item, EINA_TRUE);
2257 set_items_position(obj, it, item, EINA_FALSE);
2261 set_items_position(obj, it, item, EINA_TRUE);
2263 wd->items = eina_list_append_relative(wd->items, it, after);
2265 elm_controlbar_item_view_set(wd->more_item, create_more_view(wd));
2273 * Append new tool item
2275 * @param obj The controlbar object
2276 * @param icon_path The icon path of item
2277 * @param label The label of item
2278 * @param func Callback function of item
2279 * @param data The data of callback function
2280 * @return The item of controlbar
2282 * @ingroup Controlbar
2284 EAPI Elm_Controlbar_Item * elm_controlbar_tool_item_append(Evas_Object *
2299 Elm_Controlbar_Item * it;
2301 it = create_tool_item(obj, icon_path, label, func, data);
2304 wd = elm_widget_data_get(obj);
2305 set_items_position(obj, it, NULL, EINA_TRUE);
2306 wd->items = eina_list_append(wd->items, it);
2312 * Prepend new tool item
2314 * @param obj The controlbar object
2315 * @param icon_path The icon path of item
2316 * @param label The label of item
2317 * @param func Callback function of item
2318 * @param data The data of callback function
2319 * @return The item of controlbar
2321 * @ingroup Controlbar
2323 EAPI Elm_Controlbar_Item * elm_controlbar_tool_item_prepend(Evas_Object *
2340 Elm_Controlbar_Item * it;
2341 Elm_Controlbar_Item * item;
2342 it = create_tool_item(obj, icon_path, label, func, data);
2345 wd = elm_widget_data_get(obj);
2346 item = eina_list_data_get(wd->items);
2347 set_items_position(obj, it, item, EINA_TRUE);
2348 wd->items = eina_list_prepend(wd->items, it);
2354 * Insert new tool item before given item
2356 * @param obj The controlbar object
2357 * @param before The given item
2358 * @param icon_path The icon path of item
2359 * @param label The label of item
2360 * @param func Callback function of item
2361 * @param data The data of callback function
2362 * @return The item of controlbar
2364 * @ingroup Controlbar
2366 EAPI Elm_Controlbar_Item *
2367 elm_controlbar_tool_item_insert_before(Evas_Object * obj,
2368 Elm_Controlbar_Item * before,
2369 const char *icon_path,
2371 void (*func) (void *data,
2377 Elm_Controlbar_Item * it;
2380 it = create_tool_item(obj, icon_path, label, func, data);
2383 wd = elm_widget_data_get(obj);
2384 set_items_position(obj, it, before, EINA_TRUE);
2385 wd->items = eina_list_prepend_relative(wd->items, it, before);
2391 * Insert new tool item after given item
2393 * @param obj The controlbar object
2394 * @param after The given item
2395 * @param icon_path The icon path of item
2396 * @param label The label of item
2397 * @param func Callback function of item
2398 * @param data The data of callback function
2399 * @return The item of controlbar
2401 * @ingroup Controlbar
2403 EAPI Elm_Controlbar_Item *
2404 elm_controlbar_tool_item_insert_after(Evas_Object * obj,
2405 Elm_Controlbar_Item * after,
2406 const char *icon_path,
2408 void (*func) (void *data,
2414 Elm_Controlbar_Item * it;
2415 Elm_Controlbar_Item * item;
2418 it = create_tool_item(obj, icon_path, label, func, data);
2421 wd = elm_widget_data_get(obj);
2422 item = elm_controlbar_item_next(after);
2423 set_items_position(obj, it, item, EINA_TRUE);
2424 wd->items = eina_list_append_relative(wd->items, it, after);
2430 * Append new object item
2432 * @param obj The controlbar object
2433 * @param obj_item The object of item
2434 * @param sel The number of sel occupied
2435 * @return The item of controlbar
2437 * @ingroup Controlbar
2439 EAPI Elm_Controlbar_Item * elm_controlbar_object_item_append(Evas_Object *
2446 Elm_Controlbar_Item * it;
2447 it = create_object_item(obj, obj_item, sel);
2450 wd = elm_widget_data_get(obj);
2451 set_items_position(obj, it, NULL, EINA_TRUE);
2452 wd->items = eina_list_append(wd->items, it);
2458 * Prepend new object item
2460 * @param obj The controlbar object
2461 * @param obj_item The object of item
2462 * @param sel The number of sel occupied
2463 * @return The item of controlbar
2465 * @ingroup Controlbar
2467 EAPI Elm_Controlbar_Item * elm_controlbar_object_item_prepend(Evas_Object *
2474 Elm_Controlbar_Item * it;
2475 Elm_Controlbar_Item * item;
2476 it = create_object_item(obj, obj_item, sel);
2479 wd = elm_widget_data_get(obj);
2480 item = eina_list_data_get(wd->items);
2481 set_items_position(obj, it, item, EINA_TRUE);
2482 wd->items = eina_list_prepend(wd->items, it);
2488 * Insert new object item before given item
2490 * @param obj The controlbar object
2491 * @param before The given item
2492 * @param obj_item The object of item
2493 * @param sel The number of sel occupied
2494 * @return The item of controlbar
2496 * @ingroup Controlbar
2498 EAPI Elm_Controlbar_Item *
2499 elm_controlbar_object_item_insert_before(Evas_Object * obj,
2500 Elm_Controlbar_Item * before,
2501 Evas_Object * obj_item, const int sel)
2504 Elm_Controlbar_Item * it;
2507 it = create_object_item(obj, obj_item, sel);
2510 wd = elm_widget_data_get(obj);
2511 set_items_position(obj, it, before, EINA_TRUE);
2512 wd->items = eina_list_prepend_relative(wd->items, it, before);
2518 * Insert new object item after given item
2520 * @param obj The controlbar object
2521 * @param after The given item
2522 * @param obj_item The object of item
2523 * @param sel The number of sel occupied
2524 * @return The item of controlbar
2526 * @ingroup Controlbar
2528 EAPI Elm_Controlbar_Item *
2529 elm_controlbar_object_item_insert_after(Evas_Object * obj,
2530 Elm_Controlbar_Item * after,
2531 Evas_Object * obj_item, const int sel)
2534 Elm_Controlbar_Item * it;
2535 Elm_Controlbar_Item * item;
2538 it = create_object_item(obj, obj_item, sel);
2541 wd = elm_widget_data_get(obj);
2542 item = elm_controlbar_item_next(after);
2543 set_items_position(obj, it, item, EINA_TRUE);
2544 wd->items = eina_list_append_relative(wd->items, it, after);
2550 * Delete item from controlbar
2552 * @param it The item of controlbar
2554 * @ingroup Controlbar
2557 elm_controlbar_item_del(Elm_Controlbar_Item * it)
2563 Elm_Controlbar_Item * item;
2571 if (it->obj == NULL)
2573 printf("Invalid argument: controlbar object is NULL\n");
2576 wd = elm_widget_data_get(it->obj);
2579 printf("Cannot get smart data\n");
2586 elm_table_unpack(wd->box, it->base);
2588 EINA_LIST_FOREACH(wd->items, l, item)
2592 if (item->order > it->order)
2594 elm_table_unpack(wd->box, item->base);
2596 elm_table_pack(wd->box, item->base, item->order - 1, 0,
2609 if (it->edit_item != NULL)
2611 elm_table_unpack(wd->edit_table, it->edit_item);
2612 EINA_LIST_FOREACH(wd->items, l, item)
2616 if (item->edit_item != NULL)
2618 elm_table_unpack(wd->edit_table, item->edit_item);
2619 elm_table_pack(wd->edit_table, item->edit_item,
2620 (i - 1) % 4, (i - 1) / 4, 1, 1);
2623 if (it == item && item->style != OBJECT)
2628 if (item->style != OBJECT)
2633 // delete item in list
2635 eina_stringshare_del(it->label);
2637 evas_object_del(it->icon);
2640 if (it->style != OBJECT)
2641 evas_object_del(it->base);
2644 evas_object_hide(it->base);
2648 //edje_object_part_unswallow(wd->view, it->view);
2649 if(it->selected) elm_layout_content_unset(wd->view, "elm.swallow.view");
2650 evas_object_hide(it->view);
2653 evas_object_del(it->edit_item);
2654 wd->items = eina_list_remove(wd->items, it);
2655 wd->num = wd->num - 1;
2660 * Select item in controlbar
2662 * @param it The item of controlbar
2664 * @ingroup Controlbar
2667 elm_controlbar_item_select(Elm_Controlbar_Item * it)
2669 if (it->obj == NULL)
2671 Widget_Data * wd = elm_widget_data_get(it->obj);
2681 * Get the icon of item
2683 * @param it The item of controlbar
2684 * @return The icon object
2686 * @ingroup Controlbar
2688 EAPI Evas_Object * elm_controlbar_item_icon_get(Elm_Controlbar_Item * it)
2694 * Get the label of item
2696 * @param it The item of controlbar
2697 * @return The label of item
2699 * @ingroup Controlbar
2702 elm_controlbar_item_label_get(Elm_Controlbar_Item * it)
2708 * Set the label of item
2710 * @param it The item of controlbar
2711 * @param label The label of item
2713 * @ingroup Controlbar
2716 elm_controlbar_item_label_set(Elm_Controlbar_Item * it, const char *label)
2721 it->label = eina_stringshare_add(label);
2722 edje_object_part_text_set(_EDJ(it->base), "elm.text", it->label);
2724 edje_object_signal_emit(_EDJ(it->base),
2725 "elm,state,icon_text", "elm");
2730 * Get the selected item.
2732 * @param obj The controlbar object
2733 * @return The item of controlbar
2735 * @ingroup Controlbar
2737 EAPI Elm_Controlbar_Item * elm_controlbar_selected_item_get(Evas_Object *
2742 Elm_Controlbar_Item * item;
2745 Widget_Data * wd = elm_widget_data_get(obj);
2746 if (!wd || !wd->items)
2748 EINA_LIST_FOREACH(wd->items, l, item)
2757 * Get the first item.
2759 * @param obj The controlbar object
2760 * @return The item of controlbar
2762 * @ingroup Controlbar
2764 EAPI Elm_Controlbar_Item * elm_controlbar_first_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(wd->items);
2775 * Get the last item.
2777 * @param obj The controlbar object
2778 * @return The item of controlbar
2780 * @ingroup Controlbar
2782 EAPI Elm_Controlbar_Item * elm_controlbar_last_item_get(Evas_Object * obj)
2786 Widget_Data * wd = elm_widget_data_get(obj);
2787 if (!wd || !wd->items)
2789 return eina_list_data_get(eina_list_last(wd->items));
2795 * @param obj The controlbar object
2796 * @return The list of the items
2798 * @ingroup Controlbar
2800 EAPI Eina_List * elm_controlbar_items_get(Evas_Object * obj)
2804 Widget_Data * wd = elm_widget_data_get(obj);
2805 if (!wd || !wd->items)
2811 * Get the previous item.
2813 * @param it The item of controlbar
2814 * @return The previous item of the parameter item
2816 * @ingroup Controlbar
2818 EAPI Elm_Controlbar_Item * elm_controlbar_item_prev(Elm_Controlbar_Item *
2823 Elm_Controlbar_Item * item;
2824 if (it->obj == NULL)
2826 Widget_Data * wd = elm_widget_data_get(it->obj);
2827 if (!wd || !wd->items)
2829 EINA_LIST_FOREACH(wd->items, l, item)
2833 l = eina_list_prev(l);
2836 return eina_list_data_get(l);
2843 * Get the next item.
2845 * @param obj The controlbar object
2846 * @return The next item of the parameter item
2848 * @ingroup Controlbar
2850 EAPI Elm_Controlbar_Item * elm_controlbar_item_next(Elm_Controlbar_Item *
2855 Elm_Controlbar_Item * item;
2856 if (it->obj == NULL)
2858 Widget_Data * wd = elm_widget_data_get(it->obj);
2859 if (!wd || !wd->items)
2861 EINA_LIST_FOREACH(wd->items, l, item)
2865 l = eina_list_next(l);
2868 return eina_list_data_get(l);
2875 * Start edit mode(Don't use this API)
2877 * @param The controlbar object
2879 * @ingroup Controlbar
2882 elm_controlbar_edit_start(Evas_Object * obj)
2884 printf("\n==================================\n");
2885 printf("%s\n", __func__);
2886 printf("==================================\n");
2887 printf("This API is just for test.\n");
2888 printf("Please don't use it!!\n");
2889 printf("Thank you.\n");
2890 printf("==================================\n");
2895 fprintf(stderr, "Invalid argument: controlbar object is NULL\n");
2898 wd = elm_widget_data_get(obj);
2901 fprintf(stderr, "Cannot get smart data\n");
2904 edje_object_signal_emit(wd->edit_box, "elm,state,show,edit_box", "elm");
2905 wd->edit_mode = EINA_TRUE;
2911 * @param it The item of controlbar
2912 * @param bar true or false
2914 * @ingroup Controlbar
2917 elm_controlbar_item_visible_set(Elm_Controlbar_Item * it, Eina_Bool visible)
2919 Elm_Controlbar_Item *item;
2920 Eina_Bool check = EINA_TRUE;
2921 if (it->obj == NULL)
2923 Widget_Data * wd = elm_widget_data_get(it->obj);
2924 if (!wd || !wd->items)
2928 if (check == visible)
2932 item = elm_controlbar_last_item_get(it->obj);
2933 while(!elm_controlbar_item_visible_get(item)){
2934 item = elm_controlbar_item_prev(item);
2936 item_insert_in_bar(it, item->order + 1);
2940 item_delete_in_bar(it);
2942 wd->items = eina_list_sort(wd->items, eina_list_count(wd->items), sort_cb);
2943 _sizing_eval(it->obj);
2948 * Get the result which or not item is in bar
2950 * @param it The item of controlbar
2951 * @return true or false
2953 * @ingroup Controlbar
2956 elm_controlbar_item_visible_get(Elm_Controlbar_Item * it)
2958 if (it->obj == NULL)
2960 Widget_Data * wd = elm_widget_data_get(it->obj);
2973 * @param it The item of controlbar
2974 * @param bar true or false
2976 * @ingroup Controlbar
2979 elm_controlbar_item_editable_set(Elm_Controlbar_Item * it, Eina_Bool editable)
2981 Evas_Object * color;
2984 if(it->editable == editable) return;
2986 it->editable = editable;
2991 (Evas_Object *) edje_object_part_object_get(_EDJ(it->edit_item),
2992 "elm.item.uneditable.color");
2994 evas_object_color_get(color, &r, &g, &b, &a);
2995 evas_object_color_set(it->edit_item, r, g, b, a);
3002 * @param it The item of controlbar
3003 * @param bar true or false
3005 * @ingroup Controlbar
3008 elm_controlbar_item_disable_set(Elm_Controlbar_Item * it, Eina_Bool disable)
3010 Evas_Object * color;
3013 if(it->disable == disable) return;
3015 it->disable = disable;
3019 (Evas_Object *) edje_object_part_object_get(_EDJ(it->edit_item),
3020 "elm.item.disable.color");
3022 evas_object_color_get(color, &r, &g, &b, &a);
3023 evas_object_color_set(it->base, r, g, b, a);
3026 (Evas_Object *) edje_object_part_object_get(_EDJ(it->edit_item),
3027 "elm.item.default.color");
3029 evas_object_color_get(color, &r, &g, &b, &a);
3030 evas_object_color_set(it->base, r, g, b, a);
3035 * Set the default view(Don't use this API)
3037 * @param obj The controlbar object
3038 * @param view The default view
3040 * @ingroup Controlbar
3043 elm_controlbar_view_set(Evas_Object * obj, Evas_Object * view)
3045 printf("\n==================================\n");
3046 printf("%s\n", __func__);
3047 printf("==================================\n");
3048 printf("This API is just for test.\n");
3049 printf("Please don't use it!!\n");
3050 printf("Thank you.\n");
3051 printf("==================================\n");
3056 fprintf(stderr, "Invalid argument: controlbar object is NULL\n");
3059 wd = elm_widget_data_get(obj);
3062 fprintf(stderr, "Cannot get smart data\n");
3065 wd->view_content = view;
3066 //edje_object_part_swallow(wd->view, "elm.swallow.view", wd->view_content);
3067 elm_layout_content_set(wd->view, "elm.swallow.view", wd->view_content);
3071 * Set the view of the item
3073 * @param it The item of controlbar
3074 * @param view The view for the item
3076 * @ingroup Controlbar
3079 elm_controlbar_item_view_set(Elm_Controlbar_Item *it, Evas_Object * view)
3085 * Set the mode of the controlbar
3087 * @param obj The object of the controlbar
3088 * @param mode The mode of the controlbar
3090 * @ingroup Controlbar
3093 elm_controlbar_mode_set(Evas_Object *obj, int mode)
3098 fprintf(stderr, "Invalid argument: controlbar object is NULL\n");
3101 wd = elm_widget_data_get(obj);
3104 fprintf(stderr, "Cannot get smart data\n");
3108 if(wd->mode == mode) return;
3112 case ELM_CONTROLBAR_MODE_DEFAULT:
3113 edje_object_signal_emit(wd->edje, "elm,state,default", "elm");
3115 case ELM_CONTROLBAR_MODE_TRANSLUCENCE:
3116 edje_object_signal_emit(wd->edje, "elm,state,translucence", "elm");
3118 case ELM_CONTROLBAR_MODE_TRANSPARENCY:
3119 edje_object_signal_emit(wd->edje, "elm,state,transparency", "elm");
3121 case ELM_CONTROLBAR_MODE_LARGE:
3122 edje_object_signal_emit(wd->edje, "elm,state,large", "elm");
3124 case ELM_CONTROLBAR_MODE_SMALL:
3125 edje_object_signal_emit(wd->edje, "elm,state,small", "elm");
3134 * Set auto-align mode of the controlbar(It's not prepared yet)
3135 * If you set the auto-align and add items more than 5,
3136 * the "more" item will be made and the items more than 5 will be unvisible.
3138 * @param obj The object of the controlbar
3139 * @param auto_align The dicision that the controlbar use the auto-align
3141 * @ingroup Controlbar
3144 elm_controlbar_item_auto_align_set(Evas_Object *obj, Eina_Bool auto_align)
3147 Elm_Controlbar_Item *item;
3152 fprintf(stderr, "Invalid argument: controlbar object is NULL\n");
3155 wd = elm_widget_data_get(obj);
3158 fprintf(stderr, "Cannot get smart data\n");
3162 if(wd->auto_align == auto_align) return;
3166 if(check_bar_item_number(wd) >= 5 && !wd->more_item)
3169 EINA_LIST_FOREACH(wd->items, l, item)
3171 if(elm_controlbar_item_visible_get(item))
3174 item_delete_in_bar(item);
3177 item = elm_controlbar_last_item_get(obj);
3178 while(!elm_controlbar_item_visible_get(item)){
3179 item = elm_controlbar_item_prev(item);
3181 create_more_item(wd, item->style);
3189 if(wd->more_item->view)
3190 evas_object_del(wd->more_item->view);
3191 wd->items = eina_list_remove(wd->items, wd->more_item);
3192 eina_stringshare_del(wd->more_item->label);
3193 if (wd->more_item->icon)
3194 evas_object_del(wd->more_item->icon);
3195 if (wd->more_item->base)
3196 evas_object_del(wd->more_item->base);
3197 if (wd->more_item->edit_item)
3198 evas_object_del(wd->more_item->edit_item);
3199 free(wd->more_item);
3200 wd->more_item = NULL;
3202 // make all item is visible
3204 EINA_LIST_FOREACH(wd->items, l, item)
3206 if(!elm_controlbar_item_visible_get(item))
3207 item_insert_in_bar(item, i);
3212 wd->auto_align = auto_align;
3217 init_animation(void *data)
3220 Elm_Controlbar_Item * item;
3221 Widget_Data * wd = (Widget_Data *)data;
3223 wd->visible_items = eina_list_free(wd->visible_items);
3224 EINA_LIST_FOREACH(wd->items, l, item)
3228 wd->visible_items = eina_list_append(wd->visible_items, item->base);
3233 wd->ani_func(wd->ani_data, wd->object, wd->visible_items);
3235 return ECORE_CALLBACK_CANCEL;
3240 * Set the animation of the controlbar(Don't use this API)
3242 * @param obj The object of the controlbar
3243 * @param func The function for start animation
3244 * @param data The data for function
3246 * @ingroup Controlbar
3249 elm_controlbar_animation_set(Evas_Object *obj, void (*func) (void *data, Evas_Object *obj, void *event_info), void *data)
3251 printf("\n==================================\n");
3252 printf("%s\n", __func__);
3253 printf("==================================\n");
3254 printf("This API is just for test.\n");
3255 printf("Please don't use it!!\n");
3256 printf("Thank you.\n");
3257 printf("==================================\n");
3262 fprintf(stderr, "Invalid argument: controlbar object is NULL\n");
3265 wd = elm_widget_data_get(obj);
3268 fprintf(stderr, "Cannot get smart data\n");
3274 wd->init_animation = EINA_TRUE;
3276 wd->ani_func = func;
3277 wd->ani_data = data;
3279 ecore_idler_add(init_animation, wd);
3284 * Set the animation of the controlbar(Don't use this API)
3286 * @param obj The object of the controlbar
3287 * @param auto_animation The dicision that items move automatically
3288 * @param selected_animation The dicision that the selected item move automatically
3290 * @ingroup Controlbar
3293 elm_controlbar_item_animation_set(Evas_Object *obj, Eina_Bool auto_animation, Eina_Bool selected_animation)
3295 printf("\n==================================\n");
3296 printf("%s\n", __func__);
3297 printf("==================================\n");
3298 printf("This API is just for test.\n");
3299 printf("Please don't use it!!\n");
3300 printf("Thank you.\n");
3301 printf("==================================\n");
3306 fprintf(stderr, "Invalid argument: controlbar object is NULL\n");
3309 wd = elm_widget_data_get(obj);
3312 fprintf(stderr, "Cannot get smart data\n");
3316 if(auto_animation && !wd->effect_timer)
3318 wd->effect_timer = ecore_timer_add(1, item_animation_effect, wd);
3322 if(wd->effect_timer) ecore_timer_del(wd->effect_timer);
3323 wd->effect_timer = NULL;
3326 wd->selected_animation = selected_animation;