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