DropDownButton to use Layout scrolling (#1160)
[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                 data.IsSelected = false;
966                 SetListItemToSelected(listItemView);
967             }
968
969             if (index != -1)
970             {
971                 DropDownDataItem data = adapter.GetData(index);
972                 if (data != null)
973                 {
974                     data.IsSelected = true;
975                     DropDownItemView listItemView = dropDownMenuFullList?.GetChildAt((uint)index) as DropDownItemView;
976                     if(listItemView)
977                     {
978                         SetListItemToSelected(listItemView);
979                     }
980                 }
981             }
982
983             selectedItemIndex = index;
984             dropDownMenuFullList?.Layout?.RequestLayout();
985         }
986
987         private void CreateListBackgroundImage()
988         {
989             if (null == listBackgroundImage)
990             {
991                 listBackgroundImage = new ImageView
992                 {
993                     Name = "ListBackgroundImage",
994                     PositionUsesPivotPoint = true,
995                     ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft,
996                     PivotPoint = Tizen.NUI.PivotPoint.TopLeft,
997                     WidthResizePolicy = ResizePolicyType.FitToChildren,
998                     HeightResizePolicy = ResizePolicyType.FitToChildren,
999                 };
1000                 Add(listBackgroundImage);
1001             }
1002         }
1003
1004         private void ButtonClickEvent(object sender, Button.ClickEventArgs e)
1005         {
1006             button.Hide();
1007             listBackgroundImage.Show();
1008             dropDownMenuFullList?.Layout?.RequestLayout();
1009             listBackgroundImage.RaiseToTop();
1010         }
1011
1012         private void CreateHeaderTextAttributes()
1013         {
1014             if (Style.HeaderText == null)
1015             {
1016                 Style.HeaderText = new TextLabelStyle()
1017                 {
1018                     PositionUsesPivotPoint = true,
1019                     ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft,
1020                     PivotPoint = Tizen.NUI.PivotPoint.TopLeft,
1021                     WidthResizePolicy = ResizePolicyType.FillToParent,
1022                     HeightResizePolicy = ResizePolicyType.FillToParent,
1023                     HorizontalAlignment = HorizontalAlignment.Center,
1024                     VerticalAlignment = VerticalAlignment.Center,
1025                 };
1026             }
1027         }
1028
1029         private void CreateButtonAttributes()
1030         {
1031             if (Style.Button == null)
1032             {
1033                 Style.Button = new ButtonStyle();
1034             }
1035         }
1036
1037         private void CreateButtonTextAttributes()
1038         {
1039             CreateButtonAttributes();
1040
1041             if (Style.Button.Text== null)
1042             {
1043                 Style.Button.Text= new TextLabelStyle
1044                 {
1045                     PositionUsesPivotPoint = true,
1046                     ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft,
1047                     PivotPoint = Tizen.NUI.PivotPoint.TopLeft,
1048                     WidthResizePolicy = ResizePolicyType.UseNaturalSize,
1049                     HeightResizePolicy = ResizePolicyType.FillToParent,
1050                     Position = new Position(0, 0),
1051                     HorizontalAlignment = HorizontalAlignment.Begin,
1052                     VerticalAlignment = VerticalAlignment.Center,
1053                 };
1054             }
1055         }
1056
1057         private void CreateButtonIconAttributes()
1058         {
1059             CreateButtonAttributes();
1060
1061             if (Style.Button.Icon== null)
1062             {
1063                 Style.Button.Icon= new ImageViewStyle
1064                 {
1065                     PositionUsesPivotPoint = true,
1066                     ParentOrigin = Tizen.NUI.ParentOrigin.CenterRight,
1067                     PivotPoint = Tizen.NUI.PivotPoint.CenterRight,
1068                 };
1069             }
1070         }
1071
1072         private void CreateListBackgroundAttributes()
1073         {
1074             if (Style.ListBackgroundImage == null)
1075             {
1076                 Style.ListBackgroundImage = new ImageViewStyle
1077                 {
1078                     PositionUsesPivotPoint = true,
1079                     ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft,
1080                     PivotPoint = Tizen.NUI.PivotPoint.TopLeft,
1081                 };
1082             }
1083         }
1084         #endregion
1085
1086         #region ItemClickEventArgs
1087         /// <summary>
1088         /// ItemClickEventArgs is a class to record item click event arguments which will sent to user.
1089         /// </summary>
1090         /// <since_tizen> 6 </since_tizen>
1091         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1092         [EditorBrowsable(EditorBrowsableState.Never)]
1093         public class ItemClickEventArgs : EventArgs
1094         {
1095             /// <summary> Clicked item index of DropDown's list </summary>
1096             /// <since_tizen> 6 </since_tizen>
1097             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1098             [EditorBrowsable(EditorBrowsableState.Never)]
1099             public int Index;
1100             /// <summary> Clicked item text string of DropDown's list </summary>
1101             /// <since_tizen> 6 </since_tizen>
1102             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1103             [EditorBrowsable(EditorBrowsableState.Never)]
1104             public string Text;
1105         }
1106         #endregion
1107
1108         #region DropDownDataItem
1109         /// <summary>
1110         /// DropDownDataItem is a class to record all data which will be applied to DropDown item.
1111         /// </summary>
1112         /// <since_tizen> 6 </since_tizen>
1113         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1114         //[EditorBrowsable(EditorBrowsableState.Never)]
1115         public class DropDownDataItem
1116         {
1117             private DropDownItemStyle itemDataStyle = new DropDownItemStyle();
1118
1119             /// <summary>
1120             /// Creates a new instance of a DropDownItemData.
1121             /// </summary>
1122             /// <since_tizen> 6 </since_tizen>
1123             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1124             [EditorBrowsable(EditorBrowsableState.Never)]
1125             public DropDownDataItem()
1126             {
1127                 Initialize();
1128             }
1129
1130             /// <summary>
1131             /// Creates a new instance of a DropDownItemData with style.
1132             /// </summary>
1133             /// <param name="style">Create DropDownItemData by special style defined in UX.</param>
1134             /// <since_tizen> 6 </since_tizen>
1135             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1136             [EditorBrowsable(EditorBrowsableState.Never)]
1137             public DropDownDataItem(string style)
1138             {
1139                 if(style != null)
1140                 {
1141                     ViewStyle attributes = StyleManager.Instance.GetAttributes(style);
1142                     if(attributes == null)
1143                     {
1144                         throw new InvalidOperationException($"There is no style {style}");
1145                     }
1146                     itemDataStyle = attributes as DropDownItemStyle;
1147                 }
1148                 Initialize();
1149             }
1150
1151             /// <summary>
1152             /// Creates a new instance of a DropDownItemData with style.
1153             /// </summary>
1154             /// <param name="style">Create DropDownItemData by style customized by user.</param>
1155             /// <since_tizen> 6 </since_tizen>
1156             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1157             [EditorBrowsable(EditorBrowsableState.Never)]
1158             public DropDownDataItem(DropDownItemStyle style)
1159             {
1160                 itemDataStyle.CopyFrom(style);
1161                 Initialize();
1162             }
1163
1164             /// <summary>
1165             /// DropDown item size.
1166             /// </summary>
1167             /// <since_tizen> 6 </since_tizen>
1168             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1169             [EditorBrowsable(EditorBrowsableState.Never)]
1170             public Size Size
1171             {
1172                 get
1173                 {
1174                     return itemDataStyle.Size;
1175                 }
1176                 set
1177                 {
1178                     itemDataStyle.Size = value;
1179                 }
1180             }
1181
1182             /// <summary>
1183             /// DropDown item background color selector.
1184             /// </summary>
1185             /// <since_tizen> 6 </since_tizen>
1186             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1187             [EditorBrowsable(EditorBrowsableState.Never)]
1188             public Selector<Color> BackgroundColorSelector
1189             {
1190                 get
1191                 {
1192                     return itemDataStyle.BackgroundColor;
1193                 }
1194                 set
1195                 {
1196                     if (itemDataStyle.BackgroundColor == null)
1197                     {
1198                         itemDataStyle.BackgroundColor = new Selector<Color>();
1199                     }
1200
1201                     itemDataStyle.BackgroundColor.Clone(value);
1202                 }
1203             }
1204
1205             /// <summary>
1206             /// DropDown item text string.
1207             /// </summary>
1208             /// <since_tizen> 6 </since_tizen>
1209             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1210             [EditorBrowsable(EditorBrowsableState.Never)]
1211             public string Text
1212             {
1213                 get
1214                 {
1215                     return itemDataStyle.Text?.Text?.All;
1216                 }
1217                 set
1218                 {
1219                     CreateTextAttributes();
1220                     if (itemDataStyle.Text.Text == null)
1221                     {
1222                         itemDataStyle.Text.Text = new Selector<string> { All = value };
1223                     }
1224                     else
1225                     {
1226                         itemDataStyle.Text.Text.All = value;
1227                     }
1228                 }
1229             }
1230
1231             /// <summary>
1232             /// DropDown item text's point size.
1233             /// </summary>
1234             /// <since_tizen> 6 </since_tizen>
1235             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1236             [EditorBrowsable(EditorBrowsableState.Never)]
1237             public float PointSize
1238             {
1239                 get
1240                 {
1241                     return itemDataStyle.Text?.PointSize?.All ?? 0;
1242                 }
1243                 set
1244                 {
1245                     CreateTextAttributes();
1246                     if (itemDataStyle.Text.PointSize == null)
1247                     {
1248                         itemDataStyle.Text.PointSize = new Selector<float?> { All = value };
1249                     }
1250                     else
1251                     {
1252                         itemDataStyle.Text.PointSize.All = value;
1253                     }
1254                 }
1255             }
1256
1257             /// <summary>
1258             /// DropDown item text's font family.
1259             /// </summary>
1260             /// <since_tizen> 6 </since_tizen>
1261             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1262             [EditorBrowsable(EditorBrowsableState.Never)]
1263             public string FontFamily
1264             {
1265                 get
1266                 {
1267                     return "";
1268                     //return itemDataAttributes.TextAttributes?.FontFamily?.GetValue(State);
1269                 }
1270                 set
1271                 {
1272                     CreateTextAttributes();
1273                     itemDataStyle.Text.FontFamily = value;
1274                 }
1275             }
1276
1277             /// <summary>
1278             /// DropDown item text's position.
1279             /// </summary>
1280             /// <since_tizen> 6 </since_tizen>
1281             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1282             [EditorBrowsable(EditorBrowsableState.Never)]
1283             public Position TextPosition
1284             {
1285                 get
1286                 {
1287                     return itemDataStyle.Text?.Position;
1288                 }
1289                 set
1290                 {
1291                     CreateTextAttributes();
1292                     itemDataStyle.Text.Position = value;
1293                 }
1294             }
1295
1296             /// <summary>
1297             /// DropDown item's icon's resource url.
1298             /// </summary>
1299             /// <since_tizen> 6 </since_tizen>
1300             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1301             [EditorBrowsable(EditorBrowsableState.Never)]
1302             public string IconResourceUrl
1303             {
1304                 get
1305                 {
1306                     return itemDataStyle.Icon?.ResourceUrl?.All;
1307                 }
1308                 set
1309                 {
1310                     CreateIconAttributes();
1311                     if (itemDataStyle.Icon.ResourceUrl == null)
1312                     {
1313                         itemDataStyle.Icon.ResourceUrl = new Selector<string> { All = value };
1314                     }
1315                     else
1316                     {
1317                         itemDataStyle.Icon.ResourceUrl.All = value;
1318                     }
1319                 }
1320             }
1321
1322             /// <summary>
1323             /// DropDown item's icon's size.
1324             /// </summary>
1325             /// <since_tizen> 6 </since_tizen>
1326             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1327             [EditorBrowsable(EditorBrowsableState.Never)]
1328             public Size IconSize
1329             {
1330                 get
1331                 {
1332                     return itemDataStyle.Icon?.Size;
1333                 }
1334                 set
1335                 {
1336                     CreateIconAttributes();
1337                     itemDataStyle.Icon.Size = value;
1338                 }
1339             }
1340
1341             /// <summary>
1342             /// DropDown item's icon's position.
1343             /// </summary>
1344             /// <since_tizen> 6 </since_tizen>
1345             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1346             [EditorBrowsable(EditorBrowsableState.Never)]
1347             public Position IconPosition
1348             {
1349                 get
1350                 {
1351                     return itemDataStyle.Icon.Position;
1352                 }
1353                 set
1354                 {
1355                     CreateIconAttributes();
1356                     itemDataStyle.Icon.Position = value;
1357                 }
1358             }
1359
1360             /// <summary>
1361             /// DropDown item's check image's resource url.
1362             /// </summary>
1363             /// <since_tizen> 6 </since_tizen>
1364             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1365             [EditorBrowsable(EditorBrowsableState.Never)]
1366             public string CheckImageResourceUrl
1367             {
1368                 get
1369                 {
1370                     return itemDataStyle.CheckImage?.ResourceUrl?.All;
1371                 }
1372                 set
1373                 {
1374                     CreateCheckImageAttributes();
1375                     if (itemDataStyle.CheckImage.ResourceUrl == null)
1376                     {
1377                         itemDataStyle.CheckImage.ResourceUrl = new Selector<string> { All = value };
1378                     }
1379                     else
1380                     {
1381                         itemDataStyle.CheckImage.ResourceUrl.All = value;
1382                     }
1383                 }
1384             }
1385
1386             /// <summary>
1387             /// DropDown item's check image's size.
1388             /// </summary>
1389             /// <since_tizen> 6 </since_tizen>
1390             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1391             [EditorBrowsable(EditorBrowsableState.Never)]
1392             public Size CheckImageSize
1393             {
1394                 get
1395                 {
1396                     return itemDataStyle.CheckImage?.Size;
1397                 }
1398                 set
1399                 {
1400                     CreateCheckImageAttributes();
1401                     itemDataStyle.CheckImage.Size = value;
1402                 }
1403             }
1404
1405             /// <summary>
1406             /// DropDown item's check image's right space.
1407             /// </summary>
1408             /// <since_tizen> 6 </since_tizen>
1409             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1410             [EditorBrowsable(EditorBrowsableState.Never)]
1411             public int CheckImageGapToBoundary
1412             {
1413                 get
1414                 {
1415                     return itemDataStyle.CheckImageGapToBoundary;
1416                 }
1417                 set
1418                 {
1419                     itemDataStyle.CheckImageGapToBoundary = value;
1420                 }
1421             }
1422
1423             /// <summary>
1424             /// Flag to decide DropDown item is selected or not.
1425             /// </summary>
1426             /// <since_tizen> 6 </since_tizen>
1427             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1428             [EditorBrowsable(EditorBrowsableState.Never)]
1429             public bool IsSelected
1430             {
1431                 get
1432                 {
1433                     return itemDataStyle.IsSelected;
1434                 }
1435                 set
1436                 {
1437                     itemDataStyle.IsSelected = value;
1438                 }
1439             }
1440
1441             private void Initialize()
1442             {
1443                 if (itemDataStyle == null)
1444                 {
1445                     throw new Exception("Button attribute parse error.");
1446                 }
1447             }
1448
1449             private void CreateTextAttributes()
1450             {
1451                 if(itemDataStyle.Text== null)
1452                 {
1453                     itemDataStyle.Text= new TextLabelStyle
1454                     {
1455                         PositionUsesPivotPoint = true,
1456                         ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft,
1457                         PivotPoint = Tizen.NUI.PivotPoint.TopLeft,
1458                         WidthResizePolicy = ResizePolicyType.UseNaturalSize,
1459                         HeightResizePolicy = ResizePolicyType.FillToParent,
1460                         VerticalAlignment = VerticalAlignment.Center,
1461                         HorizontalAlignment = HorizontalAlignment.Begin,
1462                     };
1463                 }
1464             }
1465
1466             private void CreateIconAttributes()
1467             {
1468                 if (itemDataStyle.Icon== null)
1469                 {
1470                     itemDataStyle.Icon= new ImageViewStyle
1471                     {
1472                         PositionUsesPivotPoint = true,
1473                         ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft,
1474                         PivotPoint = Tizen.NUI.PivotPoint.TopLeft,
1475                     };
1476                 }
1477             }
1478
1479             private void CreateCheckImageAttributes()
1480             {
1481                 if (itemDataStyle.CheckImage== null)
1482                 {
1483                     itemDataStyle.CheckImage= new ImageViewStyle
1484                     {
1485                         PositionUsesPivotPoint = true,
1486                         ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft,
1487                         PivotPoint = Tizen.NUI.PivotPoint.TopLeft,
1488                     };
1489                 }
1490             }
1491         }
1492         #endregion
1493
1494         #region DropDownItemView
1495         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1496         [EditorBrowsable(EditorBrowsableState.Never)]
1497         internal class DropDownItemView : Control
1498         {
1499             private TextLabel mText = null;
1500             private ImageView mIcon = null;
1501             private ImageView mCheck = null;
1502
1503             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1504             [EditorBrowsable(EditorBrowsableState.Never)]
1505             public DropDownItemView() : base()
1506             {
1507             }
1508
1509             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1510             [EditorBrowsable(EditorBrowsableState.Never)]
1511             public Selector<Color> BackgroundColorSelector
1512             {
1513                 get;
1514                 set;
1515             }
1516
1517             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1518             [EditorBrowsable(EditorBrowsableState.Never)]
1519             public string Text
1520             {
1521                 get
1522                 {
1523                     if(mText == null)
1524                     {
1525                         return null;
1526                     }
1527                     return mText.Text;
1528                 }
1529                 set
1530                 {
1531                     CreateText();
1532                     mText.Text = value;
1533                 }
1534             }
1535
1536             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1537             [EditorBrowsable(EditorBrowsableState.Never)]
1538             public string FontFamily
1539             {
1540                 get
1541                 {
1542                     if (mText == null)
1543                     {
1544                         return null;
1545                     }
1546                     return mText.FontFamily;
1547                 }
1548                 set
1549                 {
1550                     CreateText();
1551                     mText.FontFamily = value;
1552                 }
1553             }
1554
1555             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1556             [EditorBrowsable(EditorBrowsableState.Never)]
1557             public float? PointSize
1558             {
1559                 get
1560                 {
1561                     if (mText == null)
1562                     {
1563                         return 0;
1564                     }
1565                     return mText.PointSize;
1566                 }
1567                 set
1568                 {
1569                     CreateText();
1570                     mText.PointSize = (float)value;
1571                 }
1572             }
1573
1574             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1575             [EditorBrowsable(EditorBrowsableState.Never)]
1576             public Color TextColor
1577             {
1578                 get
1579                 {
1580                     if (mText == null)
1581                     {
1582                         return null;
1583                     }
1584                     return mText.TextColor;
1585                 }
1586                 set
1587                 {
1588                     CreateText();
1589                     mText.TextColor = value;
1590                 }
1591             }
1592
1593             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1594             [EditorBrowsable(EditorBrowsableState.Never)]
1595             public Position TextPosition
1596             {
1597                 get
1598                 {
1599                     if (mText == null)
1600                     {
1601                         return null;
1602                     }
1603                     return mText.Position;
1604                 }
1605                 set
1606                 {
1607                     CreateText();
1608                     mText.Position = value;
1609                 }
1610             }
1611
1612             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1613             [EditorBrowsable(EditorBrowsableState.Never)]
1614             public string IconResourceUrl
1615             {
1616                 get
1617                 {
1618                     if (mIcon == null)
1619                     {
1620                         return null;
1621                     }
1622                     return mIcon.ResourceUrl;
1623                 }
1624                 set
1625                 {
1626                     CreateIcon();
1627                     mIcon.ResourceUrl = value;
1628                 }
1629             }
1630
1631             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1632             [EditorBrowsable(EditorBrowsableState.Never)]
1633             public Size IconSize
1634             {
1635                 get
1636                 {
1637                     if (mIcon == null)
1638                     {
1639                         return null;
1640                     }
1641                     return mIcon.Size;
1642                 }
1643                 set
1644                 {
1645                     CreateIcon();
1646                     mIcon.Size = value;
1647                 }
1648             }
1649
1650             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1651             [EditorBrowsable(EditorBrowsableState.Never)]
1652             public Position IconPosition
1653             {
1654                 get
1655                 {
1656                     if (mIcon == null)
1657                     {
1658                         return null;
1659                     }
1660                     return mIcon.Position;
1661                 }
1662                 set
1663                 {
1664                     CreateIcon();
1665                     mIcon.Position = value;
1666                 }
1667             }
1668
1669             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1670             [EditorBrowsable(EditorBrowsableState.Never)]
1671             public string CheckResourceUrl
1672             {
1673                 get
1674                 {
1675                     if (mCheck == null)
1676                     {
1677                         return null;
1678                     }
1679                     return mCheck.ResourceUrl;
1680                 }
1681                 set
1682                 {
1683                     CreateCheckImage();
1684                     mCheck.ResourceUrl = value;
1685                 }
1686             }
1687
1688             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1689             [EditorBrowsable(EditorBrowsableState.Never)]
1690             public Position CheckPosition
1691             {
1692                 get
1693                 {
1694                     if (mCheck == null)
1695                     {
1696                         return null;
1697                     }
1698                     return mCheck.Position;
1699                 }
1700                 set
1701                 {
1702                     CreateCheckImage();
1703                     mCheck.Position = value;
1704                 }
1705             }
1706
1707             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1708             [EditorBrowsable(EditorBrowsableState.Never)]
1709             public Size CheckImageSize
1710             {
1711                 get
1712                 {
1713                     if (mCheck == null)
1714                     {
1715                         return null;
1716                     }
1717                     return mCheck.Size;
1718                 }
1719                 set
1720                 {
1721                     CreateCheckImage();
1722                     mCheck.Size = value;
1723                 }
1724             }
1725
1726             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1727             [EditorBrowsable(EditorBrowsableState.Never)]
1728             public bool IsSelected
1729             {
1730                 get
1731                 {
1732                     if (mCheck == null)
1733                     {
1734                         return false;
1735                     }
1736                     return mCheck.Visibility;
1737                 }
1738                 set
1739                 {
1740                     CreateCheckImage();
1741                     if(value)
1742                     {
1743                         mCheck.Show();
1744                     }
1745                     else
1746                     {
1747                         mCheck.Hide();
1748                     }
1749                 }
1750             }
1751
1752             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1753             [EditorBrowsable(EditorBrowsableState.Never)]
1754             protected override void Dispose(DisposeTypes type)
1755             {
1756                 if (disposed)
1757                 {
1758                     return;
1759                 }
1760
1761                 if (type == DisposeTypes.Explicit)
1762                 {
1763                     if (mText != null)
1764                     {
1765                         Remove(mText);
1766                         mText.Dispose();
1767                         mText = null;
1768                     }
1769
1770                     if (mIcon != null)
1771                     {
1772                         Remove(mIcon);
1773                         mIcon.Dispose();
1774                         mIcon = null;
1775                     }
1776
1777                     if (mCheck != null)
1778                     {
1779                         Remove(mCheck);
1780                         mCheck.Dispose();
1781                         mCheck = null;
1782                     }
1783                 }
1784                 base.Dispose(type);
1785             }
1786
1787             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1788             [EditorBrowsable(EditorBrowsableState.Never)]
1789             protected override ViewStyle GetViewStyle()
1790             {
1791                 return null;
1792             }
1793
1794             private void CreateIcon()
1795             {
1796                 if(mIcon == null)
1797                 {
1798                     mIcon = new ImageView()
1799                     {
1800                         PositionUsesPivotPoint = true,
1801                         ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft,
1802                         PivotPoint = Tizen.NUI.PivotPoint.TopLeft,
1803                     };
1804                     Add(mIcon);
1805                 }
1806             }
1807
1808             private void CreateText()
1809             {
1810                 if (mText == null)
1811                 {
1812                     mText = new TextLabel()
1813                     {
1814                         PositionUsesPivotPoint = true,
1815                         ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft,
1816                         PivotPoint = Tizen.NUI.PivotPoint.TopLeft,
1817                         WidthResizePolicy = ResizePolicyType.UseNaturalSize,
1818                         HeightResizePolicy = ResizePolicyType.FillToParent,
1819                         VerticalAlignment = VerticalAlignment.Center,
1820                         HorizontalAlignment = HorizontalAlignment.Begin,
1821                     };
1822                     Add(mText);
1823                 }
1824             }
1825
1826             private void CreateCheckImage()
1827             {
1828                 if (mCheck == null)
1829                 {
1830                     mCheck = new ImageView()
1831                     {
1832                         PositionUsesPivotPoint = true,
1833                         ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft,
1834                         PivotPoint = Tizen.NUI.PivotPoint.TopLeft,
1835                         Name = "checkedImage",
1836                     };
1837                     Add(mCheck);
1838                 }
1839                 mCheck.Hide();
1840             }
1841         }
1842         #endregion
1843
1844         #region DropDownListBridge
1845
1846         /// <summary>
1847         /// DropDownListBridge is bridge to connect item data and an item View.
1848         /// </summary>
1849         /// <since_tizen> 6 </since_tizen>
1850         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1851         [EditorBrowsable(EditorBrowsableState.Never)]
1852         public class DropDownListBridge
1853         {
1854             private List<DropDownDataItem> itemDataList = new List<DropDownDataItem>();
1855
1856             internal bool AdapterPurge {get;set;} = false;  // Set to true if adapter content changed since last iteration.
1857
1858             /// <summary>
1859             /// Creates a new instance of a DropDownListBridge.
1860             /// </summary>
1861             /// <since_tizen> 6 </since_tizen>
1862             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1863             [EditorBrowsable(EditorBrowsableState.Never)]
1864             public DropDownListBridge()
1865             {
1866             }
1867
1868             /// <summary>
1869             /// Insert data. The inserted data will be added to the special position by index automatically.
1870             /// </summary>
1871             /// <param name="position">Position index where will be inserted.</param>
1872             /// <param name="data">Item data which will apply to tab item view.</param>
1873             /// <since_tizen> 6 </since_tizen>
1874             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1875             [EditorBrowsable(EditorBrowsableState.Never)]
1876             public void InsertData(int position, DropDownDataItem data)
1877             {
1878                 if(position == -1)
1879                 {
1880                     position = itemDataList.Count;
1881                 }
1882                 itemDataList.Insert(position, data);
1883                 AdapterPurge = true;
1884             }
1885
1886             /// <summary>
1887             /// Remove data by position.
1888             /// </summary>
1889             /// <param name="position">Position index where will be removed.</param>
1890             /// <since_tizen> 6 </since_tizen>
1891             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1892             [EditorBrowsable(EditorBrowsableState.Never)]
1893             public void RemoveData(int position)
1894             {
1895                 itemDataList.RemoveAt(position);
1896                 AdapterPurge = true;
1897             }
1898
1899             /// <summary>
1900             /// Get data by position.
1901             /// </summary>
1902             /// <param name="position">Position index where will be gotten.</param>
1903             /// <since_tizen> 6 </since_tizen>
1904             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1905             [EditorBrowsable(EditorBrowsableState.Never)]
1906             public DropDownDataItem GetData(int position)
1907             {
1908                 return itemDataList[position];
1909             }
1910
1911             /// <summary>
1912             /// Get view holder by view type.
1913             /// </summary>
1914             /// <since_tizen> 6 </since_tizen>
1915             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1916             [EditorBrowsable(EditorBrowsableState.Never)]
1917             public ViewHolder OnCreateViewHolder()
1918             {
1919                 ViewHolder viewHolder = new ViewHolder(new DropDownItemView());
1920
1921                 return viewHolder;
1922             }
1923
1924             /// <summary>
1925             /// Bind ViewHolder with View.
1926             /// </summary>
1927             /// <param name="holder">View holder.</param>
1928             /// <param name="position">Position index of source data.</param>
1929             /// <since_tizen> 6 </since_tizen>
1930             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1931             [EditorBrowsable(EditorBrowsableState.Never)]
1932             public void BindViewHolder(ViewHolder holder, int position)
1933             {
1934                 DropDownDataItem listItemData = itemDataList[position];
1935                 if(listItemData == null)
1936                 {
1937                     return;
1938                 }
1939                 DropDownItemView listItemView = holder.ItemView as DropDownItemView;
1940                 listItemView.Name = "Item" + position;
1941                 if (listItemData.Size != null)
1942                 {
1943                     if (listItemData.Size.Width > 0)
1944                     {
1945                         holder.ItemView.WidthSpecification = (int)listItemData.Size.Width;
1946                     }
1947                     else
1948                     {
1949                         holder.ItemView.WidthSpecification = LayoutParamPolicies.MatchParent;
1950                     }
1951
1952                     if (listItemData.Size.Height > 0)
1953                     {
1954                         holder.ItemView.HeightSpecification = (int)listItemData.Size.Height;
1955                     }
1956                     else
1957                     {
1958                         holder.ItemView.HeightSpecification = LayoutParamPolicies.MatchParent;
1959                     }
1960                 }
1961
1962                 if (listItemView != null)
1963                 {
1964                     listItemView.BackgroundColorSelector = listItemData.BackgroundColorSelector;
1965                     if (listItemData.Text != null)
1966                     {
1967                         listItemView.Text = listItemData.Text;
1968                         listItemView.PointSize = listItemData.PointSize;
1969                         listItemView.FontFamily = listItemData.FontFamily;
1970                         listItemView.TextPosition = listItemData.TextPosition;
1971                     }
1972
1973                     if (listItemData.IconResourceUrl != null)
1974                     {
1975                         listItemView.IconResourceUrl = listItemData.IconResourceUrl;
1976                         listItemView.IconSize = listItemData.IconSize;
1977                         if (listItemView.IconSize != null)
1978                         {
1979                             listItemView.IconPosition = new Position(listItemData.IconPosition.X, (listItemView.Size2D.Height - listItemView.IconSize.Height) / 2);
1980                         }
1981                     }
1982
1983                     if (listItemData.CheckImageResourceUrl != null)
1984                     {
1985                         listItemView.CheckResourceUrl = listItemData.CheckImageResourceUrl;
1986                         listItemView.CheckImageSize = listItemData.CheckImageSize;
1987                         if (listItemView.CheckImageSize != null)
1988                         {
1989                             listItemView.CheckPosition = new Position(listItemView.Size2D.Width - listItemData.CheckImageGapToBoundary - listItemView.CheckImageSize.Width, (listItemView.Size2D.Height - listItemView.CheckImageSize.Height) / 2);
1990                         }
1991                     }
1992
1993                     listItemView.IsSelected = listItemData.IsSelected;
1994                 }
1995             }
1996
1997             /// <summary>
1998             /// Destroy view holder, it can be override.
1999             /// </summary>
2000             /// <param name="holder">View holder.</param>
2001             /// <since_tizen> 6 </since_tizen>
2002             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
2003             [EditorBrowsable(EditorBrowsableState.Never)]
2004             public void OnDestroyViewHolder(ViewHolder holder)
2005             {
2006                 if (holder.ItemView != null)
2007                 {
2008                     holder.ItemView.Dispose();
2009                 }
2010             }
2011
2012             /// <summary>
2013             /// Get item count, it can be override.
2014             /// </summary>
2015             /// <since_tizen> 6 </since_tizen>
2016             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
2017             [EditorBrowsable(EditorBrowsableState.Never)]
2018             public int GetItemCount()
2019             {
2020                 return itemDataList.Count;
2021             }
2022         }
2023         #endregion
2024
2025         #region ViewHolder
2026
2027         /// <summary>
2028         /// A ViewHolder is a class that holds a View created from DropDownListBridge data.
2029         /// </summary>
2030         /// <since_tizen> 6 </since_tizen>
2031         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
2032         [EditorBrowsable(EditorBrowsableState.Never)]
2033         public class ViewHolder
2034         {
2035             /// <summary>
2036             /// ViewHolder constructor.
2037             /// </summary>
2038             /// <param name="itemView">View</param>
2039             /// <since_tizen> 6 </since_tizen>
2040             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
2041             [EditorBrowsable(EditorBrowsableState.Never)]
2042             public ViewHolder(View itemView)
2043             {
2044                 if (itemView == null)
2045                 {
2046                     throw new ArgumentNullException("itemView may not be null");
2047                 }
2048                 this.ItemView = itemView;
2049             }
2050
2051             /// <summary>
2052             /// Returns the view.
2053             /// </summary>
2054             /// <since_tizen> 6 </since_tizen>
2055             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
2056             [EditorBrowsable(EditorBrowsableState.Never)]
2057             public View ItemView { get; }
2058
2059               internal bool IsBound
2060             {
2061                 get;
2062                 set;
2063             }
2064
2065         }
2066
2067         #endregion
2068
2069     }
2070 }