1 #include <Elementary.h>
5 * @defgroup Softkey Softkey
12 * internal data structure of softkey object
14 #define BTN_ANIMATOR_MAX 4
15 #define PANEL_ANIMATOR_MAX 1
16 typedef struct _Widget_Data Widget_Data;
21 Evas_Object *button[2];
24 Evas_Object *glow_obj;
26 Evas_Coord x, y, w, h;
27 Evas_Coord glow_w, glow_h;
29 Evas_Coord panel_height;
30 Ecore_Animator *animator;
32 unsigned int panel_btn_idx;
33 Eina_Bool button_show[2];
34 Eina_Bool show_panel :1;
35 Eina_Bool animating :1;
36 Eina_Bool is_horizontal;
39 Eina_Bool panel_suppported;
42 struct _Elm_Softkey_Item
49 (*func)(void *data, Evas_Object *obj, void *event_info);
51 Eina_Bool disabled :1;
55 _item_disable(Elm_Softkey_Item *it, Eina_Bool disabled);
57 _del_hook(Evas_Object *obj);
59 _theme_hook(Evas_Object *obj);
61 _sizing_eval(Evas_Object *obj);
63 _sub_del(void *data, Evas_Object *obj, void *event_info);
69 _softkey_down_cb(void *data, Evas_Object *obj, const char *emission,
72 _softkey_up_cb(void *data, Evas_Object *obj, const char *emission,
76 _panel_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
78 _panel_up_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
81 _more_btn_click_cb(void *data, Evas_Object *obj, const char *emission,
84 _close_btn_click_cb(void *data, Evas_Object *obj, const char *emission,
87 _bg_click_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
90 _show_button_animator_cb(void *data);
92 _hide_button_animator_cb(void *data);
94 _panel_up_animator_cb(void *data);
96 _panel_down_animator_cb(void *data);
102 _show_button(Evas_Object *obj, Elm_Softkey_Type type, Eina_Bool show);
104 _delete_button(Evas_Object *obj);
107 _softkey_object_move(void *data, Evas *e, Evas_Object *obj, void *event_info);
109 _softkey_object_resize(void *data, Evas *e, Evas_Object *obj, void *event_info);
111 _softkey_object_show(void *data, Evas *e, Evas_Object *obj, void *event_info);
113 _softkey_object_hide(void *data, Evas *e, Evas_Object *obj, void *event_info);
115 _softkey_horizontal_set(Evas_Object *obj, Eina_Bool horizontal_mode);
117 _icon_disable(Evas_Object *icon, Eina_Bool disabled)
122 edj = elm_layout_edje_get(icon);
128 edje_object_signal_emit(icon, "elm,state,disabled", "elm");
132 edje_object_signal_emit(edj, "elm,state,disabled", "elm");
139 edje_object_signal_emit(icon, "elm,state,enabled", "elm");
143 edje_object_signal_emit(edj, "elm,state,enabled", "elm");
149 _item_disable(Elm_Softkey_Item *it, Eina_Bool disabled)
151 Widget_Data *wd = elm_widget_data_get(it->obj);
153 if (it->disabled == disabled) return;
154 it->disabled = disabled;
157 edje_object_signal_emit(it->base, "elm,state,disabled", "elm");
161 edje_object_signal_emit(it->base, "elm,state,enabled", "elm");
164 _icon_disable(it->icon, disabled);
168 _del_hook(Evas_Object *obj)
172 Widget_Data *wd = elm_widget_data_get(obj);
175 evas_object_event_callback_del(obj, EVAS_CALLBACK_RESIZE,
176 _softkey_object_resize);
177 evas_object_event_callback_del(obj, EVAS_CALLBACK_MOVE, _softkey_object_move);
178 evas_object_event_callback_del(obj, EVAS_CALLBACK_SHOW, _softkey_object_show);
179 evas_object_event_callback_del(obj, EVAS_CALLBACK_HIDE, _softkey_object_hide);
182 for (i = 0; i < 2; i++)
187 //_delete_button(btn);
188 evas_object_del(wd->button[i]);
189 wd->button[i] = NULL;
193 //evas_object_smart_callback_del(obj, "sub-object-del", _sub_del);
199 elm_softkey_panel_del(obj);
202 /* delete glow effect image */
205 evas_object_del(wd->glow_obj);
210 evas_object_del(wd->lay);
218 _theme_hook(Evas_Object *obj)
220 Elm_Softkey_Item* item;
221 Widget_Data *wd = elm_widget_data_get(obj);
222 Elm_Softkey_Item *it;
229 _elm_theme_object_set(obj, wd->lay, "softkey", "bg",
230 elm_widget_style_get(obj));
231 _elm_theme_object_set(obj, wd->glow_obj, "softkey", "glow", "default");
233 if (wd->button[ELM_SK_LEFT_BTN])
236 item = evas_object_data_get(wd->button[ELM_SK_LEFT_BTN], "item_data");
237 _elm_theme_object_set(obj, wd->button[ELM_SK_LEFT_BTN], "softkey",
238 "button_left", elm_widget_style_get(obj));
240 elm_softkey_item_label_set(item, item->label);
244 if (wd->button[ELM_SK_RIGHT_BTN])
247 item = evas_object_data_get(wd->button[ELM_SK_RIGHT_BTN], "item_data");
249 _elm_theme_object_set(obj, wd->button[ELM_SK_RIGHT_BTN], "softkey",
250 "button_right", elm_widget_style_get(obj));
252 elm_softkey_item_label_set(item, item->label);
258 _elm_theme_object_set(obj, wd->panel, "softkey", "panel",
259 elm_widget_style_get(obj));
260 if (wd->panel_btn_idx > 0)
263 edje_object_signal_emit(wd->lay, "more_btn_show", "");
264 EINA_LIST_FOREACH (wd->items, l, it)
266 _elm_theme_object_set(obj, it->base, "softkey", "panel_button",
267 elm_widget_style_get(obj));
270 edje_object_part_text_set(it->base, "elm.text", it->label); // set text
280 _sub_del(void *data, Evas_Object *obj, void *event_info)
282 Widget_Data *wd = elm_widget_data_get(obj);
283 Evas_Object *sub = event_info;
285 Elm_Softkey_Item *it;
288 EINA_LIST_FOREACH(wd->items, l, it)
299 _sizing_eval(Evas_Object *obj)
301 Widget_Data *wd = elm_widget_data_get(obj);
305 _softkey_object_move(obj, NULL, obj, NULL);
306 _softkey_object_resize(obj, NULL, obj, NULL);
310 _panel_up_animator_cb(void *data)
312 int max = PANEL_ANIMATOR_MAX;
313 static int progress = 0;
317 wd = elm_widget_data_get(data);
321 wd->animating = EINA_TRUE;
325 if (!wd->animator) return 0;
326 ecore_animator_del(wd->animator);
328 wd->animating = EINA_FALSE;
329 wd->show_panel = EINA_TRUE;
337 ypos = wd->win_h - (wd->panel_height * progress / max);
338 evas_object_move(wd->panel, wd->x, ypos);
345 _panel_down_animator_cb(void *data)
347 int max = PANEL_ANIMATOR_MAX;
348 static int progress = 0;
352 wd = elm_widget_data_get(data);
356 wd->animating = EINA_TRUE;
360 if (!wd->animator) return 0;
361 ecore_animator_del(wd->animator);
363 wd->animating = EINA_FALSE;
364 //wd->animator = ecore_animator_add(_show_button_animator_cb, data);
365 wd->show_panel = EINA_FALSE;
368 evas_object_smart_callback_call(data, "panel,hide", NULL);
373 /* move down panel */
376 ypos = wd->win_h - wd->panel_height + (wd->panel_height * progress / max);
377 evas_object_move(wd->panel, wd->x, ypos);
384 _hide_button_animator_cb(void *data)
386 int max = BTN_ANIMATOR_MAX;
387 static int progress = 0;
389 Evas_Coord btn_w, xpos;
391 wd = elm_widget_data_get(data);
395 wd->animating = EINA_TRUE;
399 if (!wd->animator) return 0;
400 ecore_animator_del(wd->animator);
401 wd->animating = EINA_FALSE;
402 wd->animator = ecore_animator_add(_panel_up_animator_cb, data);
407 /* move left button */
408 if (wd->button[ELM_SK_LEFT_BTN])
410 edje_object_part_geometry_get(wd->button[ELM_SK_LEFT_BTN], "button_rect",
411 NULL, NULL, &btn_w, NULL);
412 //evas_object_geometry_get(wd->button[ELM_SK_LEFT_BTN], NULL, NULL, &btn_w, NULL);
413 xpos = wd->x + -1 * btn_w * progress / max;
414 evas_object_move(wd->button[ELM_SK_LEFT_BTN], xpos, wd->y);
417 /* move right button */
418 if (wd->button[ELM_SK_RIGHT_BTN])
420 edje_object_part_geometry_get(wd->button[ELM_SK_RIGHT_BTN],
421 "button_rect", NULL, NULL, &btn_w, NULL);
422 //evas_object_geometry_get(wd->button[ELM_SK_RIGHT_BTN], NULL, NULL, &btn_w, NULL);
423 xpos = (wd->x + wd->w - btn_w) + (btn_w * progress / max);
424 evas_object_move(wd->button[ELM_SK_RIGHT_BTN], xpos, wd->y);
431 _show_button_animator_cb(void *data)
433 int max = BTN_ANIMATOR_MAX;
434 static int progress = 0;
436 Evas_Coord btn_w, xpos;
438 wd = elm_widget_data_get(data);
443 wd->animating = EINA_TRUE;
447 if (!wd->animator) return 0;
448 ecore_animator_del(wd->animator);
449 wd->animating = EINA_FALSE;
454 /* move left button */
455 if (wd->button[ELM_SK_LEFT_BTN])
457 edje_object_part_geometry_get(wd->button[ELM_SK_LEFT_BTN], "button_rect",
458 NULL, NULL, &btn_w, NULL);
459 //evas_object_geometry_get(wd->button[ELM_SK_LEFT_BTN], NULL, NULL, &btn_w, NULL);
460 xpos = wd->x + (-1 * btn_w) + (btn_w * progress / max);
461 evas_object_move(wd->button[ELM_SK_LEFT_BTN], xpos, wd->y);
464 /* move right button */
465 if (wd->button[ELM_SK_RIGHT_BTN])
467 edje_object_part_geometry_get(wd->button[ELM_SK_RIGHT_BTN],
468 "button_rect", NULL, NULL, &btn_w, NULL);
469 //evas_object_geometry_get(wd->button[ELM_SK_RIGHT_BTN], NULL, NULL, &btn_w, NULL);
470 xpos = wd->x + wd->w - (btn_w * progress / max);
471 evas_object_move(wd->button[ELM_SK_RIGHT_BTN], xpos, wd->y);
478 _more_btn_click_cb(void *data, Evas_Object *obj, const char *emission,
482 wd = elm_widget_data_get(data);
485 evas_object_smart_callback_call(data, "panel,show", NULL);
487 if (!wd->panel) return;
488 evas_object_show(wd->panel);
492 evas_object_show(wd->bg_rect);
495 /*if (wd->animating == EINA_FALSE) {
496 wd->animator = ecore_animator_add(_hide_button_animator_cb, data);
498 if (wd->animating == EINA_FALSE)
500 wd->animator = ecore_animator_add(_panel_up_animator_cb, data);
505 _close_panel(Evas_Object *obj)
508 wd = elm_widget_data_get(obj);
513 evas_object_hide(wd->bg_rect);
516 if (!wd->panel) return;
518 if (wd->animating == EINA_FALSE)
520 wd->animator = ecore_animator_add(_panel_down_animator_cb, obj);
525 _bg_click_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
531 _close_btn_click_cb(void *data, Evas_Object *obj, const char *emission,
538 _show_button(Evas_Object *obj, Elm_Softkey_Type type, Eina_Bool show)
542 Widget_Data *wd = elm_widget_data_get(obj);
543 Evas_Object *btn = wd->button[type];
546 /* Make visible button */
549 wd->button_show[type] = EINA_TRUE;
550 evas_object_show(btn);
554 wd->button_show[type] = EINA_FALSE;
555 evas_object_hide(btn);
562 _arrange_button(Evas_Object *obj, Elm_Softkey_Type type)
565 Evas_Coord btn_w = 0;
569 wd = elm_widget_data_get(obj);
572 btn = wd->button[type];
577 case ELM_SK_LEFT_BTN:
578 evas_object_move(btn, wd->x, wd->y);
580 case ELM_SK_RIGHT_BTN:
581 edje_object_part_geometry_get(btn, "button_rect", NULL, NULL, &btn_w,
583 //evas_object_geometry_get(btn, NULL, NULL, &btn_w, NULL);
584 evas_object_move(btn, wd->x + wd->w - btn_w, wd->y);
594 _softkey_up_cb(void *data, Evas_Object *obj, const char *emission,
599 Elm_Softkey_Item *it = (Elm_Softkey_Item *) data;
600 elm_softkey_panel_close(it->obj);
603 edj = elm_layout_edje_get(it->icon);
605 edje_object_signal_emit(edj, "elm,state,unselected", "elm");
608 it->func((void *) (it->data), it->obj, it);
610 evas_object_smart_callback_call(it->obj, "clicked", it);
614 _softkey_down_cb(void *data, Evas_Object *obj, const char *emission,
619 Elm_Softkey_Item *it = (Elm_Softkey_Item *) data;
620 evas_object_smart_callback_call(it->obj, "press", it);
622 if (!it->icon) return;
623 edj = elm_layout_edje_get(it->icon);
626 edje_object_signal_emit(edj, "elm,state,selected", "elm");
630 _panel_up_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
632 Elm_Softkey_Item *it = (Elm_Softkey_Item *) data;
635 wd = elm_widget_data_get(it->obj);
636 if (wd == NULL) return;
638 /* hide glow effect */
641 evas_object_hide(wd->glow_obj);
644 elm_softkey_panel_close(it->obj);
646 it->func((void *) (it->data), it->obj, it);
648 evas_object_smart_callback_call(it->obj, "clicked", it);
652 _panel_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
654 Evas_Coord glow_x, glow_y;
657 Elm_Softkey_Item *it = (Elm_Softkey_Item *) data;
658 wd = elm_widget_data_get(it->obj);
659 if (wd == NULL) return;
661 /* show glow effect */
664 Evas_Event_Mouse_Down *ev = (Evas_Event_Mouse_Down *) event_info;
665 glow_x = ev->canvas.x - (wd->glow_w / 2);
666 glow_y = ev->canvas.y - (wd->glow_h / 2);
668 evas_object_move(wd->glow_obj, glow_x, glow_y);
669 evas_object_show(wd->glow_obj);
672 evas_object_smart_callback_call(it->obj, "press", it);
676 _delete_button(Evas_Object *obj)
682 evas_object_del(obj);
690 _calc_win_height(Widget_Data *wd)
692 wd->win_h = wd->y + wd->h;
696 evas_object_resize(wd->bg_rect, wd->w, wd->win_h);
697 evas_object_move(wd->bg_rect, wd->x, 0);
704 evas_object_move(wd->panel, wd->x, (wd->win_h - wd->panel_height));
708 evas_object_move(wd->panel, wd->x, wd->win_h);
714 _softkey_object_move(void *data, Evas *e, Evas_Object *obj, void *event_info)
721 wd = elm_widget_data_get((Evas_Object *) data);
724 evas_object_geometry_get(wd->lay, &x, &y, NULL, NULL);
729 evas_object_move(wd->lay, x, y);
731 for (i = 0; i < 2; i++)
733 _arrange_button((Evas_Object *) data, i);
736 _calc_win_height(wd);
740 _softkey_object_resize(void *data, Evas *e, Evas_Object *obj, void *event_info)
749 wd = elm_widget_data_get((Evas_Object *) data);
752 evas_object_geometry_get(wd->lay, NULL, NULL, &w, &h);
757 if (!wd->lay) return;
758 evas_object_resize(wd->lay, w, h);
761 for (i = 0; i < 2; i++)
766 edje_object_part_geometry_get(btn, "button_rect", NULL, NULL, &btn_w,
768 evas_object_resize(btn, btn_w, h);
769 _arrange_button((Evas_Object *) data, i);
773 if (wd->w >= wd->win_h)
775 _softkey_horizontal_set(data, EINA_TRUE);
779 _softkey_horizontal_set(data, EINA_FALSE);
781 _calc_win_height(wd);
785 _softkey_object_show(void *data, Evas *e, Evas_Object *obj, void *event_info)
787 Widget_Data *wd = NULL;
790 if (data == NULL) return;
791 wd = elm_widget_data_get((Evas_Object *) data);
792 if (wd == NULL) return;
796 evas_object_show(wd->lay);
800 for (i = 0; i < 2; i++)
803 if (btn != NULL && wd->button_show[i] == EINA_TRUE)
805 evas_object_show(btn);
806 //evas_object_clip_set(btn, evas_object_clip_get((Evas_Object *)data));
809 if (wd->panel_btn_idx > 0)
811 /* show more button */
812 edje_object_signal_emit(wd->lay, "more_btn_show", "");
817 _softkey_object_hide(void *data, Evas *e, Evas_Object *obj, void *event_info)
819 Widget_Data *wd = NULL;
823 if (data == NULL) return;
824 wd = elm_widget_data_get((Evas_Object *) data);
825 if (wd == NULL) return;
829 evas_object_hide(wd->lay);
833 for (i = 0; i < 2; i++)
838 evas_object_hide(btn);
842 if (wd->panel_btn_idx > 0)
844 /* hide more button */
845 edje_object_signal_emit(wd->lay, "more_btn_hide", "");
850 * Add a new softkey to the parent
852 * @param parent the parent of the smart object
853 * @return Evas_Object* pointer of softkey(evas object) or NULL
857 elm_softkey_add(Evas_Object *parent)
859 Evas_Object *obj = NULL;
860 Widget_Data *wd = NULL;
863 wd = ELM_NEW(Widget_Data);
864 e = evas_object_evas_get(parent);
865 if (e == NULL) return NULL;
866 obj = elm_widget_add(e);
867 elm_widget_type_set(obj, "softkey");
868 elm_widget_sub_object_add(parent, obj);
869 elm_widget_data_set(obj, wd);
870 elm_widget_del_hook_set(obj, _del_hook);
871 elm_widget_theme_hook_set(obj, _theme_hook);
873 /* load background edj */
874 wd->lay = edje_object_add(e);
875 _elm_theme_object_set(obj, wd->lay, "softkey", "bg", "default");
878 printf("Cannot load bg edj\n");
881 elm_widget_resize_object_set(obj, wd->lay);
882 edje_object_signal_callback_add(wd->lay, "clicked", "more_btn",
883 _more_btn_click_cb, obj);
885 evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE,
886 _softkey_object_resize, obj);
887 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOVE,
888 _softkey_object_move, obj);
889 evas_object_event_callback_add(obj, EVAS_CALLBACK_SHOW,
890 _softkey_object_show, obj);
891 evas_object_event_callback_add(obj, EVAS_CALLBACK_HIDE,
892 _softkey_object_hide, obj);
893 wd->is_horizontal = EINA_FALSE;
894 wd->panel_suppported = EINA_TRUE;
895 wd->scale_factor = elm_scale_get();
896 if (wd->scale_factor == 0.0)
898 wd->scale_factor = 1.0;
901 /* load glow effect */
902 wd->glow_obj = edje_object_add(e);
903 _elm_theme_object_set(obj, wd->glow_obj, "softkey", "glow", "default");
904 evas_object_geometry_get(wd->glow_obj, NULL, NULL, &wd->glow_w, &wd->glow_h);
905 evas_object_resize(wd->glow_obj, wd->glow_w, wd->glow_h);
908 //evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
910 wd->button[ELM_SK_LEFT_BTN] = wd->button[ELM_SK_RIGHT_BTN] = NULL;
913 wd->show_panel = EINA_FALSE;
920 _softkey_horizontal_set(Evas_Object *obj, Eina_Bool horizontal_mode)
925 wd = elm_widget_data_get(obj);
927 wd->is_horizontal = horizontal_mode;
930 if ((edje_object_data_get(wd->panel, "max_item_count") == NULL)
931 || (edje_object_data_get(wd->panel, "panel_height") == NULL)
932 || (edje_object_data_get(wd->panel, "panel_height_horizontal")
935 wd->panel_suppported = EINA_FALSE;
938 wd->panel_suppported = EINA_TRUE;
939 if (wd->panel_suppported == EINA_TRUE)
941 if (wd->is_horizontal == EINA_TRUE)
943 snprintf(buff, sizeof(buff), "button_%d", (wd->panel_btn_idx
945 edje_object_signal_emit(wd->panel, buff, "panel_rect");
947 = (int) (atoi(edje_object_data_get(wd->panel, buff))
953 edje_object_data_get(wd->panel,
954 "panel_height_horizontal"))
955 * wd->scale_factor)));
959 snprintf(buff, sizeof(buff), "button_%d", (wd->panel_btn_idx));
960 edje_object_signal_emit(wd->panel, buff, "panel_rect");
962 = (int) (atoi(edje_object_data_get(wd->panel, buff))
968 edje_object_data_get(wd->panel,
970 * wd->scale_factor)));
973 _calc_win_height(wd);
979 * add side button of softkey
980 * @param obj softkey object
981 * @param type softkey button type
982 * @param icon The icon object to use for the item
983 * @param label The text label to use for the item
984 * @param func Convenience function to call when this item is selected
985 * @param data Data to pass to convenience function
986 * @return A handle to the item added
990 EAPI Elm_Softkey_Item *
991 elm_softkey_button_add(Evas_Object *obj, Elm_Softkey_Type type,
992 Evas_Object *icon, const char *label, void
993 (*func)(void *data, Evas_Object *obj, void *event_info),
998 char button_type[64];
999 Elm_Softkey_Item *it;
1001 if (!obj) return NULL;
1002 wd = elm_widget_data_get(obj);
1003 if (!wd) return NULL;
1005 if (wd->button[type])
1007 printf("already created.\n");
1012 evas = evas_object_evas_get(obj);
1013 if (!evas) return NULL;
1016 it = ELM_NEW(Elm_Softkey_Item);
1022 /* load button edj */
1023 if (wd->button[type] == NULL)
1025 if (type == ELM_SK_LEFT_BTN)
1027 strcpy(button_type, "button_left");
1031 strcpy(button_type, "button_right");
1034 it->base = wd->button[type] = edje_object_add(evas);
1035 if (!wd->button[type])
1040 _elm_theme_object_set(obj, wd->button[type], "softkey", button_type,
1041 elm_widget_style_get(obj));
1043 wd->button_show[type] = EINA_TRUE;
1044 if (evas_object_visible_get(obj))
1046 evas_object_show(wd->button[type]);
1048 evas_object_smart_member_add(wd->button[type], obj);
1050 edje_object_signal_callback_add(wd->button[type], "elm,action,down", "",
1051 _softkey_down_cb, it);
1052 edje_object_signal_callback_add(wd->button[type], "elm,action,click", "",
1053 _softkey_up_cb, it);
1055 evas_object_clip_set(wd->button[type], evas_object_clip_get(obj));
1056 if (wd->panel) evas_object_raise(wd->panel);
1061 elm_softkey_item_label_set(it, label);
1062 elm_softkey_item_icon_set(it, icon);
1063 if (wd->button[type])
1064 evas_object_data_set(wd->button[type], "item_data", it);
1067 if (it->label) eina_stringshare_del(it->label);
1077 * delete side button of softkey
1078 * @param obj softkey object
1079 * @param type softkey button type
1084 elm_softkey_button_del(Evas_Object *obj, Elm_Softkey_Type type)
1087 Elm_Softkey_Item *it;
1092 printf("Invalid argument: softkey object is NULL\n");
1096 wd = elm_widget_data_get(obj);
1099 btn = wd->button[type];
1102 it = evas_object_data_get(btn, "item_data");
1103 //_delete_button(btn);
1104 edje_object_signal_callback_del(wd->button[type], "elm,action,down", "",
1106 edje_object_signal_callback_del(wd->button[type], "elm,action,click", "",
1108 evas_object_del(wd->button[type]);
1109 if (it->label) eina_stringshare_del(it->label);
1110 if (it->icon) evas_object_del(it->icon);
1112 wd->button[type] = NULL;
1116 * show button of softkey
1117 * @param obj softkey object
1118 * @param type softkey button type
1123 elm_softkey_button_show(Evas_Object *obj, Elm_Softkey_Type type)
1125 _show_button(obj, type, EINA_TRUE);
1129 * hide button of softkey
1130 * @param obj softkey object
1131 * @param type softkey button type
1136 elm_softkey_button_hide(Evas_Object *obj, Elm_Softkey_Type type)
1138 _show_button(obj, type, EINA_FALSE);
1143 * @param obj softkey object
1144 * @param icon The icon object
1145 * @param label The text label to use for the item
1146 * @param func Convenience function to call when this item is selected
1147 * @param data Data to pass to convenience function
1148 * @return A handle to the item added
1152 EAPI Elm_Softkey_Item *
1153 elm_softkey_panel_item_add(Evas_Object *obj, Evas_Object *icon,
1154 const char *label, void
1155 (*func)(void *data, Evas_Object *obj,
1156 void *event_info), const void *data)
1160 char button_name[32];
1162 Elm_Softkey_Item *it;
1163 char buff[PATH_MAX];
1165 wd = elm_widget_data_get(obj);
1168 printf("Cannot get smart data\n");
1173 evas = evas_object_evas_get(obj);
1174 if (!evas) return NULL;
1176 if (wd->panel == NULL)
1179 wd->bg_rect = evas_object_rectangle_add(evas);
1180 if (!wd->bg_rect) return NULL;
1181 evas_object_color_set(wd->bg_rect, 10, 10, 10, 150);
1182 evas_object_pass_events_set(wd->bg_rect, 0);
1186 evas_object_resize(wd->bg_rect, wd->w, wd->win_h);
1187 evas_object_event_callback_add(wd->bg_rect, EVAS_CALLBACK_MOUSE_UP,
1189 evas_object_smart_member_add(wd->bg_rect, obj);
1192 wd->panel = edje_object_add(evas);
1193 if (!wd->panel) return NULL;
1194 _elm_theme_object_set(obj, wd->panel, "softkey", "panel",
1195 elm_widget_style_get(obj));
1197 evas_object_move(wd->panel, 0, wd->win_h);
1198 edje_object_signal_callback_add(wd->panel, "clicked", "close_btn",
1199 _close_btn_click_cb, obj);
1200 evas_object_smart_member_add(wd->panel, obj);
1201 if (evas_object_visible_get(obj))
1203 evas_object_show(wd->panel);
1205 wd->panel_height = 0;
1206 if ((edje_object_data_get(wd->panel, "max_item_count") == NULL)
1207 || (edje_object_data_get(wd->panel, "panel_height") == NULL)
1208 || (edje_object_data_get(wd->panel, "panel_height_horizontal")
1211 //If this key is not found in data section, then it means the panel won't come.
1216 elm_softkey_panel_del(obj);
1218 wd->panel_suppported = EINA_FALSE;
1223 wd->max_button = (int) (atoi(edje_object_data_get(wd->panel,
1224 "max_item_count")));
1225 if (wd->is_horizontal)
1231 edje_object_data_get(wd->panel,
1232 "panel_height_horizontal"))
1233 * wd->scale_factor)));
1241 edje_object_data_get(wd->panel,
1243 * wd->scale_factor)));
1247 evas_object_clip_set(wd->panel, evas_object_clip_get(obj));
1250 wd->panel_btn_idx++;
1251 if (wd->panel_btn_idx >= wd->max_button) return NULL;
1254 it = ELM_NEW(Elm_Softkey_Item);
1256 if (label) it->label = eina_stringshare_add(label);
1260 /* load panel button */
1261 it->base = btn = edje_object_add(evas);
1264 if (it->label) eina_stringshare_del(it->label);
1266 wd->panel_btn_idx--;
1269 _elm_theme_object_set(obj, btn, "softkey", "panel_button",
1270 elm_widget_style_get(obj));
1272 edje_object_part_text_set(btn, "elm.text", label); /* set text */
1273 //edje_object_message_signal_process(btn);
1277 /* swallow button */
1278 snprintf(button_name, sizeof(button_name), "panel_button_area_%d",
1280 edje_object_part_swallow(wd->panel, button_name, btn);
1282 if (wd->is_horizontal)
1284 snprintf(buff, sizeof(buff), "button_%d", wd->max_button
1285 + wd->panel_btn_idx);
1286 edje_object_signal_emit(wd->panel, buff, "panel_rect");
1287 const char* val = edje_object_data_get(wd->panel, buff);
1289 wd->panel_height = (int) (atoi(val) * wd->scale_factor);
1292 if (it->label) eina_stringshare_del(it->label);
1293 evas_object_del(it->base);
1295 wd->panel_btn_idx--;
1301 snprintf(buff, sizeof(buff), "button_%d", wd->panel_btn_idx);
1302 edje_object_signal_emit(wd->panel, buff, "panel_rect");
1303 const char* val = edje_object_data_get(wd->panel, buff);
1305 wd->panel_height = (int) (atoi(val) * wd->scale_factor);
1308 if (it->label) eina_stringshare_del(it->label);
1309 evas_object_del(it->base);
1311 wd->panel_btn_idx--;
1318 wd->panel_btn_idx--;
1321 evas_object_event_callback_add(btn, EVAS_CALLBACK_MOUSE_DOWN,
1322 _panel_down_cb, it);
1323 evas_object_event_callback_add(btn, EVAS_CALLBACK_MOUSE_UP, _panel_up_cb, it);
1324 wd->items = eina_list_append(wd->items, it);
1325 if (evas_object_visible_get(obj))
1327 /* show more button */
1328 edje_object_signal_emit(wd->lay, "more_btn_show", "");
1336 * @param obj softkey object
1337 * @return int 0 (SUCCESS) or -1 (FAIL)
1342 elm_softkey_panel_del(Evas_Object *obj)
1345 char button_name[32];
1348 Elm_Softkey_Item *it;
1350 wd = elm_widget_data_get(obj);
1352 if (wd->panel == NULL) return -1;
1355 ecore_animator_del(wd->animator);
1356 wd->animator = NULL;
1357 wd->animating = EINA_FALSE;
1359 /* delete background */
1362 //evas_object_event_callback_del(wd->bg_rect, EVAS_CALLBACK_MOUSE_UP, _bg_click_cb);
1363 evas_object_del(wd->bg_rect);
1367 for (i = 1; i <= wd->panel_btn_idx; i++)
1369 snprintf(button_name, sizeof(button_name), "panel_button_area_%d", i);
1370 btn = edje_object_part_swallow_get(wd->panel, button_name);
1371 //_delete_button(btn);
1374 //edje_object_part_unswallow(wd->panel, btn);
1375 //evas_object_event_callback_del(btn, EVAS_CALLBACK_MOUSE_DOWN, _panel_down_cb);
1376 //evas_object_event_callback_del(btn, EVAS_CALLBACK_MOUSE_UP, _panel_up_cb);
1377 evas_object_del(btn);
1381 EINA_LIST_FREE(wd->items, it)
1383 if (it->label) eina_stringshare_del(it->label);
1385 if (it->icon) it->icon = NULL;
1389 wd->panel_btn_idx = 0;
1390 wd->panel_height = 0;
1393 edje_object_signal_emit(wd->lay, "more_btn_hide", "");
1397 //evas_object_move(wd->panel, 0, wd->win_h);
1398 evas_object_clip_unset(wd->panel);
1399 evas_object_del(wd->panel);
1400 wd->show_panel = EINA_FALSE;
1408 * sliding up panel if it is closed
1410 * @param obj softkey object
1411 * @return int 0 (SUCCESS) or -1 (FAIL)
1416 elm_softkey_panel_open(Evas_Object *obj)
1419 wd = elm_widget_data_get(obj);
1422 if (!wd->panel) return -1;
1424 if (wd->show_panel == EINA_FALSE)
1426 _more_btn_click_cb(obj, NULL, NULL, NULL);
1433 * sliding down panel if it is opened
1435 * @param obj softkey object
1436 * @return int 0 (SUCCESS) or -1 (FAIL)
1441 elm_softkey_panel_close(Evas_Object *obj)
1444 wd = elm_widget_data_get(obj);
1447 if (wd->panel == NULL) return -1;
1449 if (wd->show_panel == EINA_TRUE)
1451 _close_btn_click_cb(obj, obj, NULL, NULL);
1458 * Set the icon of an softkey item
1460 * @param it The item to set the icon
1461 * @param icon The icon object
1466 elm_softkey_item_icon_set(Elm_Softkey_Item *it, Evas_Object *icon)
1470 if ((it->icon != icon) && (it->icon))
1472 //elm_widget_sub_object_del(it->obj, it->icon);
1473 evas_object_del(it->icon);
1477 if ((icon) && (it->icon != icon))
1480 //elm_widget_sub_object_add(it->obj, icon);
1481 edje_object_part_swallow(it->base, "elm.swallow.icon", icon);
1482 edje_object_signal_emit(it->base, "elm,state,icon,visible", "elm");
1483 //edje_object_message_signal_process(it->base);
1484 _sizing_eval(it->obj);
1491 * Get the icon of an softkey item
1493 * @param it The item to get the icon
1494 * @return The icon object
1499 elm_softkey_item_icon_get(Elm_Softkey_Item *it)
1501 if (!it) return NULL;
1506 * Get the text label of an softkey item
1508 * @param it The item to set the label
1509 * @param label label
1514 elm_softkey_item_label_set(Elm_Softkey_Item *it, const char *label)
1517 if (it->label) eina_stringshare_del(it->label);
1521 it->label = eina_stringshare_add(label);
1522 edje_object_signal_emit(it->base, "elm,state,text,visible", "elm");
1525 edje_object_part_text_set(it->base, "elm.text", label == NULL ? ""
1531 edje_object_signal_emit(it->base, "elm,state,text,hidden", "elm");
1533 //edje_object_message_signal_process(it->base);
1537 * Set the item callback function
1539 * @param it Item to set callback function.
1540 * @param func callback function pointer.
1541 * @param data callback function argument data.
1546 elm_softkey_item_callback_set(Elm_Softkey_Item* item, void
1547 (*func)(void *data, Evas_Object *obj, void *event_info), const void *data)
1557 * Get the text label of an softkey item
1559 * @param it The item to get the label
1560 * @return The text label of the softkey item
1565 elm_softkey_item_label_get(Elm_Softkey_Item *it)
1567 if (!it) return NULL;
1572 elm_softkey_item_disabled_get(Elm_Softkey_Item *it)
1574 if (!it) return EINA_FALSE;
1575 return it->disabled;
1579 elm_softkey_item_disabled_set(Elm_Softkey_Item *it, Eina_Bool disabled)
1582 _item_disable(it, disabled);