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