2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 using System.Collections.Generic;
22 public class NaviframeEventArgs : EventArgs
24 public EvasObject Content { get; set; }
26 public class Naviframe : Widget
28 SmartEvent _transitionFinished;
29 readonly List<NaviItem> _itemStack = new List<NaviItem>();
30 public Naviframe(EvasObject parent) : base(parent)
32 _transitionFinished = new SmartEvent(this, this.RealHandle, "transition,finished");
33 _transitionFinished.On += (s, e) => AnimationFinished?.Invoke(this, EventArgs.Empty);
40 /// It is always called when NaviItem was removed.
41 /// (even if removed by NaviItem.Delete())
42 /// This event will be invoked in progress of Pop/Delete operation.
43 /// After called Popped event, Pop/Delete method will be returned
45 public event EventHandler<NaviframeEventArgs> Popped;
46 public event EventHandler AnimationFinished;
47 public IReadOnlyList<NaviItem> NavigationStack
49 get { return _itemStack; }
52 public bool PreserveContentOnPop
56 return Interop.Elementary.elm_naviframe_content_preserve_on_pop_get(RealHandle);
60 Interop.Elementary.elm_naviframe_content_preserve_on_pop_set(RealHandle, value);
64 public bool DefaultBackButtonEnabled
68 return Interop.Elementary.elm_naviframe_prev_btn_auto_pushed_get(RealHandle);
72 Interop.Elementary.elm_naviframe_prev_btn_auto_pushed_set(RealHandle, value);
76 public NaviItem Push(EvasObject content)
78 return Push(content, null);
81 public NaviItem Push(EvasObject content, string title)
83 return Push(content, title, null);
86 public NaviItem Push(EvasObject content, string title, string style)
88 IntPtr item = Interop.Elementary.elm_naviframe_item_push(RealHandle, title, IntPtr.Zero, IntPtr.Zero, content.Handle, null);
89 NaviItem naviItem = NaviItem.FromNativeHandle(item, content);
90 _itemStack.Add(naviItem);
91 naviItem.Popped += ItemPoppedHandler;
95 public NaviItem InsertBefore(NaviItem before, EvasObject content)
97 return InsertBefore(before, content, "");
100 public NaviItem InsertBefore(NaviItem before, EvasObject content, string title)
102 return InsertBefore(before, content, title, null);
105 public NaviItem InsertBefore(NaviItem before, EvasObject content, string title, string style)
107 IntPtr item = Interop.Elementary.elm_naviframe_item_insert_before(RealHandle, before, title, IntPtr.Zero, IntPtr.Zero, content, null);
108 NaviItem naviItem = NaviItem.FromNativeHandle(item, content);
109 int idx = _itemStack.IndexOf(before);
110 _itemStack.Insert(idx, naviItem);
111 naviItem.Popped += ItemPoppedHandler;
115 public NaviItem InsertAfter(NaviItem after, EvasObject content)
117 return InsertAfter(after, content, "");
120 public NaviItem InsertAfter(NaviItem after, EvasObject content, string title)
122 return InsertAfter(after, content, title, null);
125 public NaviItem InsertAfter(NaviItem after, EvasObject content, string title, string style)
127 IntPtr item = Interop.Elementary.elm_naviframe_item_insert_after(RealHandle, after, title, IntPtr.Zero, IntPtr.Zero, content, null);
128 NaviItem naviItem = NaviItem.FromNativeHandle(item, content);
129 int idx = _itemStack.IndexOf(after);
130 _itemStack.Insert(idx + 1, naviItem);
131 naviItem.Popped += ItemPoppedHandler;
137 Interop.Elementary.elm_naviframe_item_pop(RealHandle);
140 protected override IntPtr CreateHandle(EvasObject parent)
142 IntPtr handle = Interop.Elementary.elm_layout_add(parent);
143 Interop.Elementary.elm_layout_theme_set(handle, "layout", "elm_widget", "default");
145 RealHandle = Interop.Elementary.elm_naviframe_add(handle);
146 Interop.Elementary.elm_object_part_content_set(handle, "elm.swallow.content", RealHandle);
151 void ItemPoppedHandler(object sender, EventArgs e)
153 NaviItem item = sender as NaviItem;
156 _itemStack.Remove(item);
157 Popped?.Invoke(this, new NaviframeEventArgs() { Content = item.Content });