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;
21 namespace ElmSharp.Wearable
24 /// The MoreOption is a widget composed of the toggle (cue button) and more option view that can change a visibility through the toggle.
27 /// <since_tizen> preview </since_tizen>
28 public class MoreOption : Layout
31 /// Sets or gets the list of the more option item.
33 /// <since_tizen> preview </since_tizen>
34 public IList<MoreOptionItem> Items { get; private set; }
37 /// Selected will be triggered when the user selects an item.
39 /// <since_tizen> preview </since_tizen>
40 public event EventHandler<MoreOptionItemEventArgs> Selected;
42 /// Clicked will be triggered when the user selects the already selected item again or selects a selector.
44 /// <since_tizen> preview </since_tizen>
45 public event EventHandler<MoreOptionItemEventArgs> Clicked;
47 /// Opened will be triggered when the more option view is shown.
49 /// <since_tizen> preview </since_tizen>
50 public event EventHandler Opened;
52 /// Closed will be triggered when the more option view is hidden.
54 /// <since_tizen> preview </since_tizen>
55 public event EventHandler Closed;
57 SmartEvent<PointerEventArgs> _selectedEvent;
58 SmartEvent<PointerEventArgs> _clickedEvent;
59 SmartEvent _openedEvent;
60 SmartEvent _closedEvent;
63 /// Creates and initializes a new instance of the MoreOption class.
65 /// <param name="parent">The parent is a given container, which will be attached by the MoreOption as a child. It's <see cref="EvasObject"/> type.</param>
66 /// <since_tizen> preview </since_tizen>
67 public MoreOption(EvasObject parent) : base(parent)
69 Items = new MoreOptionList(this);
71 _selectedEvent = new SmartEvent<PointerEventArgs>(this, "item,selected", (d, o, info) => new PointerEventArgs { Pointer = info });
72 _clickedEvent = new SmartEvent<PointerEventArgs>(this, "item,clicked", (d, o, info) => new PointerEventArgs { Pointer = info });
73 _openedEvent = new SmartEvent(this, "more,option,opened");
74 _closedEvent = new SmartEvent(this, "more,option,closed");
76 _selectedEvent.On += (s, e) =>
78 MoreOptionItem selected = Items.FirstOrDefault(i => i.Handle == e.Pointer);
79 Selected?.Invoke(this, new MoreOptionItemEventArgs() { Item = selected });
82 _clickedEvent.On += (s, e) =>
84 MoreOptionItem selected = Items.FirstOrDefault(i => i.Handle == e.Pointer);
85 Clicked?.Invoke(this, new MoreOptionItemEventArgs() { Item = selected });
88 _openedEvent.On += (s, e) => Opened?.Invoke(this, EventArgs.Empty);
89 _closedEvent.On += (s, e) => Closed?.Invoke(this, EventArgs.Empty);
94 /// Creates a widget handle.
96 /// <param name="parent">Parent EvasObject.</param>
97 /// <returns>Handle IntPtr.</returns>
98 /// <since_tizen> preview </since_tizen>
99 protected override IntPtr CreateHandle(EvasObject parent)
101 return Interop.Eext.eext_more_option_add(parent);
105 /// Sets or gets the direction of more option.
107 /// <since_tizen> preview </since_tizen>
108 public MoreOptionDirection Direction
112 int dir = Interop.Eext.eext_more_option_direction_get(this);
113 return (MoreOptionDirection)dir;
118 Interop.Eext.eext_more_option_direction_set(this, (int)value);
123 /// Sets or gets the visibility of the more option view.
125 /// <since_tizen> preview </since_tizen>
130 return Interop.Eext.eext_more_option_opened_get(this);
135 Interop.Eext.eext_more_option_opened_set(this, value);
141 /// Enumeration for the more option direction types.
143 /// <since_tizen> preview </since_tizen>
144 public enum MoreOptionDirection
151 /// Bottom direction.