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)
218 _elm_theme_object_set(obj, it->base, "softkey", "panel_button", elm_widget_style_get(obj));
220 edje_object_part_text_set(it->base, "elm.text", it->label); // set text
229 static void _sub_del(void *data, Evas_Object *obj, void *event_info)
231 Widget_Data *wd = elm_widget_data_get(obj);
232 Evas_Object *sub = event_info;
234 Elm_Softkey_Item *it;
238 EINA_LIST_FOREACH(wd->items, l, it)
240 if(sub == it->icon) {
247 static void _sizing_eval(Evas_Object *obj)
249 Widget_Data *wd = elm_widget_data_get(obj);
254 _softkey_object_move(obj, NULL, obj, NULL);
255 _softkey_object_resize(obj, NULL, obj, NULL);
258 static int _panel_up_animator_cb(void *data)
260 int max = PANEL_ANIMATOR_MAX;
261 static int progress = 0;
265 wd = elm_widget_data_get(data);
270 wd->animating = EINA_TRUE;
272 if (progress > max) {
275 ecore_animator_del(wd->animator);
276 wd->animating = EINA_FALSE;
277 wd->show_panel = EINA_TRUE;
284 ypos = wd->win_h - (wd->panel_height * progress / max);
285 evas_object_move(wd->panel, wd->x, ypos);
291 static int _panel_down_animator_cb(void *data)
293 int max = PANEL_ANIMATOR_MAX;
294 static int progress = 0;
298 wd = elm_widget_data_get(data);
303 wd->animating = EINA_TRUE;
305 if (progress > max) {
308 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);
436 static void _close_panel(Evas_Object *obj)
439 wd = elm_widget_data_get(obj);
444 evas_object_hide(wd->bg_rect);
450 if (wd->animating == EINA_FALSE) {
451 wd->animator = ecore_animator_add(_panel_down_animator_cb, obj);
455 static void _bg_click_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
460 static void _close_btn_click_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
465 static int _show_button(Evas_Object *obj, Elm_Softkey_Type type, Eina_Bool show)
470 Widget_Data *wd = elm_widget_data_get(obj);
471 Evas_Object *btn = wd->button[type];
475 /* Make visible button */
477 wd->button_show[type] = EINA_TRUE;
478 evas_object_show(btn);
481 wd->button_show[type] = EINA_FALSE;
482 evas_object_hide(btn);
488 static int _arrange_button(Evas_Object *obj, Elm_Softkey_Type type)
491 Evas_Coord btn_w = 0;
496 wd = elm_widget_data_get(obj);
500 btn = wd->button[type];
506 case ELM_SK_LEFT_BTN:
507 evas_object_move(btn, wd->x, wd->y);
509 case ELM_SK_RIGHT_BTN:
510 edje_object_part_geometry_get(btn, "button_rect", NULL, NULL, &btn_w, NULL);
511 evas_object_move(btn, wd->x + wd->w - btn_w, wd->y);
520 static void _softkey_up_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
524 Elm_Softkey_Item *it = (Elm_Softkey_Item *) data;
525 elm_softkey_panel_close(it->obj);
527 it->func((void *) (it->data), it->obj, it);
528 evas_object_smart_callback_call(it->obj, "clicked", it);
532 edj = elm_layout_edje_get(it->icon);
536 edje_object_signal_emit(edj, "elm,state,unselected", "elm");
539 static void _softkey_down_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
543 Elm_Softkey_Item *it = (Elm_Softkey_Item *) data;
544 evas_object_smart_callback_call(it->obj, "press", it);
548 edj = elm_layout_edje_get(it->icon);
552 edje_object_signal_emit(edj, "elm,state,selected", "elm");
555 static void _panel_up_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
557 Elm_Softkey_Item *it = (Elm_Softkey_Item *) data;
560 wd = elm_widget_data_get(it->obj);
564 /* hide glow effect */
566 evas_object_hide(wd->glow_obj);
569 elm_softkey_panel_close(it->obj);
571 it->func((void *) (it->data), it->obj, it);
572 evas_object_smart_callback_call(it->obj, "clicked", it);
575 static void _panel_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
577 Evas_Coord glow_x, glow_y;
580 Elm_Softkey_Item *it = (Elm_Softkey_Item *) data;
581 wd = elm_widget_data_get(it->obj);
585 /* show glow effect */
587 Evas_Event_Mouse_Down *ev = (Evas_Event_Mouse_Down *) event_info;
588 glow_x = ev->canvas.x - (wd->glow_w / 2);
589 glow_y = ev->canvas.y - (wd->glow_h / 2);
591 evas_object_move(wd->glow_obj, glow_x, glow_y);
592 evas_object_show(wd->glow_obj);
595 evas_object_smart_callback_call(it->obj, "press", it);
598 static int _delete_button(Evas_Object *obj)
604 evas_object_del(obj);
611 static void _calc_win_height(Widget_Data *wd)
613 wd->win_h = wd->y + wd->h;
616 evas_object_resize(wd->bg_rect, wd->w, wd->win_h);
617 evas_object_move(wd->bg_rect, wd->x, 0);
620 if (wd->show_panel) {
621 evas_object_move(wd->panel, wd->x, (wd->win_h - wd->panel_height));
624 evas_object_move(wd->panel, wd->x, wd->win_h);
628 static void _softkey_object_move(void *data, Evas *e, Evas_Object *obj, void *event_info)
636 wd = elm_widget_data_get((Evas_Object *) data);
640 evas_object_geometry_get(wd->lay, &x, &y, NULL, NULL);
645 evas_object_move(wd->lay, x, y);
647 for (i = 0; i < 2; i++) {
648 _arrange_button((Evas_Object *) data, i);
651 _calc_win_height(wd);
654 static void _softkey_object_resize(void *data, Evas *e, Evas_Object *obj, void *event_info)
664 wd = elm_widget_data_get((Evas_Object *) data);
668 evas_object_geometry_get(wd->lay, NULL, NULL, &w, &h);
675 evas_object_resize(wd->lay, w, h);
678 for (i = 0; i < 2; i++) {
681 edje_object_part_geometry_get(btn, "button_rect", NULL, NULL, &btn_w, 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);
691 _softkey_horizontal_set(data, EINA_FALSE);
693 _calc_win_height(wd);
696 static void _softkey_object_show(void *data, Evas *e, Evas_Object *obj, void *event_info)
698 Widget_Data *wd = NULL;
703 wd = elm_widget_data_get((Evas_Object *) data);
708 evas_object_show(wd->lay);
712 for (i = 0; i < 2; i++) {
714 if (btn != NULL && wd->button_show[i] == EINA_TRUE) {
715 evas_object_show(btn);
716 //evas_object_clip_set(btn, evas_object_clip_get((Evas_Object *)data));
719 if (wd->panel_btn_idx > 0) {
720 /* show more button */
721 edje_object_signal_emit(wd->lay, "more_btn_show", "");
725 static void _softkey_object_hide(void *data, Evas *e, Evas_Object *obj, void *event_info)
727 Widget_Data *wd = NULL;
733 wd = elm_widget_data_get((Evas_Object *) data);
738 evas_object_hide(wd->lay);
742 for (i = 0; i < 2; i++) {
745 evas_object_hide(btn);
749 if (wd->panel_btn_idx > 0) {
750 /* hide more button */
751 edje_object_signal_emit(wd->lay, "more_btn_hide", "");
756 * Add a new softkey to the parent
758 * @param parent the parent of the smart object
759 * @return Evas_Object* pointer of softkey(evas object) or NULL
763 elm_softkey_add(Evas_Object *parent)
765 Evas_Object *obj = NULL;
766 Widget_Data *wd = NULL;
769 wd = ELM_NEW(Widget_Data);
770 e = evas_object_evas_get(parent);
773 obj = elm_widget_add(e);
774 elm_widget_type_set(obj, "softkey");
775 elm_widget_sub_object_add(parent, obj);
776 elm_widget_data_set(obj, wd);
777 elm_widget_del_hook_set(obj, _del_hook);
778 elm_widget_theme_hook_set(obj, _theme_hook);
780 /* load background edj */
781 wd->lay = edje_object_add(e);
782 _elm_theme_object_set(obj, wd->lay, "softkey", "bg", "default");
783 if (wd->lay == NULL) {
784 printf("Cannot load bg edj\n");
787 elm_widget_resize_object_set(obj, wd->lay);
788 edje_object_signal_callback_add(wd->lay, "clicked", "more_btn", _more_btn_click_cb, obj);
790 evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE, _softkey_object_resize, obj);
791 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOVE, _softkey_object_move, obj);
792 evas_object_event_callback_add(obj, EVAS_CALLBACK_SHOW, _softkey_object_show, obj);
793 evas_object_event_callback_add(obj, EVAS_CALLBACK_HIDE, _softkey_object_hide, obj);
794 wd->is_horizontal = EINA_FALSE;
795 wd->panel_suppported = EINA_TRUE;
796 wd->scale_factor = elm_scale_get();
797 if (wd->scale_factor == 0.0) {
798 wd->scale_factor = 1.0;
801 /* load glow effect */
802 wd->glow_obj = edje_object_add(e);
803 _elm_theme_object_set(obj, wd->glow_obj, "softkey", "glow", "default");
804 evas_object_geometry_get(wd->glow_obj, NULL, NULL, &wd->glow_w, &wd->glow_h);
805 evas_object_resize(wd->glow_obj, wd->glow_w, wd->glow_h);
808 evas_object_smart_callback_add(obj, "sub-object-del", _sub_del, obj);
810 // _sizing_eval(obj);
815 static void _softkey_horizontal_set(Evas_Object *obj, Eina_Bool horizontal_mode)
821 wd = elm_widget_data_get(obj);
824 wd->is_horizontal = horizontal_mode;
826 if ((edje_object_data_get(wd->panel, "max_item_count") == NULL)
827 || (edje_object_data_get(wd->panel, "panel_height") == NULL)
828 || (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"))
839 * wd->scale_factor)));
842 sprintf(buff, "button_%d", (wd->panel_btn_idx));
843 edje_object_signal_emit(wd->panel, buff, "panel_rect");
844 wd->panel_height = (int) (atoi(edje_object_data_get(wd->panel, buff)) * wd->scale_factor);
845 evas_object_resize(wd->panel, wd->w, ((int) (atoi(edje_object_data_get(wd->panel, "panel_height"))
846 * wd->scale_factor)));
849 _calc_win_height(wd);
855 * add side button of softkey
856 * @param obj softkey object
857 * @param type softkey button type
858 * @param icon The icon object to use for the item
859 * @param label The text label to use for the item
860 * @param func Convenience function to call when this item is selected
861 * @param data Data to pass to convenience function
862 * @return A handle to the item added
866 EAPI Elm_Softkey_Item *
867 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)
871 char button_type[64];
872 Elm_Softkey_Item *it;
876 wd = elm_widget_data_get(obj);
880 if (wd->button[type]) {
881 printf("already created.\n");
886 it = ELM_NEW(Elm_Softkey_Item);
892 evas = evas_object_evas_get(obj);
896 /* load button edj */
897 if (wd->button[type] == NULL) {
898 if (type == ELM_SK_LEFT_BTN) {
899 strcpy(button_type, "button_left");
902 strcpy(button_type, "button_right");
905 it->base = wd->button[type] = edje_object_add(evas);
906 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);
929 evas_object_data_set(wd->button[type], "item_data", it);
935 * delete side button of softkey
936 * @param obj softkey object
937 * @param type softkey button type
941 EAPI void elm_softkey_button_del(Evas_Object *obj, Elm_Softkey_Type type)
944 Elm_Softkey_Item *it;
948 printf("Invalid argument: softkey object is NULL\n");
952 wd = elm_widget_data_get(obj);
956 btn = wd->button[type];
960 it = evas_object_data_get(btn, "item_data");
963 wd->button[type] = NULL;
967 * show button of softkey
968 * @param obj softkey object
969 * @param type softkey button type
973 EAPI void elm_softkey_button_show(Evas_Object *obj, Elm_Softkey_Type type)
975 _show_button(obj, type, EINA_TRUE);
979 * hide button of softkey
980 * @param obj softkey object
981 * @param type softkey button type
985 EAPI void elm_softkey_button_hide(Evas_Object *obj, Elm_Softkey_Type type)
987 _show_button(obj, type, EINA_FALSE);
992 * @param obj softkey object
993 * @param icon The icon object
994 * @param label The text label to use for the item
995 * @param func Convenience function to call when this item is selected
996 * @param data Data to pass to convenience function
997 * @return A handle to the item added
1001 EAPI Elm_Softkey_Item *
1002 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)
1006 char button_name[32];
1008 Elm_Softkey_Item *it;
1009 char buff[PATH_MAX];
1011 wd = elm_widget_data_get(obj);
1013 printf("Cannot get smart data\n");
1018 it = ELM_NEW(Elm_Softkey_Item);
1019 wd->items = eina_list_append(wd->items, it);
1021 it->label = eina_stringshare_add(label);
1027 evas = evas_object_evas_get(obj);
1031 if (wd->panel == NULL) {
1033 wd->bg_rect = evas_object_rectangle_add(evas);
1036 evas_object_color_set(wd->bg_rect, 10, 10, 10, 150);
1037 evas_object_pass_events_set(wd->bg_rect, 0);
1040 evas_object_resize(wd->bg_rect, wd->w, wd->win_h);
1041 evas_object_event_callback_add(wd->bg_rect, EVAS_CALLBACK_MOUSE_UP, _bg_click_cb, obj);
1042 evas_object_smart_member_add(wd->bg_rect, obj);
1045 wd->panel = edje_object_add(evas);
1048 _elm_theme_object_set(obj, wd->panel, "softkey", "panel", elm_widget_style_get(obj));
1050 evas_object_move(wd->panel, 0, wd->win_h);
1051 edje_object_signal_callback_add(wd->panel, "clicked", "close_btn", _close_btn_click_cb, obj);
1052 evas_object_smart_member_add(wd->panel, obj);
1053 if (evas_object_visible_get(obj)) {
1054 evas_object_show(wd->panel);
1056 wd->panel_height = 0;
1057 if ((edje_object_data_get(wd->panel, "max_item_count") == NULL)
1058 || (edje_object_data_get(wd->panel, "panel_height") == NULL)
1059 || (edje_object_data_get(wd->panel, "panel_height_horizontal") == NULL)) {
1060 //If this key is not found in data section, then it means the panel won't come.
1064 elm_softkey_panel_del(obj);
1066 wd->panel_suppported = EINA_FALSE;
1070 wd->max_button = (int) (atoi(edje_object_data_get(wd->panel, "max_item_count")));
1071 if (wd->is_horizontal) {
1072 evas_object_resize(wd->panel, wd->w, ((int) (atoi(edje_object_data_get(wd->panel, "panel_height_horizontal"))
1073 * wd->scale_factor)));
1076 evas_object_resize(wd->panel, wd->w, ((int) (atoi(edje_object_data_get(wd->panel, "panel_height"))
1077 * wd->scale_factor)));
1081 evas_object_clip_set(wd->panel, evas_object_clip_get(obj));
1084 if (wd->panel_btn_idx >= wd->max_button)
1087 wd->panel_btn_idx++;
1089 if (evas_object_visible_get(obj)) {
1090 /* show more button */
1091 edje_object_signal_emit(wd->lay, "more_btn_show", "");
1094 /* load panel button */
1095 it->base = btn = edje_object_add(evas);
1098 _elm_theme_object_set(obj, btn, "softkey", "panel_button", elm_widget_style_get(obj));
1100 edje_object_part_text_set(btn, "elm.text", label); /* set text */
1101 edje_object_message_signal_process(btn);
1103 evas_object_event_callback_add(btn, EVAS_CALLBACK_MOUSE_DOWN, _panel_down_cb, it);
1104 evas_object_event_callback_add(btn, EVAS_CALLBACK_MOUSE_UP, _panel_up_cb, it);
1106 /* swallow button */
1107 sprintf(button_name, "panel_button_area_%d", wd->panel_btn_idx);
1108 edje_object_part_swallow(wd->panel, button_name, btn);
1109 if (wd->is_horizontal) {
1110 sprintf(buff, "button_%d", wd->max_button + wd->panel_btn_idx);
1111 edje_object_signal_emit(wd->panel, buff, "panel_rect");
1112 wd->panel_height = (int) (atoi(edje_object_data_get(wd->panel, buff)) * wd->scale_factor);
1115 sprintf(buff, "button_%d", wd->panel_btn_idx);
1116 edje_object_signal_emit(wd->panel, buff, "panel_rect");
1117 wd->panel_height = (int) (atoi(edje_object_data_get(wd->panel, buff)) * wd->scale_factor);
1126 * @param obj softkey object
1127 * @return int 0 (SUCCESS) or -1 (FAIL)
1131 EAPI int elm_softkey_panel_del(Evas_Object *obj)
1134 char button_name[32];
1137 Elm_Softkey_Item *it;
1139 wd = elm_widget_data_get(obj);
1142 if (wd->panel == NULL)
1145 for (i = 1; i <= wd->panel_btn_idx; i++) {
1146 sprintf(button_name, "panel_button_area_%d", i);
1147 btn = edje_object_part_swallow_get(wd->panel, button_name);
1148 _delete_button(btn);
1151 EINA_LIST_FREE(wd->items, it)
1153 eina_stringshare_del(it->label);
1157 wd->panel_btn_idx = 0;
1158 wd->panel_height = 0;
1161 edje_object_signal_emit(wd->lay, "more_btn_hide", "");
1164 evas_object_move(wd->panel, 0, wd->win_h);
1165 evas_object_clip_unset(wd->panel);
1166 //<Added to delete the panel completely>
1167 evas_object_del(wd->panel);
1169 //<Added to delete the panel completely>
1176 * sliding up panel if it is closed
1178 * @param obj softkey object
1179 * @return int 0 (SUCCESS) or -1 (FAIL)
1183 EAPI int elm_softkey_panel_open(Evas_Object *obj)
1186 wd = elm_widget_data_get(obj);
1193 if (wd->show_panel == EINA_FALSE) {
1194 _more_btn_click_cb(obj, NULL, NULL, NULL);
1201 * sliding down panel if it is opened
1203 * @param obj softkey object
1204 * @return int 0 (SUCCESS) or -1 (FAIL)
1208 EAPI int elm_softkey_panel_close(Evas_Object *obj)
1211 wd = elm_widget_data_get(obj);
1215 if (wd->panel == NULL)
1218 if (wd->show_panel == EINA_TRUE) {
1219 _close_btn_click_cb(obj, obj, NULL, NULL);
1226 * Set the icon of an softkey item
1228 * @param it The item to set the icon
1229 * @param icon The icon object
1233 EAPI void elm_softkey_item_icon_set(Elm_Softkey_Item *it, Evas_Object *icon)
1238 if ((it->icon != icon) && (it->icon))
1239 elm_widget_sub_object_del(it->obj, it->icon);
1241 if ((icon) && (it->icon != icon)) {
1243 elm_widget_sub_object_add(it->obj, icon);
1244 //evas_object_event_callback_add(icon, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _changed_size_hints, obj);
1245 //edje_object_part_swallow(it->base, "elm.swallow.content", icon);
1246 edje_object_part_swallow(it->base, "elm.swallow.icon", icon);
1247 edje_object_signal_emit(it->base, "elm,state,icon,visible", "elm");
1248 edje_object_message_signal_process(it->base);
1249 _sizing_eval(it->obj);
1256 * Get the icon of an softkey item
1258 * @param it The item to get the icon
1259 * @return The icon object
1264 elm_softkey_item_icon_get(Elm_Softkey_Item *it)
1272 * Get the text label of an softkey item
1274 * @param it The item to set the label
1275 * @param label label
1279 EAPI void elm_softkey_item_label_set(Elm_Softkey_Item *it, const char *label)
1284 eina_stringshare_del(it->label);
1287 it->label = eina_stringshare_add(label);
1288 edje_object_signal_emit(it->base, "elm,state,text,visible", "elm");
1291 edje_object_part_text_set(it->base, "elm.text", label == NULL ? "" : label);
1295 edje_object_signal_emit(it->base, "elm,state,text,hidden", "elm");
1297 edje_object_message_signal_process(it->base);
1301 * Set the item callback function
1303 * @param it Item to set callback function.
1304 * @param func callback function pointer.
1305 * @param data callback function argument data.
1309 EAPI void elm_softkey_item_callback_set(Elm_Softkey_Item* item, void(*func)(void *data, Evas_Object *obj, void *event_info), const void *data)
1320 * Get the text label of an softkey item
1322 * @param it The item to get the label
1323 * @return The text label of the softkey item
1328 elm_softkey_item_label_get(Elm_Softkey_Item *it)
1335 EAPI Eina_Bool elm_softkey_item_disabled_get(Elm_Softkey_Item *it)
1339 return it->disabled;
1342 EAPI void elm_softkey_item_disabled_set(Elm_Softkey_Item *it, Eina_Bool disabled)
1346 _item_disable(it, disabled);