1 #include <Elementary.h>
4 typedef struct _Widget_Data Widget_Data;
5 typedef struct _Elm_Naviframe_Item Elm_Naviframe_Item;
6 typedef struct _Elm_Naviframe_Content_Item_Pair Elm_Naviframe_Content_Item_Pair;
7 typedef struct _Elm_Naviframe_Text_Item_Pair Elm_Naviframe_Text_Item_Pair;
13 Eina_Bool preserve: 1;
14 Eina_Bool auto_pushed: 1;
15 Eina_Bool freeze_events: 1;
18 struct _Elm_Naviframe_Content_Item_Pair
23 Elm_Naviframe_Item *it;
26 struct _Elm_Naviframe_Text_Item_Pair
33 struct _Elm_Naviframe_Item
37 Eina_Inlist *content_list;
38 Eina_Inlist *text_list;
40 Evas_Object *title_prev_btn;
41 Evas_Object *title_next_btn;
42 Evas_Object *title_icon;
46 Eina_Bool back_btn: 1;
47 Eina_Bool title_visible: 1;
50 static const char *widtype = NULL;
52 static const char SIG_TRANSITION_FINISHED[] = "transition,finished";
53 static const char SIG_PUSH_FINISHED[] = "push,finished";
54 static const char SIG_POP_FINISHED[] = "pop,finished";
55 static const char SIG_TITLE_CLICKED[] = "title,clicked";
57 static const Evas_Smart_Cb_Description _signals[] = {
58 {SIG_TRANSITION_FINISHED, ""},
59 {SIG_TITLE_CLICKED, ""},
63 static void _del_hook(Evas_Object *obj);
64 static void _theme_hook(Evas_Object *obj);
65 static void _emit_hook(Evas_Object *obj,
68 static void _disable_hook(Evas_Object *obj);
69 static void _mirrored_set(Evas_Object *obj, Eina_Bool rtl);
70 static void _item_text_set_hook(Elm_Object_Item *it,
73 static const char *_item_text_get_hook(const Elm_Object_Item *it,
75 static void _item_content_set_hook(Elm_Object_Item *it,
77 Evas_Object *content);
78 static Evas_Object *_item_content_get_hook(const Elm_Object_Item *it,
80 static Evas_Object *_item_content_unset_hook(Elm_Object_Item *it,
82 static void _item_signal_emit_hook(Elm_Object_Item *it,
85 static void _item_title_visible_update(Elm_Naviframe_Item *navi_it);
86 static void _sizing_eval(Evas_Object *obj);
87 static void _move(void *data, Evas *e, Evas_Object *obj, void *event_info);
88 static void _resize(void *data,
92 static void _title_clicked(void *data, Evas_Object *obj,
95 static void _back_btn_clicked(void *data,
98 static Evas_Object *_back_btn_new(Evas_Object *obj);
99 static void _item_content_del(void *data,
103 static void _title_content_del(void *data,
107 static void _title_prev_btn_del(void *data,
111 static void _title_next_btn_del(void *data,
115 static void _title_icon_del(void *data,
119 static void _title_content_set(Elm_Naviframe_Item *it,
121 Evas_Object *content);
122 static void _title_prev_btn_set(Elm_Naviframe_Item *it,
125 static void _title_next_btn_set(Elm_Naviframe_Item *it, Evas_Object *btn);
126 static void _title_icon_set(Elm_Naviframe_Item *it, Evas_Object *icon);
127 static Evas_Object * _item_content_unset(Elm_Naviframe_Item *it);
128 static Evas_Object * _title_prev_btn_unset(Elm_Naviframe_Item *it);
129 static Evas_Object * _title_next_btn_unset(Elm_Naviframe_Item *it);
130 static Evas_Object * _title_icon_unset(Elm_Naviframe_Item *it);
131 static Evas_Object * _title_content_unset(Elm_Naviframe_Item *it,
133 static void _item_del(Elm_Naviframe_Item *it);
134 static void _pushed_finished(void *data,
136 const char *emission,
138 static void _popped_finished(void *data,
140 const char *emission,
142 static void _show_finished(void *data,
144 const char *emission,
146 static void _changed_size_hints(void *data,
150 static void _item_content_set(Elm_Naviframe_Item *navi_it,
151 Evas_Object *content);
152 static void _item_style_set(Elm_Naviframe_Item *navi_it,
153 const char *item_style);
154 static Elm_Naviframe_Item * _item_new(Evas_Object *obj,
155 const char *title_label,
156 Evas_Object *prev_btn,
157 Evas_Object *next_btn,
158 Evas_Object *content,
159 const char *item_style);
162 _del_hook(Evas_Object *obj)
165 Elm_Naviframe_Item *it;
167 wd = elm_widget_data_get(obj);
172 while (wd->stack->last)
174 it = EINA_INLIST_CONTAINER_GET(wd->stack->last,
176 wd->stack = eina_inlist_remove(wd->stack, wd->stack->last);
178 if (!wd->stack) break;
185 _theme_hook(Evas_Object *obj)
188 Elm_Naviframe_Item *it;
190 wd = elm_widget_data_get(obj);
193 _elm_theme_object_set(obj,
197 elm_widget_style_get(obj));
199 EINA_INLIST_FOREACH(wd->stack, it)
201 _item_style_set(it, it->style);
202 _item_title_visible_update(it);
205 _elm_widget_mirrored_reload(obj);
206 _mirrored_set(obj, elm_widget_mirrored_get(obj));
209 static void _emit_hook(Evas_Object *obj,
210 const char *emission,
213 ELM_CHECK_WIDTYPE(obj, widtype);
215 Widget_Data *wd = elm_widget_data_get(obj);
218 edje_object_signal_emit(wd->base, emission, source);
222 _disable_hook(Evas_Object *obj __UNUSED__)
228 _mirrored_set(Evas_Object *obj, Eina_Bool rtl)
231 Elm_Naviframe_Item *it;
233 wd = elm_widget_data_get(obj);
236 EINA_INLIST_FOREACH(wd->stack, it)
237 edje_object_mirrored_set(VIEW(it), rtl);
238 edje_object_mirrored_set(wd->base, rtl);
242 _item_text_set_hook(Elm_Object_Item *it,
246 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
248 Elm_Naviframe_Text_Item_Pair *pair = NULL;
249 Elm_Naviframe_Item *navi_it = (Elm_Naviframe_Item *) it;
252 if (!part || !strcmp(part, "default"))
253 snprintf(buf, sizeof(buf), "elm.text.title");
254 else if(!strcmp("subtitle", part))
255 snprintf(buf, sizeof(buf), "elm.text.subtitle");
257 snprintf(buf, sizeof(buf), "%s", part);
259 EINA_INLIST_FOREACH(navi_it->text_list, pair)
260 if (!strcmp(buf, pair->part)) break;
264 pair = ELM_NEW(Elm_Naviframe_Text_Item_Pair);
267 ERR("Failed to allocate new text part of the item! : naviframe=%p",
271 eina_stringshare_replace(&pair->part, buf);
272 navi_it->text_list = eina_inlist_append(navi_it->text_list,
273 EINA_INLIST_GET(pair));
276 eina_stringshare_replace(&pair->text, label);
277 edje_object_part_text_set(VIEW(navi_it), buf, label);
281 snprintf(buf, sizeof(buf), "elm,state,%s,show", buf);
282 edje_object_signal_emit(VIEW(navi_it), buf, "elm");
286 snprintf(buf, sizeof(buf), "elm,state,%s,hide", buf);
287 edje_object_signal_emit(VIEW(navi_it), buf, "elm");
290 _sizing_eval(WIDGET(navi_it));
294 _item_text_get_hook(const Elm_Object_Item *it, const char *part)
296 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
297 Elm_Naviframe_Text_Item_Pair *pair = NULL;
298 Elm_Naviframe_Item *navi_it = (Elm_Naviframe_Item *) it;
301 if (!part || !strcmp(part, "default"))
302 snprintf(buf, sizeof(buf), "elm.text.title");
303 else if(!strcmp("subtitle", part))
304 snprintf(buf, sizeof(buf), "elm.text.subtitle");
306 snprintf(buf, sizeof(buf), "%s", part);
308 EINA_INLIST_FOREACH(navi_it->text_list, pair)
310 if (!strcmp(buf, pair->part))
317 _item_content_set_hook(Elm_Object_Item *it,
319 Evas_Object *content)
321 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
323 Elm_Naviframe_Item *navi_it = (Elm_Naviframe_Item *) it;
326 if (!part || !strcmp("default", part))
328 _item_content_set(navi_it, content);
331 else if (!strcmp(part, "prev_btn"))
333 _title_prev_btn_set(navi_it, content, EINA_FALSE);
336 else if (!strcmp(part, "next_btn"))
338 _title_next_btn_set(navi_it, content);
341 else if (!strcmp(part, "icon"))
343 _title_icon_set(navi_it, content);
348 _title_content_set(navi_it, part, content);
352 _item_content_get_hook(const Elm_Object_Item *it, const char *part)
354 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
355 Elm_Naviframe_Content_Item_Pair *pair = NULL;
356 Elm_Naviframe_Item *navi_it = (Elm_Naviframe_Item *) it;
359 if (!part || !strcmp("default", part))
360 return navi_it->content;
361 else if (!strcmp(part, "prev_btn"))
362 return navi_it->title_prev_btn;
363 else if (!strcmp(part, "next_btn"))
364 return navi_it->title_next_btn;
365 else if (!strcmp(part, "icon"))
366 return navi_it->title_icon;
369 EINA_INLIST_FOREACH(navi_it->content_list, pair)
371 if (!strcmp(part, pair->part))
372 return pair->content;
378 _item_content_unset_hook(Elm_Object_Item *it, const char *part)
380 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
381 Elm_Naviframe_Item *navi_it = (Elm_Naviframe_Item *) it;
384 if (!part || !strcmp("default", part))
385 return _item_content_unset(navi_it);
386 else if (!strcmp(part, "prev_btn"))
387 return _title_prev_btn_unset(navi_it);
388 else if (!strcmp(part, "next_btn"))
389 return _title_next_btn_unset(navi_it);
390 else if (!strcmp(part, "icon"))
391 return _title_icon_unset(navi_it);
393 return _title_content_unset(navi_it, part);
397 _item_signal_emit_hook(Elm_Object_Item *it,
398 const char *emission,
401 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
402 Elm_Naviframe_Item *navi_it = (Elm_Naviframe_Item *) it;
403 edje_object_signal_emit(VIEW(navi_it), emission, source);
407 _item_title_visible_update(Elm_Naviframe_Item *navi_it)
409 if (navi_it->title_visible)
410 edje_object_signal_emit(VIEW(navi_it), "elm,state,title,show", "elm");
412 edje_object_signal_emit(VIEW(navi_it), "elm,state,title,hide", "elm");
416 _sizing_eval(Evas_Object *obj)
419 Elm_Naviframe_Item *it;
420 Evas_Coord x, y, w, h;
421 Evas_Coord minw = -1, minh = -1;
423 wd = elm_widget_data_get(obj);
426 EINA_INLIST_FOREACH(wd->stack, it)
428 evas_object_geometry_get(WIDGET(it), &x, &y, &w, &h);
429 evas_object_move(VIEW(it), x, y);
430 evas_object_resize(VIEW(it), w, h);
431 edje_object_size_min_calc(VIEW(it), &it->minw, &it->minh);
432 if (it->minw > minw) minw = it->minw;
433 if (it->minh > minh) minh = it->minh;
435 evas_object_size_hint_min_set(obj, minw, minh);
436 evas_object_size_hint_max_set(obj, -1, -1);
440 _move(void *data __UNUSED__,
443 void *event_info __UNUSED__)
449 _resize(void *data __UNUSED__,
452 void *event_info __UNUSED__)
458 _title_clicked(void *data,
459 Evas_Object *obj __UNUSED__,
460 const char *emission __UNUSED__,
461 const char *source __UNUSED__)
463 Elm_Naviframe_Item *it = data;
464 evas_object_smart_callback_call(WIDGET(it), SIG_TITLE_CLICKED, it);
468 _back_btn_clicked(void *data,
470 void *event_info __UNUSED__)
472 /* Since edje has the event queue, clicked event could be happend multiple times
473 on some heavy environment. This callback del will prevent those scenario and
474 guarantee only one clicked for it's own page. */
475 evas_object_smart_callback_del(obj, "clicked", _back_btn_clicked);
476 elm_naviframe_item_pop(data);
480 _back_btn_new(Evas_Object *obj)
484 btn = elm_button_add(obj);
485 if (!btn) return NULL;
486 evas_object_smart_callback_add(btn, "clicked", _back_btn_clicked, obj);
487 snprintf(buf, sizeof(buf), "naviframe/back_btn/%s", elm_widget_style_get(obj));
488 elm_object_style_set(btn, buf);
493 _title_content_del(void *data,
495 Evas_Object *obj __UNUSED__,
496 void *event_info __UNUSED__)
499 Elm_Naviframe_Content_Item_Pair *pair = data;
500 Elm_Naviframe_Item *it = pair->it;
501 snprintf(buf, sizeof(buf), "elm,state,%s,hide", pair->part);
502 edje_object_signal_emit(VIEW(it), buf, "elm");
503 it->content_list = eina_inlist_remove(it->content_list,
504 EINA_INLIST_GET(pair));
505 eina_stringshare_del(pair->part);
510 _title_prev_btn_del(void *data,
512 Evas_Object *obj __UNUSED__,
513 void *event_info __UNUSED__)
515 Elm_Naviframe_Item *it = data;
516 it->back_btn = EINA_FALSE;
517 it->title_prev_btn = NULL;
518 edje_object_signal_emit(VIEW(it), "elm,state,prev_btn,hide", "elm");
522 _title_next_btn_del(void *data,
524 Evas_Object *obj __UNUSED__,
525 void *event_info __UNUSED__)
527 Elm_Naviframe_Item *it = data;
528 it->title_next_btn = NULL;
529 edje_object_signal_emit(VIEW(it), "elm,state,next_btn,hide", "elm");
533 _title_icon_del(void *data,
535 Evas_Object *obj __UNUSED__,
536 void *event_info __UNUSED__)
538 Elm_Naviframe_Item *it = data;
539 it->title_icon = NULL;
540 edje_object_signal_emit(VIEW(it), "elm,state,icon,hide", "elm");
544 _item_content_del(void *data,
546 Evas_Object *obj __UNUSED__,
547 void *event_info __UNUSED__)
549 Elm_Naviframe_Item *it = data;
551 edje_object_signal_emit(VIEW(it), "elm,state,content,hide", "elm");
555 _title_content_set(Elm_Naviframe_Item *it,
557 Evas_Object *content)
560 Elm_Naviframe_Content_Item_Pair *pair = NULL;
562 EINA_INLIST_FOREACH(it->content_list, pair)
563 if (!strcmp(part, pair->part)) break;
567 if (!content) return;
568 pair = ELM_NEW(Elm_Naviframe_Content_Item_Pair);
571 ERR("Failed to allocate new content part of the item! : naviframe=%p", WIDGET(it));
575 eina_stringshare_replace(&pair->part, part);
576 it->content_list = eina_inlist_append(it->content_list,
577 EINA_INLIST_GET(pair));
579 if (pair->content && (pair->content != content))
581 evas_object_event_callback_del(pair->content,
584 evas_object_event_callback_del(pair->content,
585 EVAS_CALLBACK_CHANGED_SIZE_HINTS,
586 _changed_size_hints);
587 evas_object_del(pair->content);
588 snprintf(buf, sizeof(buf), "elm,state,%s,hide", part);
589 edje_object_signal_emit(VIEW(it), buf, "elm");
593 if (pair->content != content)
595 elm_widget_sub_object_add(WIDGET(it), content);
596 evas_object_event_callback_add(content,
600 evas_object_event_callback_add(content,
601 EVAS_CALLBACK_CHANGED_SIZE_HINTS,
604 pair->content = content;
606 edje_object_part_swallow(VIEW(it), part, content);
607 snprintf(buf, sizeof(buf), "elm,state,%s,show", part);
608 edje_object_signal_emit(VIEW(it), buf, "elm");
611 _sizing_eval(WIDGET(it));
615 _title_prev_btn_set(Elm_Naviframe_Item *it,
619 if (it->title_prev_btn == btn) return;
621 if (it->title_prev_btn)
622 evas_object_del(it->title_prev_btn);
624 it->title_prev_btn = btn;
627 elm_widget_sub_object_add(WIDGET(it), btn);
628 evas_object_event_callback_add(btn,
632 evas_object_event_callback_add(btn,
633 EVAS_CALLBACK_CHANGED_SIZE_HINTS,
636 edje_object_part_swallow(VIEW(it), "elm.swallow.prev_btn", btn);
637 edje_object_signal_emit(VIEW(it), "elm,state,prev_btn,show", "elm");
638 it->back_btn = back_btn;
640 _sizing_eval(WIDGET(it));
644 _title_next_btn_set(Elm_Naviframe_Item *it, Evas_Object *btn)
646 if (it->title_next_btn == btn) return;
648 if (it->title_next_btn)
649 evas_object_del(it->title_next_btn);
651 it->title_next_btn = btn;
654 elm_widget_sub_object_add(WIDGET(it), btn);
655 evas_object_event_callback_add(btn,
659 evas_object_event_callback_add(btn,
660 EVAS_CALLBACK_CHANGED_SIZE_HINTS,
663 edje_object_part_swallow(VIEW(it), "elm.swallow.next_btn", btn);
664 edje_object_signal_emit(VIEW(it), "elm,state,next_btn,show", "elm");
666 _sizing_eval(WIDGET(it));
670 _title_icon_set(Elm_Naviframe_Item *it, Evas_Object *icon)
672 if (it->title_icon == icon) return;
675 evas_object_del(it->title_icon);
677 it->title_icon = icon;
680 elm_widget_sub_object_add(WIDGET(it), icon);
681 evas_object_event_callback_add(icon,
685 evas_object_event_callback_add(icon,
686 EVAS_CALLBACK_CHANGED_SIZE_HINTS,
689 edje_object_part_swallow(VIEW(it), "elm.swallow.icon", icon);
690 edje_object_signal_emit(VIEW(it), "elm,state,icon,show", "elm");
692 _sizing_eval(WIDGET(it));
696 _item_content_unset(Elm_Naviframe_Item *it)
698 Evas_Object *content = it->content;
699 if (!content) return NULL;
701 elm_widget_sub_object_del(WIDGET(it), content);
702 edje_object_part_unswallow(VIEW(it), content);
703 edje_object_signal_emit(VIEW(it), "elm,state,content,hide", "elm");
704 evas_object_event_callback_del(content,
707 evas_object_event_callback_del(content,
708 EVAS_CALLBACK_CHANGED_SIZE_HINTS,
709 _changed_size_hints);
710 _sizing_eval(WIDGET(it));
717 _title_prev_btn_unset(Elm_Naviframe_Item *it)
719 Evas_Object *content = it->title_prev_btn;
720 if (!content) return NULL;
722 elm_widget_sub_object_del(WIDGET(it), content);
723 edje_object_part_unswallow(VIEW(it), content);
724 edje_object_signal_emit(VIEW(it), "elm,state,prev_btn,hide", "elm");
725 evas_object_event_callback_del(content,
727 _title_prev_btn_del);
728 evas_object_event_callback_del(content,
729 EVAS_CALLBACK_CHANGED_SIZE_HINTS,
730 _changed_size_hints);
731 _sizing_eval(WIDGET(it));
733 it->title_prev_btn = NULL;
738 _title_next_btn_unset(Elm_Naviframe_Item *it)
740 Evas_Object *content = it->title_next_btn;
741 if (!content) return NULL;
743 elm_widget_sub_object_del(WIDGET(it), content);
744 edje_object_part_unswallow(VIEW(it), content);
745 edje_object_signal_emit(VIEW(it), "elm,state,next_btn,hide", "elm");
746 evas_object_event_callback_del(content,
748 _title_next_btn_del);
749 evas_object_event_callback_del(content,
750 EVAS_CALLBACK_CHANGED_SIZE_HINTS,
751 _changed_size_hints);
752 _sizing_eval(WIDGET(it));
754 it->title_next_btn = NULL;
759 _title_icon_unset(Elm_Naviframe_Item *it)
761 Evas_Object *content = it->title_icon;
762 if (!content) return NULL;
764 elm_widget_sub_object_del(WIDGET(it), content);
765 edje_object_part_unswallow(VIEW(it), content);
766 edje_object_signal_emit(VIEW(it), "elm,state,icon,hide", "elm");
767 evas_object_event_callback_del(content,
770 evas_object_event_callback_del(content,
771 EVAS_CALLBACK_CHANGED_SIZE_HINTS,
772 _changed_size_hints);
773 _sizing_eval(WIDGET(it));
774 it->title_icon = NULL;
780 _title_content_unset(Elm_Naviframe_Item *it, const char *part)
782 Elm_Naviframe_Content_Item_Pair *pair = NULL;
784 Evas_Object *content = NULL;
786 EINA_INLIST_FOREACH(it->content_list, pair)
788 if (!strcmp(part, pair->part))
790 content = pair->content;
791 eina_stringshare_del(pair->part);
792 it->content_list = eina_inlist_remove(it->content_list,
793 EINA_INLIST_GET(pair));
799 if (!content) return NULL;
801 elm_widget_sub_object_del(WIDGET(it), content);
802 edje_object_part_unswallow(VIEW(it), content);
803 snprintf(buf, sizeof(buf), "elm,state,%s,hide", part);
804 edje_object_signal_emit(VIEW(it), buf, "elm");
805 evas_object_event_callback_del(content,
808 evas_object_event_callback_del(content,
809 EVAS_CALLBACK_CHANGED_SIZE_HINTS,
810 _changed_size_hints);
811 _sizing_eval(WIDGET(it));
818 _item_del(Elm_Naviframe_Item *it)
821 Elm_Naviframe_Content_Item_Pair *content_pair;
822 Elm_Naviframe_Text_Item_Pair *text_pair;
826 wd = elm_widget_data_get(WIDGET(it));
829 if (it->title_prev_btn)
830 evas_object_del(it->title_prev_btn);
831 if (it->title_next_btn)
832 evas_object_del(it->title_next_btn);
834 evas_object_del(it->title_icon);
835 if ((it->content) && (!wd->preserve))
836 evas_object_del(it->content);
838 while (it->content_list)
840 content_pair = EINA_INLIST_CONTAINER_GET(it->content_list,
841 Elm_Naviframe_Content_Item_Pair);
842 evas_object_event_callback_del(content_pair->content,
845 evas_object_event_callback_del(content_pair->content,
846 EVAS_CALLBACK_CHANGED_SIZE_HINTS,
847 _changed_size_hints);
848 evas_object_del(content_pair->content);
849 eina_stringshare_del(content_pair->part);
850 it->content_list = eina_inlist_remove(it->content_list,
855 while (it->text_list)
857 text_pair = EINA_INLIST_CONTAINER_GET(it->text_list,
858 Elm_Naviframe_Text_Item_Pair);
859 eina_stringshare_del(text_pair->part);
860 eina_stringshare_del(text_pair->text);
861 it->text_list = eina_inlist_remove(it->text_list,
866 eina_stringshare_del(it->style);
868 elm_widget_item_del(it);
872 _pushed_finished(void *data,
873 Evas_Object *obj __UNUSED__,
874 const char *emission __UNUSED__,
875 const char *source __UNUSED__)
878 Elm_Naviframe_Item *it = data;
881 wd = elm_widget_data_get(WIDGET(it));
884 evas_object_hide(VIEW(it));
885 evas_object_smart_callback_call(WIDGET(it),
888 if (wd->freeze_events)
889 evas_object_freeze_events_set(VIEW(it), EINA_FALSE);
893 _popped_finished(void *data,
894 Evas_Object *obj __UNUSED__,
895 const char *emission __UNUSED__,
896 const char *source __UNUSED__)
898 Elm_Naviframe_Item *it = data;
900 evas_object_smart_callback_call(WIDGET(it),
907 _show_finished(void *data,
908 Evas_Object *obj __UNUSED__,
909 const char *emission __UNUSED__,
910 const char *source __UNUSED__)
912 Elm_Naviframe_Item *it;
917 wd = elm_widget_data_get(WIDGET(it));
920 evas_object_smart_callback_call(WIDGET(it),
921 SIG_TRANSITION_FINISHED,
923 if (wd->freeze_events)
924 evas_object_freeze_events_set(VIEW(it), EINA_FALSE);
928 _changed_size_hints(void *data,
930 Evas_Object *obj __UNUSED__,
931 void *event_info __UNUSED__)
937 _item_content_set(Elm_Naviframe_Item *navi_it, Evas_Object *content)
939 if (navi_it->content == content) return;
940 if (navi_it->content) evas_object_del(navi_it->content);
941 elm_widget_sub_object_add(WIDGET(navi_it), content);
942 edje_object_part_swallow(VIEW(navi_it),
943 "elm.swallow.content",
946 edje_object_signal_emit(VIEW(navi_it),
947 "elm,state,content,show",
950 edje_object_signal_emit(VIEW(navi_it),
951 "elm,state,content,hide",
953 evas_object_event_callback_add(content,
957 evas_object_event_callback_add(content,
958 EVAS_CALLBACK_CHANGED_SIZE_HINTS,
961 navi_it->content = content;
962 _sizing_eval(WIDGET(navi_it));
965 //FIXME: need to handle if this function is called while transition
967 _item_style_set(Elm_Naviframe_Item *navi_it, const char *item_style)
969 Elm_Naviframe_Content_Item_Pair *content_pair;
970 Elm_Naviframe_Text_Item_Pair *text_pair;
977 sprintf(buf, "item/basic");
978 eina_stringshare_replace(&navi_it->style, "basic");
982 if (strlen(item_style) > sizeof(buf))
983 WRN("too much long style name! : naviframe=%p", WIDGET(navi_it));
984 sprintf(buf, "item/%s", item_style);
985 eina_stringshare_replace(&navi_it->style, item_style);
987 _elm_theme_object_set(WIDGET(navi_it),
991 elm_widget_style_get(WIDGET(navi_it)));
993 EINA_INLIST_FOREACH(navi_it->text_list, text_pair)
994 _item_text_set_hook((Elm_Object_Item *) navi_it,
998 EINA_INLIST_FOREACH(navi_it->content_list, content_pair)
999 _item_content_set_hook((Elm_Object_Item *) navi_it,
1001 content_pair->content);
1003 if (navi_it->content)
1005 edje_object_part_swallow(VIEW(navi_it),
1006 "elm.swallow.content",
1008 edje_object_signal_emit(VIEW(navi_it),
1009 "elm,state,content,show",
1014 if (navi_it->title_prev_btn)
1016 edje_object_part_swallow(VIEW(navi_it),
1017 "elm.swallow.prev_btn",
1018 navi_it->title_prev_btn);
1019 edje_object_signal_emit(VIEW(navi_it),
1020 "elm,state,prev_btn,show",
1025 if (navi_it->title_next_btn)
1027 edje_object_part_swallow(VIEW(navi_it),
1028 "elm.swallow.next_btn",
1029 navi_it->title_next_btn);
1030 edje_object_signal_emit(VIEW(navi_it),
1031 "elm,state,next_btn,show",
1035 navi_it->title_visible = EINA_TRUE;
1036 _sizing_eval(WIDGET(navi_it));
1038 wd = elm_widget_data_get(WIDGET(navi_it));
1041 if (wd->freeze_events)
1042 evas_object_freeze_events_set(VIEW(navi_it), EINA_FALSE);
1045 static Elm_Naviframe_Item *
1046 _item_new(Evas_Object *obj,
1047 const char *title_label,
1048 Evas_Object *prev_btn,
1049 Evas_Object *next_btn,
1050 Evas_Object *content,
1051 const char *item_style)
1053 Widget_Data *wd = elm_widget_data_get(obj);
1056 Elm_Naviframe_Item *it = elm_widget_item_new(obj, Elm_Naviframe_Item);
1059 ERR("Failed to allocate new item! : naviframe=%p", obj);
1063 elm_widget_item_text_set_hook_set(it, _item_text_set_hook);
1064 elm_widget_item_text_get_hook_set(it, _item_text_get_hook);
1065 elm_widget_item_content_set_hook_set(it, _item_content_set_hook);
1066 elm_widget_item_content_get_hook_set(it, _item_content_get_hook);
1067 elm_widget_item_content_unset_hook_set(it, _item_content_unset_hook);
1068 elm_widget_item_signal_emit_hook_set(it, _item_signal_emit_hook);
1071 VIEW(it) = edje_object_add(evas_object_evas_get(obj));
1072 edje_object_mirrored_set(VIEW(it), elm_widget_mirrored_get(obj));
1073 evas_object_smart_member_add(VIEW(it), wd->base);
1074 elm_widget_sub_object_add(obj, VIEW(it));
1075 edje_object_signal_callback_add(VIEW(it),
1076 "elm,action,show,finished",
1078 _show_finished, it);
1079 edje_object_signal_callback_add(VIEW(it),
1080 "elm,action,pushed,finished",
1082 _pushed_finished, it);
1083 edje_object_signal_callback_add(VIEW(it),
1084 "elm,action,popped,finished",
1086 _popped_finished, it);
1087 edje_object_signal_callback_add(VIEW(it),
1088 "elm,action,title,clicked",
1090 _title_clicked, it);
1092 _item_style_set(it, item_style);
1093 _item_text_set_hook((Elm_Object_Item *) it, "elm.text.title", title_label);
1096 if ((!prev_btn) && wd->auto_pushed && eina_inlist_count(wd->stack))
1098 prev_btn = _back_btn_new(obj);
1099 _title_prev_btn_set(it, prev_btn, EINA_TRUE);
1102 _title_prev_btn_set(it, prev_btn, EINA_FALSE);
1104 _title_next_btn_set(it, next_btn);
1105 _item_content_set(it, content);
1106 it->title_visible = EINA_TRUE;
1111 elm_naviframe_add(Evas_Object *parent)
1117 ELM_WIDGET_STANDARD_SETUP(wd, Widget_Data, parent, e, obj, NULL);
1118 ELM_SET_WIDTYPE(widtype, "naviframe");
1119 elm_widget_type_set(obj, "naviframe");
1120 elm_widget_sub_object_add(parent, obj);
1121 elm_widget_data_set(obj, wd);
1122 elm_widget_del_hook_set(obj, _del_hook);
1123 elm_widget_disable_hook_set(obj, _disable_hook);
1124 elm_widget_theme_hook_set(obj, _theme_hook);
1125 elm_widget_signal_emit_hook_set(obj, _emit_hook);
1128 wd->base = edje_object_add(e);
1129 edje_object_mirrored_set(wd->base, elm_widget_mirrored_get(obj));
1130 elm_widget_resize_object_set(obj, wd->base);
1131 _elm_theme_object_set(obj, wd->base, "naviframe", "base", "default");
1133 evas_object_event_callback_add(obj, EVAS_CALLBACK_MOVE, _move, obj);
1134 evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE, _resize, obj);
1135 evas_object_smart_callbacks_descriptions_set(obj, _signals);
1137 wd->auto_pushed = EINA_TRUE;
1138 wd->freeze_events = EINA_TRUE;
1143 EAPI Elm_Object_Item *
1144 elm_naviframe_item_push(Evas_Object *obj,
1145 const char *title_label,
1146 Evas_Object *prev_btn,
1147 Evas_Object *next_btn,
1148 Evas_Object *content,
1149 const char *item_style)
1151 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1153 Elm_Naviframe_Item *prev_it, *it;
1155 wd = elm_widget_data_get(obj);
1156 if (!wd) return NULL;
1158 it = _item_new(obj, title_label, prev_btn, next_btn, content, item_style);
1159 if (!it) return NULL;
1161 evas_object_show(VIEW(it));
1163 prev_it = (Elm_Naviframe_Item *) elm_naviframe_top_item_get(obj);
1166 if (wd->freeze_events)
1168 evas_object_freeze_events_set(VIEW(it), EINA_TRUE);
1169 evas_object_freeze_events_set(VIEW(prev_it), EINA_TRUE);
1171 edje_object_signal_emit(VIEW(prev_it),
1172 "elm,state,cur,pushed",
1174 edje_object_signal_emit(VIEW(it),
1175 "elm,state,new,pushed",
1177 edje_object_message_signal_process(VIEW(prev_it));
1178 edje_object_message_signal_process(VIEW(it));
1180 wd->stack = eina_inlist_append(wd->stack, EINA_INLIST_GET(it));
1182 return (Elm_Object_Item *) it;
1185 EAPI Elm_Object_Item *
1186 elm_naviframe_item_insert_before(Elm_Object_Item *before,
1187 const char *title_label,
1188 Evas_Object *prev_btn,
1189 Evas_Object *next_btn,
1190 Evas_Object *content,
1191 const char *item_style)
1193 ELM_OBJ_ITEM_CHECK_OR_RETURN(before, NULL);
1194 Elm_Naviframe_Item *it;
1197 wd = elm_widget_data_get(WIDGET(before));
1198 if (!wd) return NULL;
1200 it = _item_new(WIDGET(before), title_label, prev_btn, next_btn, content,
1202 if (!it) return NULL;
1205 eina_inlist_prepend_relative(wd->stack, EINA_INLIST_GET(it),
1206 EINA_INLIST_GET(((Elm_Naviframe_Item *) before)));
1207 _sizing_eval(WIDGET(before));
1208 return (Elm_Object_Item *) it;
1211 EAPI Elm_Object_Item *
1212 elm_naviframe_item_insert_after(Elm_Object_Item *after,
1213 const char *title_label,
1214 Evas_Object *prev_btn,
1215 Evas_Object *next_btn,
1216 Evas_Object *content,
1217 const char *item_style)
1219 ELM_OBJ_ITEM_CHECK_OR_RETURN(after, NULL);
1220 Elm_Naviframe_Item *it;
1223 wd = elm_widget_data_get(WIDGET(after));
1224 if (!wd) return NULL;
1226 it = _item_new(WIDGET(after), title_label, prev_btn, next_btn, content,
1228 if (!it) return NULL;
1230 if (elm_naviframe_top_item_get(WIDGET(after)) == after)
1232 evas_object_hide(VIEW(after));
1233 evas_object_show(VIEW(it));
1236 eina_inlist_append_relative(wd->stack, EINA_INLIST_GET(it),
1237 EINA_INLIST_GET(((Elm_Naviframe_Item *) after)));
1238 _sizing_eval(WIDGET(after));
1239 return (Elm_Object_Item *) it;
1243 elm_naviframe_item_pop(Evas_Object *obj)
1245 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1246 Elm_Naviframe_Item *it, *prev_it = NULL;
1248 Evas_Object *content = NULL;
1250 wd = elm_widget_data_get(obj);
1251 if (!wd) return NULL;
1253 it = (Elm_Naviframe_Item *) elm_naviframe_top_item_get(obj);
1254 if (!it) return NULL;
1255 elm_widget_tree_unfocusable_set(it->content, EINA_TRUE);
1257 content = it->content;
1259 if (wd->stack->last->prev)
1260 prev_it = EINA_INLIST_CONTAINER_GET(wd->stack->last->prev,
1261 Elm_Naviframe_Item);
1262 wd->stack = eina_inlist_remove(wd->stack, EINA_INLIST_GET(it));
1265 if (wd->freeze_events)
1267 evas_object_freeze_events_set(VIEW(it), EINA_TRUE);
1268 evas_object_freeze_events_set(VIEW(prev_it), EINA_TRUE);
1270 edje_object_signal_emit(VIEW(it), "elm,state,cur,popped", "elm");
1271 evas_object_show(VIEW(prev_it));
1272 evas_object_raise(VIEW(prev_it));
1273 edje_object_signal_emit(VIEW(prev_it),
1274 "elm,state,prev,popped",
1276 edje_object_message_signal_process(VIEW(it));
1277 edje_object_message_signal_process(VIEW(prev_it));
1286 elm_naviframe_item_pop_to(Elm_Object_Item *it)
1288 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
1289 Elm_Naviframe_Item *navi_it;
1291 Eina_Inlist *l, *prev_l;
1293 navi_it = (Elm_Naviframe_Item *) it;
1294 wd = elm_widget_data_get(WIDGET(navi_it));
1297 if (it == elm_naviframe_top_item_get(WIDGET(navi_it))) return;
1299 l = wd->stack->last->prev;
1303 if (EINA_INLIST_CONTAINER_GET(l, Elm_Naviframe_Item) ==
1304 ((Elm_Naviframe_Item *) it)) break;
1306 wd->stack = eina_inlist_remove(wd->stack, l);
1307 _item_del(EINA_INLIST_CONTAINER_GET(l, Elm_Naviframe_Item));
1310 elm_naviframe_item_pop(WIDGET(navi_it));
1314 elm_naviframe_item_promote(Elm_Object_Item *it)
1316 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
1317 Elm_Naviframe_Item *navi_it;
1318 Elm_Naviframe_Item *prev_it;
1321 navi_it = (Elm_Naviframe_Item *) it;
1322 wd = elm_widget_data_get(navi_it->base.widget);
1325 if (it == elm_naviframe_top_item_get(navi_it->base.widget)) return;
1326 wd->stack = eina_inlist_demote(wd->stack, EINA_INLIST_GET(navi_it));
1327 prev_it = EINA_INLIST_CONTAINER_GET(wd->stack->last->prev,
1328 Elm_Naviframe_Item);
1329 if (wd->freeze_events)
1331 evas_object_freeze_events_set(VIEW(it), EINA_TRUE);
1332 evas_object_freeze_events_set(VIEW(prev_it), EINA_TRUE);
1334 edje_object_signal_emit(VIEW(prev_it),
1335 "elm,state,cur,pushed",
1337 evas_object_show(VIEW(navi_it));
1338 evas_object_raise(VIEW(navi_it));
1339 edje_object_signal_emit(VIEW(navi_it),
1340 "elm,state,new,pushed",
1342 edje_object_message_signal_process(VIEW(prev_it));
1343 edje_object_message_signal_process(VIEW(navi_it));
1347 elm_naviframe_item_del(Elm_Object_Item *it)
1349 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
1350 Elm_Naviframe_Item *navi_it;
1353 navi_it =(Elm_Naviframe_Item *) it;
1354 wd = elm_widget_data_get(WIDGET(navi_it));
1357 if (it == elm_naviframe_top_item_get(WIDGET(navi_it)))
1359 wd->stack = eina_inlist_remove(wd->stack, EINA_INLIST_GET(navi_it));
1361 navi_it = EINA_INLIST_CONTAINER_GET(wd->stack->last,
1362 Elm_Naviframe_Item);
1363 evas_object_show(VIEW(navi_it));
1364 evas_object_raise(VIEW(navi_it));
1365 edje_object_signal_emit(VIEW(navi_it), "elm,state,visible", "elm");
1369 wd->stack = eina_inlist_remove(wd->stack, EINA_INLIST_GET(navi_it));
1375 elm_naviframe_content_preserve_on_pop_set(Evas_Object *obj, Eina_Bool preserve)
1377 ELM_CHECK_WIDTYPE(obj, widtype);
1378 Widget_Data *wd = elm_widget_data_get(obj);
1380 wd->preserve = !!preserve;
1384 elm_naviframe_content_preserve_on_pop_get(const Evas_Object *obj)
1386 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1387 Widget_Data *wd = elm_widget_data_get(obj);
1388 if (!wd) return EINA_FALSE;
1389 return wd->preserve;
1392 EAPI Elm_Object_Item*
1393 elm_naviframe_top_item_get(const Evas_Object *obj)
1395 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1396 Widget_Data *wd = elm_widget_data_get(obj);
1397 if ((!wd) || (!wd->stack)) return NULL;
1398 return (Elm_Object_Item *) (EINA_INLIST_CONTAINER_GET(wd->stack->last,
1399 Elm_Naviframe_Item));
1402 EAPI Elm_Object_Item*
1403 elm_naviframe_bottom_item_get(const Evas_Object *obj)
1405 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1406 Widget_Data *wd = elm_widget_data_get(obj);
1407 if ((!wd) || (!wd->stack)) return NULL;
1408 return (Elm_Object_Item *) (EINA_INLIST_CONTAINER_GET(wd->stack,
1409 Elm_Naviframe_Item));
1413 elm_naviframe_item_style_set(Elm_Object_Item *it, const char *item_style)
1415 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
1416 Elm_Naviframe_Item *navi_it = (Elm_Naviframe_Item *) it;
1418 //Return if new style is exsiting one.
1420 if (!strcmp(item_style, navi_it->style)) return;
1423 if (!strcmp("basic", navi_it->style)) return;
1425 _item_style_set(navi_it, item_style);
1429 elm_naviframe_item_style_get(const Elm_Object_Item *it)
1431 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
1432 Elm_Naviframe_Item *navi_it = (Elm_Naviframe_Item *) it;
1433 return navi_it->style;
1437 elm_naviframe_item_title_visible_set(Elm_Object_Item *it, Eina_Bool visible)
1439 ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
1440 Elm_Naviframe_Item *navi_it = (Elm_Naviframe_Item *) it;
1442 visible = !!visible;
1443 if (navi_it->title_visible == visible) return;
1445 navi_it->title_visible = visible;
1446 _item_title_visible_update(navi_it);
1450 elm_naviframe_item_title_visible_get(const Elm_Object_Item *it)
1452 ELM_OBJ_ITEM_CHECK_OR_RETURN(it, EINA_FALSE);
1453 Elm_Naviframe_Item *navi_it = (Elm_Naviframe_Item *) it;
1454 return navi_it->title_visible;
1458 elm_naviframe_prev_btn_auto_pushed_set(Evas_Object *obj, Eina_Bool auto_pushed)
1460 ELM_CHECK_WIDTYPE(obj, widtype);
1461 Widget_Data *wd = elm_widget_data_get(obj);
1463 wd->auto_pushed = !!auto_pushed;
1467 elm_naviframe_prev_btn_auto_pushed_get(const Evas_Object *obj)
1469 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1470 Widget_Data *wd = elm_widget_data_get(obj);
1471 if (!wd) return EINA_FALSE;
1472 return wd->auto_pushed;
1476 elm_naviframe_items_get(const Evas_Object *obj)
1478 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1479 Widget_Data *wd = elm_widget_data_get(obj);
1480 if (!wd) return NULL;
1485 elm_naviframe_event_enabled_set(Evas_Object *obj, Eina_Bool enabled)
1487 ELM_CHECK_WIDTYPE(obj, widtype);
1488 Widget_Data *wd = elm_widget_data_get(obj);
1490 enabled = !!enabled;
1491 if (wd->freeze_events == !enabled) return;
1492 wd->freeze_events = !enabled;
1496 elm_naviframe_event_enabled_get(const Evas_Object *obj)
1498 ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
1499 Widget_Data *wd = elm_widget_data_get(obj);
1500 if (!wd) return EINA_FALSE;
1501 return !wd->freeze_events;