1 #include <Elementary.h>
5 * @addtogroup Softkey Softkey
11 * internal data structure of softkey object
13 #define BTN_ANIMATOR_MAX 4
14 #define PANEL_ANIMATOR_MAX 1
15 typedef struct _Widget_Data Widget_Data;
19 Evas_Object *button[2];
22 Evas_Object *glow_obj;
24 Evas_Coord x, y, w, h;
25 Evas_Coord glow_w, glow_h;
27 Evas_Coord panel_height;
28 Ecore_Animator *animator;
30 unsigned int panel_btn_idx;
31 Eina_Bool button_show[2];
32 Eina_Bool show_panel :1;
33 Eina_Bool animating :1;
34 Eina_Bool is_horizontal;
37 Eina_Bool panel_suppported;
40 struct _Elm_Softkey_Item {
45 void (*func)(void *data, Evas_Object *obj, void *event_info);
47 Eina_Bool disabled :1;
50 static void _item_disable(Elm_Softkey_Item *it, Eina_Bool disabled);
51 static void _del_hook(Evas_Object *obj);
52 static void _theme_hook(Evas_Object *obj);
53 static void _sizing_eval(Evas_Object *obj);
54 static void _sub_del(void *data, Evas_Object *obj, void *event_info);
59 static void _softkey_down_cb(void *data, Evas_Object *obj,
60 const char *emission, const char *source);
61 static void _softkey_up_cb(void *data, Evas_Object *obj, const char *emission,
64 static void _panel_down_cb(void *data, Evas *e, Evas_Object *obj,
66 static void _panel_up_cb(void *data, Evas *e, Evas_Object *obj,
69 static void _more_btn_click_cb(void *data, Evas_Object *obj,
70 const char *emission, const char *source);
71 static void _close_btn_click_cb(void *data, Evas_Object *obj,
72 const char *emission, const char *source);
73 static void _bg_click_cb(void *data, Evas *e, Evas_Object *obj,
76 static int _show_button_animator_cb(void *data);
77 static int _hide_button_animator_cb(void *data);
78 static int _panel_up_animator_cb(void *data);
79 static int _panel_down_animator_cb(void *data);
85 _show_button(Evas_Object *obj, Elm_Softkey_Type type, Eina_Bool show);
86 static int _delete_button(Evas_Object *obj);
88 static void _softkey_object_move(void *data, Evas *e, Evas_Object *obj,
90 static void _softkey_object_resize(void *data, Evas *e, Evas_Object *obj,
92 static void _softkey_object_show(void *data, Evas *e, Evas_Object *obj,
94 static void _softkey_object_hide(void *data, Evas *e, Evas_Object *obj,
97 static void _icon_disable(Evas_Object *icon, Eina_Bool disabled) {
102 edj = elm_layout_edje_get(icon);
106 edje_object_signal_emit(icon, "elm,state,disabled", "elm");
108 edje_object_signal_emit(edj, "elm,state,disabled", "elm");
112 edje_object_signal_emit(icon, "elm,state,enabled", "elm");
114 edje_object_signal_emit(edj, "elm,state,enabled", "elm");
119 static void _item_disable(Elm_Softkey_Item *it, Eina_Bool disabled) {
120 Widget_Data *wd = elm_widget_data_get(it->obj);
123 if (it->disabled == disabled)
125 it->disabled = disabled;
127 edje_object_signal_emit(it->base, "elm,state,disabled", "elm");
129 edje_object_signal_emit(it->base, "elm,state,enabled", "elm");
132 _icon_disable(it->icon, disabled);
135 static void _del_hook(Evas_Object *obj) {
138 Widget_Data *wd = elm_widget_data_get(obj);
144 evas_object_smart_member_del(wd->lay);
145 evas_object_del(wd->lay);
150 for (i = 0; i < 2; i++) {
153 evas_object_smart_member_del(btn);
158 /* delete background */
160 evas_object_smart_member_del(wd->bg_rect);
161 evas_object_del(wd->bg_rect);
167 elm_softkey_panel_del(obj);
168 //<Commenting as clean up for panel is being done in method elm_softkey_panel_del()
169 /*evas_object_smart_member_del(wd->panel);
170 evas_object_del(wd->panel);
172 //<Commenting as clean up for panel is being done in method elm_softkey_panel_del()
175 /* delete glow effect image */
177 evas_object_del(wd->glow_obj);
184 static void _theme_hook(Evas_Object *obj) {
185 Elm_Softkey_Item* item;
186 Widget_Data *wd = elm_widget_data_get(obj);
187 Elm_Softkey_Item *it;
193 _elm_theme_object_set(obj, wd->lay, "softkey", "bg", elm_widget_style_get(
195 _elm_theme_object_set(obj, wd->glow_obj, "softkey", "glow", "default");
197 if (wd->button[ELM_SK_LEFT_BTN]) {
199 item = evas_object_data_get(wd->button[ELM_SK_LEFT_BTN], "item_data");
200 _elm_theme_object_set(obj, wd->button[ELM_SK_LEFT_BTN], "softkey",
201 "button_left", elm_widget_style_get(obj));
203 elm_softkey_item_label_set(item, item->label);
207 if (wd->button[ELM_SK_RIGHT_BTN]) {
209 item = evas_object_data_get(wd->button[ELM_SK_RIGHT_BTN], "item_data");
211 _elm_theme_object_set(obj, wd->button[ELM_SK_RIGHT_BTN], "softkey",
212 "button_right", elm_widget_style_get(obj));
214 elm_softkey_item_label_set(item, item->label);
219 _elm_theme_object_set(obj, wd->panel, "softkey", "panel",
220 elm_widget_style_get(obj));
221 if (wd->panel_btn_idx > 0) {
223 edje_object_signal_emit(wd->lay, "more_btn_show", "");
224 EINA_LIST_FOREACH (wd->items, l, it)
226 _elm_theme_object_set(obj, it->base, "softkey", "panel_button", elm_widget_style_get(obj));
228 edje_object_part_text_set(it->base, "elm.text", it->label); // set text
237 static void _sub_del(void *data, Evas_Object *obj, void *event_info) {
238 Widget_Data *wd = elm_widget_data_get(obj);
239 Evas_Object *sub = event_info;
241 Elm_Softkey_Item *it;
245 EINA_LIST_FOREACH(wd->items, l, it)
247 if(sub == it->icon) {
254 static void _sizing_eval(Evas_Object *obj) {
255 Widget_Data *wd = elm_widget_data_get(obj);
260 _softkey_object_move(obj, NULL, obj, NULL);
261 _softkey_object_resize(obj, NULL, obj, NULL);
264 static int _panel_up_animator_cb(void *data) {
265 int max = PANEL_ANIMATOR_MAX;
266 static int progress = 0;
270 wd = elm_widget_data_get(data);
275 wd->animating = EINA_TRUE;
277 if (progress > max) {
280 ecore_animator_del(wd->animator);
281 wd->animating = EINA_FALSE;
282 wd->show_panel = EINA_TRUE;
289 ypos = wd->win_h - (wd->panel_height * progress / max);
290 evas_object_move(wd->panel, 0, ypos);
296 static int _panel_down_animator_cb(void *data) {
297 int max = PANEL_ANIMATOR_MAX;
298 static int progress = 0;
302 wd = elm_widget_data_get(data);
307 wd->animating = EINA_TRUE;
309 if (progress > max) {
312 ecore_animator_del(wd->animator);
313 wd->animating = EINA_FALSE;
314 wd->animator = ecore_animator_add(_show_button_animator_cb, data);
315 wd->show_panel = EINA_FALSE;
318 evas_object_smart_callback_call(data, "panel,hide", NULL);
323 /* move down panel */
325 ypos = wd->win_h - wd->panel_height + (wd->panel_height * progress
327 evas_object_move(wd->panel, 0, ypos);
333 static int _hide_button_animator_cb(void *data) {
334 int max = BTN_ANIMATOR_MAX;
335 static int progress = 0;
337 Evas_Coord btn_w, xpos;
339 wd = elm_widget_data_get(data);
344 wd->animating = EINA_TRUE;
346 if (progress > max) {
349 ecore_animator_del(wd->animator);
350 wd->animating = EINA_FALSE;
351 wd->animator = ecore_animator_add(_panel_up_animator_cb, data);
356 /* move left button */
357 if (wd->button[ELM_SK_LEFT_BTN]) {
358 edje_object_part_geometry_get(wd->button[ELM_SK_LEFT_BTN],
359 "button_rect", NULL, NULL, &btn_w, NULL);
361 xpos = -1 * btn_w * progress / max;
362 evas_object_move(wd->button[ELM_SK_LEFT_BTN], xpos, wd->y);
365 /* move right button */
366 if (wd->button[ELM_SK_RIGHT_BTN]) {
367 edje_object_part_geometry_get(wd->button[ELM_SK_RIGHT_BTN],
368 "button_rect", NULL, NULL, &btn_w, NULL);
370 xpos = (wd->w - btn_w) + (btn_w * progress / max);
371 evas_object_move(wd->button[ELM_SK_RIGHT_BTN], xpos, wd->y);
377 static int _show_button_animator_cb(void *data) {
378 int max = BTN_ANIMATOR_MAX;
379 static int progress = 0;
381 Evas_Coord btn_w, xpos;
383 wd = elm_widget_data_get(data);
389 wd->animating = EINA_TRUE;
391 if (progress > max) {
394 ecore_animator_del(wd->animator);
395 wd->animating = EINA_FALSE;
400 /* move left button */
401 if (wd->button[ELM_SK_LEFT_BTN]) {
402 edje_object_part_geometry_get(wd->button[ELM_SK_LEFT_BTN],
403 "button_rect", NULL, NULL, &btn_w, NULL);
405 xpos = (-1 * btn_w) + (btn_w * progress / max);
406 evas_object_move(wd->button[ELM_SK_LEFT_BTN], xpos, wd->y);
409 /* move right button */
410 if (wd->button[ELM_SK_RIGHT_BTN]) {
411 edje_object_part_geometry_get(wd->button[ELM_SK_RIGHT_BTN],
412 "button_rect", NULL, NULL, &btn_w, NULL);
414 xpos = wd->w - (btn_w * progress / max);
415 evas_object_move(wd->button[ELM_SK_RIGHT_BTN], xpos, wd->y);
421 static void _more_btn_click_cb(void *data, Evas_Object *obj,
422 const char *emission, const char *source) {
424 wd = elm_widget_data_get(data);
428 evas_object_smart_callback_call(data, "panel,show", NULL);
432 evas_object_show(wd->panel);
435 evas_object_show(wd->bg_rect);
438 if (wd->animating == EINA_FALSE) {
439 wd->animator = ecore_animator_add(_hide_button_animator_cb, data);
443 static void _close_panel(Evas_Object *obj) {
445 wd = elm_widget_data_get(obj);
450 evas_object_hide(wd->bg_rect);
456 if (wd->animating == EINA_FALSE) {
457 wd->animator = ecore_animator_add(_panel_down_animator_cb, obj);
461 static void _bg_click_cb(void *data, Evas *e, Evas_Object *obj,
466 static void _close_btn_click_cb(void *data, Evas_Object *obj,
467 const char *emission, const char *source) {
471 static int _show_button(Evas_Object *obj, Elm_Softkey_Type type, Eina_Bool show) {
475 Widget_Data *wd = elm_widget_data_get(obj);
476 Evas_Object *btn = wd->button[type];
480 /* Make visible button */
482 wd->button_show[type] = EINA_TRUE;
483 evas_object_show(btn);
485 wd->button_show[type] = EINA_FALSE;
486 evas_object_hide(btn);
492 static int _arrange_button(Evas_Object *obj, Elm_Softkey_Type type) {
494 Evas_Coord btn_w = 0;
499 wd = elm_widget_data_get(obj);
503 btn = wd->button[type];
508 case ELM_SK_LEFT_BTN:
509 evas_object_move(btn, wd->x, wd->y);
511 case ELM_SK_RIGHT_BTN:
512 edje_object_part_geometry_get(btn, "button_rect", NULL, NULL, &btn_w,
514 evas_object_move(btn, wd->w - btn_w, wd->y);
523 static void _softkey_up_cb(void *data, Evas_Object *obj, const char *emission,
524 const char *source) {
527 Elm_Softkey_Item *it = (Elm_Softkey_Item *) data;
528 elm_softkey_panel_close(it->obj);
530 it->func((void *) (it->data), it->obj, it);
531 evas_object_smart_callback_call(it->obj, "clicked", it);
535 edj = elm_layout_edje_get(it->icon);
539 edje_object_signal_emit(edj, "elm,state,unselected", "elm");
542 static void _softkey_down_cb(void *data, Evas_Object *obj,
543 const char *emission, const char *source) {
546 Elm_Softkey_Item *it = (Elm_Softkey_Item *) data;
547 evas_object_smart_callback_call(it->obj, "press", it);
551 edj = elm_layout_edje_get(it->icon);
555 edje_object_signal_emit(edj, "elm,state,selected", "elm");
558 static void _panel_up_cb(void *data, Evas *e, Evas_Object *obj,
560 Elm_Softkey_Item *it = (Elm_Softkey_Item *) data;
563 wd = elm_widget_data_get(it->obj);
567 /* hide glow effect */
569 evas_object_hide(wd->glow_obj);
572 elm_softkey_panel_close(it->obj);
574 it->func((void *) (it->data), it->obj, it);
575 evas_object_smart_callback_call(it->obj, "clicked", it);
578 static void _panel_down_cb(void *data, Evas *e, Evas_Object *obj,
580 Evas_Coord glow_x, glow_y;
583 Elm_Softkey_Item *it = (Elm_Softkey_Item *) data;
584 wd = elm_widget_data_get(it->obj);
588 /* show glow effect */
590 Evas_Event_Mouse_Down *ev = (Evas_Event_Mouse_Down *) event_info;
591 glow_x = ev->canvas.x - (wd->glow_w / 2);
592 glow_y = ev->canvas.y - (wd->glow_h / 2);
594 evas_object_move(wd->glow_obj, glow_x, glow_y);
595 evas_object_show(wd->glow_obj);
598 evas_object_smart_callback_call(it->obj, "press", it);
601 static int _delete_button(Evas_Object *obj) {
606 evas_object_del(obj);
613 static void _calc_win_height(Widget_Data *wd) {
614 wd->win_h = wd->y + wd->h;
617 evas_object_resize(wd->bg_rect, wd->w, wd->win_h);
620 if (wd->show_panel) {
621 evas_object_move(wd->panel, wd->x, (wd->win_h - wd->panel_height));
623 evas_object_move(wd->panel, wd->x, wd->win_h);
627 static void _softkey_object_move(void *data, Evas *e, Evas_Object *obj,
635 wd = elm_widget_data_get((Evas_Object *) data);
639 evas_object_geometry_get(wd->lay, &x, &y, NULL, NULL);
644 // evas_object_move(wd->lay, x, y);
646 for (i = 0; i < 2; i++) {
647 _arrange_button((Evas_Object *) data, i);
650 _calc_win_height(wd);
653 static void _softkey_object_resize(void *data, Evas *e, Evas_Object *obj,
663 wd = elm_widget_data_get((Evas_Object *) data);
667 evas_object_geometry_get(wd->lay, NULL, NULL, &w, &h);
674 evas_object_resize(wd->lay, w, h);
677 for (i = 0; i < 2; i++) {
680 edje_object_part_geometry_get(btn, "button_rect", NULL, NULL,
682 evas_object_resize(btn, btn_w, h);
683 _arrange_button((Evas_Object *) data, i);
687 if (wd->w >= wd->win_h) {
688 _softkey_horizontal_set(data, EINA_TRUE);
690 _softkey_horizontal_set(data, EINA_FALSE);
692 _calc_win_height(wd);
695 static void _softkey_object_show(void *data, Evas *e, Evas_Object *obj,
697 Widget_Data *wd = NULL;
702 wd = elm_widget_data_get((Evas_Object *) data);
707 evas_object_show(wd->lay);
711 for (i = 0; i < 2; i++) {
713 if (btn != NULL && wd->button_show[i] == EINA_TRUE) {
714 evas_object_show(btn);
715 //evas_object_clip_set(btn, evas_object_clip_get((Evas_Object *)data));
718 if (wd->panel_btn_idx > 0) {
719 /* show more button */
720 edje_object_signal_emit(wd->lay, "more_btn_show", "");
724 static void _softkey_object_hide(void *data, Evas *e, Evas_Object *obj,
726 Widget_Data *wd = NULL;
732 wd = elm_widget_data_get((Evas_Object *) data);
737 evas_object_hide(wd->lay);
741 for (i = 0; i < 2; i++) {
744 evas_object_hide(btn);
748 if (wd->panel_btn_idx > 0) {
749 /* hide more button */
750 edje_object_signal_emit(wd->lay, "more_btn_hide", "");
755 * Add a new softkey to the parent
757 * @param parent the parent of the smart object
758 * @return Evas_Object* pointer of softkey(evas object) or NULL
762 elm_softkey_add(Evas_Object *parent) {
763 Evas_Object *obj = NULL;
764 Widget_Data *wd = NULL;
767 wd = ELM_NEW(Widget_Data);
768 e = evas_object_evas_get(parent);
771 obj = elm_widget_add(e);
772 elm_widget_type_set(obj, "softkey");
773 elm_widget_sub_object_add(parent, obj);
774 elm_widget_data_set(obj, wd);
775 elm_widget_del_hook_set(obj, _del_hook);
776 elm_widget_theme_hook_set(obj, _theme_hook);
778 /* load background edj */
779 wd->lay = edje_object_add(e);
780 _elm_theme_object_set(obj, wd->lay, "softkey", "bg", "default");
781 if (wd->lay == NULL) {
782 printf("Cannot load bg edj\n");
785 elm_widget_resize_object_set(obj, wd->lay);
786 edje_object_signal_callback_add(wd->lay, "clicked", "more_btn",
787 _more_btn_click_cb, obj);
789 evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE,
790 _softkey_object_resize, obj);
791 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOVE,
792 _softkey_object_move, obj);
793 evas_object_event_callback_add(obj, EVAS_CALLBACK_SHOW,
794 _softkey_object_show, obj);
795 evas_object_event_callback_add(obj, EVAS_CALLBACK_HIDE,
796 _softkey_object_hide, obj);
797 wd->is_horizontal = EINA_FALSE;
798 wd->panel_suppported = EINA_TRUE;
799 wd->scale_factor = elm_scale_get();
800 if (wd->scale_factor == 0.0) {
801 wd->scale_factor = 1.0;
804 /* load glow effect */
805 wd->glow_obj = edje_object_add(e);
806 _elm_theme_object_set(obj, wd->glow_obj, "softkey", "glow", "default");
807 evas_object_geometry_get(wd->glow_obj, NULL, NULL, &wd->glow_w, &wd->glow_h);
808 evas_object_resize(wd->glow_obj, wd->glow_w, wd->glow_h);
811 evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
813 // _sizing_eval(obj);
818 EAPI void _softkey_horizontal_set(Evas_Object *obj, Eina_Bool horizontal_mode) {
823 wd = elm_widget_data_get(obj);
826 wd->is_horizontal = horizontal_mode;
828 if ((edje_object_data_get(wd->panel, "max_item_count") == NULL)
829 || (edje_object_data_get(wd->panel, "panel_height") == NULL)
830 || (edje_object_data_get(wd->panel, "panel_height_horizontal")
832 wd->panel_suppported = EINA_FALSE;
834 wd->panel_suppported = EINA_TRUE;
835 if (wd->panel_suppported == EINA_TRUE) {
836 if (wd->is_horizontal == EINA_TRUE) {
837 sprintf(buff, "button_%d", (wd->panel_btn_idx + wd->max_button));
838 edje_object_signal_emit(wd->panel, buff, "panel_rect");
839 wd->panel_height = (int) (atoi(edje_object_data_get(wd->panel,
840 buff)) * wd->scale_factor);
844 ((int) (atoi(edje_object_data_get(wd->panel,
845 "panel_height_horizontal")) * wd->scale_factor)));
847 sprintf(buff, "button_%d", (wd->panel_btn_idx));
848 edje_object_signal_emit(wd->panel, buff, "panel_rect");
849 wd->panel_height = (int) (atoi(edje_object_data_get(wd->panel,
850 buff)) * wd->scale_factor);
851 evas_object_resize(wd->panel, wd->w, ((int) (atoi(
852 edje_object_data_get(wd->panel, "panel_height"))
853 * wd->scale_factor)));
856 _calc_win_height(wd);
862 * add side button of softkey
863 * @param obj softkey object
864 * @param type softkey button type
865 * @param icon The icon object to use for the item
866 * @param label The text label to use for the item
867 * @param func Convenience function to call when this item is selected
868 * @param data Data to pass to convenience function
869 * @return A handle to the item added
873 EAPI Elm_Softkey_Item *
874 elm_softkey_button_add(Evas_Object *obj, Elm_Softkey_Type type,
875 Evas_Object *icon, const char *label, void(*func)(void *data,
876 Evas_Object *obj, void *event_info), const void *data) {
879 char button_type[64];
880 Elm_Softkey_Item *it;
884 wd = elm_widget_data_get(obj);
888 if (wd->button[type]) {
889 printf("already created.\n");
894 it = ELM_NEW(Elm_Softkey_Item);
900 evas = evas_object_evas_get(obj);
904 /* load button edj */
905 if (wd->button[type] == NULL) {
906 if (type == ELM_SK_LEFT_BTN) {
907 strcpy(button_type, "button_left");
909 strcpy(button_type, "button_right");
912 it->base = wd->button[type] = edje_object_add(evas);
913 if (!wd->button[type])
915 _elm_theme_object_set(obj, wd->button[type], "softkey", button_type,
916 elm_widget_style_get(obj));
918 wd->button_show[type] = EINA_TRUE;
919 if (evas_object_visible_get(obj)) {
920 evas_object_show(wd->button[type]);
922 evas_object_smart_member_add(wd->button[type], obj);
924 edje_object_signal_callback_add(wd->button[type], "elm,action,down",
925 "", _softkey_down_cb, it);
926 edje_object_signal_callback_add(wd->button[type], "elm,action,click",
927 "", _softkey_up_cb, it);
929 evas_object_clip_set(wd->button[type], evas_object_clip_get(obj));
931 evas_object_raise(wd->panel);
936 elm_softkey_item_label_set(it, label);
937 elm_softkey_item_icon_set(it, icon);
939 evas_object_data_set(wd->button[type], "item_data", it);
945 * delete side button of softkey
946 * @param obj softkey object
947 * @param type softkey button type
951 EAPI void elm_softkey_button_del(Evas_Object *obj, Elm_Softkey_Type type) {
953 Elm_Softkey_Item *it;
957 printf("Invalid argument: softkey object is NULL\n");
961 wd = elm_widget_data_get(obj);
965 btn = wd->button[type];
969 it = evas_object_data_get(btn, "item_data");
972 evas_object_smart_member_del(btn);
974 wd->button[type] = NULL;
978 * show button of softkey
979 * @param obj softkey object
980 * @param type softkey button type
984 EAPI void elm_softkey_button_show(Evas_Object *obj, Elm_Softkey_Type type) {
985 _show_button(obj, type, EINA_TRUE);
989 * hide button of softkey
990 * @param obj softkey object
991 * @param type softkey button type
995 EAPI void elm_softkey_button_hide(Evas_Object *obj, Elm_Softkey_Type type) {
996 _show_button(obj, type, EINA_FALSE);
1001 * @param obj softkey object
1002 * @param icon The icon object
1003 * @param label The text label to use for the item
1004 * @param func Convenience function to call when this item is selected
1005 * @param data Data to pass to convenience function
1006 * @return A handle to the item added
1010 EAPI Elm_Softkey_Item *
1011 elm_softkey_panel_item_add(Evas_Object *obj, Evas_Object *icon,
1012 const char *label, void(*func)(void *data, Evas_Object *obj,
1013 void *event_info), const void *data) {
1016 char button_name[32];
1018 Elm_Softkey_Item *it;
1019 char buff[PATH_MAX];
1021 wd = elm_widget_data_get(obj);
1023 printf("Cannot get smart data\n");
1028 it = ELM_NEW(Elm_Softkey_Item);
1029 wd->items = eina_list_append(wd->items, it);
1031 it->label = eina_stringshare_add(label);
1037 evas = evas_object_evas_get(obj);
1041 if (wd->panel == NULL) {
1043 wd->bg_rect = evas_object_rectangle_add(evas);
1046 evas_object_color_set(wd->bg_rect, 10, 10, 10, 150);
1047 evas_object_pass_events_set(wd->bg_rect, 0);
1050 evas_object_resize(wd->bg_rect, wd->w, wd->win_h);
1051 evas_object_event_callback_add(wd->bg_rect, EVAS_CALLBACK_MOUSE_UP,
1053 evas_object_smart_member_add(wd->bg_rect, obj);
1056 wd->panel = edje_object_add(evas);
1059 _elm_theme_object_set(obj, wd->panel, "softkey", "panel",
1060 elm_widget_style_get(obj));
1062 evas_object_move(wd->panel, 0, wd->win_h);
1063 edje_object_signal_callback_add(wd->panel, "clicked", "close_btn",
1064 _close_btn_click_cb, obj);
1065 evas_object_smart_member_add(wd->panel, obj);
1066 if (evas_object_visible_get(obj)) {
1067 evas_object_show(wd->panel);
1069 wd->panel_height = 0;
1070 if ((edje_object_data_get(wd->panel, "max_item_count") == NULL)
1071 || (edje_object_data_get(wd->panel, "panel_height") == NULL)
1072 || (edje_object_data_get(wd->panel, "panel_height_horizontal")
1074 //If this key is not found in data section, then it means the panel won't come.
1078 elm_softkey_panel_del(obj);
1080 wd->panel_suppported = EINA_FALSE;
1083 wd->max_button = (int) (atoi(edje_object_data_get(wd->panel,
1084 "max_item_count")));
1085 if (wd->is_horizontal) {
1089 ((int) (atoi(edje_object_data_get(wd->panel,
1090 "panel_height_horizontal")) * wd->scale_factor)));
1092 evas_object_resize(wd->panel, wd->w, ((int) (atoi(
1093 edje_object_data_get(wd->panel, "panel_height"))
1094 * wd->scale_factor)));
1098 evas_object_clip_set(wd->panel, evas_object_clip_get(obj));
1101 if (wd->panel_btn_idx >= wd->max_button)
1104 wd->panel_btn_idx++;
1106 if (evas_object_visible_get(obj)) {
1107 /* show more button */
1108 edje_object_signal_emit(wd->lay, "more_btn_show", "");
1111 /* load panel button */
1112 it->base = btn = edje_object_add(evas);
1115 _elm_theme_object_set(obj, btn, "softkey", "panel_button",
1116 elm_widget_style_get(obj));
1118 edje_object_part_text_set(btn, "elm.text", label); /* set text */
1119 edje_object_message_signal_process(btn);
1121 evas_object_event_callback_add(btn, EVAS_CALLBACK_MOUSE_DOWN,
1122 _panel_down_cb, it);
1123 evas_object_event_callback_add(btn, EVAS_CALLBACK_MOUSE_UP, _panel_up_cb,
1126 /* swallow button */
1127 sprintf(button_name, "panel_button_area_%d", wd->panel_btn_idx);
1128 edje_object_part_swallow(wd->panel, button_name, btn);
1129 if (wd->is_horizontal) {
1130 sprintf(buff, "button_%d", wd->max_button + wd->panel_btn_idx);
1131 edje_object_signal_emit(wd->panel, buff, "panel_rect");
1132 wd->panel_height = (int) (atoi(edje_object_data_get(wd->panel, buff))
1133 * wd->scale_factor);
1135 sprintf(buff, "button_%d", wd->panel_btn_idx);
1136 edje_object_signal_emit(wd->panel, buff, "panel_rect");
1137 wd->panel_height = (int) (atoi(edje_object_data_get(wd->panel, buff))
1138 * wd->scale_factor);
1147 * @param obj softkey object
1148 * @return int 0 (SUCCESS) or -1 (FAIL)
1152 EAPI int elm_softkey_panel_del(Evas_Object *obj) {
1154 char button_name[32];
1157 Elm_Softkey_Item *it;
1159 wd = elm_widget_data_get(obj);
1162 if (wd->panel == NULL)
1165 for (i = 1; i <= wd->panel_btn_idx; i++) {
1166 sprintf(button_name, "panel_button_area_%d", i);
1167 btn = edje_object_part_swallow_get(wd->panel, button_name);
1168 _delete_button(btn);
1171 EINA_LIST_FREE(wd->items, it)
1173 eina_stringshare_del(it->label);
1177 wd->panel_btn_idx = 0;
1178 wd->panel_height = 0;
1181 edje_object_signal_emit(wd->lay, "more_btn_hide", "");
1184 evas_object_move(wd->panel, 0, wd->win_h);
1185 evas_object_clip_unset(wd->panel);
1186 //<Added to delete the panel completely>
1187 evas_object_smart_member_del(wd->panel);
1188 evas_object_del(wd->panel);
1190 //<Added to delete the panel completely>
1197 * sliding up panel if it is closed
1199 * @param obj softkey object
1200 * @return int 0 (SUCCESS) or -1 (FAIL)
1204 EAPI int elm_softkey_panel_open(Evas_Object *obj) {
1206 wd = elm_widget_data_get(obj);
1213 if (wd->show_panel == EINA_FALSE) {
1214 _more_btn_click_cb(obj, NULL, NULL, NULL);
1221 * sliding down panel if it is opened
1223 * @param obj softkey object
1224 * @return int 0 (SUCCESS) or -1 (FAIL)
1228 EAPI int elm_softkey_panel_close(Evas_Object *obj) {
1230 wd = elm_widget_data_get(obj);
1234 if (wd->panel == NULL)
1237 if (wd->show_panel == EINA_TRUE) {
1238 _close_btn_click_cb(obj, obj, NULL, NULL);
1245 * Set the icon of an softkey item
1247 * @param it The item to set the icon
1248 * @param icon The icon object
1252 EAPI void elm_softkey_item_icon_set(Elm_Softkey_Item *it, Evas_Object *icon) {
1256 if ((it->icon != icon) && (it->icon))
1257 elm_widget_sub_object_del(it->obj, it->icon);
1259 if ((icon) && (it->icon != icon)) {
1261 elm_widget_sub_object_add(it->obj, icon);
1262 //evas_object_event_callback_add(icon, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, obj);
1263 //edje_object_part_swallow(it->base, "elm.swallow.content", icon);
1264 edje_object_part_swallow(it->base, "elm.swallow.icon", icon);
1265 edje_object_signal_emit(it->base, "elm,state,icon,visible", "elm");
1266 edje_object_message_signal_process(it->base);
1267 _sizing_eval(it->obj);
1273 * Get the icon of an softkey item
1275 * @param it The item to get the icon
1276 * @return The icon object
1281 elm_softkey_item_icon_get(Elm_Softkey_Item *it) {
1288 * Get the text label of an softkey item
1290 * @param it The item to set the label
1291 * @param label label
1295 EAPI void elm_softkey_item_label_set(Elm_Softkey_Item *it, const char *label) {
1299 eina_stringshare_del(it->label);
1302 it->label = eina_stringshare_add(label);
1303 edje_object_signal_emit(it->base, "elm,state,text,visible", "elm");
1306 edje_object_part_text_set(it->base, "elm.text", label == NULL ? ""
1310 edje_object_signal_emit(it->base, "elm,state,text,hidden", "elm");
1312 edje_object_message_signal_process(it->base);
1316 * Set the item callback function
1318 * @param it Item to set callback function.
1319 * @param func callback function pointer.
1320 * @param data callback function argument data.
1324 EAPI void elm_softkey_item_callback_set(Elm_Softkey_Item* item, void(*func)(
1325 void *data, Evas_Object *obj, void *event_info), const void *data) {
1335 * Get the text label of an softkey item
1337 * @param it The item to get the label
1338 * @return The text label of the softkey item
1343 elm_softkey_item_label_get(Elm_Softkey_Item *it) {
1349 EAPI Eina_Bool elm_softkey_item_disabled_get(Elm_Softkey_Item *it) {
1352 return it->disabled;
1355 EAPI void elm_softkey_item_disabled_set(Elm_Softkey_Item *it,
1356 Eina_Bool disabled) {
1359 _item_disable(it, disabled);