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;
140 evas_object_del(it->back_btn);
143 elm_object_unfocus(it->fn_btn1);
144 evas_object_del(it->fn_btn1);
148 elm_object_unfocus(it->fn_btn2);
149 evas_object_del(it->fn_btn2);
153 elm_object_unfocus(it->fn_btn3);
154 evas_object_del(it->fn_btn3);
157 eina_stringshare_del(it->title);
159 eina_stringshare_del(it->subtitle);
160 EINA_LIST_FOREACH(it->title_list, ll, list_obj)
161 evas_object_del(list_obj);
162 eina_list_free(it->title_list);
167 _sizing_eval(Evas_Object *obj)
169 Widget_Data *wd = elm_widget_data_get(obj);
170 Evas_Coord minw = -1, minh = -1;
171 Evas_Coord w = -1, h = -1;
174 edje_object_size_min_calc(wd->base, &minw, &minh);
175 evas_object_size_hint_min_get(obj, &w, &h);
176 if (w > minw) minw = w;
177 if (h > minw) minh = h;
179 evas_object_size_hint_min_set(obj, minw, minh);
180 evas_object_size_hint_max_set(obj, -1, -1);
182 list = eina_list_last(wd->stack);
185 Item *it = list->data;
186 _item_sizing_eval(it);
191 _item_sizing_eval(Item *it)
194 Widget_Data *wd = elm_widget_data_get(it->obj);
195 Evas_Coord pad, height, minw, w;
198 edje_object_size_min_calc(wd->base, &minw, NULL);
199 evas_object_geometry_get(wd->base, NULL, NULL, &w, NULL);
200 if (w < minw) w = minw;
201 edje_object_part_geometry_get(wd->base, "elm.rect.pad1", NULL, NULL, &pad, NULL);
202 edje_object_part_geometry_get(wd->base, "elm.swallow.title", NULL, NULL, NULL, &height);
206 it->fn_btn1_w = _set_button_width(it->fn_btn1);
209 else if (it->back_btn)
211 it->fn_btn1_w = _set_button_width(it->back_btn);
216 it->fn_btn2_w = _set_button_width(it->fn_btn2);
221 it->fn_btn3_w = _set_button_width(it->fn_btn3);
226 it->title_w = _set_button_width(it->title_obj);
227 it->title_obj = _multiple_object_set(it->obj, it->title_obj, it->title_list, it->title_w);
228 evas_object_resize(it->title_obj, it->title_w, height);
229 evas_object_size_hint_min_set(it->title_obj, it->title_w, height);
234 _resize(void *data, Evas *e, Evas_Object *obj, void *event_info)
240 _transition_complete_cb(void *data)
242 Transit_Cb_Data *cb = data;
244 Evas_Object *navi_bar = NULL;
245 Evas_Object *content = NULL;
246 Widget_Data *wd = NULL;
247 Item *prev_it = cb->prev_it;
252 navi_bar = prev_it->obj;
258 wd = elm_widget_data_get(navi_bar);
259 if (cb->pop && prev_it)
262 ll = eina_list_last(wd->stack);
263 if (ll->data == prev_it)
265 _delete_item(prev_it);
266 wd->stack = eina_list_remove_list(wd->stack, ll);
271 evas_object_hide(prev_it->fn_btn1);
272 evas_object_hide(prev_it->back_btn);
273 evas_object_hide(prev_it->title_obj);
274 evas_object_hide(prev_it->fn_btn2);
275 evas_object_hide(prev_it->fn_btn3);
277 if ((it) && (!wd->hidden))
279 edje_object_part_text_set(wd->base, "elm.text", it->title);
284 edje_object_signal_emit(wd->base, "elm,action,pop", "elm");
288 edje_object_signal_emit(wd->base, "elm,action,push", "elm");
290 edje_object_signal_emit(wd->base, "elm,state,rect,enabled", "elm");
294 edje_object_part_swallow(wd->base, "elm.swallow.title", it->title_obj);
295 edje_object_signal_emit(wd->base, "elm,state,retract,title", "elm");
299 edje_object_signal_emit(wd->base, "elm,state,retract,title", "elm");
303 edje_object_part_text_set(wd->base, "elm.text.sub", it->subtitle);
306 edje_object_part_text_set(wd->base, "elm.text.sub", NULL);
309 edje_object_signal_emit(wd->base, "elm,state,item,add,leftpad", "elm");
310 edje_object_part_swallow(wd->base, "elm.swallow.btn1", it->fn_btn1);
312 else if (it->back_btn)
314 edje_object_signal_emit(wd->base, "elm,state,item,add,leftpad", "elm");
315 edje_object_part_swallow(wd->base, "elm.swallow.btn1", it->back_btn);
318 edje_object_signal_emit(wd->base, "elm,state,item,reset,leftpad", "elm");
321 edje_object_signal_emit(wd->base, "elm,state,item,add,rightpad", "elm");
322 edje_object_part_swallow(wd->base, "elm.swallow.btn2", it->fn_btn2);
325 edje_object_signal_emit(wd->base, "elm,state,item,reset,rightpad", "elm");
328 edje_object_signal_emit(wd->base, "elm,state,item,add,rightpad2", "elm");
329 edje_object_signal_emit(wd->base, "elm,state,item,fn_btn3_set", "elm");
330 edje_object_part_swallow(wd->base, "elm.swallow.btn3", it->fn_btn3);
333 edje_object_signal_emit(wd->base, "elm,state,item,reset,rightpad2", "elm");
334 if ((it->title_obj) && (it->title))
336 edje_object_signal_emit(wd->base, "elm,state,extend,title", "elm");
338 content = it->content;
340 edje_object_message_signal_process(wd->base);
344 _back_button_clicked(void *data, Evas_Object *obj, void *event_info)
348 elm_navigationbar_pop(it->obj);
352 _hide_finished(void *data, Evas_Object *obj, void *event_info)
354 Evas_Object *navi_bar = data;
355 Widget_Data *wd = elm_widget_data_get(navi_bar);
356 wd->popping = EINA_FALSE;
357 evas_object_smart_callback_call(navi_bar, "hide,finished", event_info);
358 edje_object_signal_emit(wd->base, "elm,state,rect,disabled", "elm");
362 _set_button_width(Evas_Object *obj)
364 Evas_Coord minw = -1, minh = -1, maxw= -1, maxh = -1;
365 Evas_Coord w = 0, h = 0;
367 evas_object_size_hint_min_get(obj, &minw, &minh);
368 evas_object_size_hint_max_get(obj, &maxw, &maxh);
369 evas_object_geometry_get(obj, NULL, NULL, &w, &h);
370 if (w < minw) w = minw;
371 if (h < minh) h = minh;
372 if ((maxw >= 0) && (w > maxw)) w = maxw;
373 if ((maxh >= 0) && (h > maxh)) h = maxh;
374 evas_object_resize(obj, w, h);
379 _button_set(Evas_Object *obj, Evas_Object *prev_btn, Evas_Object *new_btn, Eina_Bool back_btn)
382 Eina_Bool changed = EINA_FALSE;
386 evas_object_del(prev_btn);
393 snprintf(buf, sizeof(buf), "navigationbar_backbutton/%s", elm_widget_style_get(obj));
394 elm_object_style_set(new_btn, buf);
398 snprintf(buf, sizeof(buf), "navigationbar_functionbutton/%s", elm_widget_style_get(obj));
399 elm_object_style_set(new_btn, buf);
401 elm_widget_sub_object_add(obj, new_btn);
408 _check_item_is_added(Evas_Object *obj, Evas_Object *content)
410 Widget_Data *wd = elm_widget_data_get(obj);
414 EINA_LIST_FOREACH(wd->stack, ll, it)
416 if (it->content == content)
425 _multiple_object_set(Evas_Object *obj, Evas_Object *sub_obj, Eina_List *list, int width)
427 Widget_Data *wd = elm_widget_data_get(obj);
429 Evas_Object *new_obj, *list_obj;
430 Evas_Coord pad, height;
435 edje_object_part_geometry_get(wd->base, "elm.rect.pad1", NULL, NULL, &pad, NULL);
436 edje_object_part_geometry_get(wd->base, "elm.swallow.title", NULL, NULL, NULL, &height);
439 new_obj = elm_layout_add(obj);
440 elm_widget_sub_object_add(obj, new_obj);
441 elm_layout_theme_set(new_obj, "navigationbar", "title", elm_widget_style_get(obj));
445 count = eina_list_count(list);
446 EINA_LIST_FOREACH(list, ll, list_obj)
448 evas_object_resize(list_obj, (width-(count-1)*pad)/count, height);
449 evas_object_size_hint_min_set(list_obj, (width-(count-1)*pad)/count, height);
450 memset(buf, 0, sizeof(buf));
451 sprintf(buf, "elm,state,item,add,%d", num);
452 edje_object_signal_emit(elm_layout_edje_get(new_obj), buf, "elm");
453 memset(buf, 0, sizeof(buf));
454 sprintf(buf, "elm.swallow.title%d", num++);
455 elm_layout_content_set(new_obj, buf, list_obj);
461 _multiple_object_unset(Item *it, Eina_List **list)
463 Evas_Object *list_obj = NULL;
465 Evas_Object *temp_obj;
470 EINA_LIST_FOREACH (it->title_list, l, list_obj)
472 memset(buf, 0, sizeof(buf));
473 sprintf(buf, "elm.swallow.title%d", num++);
474 temp_obj = elm_layout_content_unset(it->title_obj, buf);
475 *list = eina_list_append(*list, temp_obj);
476 evas_object_hide(temp_obj);
478 eina_list_free(it->title_list);
479 it->title_list = NULL;
485 * Add a new navigationbar to the parent
487 * @param[in] parent The parent object
488 * @return The new object or NULL if it cannot be created
490 * @ingroup NavigationBar
493 elm_navigationbar_add(Evas_Object *parent)
499 wd = ELM_NEW(Widget_Data);
500 e = evas_object_evas_get(parent);
501 obj = elm_widget_add(e);
502 ELM_SET_WIDTYPE(widtype, "navigationbar");
503 elm_widget_type_set(obj, "navigationbar");
504 elm_widget_sub_object_add(parent, obj);
505 elm_widget_data_set(obj, wd);
506 elm_widget_del_hook_set(obj, _del_hook);
507 elm_widget_theme_hook_set(obj, _theme_hook);
509 wd->base = edje_object_add(e);
510 _elm_theme_object_set(obj, wd->base, "navigationbar", "base", "default");
511 elm_widget_resize_object_set(obj, wd->base);
513 wd->pager = elm_pager_add(obj);
514 elm_object_style_set(wd->pager, "navigationbar");
515 elm_widget_sub_object_add(obj, wd->pager);
516 edje_object_part_swallow(wd->base, "elm.swallow.content", wd->pager);
517 evas_object_smart_callback_add(wd->pager, "hide,finished", _hide_finished, obj);
518 evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE, _resize, NULL);
525 * Push an object to the top of the NavigationBar stack (and show it)
526 * The object pushed becomes a child of the navigationbar and will be controlled
527 * it is deleted when the navigationbar is deleted or when the content is popped.
529 * @param[in] obj The NavigationBar object
530 * @param[in] title The title string
531 * @param[in] fn_btn1 The left button
532 * @param[in] fn_btn2 The right button
533 * @param[in] fn_btn3 The button placed before right most button.
534 * @param[in] content The object to push
536 * @ingroup NavigationBar
539 elm_navigationbar_push(Evas_Object *obj, const char *title, Evas_Object *fn_btn1, Evas_Object *fn_btn2, Evas_Object *fn_btn3, Evas_Object *content)
541 ELM_CHECK_WIDTYPE(obj, widtype);
542 Widget_Data *wd = elm_widget_data_get(obj);
545 Item *prev_it = NULL;
548 it = _check_item_is_added(obj, content);
550 if (!it) it = ELM_NEW(Item);
553 // add and set new items
554 _button_set(obj, NULL, fn_btn1, EINA_FALSE);
555 _button_set(obj, NULL, fn_btn2, EINA_FALSE);
556 _button_set(obj, NULL, fn_btn3, EINA_FALSE);
558 ll = eina_list_last(wd->stack);
564 it->fn_btn1 = fn_btn1;
565 it->fn_btn2 = fn_btn2;
566 it->fn_btn3 = fn_btn3;
567 it->content = content;
569 if (!fn_btn1 && prev_it)
571 char *prev_title = NULL;
573 it->back_btn = elm_button_add(obj);
574 prev_title = (char *)prev_it->title;
577 elm_button_label_set(it->back_btn, prev_title);
581 elm_button_label_set(it->back_btn, "Previous");
583 evas_object_smart_callback_add(it->back_btn, "clicked", _back_button_clicked, it);
584 _button_set(obj, NULL, it->back_btn, EINA_TRUE);
585 elm_object_focus_allow_set(it->back_btn, EINA_FALSE);
588 eina_stringshare_replace(&it->title, title);
589 edje_object_part_text_set(wd->base, "elm.text", title);
590 _item_sizing_eval(it);
592 Transit_Cb_Data *cb = ELM_NEW(Transit_Cb_Data);
593 // unswallow items and start transition
596 cb->prev_it = prev_it;
598 cb->pop = EINA_FALSE;
599 cb->first_page = EINA_FALSE;
600 if (prev_it->title_obj) edje_object_part_unswallow(wd->base, prev_it->title_obj);
601 if (prev_it->fn_btn1) edje_object_part_unswallow(wd->base, prev_it->fn_btn1);
602 else if (prev_it->back_btn) edje_object_part_unswallow(wd->base, prev_it->back_btn);
603 if (prev_it->fn_btn2) edje_object_part_unswallow(wd->base, prev_it->fn_btn2);
604 if (prev_it->fn_btn3) edje_object_part_unswallow(wd->base, prev_it->fn_btn3);
610 cb->pop = EINA_FALSE;
611 cb->first_page = EINA_TRUE;
613 _transition_complete_cb(cb);
615 elm_pager_content_push(wd->pager, it->content);
616 //push item into the stack. it should be always the tail
617 if (!_check_item_is_added(obj, content))
618 wd->stack = eina_list_append(wd->stack, it);
621 EINA_LIST_FOREACH(wd->stack, ll, it)
623 if (it->content == content)
625 wd->stack = eina_list_demote_list(wd->stack, ll);
634 * This pops the object that is on top (visible) in the navigationbar, makes it disappear, then deletes the object.
635 * The object that was underneath it, on the stack will become visible.
637 * @param[in] obj The NavigationBar object
639 * @ingroup NavigationBar
642 elm_navigationbar_pop(Evas_Object *obj)
644 ELM_CHECK_WIDTYPE(obj, widtype);
645 Widget_Data *wd = elm_widget_data_get(obj);
648 Item *prev_it = NULL;
650 if(wd->popping) return;
651 if (!wd->stack) return;
653 //find item to be popped and to be shown
654 ll = eina_list_last(wd->stack);
664 //unswallow items and start trasition
665 Transit_Cb_Data *cb = ELM_NEW(Transit_Cb_Data);
668 cb->prev_it = prev_it;
671 if (prev_it->title_obj) edje_object_part_unswallow(wd->base, prev_it->title_obj);
672 if (prev_it->fn_btn1) edje_object_part_unswallow(wd->base, prev_it->fn_btn1);
673 else if (prev_it->back_btn) edje_object_part_unswallow(wd->base, prev_it->back_btn);
674 if (prev_it->fn_btn2) edje_object_part_unswallow(wd->base, prev_it->fn_btn2);
675 if (prev_it->fn_btn3) edje_object_part_unswallow(wd->base, prev_it->fn_btn3);
676 _item_sizing_eval(it);
680 cb->prev_it = prev_it;
683 cb->first_page = EINA_FALSE;
685 _transition_complete_cb(cb);
686 wd->popping = EINA_TRUE;
687 //pop content from pager
688 elm_pager_content_pop(wd->pager);
691 edje_object_part_text_set(wd->base, "elm.text", NULL);
697 * This Pops to the given content object (and update it) by deleting rest of the objects in between.
699 * @param[in] obj The NavigationBar object
700 * @param[in] content the object to show
702 * @ingroup NavigationBar
705 elm_navigationbar_to_content_pop(Evas_Object *obj, Evas_Object *content)
707 ELM_CHECK_WIDTYPE(obj, widtype);
708 if (!content) return;
709 Widget_Data *wd = elm_widget_data_get(obj);
712 Item *prev_it = NULL;
714 if (!wd->stack) return;
715 //find item to be popped and to be shown
716 ll = eina_list_last(wd->stack);
724 if (it->obj && (it->content != content))
726 _delete_item(ll->data);
727 wd->stack = eina_list_remove_list(wd->stack, ll);
737 //unswallow items and start trasition
738 Transit_Cb_Data *cb = ELM_NEW(Transit_Cb_Data);
739 cb->prev_it = prev_it;
742 cb->first_page = EINA_FALSE;
743 if (prev_it->title_obj) edje_object_part_unswallow(wd->base, prev_it->title_obj);
744 if (prev_it->fn_btn1) edje_object_part_unswallow(wd->base, prev_it->fn_btn1);
745 else if (prev_it->back_btn) edje_object_part_unswallow(wd->base, prev_it->back_btn);
746 if (prev_it->fn_btn2) edje_object_part_unswallow(wd->base, prev_it->fn_btn2);
747 if (prev_it->fn_btn3) edje_object_part_unswallow(wd->base, prev_it->fn_btn3);
748 _item_sizing_eval(it);
749 _transition_complete_cb(cb);
750 //pop content from pager
751 elm_pager_to_content_pop(wd->pager, content);
756 * Set the title string for the pushed content
758 * @param[in] obj The NavigationBar object
759 * @param[in] content The object to push or pushed
760 * @param[in] title The title string
762 * @ingroup NavigationBar
765 elm_navigationbar_title_label_set(Evas_Object *obj, Evas_Object *content, const char *title)
767 ELM_CHECK_WIDTYPE(obj, widtype);
768 Widget_Data *wd = elm_widget_data_get(obj);
773 EINA_LIST_FOREACH(wd->stack, ll, it)
775 if (it->content == content)
777 eina_stringshare_replace(&it->title, title);
778 edje_object_part_text_set(wd->base, "elm.text", title);
781 if ((it->title_obj) && (it->title))
783 edje_object_signal_emit(wd->base, "elm,state,extend,title", "elm");
786 edje_object_signal_emit(wd->base, "elm,state,retract,title", "elm");
788 _item_sizing_eval(it);
795 * Return the title string of the pushed content
797 * @param[in] obj The NavigationBar object
798 * @param[in] content The object to push or pushed
799 * @return The title string or NULL if none
801 * @ingroup NavigationBar
804 elm_navigationbar_title_label_get(Evas_Object *obj, Evas_Object *content)
806 ELM_CHECK_WIDTYPE(obj, widtype)NULL;
807 Widget_Data *wd = elm_widget_data_get(obj);
811 if (!wd) return NULL;
812 EINA_LIST_FOREACH(wd->stack, ll, it)
814 if (it->content == content)
821 * Add a title object for the content.
823 * @param[in] obj The NavigationBar object
824 * @param[in] content The object pushed
825 * @param[in] title_obj a title object (normally button or segment_control)
827 * @ingroup NavigationBar
830 elm_navigationbar_title_object_add(Evas_Object *obj, Evas_Object *content, Evas_Object *title_obj)
832 ELM_CHECK_WIDTYPE(obj, widtype);
833 Widget_Data *wd = elm_widget_data_get(obj);
838 if (!title_obj) return;
839 if (!content) return;
841 it = _check_item_is_added(obj, content);
844 ERR("[ERROR]Push the Item first, later add the title object");
847 it->title_list = eina_list_append(it->title_list, title_obj);
848 if (it->obj) _item_sizing_eval(it);
849 //update if the content is the top item
850 ll = eina_list_last(wd->stack);
854 if (last_it->content == content)
856 Evas_Object *swallow;
857 swallow = edje_object_part_swallow_get(wd->base, "elm.swallow.title");
859 edje_object_part_unswallow(wd->base, swallow);
860 evas_object_hide(swallow);
862 edje_object_part_swallow(wd->base, "elm.swallow.title", it->title_obj);
867 edje_object_signal_emit(wd->base, "elm,state,item,add,rightpad2", "elm");
868 edje_object_signal_emit(wd->base, "elm,state,item,fn_btn3_set", "elm");
870 if ((it->title_obj) && (it->title))
872 edje_object_signal_emit(wd->base, "elm,state,extend,title", "elm");
875 _item_sizing_eval(it);
881 * Unset the list of title objects corresponding to given content and returns it to
883 * @param[in] obj The NavigationBar object
884 * @param[in] content The content object pushed
885 * @param[out] list updates the list with title objects list, this list has to be freed and the
886 * objects have to be deleted by application.
887 * @ingroup NavigationBar
890 elm_navigationbar_title_object_list_unset(Evas_Object *obj, Evas_Object *content, Eina_List **list)
892 ELM_CHECK_WIDTYPE(obj, widtype);
893 Widget_Data *wd = elm_widget_data_get(obj);
897 Item *last_it = NULL;
898 ll = eina_list_last(wd->stack);
904 EINA_LIST_FOREACH(wd->stack, ll, it)
906 if (it->content == content)
908 if (last_it->content == it->content)
910 Evas_Object *swallow;
911 swallow = edje_object_part_swallow_get(wd->base, "elm.swallow.title");
914 edje_object_part_unswallow(wd->base, swallow);
915 evas_object_hide(swallow);
918 _multiple_object_unset(it, list);
919 evas_object_del(it->title_obj);
920 it->title_obj = NULL;
923 edje_object_signal_emit(wd->base, "elm,state,retract,title", "elm");
926 edje_object_signal_emit(wd->base, "elm,state,item,add,rightpad2", "elm");
927 edje_object_signal_emit(wd->base, "elm,state,item,fn_btn3_set", "elm");
930 _item_sizing_eval(it);
937 * Return the list of title objects of the pushed content.
939 * @param[in] obj The NavigationBar object
940 * @param[in] content The object to push or pushed
941 * @return The list of title objects
943 * @ingroup NavigationBar
946 elm_navigationbar_title_object_list_get(Evas_Object *obj, Evas_Object *content)
948 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
949 Widget_Data *wd = elm_widget_data_get(obj);
953 if (!wd) return NULL;
954 EINA_LIST_FOREACH(wd->stack, ll, it)
956 if (it->content == content)
957 return it->title_list;
963 _elm_navigationbar_back_button_set(Evas_Object *obj, Evas_Object *content, Evas_Object *button)
965 Widget_Data *wd = elm_widget_data_get(obj);
971 EINA_LIST_FOREACH(wd->stack, ll, it)
973 if (it->content == content)
975 if(it->back_btn == button)
977 changed = _button_set(obj, it->back_btn, button, EINA_TRUE);
978 it->back_btn = button;
979 _item_sizing_eval(it);
984 //update if the content is the top item
985 ll = eina_list_last(wd->stack);
989 if (it->back_btn && changed && (it->content == content) && (!it->fn_btn1))
991 edje_object_part_swallow(wd->base, "elm.swallow.btn1", it->back_btn);
992 evas_object_smart_callback_add(it->back_btn, "clicked", _back_button_clicked, it);
998 _elm_navigationbar_back_button_get(Evas_Object *obj, Evas_Object *content)
1000 Widget_Data *wd = elm_widget_data_get(obj);
1004 if (!wd) return NULL;
1005 EINA_LIST_FOREACH(wd->stack, ll, it)
1007 if (it->content == content)
1008 return it->back_btn;
1014 _elm_navigationbar_function_button1_set(Evas_Object *obj, Evas_Object *content, Evas_Object *button)
1016 Widget_Data *wd = elm_widget_data_get(obj);
1022 EINA_LIST_FOREACH(wd->stack, ll, it)
1024 if (it->content == content)
1026 if(it->fn_btn1 == button)
1028 changed = _button_set(obj, it->fn_btn1, button, EINA_FALSE);
1029 it->fn_btn1 = button;
1030 _item_sizing_eval(it);
1035 //update if the content is the top item
1036 ll = eina_list_last(wd->stack);
1040 if (it->fn_btn1 && changed && (it->content == content))
1042 if (edje_object_part_swallow_get(wd->base, "elm.swallow.btn1") == it->back_btn)
1044 edje_object_part_unswallow(wd->base, it->back_btn);
1045 evas_object_hide(it->back_btn);
1047 edje_object_part_swallow(wd->base, "elm.swallow.btn1", it->fn_btn1);
1052 static Evas_Object *
1053 _elm_navigationbar_function_button1_get(Evas_Object *obj, Evas_Object *content)
1055 Widget_Data *wd = elm_widget_data_get(obj);
1059 if (!wd) return NULL;
1060 EINA_LIST_FOREACH(wd->stack, ll, it)
1062 if (it->content == content)
1069 _elm_navigationbar_function_button2_set(Evas_Object *obj, Evas_Object *content, Evas_Object *button)
1071 Widget_Data *wd = elm_widget_data_get(obj);
1077 EINA_LIST_FOREACH(wd->stack, ll, it)
1079 if (it->content == content)
1081 if(it->fn_btn2 == button)
1083 changed = _button_set(obj, it->fn_btn2, button, EINA_FALSE);
1084 it->fn_btn2 = button;
1085 _item_sizing_eval(it);
1090 //update if the content is the top item
1091 ll = eina_list_last(wd->stack);
1095 if (it->fn_btn2 && changed && (it->content == content))
1097 edje_object_part_swallow(wd->base, "elm.swallow.btn2", it->fn_btn2);
1102 static Evas_Object *
1103 _elm_navigationbar_function_button2_get(Evas_Object *obj,
1104 Evas_Object *content)
1106 Widget_Data *wd = elm_widget_data_get(obj);
1110 if (!wd) return NULL;
1111 EINA_LIST_FOREACH(wd->stack, ll, it)
1113 if (it->content == content)
1120 _elm_navigationbar_function_button3_set(Evas_Object *obj, Evas_Object *content, Evas_Object *button)
1122 Widget_Data *wd = elm_widget_data_get(obj);
1128 EINA_LIST_FOREACH(wd->stack, ll, it)
1130 if (it->content == content)
1132 if(it->fn_btn3 == button)
1134 changed = _button_set(obj, it->fn_btn3, button, EINA_FALSE);
1135 it->fn_btn3 = button;
1136 _item_sizing_eval(it);
1141 //update if the content is the top item
1142 ll = eina_list_last(wd->stack);
1146 if (it->fn_btn3 && changed && (it->content == content))
1148 edje_object_signal_emit(wd->base, "elm,state,item,add,rightpad2", "elm");
1149 edje_object_signal_emit(wd->base, "elm,state,item,fn_btn3_set", "elm");
1150 edje_object_part_swallow(wd->base, "elm.swallow.btn3", it->fn_btn3);
1153 edje_object_signal_emit(wd->base, "elm,state,retract,title", "elm");
1157 static Evas_Object *
1158 _elm_navigationbar_function_button3_get(Evas_Object *obj,
1159 Evas_Object *content)
1161 Widget_Data *wd = elm_widget_data_get(obj);
1165 if (!wd) return NULL;
1166 EINA_LIST_FOREACH(wd->stack, ll, it)
1168 if (it->content == content)
1175 * Return the content object at the top of the NavigationBar stack
1177 * @param[in] obj The NavigationBar object
1178 * @return The top content object or NULL if none
1180 * @ingroup NavigationBar
1183 elm_navigationbar_content_top_get(Evas_Object *obj)
1185 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1186 Widget_Data *wd = elm_widget_data_get(obj);
1188 if (!wd) return NULL;
1189 return elm_pager_content_top_get(wd->pager);
1193 * Return the content object at the bottom of the NavigationBar stack
1195 * @param[in] obj The NavigationBar object
1196 * @return The bottom content object or NULL if none
1198 * @ingroup NavigationBar
1201 elm_navigationbar_content_bottom_get(Evas_Object *obj)
1203 ELM_CHECK_WIDTYPE(obj, widtype)NULL;
1204 Widget_Data *wd = elm_widget_data_get(obj);
1206 if (!wd) return NULL;
1207 return elm_pager_content_bottom_get(wd->pager);
1211 * This hides the title area of navigationbar.
1213 * @param[in] obj The NavigationBar object
1214 * @param[in] hidden if EINA_TRUE the title area is hidden.
1216 * @ingroup NavigationBar
1219 elm_navigationbar_hidden_set(Evas_Object *obj,
1222 ELM_CHECK_WIDTYPE(obj, widtype);
1223 Widget_Data *wd = elm_widget_data_get(obj);
1227 edje_object_signal_emit(wd->base, "elm,state,item,moveup", "elm");
1229 edje_object_signal_emit(wd->base, "elm,state,item,movedown", "elm");
1230 wd->hidden = hidden;
1234 * Set the button object of the pushed content.
1236 * @param[in] obj The NavigationBar object
1237 * @param[in] content The object to push or pushed
1238 * @param[in] button The button
1239 * @param[in] button_type Indicates the position
1241 * @ingroup NavigationBar
1244 elm_navigationbar_title_button_set(Evas_Object *obj, Evas_Object *content, Evas_Object *button, Elm_Navi_Button_Type button_type)
1246 ELM_CHECK_WIDTYPE(obj, widtype);
1247 if (!content) return;
1251 case ELM_NAVIGATIONBAR_FUNCTION_BUTTON1:
1252 _elm_navigationbar_function_button1_set(obj, content, button);
1254 case ELM_NAVIGATIONBAR_FUNCTION_BUTTON2:
1255 _elm_navigationbar_function_button2_set(obj, content, button);
1257 case ELM_NAVIGATIONBAR_FUNCTION_BUTTON3:
1258 _elm_navigationbar_function_button3_set(obj, content, button);
1260 case ELM_NAVIGATIONBAR_BACK_BUTTON:
1261 _elm_navigationbar_back_button_set(obj, content, button);
1270 * Return the button object of the pushed content
1272 * @param[in] obj The NavigationBar object
1273 * @param[in] content The object to push or pushed
1274 * @param[in] button_type Indicates the position
1275 * @return The button object or NULL if none
1277 * @ingroup NavigationBar
1280 elm_navigationbar_title_button_get(Evas_Object *obj, Evas_Object *content, Elm_Navi_Button_Type button_type)
1282 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1283 Evas_Object *button=NULL;
1285 if (!content || !obj) return NULL;
1288 case ELM_NAVIGATIONBAR_FUNCTION_BUTTON1:
1289 button = _elm_navigationbar_function_button1_get(obj, content);
1291 case ELM_NAVIGATIONBAR_FUNCTION_BUTTON2:
1292 button = _elm_navigationbar_function_button2_get(obj, content);
1294 case ELM_NAVIGATIONBAR_FUNCTION_BUTTON3:
1295 button = _elm_navigationbar_function_button3_get(obj, content);
1297 case ELM_NAVIGATIONBAR_BACK_BUTTON:
1298 button = _elm_navigationbar_back_button_get(obj, content);
1307 * Set the sub title string for the pushed content.
1309 * @param[in] obj The NavigationBar object
1310 * @param[in] content The object to push or pushed
1311 * @param[in] subtitle The subtitle string
1313 * @ingroup NavigationBar
1316 elm_navigationbar_subtitle_label_set(Evas_Object *obj, Evas_Object *content, const char *subtitle)
1318 ELM_CHECK_WIDTYPE(obj, widtype);
1319 Widget_Data *wd = elm_widget_data_get(obj);
1324 EINA_LIST_FOREACH(wd->stack, ll, it)
1326 if (it->content == content)
1328 eina_stringshare_replace(&it->subtitle, subtitle);
1329 edje_object_part_text_set(wd->base, "elm.text.sub", subtitle);
1330 _item_sizing_eval(it);
1337 * Return the subtitle string of the pushed content.
1339 * @param[in] obj The NavigationBar object
1340 * @param[in] content The object to push or pushed
1341 * @return The subtitle string or NULL if none
1343 * @ingroup NavigationBar
1346 elm_navigationbar_subtitle_label_get(Evas_Object *obj, Evas_Object *content)
1348 ELM_CHECK_WIDTYPE(obj, widtype)NULL;
1349 Widget_Data *wd = elm_widget_data_get(obj);
1353 if (!wd) return NULL;
1354 EINA_LIST_FOREACH(wd->stack, ll, it)
1356 if (it->content == content)
1357 return it->subtitle;
1363 * This disables content area animation on push/pop.
1365 * @param[in] obj The NavigationBar object
1366 * @param[in] disable if EINA_TRUE animation is disabled.
1368 * @ingroup NavigationBar
1371 elm_navigationbar_animation_disable_set(Evas_Object *obj, Eina_Bool disable)
1373 ELM_CHECK_WIDTYPE(obj, widtype);
1374 Widget_Data *wd = elm_widget_data_get(obj);
1376 elm_pager_animation_disable_set(wd->pager, disable);