1 #include <Elementary.h>
5 * @defgroup NavigationBar NavigationBar
8 * The pager is an object that allows flipping (with animation) between 1 or
9 * more of objects, much like a stack of windows within the window.
11 * Objects can be pushed or popped from he stack or deleted as normal.
12 * Pushes and pops will animate (and a pop will delete the object once the
13 * animation is finished). Any object in the pager can be promoted to the top
14 * (from its current stacking position) as well. Objects are pushed to the
15 * top with elm_pager_content_push() and when the top item is no longer
16 * wanted, simply pop it with elm_pager_content_pop() and it will also be
17 * deleted. Any object you wish to promote to the top that is already in the
18 * pager, simply use elm_pager_content_promote(). If an object is no longer
19 * needed and is not the top item, just delete it as normal. You can query
20 * which objects are the top and bottom with elm_pager_content_bottom_get()
21 * and elm_pager_content_top_get().
24 typedef struct _Widget_Data Widget_Data;
25 typedef struct _Item Item;
26 typedef struct _Transit_Cb_Data Transit_Cb_Data;
41 Evas_Object *title_obj;
42 Eina_List *title_list;
46 Evas_Object *back_btn;
54 struct _Transit_Cb_Data
62 static const char *widtype = NULL;
64 static void _del_hook(Evas_Object *obj);
65 static void _theme_hook(Evas_Object *obj);
66 static void _sizing_eval(Evas_Object *obj);
67 static void _resize(void *data, Evas *e, Evas_Object *obj, void *event_info);
68 static void _item_sizing_eval(Item *it);
69 static void _delete_item(Item *it);
70 static void _back_button_clicked(void *data, Evas_Object *obj, void *event_info);
71 static int _set_button_width(Evas_Object *obj);
72 static Eina_Bool _button_set(Evas_Object *obj, Evas_Object *prev_btn, Evas_Object *new_btn, Eina_Bool back_btn);
73 static Evas_Object *_multiple_object_set(Evas_Object *obj, Evas_Object *sub_obj, Eina_List *list, int width);
74 static Item *_check_item_is_added(Evas_Object *obj, Evas_Object *content);
75 static void _transition_complete_cb(void *data);
76 static void _elm_navigationbar_back_button_set(Evas_Object *obj, Evas_Object *content, Evas_Object *button);
77 static Evas_Object *_elm_navigationbar_back_button_get(Evas_Object *obj, Evas_Object *content);
78 static void _elm_navigationbar_function_button1_set(Evas_Object *obj, Evas_Object *content, Evas_Object *button);
79 static Evas_Object *_elm_navigationbar_function_button1_get(Evas_Object *obj, Evas_Object *content);
80 static void _elm_navigationbar_function_button2_set(Evas_Object *obj, Evas_Object *content, Evas_Object *button);
81 static Evas_Object *_elm_navigationbar_function_button2_get(Evas_Object *obj, Evas_Object *content);
82 static void _elm_navigationbar_function_button3_set(Evas_Object *obj, Evas_Object *content, Evas_Object *button);
83 static Evas_Object *_elm_navigationbar_function_button3_get(Evas_Object *obj, Evas_Object *content);
86 _del_hook(Evas_Object *obj)
88 Widget_Data *wd = elm_widget_data_get(obj);
92 EINA_LIST_FOREACH(wd->stack, list, it)
94 eina_list_free(wd->stack);
99 _theme_hook(Evas_Object *obj)
101 Widget_Data *wd = elm_widget_data_get(obj);
102 Eina_List *list=NULL;
107 _elm_theme_object_set(obj, wd->base, "navigationbar", "base", elm_widget_style_get(obj));
108 edje_object_scale_set(wd->base, elm_widget_scale_get(obj) * _elm_config->scale);
109 EINA_LIST_FOREACH(wd->stack, list, it)
113 snprintf(buf_fn, sizeof(buf_fn), "navigationbar_functionbutton/%s", elm_widget_style_get(obj));
114 elm_object_style_set(it->fn_btn1, buf_fn);
118 snprintf(buf_fn, sizeof(buf_fn), "navigationbar_functionbutton/%s", elm_widget_style_get(obj));
119 elm_object_style_set(it->fn_btn2, buf_fn);
123 snprintf(buf_fn, sizeof(buf_fn), "navigationbar_functionbutton/%s", elm_widget_style_get(obj));
124 elm_object_style_set(it->fn_btn3, buf_fn);
126 snprintf(buf_bk, sizeof(buf_bk), "navigationbar_backbutton/%s", elm_widget_style_get(obj));
127 elm_object_style_set(it->back_btn, buf_bk);
129 edje_object_message_signal_process(wd->base);
134 _delete_item(Item *it)
138 Evas_Object *list_obj;
139 evas_object_del(it->back_btn);
140 evas_object_del(it->fn_btn1);
141 evas_object_del(it->fn_btn2);
142 evas_object_del(it->fn_btn3);
143 if (it->title) eina_stringshare_del(it->title);
144 if (it->subtitle) eina_stringshare_del(it->subtitle);
145 EINA_LIST_FOREACH(it->title_list, ll, list_obj)
146 evas_object_del(list_obj);
147 eina_list_free(it->title_list);
152 _sizing_eval(Evas_Object *obj)
154 Widget_Data *wd = elm_widget_data_get(obj);
155 Evas_Coord minw = -1, minh = -1;
156 Evas_Coord w = -1, h = -1;
159 edje_object_size_min_calc(wd->base, &minw, &minh);
160 evas_object_size_hint_min_get(obj, &w, &h);
161 if (w > minw) minw = w;
162 if (h > minw) minh = h;
164 evas_object_size_hint_min_set(obj, minw, minh);
165 evas_object_size_hint_max_set(obj, -1, -1);
167 list = eina_list_last(wd->stack);
170 Item *it = list->data;
171 _item_sizing_eval(it);
176 _item_sizing_eval(Item *it)
178 Widget_Data *wd = elm_widget_data_get(it->obj);
179 Evas_Coord pad, height, minw, w;
184 edje_object_size_min_calc(wd->base, &minw, NULL);
185 evas_object_geometry_get(wd->base, NULL, NULL, &w, NULL);
186 if (w < minw) w = minw;
188 edje_object_part_geometry_get(wd->base, "elm.rect.pad1", NULL, NULL, &pad, NULL);
189 edje_object_part_geometry_get(wd->base, "elm.swallow.title", NULL, NULL, NULL, &height);
193 it->fn_btn1_w = _set_button_width(it->fn_btn1);
196 else if (it->back_btn)
198 it->fn_btn1_w = _set_button_width(it->back_btn);
203 it->fn_btn2_w = _set_button_width(it->fn_btn2);
208 it->fn_btn3_w = _set_button_width(it->fn_btn3);
213 it->title_w = _set_button_width(it->title_obj);
214 it->title_obj = _multiple_object_set(it->obj, it->title_obj, it->title_list, it->title_w);
215 evas_object_resize(it->title_obj, it->title_w, height);
216 evas_object_size_hint_min_set(it->title_obj, it->title_w, height);
221 _resize(void *data, Evas *e, Evas_Object *obj, void *event_info)
227 _transition_complete_cb(void *data)
229 Transit_Cb_Data *cb = data;
231 Evas_Object *navi_bar = NULL;
232 Evas_Object *content = NULL;
233 Widget_Data *wd = NULL;
234 Item *prev_it = cb->prev_it;
238 navi_bar = prev_it->obj;
244 wd = elm_widget_data_get(navi_bar);
245 if (cb->pop && prev_it)
248 ll = eina_list_last(wd->stack);
249 if (ll->data == prev_it)
251 _delete_item(prev_it);
252 wd->stack = eina_list_remove_list(wd->stack, ll);
257 evas_object_hide(prev_it->fn_btn1);
258 evas_object_hide(prev_it->back_btn);
259 evas_object_hide(prev_it->title_obj);
260 evas_object_hide(prev_it->fn_btn2);
261 evas_object_hide(prev_it->fn_btn3);
263 if ((it)&&(!wd->hidden))
265 edje_object_part_text_set(wd->base, "elm.text", it->title);
270 edje_object_signal_emit(wd->base, "elm,action,pop", "elm");
274 edje_object_signal_emit(wd->base, "elm,action,push", "elm");
277 edje_object_signal_emit(wd->base, "elm,state,rect,enabled", "elm");
281 edje_object_part_swallow(wd->base, "elm.swallow.title", it->title_obj);
282 edje_object_signal_emit(wd->base, "elm,state,retract,title", "elm");
286 edje_object_signal_emit(wd->base, "elm,state,retract,title", "elm");
290 edje_object_part_text_set(wd->base, "elm.text.sub", it->subtitle);
293 edje_object_part_text_set(wd->base, "elm.text.sub", NULL);
296 edje_object_signal_emit(wd->base, "elm,state,item,add,leftpad", "elm");
297 edje_object_part_swallow(wd->base, "elm.swallow.btn1", it->fn_btn1);
299 else if (it->back_btn)
301 edje_object_signal_emit(wd->base, "elm,state,item,add,leftpad", "elm");
302 edje_object_part_swallow(wd->base, "elm.swallow.btn1", it->back_btn);
305 edje_object_signal_emit(wd->base, "elm,state,item,reset,leftpad", "elm");
309 edje_object_signal_emit(wd->base, "elm,state,item,add,rightpad", "elm");
310 edje_object_part_swallow(wd->base, "elm.swallow.btn2", it->fn_btn2);
313 edje_object_signal_emit(wd->base, "elm,state,item,reset,rightpad", "elm");
317 edje_object_signal_emit(wd->base, "elm,state,item,add,rightpad2", "elm");
318 edje_object_signal_emit(wd->base, "elm,state,item,fn_btn3_set", "elm");
319 edje_object_part_swallow(wd->base, "elm.swallow.btn3", it->fn_btn3);
322 edje_object_signal_emit(wd->base, "elm,state,item,reset,rightpad2", "elm");
324 if((it->title_obj)&&(it->title))
326 edje_object_signal_emit(wd->base, "elm,state,extend,title", "elm");
328 content = it->content;
330 edje_object_message_signal_process(wd->base);
334 _back_button_clicked(void *data, Evas_Object *obj, void *event_info)
337 elm_navigationbar_pop(it->obj);
341 _hide_finished(void *data, Evas_Object *obj, void *event_info)
343 Evas_Object *navi_bar = data;
344 Widget_Data *wd = elm_widget_data_get(navi_bar);
345 evas_object_smart_callback_call(navi_bar, "hide,finished", event_info);
346 edje_object_signal_emit(wd->base, "elm,state,rect,disabled", "elm");
350 _set_button_width(Evas_Object *obj)
352 Evas_Coord minw = -1, minh = -1, maxw= -1, maxh = -1;
353 Evas_Coord w = 0, h = 0;
355 evas_object_size_hint_min_get(obj, &minw, &minh);
356 evas_object_size_hint_max_get(obj, &maxw, &maxh);
357 evas_object_geometry_get(obj, NULL, NULL, &w, &h);
359 if (w < minw) w = minw;
360 if (h < minh) h = minh;
361 if ((maxw >= 0) && (w > maxw)) w = maxw;
362 if ((maxh >= 0) && (h > maxh)) h = maxh;
364 evas_object_resize(obj, w, h);
369 _button_set(Evas_Object *obj, Evas_Object *prev_btn, Evas_Object *new_btn, Eina_Bool back_btn)
372 Eina_Bool changed = EINA_FALSE;
373 if(prev_btn == new_btn)
378 evas_object_del(prev_btn);
385 snprintf(buf, sizeof(buf), "navigationbar_backbutton/%s", elm_widget_style_get(obj));
386 elm_object_style_set(new_btn, buf);
390 snprintf(buf, sizeof(buf), "navigationbar_functionbutton/%s", elm_widget_style_get(obj));
391 elm_object_style_set(new_btn, buf);
393 elm_widget_sub_object_add(obj, new_btn);
394 elm_object_focus_allow_set(new_btn, EINA_FALSE);
401 _check_item_is_added(Evas_Object *obj, Evas_Object *content)
403 Widget_Data *wd = elm_widget_data_get(obj);
406 EINA_LIST_FOREACH(wd->stack, ll, it)
408 if (it->content == content)
417 _multiple_object_set(Evas_Object *obj, Evas_Object *sub_obj, Eina_List *list, int width)
419 Widget_Data *wd = elm_widget_data_get(obj);
421 Evas_Object *new_obj, *list_obj;
422 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);
442 memset(buf, 0, sizeof(buf));
443 sprintf(buf, "elm,state,item,add,%d", num);
444 edje_object_signal_emit(elm_layout_edje_get(new_obj), buf, "elm");
446 memset(buf, 0, sizeof(buf));
447 sprintf(buf, "elm.swallow.title%d", num++);
448 elm_layout_content_set(new_obj, buf, list_obj);
454 _multiple_object_unset(Item *it, Eina_List **list)
456 Evas_Object *list_obj = NULL;
458 Evas_Object *temp_obj;
463 EINA_LIST_FOREACH(it->title_list, l, list_obj)
465 memset(buf, 0, sizeof(buf));
466 sprintf(buf, "elm.swallow.title%d", num++);
467 temp_obj = elm_layout_content_unset(it->title_obj, buf);
468 *list = eina_list_append(*list, temp_obj);
469 evas_object_hide(temp_obj);
471 eina_list_free(it->title_list);
472 it->title_list = NULL;
478 * Add a new navigationbar to the parent
480 * @param[in] parent The parent object
481 * @return The new object or NULL if it cannot be created
483 * @ingroup NavigationBar
486 elm_navigationbar_add(Evas_Object *parent)
492 wd = ELM_NEW(Widget_Data);
493 e = evas_object_evas_get(parent);
494 obj = elm_widget_add(e);
495 ELM_SET_WIDTYPE(widtype, "navigationbar");
496 elm_widget_type_set(obj, "navigationbar");
497 elm_widget_sub_object_add(parent, obj);
498 elm_widget_data_set(obj, wd);
499 elm_widget_del_hook_set(obj, _del_hook);
500 elm_widget_theme_hook_set(obj, _theme_hook);
502 wd->base = edje_object_add(e);
503 _elm_theme_object_set(obj, wd->base, "navigationbar", "base", "default");
504 elm_widget_resize_object_set(obj, wd->base);
506 wd->pager = elm_pager_add(obj);
507 elm_object_style_set(wd->pager, "navigationbar");
508 elm_widget_sub_object_add(obj, wd->pager);
509 edje_object_part_swallow(wd->base, "elm.swallow.content", wd->pager);
510 evas_object_smart_callback_add(wd->pager, "hide,finished", _hide_finished, obj);
511 evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE, _resize, NULL);
518 * Push an object to the top of the NavigationBar stack (and show it)
519 * The object pushed becomes a child of the navigationbar and will be controlled
520 * it is deleted when the navigationbar is deleted or when the content is popped.
522 * @param[in] obj The NavigationBar object
523 * @param[in] title The title string
524 * @param[in] fn_btn1 The left button
525 * @param[in] fn_btn2 The right button
526 * @param[in] fn_btn3 The button placed before right most button.
527 * @param[in] content The object to push
529 * @ingroup NavigationBar
532 elm_navigationbar_push(Evas_Object *obj,
534 Evas_Object *fn_btn1,
535 Evas_Object *fn_btn2,
536 Evas_Object *fn_btn3,
537 Evas_Object *content)
539 ELM_CHECK_WIDTYPE(obj, widtype);
540 Widget_Data *wd = elm_widget_data_get(obj);
543 Item *prev_it = NULL;
546 it = _check_item_is_added(obj, content);
548 if (!it) it = ELM_NEW(Item);
551 // add and set new items
552 _button_set(obj, NULL, fn_btn1, EINA_FALSE);
553 _button_set(obj, NULL, fn_btn2, EINA_FALSE);
554 _button_set(obj, NULL, fn_btn3, EINA_FALSE);
556 ll = eina_list_last(wd->stack);
562 it->fn_btn1 = fn_btn1;
563 it->fn_btn2 = fn_btn2;
564 it->fn_btn3 = fn_btn3;
565 it->content = content;
567 if (!fn_btn1 && prev_it)
569 char *prev_title = NULL;
571 it->back_btn = elm_button_add(obj);
572 prev_title = (char *)prev_it->title;
575 elm_button_label_set(it->back_btn, prev_title);
579 elm_button_label_set(it->back_btn, "Previous");
581 evas_object_smart_callback_add(it->back_btn, "clicked", _back_button_clicked, it);
582 _button_set(obj, NULL, it->back_btn, EINA_TRUE);
585 eina_stringshare_replace(&it->title, title);
586 edje_object_part_text_set(wd->base, "elm.text", title);
587 _item_sizing_eval(it);
589 Transit_Cb_Data *cb = ELM_NEW(Transit_Cb_Data);
590 // unswallow items and start transition
593 cb->prev_it = prev_it;
595 cb->pop = EINA_FALSE;
596 cb->first_page = EINA_FALSE;
597 if (prev_it->title_obj) edje_object_part_unswallow(wd->base, prev_it->title_obj);
598 if (prev_it->fn_btn1) edje_object_part_unswallow(wd->base, prev_it->fn_btn1);
599 else if (prev_it->back_btn) edje_object_part_unswallow(wd->base, prev_it->back_btn);
600 if (prev_it->fn_btn2) edje_object_part_unswallow(wd->base, prev_it->fn_btn2);
601 if (prev_it->fn_btn3) edje_object_part_unswallow(wd->base, prev_it->fn_btn3);
607 cb->pop = EINA_FALSE;
608 cb->first_page = EINA_TRUE;
610 _transition_complete_cb(cb);
612 elm_pager_content_push(wd->pager, it->content);
613 //push item into the stack. it should be always the tail
614 if (!_check_item_is_added(obj, content))
615 wd->stack = eina_list_append(wd->stack, it);
618 EINA_LIST_FOREACH(wd->stack, ll, it)
620 if (it->content == content)
622 wd->stack = eina_list_demote_list(wd->stack, ll);
631 * This pops the object that is on top (visible) in the navigationbar, makes it disappear, then deletes the object.
632 * The object that was underneath it, on the stack will become visible.
634 * @param[in] obj The NavigationBar object
636 * @ingroup NavigationBar
639 elm_navigationbar_pop(Evas_Object *obj)
641 ELM_CHECK_WIDTYPE(obj, widtype);
642 Widget_Data *wd = elm_widget_data_get(obj);
645 Item *prev_it = NULL;
647 if (!wd->stack) return;
649 //find item to be popped and to be shown
650 ll = eina_list_last(wd->stack);
660 //unswallow items and start trasition
661 Transit_Cb_Data *cb = ELM_NEW(Transit_Cb_Data);
664 cb->prev_it = prev_it;
667 if (prev_it->title_obj) edje_object_part_unswallow(wd->base, prev_it->title_obj);
668 if (prev_it->fn_btn1) edje_object_part_unswallow(wd->base, prev_it->fn_btn1);
669 else if (prev_it->back_btn) edje_object_part_unswallow(wd->base, prev_it->back_btn);
670 if (prev_it->fn_btn2) edje_object_part_unswallow(wd->base, prev_it->fn_btn2);
671 if (prev_it->fn_btn3) edje_object_part_unswallow(wd->base, prev_it->fn_btn3);
672 _item_sizing_eval(it);
677 cb->prev_it = prev_it;
680 cb->first_page = EINA_FALSE;
682 _transition_complete_cb(cb);
683 //pop content from pager
684 elm_pager_content_pop(wd->pager);
687 //evas_object_del(wd->pager);
688 edje_object_part_text_set(wd->base, "elm.text", NULL);
694 * This Pops to the given content object (and update it) by deleting rest of the objects in between.
696 * @param[in] obj The NavigationBar object
697 * @param[in] content the object to show
699 * @ingroup NavigationBar
702 elm_navigationbar_to_content_pop(Evas_Object *obj,
703 Evas_Object *content)
705 ELM_CHECK_WIDTYPE(obj, widtype);
707 Widget_Data *wd = elm_widget_data_get(obj);
710 Item *prev_it = NULL;
712 if (!wd->stack) return;
714 //find item to be popped and to be shown
715 ll = eina_list_last(wd->stack);
723 if (it->obj && (it->content != content))
725 _delete_item(ll->data);
726 wd->stack = eina_list_remove_list(wd->stack, ll);
738 //unswallow items and start trasition
739 Transit_Cb_Data *cb = ELM_NEW(Transit_Cb_Data);
740 cb->prev_it = prev_it;
743 cb->first_page = EINA_FALSE;
744 if (prev_it->title_obj) edje_object_part_unswallow(wd->base, prev_it->title_obj);
745 if (prev_it->fn_btn1) edje_object_part_unswallow(wd->base, prev_it->fn_btn1);
746 else if (prev_it->back_btn) edje_object_part_unswallow(wd->base, prev_it->back_btn);
747 if (prev_it->fn_btn2) edje_object_part_unswallow(wd->base, prev_it->fn_btn2);
748 if (prev_it->fn_btn3) edje_object_part_unswallow(wd->base, prev_it->fn_btn3);
749 _item_sizing_eval(it);
750 _transition_complete_cb(cb);
751 //pop content from pager
752 elm_pager_to_content_pop(wd->pager, content);
757 * Set the title string for the pushed content
759 * @param[in] obj The NavigationBar object
760 * @param[in] content The object to push or pushed
761 * @param[in] title The title string
763 * @ingroup NavigationBar
766 elm_navigationbar_title_label_set(Evas_Object *obj,
767 Evas_Object *content,
770 ELM_CHECK_WIDTYPE(obj, widtype);
771 Widget_Data *wd = elm_widget_data_get(obj);
777 EINA_LIST_FOREACH(wd->stack, ll, it)
779 if (it->content == content)
781 eina_stringshare_replace(&it->title, title);
782 edje_object_part_text_set(wd->base, "elm.text", title);
785 if((it->title_obj)&&(it->title)){
786 edje_object_signal_emit(wd->base, "elm,state,extend,title", "elm");
789 edje_object_signal_emit(wd->base, "elm,state,retract,title", "elm");
791 _item_sizing_eval(it);
798 * Return the title string of the pushed content
800 * @param[in] obj The NavigationBar object
801 * @param[in] content The object to push or pushed
802 * @return The title string or NULL if none
804 * @ingroup NavigationBar
807 elm_navigationbar_title_label_get(Evas_Object *obj,
808 Evas_Object *content)
810 ELM_CHECK_WIDTYPE(obj, widtype)NULL;
811 Widget_Data *wd = elm_widget_data_get(obj);
815 if (!wd) return NULL;
817 EINA_LIST_FOREACH(wd->stack, ll, it)
819 if (it->content == content)
826 * Add a title object for the content.
828 * @param[in] obj The NavigationBar object
829 * @param[in] content The object pushed
830 * @param[in] title_obj a title object (normally button or segment_control)
832 * @ingroup NavigationBar
835 elm_navigationbar_title_object_add(Evas_Object *obj,
836 Evas_Object *content,
837 Evas_Object *title_obj)
839 ELM_CHECK_WIDTYPE(obj, widtype);
840 Widget_Data *wd = elm_widget_data_get(obj);
845 if (!title_obj) return;
846 if (!content) return;
848 it = _check_item_is_added(obj, content);
851 ERR("[ERROR]Push the Item first, later add the title object");
855 it->title_list = eina_list_append(it->title_list, title_obj);
856 if(it->obj) _item_sizing_eval(it);
857 //update if the content is the top item
858 ll = eina_list_last(wd->stack);
862 if (last_it->content == content)
864 Evas_Object *swallow;
865 swallow = edje_object_part_swallow_get(wd->base, "elm.swallow.title");
867 edje_object_part_unswallow(wd->base, swallow);
868 evas_object_hide(swallow);
870 edje_object_part_swallow(wd->base, "elm.swallow.title", it->title_obj);
874 edje_object_signal_emit(wd->base, "elm,state,item,add,rightpad2", "elm");
875 edje_object_signal_emit(wd->base, "elm,state,item,fn_btn3_set", "elm");
877 if((it->title_obj)&&(it->title)){
878 edje_object_signal_emit(wd->base, "elm,state,extend,title", "elm");
881 _item_sizing_eval(it);
887 * Unset the list of title objects corresponding to given content and returns it to
889 * @param[in] obj The NavigationBar object
890 * @param[in] content The object pushed
891 * @param[in] title_obj a title object (normally button or segment_control)
892 * @param[out] list updates the list with title objects list, this list has to be freed and the
893 * objects have to be deleted by application.
894 * @ingroup NavigationBar
897 elm_navigationbar_title_object_list_unset(Evas_Object *obj,
898 Evas_Object *content, Eina_List **list)
900 ELM_CHECK_WIDTYPE(obj, widtype);
901 Widget_Data *wd = elm_widget_data_get(obj);
904 Item *last_it = NULL;
905 ll = eina_list_last(wd->stack);
912 EINA_LIST_FOREACH(wd->stack, ll, it)
914 if (it->content == content)
916 if (last_it->content == it->content)
918 Evas_Object *swallow;
919 swallow = edje_object_part_swallow_get(wd->base, "elm.swallow.title");
921 edje_object_part_unswallow(wd->base, swallow);
922 evas_object_hide(swallow);
925 _multiple_object_unset(it, list);
926 evas_object_del(it->title_obj);
927 it->title_obj = NULL;
930 edje_object_signal_emit(wd->base, "elm,state,retract,title", "elm");
933 edje_object_signal_emit(wd->base, "elm,state,item,add,rightpad2", "elm");
934 edje_object_signal_emit(wd->base, "elm,state,item,fn_btn3_set", "elm");
937 _item_sizing_eval(it);
945 * Return the list of title objects of the pushed content.
947 * @param[in] obj The NavigationBar object
948 * @param[in] content The object to push or pushed
949 * @return The list of title objects
951 * @ingroup NavigationBar
954 elm_navigationbar_title_object_list_get(Evas_Object *obj,
955 Evas_Object *content)
957 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
958 Widget_Data *wd = elm_widget_data_get(obj);
962 if (!wd) return NULL;
963 EINA_LIST_FOREACH(wd->stack, ll, it)
965 if (it->content == content)
966 return it->title_list;
972 _elm_navigationbar_back_button_set(Evas_Object *obj,
973 Evas_Object *content,
976 Widget_Data *wd = elm_widget_data_get(obj);
983 EINA_LIST_FOREACH(wd->stack, ll, it)
985 if (it->content == content)
987 changed = _button_set(obj, it->back_btn, button, EINA_TRUE);
988 it->back_btn = button;
989 _item_sizing_eval(it);
994 //update if the content is the top item
995 ll = eina_list_last(wd->stack);
999 if (it->back_btn && changed && (it->content == content) && (!it->fn_btn1))
1001 edje_object_part_swallow(wd->base, "elm.swallow.btn1", it->back_btn);
1002 evas_object_smart_callback_add(it->back_btn, "clicked", _back_button_clicked, it);
1007 static Evas_Object *
1008 _elm_navigationbar_back_button_get(Evas_Object *obj,
1009 Evas_Object *content)
1011 Widget_Data *wd = elm_widget_data_get(obj);
1015 if (!wd) return NULL;
1017 EINA_LIST_FOREACH(wd->stack, ll, it)
1019 if (it->content == content)
1020 return it->back_btn;
1026 _elm_navigationbar_function_button1_set(Evas_Object *obj,
1027 Evas_Object *content,
1028 Evas_Object *button)
1030 Widget_Data *wd = elm_widget_data_get(obj);
1037 EINA_LIST_FOREACH(wd->stack, ll, it)
1039 if (it->content == content)
1041 changed = _button_set(obj, it->fn_btn1, button, EINA_FALSE);
1042 it->fn_btn1 = button;
1043 _item_sizing_eval(it);
1048 //update if the content is the top item
1049 ll = eina_list_last(wd->stack);
1053 if (it->fn_btn1 && changed && (it->content == content))
1055 if (edje_object_part_swallow_get(wd->base, "elm.swallow.btn1") == it->back_btn)
1057 edje_object_part_unswallow(wd->base, it->back_btn);
1058 evas_object_del(it->back_btn);
1059 it->back_btn = NULL;
1061 edje_object_part_swallow(wd->base, "elm.swallow.btn1", it->fn_btn1);
1066 static Evas_Object *
1067 _elm_navigationbar_function_button1_get(Evas_Object *obj,
1068 Evas_Object *content)
1070 Widget_Data *wd = elm_widget_data_get(obj);
1074 if (!wd) return NULL;
1076 EINA_LIST_FOREACH(wd->stack, ll, it)
1078 if (it->content == content)
1085 _elm_navigationbar_function_button2_set(Evas_Object *obj,
1086 Evas_Object *content,
1087 Evas_Object *button)
1089 Widget_Data *wd = elm_widget_data_get(obj);
1095 EINA_LIST_FOREACH(wd->stack, ll, it)
1097 if (it->content == content)
1099 changed = _button_set(obj, it->fn_btn2, button, EINA_FALSE);
1100 it->fn_btn2 = button;
1101 _item_sizing_eval(it);
1106 //update if the content is the top item
1107 ll = eina_list_last(wd->stack);
1111 if (it->fn_btn2 && changed && (it->content == content))
1113 edje_object_part_swallow(wd->base, "elm.swallow.btn2", it->fn_btn2);
1118 static Evas_Object *
1119 _elm_navigationbar_function_button2_get(Evas_Object *obj,
1120 Evas_Object *content)
1122 Widget_Data *wd = elm_widget_data_get(obj);
1126 if (!wd) return NULL;
1128 EINA_LIST_FOREACH(wd->stack, ll, it)
1130 if (it->content == content)
1137 _elm_navigationbar_function_button3_set(Evas_Object *obj,
1138 Evas_Object *content,
1139 Evas_Object *button)
1141 Widget_Data *wd = elm_widget_data_get(obj);
1148 EINA_LIST_FOREACH(wd->stack, ll, it)
1150 if (it->content == content)
1152 changed = _button_set(obj, it->fn_btn3, button, EINA_FALSE);
1153 it->fn_btn3 = button;
1154 _item_sizing_eval(it);
1159 //update if the content is the top item
1160 ll = eina_list_last(wd->stack);
1164 if (it->fn_btn3 && changed && (it->content == content))
1166 edje_object_part_swallow(wd->base, "elm.swallow.btn3", it->fn_btn3);
1171 static Evas_Object *
1172 _elm_navigationbar_function_button3_get(Evas_Object *obj,
1173 Evas_Object *content)
1175 Widget_Data *wd = elm_widget_data_get(obj);
1179 if (!wd) return NULL;
1181 EINA_LIST_FOREACH(wd->stack, ll, it)
1183 if (it->content == content)
1190 * Return the content object at the top of the NavigationBar stack
1192 * @param[in] obj The NavigationBar object
1193 * @return The top content object or NULL if none
1195 * @ingroup NavigationBar
1198 elm_navigationbar_content_top_get(Evas_Object *obj)
1200 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1201 Widget_Data *wd = elm_widget_data_get(obj);
1202 if (!wd) return NULL;
1204 return elm_pager_content_top_get(wd->pager);
1208 * Return the content object at the bottom of the NavigationBar stack
1210 * @param[in] obj The NavigationBar object
1211 * @return The bottom content object or NULL if none
1213 * @ingroup NavigationBar
1216 elm_navigationbar_content_bottom_get(Evas_Object *obj)
1218 ELM_CHECK_WIDTYPE(obj, widtype)NULL;
1219 Widget_Data *wd = elm_widget_data_get(obj);
1220 if (!wd) return NULL;
1222 return elm_pager_content_bottom_get(wd->pager);
1226 * This hides the title area of navigationbar.
1228 * @param[in] obj The NavigationBar object
1229 * @param[in] hidden if EINA_TRUE the title area is hidden.
1231 * @ingroup NavigationBar
1234 elm_navigationbar_hidden_set(Evas_Object *obj,
1237 ELM_CHECK_WIDTYPE(obj, widtype);
1238 Widget_Data *wd = elm_widget_data_get(obj);
1241 if (hidden) edje_object_signal_emit(wd->base, "elm,state,item,moveup", "elm");
1242 else edje_object_signal_emit(wd->base, "elm,state,item,movedown", "elm");
1243 wd->hidden = hidden;
1247 * Set the button object of the pushed content.
1249 * @param[in] obj The NavigationBar object
1250 * @param[in] content The object to push or pushed
1251 * @param[in] button The button
1252 * @param[in] button_type Indicates the position
1254 * @ingroup NavigationBar
1257 elm_navigationbar_title_button_set(Evas_Object *obj,
1258 Evas_Object *content,
1259 Evas_Object *button,
1260 Elm_Navi_Button_Type button_type)
1262 ELM_CHECK_WIDTYPE(obj, widtype);
1263 if(!content) return;
1266 case ELM_NAVIGATIONBAR_FUNCTION_BUTTON1:
1267 _elm_navigationbar_function_button1_set(obj, content, button);
1269 case ELM_NAVIGATIONBAR_FUNCTION_BUTTON2:
1270 _elm_navigationbar_function_button2_set(obj, content, button);
1272 case ELM_NAVIGATIONBAR_FUNCTION_BUTTON3:
1273 _elm_navigationbar_function_button3_set(obj, content, button);
1275 case ELM_NAVIGATIONBAR_BACK_BUTTON:
1276 _elm_navigationbar_back_button_set(obj, content, button);
1285 * Return the button object of the pushed content
1287 * @param[in] obj The NavigationBar object
1288 * @param[in] content The object to push or pushed
1289 * @param[in] button_type Indicates the position
1290 * @return The button object or NULL if none
1292 * @ingroup NavigationBar
1295 elm_navigationbar_title_button_get(Evas_Object *obj,
1296 Evas_Object *content,Elm_Navi_Button_Type button_type)
1298 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1299 Evas_Object *button=NULL;
1300 if(!content || !obj) return NULL;
1303 case ELM_NAVIGATIONBAR_FUNCTION_BUTTON1:
1304 button = _elm_navigationbar_function_button1_get(obj, content);
1306 case ELM_NAVIGATIONBAR_FUNCTION_BUTTON2:
1307 button = _elm_navigationbar_function_button2_get(obj, content);
1309 case ELM_NAVIGATIONBAR_FUNCTION_BUTTON3:
1310 button = _elm_navigationbar_function_button3_get(obj, content);
1312 case ELM_NAVIGATIONBAR_BACK_BUTTON:
1313 button = _elm_navigationbar_back_button_get(obj, content);
1322 * Set the sub title string for the pushed content.
1324 * @param[in] obj The NavigationBar object
1325 * @param[in] content The object to push or pushed
1326 * @param[in] subtitle The subtitle string
1328 * @ingroup NavigationBar
1331 elm_navigationbar_subtitle_label_set(Evas_Object *obj,
1332 Evas_Object *content,
1333 const char *subtitle)
1335 ELM_CHECK_WIDTYPE(obj, widtype);
1336 Widget_Data *wd = elm_widget_data_get(obj);
1342 EINA_LIST_FOREACH(wd->stack, ll, it)
1344 if (it->content == content)
1346 eina_stringshare_replace(&it->subtitle, subtitle);
1347 edje_object_part_text_set(wd->base, "elm.text.sub", subtitle);
1348 _item_sizing_eval(it);
1355 * Return the subtitle string of the pushed content.
1357 * @param[in] obj The NavigationBar object
1358 * @param[in] content The object to push or pushed
1359 * @return The subtitle string or NULL if none
1361 * @ingroup NavigationBar
1364 elm_navigationbar_subtitle_label_get(Evas_Object *obj,
1365 Evas_Object *content)
1367 ELM_CHECK_WIDTYPE(obj, widtype)NULL;
1368 Widget_Data *wd = elm_widget_data_get(obj);
1372 if (!wd) return NULL;
1374 EINA_LIST_FOREACH(wd->stack, ll, it)
1376 if (it->content == content)
1377 return it->subtitle;
1383 * This disables content area animation on push/pop.
1385 * @param[in] obj The NavigationBar object
1386 * @param[in] disable if EINA_TRUE animation is disabled.
1388 * @ingroup NavigationBar
1391 elm_navigationbar_animation_disable_set(Evas_Object *obj,
1394 ELM_CHECK_WIDTYPE(obj, widtype);
1395 Widget_Data *wd = elm_widget_data_get(obj);
1396 elm_pager_animation_disable_set(wd->pager, disable);