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.
22 /// The HoverselItemEventArgs is an HoverselItem's EventArgs
24 public class HoverselItemEventArgs : EventArgs
29 public HoverselItem Item { get; set; }
31 internal static HoverselItemEventArgs CreateFromSmartEvent(IntPtr data, IntPtr obj, IntPtr info)
33 HoverselItem item = ItemObject.GetItemByHandle(info) as HoverselItem;
34 return new HoverselItemEventArgs() { Item = item };
39 /// The hoversel is a button that pops up a list of items.
41 public class Hoversel : Layout
45 SmartEvent _dismissed;
46 SmartEvent<HoverselItemEventArgs> _selected;
47 Interop.Evas.SmartCallback _onItemSelected;
50 /// Creates and initializes a new instance of the Hoversel class.
52 /// <param name="parent">The parent is a given container which will be attached by Hoversel as a child. It's <see cref="EvasObject"/> type.</param>
53 public Hoversel(EvasObject parent) : base(parent)
55 _clicked = new SmartEvent(this, "clicked");
56 _clicked.On += (sender, e) =>
58 Clicked?.Invoke(this, EventArgs.Empty);
60 _expanded = new SmartEvent(this, "expanded");
61 _expanded.On += (sender, e) =>
63 Expanded?.Invoke(this, EventArgs.Empty);
65 _dismissed = new SmartEvent(this, "dismissed");
66 _dismissed.On += (sender, e) =>
68 Dismissed?.Invoke(this, EventArgs.Empty);
70 _selected = new SmartEvent<HoverselItemEventArgs>(this, RealHandle, "selected", HoverselItemEventArgs.CreateFromSmartEvent);
71 _selected.On += (s, e) =>
73 if (e.Item != null) ItemSelected?.Invoke(this, e);
75 _onItemSelected = (data, obj, info) =>
77 HoverselItem item = ItemObject.GetItemById((int)data) as HoverselItem;
78 item?.SendItemSelected();
83 /// Clicked will be triggered when Hoversel is clicked
85 public event EventHandler Clicked;
88 /// Expanded will be triggered when Hoversel is activated by clicking the hoversel or by a function
90 public event EventHandler Expanded;
93 /// Dismissed will be triggered when Hoversel Dismissed
95 public event EventHandler Dismissed;
98 /// ItemSelected will be triggered when Hoversel's Item Selected
100 public event EventHandler<HoverselItemEventArgs> ItemSelected;
103 /// Gets or sets the status to control whether the hoversel should expand horizontally.
105 public bool IsHorizontal
109 return Interop.Elementary.elm_hoversel_horizontal_get(RealHandle);
113 Interop.Elementary.elm_hoversel_horizontal_set(RealHandle, value);
118 /// Gets or sets the hover parent.
120 public IntPtr HoverParent
124 return Interop.Elementary.elm_hoversel_hover_parent_get(RealHandle);
128 Interop.Elementary.elm_hoversel_hover_parent_set(RealHandle, value);
133 /// Gets the flag of whether the hoversel is expanded.
135 public bool IsExpanded
139 return Interop.Elementary.elm_hoversel_expanded_get(RealHandle);
144 /// Gets or sets the status of whether update icon and text of hoversel same to those of selected item automatically.
146 public bool AutoUpdate
150 return Interop.Elementary.elm_hoversel_auto_update_get(RealHandle);
154 Interop.Elementary.elm_hoversel_auto_update_set(RealHandle, value);
159 /// This triggers the hoversel popup from code, the same as if the user had clicked the button.
161 public void HoverBegin()
163 Interop.Elementary.elm_hoversel_hover_begin(RealHandle);
167 /// This dismisses the hoversel popup as if the user had clicked outside the hover.
169 public void HoverEnd()
171 Interop.Elementary.elm_hoversel_hover_end(RealHandle);
175 /// This will remove all the children items from the hoversel.
179 Interop.Elementary.elm_hoversel_clear(RealHandle);
183 /// Add an item to the hoversel button.
184 /// This adds an item to the hoversel to show when it is clicked.
186 /// <param name="label">Item's label</param>
187 /// <returns>A handle to the added item.</returns>
188 public HoverselItem AddItem(string label)
190 HoverselItem item = new HoverselItem();
192 item.Handle = Interop.Elementary.elm_hoversel_item_add(RealHandle, label, null, 0, _onItemSelected, (IntPtr)item.Id);
196 protected override IntPtr CreateHandle(EvasObject parent)
198 IntPtr handle = Interop.Elementary.elm_layout_add(parent.Handle);
199 Interop.Elementary.elm_layout_theme_set(handle, "layout", "background", "default");
201 RealHandle = Interop.Elementary.elm_hoversel_add(handle);
202 Interop.Elementary.elm_object_part_content_set(handle, "elm.swallow.content", RealHandle);