[NUI] Fix Svace issue (#1167)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI.Components / Controls / DropDown.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;
18 using System.Collections.Generic;
19 using Tizen.NUI.BaseComponents;
20 using System.ComponentModel;
21 using Tizen.NUI.Binding;
22
23 namespace Tizen.NUI.Components
24 {
25     /// <summary>
26     /// DropDown is one kind of common component, a dropdown allows the user click dropdown button to choose one value from a list.
27     /// </summary>
28     /// <since_tizen> 6 </since_tizen>
29     /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
30     [EditorBrowsable(EditorBrowsableState.Never)]
31     public class DropDown : Control
32     {
33         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
34         [EditorBrowsable(EditorBrowsableState.Never)]
35         public static readonly BindableProperty ListPaddingProperty = BindableProperty.Create("ListPadding", typeof(Extents), typeof(Tizen.NUI.Components.DropDown), null, propertyChanged: (bindable, oldValue, newValue) =>
36         {
37             var instance = (Tizen.NUI.Components.DropDown)bindable;
38             if (newValue != null)
39             {
40                 instance.privateListPadding = (Extents)newValue;
41             }
42         },
43         defaultValueCreator: (bindable) =>
44         {
45             var instance = (Tizen.NUI.Components.DropDown)bindable;
46             return instance.privateListPadding;
47         });
48         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
49         [EditorBrowsable(EditorBrowsableState.Never)]
50         public static readonly BindableProperty ListSizeProperty = BindableProperty.Create("ListSize", typeof(Size), typeof(Tizen.NUI.Components.DropDown), null, propertyChanged: (bindable, oldValue, newValue) =>
51         {
52             var instance = (Tizen.NUI.Components.DropDown)bindable;
53             if (newValue != null)
54             {
55                 instance.privateListSize = (Size)newValue;
56             }
57         },
58         defaultValueCreator: (bindable) =>
59         {
60             var instance = (Tizen.NUI.Components.DropDown)bindable;
61             return instance.privateListSize;
62         });
63         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
64         [EditorBrowsable(EditorBrowsableState.Never)]
65         public static readonly BindableProperty SelectedItemIndexProperty = BindableProperty.Create("SelectedItemIndex", typeof(int), typeof(Tizen.NUI.Components.DropDown), 0, propertyChanged: (bindable, oldValue, newValue) =>
66         {
67             var instance = (Tizen.NUI.Components.DropDown)bindable;
68             if (newValue != null)
69             {
70                 instance.privateSelectedItemIndex = (int)newValue;
71             }
72         },
73         defaultValueCreator: (bindable) =>
74         {
75             var instance = (Tizen.NUI.Components.DropDown)bindable;
76             return instance.privateSelectedItemIndex;
77         });
78         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
79         [EditorBrowsable(EditorBrowsableState.Never)]
80         public static readonly BindableProperty FocusedItemIndexProperty = BindableProperty.Create("FocusedItemIndex", typeof(int), typeof(Tizen.NUI.Components.DropDown), 0, propertyChanged: (bindable, oldValue, newValue) =>
81         {
82             var instance = (Tizen.NUI.Components.DropDown)bindable;
83             if (newValue != null)
84             {
85                 instance.privateFocusedItemIndex = (int)newValue;
86             }
87         },
88         defaultValueCreator: (bindable) =>
89         {
90             var instance = (Tizen.NUI.Components.DropDown)bindable;
91             return instance.privateFocusedItemIndex;
92         });
93         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
94         [EditorBrowsable(EditorBrowsableState.Never)]
95         public static readonly BindableProperty ListMarginProperty = BindableProperty.Create("ListMargin", typeof(Extents), typeof(Tizen.NUI.Components.DropDown), null, propertyChanged: (bindable, oldValue, newValue) =>
96         {
97             var instance = (Tizen.NUI.Components.DropDown)bindable;
98             if (newValue != null)
99             {
100                 instance.privateListMargin = (Extents)newValue;
101             }
102         },
103         defaultValueCreator: (bindable) =>
104         {
105             var instance = (Tizen.NUI.Components.DropDown)bindable;
106             return instance.privateListMargin;
107         });
108         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
109         [EditorBrowsable(EditorBrowsableState.Never)]
110         public static readonly BindableProperty ListRelativeOrientationProperty = BindableProperty.Create("ListRelativeOrientation", typeof(ListOrientation), typeof(Tizen.NUI.Components.DropDown), ListOrientation.Left, propertyChanged: (bindable, oldValue, newValue) =>
111         {
112             var instance = (Tizen.NUI.Components.DropDown)bindable;
113             if (newValue != null)
114             {
115                 instance.privateListRelativeOrientation = (ListOrientation)newValue;
116             }
117         },
118         defaultValueCreator: (bindable) =>
119         {
120             var instance = (Tizen.NUI.Components.DropDown)bindable;
121             return instance.privateListRelativeOrientation;
122         });
123         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
124         [EditorBrowsable(EditorBrowsableState.Never)]
125         public static readonly BindableProperty SpaceProperty = BindableProperty.Create("Space", typeof(Extents), typeof(Tizen.NUI.Components.DropDown), null, propertyChanged: (bindable, oldValue, newValue) =>
126         {
127             var instance = (Tizen.NUI.Components.DropDown)bindable;
128             if (newValue != null)
129             {
130                 instance.privateSpace = (Extents)newValue;
131             }
132         },
133         defaultValueCreator: (bindable) =>
134         {
135             var instance = (Tizen.NUI.Components.DropDown)bindable;
136             return instance.privateSpace;
137         });
138         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
139         [EditorBrowsable(EditorBrowsableState.Never)]
140         public static readonly BindableProperty SpaceBetweenButtonTextAndIconProperty = BindableProperty.Create("SpaceBetweenButtonTextAndIcon", typeof(int), typeof(Tizen.NUI.Components.DropDown), 0, propertyChanged: (bindable, oldValue, newValue) =>
141         {
142             var instance = (Tizen.NUI.Components.DropDown)bindable;
143             if (newValue != null)
144             {
145                 instance.privateSpaceBetweenButtonTextAndIcon = (int)newValue;
146             }
147         },
148         defaultValueCreator: (bindable) =>
149         {
150             var instance = (Tizen.NUI.Components.DropDown)bindable;
151             return instance.privateSpaceBetweenButtonTextAndIcon;
152         });
153
154
155         #region DropDown
156         private Button button = null;
157         private TextLabel headerText = null;
158         private TextLabel buttonText = null;
159         private ImageView listBackgroundImage = null;
160
161         // Component that scrolls the child added to it.
162         private LayoutScroller layoutScroller = null;
163
164         // The LinearLayout container to house the items in the drop down list.
165         private View dropDownMenuFullList = null;
166
167         private DropDownListBridge adapter = new DropDownListBridge();
168         private int selectedItemIndex = -1;
169
170         private Extents listPadding = null;
171         DropDownItemView selectedItemView = null;
172
173         private bool itemPressed = false;
174
175         private TapGestureDetector tapGestureDetector = null;
176
177         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
178         [EditorBrowsable(EditorBrowsableState.Never)]
179         public new DropDownStyle Style => ViewStyle as DropDownStyle;
180
181         /// <summary>
182         /// Creates a new instance of a DropDown.
183         /// </summary>
184         /// <since_tizen> 6 </since_tizen>
185         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
186         [EditorBrowsable(EditorBrowsableState.Never)]
187         public DropDown() : base()
188         {
189         }
190
191         /// <summary>
192         /// Creates a new instance of a DropDown with style.
193         /// </summary>
194         /// <param name="style">Create DropDown by special style defined in UX.</param>
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 DropDown(string style) : base(style)
199         {
200         }
201
202         /// <summary>
203         /// Creates a new instance of a DropDown with attributes.
204         /// </summary>
205         /// <param name="attributes">Create DropDown by attributes customized by user.</param>
206         /// <since_tizen> 6 </since_tizen>
207         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
208         [EditorBrowsable(EditorBrowsableState.Never)]
209         public DropDown(DropDownStyle attributes) : base(attributes)
210         {
211         }
212
213         /// <summary>
214         /// An event for the button clicked signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
215         /// </summary>
216         /// <since_tizen> 6 </since_tizen>
217         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
218         [EditorBrowsable(EditorBrowsableState.Never)]
219         public delegate void ClickEventHandler<ClickEventArgs>(object sender, ClickEventArgs e);
220
221         /// <summary>
222         /// An event for the item clicked signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
223         /// </summary>
224         /// <since_tizen> 6 </since_tizen>
225         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
226         [EditorBrowsable(EditorBrowsableState.Never)]
227         public event ClickEventHandler<ItemClickEventArgs> ItemClickEvent;
228
229         /// <summary>
230         /// List position in relation to the main button.
231         /// </summary>
232         /// <since_tizen> 6 </since_tizen>
233         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
234         [EditorBrowsable(EditorBrowsableState.Never)]
235         public enum ListOrientation
236         {
237             /// <summary>
238             /// Left.
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             Left,
244             /// <summary>
245             /// Right.
246             /// </summary>
247             /// <since_tizen> 6 </since_tizen>
248             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
249             [EditorBrowsable(EditorBrowsableState.Never)]
250             Right,
251         }
252
253         /// <summary>
254         /// Space between button text and button icon in DropDown.
255         /// </summary>
256         /// <since_tizen> 6 </since_tizen>
257         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
258         public int SpaceBetweenButtonTextAndIcon
259         {
260             get
261             {
262                 return (int)GetValue(SpaceBetweenButtonTextAndIconProperty);
263             }
264             set
265             {
266                 SetValue(SpaceBetweenButtonTextAndIconProperty, value);
267             }
268         }
269         private int privateSpaceBetweenButtonTextAndIcon
270         {
271             get
272             {
273                 return (int)Style.SpaceBetweenButtonTextAndIcon;
274             }
275             set
276             {
277                 Style.SpaceBetweenButtonTextAndIcon = value;
278                 RelayoutRequest();
279             }
280         }
281
282         /// <summary>
283         /// Left space in DropDown.
284         /// </summary>
285         /// <since_tizen> 6 </since_tizen>
286         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
287         public Extents Space
288         {
289             get
290             {
291                 return (Extents)GetValue(SpaceProperty);
292             }
293             set
294             {
295                 SetValue(SpaceProperty, value);
296             }
297         }
298         private Extents privateSpace
299         {
300             get
301             {
302                 return (Extents)Style.Space;
303             }
304             set
305             {
306                 Style.Space = value;
307                 RelayoutRequest();
308             }
309         }
310
311         /// <summary>
312         /// List relative orientation in DropDown.
313         /// </summary>
314         /// <since_tizen> 6 </since_tizen>
315         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
316         public ListOrientation ListRelativeOrientation
317         {
318             get
319             {
320                 return (ListOrientation)GetValue(ListRelativeOrientationProperty);
321             }
322             set
323             {
324                 SetValue(ListRelativeOrientationProperty, value);
325                 RelayoutRequest();
326             }
327         }
328         private ListOrientation privateListRelativeOrientation
329         {
330             get
331             {
332                 return (ListOrientation)Style.ListRelativeOrientation;
333             }
334             set
335             {
336                 Style.ListRelativeOrientation = value;
337                 RelayoutRequest();
338             }
339         }
340
341         /// <summary>
342         /// Space in list.
343         /// </summary>
344         /// <since_tizen> 6 </since_tizen>
345         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
346         public Extents ListMargin
347         {
348             get
349             {
350                 return (Extents)GetValue(ListMarginProperty);
351             }
352             set
353             {
354                 SetValue(ListMarginProperty, value);
355             }
356         }
357         private Extents privateListMargin
358         {
359             get
360             {
361                 return Style.ListMargin;
362             }
363             set
364             {
365                 Style.ListMargin = value;
366                 RelayoutRequest();
367             }
368         }
369
370         /// <summary>
371         /// Focused item index in list.
372         /// </summary>
373         /// <since_tizen> 6 </since_tizen>
374         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
375         public int FocusedItemIndex
376         {
377             get
378             {
379                 return (int)GetValue(FocusedItemIndexProperty);
380             }
381             set
382             {
383                 SetValue(FocusedItemIndexProperty, value);
384             }
385         }
386         private int privateFocusedItemIndex
387         {
388             get
389             {
390                 return (int)Style.FocusedItemIndex;
391             }
392             set
393             {
394                 Style.FocusedItemIndex = value;
395                 RelayoutRequest();
396             }
397         }
398
399         /// <summary>
400         /// Selected item index in list.
401         /// </summary>
402         /// <since_tizen> 6 </since_tizen>
403         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
404         public int SelectedItemIndex
405         {
406             get
407             {
408                 return (int)GetValue(SelectedItemIndexProperty);
409             }
410             set
411             {
412                 if (value == selectedItemIndex || adapter == null || value >= adapter.GetItemCount())
413                 {
414                     return;
415                 }
416
417                 SetValue(SelectedItemIndexProperty, value); // UpdatesSelectedItem
418             }
419         }
420         private int privateSelectedItemIndex
421         {
422             get
423             {
424                 return selectedItemIndex;
425             }
426             set
427             {
428                 if (value == selectedItemIndex || adapter == null || value >= adapter.GetItemCount())
429                 {
430                     return;
431                 }
432                 UpdateSelectedItem(value);
433             }
434         }
435
436         /// <summary>
437         /// List size in DropDown.
438         /// </summary>
439         /// <since_tizen> 6 </since_tizen>
440         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
441         public Size ListSize
442         {
443             get
444             {
445                 return (Size)GetValue(ListSizeProperty);
446             }
447             set
448             {
449                 SetValue(ListSizeProperty, value);
450             }
451         }
452         private Size privateListSize
453         {
454             get
455             {
456                 return Style.ListSize;
457             }
458             set
459             {
460                 Style.ListSize = value;
461                 RelayoutRequest();
462             }
463         }
464
465         /// <summary>
466         /// List padding in DropDown.
467         /// </summary>
468         /// <since_tizen> 6 </since_tizen>
469         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
470         public Extents ListPadding
471         {
472             get
473             {
474                 return (Extents)GetValue(ListPaddingProperty);
475             }
476             set
477             {
478                 SetValue(ListPaddingProperty, value);
479             }
480         }
481         private Extents privateListPadding
482         {
483             get
484             {
485                 return listPadding;
486             }
487             set
488             {
489                 Style.ListPadding.CopyFrom(value);
490
491                 if (null == listPadding)
492                 {
493                     listPadding = new Extents((ushort start, ushort end, ushort top, ushort bottom) =>
494                     {
495                         Style.ListPadding.Start = start;
496                         Style.ListPadding.End = end;
497                         Style.ListPadding.Top = top;
498                         Style.ListPadding.Bottom = bottom;
499                         RelayoutRequest();
500                     }, value.Start, value.End, value.Top, value.Bottom);
501                 }
502                 else
503                 {
504                     listPadding.CopyFrom(value);
505                 }
506
507                 RelayoutRequest();
508             }
509         }
510
511         /// <summary>
512         /// Add list item by item data. The added item will be added to end of all items automatically.
513         /// </summary>
514         /// <param name="itemData">Item data which will apply to tab item view.</param>
515         /// <since_tizen> 6 </since_tizen>
516         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
517         [EditorBrowsable(EditorBrowsableState.Never)]
518         public void AddItem(DropDownDataItem itemData)
519         {
520            // Add item to adaptor, will be added to list via AddItemAt during OnUpdate()
521            int insertionPosition = adapter.GetItemCount();
522            adapter.InsertData(insertionPosition, itemData);
523         }
524
525         /// <summary>
526         /// Delete list item by index.
527         /// </summary>
528         /// <param name="index">Position index where will be deleted.</param>
529         /// <since_tizen> 6 </since_tizen>
530         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
531         [EditorBrowsable(EditorBrowsableState.Never)]
532         public void DeleteItem(int index)
533         {
534             if(index < 0 || index >= adapter.GetItemCount())
535             {
536                 return;
537             }
538
539             if (selectedItemIndex == index)
540             {
541                 selectedItemIndex = -1;
542             }
543             else if(selectedItemIndex > index)
544             {
545                 selectedItemIndex--;
546             }
547
548             adapter.RemoveData(index);
549
550             if(index < dropDownMenuFullList?.ChildCount)
551             {
552                 View childToRemove = dropDownMenuFullList?.GetChildAt((uint)index);
553                 if (childToRemove)
554                 {
555                     childToRemove.TouchEvent -= ListItemTouchEvent;
556                     dropDownMenuFullList?.Remove(childToRemove);
557                     dropDownMenuFullList?.Layout?.RequestLayout();
558                 }
559             }
560         }
561
562         /// <summary>
563         /// Insert list item by item data. The inserted item will be added to the special position by index automatically.
564         /// </summary>
565         /// <param name="item">Item data which will apply to tab item view.</param>
566         /// <param name="index">Position index where will be inserted.</param>
567         /// <since_tizen> 6 </since_tizen>
568         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
569         [EditorBrowsable(EditorBrowsableState.Never)]
570         public void InsertItem(DropDownDataItem item, int index)
571         {
572             if (index < 0 || index >= adapter.GetItemCount())
573             {
574                 return;
575             }
576
577             if (selectedItemIndex >= index)
578             {
579                 selectedItemIndex++;
580             }
581
582             adapter.InsertData(index, item);
583         }
584
585         /// <summary>
586         /// Add scroll bar to list.
587         /// </summary>
588         /// <param name="scrollBar">Scroll bar defined by user which will be added to list.</param>
589         /// <since_tizen> 6 </since_tizen>
590         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
591         [EditorBrowsable(EditorBrowsableState.Never)]
592         public void AttachScrollBar(ScrollBar scrollBar)
593         {
594             if (layoutScroller == null)
595             {
596                 return;
597             }
598             Tizen.Log.Error("DropDown","Feature unsupported");
599         }
600
601         /// <summary>
602         /// Detach scroll bar to list.
603         /// </summary>
604         /// <since_tizen> 6 </since_tizen>
605         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
606         [EditorBrowsable(EditorBrowsableState.Never)]
607         public void DetachScrollBar()
608         {
609             if (layoutScroller == null)
610             {
611                 return;
612             }
613             Tizen.Log.Error("DropDown","Feature unsupported");
614         }
615
616         protected override void RegisterDetectionOfSubstyleChanges()
617         {
618             base.RegisterDetectionOfSubstyleChanges();
619
620             Style.PropertyChanged += DropDownAttributesPropertyChanged;
621             Style.HeaderText.PropertyChanged += HeaderTextAttributesPropertyChanged;
622             Style.Button.PropertyChanged += ButtonAttributesPropertyChanged;
623
624             Style.Button.Icon.PropertyChanged += IconStylePropertyChanged;;
625         }
626
627         private void IconStylePropertyChanged(object sender, PropertyChangedEventArgs e)
628         {
629             int iconWidth = 0;
630             int buttonTextWidth = 0;
631             if (e.PropertyName.Equals(ImageViewStyle.SizeProperty.PropertyName))
632             {
633                 iconWidth = (int)Style.Button.Icon.Size.Width;
634             }
635
636             if (buttonText.NaturalSize2D != null)
637             {
638                 buttonTextWidth = buttonText.NaturalSize2D.Width;
639             }
640
641             button.SizeWidth = iconWidth + (int)Style.SpaceBetweenButtonTextAndIcon + buttonTextWidth;
642         }
643
644         private void DropDownAttributesPropertyChanged(object sender, PropertyChangedEventArgs e)
645         {
646             if (e.PropertyName.Equals("Space"))
647             {
648                 button.Position2D.X = (int)Style.Space.Start;
649             }
650         }
651
652         private void ButtonAttributesPropertyChanged(object sender, PropertyChangedEventArgs e)
653         {
654             if (null == button)
655             {
656                 button = new Button()
657                 {
658                     PositionUsesPivotPoint = true,
659                     ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft,
660                     PivotPoint = Tizen.NUI.PivotPoint.TopLeft,
661                     HeightResizePolicy = ResizePolicyType.FillToParent,
662                     IconRelativeOrientation = Components.Button.IconOrientation.Right,
663                 };
664                 button.Name = "DropDownButton";
665                 button.ClickEvent += ButtonClickEvent;
666                 Add(button);
667
668                 button.ApplyStyle(Style.Button);
669             }
670
671             if (null == buttonText)
672             {
673                 buttonText = new TextLabel()
674                 {
675                     PositionUsesPivotPoint = true,
676                     ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft,
677                     PivotPoint = Tizen.NUI.PivotPoint.TopLeft,
678                     WidthResizePolicy = ResizePolicyType.UseNaturalSize,
679                     HeightResizePolicy = ResizePolicyType.FillToParent,
680                 };
681                 buttonText.Name = "DropDownButtonText";
682                 Add(buttonText);
683                 buttonText.Hide();
684             }
685         }
686
687         private void HeaderTextAttributesPropertyChanged(object sender, PropertyChangedEventArgs e)
688         {
689             if (null == headerText)
690             {
691                 headerText = new TextLabel();
692                 headerText.Name = "DropDownHeaderText";
693                 Add(headerText);
694
695                 headerText.ApplyStyle(Style.HeaderText);
696             }
697         }
698
699         /// <summary>
700         /// Update DropDown by attributes.
701         /// </summary>
702         /// <since_tizen> 6 </since_tizen>
703         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
704         [EditorBrowsable(EditorBrowsableState.Never)]
705         protected override void OnUpdate()
706         {
707             if (Style.ListBackgroundImage != null)
708             {
709                 if (listBackgroundImage == null)
710                 {
711                     CreateListBackgroundImage();
712                 }
713
714                 int temp = (int)Style.FocusedItemIndex;
715
716                 if (layoutScroller==null) // layoutScroller used to test of ListContainer Setup invoked already
717                 {
718                     SetUpListContainer();
719                 }
720
721                 listBackgroundImage.Size = Style.ListSize;
722
723                 // Resize and position scrolling list within the drop down list container.  Can be used to position list in relation to the background image.
724                 layoutScroller.Size = Style.ListSize - new Size((Style.ListPadding.Start + Style.ListPadding.End), (Style.ListPadding.Top + Style.ListPadding.Bottom), 0 );
725                 layoutScroller.Position2D = new Position2D(Style.ListPadding.Start,Style.ListPadding.Top);
726
727                 int listBackgroundImageX = 0;
728                 int listBackgroundImageY = 0;
729                 if (Style.ListRelativeOrientation == ListOrientation.Left)
730                 {
731                     if (Style.ListMargin != null)
732                     {
733                         listBackgroundImageX = (int)Style.ListMargin.Start;
734                         listBackgroundImageY = (int)Style.ListMargin.Top;
735                     }
736                 }
737                 else if (Style.ListRelativeOrientation == ListOrientation.Right)
738                 {
739                     if (Style.ListMargin != null)
740                     {
741                         int listWidth = 0;
742                         if (dropDownMenuFullList.Size2D != null)
743                         {
744                             listWidth = dropDownMenuFullList.Size2D.Width;
745                         }
746                         listBackgroundImageX = Size2D.Width - listWidth - (int)Style.ListMargin.End;
747                         listBackgroundImageY = (int)Style.ListMargin.Top;
748                     }
749                 }
750                 listBackgroundImage.Position2D = new Position2D(listBackgroundImageX, listBackgroundImageY);
751                 dropDownMenuFullList?.Layout?.RequestLayout();
752
753                 int numberOfItemsToAdd = adapter.GetItemCount();
754
755                 if (adapter.AdapterPurge == true)
756                 {
757                     adapter.AdapterPurge = false;
758                     for (int i =0; i<numberOfItemsToAdd; i++)
759                     {
760                         AddItemAt(adapter.GetData(i), i);
761                     }
762                 }
763
764                         // Set selection icon on View
765                 UpdateSelectedItem(selectedItemIndex);
766             }
767         }
768
769         /// <summary>
770         /// Dispose DropDown and all children on it.
771         /// </summary>
772         /// <param name="type">Dispose type.</param>
773         /// <since_tizen> 6 </since_tizen>
774         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
775         [EditorBrowsable(EditorBrowsableState.Never)]
776         protected override void Dispose(DisposeTypes type)
777         {
778             if (disposed)
779             {
780                 return;
781             }
782
783             if (type == DisposeTypes.Explicit)
784             {
785                 if (headerText != null)
786                 {
787                     Utility.Dispose(headerText);
788                 }
789
790                 if (buttonText != null)
791                 {
792                     Utility.Dispose(buttonText);
793                 }
794
795                 if (button != null)
796                 {
797                     Utility.Dispose(button);
798                 }
799
800                 if (layoutScroller != null)
801                 {
802                     if (dropDownMenuFullList != null)
803                     {
804                         Utility.Dispose(dropDownMenuFullList);
805                     }
806
807                     if (listBackgroundImage != null)
808                     {
809                         Utility.Dispose(listBackgroundImage);
810                     }
811
812                     Utility.Dispose(layoutScroller);
813                 }
814             }
815
816             base.Dispose(type);
817         }
818
819         /// <summary>
820         /// Get DropDown attribues.
821         /// </summary>
822         /// <since_tizen> 6 </since_tizen>
823         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
824         [EditorBrowsable(EditorBrowsableState.Never)]
825         protected override ViewStyle GetViewStyle()
826         {
827             return new DropDownStyle();
828         }
829
830         private void AddItemAt(DropDownDataItem itemData,int index)
831         {
832             ViewHolder viewHolder = adapter.OnCreateViewHolder();
833             if (!viewHolder.IsBound)
834             {
835                 adapter.BindViewHolder(viewHolder, index);
836                 viewHolder.IsBound = true;
837             }
838
839             if (tapGestureDetector == null)
840             {
841                 tapGestureDetector = new TapGestureDetector();
842             }
843             View view = viewHolder.ItemView;
844             view.TouchEvent += ListItemTouchEvent;
845             dropDownMenuFullList.Add(view);
846         }
847
848         private void OnClickEvent(object sender, ItemClickEventArgs e)
849         {
850             ItemClickEvent?.Invoke(sender, e);
851         }
852         private void CreateHeaderText()
853         {
854             headerText = new TextLabel();
855             headerText.Name = "DropDownHeaderText";
856             Add(headerText);
857         }
858
859         private void SetUpListContainer()
860         {
861             LinearLayout linear = new LinearLayout()
862             {
863                 LinearOrientation = LinearLayout.Orientation.Vertical,
864             };
865
866             dropDownMenuFullList = new View()
867             {
868                 Layout = linear,
869                 Name = "DropDownMenuList",
870                 WidthSpecification = LayoutParamPolicies.MatchParent,
871                 HeightSpecification = LayoutParamPolicies.WrapContent,
872                 Focusable = true,
873             };
874
875             layoutScroller = new LayoutScroller()
876             {
877                 Name = "LayoutScroller",
878             };
879             layoutScroller.AddLayoutToScroll(dropDownMenuFullList);
880
881             listBackgroundImage.Add(layoutScroller);
882             listBackgroundImage.Hide();
883         }
884
885         private View GetViewFromIndex(uint index)
886         {
887             if ((index < dropDownMenuFullList.ChildCount) && (index >=0) )
888             {
889                 return dropDownMenuFullList.GetChildAt(index);
890             }
891             else
892             {
893                 return null;
894             }
895         }
896
897         private void SetListItemToSelected(DropDownItemView targetItemView)
898         {
899             // Set the DropDownItemView matching the targetItemView to selected.
900             if (selectedItemView!=targetItemView)
901             {
902                 if (selectedItemView!=null)
903                 {
904                     // clear selection status of currently selected item view
905                     selectedItemView.IsSelected = false;
906                 }
907                 // Set target item to selected
908                 targetItemView.IsSelected = true;
909                 selectedItemView = targetItemView;
910             }
911         }
912
913         private bool ListItemTouchEvent(object sender, TouchEventArgs e)
914         {
915             PointStateType state = e.Touch.GetState(0);
916             DropDownItemView touchedView = sender as DropDownItemView;;
917             switch (state)
918             {
919                 case PointStateType.Down:
920                     if (touchedView != null && touchedView.BackgroundColorSelector != null)
921                     {
922                         touchedView.BackgroundColor = touchedView.BackgroundColorSelector.GetValue(ControlStates.Pressed);
923                     }
924                     itemPressed = true;  // if matched with a Up then a click event.
925                     break;
926                 case PointStateType.Motion:
927                     if (touchedView != null && touchedView.BackgroundColorSelector != null)
928                     {
929                         touchedView.BackgroundColor = touchedView.BackgroundColorSelector.GetValue(ControlStates.Normal);
930                     }
931                     itemPressed = false;
932                     break;
933                 case PointStateType.Up:
934                     if (touchedView != null && touchedView.BackgroundColorSelector != null)
935                     {
936                         touchedView.BackgroundColor = touchedView.BackgroundColorSelector.GetValue(ControlStates.Selected);
937
938                         if (itemPressed)  // if Down was previously sent without motion (Scrolling) in-between then a clicked event occurred.
939                         {
940                             // List item clicked
941                             Console.WriteLine("Tapped{0}", touchedView.Name);
942                             SetListItemToSelected(touchedView);
943                             button.Text = touchedView.Text;
944                             button.Show();
945                             listBackgroundImage.Hide();
946                         }
947                     }
948                     break;
949                 default:
950                     break;
951             }
952             return true;
953         }
954
955         private void UpdateSelectedItem(int index)
956         {
957             if (selectedItemIndex != -1)
958             {
959                 DropDownDataItem data = adapter.GetData(selectedItemIndex);
960                 if(data != null)
961                 {
962                     data.IsSelected = false;
963                 }
964                 DropDownItemView listItemView = dropDownMenuFullList.GetChildAt((uint)selectedItemIndex) as DropDownItemView;
965                 SetListItemToSelected(listItemView);
966             }
967
968             if (index != -1)
969             {
970                 DropDownDataItem data = adapter.GetData(index);
971                 if (data != null)
972                 {
973                     data.IsSelected = true;
974                     DropDownItemView listItemView = dropDownMenuFullList?.GetChildAt((uint)index) as DropDownItemView;
975                     if(listItemView)
976                     {
977                         SetListItemToSelected(listItemView);
978                     }
979                 }
980             }
981
982             selectedItemIndex = index;
983             dropDownMenuFullList?.Layout?.RequestLayout();
984         }
985
986         private void CreateListBackgroundImage()
987         {
988             if (null == listBackgroundImage)
989             {
990                 listBackgroundImage = new ImageView
991                 {
992                     Name = "ListBackgroundImage",
993                     PositionUsesPivotPoint = true,
994                     ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft,
995                     PivotPoint = Tizen.NUI.PivotPoint.TopLeft,
996                     WidthResizePolicy = ResizePolicyType.FitToChildren,
997                     HeightResizePolicy = ResizePolicyType.FitToChildren,
998                 };
999                 Add(listBackgroundImage);
1000             }
1001         }
1002
1003         private void ButtonClickEvent(object sender, Button.ClickEventArgs e)
1004         {
1005             button.Hide();
1006             listBackgroundImage.Show();
1007             dropDownMenuFullList?.Layout?.RequestLayout();
1008             listBackgroundImage.RaiseToTop();
1009         }
1010
1011         private void CreateHeaderTextAttributes()
1012         {
1013             if (Style.HeaderText == null)
1014             {
1015                 Style.HeaderText = new TextLabelStyle()
1016                 {
1017                     PositionUsesPivotPoint = true,
1018                     ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft,
1019                     PivotPoint = Tizen.NUI.PivotPoint.TopLeft,
1020                     WidthResizePolicy = ResizePolicyType.FillToParent,
1021                     HeightResizePolicy = ResizePolicyType.FillToParent,
1022                     HorizontalAlignment = HorizontalAlignment.Center,
1023                     VerticalAlignment = VerticalAlignment.Center,
1024                 };
1025             }
1026         }
1027
1028         private void CreateButtonAttributes()
1029         {
1030             if (Style.Button == null)
1031             {
1032                 Style.Button = new ButtonStyle();
1033             }
1034         }
1035
1036         private void CreateButtonTextAttributes()
1037         {
1038             CreateButtonAttributes();
1039
1040             if (Style.Button.Text== null)
1041             {
1042                 Style.Button.Text= new TextLabelStyle
1043                 {
1044                     PositionUsesPivotPoint = true,
1045                     ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft,
1046                     PivotPoint = Tizen.NUI.PivotPoint.TopLeft,
1047                     WidthResizePolicy = ResizePolicyType.UseNaturalSize,
1048                     HeightResizePolicy = ResizePolicyType.FillToParent,
1049                     Position = new Position(0, 0),
1050                     HorizontalAlignment = HorizontalAlignment.Begin,
1051                     VerticalAlignment = VerticalAlignment.Center,
1052                 };
1053             }
1054         }
1055
1056         private void CreateButtonIconAttributes()
1057         {
1058             CreateButtonAttributes();
1059
1060             if (Style.Button.Icon== null)
1061             {
1062                 Style.Button.Icon= new ImageViewStyle
1063                 {
1064                     PositionUsesPivotPoint = true,
1065                     ParentOrigin = Tizen.NUI.ParentOrigin.CenterRight,
1066                     PivotPoint = Tizen.NUI.PivotPoint.CenterRight,
1067                 };
1068             }
1069         }
1070
1071         private void CreateListBackgroundAttributes()
1072         {
1073             if (Style.ListBackgroundImage == null)
1074             {
1075                 Style.ListBackgroundImage = new ImageViewStyle
1076                 {
1077                     PositionUsesPivotPoint = true,
1078                     ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft,
1079                     PivotPoint = Tizen.NUI.PivotPoint.TopLeft,
1080                 };
1081             }
1082         }
1083         #endregion
1084
1085         #region ItemClickEventArgs
1086         /// <summary>
1087         /// ItemClickEventArgs is a class to record item click event arguments which will sent to user.
1088         /// </summary>
1089         /// <since_tizen> 6 </since_tizen>
1090         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1091         [EditorBrowsable(EditorBrowsableState.Never)]
1092         public class ItemClickEventArgs : EventArgs
1093         {
1094             /// <summary> Clicked item index of DropDown's list </summary>
1095             /// <since_tizen> 6 </since_tizen>
1096             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1097             [EditorBrowsable(EditorBrowsableState.Never)]
1098             public int Index;
1099             /// <summary> Clicked item text string of DropDown's list </summary>
1100             /// <since_tizen> 6 </since_tizen>
1101             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1102             [EditorBrowsable(EditorBrowsableState.Never)]
1103             public string Text;
1104         }
1105         #endregion
1106
1107         #region DropDownDataItem
1108         /// <summary>
1109         /// DropDownDataItem is a class to record all data which will be applied to DropDown item.
1110         /// </summary>
1111         /// <since_tizen> 6 </since_tizen>
1112         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1113         //[EditorBrowsable(EditorBrowsableState.Never)]
1114         public class DropDownDataItem
1115         {
1116             private DropDownItemStyle itemDataStyle = new DropDownItemStyle();
1117
1118             /// <summary>
1119             /// Creates a new instance of a DropDownItemData.
1120             /// </summary>
1121             /// <since_tizen> 6 </since_tizen>
1122             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1123             [EditorBrowsable(EditorBrowsableState.Never)]
1124             public DropDownDataItem()
1125             {
1126                 Initialize();
1127             }
1128
1129             /// <summary>
1130             /// Creates a new instance of a DropDownItemData with style.
1131             /// </summary>
1132             /// <param name="style">Create DropDownItemData by special style defined in UX.</param>
1133             /// <since_tizen> 6 </since_tizen>
1134             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1135             [EditorBrowsable(EditorBrowsableState.Never)]
1136             public DropDownDataItem(string style)
1137             {
1138                 if(style != null)
1139                 {
1140                     ViewStyle attributes = StyleManager.Instance.GetAttributes(style);
1141                     if(attributes == null)
1142                     {
1143                         throw new InvalidOperationException($"There is no style {style}");
1144                     }
1145                     itemDataStyle = attributes as DropDownItemStyle;
1146                 }
1147                 Initialize();
1148             }
1149
1150             /// <summary>
1151             /// Creates a new instance of a DropDownItemData with style.
1152             /// </summary>
1153             /// <param name="style">Create DropDownItemData by style customized by user.</param>
1154             /// <since_tizen> 6 </since_tizen>
1155             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1156             [EditorBrowsable(EditorBrowsableState.Never)]
1157             public DropDownDataItem(DropDownItemStyle style)
1158             {
1159                 itemDataStyle.CopyFrom(style);
1160                 Initialize();
1161             }
1162
1163             /// <summary>
1164             /// DropDown item size.
1165             /// </summary>
1166             /// <since_tizen> 6 </since_tizen>
1167             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1168             [EditorBrowsable(EditorBrowsableState.Never)]
1169             public Size Size
1170             {
1171                 get
1172                 {
1173                     return itemDataStyle.Size;
1174                 }
1175                 set
1176                 {
1177                     itemDataStyle.Size = value;
1178                 }
1179             }
1180
1181             /// <summary>
1182             /// DropDown item background color selector.
1183             /// </summary>
1184             /// <since_tizen> 6 </since_tizen>
1185             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1186             [EditorBrowsable(EditorBrowsableState.Never)]
1187             public Selector<Color> BackgroundColorSelector
1188             {
1189                 get
1190                 {
1191                     return itemDataStyle.BackgroundColor;
1192                 }
1193                 set
1194                 {
1195                     if (itemDataStyle.BackgroundColor == null)
1196                     {
1197                         itemDataStyle.BackgroundColor = new Selector<Color>();
1198                     }
1199
1200                     itemDataStyle.BackgroundColor?.Clone(value);
1201                 }
1202             }
1203
1204             /// <summary>
1205             /// DropDown item text string.
1206             /// </summary>
1207             /// <since_tizen> 6 </since_tizen>
1208             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1209             [EditorBrowsable(EditorBrowsableState.Never)]
1210             public string Text
1211             {
1212                 get
1213                 {
1214                     return itemDataStyle.Text?.Text?.All;
1215                 }
1216                 set
1217                 {
1218                     CreateTextAttributes();
1219                     if (itemDataStyle.Text.Text == null)
1220                     {
1221                         itemDataStyle.Text.Text = new Selector<string> { All = value };
1222                     }
1223                     else
1224                     {
1225                         itemDataStyle.Text.Text.All = value;
1226                     }
1227                 }
1228             }
1229
1230             /// <summary>
1231             /// DropDown item text's point size.
1232             /// </summary>
1233             /// <since_tizen> 6 </since_tizen>
1234             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1235             [EditorBrowsable(EditorBrowsableState.Never)]
1236             public float PointSize
1237             {
1238                 get
1239                 {
1240                     return itemDataStyle.Text?.PointSize?.All ?? 0;
1241                 }
1242                 set
1243                 {
1244                     CreateTextAttributes();
1245                     if (itemDataStyle.Text.PointSize == null)
1246                     {
1247                         itemDataStyle.Text.PointSize = new Selector<float?> { All = value };
1248                     }
1249                     else
1250                     {
1251                         itemDataStyle.Text.PointSize.All = value;
1252                     }
1253                 }
1254             }
1255
1256             /// <summary>
1257             /// DropDown item text's font family.
1258             /// </summary>
1259             /// <since_tizen> 6 </since_tizen>
1260             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1261             [EditorBrowsable(EditorBrowsableState.Never)]
1262             public string FontFamily
1263             {
1264                 get
1265                 {
1266                     return "";
1267                     //return itemDataAttributes.TextAttributes?.FontFamily?.GetValue(State);
1268                 }
1269                 set
1270                 {
1271                     CreateTextAttributes();
1272                     itemDataStyle.Text.FontFamily = value;
1273                 }
1274             }
1275
1276             /// <summary>
1277             /// DropDown item text's position.
1278             /// </summary>
1279             /// <since_tizen> 6 </since_tizen>
1280             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1281             [EditorBrowsable(EditorBrowsableState.Never)]
1282             public Position TextPosition
1283             {
1284                 get
1285                 {
1286                     return itemDataStyle.Text?.Position;
1287                 }
1288                 set
1289                 {
1290                     CreateTextAttributes();
1291                     itemDataStyle.Text.Position = value;
1292                 }
1293             }
1294
1295             /// <summary>
1296             /// DropDown item's icon's resource url.
1297             /// </summary>
1298             /// <since_tizen> 6 </since_tizen>
1299             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1300             [EditorBrowsable(EditorBrowsableState.Never)]
1301             public string IconResourceUrl
1302             {
1303                 get
1304                 {
1305                     return itemDataStyle.Icon?.ResourceUrl?.All;
1306                 }
1307                 set
1308                 {
1309                     CreateIconAttributes();
1310                     if (itemDataStyle.Icon.ResourceUrl == null)
1311                     {
1312                         itemDataStyle.Icon.ResourceUrl = new Selector<string> { All = value };
1313                     }
1314                     else
1315                     {
1316                         itemDataStyle.Icon.ResourceUrl.All = value;
1317                     }
1318                 }
1319             }
1320
1321             /// <summary>
1322             /// DropDown item's icon's size.
1323             /// </summary>
1324             /// <since_tizen> 6 </since_tizen>
1325             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1326             [EditorBrowsable(EditorBrowsableState.Never)]
1327             public Size IconSize
1328             {
1329                 get
1330                 {
1331                     return itemDataStyle.Icon?.Size;
1332                 }
1333                 set
1334                 {
1335                     CreateIconAttributes();
1336                     itemDataStyle.Icon.Size = value;
1337                 }
1338             }
1339
1340             /// <summary>
1341             /// DropDown item's icon's position.
1342             /// </summary>
1343             /// <since_tizen> 6 </since_tizen>
1344             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1345             [EditorBrowsable(EditorBrowsableState.Never)]
1346             public Position IconPosition
1347             {
1348                 get
1349                 {
1350                     return itemDataStyle.Icon.Position;
1351                 }
1352                 set
1353                 {
1354                     CreateIconAttributes();
1355                     itemDataStyle.Icon.Position = value;
1356                 }
1357             }
1358
1359             /// <summary>
1360             /// DropDown item's check image's resource url.
1361             /// </summary>
1362             /// <since_tizen> 6 </since_tizen>
1363             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1364             [EditorBrowsable(EditorBrowsableState.Never)]
1365             public string CheckImageResourceUrl
1366             {
1367                 get
1368                 {
1369                     return itemDataStyle.CheckImage?.ResourceUrl?.All;
1370                 }
1371                 set
1372                 {
1373                     CreateCheckImageAttributes();
1374                     if (itemDataStyle.CheckImage.ResourceUrl == null)
1375                     {
1376                         itemDataStyle.CheckImage.ResourceUrl = new Selector<string> { All = value };
1377                     }
1378                     else
1379                     {
1380                         itemDataStyle.CheckImage.ResourceUrl.All = value;
1381                     }
1382                 }
1383             }
1384
1385             /// <summary>
1386             /// DropDown item's check image's size.
1387             /// </summary>
1388             /// <since_tizen> 6 </since_tizen>
1389             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1390             [EditorBrowsable(EditorBrowsableState.Never)]
1391             public Size CheckImageSize
1392             {
1393                 get
1394                 {
1395                     return itemDataStyle.CheckImage?.Size;
1396                 }
1397                 set
1398                 {
1399                     CreateCheckImageAttributes();
1400                     itemDataStyle.CheckImage.Size = value;
1401                 }
1402             }
1403
1404             /// <summary>
1405             /// DropDown item's check image's right space.
1406             /// </summary>
1407             /// <since_tizen> 6 </since_tizen>
1408             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1409             [EditorBrowsable(EditorBrowsableState.Never)]
1410             public int CheckImageGapToBoundary
1411             {
1412                 get
1413                 {
1414                     return itemDataStyle.CheckImageGapToBoundary;
1415                 }
1416                 set
1417                 {
1418                     itemDataStyle.CheckImageGapToBoundary = value;
1419                 }
1420             }
1421
1422             /// <summary>
1423             /// Flag to decide DropDown item is selected or not.
1424             /// </summary>
1425             /// <since_tizen> 6 </since_tizen>
1426             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1427             [EditorBrowsable(EditorBrowsableState.Never)]
1428             public bool IsSelected
1429             {
1430                 get
1431                 {
1432                     return itemDataStyle.IsSelected;
1433                 }
1434                 set
1435                 {
1436                     itemDataStyle.IsSelected = value;
1437                 }
1438             }
1439
1440             private void Initialize()
1441             {
1442                 if (itemDataStyle == null)
1443                 {
1444                     throw new Exception("Button attribute parse error.");
1445                 }
1446             }
1447
1448             private void CreateTextAttributes()
1449             {
1450                 if(itemDataStyle.Text== null)
1451                 {
1452                     itemDataStyle.Text= new TextLabelStyle
1453                     {
1454                         PositionUsesPivotPoint = true,
1455                         ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft,
1456                         PivotPoint = Tizen.NUI.PivotPoint.TopLeft,
1457                         WidthResizePolicy = ResizePolicyType.UseNaturalSize,
1458                         HeightResizePolicy = ResizePolicyType.FillToParent,
1459                         VerticalAlignment = VerticalAlignment.Center,
1460                         HorizontalAlignment = HorizontalAlignment.Begin,
1461                     };
1462                 }
1463             }
1464
1465             private void CreateIconAttributes()
1466             {
1467                 if (itemDataStyle.Icon== null)
1468                 {
1469                     itemDataStyle.Icon= new ImageViewStyle
1470                     {
1471                         PositionUsesPivotPoint = true,
1472                         ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft,
1473                         PivotPoint = Tizen.NUI.PivotPoint.TopLeft,
1474                     };
1475                 }
1476             }
1477
1478             private void CreateCheckImageAttributes()
1479             {
1480                 if (itemDataStyle.CheckImage== null)
1481                 {
1482                     itemDataStyle.CheckImage= new ImageViewStyle
1483                     {
1484                         PositionUsesPivotPoint = true,
1485                         ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft,
1486                         PivotPoint = Tizen.NUI.PivotPoint.TopLeft,
1487                     };
1488                 }
1489             }
1490         }
1491         #endregion
1492
1493         #region DropDownItemView
1494         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1495         [EditorBrowsable(EditorBrowsableState.Never)]
1496         internal class DropDownItemView : Control
1497         {
1498             private TextLabel mText = null;
1499             private ImageView mIcon = null;
1500             private ImageView mCheck = null;
1501
1502             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1503             [EditorBrowsable(EditorBrowsableState.Never)]
1504             public DropDownItemView() : base()
1505             {
1506             }
1507
1508             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1509             [EditorBrowsable(EditorBrowsableState.Never)]
1510             public Selector<Color> BackgroundColorSelector
1511             {
1512                 get;
1513                 set;
1514             }
1515
1516             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1517             [EditorBrowsable(EditorBrowsableState.Never)]
1518             public string Text
1519             {
1520                 get
1521                 {
1522                     if(mText == null)
1523                     {
1524                         return null;
1525                     }
1526                     return mText.Text;
1527                 }
1528                 set
1529                 {
1530                     CreateText();
1531                     mText.Text = value;
1532                 }
1533             }
1534
1535             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1536             [EditorBrowsable(EditorBrowsableState.Never)]
1537             public string FontFamily
1538             {
1539                 get
1540                 {
1541                     if (mText == null)
1542                     {
1543                         return null;
1544                     }
1545                     return mText.FontFamily;
1546                 }
1547                 set
1548                 {
1549                     CreateText();
1550                     mText.FontFamily = value;
1551                 }
1552             }
1553
1554             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1555             [EditorBrowsable(EditorBrowsableState.Never)]
1556             public float? PointSize
1557             {
1558                 get
1559                 {
1560                     if (mText == null)
1561                     {
1562                         return 0;
1563                     }
1564                     return mText.PointSize;
1565                 }
1566                 set
1567                 {
1568                     CreateText();
1569                     mText.PointSize = (float)value;
1570                 }
1571             }
1572
1573             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1574             [EditorBrowsable(EditorBrowsableState.Never)]
1575             public Color TextColor
1576             {
1577                 get
1578                 {
1579                     if (mText == null)
1580                     {
1581                         return null;
1582                     }
1583                     return mText.TextColor;
1584                 }
1585                 set
1586                 {
1587                     CreateText();
1588                     mText.TextColor = value;
1589                 }
1590             }
1591
1592             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1593             [EditorBrowsable(EditorBrowsableState.Never)]
1594             public Position TextPosition
1595             {
1596                 get
1597                 {
1598                     if (mText == null)
1599                     {
1600                         return null;
1601                     }
1602                     return mText.Position;
1603                 }
1604                 set
1605                 {
1606                     CreateText();
1607                     mText.Position = value;
1608                 }
1609             }
1610
1611             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1612             [EditorBrowsable(EditorBrowsableState.Never)]
1613             public string IconResourceUrl
1614             {
1615                 get
1616                 {
1617                     if (mIcon == null)
1618                     {
1619                         return null;
1620                     }
1621                     return mIcon.ResourceUrl;
1622                 }
1623                 set
1624                 {
1625                     CreateIcon();
1626                     mIcon.ResourceUrl = value;
1627                 }
1628             }
1629
1630             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1631             [EditorBrowsable(EditorBrowsableState.Never)]
1632             public Size IconSize
1633             {
1634                 get
1635                 {
1636                     if (mIcon == null)
1637                     {
1638                         return null;
1639                     }
1640                     return mIcon.Size;
1641                 }
1642                 set
1643                 {
1644                     CreateIcon();
1645                     mIcon.Size = value;
1646                 }
1647             }
1648
1649             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1650             [EditorBrowsable(EditorBrowsableState.Never)]
1651             public Position IconPosition
1652             {
1653                 get
1654                 {
1655                     if (mIcon == null)
1656                     {
1657                         return null;
1658                     }
1659                     return mIcon.Position;
1660                 }
1661                 set
1662                 {
1663                     CreateIcon();
1664                     mIcon.Position = value;
1665                 }
1666             }
1667
1668             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1669             [EditorBrowsable(EditorBrowsableState.Never)]
1670             public string CheckResourceUrl
1671             {
1672                 get
1673                 {
1674                     if (mCheck == null)
1675                     {
1676                         return null;
1677                     }
1678                     return mCheck.ResourceUrl;
1679                 }
1680                 set
1681                 {
1682                     CreateCheckImage();
1683                     mCheck.ResourceUrl = value;
1684                 }
1685             }
1686
1687             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1688             [EditorBrowsable(EditorBrowsableState.Never)]
1689             public Position CheckPosition
1690             {
1691                 get
1692                 {
1693                     if (mCheck == null)
1694                     {
1695                         return null;
1696                     }
1697                     return mCheck.Position;
1698                 }
1699                 set
1700                 {
1701                     CreateCheckImage();
1702                     mCheck.Position = value;
1703                 }
1704             }
1705
1706             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1707             [EditorBrowsable(EditorBrowsableState.Never)]
1708             public Size CheckImageSize
1709             {
1710                 get
1711                 {
1712                     if (mCheck == null)
1713                     {
1714                         return null;
1715                     }
1716                     return mCheck.Size;
1717                 }
1718                 set
1719                 {
1720                     CreateCheckImage();
1721                     mCheck.Size = value;
1722                 }
1723             }
1724
1725             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1726             [EditorBrowsable(EditorBrowsableState.Never)]
1727             public bool IsSelected
1728             {
1729                 get
1730                 {
1731                     if (mCheck == null)
1732                     {
1733                         return false;
1734                     }
1735                     return mCheck.Visibility;
1736                 }
1737                 set
1738                 {
1739                     CreateCheckImage();
1740                     if(value)
1741                     {
1742                         mCheck.Show();
1743                     }
1744                     else
1745                     {
1746                         mCheck.Hide();
1747                     }
1748                 }
1749             }
1750
1751             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1752             [EditorBrowsable(EditorBrowsableState.Never)]
1753             protected override void Dispose(DisposeTypes type)
1754             {
1755                 if (disposed)
1756                 {
1757                     return;
1758                 }
1759
1760                 if (type == DisposeTypes.Explicit)
1761                 {
1762                     if (mText != null)
1763                     {
1764                         Remove(mText);
1765                         mText.Dispose();
1766                         mText = null;
1767                     }
1768
1769                     if (mIcon != null)
1770                     {
1771                         Remove(mIcon);
1772                         mIcon.Dispose();
1773                         mIcon = null;
1774                     }
1775
1776                     if (mCheck != null)
1777                     {
1778                         Remove(mCheck);
1779                         mCheck.Dispose();
1780                         mCheck = null;
1781                     }
1782                 }
1783                 base.Dispose(type);
1784             }
1785
1786             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1787             [EditorBrowsable(EditorBrowsableState.Never)]
1788             protected override ViewStyle GetViewStyle()
1789             {
1790                 return null;
1791             }
1792
1793             private void CreateIcon()
1794             {
1795                 if(mIcon == null)
1796                 {
1797                     mIcon = new ImageView()
1798                     {
1799                         PositionUsesPivotPoint = true,
1800                         ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft,
1801                         PivotPoint = Tizen.NUI.PivotPoint.TopLeft,
1802                     };
1803                     Add(mIcon);
1804                 }
1805             }
1806
1807             private void CreateText()
1808             {
1809                 if (mText == null)
1810                 {
1811                     mText = new TextLabel()
1812                     {
1813                         PositionUsesPivotPoint = true,
1814                         ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft,
1815                         PivotPoint = Tizen.NUI.PivotPoint.TopLeft,
1816                         WidthResizePolicy = ResizePolicyType.UseNaturalSize,
1817                         HeightResizePolicy = ResizePolicyType.FillToParent,
1818                         VerticalAlignment = VerticalAlignment.Center,
1819                         HorizontalAlignment = HorizontalAlignment.Begin,
1820                     };
1821                     Add(mText);
1822                 }
1823             }
1824
1825             private void CreateCheckImage()
1826             {
1827                 if (mCheck == null)
1828                 {
1829                     mCheck = new ImageView()
1830                     {
1831                         PositionUsesPivotPoint = true,
1832                         ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft,
1833                         PivotPoint = Tizen.NUI.PivotPoint.TopLeft,
1834                         Name = "checkedImage",
1835                     };
1836                     Add(mCheck);
1837                 }
1838                 mCheck.Hide();
1839             }
1840         }
1841         #endregion
1842
1843         #region DropDownListBridge
1844
1845         /// <summary>
1846         /// DropDownListBridge is bridge to connect item data and an item View.
1847         /// </summary>
1848         /// <since_tizen> 6 </since_tizen>
1849         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1850         [EditorBrowsable(EditorBrowsableState.Never)]
1851         public class DropDownListBridge
1852         {
1853             private List<DropDownDataItem> itemDataList = new List<DropDownDataItem>();
1854
1855             internal bool AdapterPurge {get;set;} = false;  // Set to true if adapter content changed since last iteration.
1856
1857             /// <summary>
1858             /// Creates a new instance of a DropDownListBridge.
1859             /// </summary>
1860             /// <since_tizen> 6 </since_tizen>
1861             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1862             [EditorBrowsable(EditorBrowsableState.Never)]
1863             public DropDownListBridge()
1864             {
1865             }
1866
1867             /// <summary>
1868             /// Insert data. The inserted data will be added to the special position by index automatically.
1869             /// </summary>
1870             /// <param name="position">Position index where will be inserted.</param>
1871             /// <param name="data">Item data which will apply to tab item view.</param>
1872             /// <since_tizen> 6 </since_tizen>
1873             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1874             [EditorBrowsable(EditorBrowsableState.Never)]
1875             public void InsertData(int position, DropDownDataItem data)
1876             {
1877                 if(position == -1)
1878                 {
1879                     position = itemDataList.Count;
1880                 }
1881                 itemDataList.Insert(position, data);
1882                 AdapterPurge = true;
1883             }
1884
1885             /// <summary>
1886             /// Remove data by position.
1887             /// </summary>
1888             /// <param name="position">Position index where will be removed.</param>
1889             /// <since_tizen> 6 </since_tizen>
1890             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1891             [EditorBrowsable(EditorBrowsableState.Never)]
1892             public void RemoveData(int position)
1893             {
1894                 itemDataList.RemoveAt(position);
1895                 AdapterPurge = true;
1896             }
1897
1898             /// <summary>
1899             /// Get data by position.
1900             /// </summary>
1901             /// <param name="position">Position index where will be gotten.</param>
1902             /// <since_tizen> 6 </since_tizen>
1903             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1904             [EditorBrowsable(EditorBrowsableState.Never)]
1905             public DropDownDataItem GetData(int position)
1906             {
1907                 return itemDataList[position];
1908             }
1909
1910             /// <summary>
1911             /// Get view holder by view type.
1912             /// </summary>
1913             /// <since_tizen> 6 </since_tizen>
1914             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1915             [EditorBrowsable(EditorBrowsableState.Never)]
1916             public ViewHolder OnCreateViewHolder()
1917             {
1918                 ViewHolder viewHolder = new ViewHolder(new DropDownItemView());
1919
1920                 return viewHolder;
1921             }
1922
1923             /// <summary>
1924             /// Bind ViewHolder with View.
1925             /// </summary>
1926             /// <param name="holder">View holder.</param>
1927             /// <param name="position">Position index of source data.</param>
1928             /// <since_tizen> 6 </since_tizen>
1929             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1930             [EditorBrowsable(EditorBrowsableState.Never)]
1931             public void BindViewHolder(ViewHolder holder, int position)
1932             {
1933                 DropDownDataItem listItemData = itemDataList[position];
1934                 if(listItemData == null)
1935                 {
1936                     return;
1937                 }
1938                 DropDownItemView listItemView = holder.ItemView as DropDownItemView;
1939                 listItemView.Name = "Item" + position;
1940                 if (listItemData.Size != null)
1941                 {
1942                     if (listItemData.Size.Width > 0)
1943                     {
1944                         holder.ItemView.WidthSpecification = (int)listItemData.Size.Width;
1945                     }
1946                     else
1947                     {
1948                         holder.ItemView.WidthSpecification = LayoutParamPolicies.MatchParent;
1949                     }
1950
1951                     if (listItemData.Size.Height > 0)
1952                     {
1953                         holder.ItemView.HeightSpecification = (int)listItemData.Size.Height;
1954                     }
1955                     else
1956                     {
1957                         holder.ItemView.HeightSpecification = LayoutParamPolicies.MatchParent;
1958                     }
1959                 }
1960
1961                 if (listItemView != null)
1962                 {
1963                     listItemView.BackgroundColorSelector = listItemData.BackgroundColorSelector;
1964                     if (listItemData.Text != null)
1965                     {
1966                         listItemView.Text = listItemData.Text;
1967                         listItemView.PointSize = listItemData.PointSize;
1968                         listItemView.FontFamily = listItemData.FontFamily;
1969                         listItemView.TextPosition = listItemData.TextPosition;
1970                     }
1971
1972                     if (listItemData.IconResourceUrl != null)
1973                     {
1974                         listItemView.IconResourceUrl = listItemData.IconResourceUrl;
1975                         listItemView.IconSize = listItemData.IconSize;
1976                         if (listItemView.IconSize != null)
1977                         {
1978                             listItemView.IconPosition = new Position(listItemData.IconPosition.X, (listItemView.Size2D.Height - listItemView.IconSize.Height) / 2);
1979                         }
1980                     }
1981
1982                     if (listItemData.CheckImageResourceUrl != null)
1983                     {
1984                         listItemView.CheckResourceUrl = listItemData.CheckImageResourceUrl;
1985                         listItemView.CheckImageSize = listItemData.CheckImageSize;
1986                         if (listItemView.CheckImageSize != null)
1987                         {
1988                             listItemView.CheckPosition = new Position(listItemView.Size2D.Width - listItemData.CheckImageGapToBoundary - listItemView.CheckImageSize.Width, (listItemView.Size2D.Height - listItemView.CheckImageSize.Height) / 2);
1989                         }
1990                     }
1991
1992                     listItemView.IsSelected = listItemData.IsSelected;
1993                 }
1994             }
1995
1996             /// <summary>
1997             /// Destroy view holder, it can be override.
1998             /// </summary>
1999             /// <param name="holder">View holder.</param>
2000             /// <since_tizen> 6 </since_tizen>
2001             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
2002             [EditorBrowsable(EditorBrowsableState.Never)]
2003             public void OnDestroyViewHolder(ViewHolder holder)
2004             {
2005                 if (holder.ItemView != null)
2006                 {
2007                     holder.ItemView.Dispose();
2008                 }
2009             }
2010
2011             /// <summary>
2012             /// Get item count, it can be override.
2013             /// </summary>
2014             /// <since_tizen> 6 </since_tizen>
2015             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
2016             [EditorBrowsable(EditorBrowsableState.Never)]
2017             public int GetItemCount()
2018             {
2019                 return itemDataList.Count;
2020             }
2021         }
2022         #endregion
2023
2024         #region ViewHolder
2025
2026         /// <summary>
2027         /// A ViewHolder is a class that holds a View created from DropDownListBridge data.
2028         /// </summary>
2029         /// <since_tizen> 6 </since_tizen>
2030         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
2031         [EditorBrowsable(EditorBrowsableState.Never)]
2032         public class ViewHolder
2033         {
2034             /// <summary>
2035             /// ViewHolder constructor.
2036             /// </summary>
2037             /// <param name="itemView">View</param>
2038             /// <since_tizen> 6 </since_tizen>
2039             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
2040             [EditorBrowsable(EditorBrowsableState.Never)]
2041             public ViewHolder(View itemView)
2042             {
2043                 if (itemView == null)
2044                 {
2045                     throw new ArgumentNullException("itemView may not be null");
2046                 }
2047                 this.ItemView = itemView;
2048             }
2049
2050             /// <summary>
2051             /// Returns the view.
2052             /// </summary>
2053             /// <since_tizen> 6 </since_tizen>
2054             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
2055             [EditorBrowsable(EditorBrowsableState.Never)]
2056             public View ItemView { get; }
2057
2058               internal bool IsBound
2059             {
2060                 get;
2061                 set;
2062             }
2063
2064         }
2065
2066         #endregion
2067
2068     }
2069 }