[NUI] Refactor NUI Components (#1159)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI.Components / Attributes / DropDownAttributes.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 int spaceBetweenButtonTextAndIcon = 0;
33
34         private Extents _space;
35         private Extents space
36         {
37             get
38             {
39                 if (null == _space)
40                 {
41                     _space = new Extents((ushort start, ushort end, ushort top, ushort bottom) =>
42                     {
43                         Extents extents = new Extents(start, end, top, bottom);
44                         _space.CopyFrom(extents);
45                     }, 0, 0, 0, 0);
46                 }
47
48                 return _space;
49             }
50         }
51
52         private ListOrientation? listRelativeOrientation = ListOrientation.Left;
53
54         private bool isListMarginSetted = false;
55         private Extents _listMargin;
56         private Extents listMargin
57         {
58             get
59             {
60                 if (null == _listMargin)
61                 {
62                     _listMargin = new Extents((ushort start, ushort end, ushort top, ushort bottom) =>
63                     {
64                         Extents extents = new Extents(start, end, top, bottom);
65                         _listMargin.CopyFrom(extents);
66                     }, 0, 0, 0, 0);
67                 }
68
69                 return _listMargin;
70             }
71         }
72
73         private int focusedItemIndex = 0;
74         private int selectedItemIndex = 0;
75         private Size listSize;
76
77         private Extents _listPadding;
78         private Extents listPadding
79         {
80             get
81             {
82                 if (null == _listPadding)
83                 {
84                     _listPadding = new Extents((ushort start, ushort end, ushort top, ushort bottom) =>
85                     {
86                         Extents extents = new Extents(start, end, top, bottom);
87                         _listPadding.CopyFrom(extents);
88                     }, 0, 0, 0, 0);
89                 }
90
91                 return _listPadding;
92             }
93         }
94
95         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
96         [EditorBrowsable(EditorBrowsableState.Never)]
97         public static readonly BindableProperty SpaceBetweenButtonTextAndIconProperty = BindableProperty.Create("SpaceBetweenButtonTextAndIcon", typeof(int), typeof(DropDownStyle), 0, propertyChanged: (bindable, oldValue, newValue) =>
98         {
99             var dropDownStyle = (DropDownStyle)bindable;
100             dropDownStyle.spaceBetweenButtonTextAndIcon = (int)newValue;
101         },
102         defaultValueCreator: (bindable) =>
103         {
104             var dropDownStyle = (DropDownStyle)bindable;
105             return dropDownStyle.spaceBetweenButtonTextAndIcon;
106         });
107         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
108         [EditorBrowsable(EditorBrowsableState.Never)]
109         public static readonly BindableProperty SpaceProperty = BindableProperty.Create("Space", typeof(Extents), typeof(DropDownStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
110         {
111             var dropDownStyle = (DropDownStyle)bindable;
112             dropDownStyle.space.CopyFrom((Extents)newValue);
113         },
114         defaultValueCreator: (bindable) =>
115         {
116             var dropDownStyle = (DropDownStyle)bindable;
117             return dropDownStyle.space;
118         });
119         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
120         [EditorBrowsable(EditorBrowsableState.Never)]
121         public static readonly BindableProperty ListRelativeOrientationProperty = BindableProperty.Create("ListRelativeOrientation", typeof(ListOrientation?), typeof(DropDownStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
122         {
123             var dropDownStyle = (DropDownStyle)bindable;
124             dropDownStyle.listRelativeOrientation = (ListOrientation?)newValue;
125         },
126         defaultValueCreator: (bindable) =>
127         {
128             var dropDownStyle = (DropDownStyle)bindable;
129             return dropDownStyle.listRelativeOrientation;
130         });
131         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
132         [EditorBrowsable(EditorBrowsableState.Never)]
133         public static readonly BindableProperty ListMarginProperty = BindableProperty.Create("ListMargin", typeof(Extents), typeof(DropDownStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
134         {
135             var dropDownStyle = (DropDownStyle)bindable;
136             dropDownStyle.listMargin.CopyFrom((Extents)newValue);
137         },
138         defaultValueCreator: (bindable) =>
139         {
140             var dropDownStyle = (DropDownStyle)bindable;
141             return dropDownStyle.listMargin;
142         });
143         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
144         [EditorBrowsable(EditorBrowsableState.Never)]
145         public static readonly BindableProperty FocusedItemIndexProperty = BindableProperty.Create("FocusedItemIndex", typeof(int), typeof(DropDownStyle), 0, propertyChanged: (bindable, oldValue, newValue) =>
146         {
147             var dropDownStyle = (DropDownStyle)bindable;
148             dropDownStyle.focusedItemIndex = (int)newValue;
149         },
150         defaultValueCreator: (bindable) =>
151         {
152             var dropDownStyle = (DropDownStyle)bindable;
153             return dropDownStyle.focusedItemIndex;
154         });
155         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
156         [EditorBrowsable(EditorBrowsableState.Never)]
157         public static readonly BindableProperty SelectedItemIndexProperty = BindableProperty.Create("SelectedItemIndex", typeof(int), typeof(DropDownStyle), 0, propertyChanged: (bindable, oldValue, newValue) =>
158         {
159             var dropDownStyle = (DropDownStyle)bindable;
160             dropDownStyle.selectedItemIndex = (int)newValue;
161         },
162         defaultValueCreator: (bindable) =>
163         {
164             var dropDownStyle = (DropDownStyle)bindable;
165             return dropDownStyle.selectedItemIndex;
166         });
167         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
168         [EditorBrowsable(EditorBrowsableState.Never)]
169         public static readonly BindableProperty ListSizeProperty = BindableProperty.Create("ListSize", typeof(Size), typeof(DropDownStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
170         {
171             var dropDownStyle = (DropDownStyle)bindable;
172             dropDownStyle.listSize = (Size)newValue;
173         },
174         defaultValueCreator: (bindable) =>
175         {
176             var dropDownStyle = (DropDownStyle)bindable;
177             return dropDownStyle.listSize;
178         });
179         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
180         [EditorBrowsable(EditorBrowsableState.Never)]
181         public static readonly BindableProperty ListPaddingProperty = BindableProperty.Create("ListPadding", typeof(Extents), typeof(DropDownStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
182         {
183             var dropDownStyle = (DropDownStyle)bindable;
184             dropDownStyle.listPadding.CopyFrom((Extents)newValue);
185         },
186         defaultValueCreator: (bindable) =>
187         {
188             var dropDownStyle = (DropDownStyle)bindable;
189             return dropDownStyle.listPadding;
190         });
191
192         /// <summary>
193         /// Creates a new instance of a DropDownStyle.
194         /// </summary>
195         /// <since_tizen> 6 </since_tizen>
196         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
197         [EditorBrowsable(EditorBrowsableState.Never)]
198         public DropDownStyle() : base()
199         {
200             Button = new ButtonStyle();
201             HeaderText = new TextLabelStyle();
202             ListBackgroundImage = new ImageViewStyle();
203         }
204         /// <summary>
205         /// Creates a new instance of a DropDownStyle with style.
206         /// </summary>
207         /// <param name="style">Create DropDownStyle by style customized by user.</param>
208         /// <since_tizen> 6 </since_tizen>
209         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
210         [EditorBrowsable(EditorBrowsableState.Never)]
211         public DropDownStyle(DropDownStyle style) : base(style)
212         {
213             if(style == null)
214             {
215                 return;
216             }
217
218             Button = new ButtonStyle();
219             HeaderText = new TextLabelStyle();
220             ListBackgroundImage = new ImageViewStyle();
221
222             CopyFrom(style);
223         }
224
225         /// <summary>
226         /// DropDown button's Style.
227         /// </summary>
228         /// <since_tizen> 6 </since_tizen>
229         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
230         [EditorBrowsable(EditorBrowsableState.Never)]
231         public ButtonStyle Button
232         {
233             get;
234             set;
235         }
236
237         /// <summary>
238         /// Header text's Style.
239         /// </summary>
240         /// <since_tizen> 6 </since_tizen>
241         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
242         [EditorBrowsable(EditorBrowsableState.Never)]
243         public TextLabelStyle HeaderText
244         {
245             get;
246             set;
247         }
248
249         /// <summary>
250         /// List background image's Style.
251         /// </summary>
252         /// <since_tizen> 6 </since_tizen>
253         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
254         [EditorBrowsable(EditorBrowsableState.Never)]
255         public ImageViewStyle ListBackgroundImage
256         {
257             get;
258             set;
259         }
260
261         /// <summary>
262         /// Space between button text and button icon.
263         /// </summary>
264         /// <since_tizen> 6 </since_tizen>
265         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
266         [EditorBrowsable(EditorBrowsableState.Never)]
267         public int SpaceBetweenButtonTextAndIcon
268         {
269             get
270             {
271                 int temp = (int)GetValue(SpaceBetweenButtonTextAndIconProperty);
272                 return temp;
273             }
274             set
275             {
276                 SetValue(SpaceBetweenButtonTextAndIconProperty, value);
277             }
278         }
279
280         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
281         [EditorBrowsable(EditorBrowsableState.Never)]
282         public Extents Space
283         {
284             get
285             {
286                 Extents temp = (Extents)GetValue(SpaceProperty);
287                 return temp;
288             }
289             set
290             {
291                 SetValue(SpaceProperty, value);
292             }
293         }
294
295         /// <summary>
296         /// List relative orientation.
297         /// </summary>
298         /// <since_tizen> 6 </since_tizen>
299         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
300         [EditorBrowsable(EditorBrowsableState.Never)]
301         public ListOrientation? ListRelativeOrientation
302         {
303             get
304             {
305                 ListOrientation? temp = (ListOrientation?)GetValue(ListRelativeOrientationProperty);
306                 return temp;
307             }
308             set
309             {
310                 SetValue(ListRelativeOrientationProperty, value);
311             }
312         }
313
314         /// <summary>
315         /// List margin.
316         /// </summary>
317         /// <since_tizen> 6 </since_tizen>
318         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
319         [EditorBrowsable(EditorBrowsableState.Never)]
320         public Extents ListMargin
321         {
322             get
323             {
324                 Extents temp = (Extents)GetValue(ListMarginProperty);
325                 return temp;
326             }
327             set
328             {
329                 SetValue(ListMarginProperty, value);
330             }
331         }
332
333         /// <summary>
334         /// Focused item index.
335         /// </summary>
336         /// <since_tizen> 6 </since_tizen>
337         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
338         [EditorBrowsable(EditorBrowsableState.Never)]
339         public int FocusedItemIndex
340         {
341             get
342             {
343                 int temp = (int)GetValue(FocusedItemIndexProperty);
344                 return temp;
345             }
346             set
347             {
348                 SetValue(FocusedItemIndexProperty, value);
349             }
350         }
351
352         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
353         [EditorBrowsable(EditorBrowsableState.Never)]
354         public int SelectedItemIndex
355         {
356             get
357             {
358                 int temp = (int)GetValue(SelectedItemIndexProperty);
359                 return temp;
360             }
361             set
362             {
363                 SetValue(SelectedItemIndexProperty, value);
364             }
365         }
366
367         /// <summary>
368         /// List size.
369         /// </summary>
370         /// <since_tizen> 6 </since_tizen>
371         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
372         [EditorBrowsable(EditorBrowsableState.Never)]
373         public Size ListSize
374         {
375             get
376             {
377                 Size temp = (Size)GetValue(ListSizeProperty);
378                 return temp;
379             }
380             set
381             {
382                 SetValue(ListSizeProperty, value);
383             }
384         }
385
386         /// <summary>
387         /// List padding.
388         /// </summary>
389         /// <since_tizen> 6 </since_tizen>
390         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
391         [EditorBrowsable(EditorBrowsableState.Never)]
392         public Extents ListPadding
393         {
394             get
395             {
396                 Extents temp = (Extents)GetValue(ListPaddingProperty);
397                 return temp;
398             }
399             set
400             {
401                 SetValue(ListPaddingProperty, value);
402             }
403         }
404
405         /// <summary>
406         /// Icon's Style.
407         /// </summary>
408         /// <since_tizen> 6 </since_tizen>
409         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
410         [EditorBrowsable(EditorBrowsableState.Never)]
411         public ImageViewStyle Icon
412         {
413             get;
414             set;
415         }
416
417         /// <summary>
418         /// Check image's Style.
419         /// </summary>
420         /// <since_tizen> 6 </since_tizen>
421         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
422         [EditorBrowsable(EditorBrowsableState.Never)]
423         public ImageViewStyle CheckImage
424         {
425             get;
426             set;
427         }
428
429         /// <summary>
430         /// Gap of Check image to boundary.
431         /// </summary>
432         /// <since_tizen> 6 </since_tizen>
433         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
434         [EditorBrowsable(EditorBrowsableState.Never)]
435         public int CheckImageGapToBoundary
436         {
437             get;
438             set;
439         }
440
441         /// <summary>
442         /// Flag to decide item is selected or not.
443         /// </summary>
444         /// <since_tizen> 6 </since_tizen>
445         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
446         [EditorBrowsable(EditorBrowsableState.Never)]
447         public bool IsSelected
448         {
449             get;
450             set;
451         }
452
453         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
454         [EditorBrowsable(EditorBrowsableState.Never)]
455         public override void CopyFrom(BindableObject bindableObject)
456         {
457             base.CopyFrom(bindableObject);
458
459             DropDownStyle dropDownStyle = bindableObject as DropDownStyle;
460
461             if (null != dropDownStyle)
462             {
463                 Button.CopyFrom(dropDownStyle.Button);
464                 HeaderText.CopyFrom(dropDownStyle.HeaderText);
465                 ListBackgroundImage.CopyFrom(dropDownStyle.ListBackgroundImage);
466             }
467         }
468     }
469
470     /// <summary>
471     /// DropDownItemStyle is a class which saves DropDownItem's ux data.
472     /// </summary>
473     /// <since_tizen> 6 </since_tizen>
474     /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
475     [EditorBrowsable(EditorBrowsableState.Never)]
476     public class DropDownItemStyle : ControlStyle
477     {
478         /// <summary>
479         /// Creates a new instance of a DropDownItemStyle.
480         /// </summary>
481         /// <since_tizen> 6 </since_tizen>
482         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
483         [EditorBrowsable(EditorBrowsableState.Never)]
484         public DropDownItemStyle() : base() { }
485         /// <summary>
486         /// Creates a new instance of a DropDownItemStyle with style.
487         /// </summary>
488         /// <param name="style">Create DropDownItemStyle by style customized by user.</param>
489         /// <since_tizen> 6 </since_tizen>
490         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
491         [EditorBrowsable(EditorBrowsableState.Never)]
492         public DropDownItemStyle(DropDownItemStyle style) : base(style)
493         {
494             if (style.Text!= null)
495             {
496                 Text.CopyFrom(style.Text);
497             }
498
499             if (style.Icon!= null)
500             {
501                 Icon.CopyFrom(style.Icon);
502             }
503
504             if (style.CheckImage!= null)
505             {
506                 CheckImage.CopyFrom(style.CheckImage);
507             }
508
509             CheckImageGapToBoundary = style.CheckImageGapToBoundary;
510             IsSelected = style.IsSelected;
511         }
512
513         /// <summary>
514         /// Text's Style.
515         /// </summary>
516         /// <since_tizen> 6 </since_tizen>
517         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
518         [EditorBrowsable(EditorBrowsableState.Never)]
519         public TextLabelStyle Text
520         {
521             get;
522             set;
523         }
524
525         /// <summary>
526         /// Icon's Style.
527         /// </summary>
528         /// <since_tizen> 6 </since_tizen>
529         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
530         [EditorBrowsable(EditorBrowsableState.Never)]
531         public ImageViewStyle Icon
532         {
533             get;
534             set;
535         }
536
537         /// <summary>
538         /// Check image's Style.
539         /// </summary>
540         /// <since_tizen> 6 </since_tizen>
541         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
542         [EditorBrowsable(EditorBrowsableState.Never)]
543         public ImageViewStyle CheckImage
544         {
545             get;
546             set;
547         }
548
549         /// <summary>
550         /// Gap of Check image to boundary.
551         /// </summary>
552         /// <since_tizen> 6 </since_tizen>
553         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
554         [EditorBrowsable(EditorBrowsableState.Never)]
555         public int CheckImageGapToBoundary
556         {
557             get;
558             set;
559         }
560
561         /// <summary>
562         /// Flag to decide item is selected or not.
563         /// </summary>
564         /// <since_tizen> 6 </since_tizen>
565         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
566         [EditorBrowsable(EditorBrowsableState.Never)]
567         public bool IsSelected
568         {
569             get;
570             set;
571         }
572     }
573 }