2 * Copyright(c) 2019 Samsung Electronics Co., Ltd.
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.
17 using System.ComponentModel;
18 using Tizen.NUI.BaseComponents;
19 using Tizen.NUI.Binding;
20 using static Tizen.NUI.Components.DropDown;
22 namespace Tizen.NUI.Components
25 /// DropDownStyle is a class which saves DropDown's ux data.
27 /// <since_tizen> 6 </since_tizen>
28 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
29 [EditorBrowsable(EditorBrowsableState.Never)]
30 public class DropDownStyle : ControlStyle
32 private Extents listMargin;
33 private Extents listPadding;
34 private int spaceBetweenButtonTextAndIcon = 0;
35 private ListOrientation? listRelativeOrientation = ListOrientation.Left;
36 private int selectedItemIndex = 0;
38 /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
39 [EditorBrowsable(EditorBrowsableState.Never)]
40 public static readonly BindableProperty SpaceBetweenButtonTextAndIconProperty = BindableProperty.Create(nameof(SpaceBetweenButtonTextAndIcon), typeof(int), typeof(DropDownStyle), 0, propertyChanged: (bindable, oldValue, newValue) =>
42 var dropDownStyle = (DropDownStyle)bindable;
43 dropDownStyle.spaceBetweenButtonTextAndIcon = (int)newValue;
45 defaultValueCreator: (bindable) =>
47 var dropDownStyle = (DropDownStyle)bindable;
48 return dropDownStyle.spaceBetweenButtonTextAndIcon;
50 /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
51 [EditorBrowsable(EditorBrowsableState.Never)]
52 public static readonly BindableProperty ListRelativeOrientationProperty = BindableProperty.Create(nameof(ListRelativeOrientation), typeof(ListOrientation?), typeof(DropDownStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
54 var dropDownStyle = (DropDownStyle)bindable;
55 dropDownStyle.listRelativeOrientation = (ListOrientation?)newValue;
57 defaultValueCreator: (bindable) =>
59 var dropDownStyle = (DropDownStyle)bindable;
60 return dropDownStyle.listRelativeOrientation;
62 /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
63 [EditorBrowsable(EditorBrowsableState.Never)]
64 public static readonly BindableProperty ListMarginProperty = BindableProperty.Create(nameof(ListMargin), typeof(Extents), typeof(DropDownStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
66 var dropDownStyle = (DropDownStyle)bindable;
67 dropDownStyle.listMargin.CopyFrom((Extents)newValue);
69 defaultValueCreator: (bindable) =>
71 var dropDownStyle = (DropDownStyle)bindable;
72 return dropDownStyle.listMargin;
74 /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
75 [EditorBrowsable(EditorBrowsableState.Never)]
76 public static readonly BindableProperty SelectedItemIndexProperty = BindableProperty.Create(nameof(SelectedItemIndex), typeof(int), typeof(DropDownStyle), 0, propertyChanged: (bindable, oldValue, newValue) =>
78 var dropDownStyle = (DropDownStyle)bindable;
79 dropDownStyle.selectedItemIndex = (int)newValue;
81 defaultValueCreator: (bindable) =>
83 var dropDownStyle = (DropDownStyle)bindable;
84 return dropDownStyle.selectedItemIndex;
86 /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
87 [EditorBrowsable(EditorBrowsableState.Never)]
88 public static readonly BindableProperty ListPaddingProperty = BindableProperty.Create(nameof(ListPadding), typeof(Extents), typeof(DropDownStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
90 var dropDownStyle = (DropDownStyle)bindable;
93 dropDownStyle.listPadding.CopyFrom((Extents)newValue);
96 defaultValueCreator: (bindable) =>
98 var dropDownStyle = (DropDownStyle)bindable;
99 return dropDownStyle.listPadding;
103 /// Creates a new instance of a DropDownStyle.
105 /// <since_tizen> 6 </since_tizen>
106 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
107 [EditorBrowsable(EditorBrowsableState.Never)]
108 public DropDownStyle() : base() { }
111 /// Creates a new instance of a DropDownStyle with style.
113 /// <param name="style">Create DropDownStyle by style customized by user.</param>
114 /// <since_tizen> 6 </since_tizen>
115 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
116 [EditorBrowsable(EditorBrowsableState.Never)]
117 public DropDownStyle(DropDownStyle style) : base(style)
119 if(null == style) return;
121 this.CopyFrom(style);
125 /// DropDown button's Style.
127 /// <since_tizen> 6 </since_tizen>
128 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
129 [EditorBrowsable(EditorBrowsableState.Never)]
130 public ButtonStyle Button { get; set; } = new ButtonStyle();
133 /// Header text's Style.
135 /// <since_tizen> 6 </since_tizen>
136 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
137 [EditorBrowsable(EditorBrowsableState.Never)]
138 public TextLabelStyle HeaderText { get; set; } = new TextLabelStyle();
141 /// List background image's Style.
143 /// <since_tizen> 6 </since_tizen>
144 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
145 [EditorBrowsable(EditorBrowsableState.Never)]
146 public ImageViewStyle ListBackgroundImage { get; set; } = new ImageViewStyle();
149 /// Space between button text and button icon.
151 /// <since_tizen> 6 </since_tizen>
152 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
153 [EditorBrowsable(EditorBrowsableState.Never)]
154 public int SpaceBetweenButtonTextAndIcon
156 get => (int)GetValue(SpaceBetweenButtonTextAndIconProperty);
157 set => SetValue(SpaceBetweenButtonTextAndIconProperty, value);
161 /// List relative orientation.
163 /// <since_tizen> 6 </since_tizen>
164 /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
165 [EditorBrowsable(EditorBrowsableState.Never)]
166 public ListOrientation? ListRelativeOrientation
168 get => (ListOrientation?)GetValue(ListRelativeOrientationProperty);
169 set => SetValue(ListRelativeOrientationProperty, value);
175 /// <since_tizen> 6 </since_tizen>
176 /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
177 [EditorBrowsable(EditorBrowsableState.Never)]
178 public Extents ListMargin
182 Extents tmp = (Extents)GetValue(ListMarginProperty);
183 return (null != tmp) ? tmp : listMargin = new Extents((ushort start, ushort end, ushort top, ushort bottom) => { ListMargin = new Extents(start, end, top, bottom); }, 0, 0, 0, 0);
185 set => SetValue(ListMarginProperty, value);
188 /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
189 [EditorBrowsable(EditorBrowsableState.Never)]
190 public int SelectedItemIndex
192 get => (int)GetValue(SelectedItemIndexProperty);
193 set => SetValue(SelectedItemIndexProperty, value);
199 /// <since_tizen> 6 </since_tizen>
200 /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
201 [EditorBrowsable(EditorBrowsableState.Never)]
202 public Extents ListPadding
206 Extents tmp = (Extents)GetValue(ListPaddingProperty);
207 return (null != tmp) ? tmp : listPadding = new Extents((ushort start, ushort end, ushort top, ushort bottom) => { ListPadding = new Extents(start, end, top, bottom); }, 0, 0, 0, 0);
209 set => SetValue(ListPaddingProperty, value);
212 /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
213 [EditorBrowsable(EditorBrowsableState.Never)]
214 public override void CopyFrom(BindableObject bindableObject)
216 base.CopyFrom(bindableObject);
218 DropDownStyle dropDownStyle = bindableObject as DropDownStyle;
220 if (null != dropDownStyle)
222 Button.CopyFrom(dropDownStyle.Button);
223 HeaderText.CopyFrom(dropDownStyle.HeaderText);
224 ListBackgroundImage.CopyFrom(dropDownStyle.ListBackgroundImage);
225 SpaceBetweenButtonTextAndIcon = dropDownStyle.SpaceBetweenButtonTextAndIcon;
226 ListRelativeOrientation = dropDownStyle.ListRelativeOrientation;
227 ListMargin.CopyFrom(dropDownStyle.ListMargin);
228 SelectedItemIndex = dropDownStyle.SelectedItemIndex;
229 ListPadding.CopyFrom(dropDownStyle.ListPadding);
235 /// DropDownItemStyle is a class which saves DropDownItem's ux data.
237 /// <since_tizen> 6 </since_tizen>
238 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
239 [EditorBrowsable(EditorBrowsableState.Never)]
240 public class DropDownItemStyle : ControlStyle
243 /// Creates a new instance of a DropDownItemStyle.
245 /// <since_tizen> 6 </since_tizen>
246 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
247 [EditorBrowsable(EditorBrowsableState.Never)]
248 public DropDownItemStyle() : base() { }
251 /// Creates a new instance of a DropDownItemStyle with style.
253 /// <param name="style">Create DropDownItemStyle by style customized by user.</param>
254 /// <since_tizen> 6 </since_tizen>
255 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
256 [EditorBrowsable(EditorBrowsableState.Never)]
257 public DropDownItemStyle(DropDownItemStyle style) : base(style)
259 if(null == style) return;
261 this.CopyFrom(style);
267 /// <since_tizen> 6 </since_tizen>
268 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
269 [EditorBrowsable(EditorBrowsableState.Never)]
270 public TextLabelStyle Text { get; set; } = new TextLabelStyle();
275 /// <since_tizen> 6 </since_tizen>
276 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
277 [EditorBrowsable(EditorBrowsableState.Never)]
278 public ImageViewStyle Icon { get; set; } = new ImageViewStyle();
281 /// Check image's Style.
283 /// <since_tizen> 6 </since_tizen>
284 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
285 [EditorBrowsable(EditorBrowsableState.Never)]
286 public ImageViewStyle CheckImage { get; set; } = new ImageViewStyle();
289 /// Gap of Check image to boundary.
291 /// <since_tizen> 6 </since_tizen>
292 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
293 [EditorBrowsable(EditorBrowsableState.Never)]
294 public int CheckImageGapToBoundary { get; set; }
297 /// Flag to decide item is selected or not.
299 /// <since_tizen> 6 </since_tizen>
300 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
301 [EditorBrowsable(EditorBrowsableState.Never)]
302 public bool IsSelected { get; set; }
304 /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
305 [EditorBrowsable(EditorBrowsableState.Never)]
306 public override void CopyFrom(BindableObject bindableObject)
308 base.CopyFrom(bindableObject);
310 DropDownItemStyle dropDownItemStyle = bindableObject as DropDownItemStyle;
312 if (null != dropDownItemStyle)
314 Text.CopyFrom(dropDownItemStyle.Text);
315 Icon.CopyFrom(dropDownItemStyle.Icon);
316 CheckImage.CopyFrom(dropDownItemStyle.CheckImage);
317 CheckImageGapToBoundary = dropDownItemStyle.CheckImageGapToBoundary;
318 IsSelected = dropDownItemStyle.IsSelected;