[NUI.Components] Fix build warnings (#1233) (#1237)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI.Components / Style / DropDownStyle.cs
1 /*
2  * Copyright(c) 2019 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17 using System.ComponentModel;
18 using Tizen.NUI.BaseComponents;
19 using Tizen.NUI.Binding;
20 using static Tizen.NUI.Components.DropDown;
21
22 namespace Tizen.NUI.Components
23 {
24     /// <summary>
25     /// DropDownStyle is a class which saves DropDown's ux data.
26     /// </summary>
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
31     {
32         private Extents listMargin;
33         private Extents listPadding;
34         private int spaceBetweenButtonTextAndIcon = 0;
35         private ListOrientation? listRelativeOrientation = ListOrientation.Left;
36         private int selectedItemIndex = 0;
37
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) =>
41         {
42             var dropDownStyle = (DropDownStyle)bindable;
43             dropDownStyle.spaceBetweenButtonTextAndIcon = (int)newValue;
44         },
45         defaultValueCreator: (bindable) =>
46         {
47             var dropDownStyle = (DropDownStyle)bindable;
48             return dropDownStyle.spaceBetweenButtonTextAndIcon;
49         });
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) =>
53         {
54             var dropDownStyle = (DropDownStyle)bindable;
55             dropDownStyle.listRelativeOrientation = (ListOrientation?)newValue;
56         },
57         defaultValueCreator: (bindable) =>
58         {
59             var dropDownStyle = (DropDownStyle)bindable;
60             return dropDownStyle.listRelativeOrientation;
61         });
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) =>
65         {
66             var dropDownStyle = (DropDownStyle)bindable;
67             dropDownStyle.listMargin.CopyFrom((Extents)newValue);
68         },
69         defaultValueCreator: (bindable) =>
70         {
71             var dropDownStyle = (DropDownStyle)bindable;
72             return dropDownStyle.listMargin;
73         });
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) =>
77         {
78             var dropDownStyle = (DropDownStyle)bindable;
79             dropDownStyle.selectedItemIndex = (int)newValue;
80         },
81         defaultValueCreator: (bindable) =>
82         {
83             var dropDownStyle = (DropDownStyle)bindable;
84             return dropDownStyle.selectedItemIndex;
85         });
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) =>
89         {
90             var dropDownStyle = (DropDownStyle)bindable;
91             if (null != newValue)
92             {
93                 dropDownStyle.listPadding.CopyFrom((Extents)newValue);
94             }
95         },
96         defaultValueCreator: (bindable) =>
97         {
98             var dropDownStyle = (DropDownStyle)bindable;
99             return dropDownStyle.listPadding;
100         });
101
102         /// <summary>
103         /// Creates a new instance of a DropDownStyle.
104         /// </summary>
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() { }
109
110         /// <summary>
111         /// Creates a new instance of a DropDownStyle with style.
112         /// </summary>
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)
118         {
119             if(null == style) return;
120
121             this.CopyFrom(style);
122         }
123
124         /// <summary>
125         /// DropDown button's Style.
126         /// </summary>
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();
131
132         /// <summary>
133         /// Header text's Style.
134         /// </summary>
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();
139
140         /// <summary>
141         /// List background image's Style.
142         /// </summary>
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();
147
148         /// <summary>
149         /// Space between button text and button icon.
150         /// </summary>
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
155         {
156             get => (int)GetValue(SpaceBetweenButtonTextAndIconProperty);
157             set => SetValue(SpaceBetweenButtonTextAndIconProperty, value);
158         }
159
160         /// <summary>
161         /// List relative orientation.
162         /// </summary>
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
167         {
168             get => (ListOrientation?)GetValue(ListRelativeOrientationProperty);
169             set => SetValue(ListRelativeOrientationProperty, value);
170         }
171
172         /// <summary>
173         /// List margin.
174         /// </summary>
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
179         {
180             get
181             {
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);
184             }
185             set => SetValue(ListMarginProperty, value);
186         }
187
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
191         {
192             get => (int)GetValue(SelectedItemIndexProperty);
193             set => SetValue(SelectedItemIndexProperty, value);
194         }
195
196         /// <summary>
197         /// List padding.
198         /// </summary>
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
203         {
204             get
205             {
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);
208             }
209             set => SetValue(ListPaddingProperty, value);
210         }
211
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)
215         {
216             base.CopyFrom(bindableObject);
217
218             DropDownStyle dropDownStyle = bindableObject as DropDownStyle;
219
220             if (null != dropDownStyle)
221             {
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);
230             }
231         }
232     }
233
234     /// <summary>
235     /// DropDownItemStyle is a class which saves DropDownItem's ux data.
236     /// </summary>
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
241     {
242         /// <summary>
243         /// Creates a new instance of a DropDownItemStyle.
244         /// </summary>
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() { }
249
250         /// <summary>
251         /// Creates a new instance of a DropDownItemStyle with style.
252         /// </summary>
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)
258         {
259             if(null == style) return;
260
261             this.CopyFrom(style);
262         }
263
264         /// <summary>
265         /// Text's Style.
266         /// </summary>
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();
271
272         /// <summary>
273         /// Icon's Style.
274         /// </summary>
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();
279
280         /// <summary>
281         /// Check image's Style.
282         /// </summary>
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();
287
288         /// <summary>
289         /// Gap of Check image to boundary.
290         /// </summary>
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; }
295
296         /// <summary>
297         /// Flag to decide item is selected or not.
298         /// </summary>
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; }
303
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)
307         {
308             base.CopyFrom(bindableObject);
309
310             DropDownItemStyle dropDownItemStyle = bindableObject as DropDownItemStyle;
311
312             if (null != dropDownItemStyle)
313             {
314                 Text.CopyFrom(dropDownItemStyle.Text);
315                 Icon.CopyFrom(dropDownItemStyle.Icon);
316                 CheckImage.CopyFrom(dropDownItemStyle.CheckImage);
317                 CheckImageGapToBoundary = dropDownItemStyle.CheckImageGapToBoundary;
318                 IsSelected = dropDownItemStyle.IsSelected;
319             }
320         }
321     }
322 }