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
48 void (*func)(void *data, Evas_Object *obj, void *event_info);
50 Eina_Bool disabled :1;
53 static void _item_disable(Elm_Softkey_Item *it, Eina_Bool disabled);
54 static void _del_hook(Evas_Object *obj);
55 static void _theme_hook(Evas_Object *obj);
56 static void _sizing_eval(Evas_Object *obj);
57 static void _sub_del(void *data, Evas_Object *obj, void *event_info);
62 static void _softkey_down_cb(void *data, Evas_Object *obj, const char *emission, const char *source);
63 static void _softkey_up_cb(void *data, Evas_Object *obj, const char *emission, const char *source);
65 static void _panel_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
66 static void _panel_up_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
68 static void _more_btn_click_cb(void *data, Evas_Object *obj, const char *emission, const char *source);
69 static void _close_btn_click_cb(void *data, Evas_Object *obj, const char *emission, const char *source);
70 static void _bg_click_cb(void *data, Evas *e, Evas_Object *obj, void *event_info);
72 static int _show_button_animator_cb(void *data);
73 static int _hide_button_animator_cb(void *data);
74 static int _panel_up_animator_cb(void *data);
75 static int _panel_down_animator_cb(void *data);
81 _show_button(Evas_Object *obj, Elm_Softkey_Type type, Eina_Bool show);
82 static int _delete_button(Evas_Object *obj);
84 static void _softkey_object_move(void *data, Evas *e, Evas_Object *obj, void *event_info);
85 static void _softkey_object_resize(void *data, Evas *e, Evas_Object *obj, void *event_info);
86 static void _softkey_object_show(void *data, Evas *e, Evas_Object *obj, void *event_info);
87 static void _softkey_object_hide(void *data, Evas *e, Evas_Object *obj, void *event_info);
88 static void _softkey_horizontal_set(Evas_Object *obj, Eina_Bool horizontal_mode);
89 static void _icon_disable(Evas_Object *icon, Eina_Bool disabled)
95 edj = elm_layout_edje_get(icon);
99 edje_object_signal_emit(icon, "elm,state,disabled", "elm");
102 edje_object_signal_emit(edj, "elm,state,disabled", "elm");
107 edje_object_signal_emit(icon, "elm,state,enabled", "elm");
110 edje_object_signal_emit(edj, "elm,state,enabled", "elm");
115 static void _item_disable(Elm_Softkey_Item *it, Eina_Bool disabled)
117 Widget_Data *wd = elm_widget_data_get(it->obj);
120 if (it->disabled == disabled)
122 it->disabled = disabled;
124 edje_object_signal_emit(it->base, "elm,state,disabled", "elm");
127 edje_object_signal_emit(it->base, "elm,state,enabled", "elm");
130 _icon_disable(it->icon, disabled);
133 static void _del_hook(Evas_Object *obj)
137 Widget_Data *wd = elm_widget_data_get(obj);
143 evas_object_del(wd->lay);
148 for (i = 0; i < 2; i++) {
155 /* delete background */
157 evas_object_del(wd->bg_rect);
163 elm_softkey_panel_del(obj);
164 //<Commenting as clean up for panel is being done in method elm_softkey_panel_del()
165 /*evas_object_del(wd->panel);
167 //<Commenting as clean up for panel is being done in method elm_softkey_panel_del()
170 /* delete glow effect image */
172 evas_object_del(wd->glow_obj);
179 static void _theme_hook(Evas_Object *obj)
181 Elm_Softkey_Item* item;
182 Widget_Data *wd = elm_widget_data_get(obj);
183 Elm_Softkey_Item *it;
189 _elm_theme_object_set(obj, wd->lay, "softkey", "bg", elm_widget_style_get(obj));
190 _elm_theme_object_set(obj, wd->glow_obj, "softkey", "glow", "default");
192 if (wd->button[ELM_SK_LEFT_BTN]) {
194 item = evas_object_data_get(wd->button[ELM_SK_LEFT_BTN], "item_data");
195 _elm_theme_object_set(obj, wd->button[ELM_SK_LEFT_BTN], "softkey", "button_left", elm_widget_style_get(obj));
197 elm_softkey_item_label_set(item, item->label);
201 if (wd->button[ELM_SK_RIGHT_BTN]) {
203 item = evas_object_data_get(wd->button[ELM_SK_RIGHT_BTN], "item_data");
205 _elm_theme_object_set(obj, wd->button[ELM_SK_RIGHT_BTN], "softkey", "button_right", elm_widget_style_get(obj));
207 elm_softkey_item_label_set(item, item->label);
212 _elm_theme_object_set(obj, wd->panel, "softkey", "panel", elm_widget_style_get(obj));
213 if (wd->panel_btn_idx > 0) {
215 edje_object_signal_emit(wd->lay, "more_btn_show", "");
216 EINA_LIST_FOREACH (wd->items, l, it) {
217 _elm_theme_object_set(obj, it->base, "softkey", "panel_button", elm_widget_style_get(obj));
219 edje_object_part_text_set(it->base, "elm.text", it->label); // set text
228 static void _sub_del(void *data, Evas_Object *obj, void *event_info)
230 Widget_Data *wd = elm_widget_data_get(obj);
231 Evas_Object *sub = event_info;
233 Elm_Softkey_Item *it;
237 EINA_LIST_FOREACH(wd->items, l, it) {
238 if (sub == it->icon) {
245 static void _sizing_eval(Evas_Object *obj)
247 Widget_Data *wd = elm_widget_data_get(obj);
252 _softkey_object_move(obj, NULL, obj, NULL);
253 _softkey_object_resize(obj, NULL, obj, NULL);
256 static int _panel_up_animator_cb(void *data)
258 int max = PANEL_ANIMATOR_MAX;
259 static int progress = 0;
263 wd = elm_widget_data_get(data);
268 wd->animating = EINA_TRUE;
270 if (progress > max) {
273 ecore_animator_del(wd->animator);
275 wd->animating = EINA_FALSE;
276 wd->show_panel = EINA_TRUE;
283 ypos = wd->win_h - (wd->panel_height * progress / max);
284 evas_object_move(wd->panel, wd->x, ypos);
290 static int _panel_down_animator_cb(void *data)
292 int max = PANEL_ANIMATOR_MAX;
293 static int progress = 0;
297 wd = elm_widget_data_get(data);
302 wd->animating = EINA_TRUE;
304 if (progress > max) {
307 ecore_animator_del(wd->animator);
309 wd->animating = EINA_FALSE;
310 //wd->animator = ecore_animator_add(_show_button_animator_cb, data);
311 wd->show_panel = EINA_FALSE;
314 evas_object_smart_callback_call(data, "panel,hide", NULL);
319 /* move down panel */
321 ypos = wd->win_h - wd->panel_height + (wd->panel_height * progress / max);
322 evas_object_move(wd->panel, wd->x, ypos);
328 static int _hide_button_animator_cb(void *data)
330 int max = BTN_ANIMATOR_MAX;
331 static int progress = 0;
333 Evas_Coord btn_w, xpos;
335 wd = elm_widget_data_get(data);
340 wd->animating = EINA_TRUE;
342 if (progress > max) {
345 ecore_animator_del(wd->animator);
346 wd->animating = EINA_FALSE;
347 wd->animator = ecore_animator_add(_panel_up_animator_cb, data);
352 /* move left button */
353 if (wd->button[ELM_SK_LEFT_BTN]) {
354 edje_object_part_geometry_get(wd->button[ELM_SK_LEFT_BTN], "button_rect", NULL, NULL, &btn_w, NULL);
356 xpos = wd->x + -1 * btn_w * progress / max;
357 evas_object_move(wd->button[ELM_SK_LEFT_BTN], xpos, wd->y);
360 /* move right button */
361 if (wd->button[ELM_SK_RIGHT_BTN]) {
362 edje_object_part_geometry_get(wd->button[ELM_SK_RIGHT_BTN], "button_rect", NULL, NULL, &btn_w, NULL);
364 xpos = (wd->x + wd->w - btn_w) + (btn_w * progress / max);
365 evas_object_move(wd->button[ELM_SK_RIGHT_BTN], xpos, wd->y);
371 static int _show_button_animator_cb(void *data)
373 int max = BTN_ANIMATOR_MAX;
374 static int progress = 0;
376 Evas_Coord btn_w, xpos;
378 wd = elm_widget_data_get(data);
384 wd->animating = EINA_TRUE;
386 if (progress > max) {
389 ecore_animator_del(wd->animator);
390 wd->animating = EINA_FALSE;
395 /* move left button */
396 if (wd->button[ELM_SK_LEFT_BTN]) {
397 edje_object_part_geometry_get(wd->button[ELM_SK_LEFT_BTN], "button_rect", NULL, NULL, &btn_w, NULL);
399 xpos = wd->x + (-1 * btn_w) + (btn_w * progress / max);
400 evas_object_move(wd->button[ELM_SK_LEFT_BTN], xpos, wd->y);
403 /* move right button */
404 if (wd->button[ELM_SK_RIGHT_BTN]) {
405 edje_object_part_geometry_get(wd->button[ELM_SK_RIGHT_BTN], "button_rect", NULL, NULL, &btn_w, NULL);
407 xpos = wd->x + wd->w - (btn_w * progress / max);
408 evas_object_move(wd->button[ELM_SK_RIGHT_BTN], xpos, wd->y);
414 static void _more_btn_click_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
417 wd = elm_widget_data_get(data);
421 evas_object_smart_callback_call(data, "panel,show", NULL);
425 evas_object_show(wd->panel);
428 evas_object_show(wd->bg_rect);
431 /*if (wd->animating == EINA_FALSE) {
432 wd->animator = ecore_animator_add(_hide_button_animator_cb, data);
434 if (wd->animating == EINA_FALSE) {
435 wd->animator = ecore_animator_add(_panel_up_animator_cb, data);
439 static void _close_panel(Evas_Object *obj)
442 wd = elm_widget_data_get(obj);
447 evas_object_hide(wd->bg_rect);
453 if (wd->animating == EINA_FALSE) {
454 wd->animator = ecore_animator_add(_panel_down_animator_cb, obj);
458 static void _bg_click_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
463 static void _close_btn_click_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
468 static int _show_button(Evas_Object *obj, Elm_Softkey_Type type, Eina_Bool show)
473 Widget_Data *wd = elm_widget_data_get(obj);
474 Evas_Object *btn = wd->button[type];
478 /* Make visible button */
480 wd->button_show[type] = EINA_TRUE;
481 evas_object_show(btn);
484 wd->button_show[type] = EINA_FALSE;
485 evas_object_hide(btn);
491 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];
509 case ELM_SK_LEFT_BTN:
510 evas_object_move(btn, wd->x, wd->y);
512 case ELM_SK_RIGHT_BTN:
513 edje_object_part_geometry_get(btn, "button_rect", NULL, NULL, &btn_w, NULL);
514 evas_object_move(btn, wd->x + wd->w - btn_w, wd->y);
523 static void _softkey_up_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
527 Elm_Softkey_Item *it = (Elm_Softkey_Item *) data;
528 elm_softkey_panel_close(it->obj);
531 edj = elm_layout_edje_get(it->icon);
534 edje_object_signal_emit(edj, "elm,state,unselected", "elm");
537 it->func((void *) (it->data), it->obj, it);
538 evas_object_smart_callback_call(it->obj, "clicked", it);
541 static void _softkey_down_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
545 Elm_Softkey_Item *it = (Elm_Softkey_Item *) data;
546 evas_object_smart_callback_call(it->obj, "press", it);
550 edj = elm_layout_edje_get(it->icon);
554 edje_object_signal_emit(edj, "elm,state,selected", "elm");
557 static void _panel_up_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
559 Elm_Softkey_Item *it = (Elm_Softkey_Item *) data;
562 wd = elm_widget_data_get(it->obj);
566 /* hide glow effect */
568 evas_object_hide(wd->glow_obj);
571 elm_softkey_panel_close(it->obj);
573 it->func((void *) (it->data), it->obj, it);
574 evas_object_smart_callback_call(it->obj, "clicked", it);
577 static void _panel_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
579 Evas_Coord glow_x, glow_y;
582 Elm_Softkey_Item *it = (Elm_Softkey_Item *) data;
583 wd = elm_widget_data_get(it->obj);
587 /* show glow effect */
589 Evas_Event_Mouse_Down *ev = (Evas_Event_Mouse_Down *) event_info;
590 glow_x = ev->canvas.x - (wd->glow_w / 2);
591 glow_y = ev->canvas.y - (wd->glow_h / 2);
593 evas_object_move(wd->glow_obj, glow_x, glow_y);
594 evas_object_show(wd->glow_obj);
597 evas_object_smart_callback_call(it->obj, "press", it);
600 static int _delete_button(Evas_Object *obj)
606 evas_object_del(obj);
613 static void _calc_win_height(Widget_Data *wd)
615 wd->win_h = wd->y + wd->h;
618 evas_object_resize(wd->bg_rect, wd->w, wd->win_h);
619 evas_object_move(wd->bg_rect, wd->x, 0);
622 if (wd->show_panel) {
623 evas_object_move(wd->panel, wd->x, (wd->win_h - wd->panel_height));
626 evas_object_move(wd->panel, wd->x, wd->win_h);
630 static void _softkey_object_move(void *data, Evas *e, Evas_Object *obj, void *event_info)
638 wd = elm_widget_data_get((Evas_Object *) data);
642 evas_object_geometry_get(wd->lay, &x, &y, NULL, NULL);
647 evas_object_move(wd->lay, x, y);
649 for (i = 0; i < 2; i++) {
650 _arrange_button((Evas_Object *) data, i);
653 _calc_win_height(wd);
656 static void _softkey_object_resize(void *data, Evas *e, Evas_Object *obj, void *event_info)
666 wd = elm_widget_data_get((Evas_Object *) data);
670 evas_object_geometry_get(wd->lay, NULL, NULL, &w, &h);
677 evas_object_resize(wd->lay, w, h);
680 for (i = 0; i < 2; i++) {
683 edje_object_part_geometry_get(btn, "button_rect", NULL, NULL, &btn_w, NULL);
684 evas_object_resize(btn, btn_w, h);
685 _arrange_button((Evas_Object *) data, i);
689 if (wd->w >= wd->win_h) {
690 _softkey_horizontal_set(data, EINA_TRUE);
693 _softkey_horizontal_set(data, EINA_FALSE);
695 _calc_win_height(wd);
698 static void _softkey_object_show(void *data, Evas *e, Evas_Object *obj, void *event_info)
700 Widget_Data *wd = NULL;
705 wd = elm_widget_data_get((Evas_Object *) data);
710 evas_object_show(wd->lay);
714 for (i = 0; i < 2; i++) {
716 if (btn != NULL && wd->button_show[i] == EINA_TRUE) {
717 evas_object_show(btn);
718 //evas_object_clip_set(btn, evas_object_clip_get((Evas_Object *)data));
721 if (wd->panel_btn_idx > 0) {
722 /* show more button */
723 edje_object_signal_emit(wd->lay, "more_btn_show", "");
727 static void _softkey_object_hide(void *data, Evas *e, Evas_Object *obj, void *event_info)
729 Widget_Data *wd = NULL;
735 wd = elm_widget_data_get((Evas_Object *) data);
740 evas_object_hide(wd->lay);
744 for (i = 0; i < 2; i++) {
747 evas_object_hide(btn);
751 if (wd->panel_btn_idx > 0) {
752 /* hide more button */
753 edje_object_signal_emit(wd->lay, "more_btn_hide", "");
758 * Add a new softkey to the parent
760 * @param parent the parent of the smart object
761 * @return Evas_Object* pointer of softkey(evas object) or NULL
765 elm_softkey_add(Evas_Object *parent)
767 Evas_Object *obj = NULL;
768 Widget_Data *wd = NULL;
771 wd = ELM_NEW(Widget_Data);
772 e = evas_object_evas_get(parent);
775 obj = elm_widget_add(e);
776 elm_widget_type_set(obj, "softkey");
777 elm_widget_sub_object_add(parent, obj);
778 elm_widget_data_set(obj, wd);
779 elm_widget_del_hook_set(obj, _del_hook);
780 elm_widget_theme_hook_set(obj, _theme_hook);
782 /* load background edj */
783 wd->lay = edje_object_add(e);
784 _elm_theme_object_set(obj, wd->lay, "softkey", "bg", "default");
785 if (wd->lay == NULL) {
786 printf("Cannot load bg edj\n");
789 elm_widget_resize_object_set(obj, wd->lay);
790 edje_object_signal_callback_add(wd->lay, "clicked", "more_btn", _more_btn_click_cb, obj);
792 evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE, _softkey_object_resize, obj);
793 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOVE, _softkey_object_move, obj);
794 evas_object_event_callback_add(obj, EVAS_CALLBACK_SHOW, _softkey_object_show, obj);
795 evas_object_event_callback_add(obj, EVAS_CALLBACK_HIDE, _softkey_object_hide, obj);
796 wd->is_horizontal = EINA_FALSE;
797 wd->panel_suppported = EINA_TRUE;
798 wd->scale_factor = elm_scale_get();
799 if (wd->scale_factor == 0.0) {
800 wd->scale_factor = 1.0;
803 /* load glow effect */
804 wd->glow_obj = edje_object_add(e);
805 _elm_theme_object_set(obj, wd->glow_obj, "softkey", "glow", "default");
806 evas_object_geometry_get(wd->glow_obj, NULL, NULL, &wd->glow_w, &wd->glow_h);
807 evas_object_resize(wd->glow_obj, wd->glow_w, wd->glow_h);
810 evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
812 // _sizing_eval(obj);
817 static 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) || (edje_object_data_get(wd->panel, "panel_height") == NULL) || (edje_object_data_get(wd->panel, "panel_height_horizontal") == NULL)) {
829 wd->panel_suppported = EINA_FALSE;
832 wd->panel_suppported = EINA_TRUE;
833 if (wd->panel_suppported == EINA_TRUE) {
834 if (wd->is_horizontal == EINA_TRUE) {
835 sprintf(buff, "button_%d", (wd->panel_btn_idx + wd->max_button));
836 edje_object_signal_emit(wd->panel, buff, "panel_rect");
837 wd->panel_height = (int) (atoi(edje_object_data_get(wd->panel, buff)) * wd->scale_factor);
838 evas_object_resize(wd->panel, wd->w, ((int) (atoi(edje_object_data_get(wd->panel, "panel_height_horizontal")) * wd->scale_factor)));
841 sprintf(buff, "button_%d", (wd->panel_btn_idx));
842 edje_object_signal_emit(wd->panel, buff, "panel_rect");
843 wd->panel_height = (int) (atoi(edje_object_data_get(wd->panel, buff)) * wd->scale_factor);
844 evas_object_resize(wd->panel, wd->w, ((int) (atoi(edje_object_data_get(wd->panel, "panel_height")) * wd->scale_factor)));
847 _calc_win_height(wd);
853 * add side button of softkey
854 * @param obj softkey object
855 * @param type softkey button type
856 * @param icon The icon object to use for the item
857 * @param label The text label to use for the item
858 * @param func Convenience function to call when this item is selected
859 * @param data Data to pass to convenience function
860 * @return A handle to the item added
864 EAPI Elm_Softkey_Item *
865 elm_softkey_button_add(Evas_Object *obj, Elm_Softkey_Type type, Evas_Object *icon, const char *label, void(*func)(void *data, Evas_Object *obj, void *event_info), const void *data)
869 char button_type[64];
870 Elm_Softkey_Item *it;
874 wd = elm_widget_data_get(obj);
878 if (wd->button[type]) {
879 printf("already created.\n");
884 evas = evas_object_evas_get(obj);
889 it = ELM_NEW(Elm_Softkey_Item);
894 /* load button edj */
895 if (wd->button[type] == NULL) {
896 if (type == ELM_SK_LEFT_BTN) {
897 strcpy(button_type, "button_left");
900 strcpy(button_type, "button_right");
903 it->base = wd->button[type] = edje_object_add(evas);
904 if (!wd->button[type]) {
908 _elm_theme_object_set(obj, wd->button[type], "softkey", button_type, elm_widget_style_get(obj));
910 wd->button_show[type] = EINA_TRUE;
911 if (evas_object_visible_get(obj)) {
912 evas_object_show(wd->button[type]);
914 evas_object_smart_member_add(wd->button[type], obj);
916 edje_object_signal_callback_add(wd->button[type], "elm,action,down", "", _softkey_down_cb, it);
917 edje_object_signal_callback_add(wd->button[type], "elm,action,click", "", _softkey_up_cb, it);
919 evas_object_clip_set(wd->button[type], evas_object_clip_get(obj));
921 evas_object_raise(wd->panel);
926 elm_softkey_item_label_set(it, label);
927 elm_softkey_item_icon_set(it, icon);
928 if (wd->button[type])
929 evas_object_data_set(wd->button[type], "item_data", it);
932 eina_stringshare_del(it->label);
942 * delete side button of softkey
943 * @param obj softkey object
944 * @param type softkey button type
948 EAPI void elm_softkey_button_del(Evas_Object *obj, Elm_Softkey_Type type)
951 Elm_Softkey_Item *it;
955 printf("Invalid argument: softkey object is NULL\n");
959 wd = elm_widget_data_get(obj);
963 btn = wd->button[type];
967 it = evas_object_data_get(btn, "item_data");
970 wd->button[type] = NULL;
974 * show button of softkey
975 * @param obj softkey object
976 * @param type softkey button type
980 EAPI void elm_softkey_button_show(Evas_Object *obj, Elm_Softkey_Type type)
982 _show_button(obj, type, EINA_TRUE);
986 * hide button of softkey
987 * @param obj softkey object
988 * @param type softkey button type
992 EAPI void elm_softkey_button_hide(Evas_Object *obj, Elm_Softkey_Type type)
994 _show_button(obj, type, EINA_FALSE);
999 * @param obj softkey object
1000 * @param icon The icon object
1001 * @param label The text label to use for the item
1002 * @param func Convenience function to call when this item is selected
1003 * @param data Data to pass to convenience function
1004 * @return A handle to the item added
1008 EAPI Elm_Softkey_Item *
1009 elm_softkey_panel_item_add(Evas_Object *obj, Evas_Object *icon, const char *label, void(*func)(void *data, Evas_Object *obj, void *event_info), const void *data)
1013 char button_name[32];
1015 Elm_Softkey_Item *it;
1016 char buff[PATH_MAX];
1018 wd = elm_widget_data_get(obj);
1020 printf("Cannot get smart data\n");
1025 evas = evas_object_evas_get(obj);
1029 if (wd->panel == NULL) {
1031 wd->bg_rect = evas_object_rectangle_add(evas);
1034 evas_object_color_set(wd->bg_rect, 10, 10, 10, 150);
1035 evas_object_pass_events_set(wd->bg_rect, 0);
1038 evas_object_resize(wd->bg_rect, wd->w, wd->win_h);
1039 evas_object_event_callback_add(wd->bg_rect, EVAS_CALLBACK_MOUSE_UP, _bg_click_cb, obj);
1040 evas_object_smart_member_add(wd->bg_rect, obj);
1043 wd->panel = edje_object_add(evas);
1046 _elm_theme_object_set(obj, wd->panel, "softkey", "panel", elm_widget_style_get(obj));
1048 evas_object_move(wd->panel, 0, wd->win_h);
1049 edje_object_signal_callback_add(wd->panel, "clicked", "close_btn", _close_btn_click_cb, obj);
1050 evas_object_smart_member_add(wd->panel, obj);
1051 if (evas_object_visible_get(obj)) {
1052 evas_object_show(wd->panel);
1054 wd->panel_height = 0;
1055 if ((edje_object_data_get(wd->panel, "max_item_count") == NULL) || (edje_object_data_get(wd->panel, "panel_height") == NULL) || (edje_object_data_get(wd->panel, "panel_height_horizontal") == NULL)) {
1056 //If this key is not found in data section, then it means the panel won't come.
1060 elm_softkey_panel_del(obj);
1062 wd->panel_suppported = EINA_FALSE;
1066 wd->max_button = (int) (atoi(edje_object_data_get(wd->panel, "max_item_count")));
1067 if (wd->is_horizontal) {
1068 evas_object_resize(wd->panel, wd->w, ((int) (atoi(edje_object_data_get(wd->panel, "panel_height_horizontal")) * wd->scale_factor)));
1071 evas_object_resize(wd->panel, wd->w, ((int) (atoi(edje_object_data_get(wd->panel, "panel_height")) * wd->scale_factor)));
1075 evas_object_clip_set(wd->panel, evas_object_clip_get(obj));
1078 wd->panel_btn_idx++;
1079 if (wd->panel_btn_idx >= wd->max_button)
1083 it = ELM_NEW(Elm_Softkey_Item);
1084 wd->items = eina_list_append(wd->items, it);
1087 it->label = eina_stringshare_add(label);
1091 /* load panel button */
1092 it->base = btn = edje_object_add(evas);
1095 eina_stringshare_del(it->label);
1097 wd->panel_btn_idx--;
1100 _elm_theme_object_set(obj, btn, "softkey", "panel_button", elm_widget_style_get(obj));
1102 edje_object_part_text_set(btn, "elm.text", label); /* set text */
1103 edje_object_message_signal_process(btn);
1105 evas_object_event_callback_add(btn, EVAS_CALLBACK_MOUSE_DOWN, _panel_down_cb, it);
1106 evas_object_event_callback_add(btn, EVAS_CALLBACK_MOUSE_UP, _panel_up_cb, it);
1109 /* swallow button */
1110 sprintf(button_name, "panel_button_area_%d", wd->panel_btn_idx);
1111 edje_object_part_swallow(wd->panel, button_name, btn);
1113 if (wd->is_horizontal) {
1114 sprintf(buff, "button_%d", wd->max_button + wd->panel_btn_idx);
1115 edje_object_signal_emit(wd->panel, buff, "panel_rect");
1116 const char* val = edje_object_data_get(wd->panel, buff);
1118 wd->panel_height = (int) (atoi(val) * wd->scale_factor);
1121 eina_stringshare_del(it->label);
1122 evas_object_del(it->base);
1124 wd->panel_btn_idx--;
1129 sprintf(buff, "button_%d", wd->panel_btn_idx);
1130 edje_object_signal_emit(wd->panel, buff, "panel_rect");
1131 const char* val = edje_object_data_get(wd->panel, buff);
1133 wd->panel_height = (int) (atoi(val) * wd->scale_factor);
1136 eina_stringshare_del(it->label);
1137 evas_object_del(it->base);
1139 wd->panel_btn_idx--;
1145 wd->panel_btn_idx--;
1149 if (evas_object_visible_get(obj)) {
1150 /* show more button */
1151 edje_object_signal_emit(wd->lay, "more_btn_show", "");
1159 * @param obj softkey object
1160 * @return int 0 (SUCCESS) or -1 (FAIL)
1164 EAPI int elm_softkey_panel_del(Evas_Object *obj)
1167 char button_name[32];
1170 Elm_Softkey_Item *it;
1172 wd = elm_widget_data_get(obj);
1175 if (wd->panel == NULL)
1178 ecore_animator_del(wd->animator);
1179 wd->animator = NULL;
1180 wd->animating=EINA_FALSE;
1183 for (i = 1; i <= wd->panel_btn_idx; i++) {
1184 sprintf(button_name, "panel_button_area_%d", i);
1185 btn = edje_object_part_swallow_get(wd->panel, button_name);
1186 _delete_button(btn);
1189 EINA_LIST_FREE(wd->items, it) {
1190 eina_stringshare_del(it->label);
1194 wd->panel_btn_idx = 0;
1195 wd->panel_height = 0;
1198 edje_object_signal_emit(wd->lay, "more_btn_hide", "");
1201 evas_object_move(wd->panel, 0, wd->win_h);
1202 evas_object_clip_unset(wd->panel);
1203 //<Added to delete the panel completely>
1204 evas_object_del(wd->panel);
1206 //<Added to delete the panel completely>
1213 * sliding up panel if it is closed
1215 * @param obj softkey object
1216 * @return int 0 (SUCCESS) or -1 (FAIL)
1220 EAPI int elm_softkey_panel_open(Evas_Object *obj)
1223 wd = elm_widget_data_get(obj);
1230 if (wd->show_panel == EINA_FALSE) {
1231 _more_btn_click_cb(obj, NULL, NULL, NULL);
1238 * sliding down panel if it is opened
1240 * @param obj softkey object
1241 * @return int 0 (SUCCESS) or -1 (FAIL)
1245 EAPI int elm_softkey_panel_close(Evas_Object *obj)
1248 wd = elm_widget_data_get(obj);
1252 if (wd->panel == NULL)
1255 if (wd->show_panel == EINA_TRUE) {
1256 _close_btn_click_cb(obj, obj, NULL, NULL);
1263 * Set the icon of an softkey item
1265 * @param it The item to set the icon
1266 * @param icon The icon object
1270 EAPI void elm_softkey_item_icon_set(Elm_Softkey_Item *it, Evas_Object *icon)
1275 if ((it->icon != icon) && (it->icon))
1276 elm_widget_sub_object_del(it->obj, it->icon);
1278 if ((icon) && (it->icon != icon)) {
1280 elm_widget_sub_object_add(it->obj, icon);
1281 //evas_object_event_callback_add(icon, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, obj);
1282 //edje_object_part_swallow(it->base, "elm.swallow.content", icon);
1283 edje_object_part_swallow(it->base, "elm.swallow.icon", icon);
1284 edje_object_signal_emit(it->base, "elm,state,icon,visible", "elm");
1285 edje_object_message_signal_process(it->base);
1286 _sizing_eval(it->obj);
1293 * Get the icon of an softkey item
1295 * @param it The item to get the icon
1296 * @return The icon object
1301 elm_softkey_item_icon_get(Elm_Softkey_Item *it)
1309 * Get the text label of an softkey item
1311 * @param it The item to set the label
1312 * @param label label
1316 EAPI void elm_softkey_item_label_set(Elm_Softkey_Item *it, const char *label)
1321 eina_stringshare_del(it->label);
1324 it->label = eina_stringshare_add(label);
1325 edje_object_signal_emit(it->base, "elm,state,text,visible", "elm");
1328 edje_object_part_text_set(it->base, "elm.text", label == NULL ? "" : label);
1332 edje_object_signal_emit(it->base, "elm,state,text,hidden", "elm");
1334 edje_object_message_signal_process(it->base);
1338 * Set the item callback function
1340 * @param it Item to set callback function.
1341 * @param func callback function pointer.
1342 * @param data callback function argument data.
1346 EAPI void elm_softkey_item_callback_set(Elm_Softkey_Item* item, void(*func)(void *data, Evas_Object *obj, void *event_info), const void *data)
1357 * Get the text label of an softkey item
1359 * @param it The item to get the label
1360 * @return The text label of the softkey item
1365 elm_softkey_item_label_get(Elm_Softkey_Item *it)
1372 EAPI Eina_Bool elm_softkey_item_disabled_get(Elm_Softkey_Item *it)
1376 return it->disabled;
1379 EAPI void elm_softkey_item_disabled_set(Elm_Softkey_Item *it, Eina_Bool disabled)
1383 _item_disable(it, disabled);