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