[NUI.Components] Fix svace issues (#1310)
[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(nameof(ListPadding), typeof(Extents), typeof(DropDown), null, propertyChanged: (bindable, oldValue, newValue) =>
36         {
37             var instance = (DropDown)bindable;
38             if (newValue != null)
39             {
40                 instance.listPadding.CopyFrom((Extents)newValue);
41                 instance.UpdateDropDown();
42             }
43         },
44         defaultValueCreator: (bindable) =>
45         {
46             var instance = (DropDown)bindable;
47             return instance.listPadding;
48         });
49         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
50         [EditorBrowsable(EditorBrowsableState.Never)]
51         public static readonly BindableProperty SelectedItemIndexProperty = BindableProperty.Create(nameof(SelectedItemIndex), typeof(int), typeof(DropDown), 0, propertyChanged: (bindable, oldValue, newValue) =>
52         {
53             var instance = (DropDown)bindable;
54             if (newValue != null)
55             {
56                 int selectedItemIndex = (int)newValue;
57                 if (selectedItemIndex == instance.selectedItemIndex || instance.adapter == null || selectedItemIndex >= instance.adapter.GetItemCount())
58                 {
59                     return;
60                 }
61                 instance.UpdateSelectedItem(selectedItemIndex);
62             }
63         },
64         defaultValueCreator: (bindable) =>
65         {
66             var instance = (DropDown)bindable;
67             return instance.selectedItemIndex;
68         });
69         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
70         [EditorBrowsable(EditorBrowsableState.Never)]
71         public static readonly BindableProperty ListMarginProperty = BindableProperty.Create(nameof(ListMargin), typeof(Extents), typeof(DropDown), null, propertyChanged: (bindable, oldValue, newValue) =>
72         {
73             var instance = (DropDown)bindable;
74             if (newValue != null)
75             {
76                 instance.listMargin.CopyFrom((Extents)newValue);
77                 instance.UpdateDropDown();
78             }
79         },
80         defaultValueCreator: (bindable) =>
81         {
82             var instance = (DropDown)bindable;
83             return instance.listMargin;
84         });
85         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
86         [EditorBrowsable(EditorBrowsableState.Never)]
87         public static readonly BindableProperty ListRelativeOrientationProperty = BindableProperty.Create(nameof(ListRelativeOrientation), typeof(ListOrientation), typeof(DropDown), ListOrientation.Left, propertyChanged: (bindable, oldValue, newValue) =>
88         {
89             var instance = (DropDown)bindable;
90             if (newValue != null)
91             {
92                 instance.listRelativeOrientation = (ListOrientation)newValue;
93                 instance.UpdateDropDown();
94             }
95         },
96         defaultValueCreator: (bindable) =>
97         {
98             var instance = (DropDown)bindable;
99             return instance.listRelativeOrientation;
100         });
101         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
102         [EditorBrowsable(EditorBrowsableState.Never)]
103         public static readonly BindableProperty SpaceBetweenButtonTextAndIconProperty = BindableProperty.Create(nameof(SpaceBetweenButtonTextAndIcon), typeof(int), typeof(DropDown), 0, propertyChanged: (bindable, oldValue, newValue) =>
104         {
105             var instance = (DropDown)bindable;
106             if (newValue != null)
107             {
108                 instance.spaceBetweenButtonTextAndIcon = (int)newValue;
109             }
110         },
111         defaultValueCreator: (bindable) =>
112         {
113             var instance = (DropDown)bindable;
114             return instance.spaceBetweenButtonTextAndIcon;
115         });
116
117         #region DropDown
118         private Button button = null;
119         private TextLabel headerText = null;
120         private TextLabel buttonText = null;
121         private ImageView listBackgroundImage = null;
122         // Component that scrolls the child added to it.
123         private ScrollableBase scrollableBase = null;
124
125         // The LinearLayout container to house the items in the drop down list.
126         private View dropDownMenuFullList = null;
127         private DropDownListBridge adapter = new DropDownListBridge();
128         private DropDownItemView selectedItemView = null;
129         private TapGestureDetector tapGestureDetector = null;
130
131         private Extents listMargin = new Extents(0, 0, 0, 0);
132         private Extents listPadding = new Extents(0, 0, 0, 0);
133         private ListOrientation listRelativeOrientation = ListOrientation.Left;
134         private int selectedItemIndex = -1;
135         private int spaceBetweenButtonTextAndIcon = 0;
136         private bool itemPressed = false;
137
138         static DropDown() { }
139
140         /// <summary>
141         /// Creates a new instance of a DropDown.
142         /// </summary>
143         /// <since_tizen> 6 </since_tizen>
144         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
145         [EditorBrowsable(EditorBrowsableState.Never)]
146         public DropDown() : base() { }
147
148         /// <summary>
149         /// Creates a new instance of a DropDown with style.
150         /// </summary>
151         /// <param name="style">Create DropDown by special style defined in UX.</param>
152         /// <since_tizen> 6 </since_tizen>
153         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
154         [EditorBrowsable(EditorBrowsableState.Never)]
155         public DropDown(string style) : base(style) { }
156
157         /// <summary>
158         /// Creates a new instance of a DropDown with attributes.
159         /// </summary>
160         /// <param name="attributes">Create DropDown by attributes customized by user.</param>
161         /// <since_tizen> 6 </since_tizen>
162         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
163         [EditorBrowsable(EditorBrowsableState.Never)]
164         public DropDown(DropDownStyle attributes) : base(attributes)
165         {
166         }
167
168         /// <summary>
169         /// An event for the button clicked signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
170         /// </summary>
171         /// <since_tizen> 6 </since_tizen>
172         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
173         [EditorBrowsable(EditorBrowsableState.Never)]
174         public delegate void ClickEventHandler<ClickEventArgs>(object sender, ClickEventArgs e);
175
176         /// <summary>
177         /// An event for the item clicked signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
178         /// </summary>
179         /// <since_tizen> 6 </since_tizen>
180         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
181         [EditorBrowsable(EditorBrowsableState.Never)]
182         public event ClickEventHandler<ItemClickEventArgs> ItemClickEvent;
183
184         /// <summary>
185         /// List position in relation to the main button.
186         /// </summary>
187         /// <since_tizen> 6 </since_tizen>
188         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
189         [EditorBrowsable(EditorBrowsableState.Never)]
190         public enum ListOrientation
191         {
192             /// <summary>
193             /// Left.
194             /// </summary>
195             /// <since_tizen> 6 </since_tizen>
196             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
197             [EditorBrowsable(EditorBrowsableState.Never)]
198             Left,
199             /// <summary>
200             /// Right.
201             /// </summary>
202             /// <since_tizen> 6 </since_tizen>
203             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
204             [EditorBrowsable(EditorBrowsableState.Never)]
205             Right,
206         }
207
208         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
209         [EditorBrowsable(EditorBrowsableState.Never)]
210         public new DropDownStyle Style => ViewStyle as DropDownStyle;
211
212         /// <summary>
213         /// Space between button text and button icon in DropDown.
214         /// </summary>
215         /// <since_tizen> 6 </since_tizen>
216         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
217         public int SpaceBetweenButtonTextAndIcon
218         {
219             get => (int)GetValue(SpaceBetweenButtonTextAndIconProperty);
220             set => SetValue(SpaceBetweenButtonTextAndIconProperty, value);
221         }
222
223         /// <summary>
224         /// List relative orientation in DropDown.
225         /// </summary>
226         /// <since_tizen> 6 </since_tizen>
227         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
228         public ListOrientation ListRelativeOrientation
229         {
230             get => (ListOrientation)GetValue(ListRelativeOrientationProperty);
231             set => SetValue(ListRelativeOrientationProperty, value);
232         }
233
234         /// <summary>
235         /// Space in list.
236         /// </summary>
237         /// <since_tizen> 6 </since_tizen>
238         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
239         public Extents ListMargin
240         {
241             get
242             {
243                 Extents tmp = (Extents)GetValue(ListMarginProperty);
244                 return new Extents((ushort start, ushort end, ushort top, ushort bottom) => { ListMargin = new Extents(start, end, top, bottom); }, tmp.Start, tmp.End, tmp.Top, tmp.Bottom);
245             }
246             set => SetValue(ListMarginProperty, value);
247         }
248
249         /// <summary>
250         /// Selected item index in list.
251         /// </summary>
252         /// <since_tizen> 6 </since_tizen>
253         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
254         public int SelectedItemIndex
255         {
256             get => (int)GetValue(SelectedItemIndexProperty);
257             set => SetValue(SelectedItemIndexProperty, value);
258         }
259
260         /// <summary>
261         /// List padding in DropDown.
262         /// </summary>
263         /// <since_tizen> 6 </since_tizen>
264         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
265         public Extents ListPadding
266         {
267             get
268             {
269                 Extents tmp = (Extents)GetValue(ListPaddingProperty);
270                 return new Extents((ushort start, ushort end, ushort top, ushort bottom) => { ListPadding = new Extents(start, end, top, bottom); }, tmp.Start, tmp.End, tmp.Top, tmp.Bottom);
271             }
272             set => SetValue(ListPaddingProperty, value);
273         }
274
275         /// <summary>
276         /// Add list item by item data. The added item will be added to end of all items automatically.
277         /// </summary>
278         /// <param name="itemData">Item data which will apply to tab item view.</param>
279         /// <since_tizen> 6 </since_tizen>
280         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
281         [EditorBrowsable(EditorBrowsableState.Never)]
282         public void AddItem(DropDownDataItem itemData)
283         {
284            // Add item to adaptor, will be added to list via AddItemAt during OnUpdate()
285            int insertionPosition = adapter.GetItemCount();
286            adapter.InsertData(insertionPosition, itemData);
287         }
288
289         /// <summary>
290         /// Delete list item by index.
291         /// </summary>
292         /// <param name="index">Position index where will be deleted.</param>
293         /// <since_tizen> 6 </since_tizen>
294         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
295         [EditorBrowsable(EditorBrowsableState.Never)]
296         public void DeleteItem(int index)
297         {
298             if (index < 0 || index >= adapter?.GetItemCount()) return;
299             if (null == dropDownMenuFullList) return;
300
301             if (selectedItemIndex == index)
302             {
303                 selectedItemIndex = -1;
304             }
305             else if(selectedItemIndex > index)
306             {
307                 selectedItemIndex--;
308             }
309
310             adapter?.RemoveData(index);
311
312             if(index < dropDownMenuFullList.ChildCount)
313             {
314                 View childToRemove = dropDownMenuFullList.GetChildAt((uint)index);
315                 if (childToRemove)
316                 {
317                     childToRemove.TouchEvent -= ListItemTouchEvent;
318                     dropDownMenuFullList.Remove(childToRemove);
319                     dropDownMenuFullList?.Layout?.RequestLayout();
320                 }
321             }
322         }
323
324         /// <summary>
325         /// Insert list item by item data. The inserted item will be added to the special position by index automatically.
326         /// </summary>
327         /// <param name="item">Item data which will apply to tab item view.</param>
328         /// <param name="index">Position index where will be inserted.</param>
329         /// <since_tizen> 6 </since_tizen>
330         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
331         [EditorBrowsable(EditorBrowsableState.Never)]
332         public void InsertItem(DropDownDataItem item, int index)
333         {
334             if (index < 0 || index >= adapter.GetItemCount())
335             {
336                 return;
337             }
338
339             if (selectedItemIndex >= index)
340             {
341                 selectedItemIndex++;
342             }
343
344             adapter.InsertData(index, item);
345         }
346
347         /// <summary>
348         /// Add scroll bar to list.
349         /// </summary>
350         /// <param name="scrollBar">Scroll bar defined by user which will be added to list.</param>
351         /// <since_tizen> 6 </since_tizen>
352         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
353         [EditorBrowsable(EditorBrowsableState.Never)]
354         public void AttachScrollBar(ScrollBar scrollBar)
355         {
356             if (scrollableBase == null)
357             {
358                 return;
359             }
360             Tizen.Log.Error("DropDown","Feature unsupported");
361         }
362
363         /// <summary>
364         /// Detach scroll bar to list.
365         /// </summary>
366         /// <since_tizen> 6 </since_tizen>
367         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
368         [EditorBrowsable(EditorBrowsableState.Never)]
369         public void DetachScrollBar()
370         {
371             if (scrollableBase == null)
372             {
373                 return;
374             }
375             Tizen.Log.Error("DropDown","Feature unsupported");
376         }
377
378         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
379         [EditorBrowsable(EditorBrowsableState.Never)]
380         public override void ApplyStyle(ViewStyle viewStyle)
381         {
382             base.ApplyStyle(viewStyle);
383
384             DropDownStyle dropDownStyle = viewStyle as DropDownStyle;
385             if (null != dropDownStyle)
386             {
387                 CreateHeaderText();
388                 CreateButtonText();
389                 CreateButton();
390
391                 CreateListBackgroundImage();
392                 if (null == scrollableBase) // scrollableBase used to test of ListContainer Setup invoked already
393                 {
394                     SetUpListContainer();
395                 }
396                 button.ApplyStyle(dropDownStyle.Button);
397                 headerText.ApplyStyle(dropDownStyle.HeaderText);
398                 listBackgroundImage.ApplyStyle(dropDownStyle.ListBackgroundImage);
399                 UpdateDropDown();
400             }
401         }
402
403         /// <summary>
404         /// Update DropDown by attributes.
405         /// </summary>
406         /// <since_tizen> 6 </since_tizen>
407         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
408         [EditorBrowsable(EditorBrowsableState.Never)]
409         protected void UpdateDropDown()
410         {
411             if (null == scrollableBase || null == listBackgroundImage || null == dropDownMenuFullList) return;
412             if (null == Style.ListBackgroundImage.Size) return;
413             // Resize and position scrolling list within the drop down list container.  Can be used to position list in relation to the background image.
414             scrollableBase.Size = Style.ListBackgroundImage.Size - new Size((listPadding.Start + listPadding.End), (listPadding.Top + listPadding.Bottom), 0);
415             scrollableBase.Position2D = new Position2D(listPadding.Start, listPadding.Top);
416
417             int listBackgroundImageX = 0;
418             int listBackgroundImageY = 0;
419             if (listRelativeOrientation == ListOrientation.Left)
420             {
421                 listBackgroundImageX = (int)listMargin.Start;
422                 listBackgroundImageY = (int)listMargin.Top;
423             }
424             else if (listRelativeOrientation == ListOrientation.Right)
425             {
426                 listBackgroundImageX = -(int)listMargin.End;
427                 listBackgroundImageY = (int)listMargin.Top;
428             }
429             listBackgroundImage.Position2D = new Position2D(listBackgroundImageX, listBackgroundImageY);
430             dropDownMenuFullList?.Layout?.RequestLayout();
431         }
432
433         /// <summary>
434         /// update.
435         /// </summary>
436         protected override void OnUpdate()
437         {
438             float iconWidth = 0;
439             float buttonTextWidth = 0;
440             if (null != buttonText)
441             {
442                 buttonText.Text = Style.Button.Text.Text.All;
443                 buttonText.PointSize = Style.Button.Text.PointSize?.All ?? 20;
444                 buttonTextWidth = buttonText.NaturalSize.Width;
445             }
446             iconWidth = Style.Button.Icon.Size?.Width ?? 48;
447             button.SizeWidth = iconWidth + Style.SpaceBetweenButtonTextAndIcon + buttonTextWidth;
448
449             int numberOfItemsToAdd = adapter.GetItemCount();
450
451             if (adapter.AdapterPurge == true)
452             {
453                 adapter.AdapterPurge = false;
454                 for (int i = 0; i < numberOfItemsToAdd; i++)
455                 {
456                     AddItemAt(adapter.GetData(i), i);
457                 }
458             }
459             // Set selection icon on View
460             UpdateSelectedItem(selectedItemIndex);
461         }
462
463         /// <summary>
464         /// Dispose DropDown and all children on it.
465         /// </summary>
466         /// <param name="type">Dispose type.</param>
467         /// <since_tizen> 6 </since_tizen>
468         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
469         [EditorBrowsable(EditorBrowsableState.Never)]
470         protected override void Dispose(DisposeTypes type)
471         {
472             if (disposed)
473             {
474                 return;
475             }
476
477             if (type == DisposeTypes.Explicit)
478             {
479                 Utility.Dispose(headerText);
480                 Utility.Dispose(buttonText);
481                 Utility.Dispose(button);
482                 Utility.Dispose(scrollableBase);
483                 Utility.Dispose(dropDownMenuFullList);
484                 Utility.Dispose(listBackgroundImage);
485             }
486
487             base.Dispose(type);
488         }
489
490         /// <summary>
491         /// Get DropDown attribues.
492         /// </summary>
493         /// <since_tizen> 6 </since_tizen>
494         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
495         [EditorBrowsable(EditorBrowsableState.Never)]
496         protected override ViewStyle GetViewStyle()
497         {
498             return new DropDownStyle();
499         }
500
501         private void AddItemAt(DropDownDataItem itemData,int index)
502         {
503             ViewHolder viewHolder = adapter.OnCreateViewHolder();
504             if (!viewHolder.IsBound)
505             {
506                 adapter.BindViewHolder(viewHolder, index);
507                 viewHolder.IsBound = true;
508             }
509
510             if (tapGestureDetector == null)
511             {
512                 tapGestureDetector = new TapGestureDetector();
513             }
514             View view = viewHolder.ItemView;
515             view.TouchEvent += ListItemTouchEvent;
516             dropDownMenuFullList.Add(view);
517         }
518
519         private void OnClickEvent(object sender, ItemClickEventArgs e)
520         {
521             ItemClickEvent?.Invoke(sender, e);
522         }
523
524         private void CreateHeaderText()
525         {
526             if (null == headerText)
527             {
528                 headerText = new TextLabel()
529                 {
530                     WidthResizePolicy = ResizePolicyType.UseNaturalSize,
531                     HeightResizePolicy = ResizePolicyType.UseNaturalSize,
532                     HorizontalAlignment = HorizontalAlignment.Center,
533                     VerticalAlignment = VerticalAlignment.Center,
534                     ParentOrigin = NUI.ParentOrigin.Center,
535                     PivotPoint = NUI.ParentOrigin.Center,
536                     PositionUsesPivotPoint = true,
537                 };
538                 headerText.Name = "DropDownHeaderText";
539                 Add(headerText);
540             }
541         }
542
543         private void CreateButtonText()
544         {
545             if (null == buttonText)
546             {
547                 buttonText = new TextLabel();
548             }
549         }
550
551         private void CreateButton()
552         {
553             if (null == button)
554             {
555                 button = new Button()
556                 {
557                     ParentOrigin = NUI.ParentOrigin.CenterLeft,
558                     PivotPoint = NUI.PivotPoint.CenterLeft,
559                     PositionUsesPivotPoint = true,
560                     HeightResizePolicy = ResizePolicyType.FitToChildren,
561                     IconRelativeOrientation = Button.IconOrientation.Right,
562                 };
563                 button.Name = "DropDownButton";
564                 button.ClickEvent += ButtonClickEvent;
565                 Add(button);
566             }
567         }
568
569         private void CreateListBackgroundImage()
570         {
571             if (null == listBackgroundImage)
572             {
573                 listBackgroundImage = new ImageView
574                 {
575                     Name = "ListBackgroundImage",
576                     PositionUsesPivotPoint = true,
577                     ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft,
578                     PivotPoint = Tizen.NUI.PivotPoint.TopLeft,
579                     WidthResizePolicy = ResizePolicyType.FitToChildren,
580                     HeightResizePolicy = ResizePolicyType.FitToChildren,
581                 };
582                 Add(listBackgroundImage);
583             }
584         }
585
586         private void SetUpListContainer()
587         {
588             LinearLayout linear = new LinearLayout()
589             {
590                 LinearOrientation = LinearLayout.Orientation.Vertical,
591             };
592
593             dropDownMenuFullList = new View()
594             {
595                 Layout = linear,
596                 Name = "DropDownMenuList",
597                 WidthSpecification = LayoutParamPolicies.MatchParent,
598                 HeightSpecification = LayoutParamPolicies.WrapContent,
599                 Focusable = true,
600             };
601
602             scrollableBase = new ScrollableBase()
603             {
604                 Name = "Scrollable",
605             };
606             scrollableBase.Add(dropDownMenuFullList);
607
608             listBackgroundImage.Add(scrollableBase);
609             listBackgroundImage.Hide();
610         }
611
612         private View GetViewFromIndex(uint index)
613         {
614             if ((index < dropDownMenuFullList.ChildCount) && (index >=0) )
615             {
616                 return dropDownMenuFullList.GetChildAt(index);
617             }
618             else
619             {
620                 return null;
621             }
622         }
623
624         private void SetListItemToSelected(DropDownItemView targetItemView)
625         {
626             // Set the DropDownItemView matching the targetItemView to selected.
627             if (selectedItemView!=targetItemView)
628             {
629                 if (selectedItemView!=null)
630                 {
631                     // clear selection status of currently selected item view
632                     selectedItemView.IsSelected = false;
633                 }
634                 // Set target item to selected
635                 targetItemView.IsSelected = true;
636                 selectedItemView = targetItemView;
637             }
638         }
639
640         private bool ListItemTouchEvent(object sender, TouchEventArgs e)
641         {
642             PointStateType state = e.Touch.GetState(0);
643             DropDownItemView touchedView = sender as DropDownItemView;;
644             switch (state)
645             {
646                 case PointStateType.Down:
647                     if (touchedView != null && touchedView.BackgroundColorSelector != null)
648                     {
649                         touchedView.BackgroundColor = touchedView.BackgroundColorSelector.GetValue(ControlStates.Pressed);
650                     }
651                     itemPressed = true;  // if matched with a Up then a click event.
652                     break;
653                 case PointStateType.Motion:
654                     if (touchedView != null && touchedView.BackgroundColorSelector != null)
655                     {
656                         touchedView.BackgroundColor = touchedView.BackgroundColorSelector.GetValue(ControlStates.Normal);
657                     }
658                     itemPressed = false;
659                     break;
660                 case PointStateType.Up:
661                     if (touchedView != null && touchedView.BackgroundColorSelector != null)
662                     {
663                         touchedView.BackgroundColor = touchedView.BackgroundColorSelector.GetValue(ControlStates.Selected);
664
665                         if (itemPressed)  // if Down was previously sent without motion (Scrolling) in-between then a clicked event occurred.
666                         {
667                             // List item clicked
668                             Console.WriteLine("Tapped{0}", touchedView.Name);
669                             SetListItemToSelected(touchedView);
670                             button.Text = touchedView.Text;
671                             button.Show();
672                             listBackgroundImage.Hide();
673                         }
674                     }
675                     break;
676                 default:
677                     break;
678             }
679             return true;
680         }
681
682         private void UpdateSelectedItem(int index)
683         {
684             if (null == adapter) return;
685             if (null == dropDownMenuFullList) return;
686             if (selectedItemIndex != -1)
687             {
688                 DropDownDataItem data = adapter.GetData(selectedItemIndex);
689                 if(null != data)
690                 {
691                     data.IsSelected = false;
692                 }
693                 DropDownItemView listItemView = dropDownMenuFullList.GetChildAt((uint)selectedItemIndex) as DropDownItemView;
694
695                 SetListItemToSelected(listItemView);
696             }
697
698             if (index != -1)
699             {
700                 DropDownDataItem data = adapter.GetData(index);
701                 if (null != data)
702                 {
703                     data.IsSelected = true;
704                     DropDownItemView listItemView = dropDownMenuFullList?.GetChildAt((uint)index) as DropDownItemView;
705                     if(listItemView)
706                     {
707                         SetListItemToSelected(listItemView);
708                     }
709                 }
710             }
711
712             selectedItemIndex = index;
713             dropDownMenuFullList?.Layout?.RequestLayout();
714         }
715
716         private void ButtonClickEvent(object sender, Button.ClickEventArgs e)
717         {
718             button.Hide();
719             listBackgroundImage.Show();
720             dropDownMenuFullList?.Layout?.RequestLayout();
721             listBackgroundImage.RaiseToTop();
722         }
723
724         #endregion
725
726         #region ItemClickEventArgs
727         /// <summary>
728         /// ItemClickEventArgs is a class to record item click event arguments which will sent to user.
729         /// </summary>
730         /// <since_tizen> 6 </since_tizen>
731         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
732         [EditorBrowsable(EditorBrowsableState.Never)]
733         public class ItemClickEventArgs : EventArgs
734         {
735             /// <summary> Clicked item index of DropDown's list </summary>
736             /// <since_tizen> 6 </since_tizen>
737             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
738             [EditorBrowsable(EditorBrowsableState.Never)]
739             public int Index;
740             /// <summary> Clicked item text string of DropDown's list </summary>
741             /// <since_tizen> 6 </since_tizen>
742             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
743             [EditorBrowsable(EditorBrowsableState.Never)]
744             public string Text;
745         }
746         #endregion
747
748         #region DropDownDataItem
749         /// <summary>
750         /// DropDownDataItem is a class to record all data which will be applied to DropDown item.
751         /// </summary>
752         /// <since_tizen> 6 </since_tizen>
753         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
754         //[EditorBrowsable(EditorBrowsableState.Never)]
755         public class DropDownDataItem
756         {
757             private DropDownItemStyle itemDataStyle = new DropDownItemStyle();
758
759             /// <summary>
760             /// Creates a new instance of a DropDownItemData.
761             /// </summary>
762             /// <since_tizen> 6 </since_tizen>
763             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
764             [EditorBrowsable(EditorBrowsableState.Never)]
765             public DropDownDataItem()
766             {
767                 Initialize();
768             }
769
770             /// <summary>
771             /// Creates a new instance of a DropDownItemData with style.
772             /// </summary>
773             /// <param name="style">Create DropDownItemData by special style defined in UX.</param>
774             /// <since_tizen> 6 </since_tizen>
775             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
776             [EditorBrowsable(EditorBrowsableState.Never)]
777             public DropDownDataItem(string style)
778             {
779                 if(style != null)
780                 {
781                     ViewStyle attributes = StyleManager.Instance.GetViewStyle(style);
782                     if(attributes == null)
783                     {
784                         throw new InvalidOperationException($"There is no style {style}");
785                     }
786                     itemDataStyle = attributes as DropDownItemStyle;
787                 }
788                 Initialize();
789             }
790
791             /// <summary>
792             /// Creates a new instance of a DropDownItemData with style.
793             /// </summary>
794             /// <param name="style">Create DropDownItemData by style customized by user.</param>
795             /// <since_tizen> 6 </since_tizen>
796             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
797             [EditorBrowsable(EditorBrowsableState.Never)]
798             public DropDownDataItem(DropDownItemStyle style)
799             {
800                 itemDataStyle.CopyFrom(style);
801                 Initialize();
802             }
803
804             /// <summary>
805             /// DropDown item size.
806             /// </summary>
807             /// <since_tizen> 6 </since_tizen>
808             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
809             [EditorBrowsable(EditorBrowsableState.Never)]
810             public Size Size
811             {
812                 get
813                 {
814                     return itemDataStyle.Size;
815                 }
816                 set
817                 {
818                     itemDataStyle.Size = value;
819                 }
820             }
821
822             /// <summary>
823             /// DropDown item background color selector.
824             /// </summary>
825             /// <since_tizen> 6 </since_tizen>
826             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
827             [EditorBrowsable(EditorBrowsableState.Never)]
828             public Selector<Color> BackgroundColor
829             {
830                 get
831                 {
832                     return itemDataStyle.BackgroundColor;
833                 }
834                 set
835                 {
836                     if (null == itemDataStyle?.BackgroundColor)
837                     {
838                         itemDataStyle.BackgroundColor = new Selector<Color>();
839                     }
840
841                     itemDataStyle.BackgroundColor.Clone(value);
842                 }
843             }
844
845             /// <summary>
846             /// DropDown item text string.
847             /// </summary>
848             /// <since_tizen> 6 </since_tizen>
849             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
850             [EditorBrowsable(EditorBrowsableState.Never)]
851             public string Text
852             {
853                 get
854                 {
855                     return itemDataStyle.Text?.Text?.All;
856                 }
857                 set
858                 {
859                     if (null == itemDataStyle.Text.Text)
860                     {
861                         itemDataStyle.Text.Text = new Selector<string> { All = value };
862                     }
863                     else
864                     {
865                         itemDataStyle.Text.Text = value;
866                     }
867                 }
868             }
869
870             /// <summary>
871             /// DropDown item text's point size.
872             /// </summary>
873             /// <since_tizen> 6 </since_tizen>
874             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
875             [EditorBrowsable(EditorBrowsableState.Never)]
876             public float PointSize
877             {
878                 get
879                 {
880                     return itemDataStyle.Text?.PointSize?.All ?? 0;
881                 }
882                 set
883                 {
884                     if (null == itemDataStyle.Text.PointSize)
885                     {
886                         itemDataStyle.Text.PointSize = new Selector<float?> { All = value };
887                     }
888                     else
889                     {
890                         itemDataStyle.Text.PointSize = value;
891                     }
892                 }
893             }
894
895             /// <summary>
896             /// DropDown item text's font family.
897             /// </summary>
898             /// <since_tizen> 6 </since_tizen>
899             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
900             [EditorBrowsable(EditorBrowsableState.Never)]
901             public string FontFamily
902             {
903                 get
904                 {
905                     return itemDataStyle.Text.FontFamily?.All;
906                 }
907                 set
908                 {
909                     if (null == itemDataStyle.Text.FontFamily)
910                     {
911                         itemDataStyle.Text.FontFamily = new Selector<string> { All = value };
912                     }
913                     else
914                     {
915                         itemDataStyle.Text.FontFamily = value;
916                     }
917                 }
918             }
919
920             /// <summary>
921             /// DropDown item text's position.
922             /// </summary>
923             /// <since_tizen> 6 </since_tizen>
924             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
925             [EditorBrowsable(EditorBrowsableState.Never)]
926             public Position TextPosition
927             {
928                 get
929                 {
930                     return itemDataStyle.Text?.Position;
931                 }
932                 set
933                 {
934                     itemDataStyle.Text.Position = value;
935                 }
936             }
937
938             /// <summary>
939             /// DropDown item's icon's resource url.
940             /// </summary>
941             /// <since_tizen> 6 </since_tizen>
942             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
943             [EditorBrowsable(EditorBrowsableState.Never)]
944             public string IconResourceUrl
945             {
946                 get
947                 {
948                     return itemDataStyle.Icon?.ResourceUrl?.All;
949                 }
950                 set
951                 {
952                     if (null == itemDataStyle.Icon.ResourceUrl)
953                     {
954                         itemDataStyle.Icon.ResourceUrl = new Selector<string> { All = value };
955                     }
956                     else
957                     {
958                         itemDataStyle.Icon.ResourceUrl = value;
959                     }
960                 }
961             }
962
963             /// <summary>
964             /// DropDown item's icon's size.
965             /// </summary>
966             /// <since_tizen> 6 </since_tizen>
967             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
968             [EditorBrowsable(EditorBrowsableState.Never)]
969             public Size IconSize
970             {
971                 get
972                 {
973                     return itemDataStyle.Icon?.Size;
974                 }
975                 set
976                 {
977                     itemDataStyle.Icon.Size = value;
978                 }
979             }
980
981             /// <summary>
982             /// DropDown item's icon's position.
983             /// </summary>
984             /// <since_tizen> 6 </since_tizen>
985             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
986             [EditorBrowsable(EditorBrowsableState.Never)]
987             public Position IconPosition
988             {
989                 get
990                 {
991                     return itemDataStyle.Icon.Position;
992                 }
993                 set
994                 {
995                     itemDataStyle.Icon.Position = value;
996                 }
997             }
998
999             /// <summary>
1000             /// DropDown item's check image's resource url.
1001             /// </summary>
1002             /// <since_tizen> 6 </since_tizen>
1003             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1004             [EditorBrowsable(EditorBrowsableState.Never)]
1005             public string CheckImageResourceUrl
1006             {
1007                 get
1008                 {
1009                     return itemDataStyle.CheckImage?.ResourceUrl?.All;
1010                 }
1011                 set
1012                 {
1013                     if (null == itemDataStyle.CheckImage.ResourceUrl)
1014                     {
1015                         itemDataStyle.CheckImage.ResourceUrl = new Selector<string> { All = value };
1016                     }
1017                     else
1018                     {
1019                         itemDataStyle.CheckImage.ResourceUrl = value;
1020                     }
1021                 }
1022             }
1023
1024             /// <summary>
1025             /// DropDown item's check image's size.
1026             /// </summary>
1027             /// <since_tizen> 6 </since_tizen>
1028             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1029             [EditorBrowsable(EditorBrowsableState.Never)]
1030             public Size CheckImageSize
1031             {
1032                 get
1033                 {
1034                     return itemDataStyle.CheckImage?.Size;
1035                 }
1036                 set
1037                 {
1038                     itemDataStyle.CheckImage.Size = value;
1039                 }
1040             }
1041
1042             /// <summary>
1043             /// DropDown item's check image's right space.
1044             /// </summary>
1045             /// <since_tizen> 6 </since_tizen>
1046             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1047             [EditorBrowsable(EditorBrowsableState.Never)]
1048             public int CheckImageGapToBoundary
1049             {
1050                 get
1051                 {
1052                     return itemDataStyle.CheckImageGapToBoundary;
1053                 }
1054                 set
1055                 {
1056                     itemDataStyle.CheckImageGapToBoundary = value;
1057                 }
1058             }
1059
1060             /// <summary>
1061             /// Flag to decide DropDown item is selected or not.
1062             /// </summary>
1063             /// <since_tizen> 6 </since_tizen>
1064             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1065             [EditorBrowsable(EditorBrowsableState.Never)]
1066             public bool IsSelected
1067             {
1068                 get
1069                 {
1070                     return itemDataStyle.IsSelected;
1071                 }
1072                 set
1073                 {
1074                     itemDataStyle.IsSelected = value;
1075                 }
1076             }
1077
1078             private void Initialize()
1079             {
1080                 if (itemDataStyle == null)
1081                 {
1082                     throw new Exception("DropDownDataItem style parse error.");
1083                 }
1084             }
1085         }
1086         #endregion
1087
1088         #region DropDownItemView
1089         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1090         [EditorBrowsable(EditorBrowsableState.Never)]
1091         internal class DropDownItemView : Control
1092         {
1093             private TextLabel mText = null;
1094             private ImageView mIcon = null;
1095             private ImageView mCheck = null;
1096
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 DropDownItemView() : base() { }
1100
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 Selector<Color> BackgroundColorSelector { get; set; }
1104
1105             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1106             [EditorBrowsable(EditorBrowsableState.Never)]
1107             public string Text
1108             {
1109                 get
1110                 {
1111                     return (null == mText) ? null : mText.Text;
1112                 }
1113                 set
1114                 {
1115                     CreateText();
1116                     mText.Text = value;
1117                 }
1118             }
1119
1120             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1121             [EditorBrowsable(EditorBrowsableState.Never)]
1122             public string FontFamily
1123             {
1124                 get
1125                 {
1126                     return (null == mText) ? null : mText.FontFamily;
1127                 }
1128                 set
1129                 {
1130                     CreateText();
1131                     mText.FontFamily = value;
1132                 }
1133             }
1134
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 float? PointSize
1138             {
1139                 get
1140                 {
1141                     return (null == mText) ? 0 : mText.PointSize;
1142                 }
1143                 set
1144                 {
1145                     CreateText();
1146                     mText.PointSize = (float)value;
1147                 }
1148             }
1149
1150             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1151             [EditorBrowsable(EditorBrowsableState.Never)]
1152             public Color TextColor
1153             {
1154                 get
1155                 {
1156                     return (null == mText) ? null : mText.TextColor;
1157                 }
1158                 set
1159                 {
1160                     CreateText();
1161                     mText.TextColor = value;
1162                 }
1163             }
1164
1165             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1166             [EditorBrowsable(EditorBrowsableState.Never)]
1167             public Position TextPosition
1168             {
1169                 get
1170                 {
1171                     return (null == mText) ? null : mText.Position;
1172                 }
1173                 set
1174                 {
1175                     CreateText();
1176                     mText.Position = value;
1177                 }
1178             }
1179
1180             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1181             [EditorBrowsable(EditorBrowsableState.Never)]
1182             public string IconResourceUrl
1183             {
1184                 get
1185                 {
1186                     return (null == mIcon) ? null : mIcon.ResourceUrl;
1187                 }
1188                 set
1189                 {
1190                     CreateIcon();
1191                     mIcon.ResourceUrl = value;
1192                 }
1193             }
1194
1195             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1196             [EditorBrowsable(EditorBrowsableState.Never)]
1197             public Size IconSize
1198             {
1199                 get
1200                 {
1201                     return (null == mIcon) ? null : mIcon.Size;
1202                 }
1203                 set
1204                 {
1205                     CreateIcon();
1206                     mIcon.Size = value;
1207                 }
1208             }
1209
1210             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1211             [EditorBrowsable(EditorBrowsableState.Never)]
1212             public Position IconPosition
1213             {
1214                 get
1215                 {
1216                     return (null == mIcon) ? null : mIcon.Position;
1217                 }
1218                 set
1219                 {
1220                     CreateIcon();
1221                     mIcon.Position = value;
1222                 }
1223             }
1224
1225             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1226             [EditorBrowsable(EditorBrowsableState.Never)]
1227             public string CheckResourceUrl
1228             {
1229                 get
1230                 {
1231                     return (null == mCheck) ? null : mCheck.ResourceUrl;
1232                 }
1233                 set
1234                 {
1235                     CreateCheckImage();
1236                     mCheck.ResourceUrl = value;
1237                 }
1238             }
1239
1240             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1241             [EditorBrowsable(EditorBrowsableState.Never)]
1242             public Position CheckPosition
1243             {
1244                 get
1245                 {
1246                     return (null == mCheck) ? null : mCheck.Position;
1247                 }
1248                 set
1249                 {
1250                     CreateCheckImage();
1251                     mCheck.Position = value;
1252                 }
1253             }
1254
1255             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1256             [EditorBrowsable(EditorBrowsableState.Never)]
1257             public Size CheckImageSize
1258             {
1259                 get
1260                 {
1261                     return (null == mCheck) ? null : mCheck.Size;
1262                 }
1263                 set
1264                 {
1265                     CreateCheckImage();
1266                     mCheck.Size = value;
1267                 }
1268             }
1269
1270             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1271             [EditorBrowsable(EditorBrowsableState.Never)]
1272             public bool IsSelected
1273             {
1274                 get
1275                 {
1276                     return (null == mCheck) ? false : mCheck.Visibility;
1277                 }
1278                 set
1279                 {
1280                     CreateCheckImage();
1281                     if(value)
1282                     {
1283                         mCheck.Show();
1284                     }
1285                     else
1286                     {
1287                         mCheck.Hide();
1288                     }
1289                 }
1290             }
1291
1292             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1293             [EditorBrowsable(EditorBrowsableState.Never)]
1294             protected override void Dispose(DisposeTypes type)
1295             {
1296                 if (disposed)
1297                 {
1298                     return;
1299                 }
1300
1301                 if (type == DisposeTypes.Explicit)
1302                 {
1303                     if (mText != null)
1304                     {
1305                         Remove(mText);
1306                         mText.Dispose();
1307                         mText = null;
1308                     }
1309
1310                     if (mIcon != null)
1311                     {
1312                         Remove(mIcon);
1313                         mIcon.Dispose();
1314                         mIcon = null;
1315                     }
1316
1317                     if (mCheck != null)
1318                     {
1319                         Remove(mCheck);
1320                         mCheck.Dispose();
1321                         mCheck = null;
1322                     }
1323                 }
1324                 base.Dispose(type);
1325             }
1326
1327             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1328             [EditorBrowsable(EditorBrowsableState.Never)]
1329             protected override ViewStyle GetViewStyle()
1330             {
1331                 return null;
1332             }
1333
1334             private void CreateIcon()
1335             {
1336                 if(mIcon == null)
1337                 {
1338                     mIcon = new ImageView()
1339                     {
1340                         PositionUsesPivotPoint = true,
1341                         ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft,
1342                         PivotPoint = Tizen.NUI.PivotPoint.TopLeft,
1343                     };
1344                     Add(mIcon);
1345                 }
1346             }
1347
1348             private void CreateText()
1349             {
1350                 if (mText == null)
1351                 {
1352                     mText = new TextLabel()
1353                     {
1354                         PositionUsesPivotPoint = true,
1355                         ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft,
1356                         PivotPoint = Tizen.NUI.PivotPoint.TopLeft,
1357                         WidthResizePolicy = ResizePolicyType.UseNaturalSize,
1358                         HeightResizePolicy = ResizePolicyType.FillToParent,
1359                         VerticalAlignment = VerticalAlignment.Center,
1360                         HorizontalAlignment = HorizontalAlignment.Begin,
1361                     };
1362                     Add(mText);
1363                 }
1364             }
1365
1366             private void CreateCheckImage()
1367             {
1368                 if (mCheck == null)
1369                 {
1370                     mCheck = new ImageView()
1371                     {
1372                         PositionUsesPivotPoint = true,
1373                         ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft,
1374                         PivotPoint = Tizen.NUI.PivotPoint.TopLeft,
1375                         Name = "checkedImage",
1376                     };
1377                     Add(mCheck);
1378                 }
1379                 mCheck.Hide();
1380             }
1381         }
1382         #endregion
1383
1384         #region DropDownListBridge
1385
1386         /// <summary>
1387         /// DropDownListBridge is bridge to connect item data and an item View.
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 class DropDownListBridge
1393         {
1394             private List<DropDownDataItem> itemDataList = new List<DropDownDataItem>();
1395
1396             internal bool AdapterPurge {get;set;} = false;  // Set to true if adapter content changed since last iteration.
1397
1398             /// <summary>
1399             /// Creates a new instance of a DropDownListBridge.
1400             /// </summary>
1401             /// <since_tizen> 6 </since_tizen>
1402             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1403             [EditorBrowsable(EditorBrowsableState.Never)]
1404             public DropDownListBridge() { }
1405
1406             /// <summary>
1407             /// Insert data. The inserted data will be added to the special position by index automatically.
1408             /// </summary>
1409             /// <param name="position">Position index where will be inserted.</param>
1410             /// <param name="data">Item data which will apply to tab item view.</param>
1411             /// <since_tizen> 6 </since_tizen>
1412             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1413             [EditorBrowsable(EditorBrowsableState.Never)]
1414             public void InsertData(int position, DropDownDataItem data)
1415             {
1416                 if(position == -1)
1417                 {
1418                     position = itemDataList.Count;
1419                 }
1420                 itemDataList.Insert(position, data);
1421                 AdapterPurge = true;
1422             }
1423
1424             /// <summary>
1425             /// Remove data by position.
1426             /// </summary>
1427             /// <param name="position">Position index where will be removed.</param>
1428             /// <since_tizen> 6 </since_tizen>
1429             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1430             [EditorBrowsable(EditorBrowsableState.Never)]
1431             public void RemoveData(int position)
1432             {
1433                 itemDataList.RemoveAt(position);
1434                 AdapterPurge = true;
1435             }
1436
1437             /// <summary>
1438             /// Get data by position.
1439             /// </summary>
1440             /// <param name="position">Position index where will be gotten.</param>
1441             /// <since_tizen> 6 </since_tizen>
1442             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1443             [EditorBrowsable(EditorBrowsableState.Never)]
1444             public DropDownDataItem GetData(int position)
1445             {
1446                 return itemDataList[position];
1447             }
1448
1449             /// <summary>
1450             /// Get view holder by view type.
1451             /// </summary>
1452             /// <since_tizen> 6 </since_tizen>
1453             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1454             [EditorBrowsable(EditorBrowsableState.Never)]
1455             public ViewHolder OnCreateViewHolder()
1456             {
1457                 ViewHolder viewHolder = new ViewHolder(new DropDownItemView());
1458
1459                 return viewHolder;
1460             }
1461
1462             /// <summary>
1463             /// Bind ViewHolder with View.
1464             /// </summary>
1465             /// <param name="holder">View holder.</param>
1466             /// <param name="position">Position index of source data.</param>
1467             /// <since_tizen> 6 </since_tizen>
1468             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1469             [EditorBrowsable(EditorBrowsableState.Never)]
1470             public void BindViewHolder(ViewHolder holder, int position)
1471             {
1472                 if (null == holder) return;
1473                 DropDownDataItem listItemData = itemDataList[position];
1474                 if(listItemData == null)
1475                 {
1476                     return;
1477                 }
1478                 DropDownItemView listItemView = holder.ItemView as DropDownItemView;
1479                 listItemView.Name = "Item" + position;
1480                 if (listItemData.Size != null)
1481                 {
1482                     if (listItemData.Size.Width > 0)
1483                     {
1484                         holder.ItemView.WidthSpecification = (int)listItemData.Size.Width;
1485                     }
1486                     else
1487                     {
1488                         holder.ItemView.WidthSpecification = LayoutParamPolicies.MatchParent;
1489                     }
1490
1491                     if (listItemData.Size.Height > 0)
1492                     {
1493                         holder.ItemView.HeightSpecification = (int)listItemData.Size.Height;
1494                     }
1495                     else
1496                     {
1497                         holder.ItemView.HeightSpecification = LayoutParamPolicies.MatchParent;
1498                     }
1499                 }
1500
1501                 if (listItemView != null)
1502                 {
1503                     listItemView.BackgroundColorSelector = listItemData.BackgroundColor;
1504                     if (listItemData.Text != null)
1505                     {
1506                         listItemView.Text = listItemData.Text;
1507                         listItemView.PointSize = listItemData.PointSize;
1508                         listItemView.FontFamily = listItemData.FontFamily;
1509                         listItemView.TextPosition = listItemData.TextPosition;
1510                     }
1511
1512                     if (listItemData.IconResourceUrl != null)
1513                     {
1514                         listItemView.IconResourceUrl = listItemData.IconResourceUrl;
1515                         listItemView.IconSize = listItemData.IconSize;
1516                         if (listItemView.IconSize != null)
1517                         {
1518                             listItemView.IconPosition = new Position(listItemData.IconPosition.X, (listItemView.Size2D.Height - listItemView.IconSize.Height) / 2);
1519                         }
1520                     }
1521
1522                     if (listItemData.CheckImageResourceUrl != null)
1523                     {
1524                         listItemView.CheckResourceUrl = listItemData.CheckImageResourceUrl;
1525
1526                         if (null != listItemData.CheckImageSize)
1527                         {
1528                             listItemView.CheckImageSize = listItemData.CheckImageSize;
1529                         }
1530
1531                         if (listItemView.CheckImageSize != null)
1532                         {
1533                             listItemView.CheckPosition = new Position(listItemView.Size2D.Width - listItemData.CheckImageGapToBoundary - listItemView.CheckImageSize.Width, (listItemView.Size2D.Height - listItemView.CheckImageSize.Height) / 2);
1534                         }
1535                     }
1536
1537                     listItemView.IsSelected = listItemData.IsSelected;
1538                 }
1539             }
1540
1541             /// <summary>
1542             /// Destroy view holder, it can be override.
1543             /// </summary>
1544             /// <param name="holder">View holder.</param>
1545             /// <since_tizen> 6 </since_tizen>
1546             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1547             [EditorBrowsable(EditorBrowsableState.Never)]
1548             public void OnDestroyViewHolder(ViewHolder holder)
1549             {
1550                 if (null == holder) return;
1551                 if (holder.ItemView != null)
1552                 {
1553                     holder.ItemView.Dispose();
1554                 }
1555             }
1556
1557             /// <summary>
1558             /// Get item count, it can be override.
1559             /// </summary>
1560             /// <since_tizen> 6 </since_tizen>
1561             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1562             [EditorBrowsable(EditorBrowsableState.Never)]
1563             public int GetItemCount()
1564             {
1565                 return itemDataList.Count;
1566             }
1567         }
1568
1569         #endregion
1570
1571         #region ViewHolder
1572
1573         /// <summary>
1574         /// A ViewHolder is a class that holds a View created from DropDownListBridge data.
1575         /// </summary>
1576         /// <since_tizen> 6 </since_tizen>
1577         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1578         [EditorBrowsable(EditorBrowsableState.Never)]
1579         public class ViewHolder
1580         {
1581             /// <summary>
1582             /// ViewHolder constructor.
1583             /// </summary>
1584             /// <param name="itemView">View</param>
1585             /// <since_tizen> 6 </since_tizen>
1586             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1587             [EditorBrowsable(EditorBrowsableState.Never)]
1588             public ViewHolder(View itemView)
1589             {
1590                 if (itemView == null)
1591                 {
1592                     throw new ArgumentNullException("itemView may not be null");
1593                 }
1594                 this.ItemView = itemView;
1595             }
1596
1597             /// <summary>
1598             /// Returns the view.
1599             /// </summary>
1600             /// <since_tizen> 6 </since_tizen>
1601             /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1602             [EditorBrowsable(EditorBrowsableState.Never)]
1603             public View ItemView { get; }
1604
1605             internal bool IsBound { get; set; }
1606         }
1607
1608         #endregion
1609     }
1610 }