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 void _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)
375 evas_object_del(prev_btn);
382 snprintf(buf, sizeof(buf), "navigationbar_backbutton/%s", elm_widget_style_get(obj));
383 elm_object_style_set(new_btn, buf);
387 snprintf(buf, sizeof(buf), "navigationbar_functionbutton/%s", elm_widget_style_get(obj));
388 elm_object_style_set(new_btn, buf);
390 elm_widget_sub_object_add(obj, new_btn);
391 elm_object_focus_allow_set(new_btn, EINA_FALSE);
397 _check_item_is_added(Evas_Object *obj, Evas_Object *content)
399 Widget_Data *wd = elm_widget_data_get(obj);
402 EINA_LIST_FOREACH(wd->stack, ll, it)
404 if (it->content == content)
413 _multiple_object_set(Evas_Object *obj, Evas_Object *sub_obj, Eina_List *list, int width)
415 Widget_Data *wd = elm_widget_data_get(obj);
417 Evas_Object *new_obj, *list_obj;
418 Evas_Coord pad, height;
422 edje_object_part_geometry_get(wd->base, "elm.rect.pad1", NULL, NULL, &pad, NULL);
423 edje_object_part_geometry_get(wd->base, "elm.swallow.title", NULL, NULL, NULL, &height);
426 new_obj = elm_layout_add(obj);
427 elm_widget_sub_object_add(obj, new_obj);
428 elm_layout_theme_set(new_obj, "navigationbar", "title", elm_widget_style_get(obj));
432 count = eina_list_count(list);
433 EINA_LIST_FOREACH(list, ll, list_obj)
435 evas_object_resize(list_obj, (width-(count-1)*pad)/count, height);
436 evas_object_size_hint_min_set(list_obj, (width-(count-1)*pad)/count, height);
438 memset(buf, 0, sizeof(buf));
439 sprintf(buf, "elm,state,item,add,%d", num);
440 edje_object_signal_emit(elm_layout_edje_get(new_obj), buf, "elm");
442 memset(buf, 0, sizeof(buf));
443 sprintf(buf, "elm.swallow.title%d", num++);
444 elm_layout_content_set(new_obj, buf, list_obj);
450 _multiple_object_unset(Item *it, Eina_List **list)
452 Evas_Object *list_obj = NULL;
454 Evas_Object *temp_obj;
459 EINA_LIST_FOREACH(it->title_list, l, list_obj)
461 memset(buf, 0, sizeof(buf));
462 sprintf(buf, "elm.swallow.title%d", num++);
463 temp_obj = elm_layout_content_unset(it->title_obj, buf);
464 *list = eina_list_append(*list, temp_obj);
465 evas_object_hide(temp_obj);
467 eina_list_free(it->title_list);
468 it->title_list = NULL;
474 * Add a new navigationbar to the parent
476 * @param[in] parent The parent object
477 * @return The new object or NULL if it cannot be created
479 * @ingroup NavigationBar
482 elm_navigationbar_add(Evas_Object *parent)
488 wd = ELM_NEW(Widget_Data);
489 e = evas_object_evas_get(parent);
490 obj = elm_widget_add(e);
491 ELM_SET_WIDTYPE(widtype, "navigationbar");
492 elm_widget_type_set(obj, "navigationbar");
493 elm_widget_sub_object_add(parent, obj);
494 elm_widget_data_set(obj, wd);
495 elm_widget_del_hook_set(obj, _del_hook);
496 elm_widget_theme_hook_set(obj, _theme_hook);
498 wd->base = edje_object_add(e);
499 _elm_theme_object_set(obj, wd->base, "navigationbar", "base", "default");
500 elm_widget_resize_object_set(obj, wd->base);
502 wd->pager = elm_pager_add(obj);
503 elm_object_style_set(wd->pager, "navigationbar");
504 elm_widget_sub_object_add(obj, wd->pager);
505 edje_object_part_swallow(wd->base, "elm.swallow.content", wd->pager);
506 evas_object_smart_callback_add(wd->pager, "hide,finished", _hide_finished, obj);
507 evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE, _resize, NULL);
514 * Push an object to the top of the NavigationBar stack (and show it)
515 * The object pushed becomes a child of the navigationbar and will be controlled
516 * it is deleted when the navigationbar is deleted or when the content is popped.
518 * @param[in] obj The NavigationBar object
519 * @param[in] title The title string
520 * @param[in] fn_btn1 The left button
521 * @param[in] fn_btn2 The right button
522 * @param[in] fn_btn3 The button placed before right most button.
523 * @param[in] content The object to push
525 * @ingroup NavigationBar
528 elm_navigationbar_push(Evas_Object *obj,
530 Evas_Object *fn_btn1,
531 Evas_Object *fn_btn2,
532 Evas_Object *fn_btn3,
533 Evas_Object *content)
535 ELM_CHECK_WIDTYPE(obj, widtype);
536 Widget_Data *wd = elm_widget_data_get(obj);
539 Item *prev_it = NULL;
542 it = _check_item_is_added(obj, content);
544 if (!it) it = ELM_NEW(Item);
547 // add and set new items
548 _button_set(obj, NULL, fn_btn1, EINA_FALSE);
549 _button_set(obj, NULL, fn_btn2, EINA_FALSE);
550 _button_set(obj, NULL, fn_btn3, EINA_FALSE);
552 ll = eina_list_last(wd->stack);
558 it->fn_btn1 = fn_btn1;
559 it->fn_btn2 = fn_btn2;
560 it->fn_btn3 = fn_btn3;
561 it->content = content;
563 if (!fn_btn1 && prev_it)
565 char *prev_title = NULL;
567 it->back_btn = elm_button_add(obj);
568 prev_title = (char *)prev_it->title;
571 elm_button_label_set(it->back_btn, prev_title);
575 elm_button_label_set(it->back_btn, "Previous");
577 evas_object_smart_callback_add(it->back_btn, "clicked", _back_button_clicked, it);
578 _button_set(obj, NULL, it->back_btn, EINA_TRUE);
581 eina_stringshare_replace(&it->title, title);
582 edje_object_part_text_set(wd->base, "elm.text", title);
583 _item_sizing_eval(it);
585 Transit_Cb_Data *cb = ELM_NEW(Transit_Cb_Data);
586 // unswallow items and start transition
589 cb->prev_it = prev_it;
591 cb->pop = EINA_FALSE;
592 cb->first_page = EINA_FALSE;
593 if (prev_it->title_obj) edje_object_part_unswallow(wd->base, prev_it->title_obj);
594 if (prev_it->fn_btn1) edje_object_part_unswallow(wd->base, prev_it->fn_btn1);
595 else if (prev_it->back_btn) edje_object_part_unswallow(wd->base, prev_it->back_btn);
596 if (prev_it->fn_btn2) edje_object_part_unswallow(wd->base, prev_it->fn_btn2);
597 if (prev_it->fn_btn3) edje_object_part_unswallow(wd->base, prev_it->fn_btn3);
603 cb->pop = EINA_FALSE;
604 cb->first_page = EINA_TRUE;
606 _transition_complete_cb(cb);
608 elm_pager_content_push(wd->pager, it->content);
609 //push item into the stack. it should be always the tail
610 if (!_check_item_is_added(obj, content))
611 wd->stack = eina_list_append(wd->stack, it);
614 EINA_LIST_FOREACH(wd->stack, ll, it)
616 if (it->content == content)
618 wd->stack = eina_list_demote_list(wd->stack, ll);
627 * This pops the object that is on top (visible) in the navigationbar, makes it disappear, then deletes the object.
628 * The object that was underneath it, on the stack will become visible.
630 * @param[in] obj The NavigationBar object
632 * @ingroup NavigationBar
635 elm_navigationbar_pop(Evas_Object *obj)
637 ELM_CHECK_WIDTYPE(obj, widtype);
638 Widget_Data *wd = elm_widget_data_get(obj);
641 Item *prev_it = NULL;
643 if (!wd->stack) return;
645 //find item to be popped and to be shown
646 ll = eina_list_last(wd->stack);
656 //unswallow items and start trasition
657 Transit_Cb_Data *cb = ELM_NEW(Transit_Cb_Data);
660 cb->prev_it = prev_it;
663 if (prev_it->title_obj) edje_object_part_unswallow(wd->base, prev_it->title_obj);
664 if (prev_it->fn_btn1) edje_object_part_unswallow(wd->base, prev_it->fn_btn1);
665 else if (prev_it->back_btn) edje_object_part_unswallow(wd->base, prev_it->back_btn);
666 if (prev_it->fn_btn2) edje_object_part_unswallow(wd->base, prev_it->fn_btn2);
667 if (prev_it->fn_btn3) edje_object_part_unswallow(wd->base, prev_it->fn_btn3);
668 _item_sizing_eval(it);
673 cb->prev_it = prev_it;
676 cb->first_page = EINA_FALSE;
678 _transition_complete_cb(cb);
679 //pop content from pager
680 elm_pager_content_pop(wd->pager);
683 //evas_object_del(wd->pager);
684 edje_object_part_text_set(wd->base, "elm.text", NULL);
690 * This Pops to the given content object (and update it) by deleting rest of the objects in between.
692 * @param[in] obj The NavigationBar object
693 * @param[in] content the object to show
695 * @ingroup NavigationBar
698 elm_navigationbar_to_content_pop(Evas_Object *obj,
699 Evas_Object *content)
701 ELM_CHECK_WIDTYPE(obj, widtype);
703 Widget_Data *wd = elm_widget_data_get(obj);
706 Item *prev_it = NULL;
708 if (!wd->stack) return;
710 //find item to be popped and to be shown
711 ll = eina_list_last(wd->stack);
719 if (it->obj && (it->content != content))
721 _delete_item(ll->data);
722 wd->stack = eina_list_remove_list(wd->stack, ll);
734 //unswallow items and start trasition
735 Transit_Cb_Data *cb = ELM_NEW(Transit_Cb_Data);
736 cb->prev_it = prev_it;
739 cb->first_page = EINA_FALSE;
740 if (prev_it->title_obj) edje_object_part_unswallow(wd->base, prev_it->title_obj);
741 if (prev_it->fn_btn1) edje_object_part_unswallow(wd->base, prev_it->fn_btn1);
742 else if (prev_it->back_btn) edje_object_part_unswallow(wd->base, prev_it->back_btn);
743 if (prev_it->fn_btn2) edje_object_part_unswallow(wd->base, prev_it->fn_btn2);
744 if (prev_it->fn_btn3) edje_object_part_unswallow(wd->base, prev_it->fn_btn3);
745 _item_sizing_eval(it);
746 _transition_complete_cb(cb);
747 //pop content from pager
748 elm_pager_to_content_pop(wd->pager, content);
753 * Set the title string for the pushed content
755 * @param[in] obj The NavigationBar object
756 * @param[in] content The object to push or pushed
757 * @param[in] title The title string
759 * @ingroup NavigationBar
762 elm_navigationbar_title_label_set(Evas_Object *obj,
763 Evas_Object *content,
766 ELM_CHECK_WIDTYPE(obj, widtype);
767 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)){
782 edje_object_signal_emit(wd->base, "elm,state,extend,title", "elm");
785 edje_object_signal_emit(wd->base, "elm,state,retract,title", "elm");
787 _item_sizing_eval(it);
794 * Return the title string of the pushed content
796 * @param[in] obj The NavigationBar object
797 * @param[in] content The object to push or pushed
798 * @return The title string or NULL if none
800 * @ingroup NavigationBar
803 elm_navigationbar_title_label_get(Evas_Object *obj,
804 Evas_Object *content)
806 ELM_CHECK_WIDTYPE(obj, widtype)NULL;
807 Widget_Data *wd = elm_widget_data_get(obj);
811 if (!wd) return NULL;
813 EINA_LIST_FOREACH(wd->stack, ll, it)
815 if (it->content == content)
822 * Add a title object for the content.
824 * @param[in] obj The NavigationBar object
825 * @param[in] content The object pushed
826 * @param[in] title_obj a title object (normally button or segment_control)
828 * @ingroup NavigationBar
831 elm_navigationbar_title_object_add(Evas_Object *obj,
832 Evas_Object *content,
833 Evas_Object *title_obj)
835 ELM_CHECK_WIDTYPE(obj, widtype);
836 Widget_Data *wd = elm_widget_data_get(obj);
841 if (!title_obj) return;
842 if (!content) return;
844 it = _check_item_is_added(obj, content);
847 ERR("[ERROR]Push the Item first, later add the title object");
851 it->title_list = eina_list_append(it->title_list, title_obj);
852 if(it->obj) _item_sizing_eval(it);
853 //update if the content is the top item
854 ll = eina_list_last(wd->stack);
858 if (last_it->content == content)
860 Evas_Object *swallow;
861 swallow = edje_object_part_swallow_get(wd->base, "elm.swallow.title");
863 edje_object_part_unswallow(wd->base, swallow);
864 evas_object_hide(swallow);
866 edje_object_part_swallow(wd->base, "elm.swallow.title", it->title_obj);
870 edje_object_signal_emit(wd->base, "elm,state,item,add,rightpad2", "elm");
871 edje_object_signal_emit(wd->base, "elm,state,item,fn_btn3_set", "elm");
873 if((it->title_obj)&&(it->title)){
874 edje_object_signal_emit(wd->base, "elm,state,extend,title", "elm");
877 _item_sizing_eval(it);
883 * Unset the list of title objects corresponding to given content and returns it to
885 * @param[in] obj The NavigationBar object
886 * @param[in] content The object pushed
887 * @param[in] title_obj a title object (normally button or segment_control)
888 * @param[out] list updates the list with title objects list, this list has to be freed and the
889 * objects have to be deleted by application.
890 * @ingroup NavigationBar
893 elm_navigationbar_title_object_list_unset(Evas_Object *obj,
894 Evas_Object *content, Eina_List **list)
896 ELM_CHECK_WIDTYPE(obj, widtype);
897 Widget_Data *wd = elm_widget_data_get(obj);
900 Item *last_it = NULL;
901 ll = eina_list_last(wd->stack);
908 EINA_LIST_FOREACH(wd->stack, ll, it)
910 if (it->content == content)
912 if (last_it->content == it->content)
914 Evas_Object *swallow;
915 swallow = edje_object_part_swallow_get(wd->base, "elm.swallow.title");
917 edje_object_part_unswallow(wd->base, swallow);
918 evas_object_hide(swallow);
921 _multiple_object_unset(it, list);
922 evas_object_del(it->title_obj);
923 it->title_obj = NULL;
926 edje_object_signal_emit(wd->base, "elm,state,retract,title", "elm");
929 edje_object_signal_emit(wd->base, "elm,state,item,add,rightpad2", "elm");
930 edje_object_signal_emit(wd->base, "elm,state,item,fn_btn3_set", "elm");
933 _item_sizing_eval(it);
941 * Return the list of title objects of the pushed content.
943 * @param[in] obj The NavigationBar object
944 * @param[in] content The object to push or pushed
945 * @return The list of title objects
947 * @ingroup NavigationBar
950 elm_navigationbar_title_object_list_get(Evas_Object *obj,
951 Evas_Object *content)
953 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
954 Widget_Data *wd = elm_widget_data_get(obj);
958 if (!wd) return NULL;
959 EINA_LIST_FOREACH(wd->stack, ll, it)
961 if (it->content == content)
962 return it->title_list;
968 _elm_navigationbar_back_button_set(Evas_Object *obj,
969 Evas_Object *content,
972 Widget_Data *wd = elm_widget_data_get(obj);
978 EINA_LIST_FOREACH(wd->stack, ll, it)
980 if (it->content == content)
982 _button_set(obj, it->back_btn, button, EINA_TRUE);
983 it->back_btn = button;
984 _item_sizing_eval(it);
989 //update if the content is the top item
990 ll = eina_list_last(wd->stack);
994 if (it->back_btn && (it->content == content) && (!it->fn_btn1))
996 edje_object_part_swallow(wd->base, "elm.swallow.btn1", it->back_btn);
997 evas_object_smart_callback_add(it->back_btn, "clicked", _back_button_clicked, it);
1002 static Evas_Object *
1003 _elm_navigationbar_back_button_get(Evas_Object *obj,
1004 Evas_Object *content)
1006 Widget_Data *wd = elm_widget_data_get(obj);
1010 if (!wd) return NULL;
1012 EINA_LIST_FOREACH(wd->stack, ll, it)
1014 if (it->content == content)
1015 return it->back_btn;
1021 _elm_navigationbar_function_button1_set(Evas_Object *obj,
1022 Evas_Object *content,
1023 Evas_Object *button)
1025 Widget_Data *wd = elm_widget_data_get(obj);
1031 EINA_LIST_FOREACH(wd->stack, ll, it)
1033 if (it->content == content)
1035 _button_set(obj, it->fn_btn1, button, EINA_FALSE);
1036 it->fn_btn1 = button;
1037 _item_sizing_eval(it);
1042 //update if the content is the top item
1043 ll = eina_list_last(wd->stack);
1047 if (it->fn_btn1 && (it->content == content))
1049 if (edje_object_part_swallow_get(wd->base, "elm.swallow.btn1") == it->back_btn)
1051 edje_object_part_unswallow(wd->base, it->back_btn);
1052 evas_object_del(it->back_btn);
1053 it->back_btn = NULL;
1055 edje_object_part_swallow(wd->base, "elm.swallow.btn1", it->fn_btn1);
1060 static Evas_Object *
1061 _elm_navigationbar_function_button1_get(Evas_Object *obj,
1062 Evas_Object *content)
1064 Widget_Data *wd = elm_widget_data_get(obj);
1068 if (!wd) return NULL;
1070 EINA_LIST_FOREACH(wd->stack, ll, it)
1072 if (it->content == content)
1079 _elm_navigationbar_function_button2_set(Evas_Object *obj,
1080 Evas_Object *content,
1081 Evas_Object *button)
1083 Widget_Data *wd = elm_widget_data_get(obj);
1088 EINA_LIST_FOREACH(wd->stack, ll, it)
1090 if (it->content == content)
1092 _button_set(obj, it->fn_btn2, button, EINA_FALSE);
1093 it->fn_btn2 = button;
1094 _item_sizing_eval(it);
1099 //update if the content is the top item
1100 ll = eina_list_last(wd->stack);
1104 if (it->fn_btn2 && (it->content == content))
1106 edje_object_part_swallow(wd->base, "elm.swallow.btn2", it->fn_btn2);
1111 static Evas_Object *
1112 _elm_navigationbar_function_button2_get(Evas_Object *obj,
1113 Evas_Object *content)
1115 Widget_Data *wd = elm_widget_data_get(obj);
1119 if (!wd) return NULL;
1121 EINA_LIST_FOREACH(wd->stack, ll, it)
1123 if (it->content == content)
1130 _elm_navigationbar_function_button3_set(Evas_Object *obj,
1131 Evas_Object *content,
1132 Evas_Object *button)
1134 Widget_Data *wd = elm_widget_data_get(obj);
1140 EINA_LIST_FOREACH(wd->stack, ll, it)
1142 if (it->content == content)
1144 _button_set(obj, it->fn_btn3, button, EINA_FALSE);
1145 it->fn_btn3 = button;
1146 _item_sizing_eval(it);
1151 //update if the content is the top item
1152 ll = eina_list_last(wd->stack);
1156 if (it->fn_btn3 && (it->content == content))
1158 edje_object_part_swallow(wd->base, "elm.swallow.btn3", it->fn_btn3);
1163 static Evas_Object *
1164 _elm_navigationbar_function_button3_get(Evas_Object *obj,
1165 Evas_Object *content)
1167 Widget_Data *wd = elm_widget_data_get(obj);
1171 if (!wd) return NULL;
1173 EINA_LIST_FOREACH(wd->stack, ll, it)
1175 if (it->content == content)
1182 * Return the content object at the top of the NavigationBar stack
1184 * @param[in] obj The NavigationBar object
1185 * @return The top content object or NULL if none
1187 * @ingroup NavigationBar
1190 elm_navigationbar_content_top_get(Evas_Object *obj)
1192 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1193 Widget_Data *wd = elm_widget_data_get(obj);
1194 if (!wd) return NULL;
1196 return elm_pager_content_top_get(wd->pager);
1200 * Return the content object at the bottom of the NavigationBar stack
1202 * @param[in] obj The NavigationBar object
1203 * @return The bottom content object or NULL if none
1205 * @ingroup NavigationBar
1208 elm_navigationbar_content_bottom_get(Evas_Object *obj)
1210 ELM_CHECK_WIDTYPE(obj, widtype)NULL;
1211 Widget_Data *wd = elm_widget_data_get(obj);
1212 if (!wd) return NULL;
1214 return elm_pager_content_bottom_get(wd->pager);
1218 * This hides the title area of navigationbar.
1220 * @param[in] obj The NavigationBar object
1221 * @param[in] hidden if EINA_TRUE the title area is hidden.
1223 * @ingroup NavigationBar
1226 elm_navigationbar_hidden_set(Evas_Object *obj,
1229 ELM_CHECK_WIDTYPE(obj, widtype);
1230 Widget_Data *wd = elm_widget_data_get(obj);
1233 if (hidden) edje_object_signal_emit(wd->base, "elm,state,item,moveup", "elm");
1234 else edje_object_signal_emit(wd->base, "elm,state,item,movedown", "elm");
1235 wd->hidden = hidden;
1239 * Set the button object of the pushed content.
1241 * @param[in] obj The NavigationBar object
1242 * @param[in] content The object to push or pushed
1243 * @param[in] button The button
1244 * @param[in] button_type Indicates the position
1246 * @ingroup NavigationBar
1249 elm_navigationbar_title_button_set(Evas_Object *obj,
1250 Evas_Object *content,
1251 Evas_Object *button,
1252 Elm_Navi_Button_Type button_type)
1254 ELM_CHECK_WIDTYPE(obj, widtype);
1255 if(!content) return;
1258 case ELM_NAVIGATIONBAR_FUNCTION_BUTTON1:
1259 _elm_navigationbar_function_button1_set(obj, content, button);
1261 case ELM_NAVIGATIONBAR_FUNCTION_BUTTON2:
1262 _elm_navigationbar_function_button2_set(obj, content, button);
1264 case ELM_NAVIGATIONBAR_FUNCTION_BUTTON3:
1265 _elm_navigationbar_function_button3_set(obj, content, button);
1267 case ELM_NAVIGATIONBAR_BACK_BUTTON:
1268 _elm_navigationbar_back_button_set(obj, content, button);
1277 * Return the button object of the pushed content
1279 * @param[in] obj The NavigationBar object
1280 * @param[in] content The object to push or pushed
1281 * @param[in] button_type Indicates the position
1282 * @return The button object or NULL if none
1284 * @ingroup NavigationBar
1287 elm_navigationbar_title_button_get(Evas_Object *obj,
1288 Evas_Object *content,Elm_Navi_Button_Type button_type)
1290 ELM_CHECK_WIDTYPE(obj, widtype) NULL;
1291 Evas_Object *button=NULL;
1292 if(!content || !obj) return NULL;
1295 case ELM_NAVIGATIONBAR_FUNCTION_BUTTON1:
1296 button = _elm_navigationbar_function_button1_get(obj, content);
1298 case ELM_NAVIGATIONBAR_FUNCTION_BUTTON2:
1299 button = _elm_navigationbar_function_button2_get(obj, content);
1301 case ELM_NAVIGATIONBAR_FUNCTION_BUTTON3:
1302 button = _elm_navigationbar_function_button3_get(obj, content);
1304 case ELM_NAVIGATIONBAR_BACK_BUTTON:
1305 button = _elm_navigationbar_back_button_get(obj, content);
1314 * Set the sub title string for the pushed content.
1316 * @param[in] obj The NavigationBar object
1317 * @param[in] content The object to push or pushed
1318 * @param[in] subtitle The subtitle string
1320 * @ingroup NavigationBar
1323 elm_navigationbar_subtitle_label_set(Evas_Object *obj,
1324 Evas_Object *content,
1325 const char *subtitle)
1327 ELM_CHECK_WIDTYPE(obj, widtype);
1328 Widget_Data *wd = elm_widget_data_get(obj);
1334 EINA_LIST_FOREACH(wd->stack, ll, it)
1336 if (it->content == content)
1338 eina_stringshare_replace(&it->subtitle, subtitle);
1339 edje_object_part_text_set(wd->base, "elm.text.sub", subtitle);
1340 _item_sizing_eval(it);
1347 * Return the subtitle string of the pushed content.
1349 * @param[in] obj The NavigationBar object
1350 * @param[in] content The object to push or pushed
1351 * @return The subtitle string or NULL if none
1353 * @ingroup NavigationBar
1356 elm_navigationbar_subtitle_label_get(Evas_Object *obj,
1357 Evas_Object *content)
1359 ELM_CHECK_WIDTYPE(obj, widtype)NULL;
1360 Widget_Data *wd = elm_widget_data_get(obj);
1364 if (!wd) return NULL;
1366 EINA_LIST_FOREACH(wd->stack, ll, it)
1368 if (it->content == content)
1369 return it->subtitle;
1375 * This disables content area animation on push/pop.
1377 * @param[in] obj The NavigationBar object
1378 * @param[in] disable if EINA_TRUE animation is disabled.
1380 * @ingroup NavigationBar
1383 elm_navigationbar_animation_disable_set(Evas_Object *obj,
1386 ELM_CHECK_WIDTYPE(obj, widtype);
1387 Widget_Data *wd = elm_widget_data_get(obj);
1388 elm_pager_animation_disable_set(wd->pager, disable);