2 * Copyright(c) 2019 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 using System.Collections.Generic;
19 using Tizen.NUI.BaseComponents;
20 using System.ComponentModel;
21 using Tizen.NUI.Binding;
23 namespace Tizen.NUI.Components
26 /// DropDown is one kind of common component, a dropdown allows the user click dropdown button to choose one value from a list.
28 /// <since_tizen> 6 </since_tizen>
29 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
30 [EditorBrowsable(EditorBrowsableState.Never)]
31 public class DropDown : Control
33 /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
34 [EditorBrowsable(EditorBrowsableState.Never)]
35 public static readonly BindableProperty ListPaddingProperty = BindableProperty.Create("ListPadding", typeof(Extents), typeof(Tizen.NUI.Components.DropDown), null, propertyChanged: (bindable, oldValue, newValue) =>
37 var instance = (Tizen.NUI.Components.DropDown)bindable;
40 instance.privateListPadding = (Extents)newValue;
43 defaultValueCreator: (bindable) =>
45 var instance = (Tizen.NUI.Components.DropDown)bindable;
46 return instance.privateListPadding;
48 /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
49 [EditorBrowsable(EditorBrowsableState.Never)]
50 public static readonly BindableProperty ListSizeProperty = BindableProperty.Create("ListSize", typeof(Size), typeof(Tizen.NUI.Components.DropDown), null, propertyChanged: (bindable, oldValue, newValue) =>
52 var instance = (Tizen.NUI.Components.DropDown)bindable;
55 instance.privateListSize = (Size)newValue;
58 defaultValueCreator: (bindable) =>
60 var instance = (Tizen.NUI.Components.DropDown)bindable;
61 return instance.privateListSize;
63 /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
64 [EditorBrowsable(EditorBrowsableState.Never)]
65 public static readonly BindableProperty SelectedItemIndexProperty = BindableProperty.Create("SelectedItemIndex", typeof(int), typeof(Tizen.NUI.Components.DropDown), 0, propertyChanged: (bindable, oldValue, newValue) =>
67 var instance = (Tizen.NUI.Components.DropDown)bindable;
70 instance.privateSelectedItemIndex = (int)newValue;
73 defaultValueCreator: (bindable) =>
75 var instance = (Tizen.NUI.Components.DropDown)bindable;
76 return instance.privateSelectedItemIndex;
78 /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
79 [EditorBrowsable(EditorBrowsableState.Never)]
80 public static readonly BindableProperty FocusedItemIndexProperty = BindableProperty.Create("FocusedItemIndex", typeof(int), typeof(Tizen.NUI.Components.DropDown), 0, propertyChanged: (bindable, oldValue, newValue) =>
82 var instance = (Tizen.NUI.Components.DropDown)bindable;
85 instance.privateFocusedItemIndex = (int)newValue;
88 defaultValueCreator: (bindable) =>
90 var instance = (Tizen.NUI.Components.DropDown)bindable;
91 return instance.privateFocusedItemIndex;
93 /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
94 [EditorBrowsable(EditorBrowsableState.Never)]
95 public static readonly BindableProperty ListMarginProperty = BindableProperty.Create("ListMargin", typeof(Extents), typeof(Tizen.NUI.Components.DropDown), null, propertyChanged: (bindable, oldValue, newValue) =>
97 var instance = (Tizen.NUI.Components.DropDown)bindable;
100 instance.privateListMargin = (Extents)newValue;
103 defaultValueCreator: (bindable) =>
105 var instance = (Tizen.NUI.Components.DropDown)bindable;
106 return instance.privateListMargin;
108 /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
109 [EditorBrowsable(EditorBrowsableState.Never)]
110 public static readonly BindableProperty ListRelativeOrientationProperty = BindableProperty.Create("ListRelativeOrientation", typeof(ListOrientation), typeof(Tizen.NUI.Components.DropDown), ListOrientation.Left, propertyChanged: (bindable, oldValue, newValue) =>
112 var instance = (Tizen.NUI.Components.DropDown)bindable;
113 if (newValue != null)
115 instance.privateListRelativeOrientation = (ListOrientation)newValue;
118 defaultValueCreator: (bindable) =>
120 var instance = (Tizen.NUI.Components.DropDown)bindable;
121 return instance.privateListRelativeOrientation;
123 /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
124 [EditorBrowsable(EditorBrowsableState.Never)]
125 public static readonly BindableProperty SpaceProperty = BindableProperty.Create("Space", typeof(Extents), typeof(Tizen.NUI.Components.DropDown), null, propertyChanged: (bindable, oldValue, newValue) =>
127 var instance = (Tizen.NUI.Components.DropDown)bindable;
128 if (newValue != null)
130 instance.privateSpace = (Extents)newValue;
133 defaultValueCreator: (bindable) =>
135 var instance = (Tizen.NUI.Components.DropDown)bindable;
136 return instance.privateSpace;
138 /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
139 [EditorBrowsable(EditorBrowsableState.Never)]
140 public static readonly BindableProperty SpaceBetweenButtonTextAndIconProperty = BindableProperty.Create("SpaceBetweenButtonTextAndIcon", typeof(int), typeof(Tizen.NUI.Components.DropDown), 0, propertyChanged: (bindable, oldValue, newValue) =>
142 var instance = (Tizen.NUI.Components.DropDown)bindable;
143 if (newValue != null)
145 instance.privateSpaceBetweenButtonTextAndIcon = (int)newValue;
148 defaultValueCreator: (bindable) =>
150 var instance = (Tizen.NUI.Components.DropDown)bindable;
151 return instance.privateSpaceBetweenButtonTextAndIcon;
156 private Button button = null;
157 private TextLabel headerText = null;
158 private TextLabel buttonText = null;
159 private ImageView listBackgroundImage = null;
160 private FlexibleView list = null;
161 private DropDownListBridge adapter = new DropDownListBridge();
162 private DropDownItemView touchedView = null;
163 private int selectedItemIndex = -1;
165 private Extents listPadding = null;
167 /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
168 [EditorBrowsable(EditorBrowsableState.Never)]
169 public new DropDownStyle Style => ViewStyle as DropDownStyle;
172 /// Creates a new instance of a DropDown.
174 /// <since_tizen> 6 </since_tizen>
175 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
176 [EditorBrowsable(EditorBrowsableState.Never)]
177 public DropDown() : base()
182 /// Creates a new instance of a DropDown with style.
184 /// <param name="style">Create DropDown by special style defined in UX.</param>
185 /// <since_tizen> 6 </since_tizen>
186 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
187 [EditorBrowsable(EditorBrowsableState.Never)]
188 public DropDown(string style) : base(style)
193 /// Creates a new instance of a DropDown with attributes.
195 /// <param name="attributes">Create DropDown by attributes customized by user.</param>
196 /// <since_tizen> 6 </since_tizen>
197 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
198 [EditorBrowsable(EditorBrowsableState.Never)]
199 public DropDown(DropDownStyle attributes) : base(attributes)
204 /// An event for the button clicked signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
206 /// <since_tizen> 6 </since_tizen>
207 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
208 [EditorBrowsable(EditorBrowsableState.Never)]
209 public delegate void ClickEventHandler<ClickEventArgs>(object sender, ClickEventArgs e);
212 /// An event for the item clicked signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
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 event ClickEventHandler<ItemClickEventArgs> ItemClickEvent;
220 /// List orientation.
222 /// <since_tizen> 6 </since_tizen>
223 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
224 [EditorBrowsable(EditorBrowsableState.Never)]
225 public enum ListOrientation
230 /// <since_tizen> 6 </since_tizen>
231 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
232 [EditorBrowsable(EditorBrowsableState.Never)]
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)]
244 /// Space between button text and button icon in DropDown.
246 /// <since_tizen> 6 </since_tizen>
247 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
248 public int SpaceBetweenButtonTextAndIcon
252 return (int)GetValue(SpaceBetweenButtonTextAndIconProperty);
256 SetValue(SpaceBetweenButtonTextAndIconProperty, value);
259 private int privateSpaceBetweenButtonTextAndIcon
263 return (int)Style.SpaceBetweenButtonTextAndIcon;
267 Style.SpaceBetweenButtonTextAndIcon = value;
273 /// Left space in DropDown.
275 /// <since_tizen> 6 </since_tizen>
276 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
281 return (Extents)GetValue(SpaceProperty);
285 SetValue(SpaceProperty, value);
288 private Extents privateSpace
292 return (Extents)Style.Space;
302 /// List relative orientation in DropDown.
304 /// <since_tizen> 6 </since_tizen>
305 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
306 public ListOrientation ListRelativeOrientation
310 return (ListOrientation)GetValue(ListRelativeOrientationProperty);
314 SetValue(ListRelativeOrientationProperty, value);
317 private ListOrientation privateListRelativeOrientation
321 return (ListOrientation)Style.ListRelativeOrientation;
325 Style.ListRelativeOrientation = value;
333 /// <since_tizen> 6 </since_tizen>
334 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
335 public Extents ListMargin
339 return (Extents)GetValue(ListMarginProperty);
343 SetValue(ListMarginProperty, value);
346 private Extents privateListMargin
350 return Style.ListMargin;
354 Style.ListMargin = value;
360 /// Focused item index in list.
362 /// <since_tizen> 6 </since_tizen>
363 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
364 public int FocusedItemIndex
368 return (int)GetValue(FocusedItemIndexProperty);
372 SetValue(FocusedItemIndexProperty, value);
375 private int privateFocusedItemIndex
379 return (int)Style.FocusedItemIndex;
383 Style.FocusedItemIndex = value;
389 /// Selected item index in list.
391 /// <since_tizen> 6 </since_tizen>
392 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
393 public int SelectedItemIndex
397 return (int)GetValue(SelectedItemIndexProperty);
401 SetValue(SelectedItemIndexProperty, value);
404 private int privateSelectedItemIndex
408 return selectedItemIndex;
412 if (value == selectedItemIndex || adapter == null || value >= adapter.GetItemCount())
416 UpdateSelectedItem(value);
421 /// List size in DropDown.
423 /// <since_tizen> 6 </since_tizen>
424 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
429 return (Size)GetValue(ListSizeProperty);
433 SetValue(ListSizeProperty, value);
436 private Size privateListSize
440 return Style.ListSize;
444 Style.ListSize = value;
450 /// List padding in DropDown.
452 /// <since_tizen> 6 </since_tizen>
453 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
454 public Extents ListPadding
458 return (Extents)GetValue(ListPaddingProperty);
462 SetValue(ListPaddingProperty, value);
465 private Extents privateListPadding
473 Style.ListPadding.CopyFrom(value);
475 if (null == listPadding)
477 listPadding = new Extents((ushort start, ushort end, ushort top, ushort bottom) =>
479 Style.ListPadding.Start = start;
480 Style.ListPadding.End = end;
481 Style.ListPadding.Top = top;
482 Style.ListPadding.Bottom = bottom;
484 }, value.Start, value.End, value.Top, value.Bottom);
488 listPadding.CopyFrom(value);
496 /// Add list item by item data. The added item will be added to end of all items automatically.
498 /// <param name="itemData">Item data which will apply to tab item view.</param>
499 /// <since_tizen> 6 </since_tizen>
500 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
501 [EditorBrowsable(EditorBrowsableState.Never)]
502 public void AddItem(DropDownDataItem itemData)
504 adapter.InsertData(-1, itemData);
508 /// Delete list item by index.
510 /// <param name="index">Position index where will be deleted.</param>
511 /// <since_tizen> 6 </since_tizen>
512 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
513 [EditorBrowsable(EditorBrowsableState.Never)]
514 public void DeleteItem(int index)
516 if(index < 0 || index >= adapter.GetItemCount())
521 if (selectedItemIndex == index)
523 selectedItemIndex = -1;
525 else if(selectedItemIndex > index)
530 adapter.RemoveData(index);
534 /// Insert list item by item data. The inserted item will be added to the special position by index automatically.
536 /// <param name="item">Item data which will apply to tab item view.</param>
537 /// <param name="index">Position index where will be inserted.</param>
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 void InsertItem(DropDownDataItem item, int index)
543 if (index < 0 || index >= adapter.GetItemCount())
548 if (selectedItemIndex >= index)
553 adapter.InsertData(index, item);
557 /// Add scroll bar to list.
559 /// <param name="scrollBar">Scroll bar defined by user which will be added to list.</param>
560 /// <since_tizen> 6 </since_tizen>
561 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
562 [EditorBrowsable(EditorBrowsableState.Never)]
563 public void AttachScrollBar(ScrollBar scrollBar)
569 list.AttachScrollBar(scrollBar);
573 /// Detach scroll bar to list.
575 /// <since_tizen> 6 </since_tizen>
576 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
577 [EditorBrowsable(EditorBrowsableState.Never)]
578 public void DetachScrollBar()
584 list.DetachScrollBar();
587 protected override void RegisterDetectionOfSubstyleChanges()
589 base.RegisterDetectionOfSubstyleChanges();
591 Style.PropertyChanged += DropDownAttributesPropertyChanged;
592 Style.HeaderText.PropertyChanged += HeaderTextAttributesPropertyChanged;
593 Style.Button.PropertyChanged += ButtonAttributesPropertyChanged;
595 Style.Button.Icon.PropertyChanged += IconStylePropertyChanged;
598 private void IconStylePropertyChanged(object sender, PropertyChangedEventArgs e)
601 int buttonTextWidth = 0;
602 if (e.PropertyName.Equals(ImageViewStyle.SizeProperty.PropertyName))
604 iconWidth = (int)Style.Button.Icon.Size.Width;
607 if (buttonText.NaturalSize2D != null)
609 buttonTextWidth = buttonText.NaturalSize2D.Width;
612 button.SizeWidth = iconWidth + (int)Style.SpaceBetweenButtonTextAndIcon + buttonTextWidth;
615 private void DropDownAttributesPropertyChanged(object sender, PropertyChangedEventArgs e)
617 if (e.PropertyName.Equals("Space"))
619 button.Position2D.X = (int)Style.Space.Start;
623 private void ButtonAttributesPropertyChanged(object sender, PropertyChangedEventArgs e)
627 button = new Button()
629 PositionUsesPivotPoint = true,
630 ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft,
631 PivotPoint = Tizen.NUI.PivotPoint.TopLeft,
632 HeightResizePolicy = ResizePolicyType.FillToParent,
633 IconRelativeOrientation = Components.Button.IconOrientation.Right,
635 button.Name = "DropDownButton";
636 button.ClickEvent += ButtonClickEvent;
639 button.ApplyStyle(Style.Button);
642 if (null == buttonText)
644 buttonText = new TextLabel()
646 PositionUsesPivotPoint = true,
647 ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft,
648 PivotPoint = Tizen.NUI.PivotPoint.TopLeft,
649 WidthResizePolicy = ResizePolicyType.UseNaturalSize,
650 HeightResizePolicy = ResizePolicyType.FillToParent,
652 buttonText.Name = "DropDownButtonText";
658 private void HeaderTextAttributesPropertyChanged(object sender, PropertyChangedEventArgs e)
660 if (null == headerText)
662 headerText = new TextLabel();
663 headerText.Name = "DropDownHeaderText";
666 headerText.ApplyStyle(Style.HeaderText);
671 /// Update DropDown by attributes.
673 /// <since_tizen> 6 </since_tizen>
674 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
675 [EditorBrowsable(EditorBrowsableState.Never)]
676 protected override void OnUpdate()
678 if (Style.ListBackgroundImage != null)
680 if (listBackgroundImage == null)
682 CreateListBackgroundImage();
686 int temp = (int)Style.FocusedItemIndex;
687 list.FocusedItemIndex = temp;
688 list.Size = Style.ListSize;
689 list.Padding = Style.ListPadding;
691 int listBackgroundImageX = 0;
692 int listBackgroundImageY = 0;
693 if (Style.ListRelativeOrientation == ListOrientation.Left)
695 if (Style.ListMargin != null)
697 listBackgroundImageX = (int)Style.ListMargin.Start;
698 listBackgroundImageY = (int)Style.ListMargin.Top;
701 else if (Style.ListRelativeOrientation == ListOrientation.Right)
703 if (Style.ListMargin != null)
706 if (list.Size2D != null)
708 listWidth = list.Size2D.Width;
710 listBackgroundImageX = Size2D.Width - listWidth - (int)Style.ListMargin.End;
711 listBackgroundImageY = (int)Style.ListMargin.Top;
714 listBackgroundImage.Position2D = new Position2D(listBackgroundImageX, listBackgroundImageY);
719 /// Dispose DropDown and all children on it.
721 /// <param name="type">Dispose type.</param>
722 /// <since_tizen> 6 </since_tizen>
723 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
724 [EditorBrowsable(EditorBrowsableState.Never)]
725 protected override void Dispose(DisposeTypes type)
732 if (type == DisposeTypes.Explicit)
734 if (headerText != null)
736 Utility.Dispose(headerText);
739 if (buttonText != null)
741 Utility.Dispose(buttonText);
746 Utility.Dispose(button);
751 if (listBackgroundImage != null)
753 Utility.Dispose(listBackgroundImage);
756 Utility.Dispose(list);
764 /// Get DropDown attribues.
766 /// <since_tizen> 6 </since_tizen>
767 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
768 [EditorBrowsable(EditorBrowsableState.Never)]
769 protected override ViewStyle GetViewStyle()
771 return new DropDownStyle();
774 private void OnClickEvent(object sender, ItemClickEventArgs e)
776 ItemClickEvent?.Invoke(sender, e);
779 private void CreateList()
781 list = new FlexibleView();
782 list.Name = "DropDownList";
783 LinearLayoutManager layoutManager = new LinearLayoutManager(LinearLayoutManager.VERTICAL);
784 list.SetLayoutManager(layoutManager);
785 list.SetAdapter(adapter);
786 list.Focusable = true;
787 list.ItemTouchEvent += ListItemTouchEvent;
788 list.ItemClickEvent += ListItemClickEvent;
789 listBackgroundImage.Add(list);
790 listBackgroundImage.Hide();
793 private void ListItemClickEvent(object sender, FlexibleView.ItemClickEventArgs e)
795 if (e.ClickedView != null)
797 UpdateSelectedItem(e.ClickedView.AdapterPosition);
799 ItemClickEventArgs args = new ItemClickEventArgs();
800 args.Index = e.ClickedView.AdapterPosition;
801 args.Text = (e.ClickedView.ItemView as DropDownItemView)?.Text;
802 OnClickEvent(this, args);
805 listBackgroundImage.Hide();
808 private void ListItemTouchEvent(object sender, FlexibleView.ItemTouchEventArgs e)
810 PointStateType state = e.Touch.GetState(0);
813 case PointStateType.Down:
814 if (e.TouchedView != null)
816 touchedView = e.TouchedView.ItemView as DropDownItemView;
817 if (touchedView != null && touchedView.BackgroundColorSelector != null)
819 touchedView.BackgroundColor = touchedView.BackgroundColorSelector.GetValue(ControlStates.Pressed);
823 case PointStateType.Motion:
824 if (touchedView != null && touchedView.BackgroundColorSelector != null)
826 touchedView.BackgroundColor = touchedView.BackgroundColorSelector.GetValue(ControlStates.Normal);
829 case PointStateType.Up:
830 if (touchedView != null && touchedView.BackgroundColorSelector != null)
832 touchedView.BackgroundColor = touchedView.BackgroundColorSelector.GetValue(ControlStates.Selected);
840 private void UpdateSelectedItem(int index)
842 if (selectedItemIndex != -1)
844 DropDownDataItem data = adapter.GetData(selectedItemIndex);
847 data.IsSelected = false;
849 DropDownItemView view = list?.FindViewHolderForAdapterPosition(selectedItemIndex)?.ItemView as DropDownItemView;
852 view.IsSelected = false;
858 DropDownDataItem data = adapter.GetData(index);
861 data.IsSelected = true;
863 DropDownItemView view = list?.FindViewHolderForAdapterPosition(index)?.ItemView as DropDownItemView;
866 view.IsSelected = true;
867 button.Style.Text.Text = view.Text;
871 selectedItemIndex = index;
874 private void CreateListBackgroundImage()
876 if (null == listBackgroundImage)
878 listBackgroundImage = new ImageView
880 Name = "ListBackgroundImage",
881 PositionUsesPivotPoint = true,
882 ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft,
883 PivotPoint = Tizen.NUI.PivotPoint.TopLeft,
884 WidthResizePolicy = ResizePolicyType.FitToChildren,
885 HeightResizePolicy = ResizePolicyType.FitToChildren,
887 Add(listBackgroundImage);
891 private void ButtonClickEvent(object sender, Button.ClickEventArgs e)
893 listBackgroundImage.Show();
896 private void CreateHeaderTextAttributes()
898 if (Style.HeaderText == null)
900 Style.HeaderText = new TextLabelStyle()
902 PositionUsesPivotPoint = true,
903 ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft,
904 PivotPoint = Tizen.NUI.PivotPoint.TopLeft,
905 WidthResizePolicy = ResizePolicyType.FillToParent,
906 HeightResizePolicy = ResizePolicyType.FillToParent,
907 HorizontalAlignment = HorizontalAlignment.Center,
908 VerticalAlignment = VerticalAlignment.Center,
913 private void CreateButtonAttributes()
915 if (Style.Button == null)
917 Style.Button = new ButtonStyle();
921 private void CreateButtonTextAttributes()
923 CreateButtonAttributes();
925 if (Style.Button.Text== null)
927 Style.Button.Text= new TextLabelStyle
929 PositionUsesPivotPoint = true,
930 ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft,
931 PivotPoint = Tizen.NUI.PivotPoint.TopLeft,
932 WidthResizePolicy = ResizePolicyType.UseNaturalSize,
933 HeightResizePolicy = ResizePolicyType.FillToParent,
934 Position = new Position(0, 0),
935 HorizontalAlignment = HorizontalAlignment.Begin,
936 VerticalAlignment = VerticalAlignment.Center,
941 private void CreateButtonIconAttributes()
943 CreateButtonAttributes();
945 if (Style.Button.Icon== null)
947 Style.Button.Icon= new ImageViewStyle
949 PositionUsesPivotPoint = true,
950 ParentOrigin = Tizen.NUI.ParentOrigin.CenterRight,
951 PivotPoint = Tizen.NUI.PivotPoint.CenterRight,
956 private void CreateListBackgroundAttributes()
958 if (Style.ListBackgroundImage == null)
960 Style.ListBackgroundImage = new ImageViewStyle
962 PositionUsesPivotPoint = true,
963 ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft,
964 PivotPoint = Tizen.NUI.PivotPoint.TopLeft,
970 #region ItemClickEventArgs
972 /// ItemClickEventArgs is a class to record item click event arguments which will sent to user.
974 /// <since_tizen> 6 </since_tizen>
975 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
976 [EditorBrowsable(EditorBrowsableState.Never)]
977 public class ItemClickEventArgs : EventArgs
979 /// <summary> Clicked item index of DropDown's list </summary>
980 /// <since_tizen> 6 </since_tizen>
981 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
982 [EditorBrowsable(EditorBrowsableState.Never)]
984 /// <summary> Clicked item text string of DropDown's list </summary>
985 /// <since_tizen> 6 </since_tizen>
986 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
987 [EditorBrowsable(EditorBrowsableState.Never)]
992 #region DropDownDataItem
994 /// DropDownDataItem is a class to record all data which will be applied to DropDown item.
996 /// <since_tizen> 6 </since_tizen>
997 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
998 //[EditorBrowsable(EditorBrowsableState.Never)]
999 public class DropDownDataItem
1001 private DropDownItemStyle itemDataStyle = new DropDownItemStyle();
1004 /// Creates a new instance of a DropDownItemData.
1006 /// <since_tizen> 6 </since_tizen>
1007 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1008 [EditorBrowsable(EditorBrowsableState.Never)]
1009 public DropDownDataItem()
1015 /// Creates a new instance of a DropDownItemData with style.
1017 /// <param name="style">Create DropDownItemData by special style defined in UX.</param>
1018 /// <since_tizen> 6 </since_tizen>
1019 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1020 [EditorBrowsable(EditorBrowsableState.Never)]
1021 public DropDownDataItem(string style)
1025 ViewStyle attributes = StyleManager.Instance.GetAttributes(style);
1026 if(attributes == null)
1028 throw new InvalidOperationException($"There is no style {style}");
1030 itemDataStyle = attributes as DropDownItemStyle;
1036 /// Creates a new instance of a DropDownItemData with style.
1038 /// <param name="style">Create DropDownItemData by style customized by user.</param>
1039 /// <since_tizen> 6 </since_tizen>
1040 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1041 [EditorBrowsable(EditorBrowsableState.Never)]
1042 public DropDownDataItem(DropDownItemStyle style)
1044 itemDataStyle.CopyFrom(style);
1049 /// DropDown item size.
1051 /// <since_tizen> 6 </since_tizen>
1052 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1053 [EditorBrowsable(EditorBrowsableState.Never)]
1058 return itemDataStyle.Size;
1062 itemDataStyle.Size = value;
1067 /// DropDown item background color selector.
1069 /// <since_tizen> 6 </since_tizen>
1070 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1071 [EditorBrowsable(EditorBrowsableState.Never)]
1072 public Selector<Color> BackgroundColorSelector
1076 return itemDataStyle.BackgroundColor;
1080 if (itemDataStyle.BackgroundColor == null)
1082 itemDataStyle.BackgroundColor = new Selector<Color>();
1085 itemDataStyle.BackgroundColor.Clone(value);
1090 /// DropDown item text string.
1092 /// <since_tizen> 6 </since_tizen>
1093 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1094 [EditorBrowsable(EditorBrowsableState.Never)]
1099 return itemDataStyle.Text?.Text?.All;
1103 CreateTextAttributes();
1104 if (itemDataStyle.Text.Text == null)
1106 itemDataStyle.Text.Text = new Selector<string> { All = value };
1110 itemDataStyle.Text.Text.All = value;
1116 /// DropDown item text's point size.
1118 /// <since_tizen> 6 </since_tizen>
1119 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1120 [EditorBrowsable(EditorBrowsableState.Never)]
1121 public float PointSize
1125 return itemDataStyle.Text?.PointSize?.All ?? 0;
1129 CreateTextAttributes();
1130 if (itemDataStyle.Text.PointSize == null)
1132 itemDataStyle.Text.PointSize = new Selector<float?> { All = value };
1136 itemDataStyle.Text.PointSize.All = value;
1142 /// DropDown item text's font family.
1144 /// <since_tizen> 6 </since_tizen>
1145 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1146 [EditorBrowsable(EditorBrowsableState.Never)]
1147 public string FontFamily
1152 //return itemDataAttributes.TextAttributes?.FontFamily?.GetValue(State);
1156 CreateTextAttributes();
1157 itemDataStyle.Text.FontFamily = value;
1162 /// DropDown item text's position.
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 Position TextPosition
1171 return itemDataStyle.Text?.Position;
1175 CreateTextAttributes();
1176 itemDataStyle.Text.Position = value;
1181 /// DropDown item's icon's resource url.
1183 /// <since_tizen> 6 </since_tizen>
1184 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1185 [EditorBrowsable(EditorBrowsableState.Never)]
1186 public string IconResourceUrl
1190 return itemDataStyle.Icon?.ResourceUrl?.All;
1194 CreateIconAttributes();
1195 if (itemDataStyle.Icon.ResourceUrl == null)
1197 itemDataStyle.Icon.ResourceUrl = new Selector<string> { All = value };
1201 itemDataStyle.Icon.ResourceUrl.All = value;
1207 /// DropDown item's icon's size.
1209 /// <since_tizen> 6 </since_tizen>
1210 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1211 [EditorBrowsable(EditorBrowsableState.Never)]
1212 public Size IconSize
1216 return itemDataStyle.Icon?.Size;
1220 CreateIconAttributes();
1221 itemDataStyle.Icon.Size = value;
1226 /// DropDown item's icon's position.
1228 /// <since_tizen> 6 </since_tizen>
1229 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1230 [EditorBrowsable(EditorBrowsableState.Never)]
1231 public Position IconPosition
1235 return itemDataStyle.Icon.Position;
1239 CreateIconAttributes();
1240 itemDataStyle.Icon.Position = value;
1245 /// DropDown item's check image's resource url.
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 string CheckImageResourceUrl
1254 return itemDataStyle.CheckImage?.ResourceUrl?.All;
1258 CreateCheckImageAttributes();
1259 if (itemDataStyle.CheckImage.ResourceUrl == null)
1261 itemDataStyle.CheckImage.ResourceUrl = new Selector<string> { All = value };
1265 itemDataStyle.CheckImage.ResourceUrl.All = value;
1271 /// DropDown item's check image's size.
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 Size CheckImageSize
1280 return itemDataStyle.CheckImage?.Size;
1284 CreateCheckImageAttributes();
1285 itemDataStyle.CheckImage.Size = value;
1290 /// DropDown item's check image's right space.
1292 /// <since_tizen> 6 </since_tizen>
1293 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1294 [EditorBrowsable(EditorBrowsableState.Never)]
1295 public int CheckImageGapToBoundary
1299 return itemDataStyle.CheckImageGapToBoundary;
1303 itemDataStyle.CheckImageGapToBoundary = value;
1308 /// Flag to decide DropDown item is selected or not.
1310 /// <since_tizen> 6 </since_tizen>
1311 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1312 [EditorBrowsable(EditorBrowsableState.Never)]
1313 public bool IsSelected
1317 return itemDataStyle.IsSelected;
1321 itemDataStyle.IsSelected = value;
1325 private void Initalize()
1327 if (itemDataStyle == null)
1329 throw new Exception("Button attribute parse error.");
1333 private void CreateTextAttributes()
1335 if(itemDataStyle.Text== null)
1337 itemDataStyle.Text= new TextLabelStyle
1339 PositionUsesPivotPoint = true,
1340 ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft,
1341 PivotPoint = Tizen.NUI.PivotPoint.TopLeft,
1342 WidthResizePolicy = ResizePolicyType.UseNaturalSize,
1343 HeightResizePolicy = ResizePolicyType.FillToParent,
1344 VerticalAlignment = VerticalAlignment.Center,
1345 HorizontalAlignment = HorizontalAlignment.Begin,
1350 private void CreateIconAttributes()
1352 if (itemDataStyle.Icon== null)
1354 itemDataStyle.Icon= new ImageViewStyle
1356 PositionUsesPivotPoint = true,
1357 ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft,
1358 PivotPoint = Tizen.NUI.PivotPoint.TopLeft,
1363 private void CreateCheckImageAttributes()
1365 if (itemDataStyle.CheckImage== null)
1367 itemDataStyle.CheckImage= new ImageViewStyle
1369 PositionUsesPivotPoint = true,
1370 ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft,
1371 PivotPoint = Tizen.NUI.PivotPoint.TopLeft,
1378 #region DropDownItemView
1379 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1380 [EditorBrowsable(EditorBrowsableState.Never)]
1381 internal class DropDownItemView : Control
1383 private TextLabel mText = null;
1384 private ImageView mIcon = null;
1385 private ImageView mCheck = null;
1387 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1388 [EditorBrowsable(EditorBrowsableState.Never)]
1389 public DropDownItemView() : base()
1393 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1394 [EditorBrowsable(EditorBrowsableState.Never)]
1395 public Selector<Color> BackgroundColorSelector
1401 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1402 [EditorBrowsable(EditorBrowsableState.Never)]
1420 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1421 [EditorBrowsable(EditorBrowsableState.Never)]
1422 public string FontFamily
1430 return mText.FontFamily;
1435 mText.FontFamily = value;
1439 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1440 [EditorBrowsable(EditorBrowsableState.Never)]
1441 public float? PointSize
1449 return mText.PointSize;
1454 mText.PointSize = (float)value;
1458 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1459 [EditorBrowsable(EditorBrowsableState.Never)]
1460 public Color TextColor
1468 return mText.TextColor;
1473 mText.TextColor = value;
1477 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1478 [EditorBrowsable(EditorBrowsableState.Never)]
1479 public Position TextPosition
1487 return mText.Position;
1492 mText.Position = value;
1496 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1497 [EditorBrowsable(EditorBrowsableState.Never)]
1498 public string IconResourceUrl
1506 return mIcon.ResourceUrl;
1511 mIcon.ResourceUrl = value;
1515 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1516 [EditorBrowsable(EditorBrowsableState.Never)]
1517 public Size IconSize
1534 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1535 [EditorBrowsable(EditorBrowsableState.Never)]
1536 public Position IconPosition
1544 return mIcon.Position;
1549 mIcon.Position = value;
1553 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1554 [EditorBrowsable(EditorBrowsableState.Never)]
1555 public string CheckResourceUrl
1563 return mCheck.ResourceUrl;
1568 mCheck.ResourceUrl = value;
1572 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1573 [EditorBrowsable(EditorBrowsableState.Never)]
1574 public Position CheckPosition
1582 return mCheck.Position;
1587 mCheck.Position = value;
1591 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1592 [EditorBrowsable(EditorBrowsableState.Never)]
1593 public Size CheckImageSize
1606 mCheck.Size = value;
1610 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1611 [EditorBrowsable(EditorBrowsableState.Never)]
1612 public bool IsSelected
1620 return mCheck.Visibility;
1636 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1637 [EditorBrowsable(EditorBrowsableState.Never)]
1638 protected override void Dispose(DisposeTypes type)
1645 if (type == DisposeTypes.Explicit)
1671 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1672 [EditorBrowsable(EditorBrowsableState.Never)]
1673 protected override ViewStyle GetViewStyle()
1678 private void CreateIcon()
1682 mIcon = new ImageView()
1684 PositionUsesPivotPoint = true,
1685 ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft,
1686 PivotPoint = Tizen.NUI.PivotPoint.TopLeft,
1692 private void CreateText()
1696 mText = new TextLabel()
1698 PositionUsesPivotPoint = true,
1699 ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft,
1700 PivotPoint = Tizen.NUI.PivotPoint.TopLeft,
1701 WidthResizePolicy = ResizePolicyType.UseNaturalSize,
1702 HeightResizePolicy = ResizePolicyType.FillToParent,
1703 VerticalAlignment = VerticalAlignment.Center,
1704 HorizontalAlignment = HorizontalAlignment.Begin,
1710 private void CreateCheckImage()
1714 mCheck = new ImageView()
1716 PositionUsesPivotPoint = true,
1717 ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft,
1718 PivotPoint = Tizen.NUI.PivotPoint.TopLeft,
1727 #region DropDownListBridge
1730 /// DropDownListBridge is bridge to contact item data and item view.
1732 /// <since_tizen> 6 </since_tizen>
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 class DropDownListBridge : FlexibleView.Adapter
1737 private List<DropDownDataItem> mDatas = new List<DropDownDataItem>();
1740 /// Creates a new instance of a DropDownListBridge.
1742 /// <since_tizen> 6 </since_tizen>
1743 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1744 [EditorBrowsable(EditorBrowsableState.Never)]
1745 public DropDownListBridge()
1750 /// Insert data. The inserted data will be added to the special position by index automatically.
1752 /// <param name="position">Position index where will be inserted.</param>
1753 /// <param name="data">Item data which will apply to tab item view.</param>
1754 /// <since_tizen> 6 </since_tizen>
1755 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1756 [EditorBrowsable(EditorBrowsableState.Never)]
1757 public void InsertData(int position, DropDownDataItem data)
1761 position = mDatas.Count;
1763 mDatas.Insert(position, data);
1764 NotifyItemInserted(position);
1768 /// Remove data by position.
1770 /// <param name="position">Position index where will be removed.</param>
1771 /// <since_tizen> 6 </since_tizen>
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 void RemoveData(int position)
1776 mDatas.RemoveAt(position);
1777 NotifyItemRemoved(position);
1781 /// Get data by position.
1783 /// <param name="position">Position index where will be gotten.</param>
1784 /// <since_tizen> 6 </since_tizen>
1785 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1786 [EditorBrowsable(EditorBrowsableState.Never)]
1787 public DropDownDataItem GetData(int position)
1789 return mDatas[position];
1793 /// Get view holder by view type.
1795 /// <param name="viewType">Create item view.</param>
1796 /// <since_tizen> 6 </since_tizen>
1797 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1798 [EditorBrowsable(EditorBrowsableState.Never)]
1799 public override FlexibleView.ViewHolder OnCreateViewHolder(int viewType)
1801 FlexibleView.ViewHolder viewHolder = new FlexibleView.ViewHolder(new DropDownItemView());
1807 /// Binder view holder, it can be override.
1809 /// <param name="holder">View holder.</param>
1810 /// <param name="position">Position index where will be gotten.</param>
1811 /// <since_tizen> 6 </since_tizen>
1812 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1813 [EditorBrowsable(EditorBrowsableState.Never)]
1814 public override void OnBindViewHolder(FlexibleView.ViewHolder holder, int position)
1816 DropDownDataItem listItemData = mDatas[position];
1817 if(listItemData == null)
1821 DropDownItemView listItemView = holder.ItemView as DropDownItemView;
1822 listItemView.Name = "Item" + position;
1823 if (listItemData.Size != null)
1825 holder.ItemView.Size = listItemData.Size;
1828 if (listItemView != null)
1830 listItemView.BackgroundColorSelector = listItemData.BackgroundColorSelector;
1831 if (listItemData.Text != null)
1833 listItemView.Text = listItemData.Text;
1834 listItemView.PointSize = listItemData.PointSize;
1835 listItemView.FontFamily = listItemData.FontFamily;
1836 listItemView.TextPosition = listItemData.TextPosition;
1839 if (listItemData.IconResourceUrl != null)
1841 listItemView.IconResourceUrl = listItemData.IconResourceUrl;
1842 listItemView.IconSize = listItemData.IconSize;
1843 if (listItemView.IconSize != null)
1845 listItemView.IconPosition = new Position(listItemData.IconPosition.X, (listItemView.Size2D.Height - listItemView.IconSize.Height) / 2);
1849 if (listItemData.CheckImageResourceUrl != null)
1851 listItemView.CheckResourceUrl = listItemData.CheckImageResourceUrl;
1852 listItemView.CheckImageSize = listItemData.CheckImageSize;
1853 if (listItemView.CheckImageSize != null)
1855 listItemView.CheckPosition = new Position(listItemView.Size2D.Width - listItemData.CheckImageGapToBoundary - listItemView.CheckImageSize.Width, (listItemView.Size2D.Height - listItemView.CheckImageSize.Height) / 2);
1859 listItemView.IsSelected = listItemData.IsSelected;
1864 /// Destroy view holder, it can be override.
1866 /// <param name="holder">View holder.</param>
1867 /// <since_tizen> 6 </since_tizen>
1868 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1869 [EditorBrowsable(EditorBrowsableState.Never)]
1870 public override void OnDestroyViewHolder(FlexibleView.ViewHolder holder)
1872 if (holder.ItemView != null)
1874 holder.ItemView.Dispose();
1879 /// Get item count, it can be override.
1881 /// <since_tizen> 6 </since_tizen>
1882 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
1883 [EditorBrowsable(EditorBrowsableState.Never)]
1884 public override int GetItemCount()
1886 return mDatas.Count;