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");
607 if (it->func) it->func((void *) (it->data), it->obj, it);
608 evas_object_smart_callback_call(it->obj, "clicked", it);
612 _softkey_down_cb(void *data, Evas_Object *obj, const char *emission,
617 Elm_Softkey_Item *it = (Elm_Softkey_Item *) data;
618 evas_object_smart_callback_call(it->obj, "press", it);
620 if (!it->icon) return;
621 edj = elm_layout_edje_get(it->icon);
624 edje_object_signal_emit(edj, "elm,state,selected", "elm");
628 _panel_up_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
630 Elm_Softkey_Item *it = (Elm_Softkey_Item *) data;
633 wd = elm_widget_data_get(it->obj);
634 if (wd == NULL) return;
636 /* hide glow effect */
639 evas_object_hide(wd->glow_obj);
642 elm_softkey_panel_close(it->obj);
643 if (it->func) it->func((void *) (it->data), it->obj, it);
644 evas_object_smart_callback_call(it->obj, "clicked", it);
648 _panel_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
650 Evas_Coord glow_x, glow_y;
653 Elm_Softkey_Item *it = (Elm_Softkey_Item *) data;
654 wd = elm_widget_data_get(it->obj);
655 if (wd == NULL) return;
657 /* show glow effect */
660 Evas_Event_Mouse_Down *ev = (Evas_Event_Mouse_Down *) event_info;
661 glow_x = ev->canvas.x - (wd->glow_w / 2);
662 glow_y = ev->canvas.y - (wd->glow_h / 2);
664 evas_object_move(wd->glow_obj, glow_x, glow_y);
665 evas_object_show(wd->glow_obj);
668 evas_object_smart_callback_call(it->obj, "press", it);
672 _delete_button(Evas_Object *obj)
678 evas_object_del(obj);
686 _calc_win_height(Widget_Data *wd)
688 wd->win_h = wd->y + wd->h;
692 evas_object_resize(wd->bg_rect, wd->w, wd->win_h);
693 evas_object_move(wd->bg_rect, wd->x, 0);
700 evas_object_move(wd->panel, wd->x, (wd->win_h - wd->panel_height));
704 evas_object_move(wd->panel, wd->x, wd->win_h);
710 _softkey_object_move(void *data, Evas *e, Evas_Object *obj, void *event_info)
717 wd = elm_widget_data_get((Evas_Object *) data);
720 evas_object_geometry_get(wd->lay, &x, &y, NULL, NULL);
725 evas_object_move(wd->lay, x, y);
727 for (i = 0; i < 2; i++)
729 _arrange_button((Evas_Object *) data, i);
732 _calc_win_height(wd);
736 _softkey_object_resize(void *data, Evas *e, Evas_Object *obj, void *event_info)
745 wd = elm_widget_data_get((Evas_Object *) data);
748 evas_object_geometry_get(wd->lay, NULL, NULL, &w, &h);
753 if (!wd->lay) return;
754 evas_object_resize(wd->lay, w, h);
757 for (i = 0; i < 2; i++)
762 edje_object_part_geometry_get(btn, "button_rect", NULL, NULL, &btn_w,
764 evas_object_resize(btn, btn_w, h);
765 _arrange_button((Evas_Object *) data, i);
769 if (wd->w >= wd->win_h)
771 _softkey_horizontal_set(data, EINA_TRUE);
775 _softkey_horizontal_set(data, EINA_FALSE);
777 _calc_win_height(wd);
781 _softkey_object_show(void *data, Evas *e, Evas_Object *obj, void *event_info)
783 Widget_Data *wd = NULL;
786 if (data == NULL) return;
787 wd = elm_widget_data_get((Evas_Object *) data);
788 if (wd == NULL) return;
792 evas_object_show(wd->lay);
796 for (i = 0; i < 2; i++)
799 if (btn != NULL && wd->button_show[i] == EINA_TRUE)
801 evas_object_show(btn);
802 //evas_object_clip_set(btn, evas_object_clip_get((Evas_Object *)data));
805 if (wd->panel_btn_idx > 0)
807 /* show more button */
808 edje_object_signal_emit(wd->lay, "more_btn_show", "");
813 _softkey_object_hide(void *data, Evas *e, Evas_Object *obj, void *event_info)
815 Widget_Data *wd = NULL;
819 if (data == NULL) return;
820 wd = elm_widget_data_get((Evas_Object *) data);
821 if (wd == NULL) return;
825 evas_object_hide(wd->lay);
829 for (i = 0; i < 2; i++)
834 evas_object_hide(btn);
838 if (wd->panel_btn_idx > 0)
840 /* hide more button */
841 edje_object_signal_emit(wd->lay, "more_btn_hide", "");
846 * Add a new softkey to the parent
848 * @param parent the parent of the smart object
849 * @return Evas_Object* pointer of softkey(evas object) or NULL
853 elm_softkey_add(Evas_Object *parent)
855 Evas_Object *obj = NULL;
856 Widget_Data *wd = NULL;
859 wd = ELM_NEW(Widget_Data);
860 e = evas_object_evas_get(parent);
861 if (e == NULL) return NULL;
862 obj = elm_widget_add(e);
863 elm_widget_type_set(obj, "softkey");
864 elm_widget_sub_object_add(parent, obj);
865 elm_widget_data_set(obj, wd);
866 elm_widget_del_hook_set(obj, _del_hook);
867 elm_widget_theme_hook_set(obj, _theme_hook);
869 /* load background edj */
870 wd->lay = edje_object_add(e);
871 _elm_theme_object_set(obj, wd->lay, "softkey", "bg", "default");
874 printf("Cannot load bg edj\n");
877 elm_widget_resize_object_set(obj, wd->lay);
878 edje_object_signal_callback_add(wd->lay, "clicked", "more_btn",
879 _more_btn_click_cb, obj);
881 evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE,
882 _softkey_object_resize, obj);
883 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOVE,
884 _softkey_object_move, obj);
885 evas_object_event_callback_add(obj, EVAS_CALLBACK_SHOW,
886 _softkey_object_show, obj);
887 evas_object_event_callback_add(obj, EVAS_CALLBACK_HIDE,
888 _softkey_object_hide, obj);
889 wd->is_horizontal = EINA_FALSE;
890 wd->panel_suppported = EINA_TRUE;
891 wd->scale_factor = elm_scale_get();
892 if (wd->scale_factor == 0.0)
894 wd->scale_factor = 1.0;
897 /* load glow effect */
898 wd->glow_obj = edje_object_add(e);
899 _elm_theme_object_set(obj, wd->glow_obj, "softkey", "glow", "default");
900 evas_object_geometry_get(wd->glow_obj, NULL, NULL, &wd->glow_w, &wd->glow_h);
901 evas_object_resize(wd->glow_obj, wd->glow_w, wd->glow_h);
904 //evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
906 wd->button[ELM_SK_LEFT_BTN] = wd->button[ELM_SK_RIGHT_BTN] = NULL;
909 wd->show_panel = EINA_FALSE;
916 _softkey_horizontal_set(Evas_Object *obj, Eina_Bool horizontal_mode)
921 wd = elm_widget_data_get(obj);
923 wd->is_horizontal = horizontal_mode;
926 if ((edje_object_data_get(wd->panel, "max_item_count") == NULL)
927 || (edje_object_data_get(wd->panel, "panel_height") == NULL)
928 || (edje_object_data_get(wd->panel, "panel_height_horizontal")
931 wd->panel_suppported = EINA_FALSE;
934 wd->panel_suppported = EINA_TRUE;
935 if (wd->panel_suppported == EINA_TRUE)
937 if (wd->is_horizontal == EINA_TRUE)
939 snprintf(buff, sizeof(buff), "button_%d", (wd->panel_btn_idx
941 edje_object_signal_emit(wd->panel, buff, "panel_rect");
943 = (int) (atoi(edje_object_data_get(wd->panel, buff))
949 edje_object_data_get(wd->panel,
950 "panel_height_horizontal"))
951 * wd->scale_factor)));
955 snprintf(buff, sizeof(buff), "button_%d", (wd->panel_btn_idx));
956 edje_object_signal_emit(wd->panel, buff, "panel_rect");
958 = (int) (atoi(edje_object_data_get(wd->panel, buff))
964 edje_object_data_get(wd->panel,
966 * wd->scale_factor)));
969 _calc_win_height(wd);
975 * add side button of softkey
976 * @param obj softkey object
977 * @param type softkey button type
978 * @param icon The icon object to use for the item
979 * @param label The text label to use for the item
980 * @param func Convenience function to call when this item is selected
981 * @param data Data to pass to convenience function
982 * @return A handle to the item added
986 EAPI Elm_Softkey_Item *
987 elm_softkey_button_add(Evas_Object *obj, Elm_Softkey_Type type,
988 Evas_Object *icon, const char *label, void
989 (*func)(void *data, Evas_Object *obj, void *event_info),
994 char button_type[64];
995 Elm_Softkey_Item *it;
997 if (!obj) return NULL;
998 wd = elm_widget_data_get(obj);
999 if (!wd) return NULL;
1001 if (wd->button[type])
1003 printf("already created.\n");
1008 evas = evas_object_evas_get(obj);
1009 if (!evas) return NULL;
1012 it = ELM_NEW(Elm_Softkey_Item);
1018 /* load button edj */
1019 if (wd->button[type] == NULL)
1021 if (type == ELM_SK_LEFT_BTN)
1023 strcpy(button_type, "button_left");
1027 strcpy(button_type, "button_right");
1030 it->base = wd->button[type] = edje_object_add(evas);
1031 if (!wd->button[type])
1036 _elm_theme_object_set(obj, wd->button[type], "softkey", button_type,
1037 elm_widget_style_get(obj));
1039 wd->button_show[type] = EINA_TRUE;
1040 if (evas_object_visible_get(obj))
1042 evas_object_show(wd->button[type]);
1044 evas_object_smart_member_add(wd->button[type], obj);
1046 edje_object_signal_callback_add(wd->button[type], "elm,action,down", "",
1047 _softkey_down_cb, it);
1048 edje_object_signal_callback_add(wd->button[type], "elm,action,click", "",
1049 _softkey_up_cb, it);
1051 evas_object_clip_set(wd->button[type], evas_object_clip_get(obj));
1052 if (wd->panel) evas_object_raise(wd->panel);
1057 elm_softkey_item_label_set(it, label);
1058 elm_softkey_item_icon_set(it, icon);
1059 if (wd->button[type])
1060 evas_object_data_set(wd->button[type], "item_data", it);
1063 if (it->label) eina_stringshare_del(it->label);
1073 * delete side button of softkey
1074 * @param obj softkey object
1075 * @param type softkey button type
1080 elm_softkey_button_del(Evas_Object *obj, Elm_Softkey_Type type)
1083 Elm_Softkey_Item *it;
1088 printf("Invalid argument: softkey object is NULL\n");
1092 wd = elm_widget_data_get(obj);
1095 btn = wd->button[type];
1098 it = evas_object_data_get(btn, "item_data");
1099 //_delete_button(btn);
1100 edje_object_signal_callback_del(wd->button[type], "elm,action,down", "",
1102 edje_object_signal_callback_del(wd->button[type], "elm,action,click", "",
1104 evas_object_del(wd->button[type]);
1105 if (it->label) eina_stringshare_del(it->label);
1106 if (it->icon) evas_object_del(it->icon);
1108 wd->button[type] = NULL;
1112 * show button of softkey
1113 * @param obj softkey object
1114 * @param type softkey button type
1119 elm_softkey_button_show(Evas_Object *obj, Elm_Softkey_Type type)
1121 _show_button(obj, type, EINA_TRUE);
1125 * hide button of softkey
1126 * @param obj softkey object
1127 * @param type softkey button type
1132 elm_softkey_button_hide(Evas_Object *obj, Elm_Softkey_Type type)
1134 _show_button(obj, type, EINA_FALSE);
1139 * @param obj softkey object
1140 * @param icon The icon object
1141 * @param label The text label to use for the item
1142 * @param func Convenience function to call when this item is selected
1143 * @param data Data to pass to convenience function
1144 * @return A handle to the item added
1148 EAPI Elm_Softkey_Item *
1149 elm_softkey_panel_item_add(Evas_Object *obj, Evas_Object *icon,
1150 const char *label, void
1151 (*func)(void *data, Evas_Object *obj,
1152 void *event_info), const void *data)
1156 char button_name[32];
1158 Elm_Softkey_Item *it;
1159 char buff[PATH_MAX];
1161 wd = elm_widget_data_get(obj);
1164 printf("Cannot get smart data\n");
1169 evas = evas_object_evas_get(obj);
1170 if (!evas) return NULL;
1172 if (wd->panel == NULL)
1175 wd->bg_rect = evas_object_rectangle_add(evas);
1176 if (!wd->bg_rect) return NULL;
1177 evas_object_color_set(wd->bg_rect, 10, 10, 10, 150);
1178 evas_object_pass_events_set(wd->bg_rect, 0);
1182 evas_object_resize(wd->bg_rect, wd->w, wd->win_h);
1183 evas_object_event_callback_add(wd->bg_rect, EVAS_CALLBACK_MOUSE_UP,
1185 evas_object_smart_member_add(wd->bg_rect, obj);
1188 wd->panel = edje_object_add(evas);
1189 if (!wd->panel) return NULL;
1190 _elm_theme_object_set(obj, wd->panel, "softkey", "panel",
1191 elm_widget_style_get(obj));
1193 evas_object_move(wd->panel, 0, wd->win_h);
1194 edje_object_signal_callback_add(wd->panel, "clicked", "close_btn",
1195 _close_btn_click_cb, obj);
1196 evas_object_smart_member_add(wd->panel, obj);
1197 if (evas_object_visible_get(obj))
1199 evas_object_show(wd->panel);
1201 wd->panel_height = 0;
1202 if ((edje_object_data_get(wd->panel, "max_item_count") == NULL)
1203 || (edje_object_data_get(wd->panel, "panel_height") == NULL)
1204 || (edje_object_data_get(wd->panel, "panel_height_horizontal")
1207 //If this key is not found in data section, then it means the panel won't come.
1212 elm_softkey_panel_del(obj);
1214 wd->panel_suppported = EINA_FALSE;
1219 wd->max_button = (int) (atoi(edje_object_data_get(wd->panel,
1220 "max_item_count")));
1221 if (wd->is_horizontal)
1227 edje_object_data_get(wd->panel,
1228 "panel_height_horizontal"))
1229 * wd->scale_factor)));
1237 edje_object_data_get(wd->panel,
1239 * wd->scale_factor)));
1243 evas_object_clip_set(wd->panel, evas_object_clip_get(obj));
1246 wd->panel_btn_idx++;
1247 if (wd->panel_btn_idx >= wd->max_button) return NULL;
1250 it = ELM_NEW(Elm_Softkey_Item);
1252 if (label) it->label = eina_stringshare_add(label);
1256 /* load panel button */
1257 it->base = btn = edje_object_add(evas);
1260 if (it->label) eina_stringshare_del(it->label);
1262 wd->panel_btn_idx--;
1265 _elm_theme_object_set(obj, btn, "softkey", "panel_button",
1266 elm_widget_style_get(obj));
1268 edje_object_part_text_set(btn, "elm.text", label); /* set text */
1269 //edje_object_message_signal_process(btn);
1273 /* swallow button */
1274 snprintf(button_name, sizeof(button_name), "panel_button_area_%d",
1276 edje_object_part_swallow(wd->panel, button_name, btn);
1278 if (wd->is_horizontal)
1280 snprintf(buff, sizeof(buff), "button_%d", wd->max_button
1281 + wd->panel_btn_idx);
1282 edje_object_signal_emit(wd->panel, buff, "panel_rect");
1283 const char* val = edje_object_data_get(wd->panel, buff);
1285 wd->panel_height = (int) (atoi(val) * wd->scale_factor);
1288 if (it->label) eina_stringshare_del(it->label);
1289 evas_object_del(it->base);
1291 wd->panel_btn_idx--;
1297 snprintf(buff, sizeof(buff), "button_%d", wd->panel_btn_idx);
1298 edje_object_signal_emit(wd->panel, buff, "panel_rect");
1299 const char* val = edje_object_data_get(wd->panel, buff);
1301 wd->panel_height = (int) (atoi(val) * wd->scale_factor);
1304 if (it->label) eina_stringshare_del(it->label);
1305 evas_object_del(it->base);
1307 wd->panel_btn_idx--;
1314 wd->panel_btn_idx--;
1317 evas_object_event_callback_add(btn, EVAS_CALLBACK_MOUSE_DOWN,
1318 _panel_down_cb, it);
1319 evas_object_event_callback_add(btn, EVAS_CALLBACK_MOUSE_UP, _panel_up_cb, it);
1320 wd->items = eina_list_append(wd->items, it);
1321 if (evas_object_visible_get(obj))
1323 /* show more button */
1324 edje_object_signal_emit(wd->lay, "more_btn_show", "");
1332 * @param obj softkey object
1333 * @return int 0 (SUCCESS) or -1 (FAIL)
1338 elm_softkey_panel_del(Evas_Object *obj)
1341 char button_name[32];
1344 Elm_Softkey_Item *it;
1346 wd = elm_widget_data_get(obj);
1348 if (wd->panel == NULL) return -1;
1351 ecore_animator_del(wd->animator);
1352 wd->animator = NULL;
1353 wd->animating = EINA_FALSE;
1355 /* delete background */
1358 //evas_object_event_callback_del(wd->bg_rect, EVAS_CALLBACK_MOUSE_UP, _bg_click_cb);
1359 evas_object_del(wd->bg_rect);
1363 for (i = 1; i <= wd->panel_btn_idx; i++)
1365 snprintf(button_name, sizeof(button_name), "panel_button_area_%d", i);
1366 btn = edje_object_part_swallow_get(wd->panel, button_name);
1367 //_delete_button(btn);
1370 //edje_object_part_unswallow(wd->panel, btn);
1371 //evas_object_event_callback_del(btn, EVAS_CALLBACK_MOUSE_DOWN, _panel_down_cb);
1372 //evas_object_event_callback_del(btn, EVAS_CALLBACK_MOUSE_UP, _panel_up_cb);
1373 evas_object_del(btn);
1377 EINA_LIST_FREE(wd->items, it)
1379 if (it->label) eina_stringshare_del(it->label);
1381 if (it->icon) it->icon = NULL;
1385 wd->panel_btn_idx = 0;
1386 wd->panel_height = 0;
1389 edje_object_signal_emit(wd->lay, "more_btn_hide", "");
1393 //evas_object_move(wd->panel, 0, wd->win_h);
1394 evas_object_clip_unset(wd->panel);
1395 evas_object_del(wd->panel);
1396 wd->show_panel = EINA_FALSE;
1404 * sliding up panel if it is closed
1406 * @param obj softkey object
1407 * @return int 0 (SUCCESS) or -1 (FAIL)
1412 elm_softkey_panel_open(Evas_Object *obj)
1415 wd = elm_widget_data_get(obj);
1418 if (!wd->panel) return -1;
1420 if (wd->show_panel == EINA_FALSE)
1422 _more_btn_click_cb(obj, NULL, NULL, NULL);
1429 * sliding down panel if it is opened
1431 * @param obj softkey object
1432 * @return int 0 (SUCCESS) or -1 (FAIL)
1437 elm_softkey_panel_close(Evas_Object *obj)
1440 wd = elm_widget_data_get(obj);
1443 if (wd->panel == NULL) return -1;
1445 if (wd->show_panel == EINA_TRUE)
1447 _close_btn_click_cb(obj, obj, NULL, NULL);
1454 * Set the icon of an softkey item
1456 * @param it The item to set the icon
1457 * @param icon The icon object
1462 elm_softkey_item_icon_set(Elm_Softkey_Item *it, Evas_Object *icon)
1466 if ((it->icon != icon) && (it->icon))
1468 //elm_widget_sub_object_del(it->obj, it->icon);
1469 evas_object_del(it->icon);
1473 if ((icon) && (it->icon != icon))
1476 //elm_widget_sub_object_add(it->obj, icon);
1477 edje_object_part_swallow(it->base, "elm.swallow.icon", icon);
1478 edje_object_signal_emit(it->base, "elm,state,icon,visible", "elm");
1479 //edje_object_message_signal_process(it->base);
1480 _sizing_eval(it->obj);
1487 * Get the icon of an softkey item
1489 * @param it The item to get the icon
1490 * @return The icon object
1495 elm_softkey_item_icon_get(Elm_Softkey_Item *it)
1497 if (!it) return NULL;
1502 * Get the text label of an softkey item
1504 * @param it The item to set the label
1505 * @param label label
1510 elm_softkey_item_label_set(Elm_Softkey_Item *it, const char *label)
1513 if (it->label) eina_stringshare_del(it->label);
1517 it->label = eina_stringshare_add(label);
1518 edje_object_signal_emit(it->base, "elm,state,text,visible", "elm");
1521 edje_object_part_text_set(it->base, "elm.text", label == NULL ? ""
1527 edje_object_signal_emit(it->base, "elm,state,text,hidden", "elm");
1529 //edje_object_message_signal_process(it->base);
1533 * Set the item callback function
1535 * @param it Item to set callback function.
1536 * @param func callback function pointer.
1537 * @param data callback function argument data.
1542 elm_softkey_item_callback_set(Elm_Softkey_Item* item, void
1543 (*func)(void *data, Evas_Object *obj, void *event_info), const void *data)
1553 * Get the text label of an softkey item
1555 * @param it The item to get the label
1556 * @return The text label of the softkey item
1561 elm_softkey_item_label_get(Elm_Softkey_Item *it)
1563 if (!it) return NULL;
1568 elm_softkey_item_disabled_get(Elm_Softkey_Item *it)
1570 if (!it) return EINA_FALSE;
1571 return it->disabled;
1575 elm_softkey_item_disabled_set(Elm_Softkey_Item *it, Eina_Bool disabled)
1578 _item_disable(it, disabled);