1 #include <Elementary.h>
5 * @defgroup NavigationBar NavigationBar
8 * The Navigationbar is an object that allows flipping (with animation) between 1 or
9 * more of objects, much like a stack of windows within the window. It also displays title
10 * area above all the pages consisting of title,function buttons.
12 * Objects can be pushed or popped from the stack.
13 * Pushes and pops will animate (and a pop will delete the object once the
14 * animation is finished). Objects are pushed to the top with
15 * elm_navigationbar_push() and when the top item is no longer
16 * wanted, simply pop it with elm_navigationbar_pop() and it will also be
17 * deleted. You can query which objects are the top and bottom with
18 * elm_navigationbar_content_bottom_get() and elm_navigationbar_content_top_get().
21 typedef struct _Widget_Data Widget_Data;
22 typedef struct _Item Item;
23 typedef struct _Transit_Cb_Data Transit_Cb_Data;
39 Evas_Object *title_obj;
40 Eina_List *title_list;
44 Evas_Object *back_btn;
52 struct _Transit_Cb_Data
60 static const char *widtype = NULL;
62 static void _del_hook(Evas_Object *obj);
63 static void _theme_hook(Evas_Object *obj);
64 static void _sizing_eval(Evas_Object *obj);
65 static void _resize(void *data, Evas *e, Evas_Object *obj, void *event_info);
66 static void _item_sizing_eval(Item *it);
67 static void _delete_item(Item *it);
68 static void _back_button_clicked(void *data, Evas_Object *obj, void *event_info);
69 static int _set_button_width(Evas_Object *obj);
70 static Eina_Bool _button_set(Evas_Object *obj, Evas_Object *prev_btn, Evas_Object *new_btn, Eina_Bool back_btn);
71 static Evas_Object *_multiple_object_set(Evas_Object *obj, Evas_Object *sub_obj, Eina_List *list, int width);
72 static Item *_check_item_is_added(Evas_Object *obj, Evas_Object *content);
73 static void _transition_complete_cb(void *data);
74 static void _elm_navigationbar_back_button_set(Evas_Object *obj, Evas_Object *content, Evas_Object *button);
75 static Evas_Object *_elm_navigationbar_back_button_get(Evas_Object *obj, Evas_Object *content);
76 static void _elm_navigationbar_function_button1_set(Evas_Object *obj, Evas_Object *content, Evas_Object *button);
77 static Evas_Object *_elm_navigationbar_function_button1_get(Evas_Object *obj, Evas_Object *content);
78 static void _elm_navigationbar_function_button2_set(Evas_Object *obj, Evas_Object *content, Evas_Object *button);
79 static Evas_Object *_elm_navigationbar_function_button2_get(Evas_Object *obj, Evas_Object *content);
80 static void _elm_navigationbar_function_button3_set(Evas_Object *obj, Evas_Object *content, Evas_Object *button);
81 static Evas_Object *_elm_navigationbar_function_button3_get(Evas_Object *obj, Evas_Object *content);
84 _del_hook(Evas_Object *obj)
86 Widget_Data *wd = elm_widget_data_get(obj);
90 EINA_LIST_FOREACH(wd->stack, list, it)
92 eina_list_free(wd->stack);
97 _theme_hook(Evas_Object *obj)
99 Widget_Data *wd = elm_widget_data_get(obj);
100 Eina_List *list = NULL;
106 _elm_theme_object_set(obj, wd->base, "navigationbar", "base", elm_widget_style_get(obj));
107 edje_object_scale_set(wd->base, elm_widget_scale_get(obj) * _elm_config->scale);
108 EINA_LIST_FOREACH(wd->stack, list, it)
112 snprintf(buf_fn, sizeof(buf_fn), "navigationbar_functionbutton/%s", elm_widget_style_get(obj));
113 elm_object_style_set(it->fn_btn1, buf_fn);
117 snprintf(buf_fn, sizeof(buf_fn), "navigationbar_functionbutton/%s", elm_widget_style_get(obj));
118 elm_object_style_set(it->fn_btn2, buf_fn);
122 snprintf(buf_fn, sizeof(buf_fn), "navigationbar_functionbutton/%s", elm_widget_style_get(obj));
123 elm_object_style_set(it->fn_btn3, buf_fn);
125 snprintf(buf_bk, sizeof(buf_bk), "navigationbar_backbutton/%s", elm_widget_style_get(obj));
126 elm_object_style_set(it->back_btn, buf_bk);
128 edje_object_message_signal_process(wd->base);
133 _delete_item(Item *it)
137 Evas_Object *list_obj;
139 evas_object_del(it->back_btn);
140 elm_object_unfocus(it->fn_btn1);
141 evas_object_del(it->fn_btn1);
142 elm_object_unfocus(it->fn_btn2);
143 evas_object_del(it->fn_btn2);
144 elm_object_unfocus(it->fn_btn3);
145 evas_object_del(it->fn_btn3);
147 eina_stringshare_del(it->title);
149 eina_stringshare_del(it->subtitle);
150 EINA_LIST_FOREACH(it->title_list, ll, list_obj)
151 evas_object_del(list_obj);
152 eina_list_free(it->title_list);
157 _sizing_eval(Evas_Object *obj)
159 Widget_Data *wd = elm_widget_data_get(obj);
160 Evas_Coord minw = -1, minh = -1;
161 Evas_Coord w = -1, h = -1;
164 edje_object_size_min_calc(wd->base, &minw, &minh);
165 evas_object_size_hint_min_get(obj, &w, &h);
166 if (w > minw) minw = w;
167 if (h > minw) minh = h;
169 evas_object_size_hint_min_set(obj, minw, minh);
170 evas_object_size_hint_max_set(obj, -1, -1);
172 list = eina_list_last(wd->stack);
175 Item *it = list->data;
176 _item_sizing_eval(it);
181 _item_sizing_eval(Item *it)
183 Widget_Data *wd = elm_widget_data_get(it->obj);
184 Evas_Coord pad, height, minw, w;
189 edje_object_size_min_calc(wd->base, &minw, NULL);
190 evas_object_geometry_get(wd->base, NULL, NULL, &w, NULL);
191 if (w < minw) w = minw;
192 edje_object_part_geometry_get(wd->base, "elm.rect.pad1", NULL, NULL, &pad, NULL);
193 edje_object_part_geometry_get(wd->base, "elm.swallow.title", NULL, NULL, NULL, &height);
197 it->fn_btn1_w = _set_button_width(it->fn_btn1);
200 else if (it->back_btn)
202 it->fn_btn1_w = _set_button_width(it->back_btn);
207 it->fn_btn2_w = _set_button_width(it->fn_btn2);
212 it->fn_btn3_w = _set_button_width(it->fn_btn3);
217 it->title_w = _set_button_width(it->title_obj);
218 it->title_obj = _multiple_object_set(it->obj, it->title_obj, it->title_list, it->title_w);
219 evas_object_resize(it->title_obj, it->title_w, height);
220 evas_object_size_hint_min_set(it->title_obj, it->title_w, height);
225 _resize(void *data, Evas *e, Evas_Object *obj, void *event_info)
231 _transition_complete_cb(void *data)
233 Transit_Cb_Data *cb = data;
235 Evas_Object *navi_bar = NULL;
236 Evas_Object *content = NULL;
237 Widget_Data *wd = NULL;
238 Item *prev_it = cb->prev_it;
243 navi_bar = prev_it->obj;
249 wd = elm_widget_data_get(navi_bar);
250 if (cb->pop && prev_it)
253 ll = eina_list_last(wd->stack);
254 if (ll->data == prev_it)
256 _delete_item(prev_it);
257 wd->stack = eina_list_remove_list(wd->stack, ll);
262 evas_object_hide(prev_it->fn_btn1);
263 evas_object_hide(prev_it->back_btn);
264 evas_object_hide(prev_it->title_obj);
265 evas_object_hide(prev_it->fn_btn2);
266 evas_object_hide(prev_it->fn_btn3);
268 if ((it) && (!wd->hidden))
270 edje_object_part_text_set(wd->base, "elm.text", it->title);
275 edje_object_signal_emit(wd->base, "elm,action,pop", "elm");
279 edje_object_signal_emit(wd->base, "elm,action,push", "elm");
281 edje_object_signal_emit(wd->base, "elm,state,rect,enabled", "elm");
285 edje_object_part_swallow(wd->base, "elm.swallow.title", it->title_obj);
286 edje_object_signal_emit(wd->base, "elm,state,retract,title", "elm");
290 edje_object_signal_emit(wd->base, "elm,state,retract,title", "elm");
294 edje_object_part_text_set(wd->base, "elm.text.sub", it->subtitle);
297 edje_object_part_text_set(wd->base, "elm.text.sub", NULL);
300 edje_object_signal_emit(wd->base, "elm,state,item,add,leftpad", "elm");
301 edje_object_part_swallow(wd->base, "elm.swallow.btn1", it->fn_btn1);
303 else if (it->back_btn)
305 edje_object_signal_emit(wd->base, "elm,state,item,add,leftpad", "elm");
306 edje_object_part_swallow(wd->base, "elm.swallow.btn1", it->back_btn);
309 edje_object_signal_emit(wd->base, "elm,state,item,reset,leftpad", "elm");
312 edje_object_signal_emit(wd->base, "elm,state,item,add,rightpad", "elm");
313 edje_object_part_swallow(wd->base, "elm.swallow.btn2", it->fn_btn2);
316 edje_object_signal_emit(wd->base, "elm,state,item,reset,rightpad", "elm");
319 edje_object_signal_emit(wd->base, "elm,state,item,add,rightpad2", "elm");
320 edje_object_signal_emit(wd->base, "elm,state,item,fn_btn3_set", "elm");
321 edje_object_part_swallow(wd->base, "elm.swallow.btn3", it->fn_btn3);
324 edje_object_signal_emit(wd->base, "elm,state,item,reset,rightpad2", "elm");
325 if ((it->title_obj) && (it->title))
327 edje_object_signal_emit(wd->base, "elm,state,extend,title", "elm");
329 content = it->content;
331 edje_object_message_signal_process(wd->base);
335 _back_button_clicked(void *data, Evas_Object *obj, void *event_info)
339 elm_navigationbar_pop(it->obj);
343 _hide_finished(void *data, Evas_Object *obj, void *event_info)
345 Evas_Object *navi_bar = data;
346 Widget_Data *wd = elm_widget_data_get(navi_bar);
347 wd->popping = EINA_FALSE;
348 evas_object_smart_callback_call(navi_bar, "hide,finished", event_info);
349 edje_object_signal_emit(wd->base, "elm,state,rect,disabled", "elm");
353 _set_button_width(Evas_Object *obj)
355 Evas_Coord minw = -1, minh = -1, maxw= -1, maxh = -1;
356 Evas_Coord w = 0, h = 0;
358 evas_object_size_hint_min_get(obj, &minw, &minh);
359 evas_object_size_hint_max_get(obj, &maxw, &maxh);
360 evas_object_geometry_get(obj, NULL, NULL, &w, &h);
361 if (w < minw) w = minw;
362 if (h < minh) h = minh;
363 if ((maxw >= 0) && (w > maxw)) w = maxw;
364 if ((maxh >= 0) && (h > maxh)) h = maxh;
365 evas_object_resize(obj, w, h);
370 _button_set(Evas_Object *obj, Evas_Object *prev_btn, Evas_Object *new_btn, Eina_Bool back_btn)
373 Eina_Bool changed = EINA_FALSE;
377 evas_object_del(prev_btn);
384 snprintf(buf, sizeof(buf), "navigationbar_backbutton/%s", elm_widget_style_get(obj));
385 elm_object_style_set(new_btn, buf);
389 snprintf(buf, sizeof(buf), "navigationbar_functionbutton/%s", elm_widget_style_get(obj));
390 elm_object_style_set(new_btn, buf);
392 elm_widget_sub_object_add(obj, new_btn);
399 _check_item_is_added(Evas_Object *obj, Evas_Object *content)
401 Widget_Data *wd = elm_widget_data_get(obj);
405 EINA_LIST_FOREACH(wd->stack, ll, it)
407 if (it->content == content)
416 _multiple_object_set(Evas_Object *obj, Evas_Object *sub_obj, Eina_List *list, int width)
418 Widget_Data *wd = elm_widget_data_get(obj);
420 Evas_Object *new_obj, *list_obj;
421 Evas_Coord pad, height;
426 edje_object_part_geometry_get(wd->base, "elm.rect.pad1", NULL, NULL, &pad, NULL);
427 edje_object_part_geometry_get(wd->base, "elm.swallow.title", NULL, NULL, NULL, &height);
430 new_obj = elm_layout_add(obj);
431 elm_widget_sub_object_add(obj, new_obj);
432 elm_layout_theme_set(new_obj, "navigationbar", "title", elm_widget_style_get(obj));
436 count = eina_list_count(list);
437 EINA_LIST_FOREACH(list, ll, list_obj)
439 evas_object_resize(list_obj, (width-(count-1)*pad)/count, height);
440 evas_object_size_hint_min_set(list_obj, (width-(count-1)*pad)/count, height);
441 memset(buf, 0, sizeof(buf));
442 sprintf(buf, "elm,state,item,add,%d", num);
443 edje_object_signal_emit(elm_layout_edje_get(new_obj), buf, "elm");
444 memset(buf, 0, sizeof(buf));
445 sprintf(buf, "elm.swallow.title%d", num++);
446 elm_layout_content_set(new_obj, buf, list_obj);
452 _multiple_object_unset(Item *it, Eina_List **list)
454 Evas_Object *list_obj = NULL;
456 Evas_Object *temp_obj;
461 EINA_LIST_FOREACH (it->title_list, l, list_obj)
463 memset(buf, 0, sizeof(buf));
464 sprintf(buf, "elm.swallow.title%d", num++);
465 temp_obj = elm_layout_content_unset(it->title_obj, buf);
466 *list = eina_list_append(*list, temp_obj);
467 evas_object_hide(temp_obj);
469 eina_list_free(it->title_list);
470 it->title_list = NULL;
476 * Add a new navigationbar to the parent
478 * @param[in] parent The parent object
479 * @return The new object or NULL if it cannot be created
481 * @ingroup NavigationBar
484 elm_navigationbar_add(Evas_Object *parent)
490 wd = ELM_NEW(Widget_Data);
491 e = evas_object_evas_get(parent);
492 obj = elm_widget_add(e);
493 ELM_SET_WIDTYPE(widtype, "navigationbar");
494 elm_widget_type_set(obj, "navigationbar");
495 elm_widget_sub_object_add(parent, obj);
496 elm_widget_data_set(obj, wd);
497 elm_widget_del_hook_set(obj, _del_hook);
498 elm_widget_theme_hook_set(obj, _theme_hook);
500 wd->base = edje_object_add(e);
501 _elm_theme_object_set(obj, wd->base, "navigationbar", "base", "default");
502 elm_widget_resize_object_set(obj, wd->base);
504 wd->pager = elm_pager_add(obj);
505 elm_object_style_set(wd->pager, "navigationbar");
506 elm_widget_sub_object_add(obj, wd->pager);
507 edje_object_part_swallow(wd->base, "elm.swallow.content", wd->pager);
508 evas_object_smart_callback_add(wd->pager, "hide,finished", _hide_finished, obj);
509 evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE, _resize, NULL);
516 * Push an object to the top of the NavigationBar stack (and show it)
517 * The object pushed becomes a child of the navigationbar and will be controlled
518 * it is deleted when the navigationbar is deleted or when the content is popped.
520 * @param[in] obj The NavigationBar object
521 * @param[in] title The title string
522 * @param[in] fn_btn1 The left button
523 * @param[in] fn_btn2 The right button
524 * @param[in] fn_btn3 The button placed before right most button.
525 * @param[in] content The object to push
527 * @ingroup NavigationBar
530 elm_navigationbar_push(Evas_Object *obj, const char *title, Evas_Object *fn_btn1, Evas_Object *fn_btn2, Evas_Object *fn_btn3, Evas_Object *content)
532 ELM_CHECK_WIDTYPE(obj, widtype);
533 Widget_Data *wd = elm_widget_data_get(obj);
536 Item *prev_it = NULL;
539 it = _check_item_is_added(obj, content);
541 if (!it) it = ELM_NEW(Item);
544 // add and set new items
545 _button_set(obj, NULL, fn_btn1, EINA_FALSE);
546 _button_set(obj, NULL, fn_btn2, EINA_FALSE);
547 _button_set(obj, NULL, fn_btn3, EINA_FALSE);
549 ll = eina_list_last(wd->stack);
555 it->fn_btn1 = fn_btn1;
556 it->fn_btn2 = fn_btn2;
557 it->fn_btn3 = fn_btn3;
558 it->content = content;
560 if (!fn_btn1 && prev_it)
562 char *prev_title = NULL;
564 it->back_btn = elm_button_add(obj);
565 prev_title = (char *)prev_it->title;
568 elm_button_label_set(it->back_btn, prev_title);
572 elm_button_label_set(it->back_btn, "Previous");
574 evas_object_smart_callback_add(it->back_btn, "clicked", _back_button_clicked, it);
575 _button_set(obj, NULL, it->back_btn, EINA_TRUE);
576 elm_object_focus_allow_set(it->back_btn, EINA_FALSE);
579 eina_stringshare_replace(&it->title, title);
580 edje_object_part_text_set(wd->base, "elm.text", title);
581 _item_sizing_eval(it);
583 Transit_Cb_Data *cb = ELM_NEW(Transit_Cb_Data);
584 // unswallow items and start transition
587 cb->prev_it = prev_it;
589 cb->pop = EINA_FALSE;
590 cb->first_page = EINA_FALSE;
591 if (prev_it->title_obj) edje_object_part_unswallow(wd->base, prev_it->title_obj);
592 if (prev_it->fn_btn1) edje_object_part_unswallow(wd->base, prev_it->fn_btn1);
593 else if (prev_it->back_btn) edje_object_part_unswallow(wd->base, prev_it->back_btn);
594 if (prev_it->fn_btn2) edje_object_part_unswallow(wd->base, prev_it->fn_btn2);
595 if (prev_it->fn_btn3) edje_object_part_unswallow(wd->base, prev_it->fn_btn3);
601 cb->pop = EINA_FALSE;
602 cb->first_page = EINA_TRUE;
604 _transition_complete_cb(cb);
606 elm_pager_content_push(wd->pager, it->content);
607 //push item into the stack. it should be always the tail
608 if (!_check_item_is_added(obj, content))
609 wd->stack = eina_list_append(wd->stack, it);
612 EINA_LIST_FOREACH(wd->stack, ll, it)
614 if (it->content == content)
616 wd->stack = eina_list_demote_list(wd->stack, ll);
625 * This pops the object that is on top (visible) in the navigationbar, makes it disappear, then deletes the object.
626 * The object that was underneath it, on the stack will become visible.
628 * @param[in] obj The NavigationBar object
630 * @ingroup NavigationBar
633 elm_navigationbar_pop(Evas_Object *obj)
635 ELM_CHECK_WIDTYPE(obj, widtype);
636 Widget_Data *wd = elm_widget_data_get(obj);
639 Item *prev_it = NULL;
641 if(wd->popping) return;
642 if (!wd->stack) return;
644 //find item to be popped and to be shown
645 ll = eina_list_last(wd->stack);
655 //unswallow items and start trasition
656 Transit_Cb_Data *cb = ELM_NEW(Transit_Cb_Data);
659 cb->prev_it = prev_it;
662 if (prev_it->title_obj) edje_object_part_unswallow(wd->base, prev_it->title_obj);
663 if (prev_it->fn_btn1) edje_object_part_unswallow(wd->base, prev_it->fn_btn1);
664 else if (prev_it->back_btn) edje_object_part_unswallow(wd->base, prev_it->back_btn);
665 if (prev_it->fn_btn2) edje_object_part_unswallow(wd->base, prev_it->fn_btn2);
666 if (prev_it->fn_btn3) edje_object_part_unswallow(wd->base, prev_it->fn_btn3);
667 _item_sizing_eval(it);
671 cb->prev_it = prev_it;
674 cb->first_page = EINA_FALSE;
676 _transition_complete_cb(cb);
677 wd->popping = EINA_TRUE;
678 //pop content from pager
679 elm_pager_content_pop(wd->pager);
682 edje_object_part_text_set(wd->base, "elm.text", NULL);
688 * This Pops to the given content object (and update it) by deleting rest of the objects in between.
690 * @param[in] obj The NavigationBar object
691 * @param[in] content the object to show
693 * @ingroup NavigationBar
696 elm_navigationbar_to_content_pop(Evas_Object *obj, Evas_Object *content)
698 ELM_CHECK_WIDTYPE(obj, widtype);
699 if (!content) return;
700 Widget_Data *wd = elm_widget_data_get(obj);
703 Item *prev_it = NULL;
705 if (!wd->stack) return;
706 //find item to be popped and to be shown
707 ll = eina_list_last(wd->stack);
715 if (it->obj && (it->content != content))
717 _delete_item(ll->data);
718 wd->stack = eina_list_remove_list(wd->stack, ll);
728 //unswallow items and start trasition
729 Transit_Cb_Data *cb = ELM_NEW(Transit_Cb_Data);
730 cb->prev_it = prev_it;
733 cb->first_page = EINA_FALSE;
734 if (prev_it->title_obj) edje_object_part_unswallow(wd->base, prev_it->title_obj);
735 if (prev_it->fn_btn1) edje_object_part_unswallow(wd->base, prev_it->fn_btn1);
736 else if (prev_it->back_btn) edje_object_part_unswallow(wd->base, prev_it->back_btn);
737 if (prev_it->fn_btn2) edje_object_part_unswallow(wd->base, prev_it->fn_btn2);
738 if (prev_it->fn_btn3) edje_object_part_unswallow(wd->base, prev_it->fn_btn3);
739 _item_sizing_eval(it);
740 _transition_complete_cb(cb);
741 //pop content from pager
742 elm_pager_to_content_pop(wd->pager, content);
747 * Set the title string for the pushed content
749 * @param[in] obj The NavigationBar object
750 * @param[in] content The object to push or pushed
751 * @param[in] title The title string
753 * @ingroup NavigationBar
756 elm_navigationbar_title_label_set(Evas_Object *obj, Evas_Object *content, const char *title)
758 ELM_CHECK_WIDTYPE(obj, widtype);
759 Widget_Data *wd = elm_widget_data_get(obj);
764 EINA_LIST_FOREACH(wd->stack, ll, it)
766 if (it->content == content)
768 eina_stringshare_replace(&it->title, title);
769 edje_object_part_text_set(wd->base, "elm.text", title);
772 if ((it->title_obj) && (it->title))
774 edje_object_signal_emit(wd->base, "elm,state,extend,title", "elm");
777 edje_object_signal_emit(wd->base, "elm,state,retract,title", "elm");
779 _item_sizing_eval(it);
786 * Return the title string of the pushed content
788 * @param[in] obj The NavigationBar object
789 * @param[in] content The object to push or pushed
790 * @return The title string or NULL if none
792 * @ingroup NavigationBar
795 elm_navigationbar_title_label_get(Evas_Object *obj, Evas_Object *content)
797 ELM_CHECK_WIDTYPE(obj, widtype)NULL;
798 Widget_Data *wd = elm_widget_data_get(obj);
802 if (!wd) return NULL;
803 EINA_LIST_FOREACH(wd->stack, ll, it)
805 if (it->content == content)
812 * Add a title object for the content.
814 * @param[in] obj The NavigationBar object
815 * @param[in] content The object pushed
816 * @param[in] title_obj a title object (normally button or segment_control)
818 * @ingroup NavigationBar
821 elm_navigationbar_title_object_add(Evas_Object *obj, Evas_Object *content, Evas_Object *title_obj)
823 ELM_CHECK_WIDTYPE(obj, widtype);
824 Widget_Data *wd = elm_widget_data_get(obj);
829 if (!title_obj) return;
830 if (!content) return;
832 it = _check_item_is_added(obj, content);
835 ERR("[ERROR]Push the Item first, later add the title object");
838 it->title_list = eina_list_append(it->title_list, title_obj);
839 if (it->obj) _item_sizing_eval(it);
840 //update if the content is the top item
841 ll = eina_list_last(wd->stack);
845 if (last_it->content == content)
847 Evas_Object *swallow;
848 swallow = edje_object_part_swallow_get(wd->base, "elm.swallow.title");
850 edje_object_part_unswallow(wd->base, swallow);
851 evas_object_hide(swallow);
853 edje_object_part_swallow(wd->base, "elm.swallow.title", it->title_obj);
858 edje_object_signal_emit(wd->base, "elm,state,item,add,rightpad2", "elm");
859 edje_object_signal_emit(wd->base, "elm,state,item,fn_btn3_set", "elm");
861 if ((it->title_obj) && (it->title))
863 edje_object_signal_emit(wd->base, "elm,state,extend,title", "elm");
866 _item_sizing_eval(it);
872 * Unset the list of title objects corresponding to given content and returns it to
874 * @param[in] obj The NavigationBar object
875 * @param[in] content The content object pushed
876 * @param[out] list updates the list with title objects list, this list has to be freed and the
877 * objects have to be deleted by application.
878 * @ingroup NavigationBar
881 elm_navigationbar_title_object_list_unset(Evas_Object *obj, Evas_Object *content, Eina_List **list)
883 ELM_CHECK_WIDTYPE(obj, widtype);
884 Widget_Data *wd = elm_widget_data_get(obj);
887 Item *last_it = NULL;
888 ll = eina_list_last(wd->stack);
895 EINA_LIST_FOREACH(wd->stack, ll, it)
897 if (it->content == content)
899 if (last_it->content == it->content)
901 Evas_Object *swallow;
902 swallow = edje_object_part_swallow_get(wd->base, "elm.swallow.title");
905 edje_object_part_unswallow(wd->base, swallow);
906 evas_object_hide(swallow);
909 _multiple_object_unset(it, list);
910 evas_object_del(it->title_obj);
911 it->title_obj = NULL;
914 edje_object_signal_emit(wd->base, "elm,state,retract,title", "elm");
917 edje_object_signal_emit(wd->base, "elm,state,item,add,rightpad2", "elm");
918 edje_object_signal_emit(wd->base, "elm,state,item,fn_btn3_set", "elm");
921 _item_sizing_eval(it);
928 * Return the list of title objects of the pushed content.
930 * @param[in] obj The NavigationBar object
931 * @param[in] content The object to push or pushed
932 * @return The list of title objects
934 * @ingroup NavigationBar
937 elm_navigationbar_title_object_list_get(Evas_Object *obj, Evas_Object *content)
939 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
940 Widget_Data *wd = elm_widget_data_get(obj);
944 if (!wd) return NULL;
945 EINA_LIST_FOREACH(wd->stack, ll, it)
947 if (it->content == content)
948 return it->title_list;
954 _elm_navigationbar_back_button_set(Evas_Object *obj, Evas_Object *content, Evas_Object *button)
956 Widget_Data *wd = elm_widget_data_get(obj);
962 EINA_LIST_FOREACH(wd->stack, ll, it)
964 if (it->content == content)
966 if(it->back_btn == button)
968 changed = _button_set(obj, it->back_btn, button, EINA_TRUE);
969 it->back_btn = button;
970 _item_sizing_eval(it);
975 //update if the content is the top item
976 ll = eina_list_last(wd->stack);
980 if (it->back_btn && changed && (it->content == content) && (!it->fn_btn1))
982 edje_object_part_swallow(wd->base, "elm.swallow.btn1", it->back_btn);
983 evas_object_smart_callback_add(it->back_btn, "clicked", _back_button_clicked, it);
989 _elm_navigationbar_back_button_get(Evas_Object *obj, Evas_Object *content)
991 Widget_Data *wd = elm_widget_data_get(obj);
995 if (!wd) return NULL;
996 EINA_LIST_FOREACH(wd->stack, ll, it)
998 if (it->content == content)
1005 _elm_navigationbar_function_button1_set(Evas_Object *obj, Evas_Object *content, Evas_Object *button)
1007 Widget_Data *wd = elm_widget_data_get(obj);
1013 EINA_LIST_FOREACH(wd->stack, ll, it)
1015 if (it->content == content)
1017 if(it->fn_btn1 == button)
1019 changed = _button_set(obj, it->fn_btn1, button, EINA_FALSE);
1020 it->fn_btn1 = button;
1021 _item_sizing_eval(it);
1026 //update if the content is the top item
1027 ll = eina_list_last(wd->stack);
1031 if (it->fn_btn1 && changed && (it->content == content))
1033 if (edje_object_part_swallow_get(wd->base, "elm.swallow.btn1") == it->back_btn)
1035 edje_object_part_unswallow(wd->base, it->back_btn);
1036 evas_object_hide(it->back_btn);
1038 edje_object_part_swallow(wd->base, "elm.swallow.btn1", it->fn_btn1);
1043 static Evas_Object *
1044 _elm_navigationbar_function_button1_get(Evas_Object *obj, Evas_Object *content)
1046 Widget_Data *wd = elm_widget_data_get(obj);
1050 if (!wd) return NULL;
1051 EINA_LIST_FOREACH(wd->stack, ll, it)
1053 if (it->content == content)
1060 _elm_navigationbar_function_button2_set(Evas_Object *obj, Evas_Object *content, Evas_Object *button)
1062 Widget_Data *wd = elm_widget_data_get(obj);
1068 EINA_LIST_FOREACH(wd->stack, ll, it)
1070 if (it->content == content)
1072 if(it->fn_btn2 == button)
1074 changed = _button_set(obj, it->fn_btn2, button, EINA_FALSE);
1075 it->fn_btn2 = button;
1076 _item_sizing_eval(it);
1081 //update if the content is the top item
1082 ll = eina_list_last(wd->stack);
1086 if (it->fn_btn2 && changed && (it->content == content))
1088 edje_object_part_swallow(wd->base, "elm.swallow.btn2", it->fn_btn2);
1093 static Evas_Object *
1094 _elm_navigationbar_function_button2_get(Evas_Object *obj,
1095 Evas_Object *content)
1097 Widget_Data *wd = elm_widget_data_get(obj);
1101 if (!wd) return NULL;
1102 EINA_LIST_FOREACH(wd->stack, ll, it)
1104 if (it->content == content)
1111 _elm_navigationbar_function_button3_set(Evas_Object *obj, Evas_Object *content, Evas_Object *button)
1113 Widget_Data *wd = elm_widget_data_get(obj);
1119 EINA_LIST_FOREACH(wd->stack, ll, it)
1121 if (it->content == content)
1123 if(it->fn_btn3 == button)
1125 changed = _button_set(obj, it->fn_btn3, button, EINA_FALSE);
1126 it->fn_btn3 = button;
1127 _item_sizing_eval(it);
1132 //update if the content is the top item
1133 ll = eina_list_last(wd->stack);
1137 if (it->fn_btn3 && changed && (it->content == content))
1139 edje_object_signal_emit(wd->base, "elm,state,item,add,rightpad2", "elm");
1140 edje_object_signal_emit(wd->base, "elm,state,item,fn_btn3_set", "elm");
1141 edje_object_part_swallow(wd->base, "elm.swallow.btn3", it->fn_btn3);
1144 edje_object_signal_emit(wd->base, "elm,state,retract,title", "elm");
1148 static Evas_Object *
1149 _elm_navigationbar_function_button3_get(Evas_Object *obj,
1150 Evas_Object *content)
1152 Widget_Data *wd = elm_widget_data_get(obj);
1156 if (!wd) return NULL;
1157 EINA_LIST_FOREACH(wd->stack, ll, it)
1159 if (it->content == content)
1166 * Return the content object at the top of the NavigationBar stack
1168 * @param[in] obj The NavigationBar object
1169 * @return The top content object or NULL if none
1171 * @ingroup NavigationBar
1174 elm_navigationbar_content_top_get(Evas_Object *obj)
1176 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1177 Widget_Data *wd = elm_widget_data_get(obj);
1179 if (!wd) return NULL;
1180 return elm_pager_content_top_get(wd->pager);
1184 * Return the content object at the bottom of the NavigationBar stack
1186 * @param[in] obj The NavigationBar object
1187 * @return The bottom content object or NULL if none
1189 * @ingroup NavigationBar
1192 elm_navigationbar_content_bottom_get(Evas_Object *obj)
1194 ELM_CHECK_WIDTYPE(obj, widtype)NULL;
1195 Widget_Data *wd = elm_widget_data_get(obj);
1197 if (!wd) return NULL;
1198 return elm_pager_content_bottom_get(wd->pager);
1202 * This hides the title area of navigationbar.
1204 * @param[in] obj The NavigationBar object
1205 * @param[in] hidden if EINA_TRUE the title area is hidden.
1207 * @ingroup NavigationBar
1210 elm_navigationbar_hidden_set(Evas_Object *obj,
1213 ELM_CHECK_WIDTYPE(obj, widtype);
1214 Widget_Data *wd = elm_widget_data_get(obj);
1218 edje_object_signal_emit(wd->base, "elm,state,item,moveup", "elm");
1220 edje_object_signal_emit(wd->base, "elm,state,item,movedown", "elm");
1221 wd->hidden = hidden;
1225 * Set the button object of the pushed content.
1227 * @param[in] obj The NavigationBar object
1228 * @param[in] content The object to push or pushed
1229 * @param[in] button The button
1230 * @param[in] button_type Indicates the position
1232 * @ingroup NavigationBar
1235 elm_navigationbar_title_button_set(Evas_Object *obj, Evas_Object *content, Evas_Object *button, Elm_Navi_Button_Type button_type)
1237 ELM_CHECK_WIDTYPE(obj, widtype);
1238 if (!content) return;
1242 case ELM_NAVIGATIONBAR_FUNCTION_BUTTON1:
1243 _elm_navigationbar_function_button1_set(obj, content, button);
1245 case ELM_NAVIGATIONBAR_FUNCTION_BUTTON2:
1246 _elm_navigationbar_function_button2_set(obj, content, button);
1248 case ELM_NAVIGATIONBAR_FUNCTION_BUTTON3:
1249 _elm_navigationbar_function_button3_set(obj, content, button);
1251 case ELM_NAVIGATIONBAR_BACK_BUTTON:
1252 _elm_navigationbar_back_button_set(obj, content, button);
1261 * Return the button object of the pushed content
1263 * @param[in] obj The NavigationBar object
1264 * @param[in] content The object to push or pushed
1265 * @param[in] button_type Indicates the position
1266 * @return The button object or NULL if none
1268 * @ingroup NavigationBar
1271 elm_navigationbar_title_button_get(Evas_Object *obj, Evas_Object *content, Elm_Navi_Button_Type button_type)
1273 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1274 Evas_Object *button=NULL;
1276 if (!content || !obj) return NULL;
1279 case ELM_NAVIGATIONBAR_FUNCTION_BUTTON1:
1280 button = _elm_navigationbar_function_button1_get(obj, content);
1282 case ELM_NAVIGATIONBAR_FUNCTION_BUTTON2:
1283 button = _elm_navigationbar_function_button2_get(obj, content);
1285 case ELM_NAVIGATIONBAR_FUNCTION_BUTTON3:
1286 button = _elm_navigationbar_function_button3_get(obj, content);
1288 case ELM_NAVIGATIONBAR_BACK_BUTTON:
1289 button = _elm_navigationbar_back_button_get(obj, content);
1298 * Set the sub title string for the pushed content.
1300 * @param[in] obj The NavigationBar object
1301 * @param[in] content The object to push or pushed
1302 * @param[in] subtitle The subtitle string
1304 * @ingroup NavigationBar
1307 elm_navigationbar_subtitle_label_set(Evas_Object *obj, Evas_Object *content, const char *subtitle)
1309 ELM_CHECK_WIDTYPE(obj, widtype);
1310 Widget_Data *wd = elm_widget_data_get(obj);
1315 EINA_LIST_FOREACH(wd->stack, ll, it)
1317 if (it->content == content)
1319 eina_stringshare_replace(&it->subtitle, subtitle);
1320 edje_object_part_text_set(wd->base, "elm.text.sub", subtitle);
1321 _item_sizing_eval(it);
1328 * Return the subtitle string of the pushed content.
1330 * @param[in] obj The NavigationBar object
1331 * @param[in] content The object to push or pushed
1332 * @return The subtitle string or NULL if none
1334 * @ingroup NavigationBar
1337 elm_navigationbar_subtitle_label_get(Evas_Object *obj, Evas_Object *content)
1339 ELM_CHECK_WIDTYPE(obj, widtype)NULL;
1340 Widget_Data *wd = elm_widget_data_get(obj);
1344 if (!wd) return NULL;
1345 EINA_LIST_FOREACH(wd->stack, ll, it)
1347 if (it->content == content)
1348 return it->subtitle;
1354 * This disables content area animation on push/pop.
1356 * @param[in] obj The NavigationBar object
1357 * @param[in] disable if EINA_TRUE animation is disabled.
1359 * @ingroup NavigationBar
1362 elm_navigationbar_animation_disable_set(Evas_Object *obj, Eina_Bool disable)
1364 ELM_CHECK_WIDTYPE(obj, widtype);
1365 Widget_Data *wd = elm_widget_data_get(obj);
1367 elm_pager_animation_disable_set(wd->pager, disable);