/// <since_tizen> 6 </since_tizen>
/// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
- public class DropDown : Control
+ public partial class DropDown : Control
{
/// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
- public static readonly BindableProperty ListPaddingProperty = BindableProperty.Create("ListPadding", typeof(Extents), typeof(Tizen.NUI.Components.DropDown), null, propertyChanged: (bindable, oldValue, newValue) =>
+ public static readonly BindableProperty ListPaddingProperty = BindableProperty.Create(nameof(ListPadding), typeof(Extents), typeof(DropDown), null, propertyChanged: (bindable, oldValue, newValue) =>
{
- var instance = (Tizen.NUI.Components.DropDown)bindable;
+ var instance = (DropDown)bindable;
if (newValue != null)
{
- instance.privateListPadding = (Extents)newValue;
+ instance.listPadding.CopyFrom((Extents)newValue);
+ instance.UpdateDropDown();
}
},
defaultValueCreator: (bindable) =>
{
- var instance = (Tizen.NUI.Components.DropDown)bindable;
- return instance.privateListPadding;
+ var instance = (DropDown)bindable;
+ return instance.listPadding;
});
/// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
- public static readonly BindableProperty ListSizeProperty = BindableProperty.Create("ListSize", typeof(Size), typeof(Tizen.NUI.Components.DropDown), null, propertyChanged: (bindable, oldValue, newValue) =>
+ public static readonly BindableProperty SelectedItemIndexProperty = BindableProperty.Create(nameof(SelectedItemIndex), typeof(int), typeof(DropDown), 0, propertyChanged: (bindable, oldValue, newValue) =>
{
- var instance = (Tizen.NUI.Components.DropDown)bindable;
+ var instance = (DropDown)bindable;
if (newValue != null)
{
- instance.privateListSize = (Size)newValue;
- }
- },
- defaultValueCreator: (bindable) =>
- {
- var instance = (Tizen.NUI.Components.DropDown)bindable;
- return instance.privateListSize;
- });
- /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
- [EditorBrowsable(EditorBrowsableState.Never)]
- public static readonly BindableProperty SelectedItemIndexProperty = BindableProperty.Create("SelectedItemIndex", typeof(int), typeof(Tizen.NUI.Components.DropDown), 0, propertyChanged: (bindable, oldValue, newValue) =>
- {
- var instance = (Tizen.NUI.Components.DropDown)bindable;
- if (newValue != null)
- {
- instance.privateSelectedItemIndex = (int)newValue;
- }
- },
- defaultValueCreator: (bindable) =>
- {
- var instance = (Tizen.NUI.Components.DropDown)bindable;
- return instance.privateSelectedItemIndex;
- });
- /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
- [EditorBrowsable(EditorBrowsableState.Never)]
- public static readonly BindableProperty FocusedItemIndexProperty = BindableProperty.Create("FocusedItemIndex", typeof(int), typeof(Tizen.NUI.Components.DropDown), 0, propertyChanged: (bindable, oldValue, newValue) =>
- {
- var instance = (Tizen.NUI.Components.DropDown)bindable;
- if (newValue != null)
- {
- instance.privateFocusedItemIndex = (int)newValue;
- }
- },
- defaultValueCreator: (bindable) =>
- {
- var instance = (Tizen.NUI.Components.DropDown)bindable;
- return instance.privateFocusedItemIndex;
- });
- /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
- [EditorBrowsable(EditorBrowsableState.Never)]
- public static readonly BindableProperty ListMarginProperty = BindableProperty.Create("ListMargin", typeof(Extents), typeof(Tizen.NUI.Components.DropDown), null, propertyChanged: (bindable, oldValue, newValue) =>
- {
- var instance = (Tizen.NUI.Components.DropDown)bindable;
- if (newValue != null)
- {
- instance.privateListMargin = (Extents)newValue;
+ int selectedItemIndex = (int)newValue;
+ if (selectedItemIndex == instance.selectedItemIndex || instance.adapter == null || selectedItemIndex < 0 || selectedItemIndex >= instance.adapter.GetItemCount())
+ {
+ return;
+ }
+ instance.SetListItemToSelected((uint)selectedItemIndex);
}
},
defaultValueCreator: (bindable) =>
{
- var instance = (Tizen.NUI.Components.DropDown)bindable;
- return instance.privateListMargin;
+ var instance = (DropDown)bindable;
+ return instance.selectedItemIndex;
});
/// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
- public static readonly BindableProperty ListRelativeOrientationProperty = BindableProperty.Create("ListRelativeOrientation", typeof(ListOrientation), typeof(Tizen.NUI.Components.DropDown), ListOrientation.Left, propertyChanged: (bindable, oldValue, newValue) =>
+ public static readonly BindableProperty ListMarginProperty = BindableProperty.Create(nameof(ListMargin), typeof(Extents), typeof(DropDown), null, propertyChanged: (bindable, oldValue, newValue) =>
{
- var instance = (Tizen.NUI.Components.DropDown)bindable;
+ var instance = (DropDown)bindable;
if (newValue != null)
{
- instance.privateListRelativeOrientation = (ListOrientation)newValue;
+ instance.listMargin.CopyFrom((Extents)newValue);
+ instance.UpdateDropDown();
}
},
defaultValueCreator: (bindable) =>
{
- var instance = (Tizen.NUI.Components.DropDown)bindable;
- return instance.privateListRelativeOrientation;
+ var instance = (DropDown)bindable;
+ return instance.listMargin;
});
/// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
- public static readonly BindableProperty SpaceProperty = BindableProperty.Create("Space", typeof(Extents), typeof(Tizen.NUI.Components.DropDown), null, propertyChanged: (bindable, oldValue, newValue) =>
+ public static readonly BindableProperty ListRelativeOrientationProperty = BindableProperty.Create(nameof(ListRelativeOrientation), typeof(ListOrientation), typeof(DropDown), ListOrientation.Left, propertyChanged: (bindable, oldValue, newValue) =>
{
- var instance = (Tizen.NUI.Components.DropDown)bindable;
+ var instance = (DropDown)bindable;
if (newValue != null)
{
- instance.privateSpace = (Extents)newValue;
+ instance.listRelativeOrientation = (ListOrientation)newValue;
+ instance.UpdateDropDown();
}
},
defaultValueCreator: (bindable) =>
{
- var instance = (Tizen.NUI.Components.DropDown)bindable;
- return instance.privateSpace;
+ var instance = (DropDown)bindable;
+ return instance.listRelativeOrientation;
});
/// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
- public static readonly BindableProperty SpaceBetweenButtonTextAndIconProperty = BindableProperty.Create("SpaceBetweenButtonTextAndIcon", typeof(int), typeof(Tizen.NUI.Components.DropDown), 0, propertyChanged: (bindable, oldValue, newValue) =>
+ public static readonly BindableProperty SpaceBetweenButtonTextAndIconProperty = BindableProperty.Create(nameof(SpaceBetweenButtonTextAndIcon), typeof(int), typeof(DropDown), 0, propertyChanged: (bindable, oldValue, newValue) =>
{
- var instance = (Tizen.NUI.Components.DropDown)bindable;
+ var instance = (DropDown)bindable;
if (newValue != null)
{
- instance.privateSpaceBetweenButtonTextAndIcon = (int)newValue;
+ instance.spaceBetweenButtonTextAndIcon = (int)newValue;
}
},
defaultValueCreator: (bindable) =>
{
- var instance = (Tizen.NUI.Components.DropDown)bindable;
- return instance.privateSpaceBetweenButtonTextAndIcon;
+ var instance = (DropDown)bindable;
+ return instance.spaceBetweenButtonTextAndIcon;
});
-
#region DropDown
private Button button = null;
private TextLabel headerText = null;
private TextLabel buttonText = null;
private ImageView listBackgroundImage = null;
-
// Component that scrolls the child added to it.
- private LayoutScroller layoutScroller = null;
+ private ScrollableBase scrollableBase = null;
// The LinearLayout container to house the items in the drop down list.
private View dropDownMenuFullList = null;
-
private DropDownListBridge adapter = new DropDownListBridge();
- private int selectedItemIndex = -1;
-
- private Extents listPadding = null;
- DropDownItemView selectedItemView = null;
+ private DropDownItemView selectedItemView = null;
+ private TapGestureDetector tapGestureDetector = null;
+ private Extents listMargin = new Extents(0, 0, 0, 0);
+ private Extents listPadding = new Extents(0, 0, 0, 0);
+ private ListOrientation listRelativeOrientation = ListOrientation.Left;
+ private int selectedItemIndex = -1;
+ private int spaceBetweenButtonTextAndIcon = 0;
private bool itemPressed = false;
- private TapGestureDetector tapGestureDetector = null;
-
- /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
- [EditorBrowsable(EditorBrowsableState.Never)]
- public new DropDownStyle Style => ViewStyle as DropDownStyle;
+ static DropDown() { }
/// <summary>
/// Creates a new instance of a DropDown.
/// <since_tizen> 6 </since_tizen>
/// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
- public DropDown() : base()
- {
- }
+ public DropDown() : base() { }
/// <summary>
/// Creates a new instance of a DropDown with style.
/// <since_tizen> 6 </since_tizen>
/// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
- public DropDown(string style) : base(style)
- {
- }
+ public DropDown(string style) : base(style) { }
/// <summary>
- /// Creates a new instance of a DropDown with attributes.
+ /// Creates a new instance of a DropDown with style.
/// </summary>
- /// <param name="attributes">Create DropDown by attributes customized by user.</param>
+ /// <param name="dropDownStyle">Create DropDown by style customized by user.</param>
/// <since_tizen> 6 </since_tizen>
/// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
- public DropDown(DropDownStyle attributes) : base(attributes)
+ public DropDown(DropDownStyle dropDownStyle) : base(dropDownStyle)
{
}
/// <summary>
- /// An event for the button clicked signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
- /// </summary>
- /// <since_tizen> 6 </since_tizen>
- /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
- [EditorBrowsable(EditorBrowsableState.Never)]
- public delegate void ClickEventHandler<ClickEventArgs>(object sender, ClickEventArgs e);
-
- /// <summary>
/// An event for the item clicked signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
/// </summary>
/// <since_tizen> 6 </since_tizen>
/// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
- public event ClickEventHandler<ItemClickEventArgs> ItemClickEvent;
+ public event EventHandler<ItemClickEventArgs> ItemClickEvent;
/// <summary>
/// List position in relation to the main button.
}
/// <summary>
- /// Space between button text and button icon in DropDown.
+ /// Get or set header text.
/// </summary>
- /// <since_tizen> 6 </since_tizen>
- /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
- public int SpaceBetweenButtonTextAndIcon
- {
- get
- {
- return (int)GetValue(SpaceBetweenButtonTextAndIconProperty);
- }
- set
- {
- SetValue(SpaceBetweenButtonTextAndIconProperty, value);
- }
- }
- private int privateSpaceBetweenButtonTextAndIcon
+ /// This will be public opened in tizen_next after ACR done. Before ACR, need to be hidden as inhouse API.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public TextLabel HeaderText
{
get
{
- return (int)Style.SpaceBetweenButtonTextAndIcon;
+ if (null == headerText)
+ {
+ headerText = new TextLabel()
+ {
+ WidthResizePolicy = ResizePolicyType.UseNaturalSize,
+ HeightResizePolicy = ResizePolicyType.UseNaturalSize,
+ HorizontalAlignment = HorizontalAlignment.Center,
+ VerticalAlignment = VerticalAlignment.Center,
+ ParentOrigin = NUI.ParentOrigin.Center,
+ PivotPoint = NUI.ParentOrigin.Center,
+ PositionUsesPivotPoint = true,
+ Name = "DropDownHeaderText"
+ };
+ Add(headerText);
+ }
+ return headerText;
}
- set
+ internal set
{
- Style.SpaceBetweenButtonTextAndIcon = value;
- RelayoutRequest();
+ headerText = value;
}
}
/// <summary>
- /// Left space in DropDown.
+ /// Get or set button.
/// </summary>
- /// <since_tizen> 6 </since_tizen>
- /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
- public Extents Space
- {
- get
- {
- return (Extents)GetValue(SpaceProperty);
- }
- set
- {
- SetValue(SpaceProperty, value);
- }
- }
- private Extents privateSpace
+ /// This will be public opened in tizen_next after ACR done. Before ACR, need to be hidden as inhouse API.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public Button Button
{
get
{
- return (Extents)Style.Space;
+ if (null == button)
+ {
+ button = new Button()
+ {
+ ParentOrigin = NUI.ParentOrigin.CenterLeft,
+ PivotPoint = NUI.PivotPoint.CenterLeft,
+ PositionUsesPivotPoint = true,
+ HeightResizePolicy = ResizePolicyType.FitToChildren,
+ IconRelativeOrientation = Button.IconOrientation.Right,
+ Name = "DropDownButton"
+ };
+ button.ClickEvent += ButtonClickEvent;
+ Add(button);
+
+ if (null == buttonText)
+ {
+ buttonText = new TextLabel();
+ }
+ }
+ return button;
}
- set
+ internal set
{
- Style.Space = value;
- RelayoutRequest();
+ button = value;
}
}
/// <summary>
- /// List relative orientation in DropDown.
+ /// Get or set the background image of list.
/// </summary>
- /// <since_tizen> 6 </since_tizen>
- /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
- public ListOrientation ListRelativeOrientation
- {
- get
- {
- return (ListOrientation)GetValue(ListRelativeOrientationProperty);
- }
- set
- {
- SetValue(ListRelativeOrientationProperty, value);
- RelayoutRequest();
- }
- }
- private ListOrientation privateListRelativeOrientation
+ /// This will be public opened in tizen_next after ACR done. Before ACR, need to be hidden as inhouse API.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public ImageView ListBackgroundImage
{
get
{
- return (ListOrientation)Style.ListRelativeOrientation;
+ if (null == listBackgroundImage)
+ {
+ listBackgroundImage = new ImageView()
+ {
+ Name = "ListBackgroundImage",
+ PositionUsesPivotPoint = true,
+ ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft,
+ PivotPoint = Tizen.NUI.PivotPoint.TopLeft,
+ WidthResizePolicy = ResizePolicyType.FitToChildren,
+ HeightResizePolicy = ResizePolicyType.FitToChildren,
+ };
+ Add(listBackgroundImage);
+
+ if (null == scrollableBase) // scrollableBase used to test of ListContainer Setup invoked already
+ {
+ SetUpListContainer();
+ }
+ }
+ return listBackgroundImage;
}
- set
+ internal set
{
- Style.ListRelativeOrientation = value;
- RelayoutRequest();
+ listBackgroundImage = value;
}
}
/// <summary>
- /// Space in list.
+ /// Return a copied Style instance of DropDown
+ /// </summary>
+ /// <remarks>
+ /// It returns copied Style instance and changing it does not effect to the DropDown.
+ /// Style setting is possible by using constructor or the function of ApplyStyle(ViewStyle viewStyle)
+ /// </remarks>
+ /// This will be public opened in tizen_next after ACR done. Before ACR, need to be hidden as inhouse API.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ //public new DropDownStyle Style
+ //{
+ // get
+ // {
+ // return new DropDownStyle(ViewStyle as DropDownStyle);
+ // }
+ //}
+ public new DropDownStyle Style => ViewStyle as DropDownStyle;
+
+ /// <summary>
+ /// Space between button text and button icon in DropDown.
/// </summary>
/// <since_tizen> 6 </since_tizen>
/// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
- public Extents ListMargin
- {
- get
- {
- return (Extents)GetValue(ListMarginProperty);
- }
- set
- {
- SetValue(ListMarginProperty, value);
- }
- }
- private Extents privateListMargin
+ public int SpaceBetweenButtonTextAndIcon
{
- get
- {
- return Style.ListMargin;
- }
- set
- {
- Style.ListMargin = value;
- RelayoutRequest();
- }
+ get => (int)GetValue(SpaceBetweenButtonTextAndIconProperty);
+ set => SetValue(SpaceBetweenButtonTextAndIconProperty, value);
}
/// <summary>
- /// Focused item index in list.
+ /// List relative orientation in DropDown.
/// </summary>
/// <since_tizen> 6 </since_tizen>
/// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
- public int FocusedItemIndex
- {
- get
- {
- return (int)GetValue(FocusedItemIndexProperty);
- }
- set
- {
- SetValue(FocusedItemIndexProperty, value);
- }
- }
- private int privateFocusedItemIndex
+ public ListOrientation ListRelativeOrientation
{
- get
- {
- return (int)Style.FocusedItemIndex;
- }
- set
- {
- Style.FocusedItemIndex = value;
- RelayoutRequest();
- }
+ get => (ListOrientation)GetValue(ListRelativeOrientationProperty);
+ set => SetValue(ListRelativeOrientationProperty, value);
}
/// <summary>
- /// Selected item index in list.
+ /// Space in list.
/// </summary>
/// <since_tizen> 6 </since_tizen>
/// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
- public int SelectedItemIndex
- {
- get
- {
- return (int)GetValue(SelectedItemIndexProperty);
- }
- set
- {
- if (value == selectedItemIndex || adapter == null || value >= adapter.GetItemCount())
- {
- return;
- }
-
- SetValue(SelectedItemIndexProperty, value); // UpdatesSelectedItem
- }
- }
- private int privateSelectedItemIndex
+ public Extents ListMargin
{
get
{
- return selectedItemIndex;
- }
- set
- {
- if (value == selectedItemIndex || adapter == null || value >= adapter.GetItemCount())
- {
- return;
- }
- UpdateSelectedItem(value);
+ Extents tmp = (Extents)GetValue(ListMarginProperty);
+ return new Extents((ushort start, ushort end, ushort top, ushort bottom) => { ListMargin = new Extents(start, end, top, bottom); }, tmp.Start, tmp.End, tmp.Top, tmp.Bottom);
}
+ set => SetValue(ListMarginProperty, value);
}
/// <summary>
- /// List size in DropDown.
+ /// Selected item index in list.
/// </summary>
/// <since_tizen> 6 </since_tizen>
/// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
- public Size ListSize
- {
- get
- {
- return (Size)GetValue(ListSizeProperty);
- }
- set
- {
- SetValue(ListSizeProperty, value);
- }
- }
- private Size privateListSize
+ public int SelectedItemIndex
{
- get
- {
- return Style.ListSize;
- }
- set
- {
- Style.ListSize = value;
- RelayoutRequest();
- }
+ get => (int)GetValue(SelectedItemIndexProperty);
+ set => SetValue(SelectedItemIndexProperty, value);
}
/// <summary>
{
get
{
- return (Extents)GetValue(ListPaddingProperty);
- }
- set
- {
- SetValue(ListPaddingProperty, value);
- }
- }
- private Extents privateListPadding
- {
- get
- {
- return listPadding;
- }
- set
- {
- Style.ListPadding.CopyFrom(value);
-
- if (null == listPadding)
- {
- listPadding = new Extents((ushort start, ushort end, ushort top, ushort bottom) =>
- {
- Style.ListPadding.Start = start;
- Style.ListPadding.End = end;
- Style.ListPadding.Top = top;
- Style.ListPadding.Bottom = bottom;
- RelayoutRequest();
- }, value.Start, value.End, value.Top, value.Bottom);
- }
- else
- {
- listPadding.CopyFrom(value);
- }
-
- RelayoutRequest();
+ Extents tmp = (Extents)GetValue(ListPaddingProperty);
+ return new Extents((ushort start, ushort end, ushort top, ushort bottom) => { ListPadding = new Extents(start, end, top, bottom); }, tmp.Start, tmp.End, tmp.Top, tmp.Bottom);
}
+ set => SetValue(ListPaddingProperty, value);
}
/// <summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public void DeleteItem(int index)
{
- if(index < 0 || index >= adapter.GetItemCount())
- {
- return;
- }
+ if (index < 0 || index >= adapter?.GetItemCount()) return;
+ if (null == dropDownMenuFullList) return;
if (selectedItemIndex == index)
{
selectedItemIndex--;
}
- adapter.RemoveData(index);
+ adapter?.RemoveData(index);
if(index < dropDownMenuFullList.ChildCount)
{
[EditorBrowsable(EditorBrowsableState.Never)]
public void AttachScrollBar(ScrollBar scrollBar)
{
- if (layoutScroller == null)
+ if (scrollableBase == null)
{
return;
}
[EditorBrowsable(EditorBrowsableState.Never)]
public void DetachScrollBar()
{
- if (layoutScroller == null)
+ if (scrollableBase == null)
{
return;
}
Tizen.Log.Error("DropDown","Feature unsupported");
}
- protected override void RegisterDetectionOfSubstyleChanges()
+ /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override void ApplyStyle(ViewStyle viewStyle)
{
- base.RegisterDetectionOfSubstyleChanges();
-
- Style.PropertyChanged += DropDownAttributesPropertyChanged;
- Style.HeaderText.PropertyChanged += HeaderTextAttributesPropertyChanged;
- Style.Button.PropertyChanged += ButtonAttributesPropertyChanged;
+ base.ApplyStyle(viewStyle);
- Style.Button.Icon.PropertyChanged += IconStylePropertyChanged;;
+ DropDownStyle dropDownStyle = viewStyle as DropDownStyle;
+ if (null != dropDownStyle)
+ {
+ if (null != dropDownStyle.Button)
+ {
+ Button.ApplyStyle(dropDownStyle.Button);
+ }
+ if (null != dropDownStyle.HeaderText)
+ {
+ HeaderText.ApplyStyle(dropDownStyle.HeaderText);
+ }
+ if (null != dropDownStyle.ListBackgroundImage)
+ {
+ ListBackgroundImage.ApplyStyle(dropDownStyle.ListBackgroundImage);
+ }
+ UpdateDropDown();
+ }
}
- private void IconStylePropertyChanged(object sender, PropertyChangedEventArgs e)
+ /// <summary>
+ /// Update DropDown by style.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ protected void UpdateDropDown()
{
- int iconWidth = 0;
- int buttonTextWidth = 0;
- if (e.PropertyName.Equals(ImageViewStyle.SizeProperty.PropertyName))
- {
- iconWidth = (int)Style.Button.Icon.Size.Width;
- }
+ if (null == scrollableBase || null == listBackgroundImage || null == dropDownMenuFullList) return;
+ if (null == Style.ListBackgroundImage.Size) return;
+ // Resize and position scrolling list within the drop down list container. Can be used to position list in relation to the background image.
+ scrollableBase.Size = Style.ListBackgroundImage.Size - new Size((listPadding.Start + listPadding.End), (listPadding.Top + listPadding.Bottom), 0);
+ scrollableBase.Position2D = new Position2D(listPadding.Start, listPadding.Top);
- if (buttonText.NaturalSize2D != null)
+ int listBackgroundImageX = 0;
+ int listBackgroundImageY = 0;
+ if (listRelativeOrientation == ListOrientation.Left)
{
- buttonTextWidth = buttonText.NaturalSize2D.Width;
+ listBackgroundImageX = (int)listMargin.Start;
+ listBackgroundImageY = (int)listMargin.Top;
}
-
- button.SizeWidth = iconWidth + (int)Style.SpaceBetweenButtonTextAndIcon + buttonTextWidth;
- }
-
- private void DropDownAttributesPropertyChanged(object sender, PropertyChangedEventArgs e)
- {
- if (e.PropertyName.Equals("Space"))
+ else if (listRelativeOrientation == ListOrientation.Right)
{
- button.Position2D.X = (int)Style.Space.Start;
+ listBackgroundImageX = -(int)listMargin.End;
+ listBackgroundImageY = (int)listMargin.Top;
}
+ listBackgroundImage.Position2D = new Position2D(listBackgroundImageX, listBackgroundImageY);
+ dropDownMenuFullList?.Layout?.RequestLayout();
}
- private void ButtonAttributesPropertyChanged(object sender, PropertyChangedEventArgs e)
+ /// <summary>
+ /// update.
+ /// </summary>
+ protected override void OnUpdate()
{
- if (null == button)
+ float buttonTextWidth = 0;
+ if (null != buttonText)
{
- button = new Button()
- {
- PositionUsesPivotPoint = true,
- ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft,
- PivotPoint = Tizen.NUI.PivotPoint.TopLeft,
- HeightResizePolicy = ResizePolicyType.FillToParent,
- IconRelativeOrientation = Components.Button.IconOrientation.Right,
- };
- button.Name = "DropDownButton";
- button.ClickEvent += ButtonClickEvent;
- Add(button);
-
- button.ApplyStyle(Style.Button);
+ buttonText.Text = Style.Button.Text.Text.All;
+ buttonText.PointSize = Style.Button.Text.PointSize?.GetValue(ControlState) ?? StyleManager.PointSizeNormal;
+ buttonTextWidth = buttonText.NaturalSize.Width;
}
+ float fitWidth = (Style.Button.Icon.Size?.Width ?? 48) + Style.SpaceBetweenButtonTextAndIcon + buttonTextWidth;
+ fitWidth += (button.IconPadding.Start + button.IconPadding.End);
+ button.Size.Width = Math.Max(button.Size.Width, fitWidth);
+ RelayoutRequest();
- if (null == buttonText)
+ int numberOfItemsToAdd = adapter.GetItemCount();
+
+ if (adapter.AdapterPurge == true)
{
- buttonText = new TextLabel()
+ adapter.AdapterPurge = false;
+ for (int i = 0; i < numberOfItemsToAdd; i++)
{
- PositionUsesPivotPoint = true,
- ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft,
- PivotPoint = Tizen.NUI.PivotPoint.TopLeft,
- WidthResizePolicy = ResizePolicyType.UseNaturalSize,
- HeightResizePolicy = ResizePolicyType.FillToParent,
- };
- buttonText.Name = "DropDownButtonText";
- Add(buttonText);
- buttonText.Hide();
+ AddItemAt(adapter.GetData(i), i);
+ }
}
- }
-
- private void HeaderTextAttributesPropertyChanged(object sender, PropertyChangedEventArgs e)
- {
- if (null == headerText)
+ // Set selection icon on View
+ if (selectedItemIndex > 0)
{
- headerText = new TextLabel();
- headerText.Name = "DropDownHeaderText";
- Add(headerText);
-
- headerText.ApplyStyle(Style.HeaderText);
+ SetListItemToSelected((uint)selectedItemIndex, selectedItemView);
}
}
/// <summary>
- /// Update DropDown by attributes.
+ /// Dispose DropDown and all children on it.
/// </summary>
+ /// <param name="type">Dispose type.</param>
/// <since_tizen> 6 </since_tizen>
/// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
- protected override void OnUpdate()
+ protected override void Dispose(DisposeTypes type)
{
- if (Style.ListBackgroundImage != null)
+ if (disposed)
{
- if (listBackgroundImage == null)
- {
- CreateListBackgroundImage();
- }
-
- int temp = (int)Style.FocusedItemIndex;
-
- if (layoutScroller==null) // layoutScroller used to test of ListContainer Setup invoked already
- {
- SetUpListContainer();
- }
-
- listBackgroundImage.Size = Style.ListSize;
-
- // Resize and position scrolling list within the drop down list container. Can be used to position list in relation to the background image.
- layoutScroller.Size = Style.ListSize - new Size((Style.ListPadding.Start + Style.ListPadding.End), (Style.ListPadding.Top + Style.ListPadding.Bottom), 0 );
- layoutScroller.Position2D = new Position2D(Style.ListPadding.Start,Style.ListPadding.Top);
-
- int listBackgroundImageX = 0;
- int listBackgroundImageY = 0;
- if (Style.ListRelativeOrientation == ListOrientation.Left)
- {
- if (Style.ListMargin != null)
- {
- listBackgroundImageX = (int)Style.ListMargin.Start;
- listBackgroundImageY = (int)Style.ListMargin.Top;
- }
- }
- else if (Style.ListRelativeOrientation == ListOrientation.Right)
- {
- if (Style.ListMargin != null)
- {
- int listWidth = 0;
- if (dropDownMenuFullList.Size2D != null)
- {
- listWidth = dropDownMenuFullList.Size2D.Width;
- }
- listBackgroundImageX = Size2D.Width - listWidth - (int)Style.ListMargin.End;
- listBackgroundImageY = (int)Style.ListMargin.Top;
- }
- }
- listBackgroundImage.Position2D = new Position2D(listBackgroundImageX, listBackgroundImageY);
- dropDownMenuFullList?.Layout?.RequestLayout();
-
- int numberOfItemsToAdd = adapter.GetItemCount();
-
- if (adapter.AdapterPurge == true)
- {
- adapter.AdapterPurge = false;
- for (int i =0; i<numberOfItemsToAdd; i++)
- {
- AddItemAt(adapter.GetData(i), i);
- }
- }
-
- // Set selection icon on View
- UpdateSelectedItem(selectedItemIndex);
- }
- }
-
- /// <summary>
- /// Dispose DropDown and all children on it.
- /// </summary>
- /// <param name="type">Dispose type.</param>
- /// <since_tizen> 6 </since_tizen>
- /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
- [EditorBrowsable(EditorBrowsableState.Never)]
- protected override void Dispose(DisposeTypes type)
- {
- if (disposed)
- {
- return;
- }
+ return;
+ }
if (type == DisposeTypes.Explicit)
{
- if (headerText != null)
- {
- Utility.Dispose(headerText);
- }
-
- if (buttonText != null)
- {
- Utility.Dispose(buttonText);
- }
-
- if (button != null)
- {
- Utility.Dispose(button);
- }
-
- if (layoutScroller != null)
- {
- if (dropDownMenuFullList != null)
- {
- Utility.Dispose(dropDownMenuFullList);
- }
-
- if (listBackgroundImage != null)
- {
- Utility.Dispose(listBackgroundImage);
- }
-
- Utility.Dispose(layoutScroller);
- }
+ Utility.Dispose(headerText);
+ Utility.Dispose(buttonText);
+ Utility.Dispose(button);
+ Utility.Dispose(scrollableBase);
+ Utility.Dispose(dropDownMenuFullList);
+ Utility.Dispose(listBackgroundImage);
}
base.Dispose(type);
}
/// <summary>
- /// Get DropDown attribues.
+ /// Get DropDown style.
/// </summary>
+ /// <returns>The default dropdown style.</returns>
/// <since_tizen> 6 </since_tizen>
/// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
- protected override ViewStyle GetViewStyle()
+ protected override ViewStyle CreateViewStyle()
{
return new DropDownStyle();
}
tapGestureDetector = new TapGestureDetector();
}
View view = viewHolder.ItemView;
+ view.ApplyStyle(itemData.itemDataStyle);
view.TouchEvent += ListItemTouchEvent;
dropDownMenuFullList.Add(view);
}
{
ItemClickEvent?.Invoke(sender, e);
}
- private void CreateHeaderText()
+
+ private void CreateButtonText()
+ {
+ if (null == buttonText)
+ {
+ buttonText = new TextLabel();
+ }
+ }
+
+ private void CreateButton()
{
- headerText = new TextLabel();
- headerText.Name = "DropDownHeaderText";
- Add(headerText);
+ if (null == button)
+ {
+ button = new Button()
+ {
+ ParentOrigin = NUI.ParentOrigin.CenterLeft,
+ PivotPoint = NUI.PivotPoint.CenterLeft,
+ PositionUsesPivotPoint = true,
+ HeightResizePolicy = ResizePolicyType.FitToChildren,
+ IconRelativeOrientation = Button.IconOrientation.Right,
+ };
+ button.Name = "DropDownButton";
+ button.ClickEvent += ButtonClickEvent;
+ Add(button);
+ }
}
private void SetUpListContainer()
Focusable = true,
};
- layoutScroller = new LayoutScroller()
+ scrollableBase = new ScrollableBase()
{
- Name = "LayoutScroller",
+ Name = "Scrollable",
};
- layoutScroller.AddLayoutToScroll(dropDownMenuFullList);
+ scrollableBase.Add(dropDownMenuFullList);
- listBackgroundImage.Add(layoutScroller);
+ listBackgroundImage.Add(scrollableBase);
listBackgroundImage.Hide();
}
}
}
- private void SetListItemToSelected(DropDownItemView targetItemView)
+ private void SetListItemToSelected(DropDownItemView view)
{
- // Set the DropDownItemView matching the targetItemView to selected.
- if (selectedItemView!=targetItemView)
+ if (dropDownMenuFullList == null || view == null || view == selectedItemView)
+ {
+ return;
+ }
+
+ uint newSelectedIndex = 0;
+ for (; newSelectedIndex < dropDownMenuFullList.ChildCount; newSelectedIndex++)
{
- if (selectedItemView!=null)
+ var itemView = dropDownMenuFullList.GetChildAt(newSelectedIndex) as DropDownItemView;
+ if (itemView == view)
{
- // clear selection status of currently selected item view
- selectedItemView.IsSelected = false;
+ SetListItemToSelected(newSelectedIndex, view);
+ return;
}
- // Set target item to selected
- targetItemView.IsSelected = true;
- selectedItemView = targetItemView;
}
}
+ private void SetListItemToSelected(uint index)
+ {
+ if (dropDownMenuFullList == null || index == selectedItemIndex)
+ {
+ return;
+ }
+
+ SetListItemToSelected(index, GetViewFromIndex(index) as DropDownItemView);
+ }
+
+ private void SetListItemToSelected(uint index, DropDownItemView view)
+ {
+ if (adapter == null)
+ {
+ return;
+ }
+
+ if (selectedItemView != null)
+ {
+ selectedItemView.IsSelected = false;
+ adapter.GetData(selectedItemIndex).IsSelected = false;
+ }
+
+ if (view == null || index >= dropDownMenuFullList.ChildCount)
+ {
+ selectedItemIndex = -1;
+ selectedItemView = null;
+ return;
+ }
+
+ selectedItemIndex = (int)index;
+ selectedItemView = view;
+ selectedItemView.IsSelected = true;
+ adapter.GetData(selectedItemIndex).IsSelected = true;
+ dropDownMenuFullList.Layout?.RequestLayout();
+ }
+
private bool ListItemTouchEvent(object sender, TouchEventArgs e)
{
PointStateType state = e.Touch.GetState(0);
- DropDownItemView touchedView = sender as DropDownItemView;;
+ DropDownItemView touchedView = sender as DropDownItemView;
+
+ touchedView.OnTouch(e.Touch); // Handle control state change
+
switch (state)
{
case PointStateType.Down:
- if (touchedView != null && touchedView.BackgroundColorSelector != null)
- {
- touchedView.BackgroundColor = touchedView.BackgroundColorSelector.GetValue(ControlStates.Pressed);
- }
itemPressed = true; // if matched with a Up then a click event.
break;
case PointStateType.Motion:
- if (touchedView != null && touchedView.BackgroundColorSelector != null)
- {
- touchedView.BackgroundColor = touchedView.BackgroundColorSelector.GetValue(ControlStates.Normal);
- }
itemPressed = false;
break;
case PointStateType.Up:
- if (touchedView != null && touchedView.BackgroundColorSelector != null)
+ if (touchedView != null)
{
- touchedView.BackgroundColor = touchedView.BackgroundColorSelector.GetValue(ControlStates.Selected);
-
if (itemPressed) // if Down was previously sent without motion (Scrolling) in-between then a clicked event occurred.
{
// List item clicked
return true;
}
- private void UpdateSelectedItem(int index)
- {
- if (selectedItemIndex != -1)
- {
- DropDownDataItem data = adapter.GetData(selectedItemIndex);
- if(data != null)
- {
- data.IsSelected = false;
- }
- DropDownItemView listItemView = dropDownMenuFullList.GetChildAt((uint)selectedItemIndex) as DropDownItemView;
- data.IsSelected = false;
- SetListItemToSelected(listItemView);
- }
-
- if (index != -1)
- {
- DropDownDataItem data = adapter.GetData(index);
- if (data != null)
- {
- data.IsSelected = true;
- DropDownItemView listItemView = dropDownMenuFullList?.GetChildAt((uint)index) as DropDownItemView;
- if(listItemView)
- {
- SetListItemToSelected(listItemView);
- }
- }
- }
-
- selectedItemIndex = index;
- dropDownMenuFullList?.Layout?.RequestLayout();
- }
-
- private void CreateListBackgroundImage()
- {
- if (null == listBackgroundImage)
- {
- listBackgroundImage = new ImageView
- {
- Name = "ListBackgroundImage",
- PositionUsesPivotPoint = true,
- ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft,
- PivotPoint = Tizen.NUI.PivotPoint.TopLeft,
- WidthResizePolicy = ResizePolicyType.FitToChildren,
- HeightResizePolicy = ResizePolicyType.FitToChildren,
- };
- Add(listBackgroundImage);
- }
- }
-
private void ButtonClickEvent(object sender, Button.ClickEventArgs e)
{
button.Hide();
listBackgroundImage.RaiseToTop();
}
- private void CreateHeaderTextAttributes()
- {
- if (Style.HeaderText == null)
- {
- Style.HeaderText = new TextLabelStyle()
- {
- PositionUsesPivotPoint = true,
- ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft,
- PivotPoint = Tizen.NUI.PivotPoint.TopLeft,
- WidthResizePolicy = ResizePolicyType.FillToParent,
- HeightResizePolicy = ResizePolicyType.FillToParent,
- HorizontalAlignment = HorizontalAlignment.Center,
- VerticalAlignment = VerticalAlignment.Center,
- };
- }
- }
-
- private void CreateButtonAttributes()
- {
- if (Style.Button == null)
- {
- Style.Button = new ButtonStyle();
- }
- }
-
- private void CreateButtonTextAttributes()
- {
- CreateButtonAttributes();
-
- if (Style.Button.Text== null)
- {
- Style.Button.Text= new TextLabelStyle
- {
- PositionUsesPivotPoint = true,
- ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft,
- PivotPoint = Tizen.NUI.PivotPoint.TopLeft,
- WidthResizePolicy = ResizePolicyType.UseNaturalSize,
- HeightResizePolicy = ResizePolicyType.FillToParent,
- Position = new Position(0, 0),
- HorizontalAlignment = HorizontalAlignment.Begin,
- VerticalAlignment = VerticalAlignment.Center,
- };
- }
- }
-
- private void CreateButtonIconAttributes()
- {
- CreateButtonAttributes();
-
- if (Style.Button.Icon== null)
- {
- Style.Button.Icon= new ImageViewStyle
- {
- PositionUsesPivotPoint = true,
- ParentOrigin = Tizen.NUI.ParentOrigin.CenterRight,
- PivotPoint = Tizen.NUI.PivotPoint.CenterRight,
- };
- }
- }
-
- private void CreateListBackgroundAttributes()
- {
- if (Style.ListBackgroundImage == null)
- {
- Style.ListBackgroundImage = new ImageViewStyle
- {
- PositionUsesPivotPoint = true,
- ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft,
- PivotPoint = Tizen.NUI.PivotPoint.TopLeft,
- };
- }
- }
#endregion
#region ItemClickEventArgs
/// <since_tizen> 6 </since_tizen>
/// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
- public int Index;
+ public int Index { get; set; }
/// <summary> Clicked item text string of DropDown's list </summary>
/// <since_tizen> 6 </since_tizen>
/// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
- public string Text;
+ public string Text { get; set; }
}
#endregion
- #region DropDownDataItem
+ #region ViewHolder
+
/// <summary>
- /// DropDownDataItem is a class to record all data which will be applied to DropDown item.
+ /// A ViewHolder is a class that holds a View created from DropDownListBridge data.
/// </summary>
/// <since_tizen> 6 </since_tizen>
/// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
- //[EditorBrowsable(EditorBrowsableState.Never)]
- public class DropDownDataItem
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public class ViewHolder
{
- private DropDownItemStyle itemDataStyle = new DropDownItemStyle();
-
- /// <summary>
- /// Creates a new instance of a DropDownItemData.
- /// </summary>
- /// <since_tizen> 6 </since_tizen>
- /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
- [EditorBrowsable(EditorBrowsableState.Never)]
- public DropDownDataItem()
- {
- Initialize();
- }
-
- /// <summary>
- /// Creates a new instance of a DropDownItemData with style.
- /// </summary>
- /// <param name="style">Create DropDownItemData by special style defined in UX.</param>
- /// <since_tizen> 6 </since_tizen>
- /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
- [EditorBrowsable(EditorBrowsableState.Never)]
- public DropDownDataItem(string style)
- {
- if(style != null)
- {
- ViewStyle attributes = StyleManager.Instance.GetAttributes(style);
- if(attributes == null)
- {
- throw new InvalidOperationException($"There is no style {style}");
- }
- itemDataStyle = attributes as DropDownItemStyle;
- }
- Initialize();
- }
-
- /// <summary>
- /// Creates a new instance of a DropDownItemData with style.
- /// </summary>
- /// <param name="style">Create DropDownItemData by style customized by user.</param>
- /// <since_tizen> 6 </since_tizen>
- /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
- [EditorBrowsable(EditorBrowsableState.Never)]
- public DropDownDataItem(DropDownItemStyle style)
- {
- itemDataStyle.CopyFrom(style);
- Initialize();
- }
-
- /// <summary>
- /// DropDown item size.
- /// </summary>
- /// <since_tizen> 6 </since_tizen>
- /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
- [EditorBrowsable(EditorBrowsableState.Never)]
- public Size Size
- {
- get
- {
- return itemDataStyle.Size;
- }
- set
- {
- itemDataStyle.Size = value;
- }
- }
-
/// <summary>
- /// DropDown item background color selector.
+ /// ViewHolder constructor.
/// </summary>
+ /// <param name="itemView">View</param>
/// <since_tizen> 6 </since_tizen>
/// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
- public Selector<Color> BackgroundColorSelector
+ public ViewHolder(View itemView)
{
- get
- {
- return itemDataStyle.BackgroundColor;
- }
- set
- {
- if (itemDataStyle.BackgroundColor == null)
- {
- itemDataStyle.BackgroundColor = new Selector<Color>();
- }
-
- itemDataStyle.BackgroundColor.Clone(value);
- }
+ ItemView = itemView ?? throw new ArgumentNullException(nameof(itemView), "itemView may not be null");
}
/// <summary>
- /// DropDown item text string.
+ /// Returns the view.
/// </summary>
/// <since_tizen> 6 </since_tizen>
/// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
- public string Text
- {
- get
- {
- return itemDataStyle.Text?.Text?.All;
- }
- set
- {
- CreateTextAttributes();
- if (itemDataStyle.Text.Text == null)
- {
- itemDataStyle.Text.Text = new Selector<string> { All = value };
- }
- else
- {
- itemDataStyle.Text.Text.All = value;
- }
- }
- }
+ public View ItemView { get; }
- /// <summary>
- /// DropDown item text's point size.
- /// </summary>
- /// <since_tizen> 6 </since_tizen>
- /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
- [EditorBrowsable(EditorBrowsableState.Never)]
- public float PointSize
- {
- get
- {
- return itemDataStyle.Text?.PointSize?.All ?? 0;
- }
- set
- {
- CreateTextAttributes();
- if (itemDataStyle.Text.PointSize == null)
- {
- itemDataStyle.Text.PointSize = new Selector<float?> { All = value };
- }
- else
- {
- itemDataStyle.Text.PointSize.All = value;
- }
- }
- }
+ internal bool IsBound { get; set; }
+ }
- /// <summary>
- /// DropDown item text's font family.
- /// </summary>
- /// <since_tizen> 6 </since_tizen>
- /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
- [EditorBrowsable(EditorBrowsableState.Never)]
- public string FontFamily
- {
- get
- {
- return "";
- //return itemDataAttributes.TextAttributes?.FontFamily?.GetValue(State);
- }
- set
- {
- CreateTextAttributes();
- itemDataStyle.Text.FontFamily = value;
- }
- }
-
- /// <summary>
- /// DropDown item text's position.
- /// </summary>
- /// <since_tizen> 6 </since_tizen>
- /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
- [EditorBrowsable(EditorBrowsableState.Never)]
- public Position TextPosition
- {
- get
- {
- return itemDataStyle.Text?.Position;
- }
- set
- {
- CreateTextAttributes();
- itemDataStyle.Text.Position = value;
- }
- }
-
- /// <summary>
- /// DropDown item's icon's resource url.
- /// </summary>
- /// <since_tizen> 6 </since_tizen>
- /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
- [EditorBrowsable(EditorBrowsableState.Never)]
- public string IconResourceUrl
- {
- get
- {
- return itemDataStyle.Icon?.ResourceUrl?.All;
- }
- set
- {
- CreateIconAttributes();
- if (itemDataStyle.Icon.ResourceUrl == null)
- {
- itemDataStyle.Icon.ResourceUrl = new Selector<string> { All = value };
- }
- else
- {
- itemDataStyle.Icon.ResourceUrl.All = value;
- }
- }
- }
-
- /// <summary>
- /// DropDown item's icon's size.
- /// </summary>
- /// <since_tizen> 6 </since_tizen>
- /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
- [EditorBrowsable(EditorBrowsableState.Never)]
- public Size IconSize
- {
- get
- {
- return itemDataStyle.Icon?.Size;
- }
- set
- {
- CreateIconAttributes();
- itemDataStyle.Icon.Size = value;
- }
- }
-
- /// <summary>
- /// DropDown item's icon's position.
- /// </summary>
- /// <since_tizen> 6 </since_tizen>
- /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
- [EditorBrowsable(EditorBrowsableState.Never)]
- public Position IconPosition
- {
- get
- {
- return itemDataStyle.Icon.Position;
- }
- set
- {
- CreateIconAttributes();
- itemDataStyle.Icon.Position = value;
- }
- }
-
- /// <summary>
- /// DropDown item's check image's resource url.
- /// </summary>
- /// <since_tizen> 6 </since_tizen>
- /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
- [EditorBrowsable(EditorBrowsableState.Never)]
- public string CheckImageResourceUrl
- {
- get
- {
- return itemDataStyle.CheckImage?.ResourceUrl?.All;
- }
- set
- {
- CreateCheckImageAttributes();
- if (itemDataStyle.CheckImage.ResourceUrl == null)
- {
- itemDataStyle.CheckImage.ResourceUrl = new Selector<string> { All = value };
- }
- else
- {
- itemDataStyle.CheckImage.ResourceUrl.All = value;
- }
- }
- }
-
- /// <summary>
- /// DropDown item's check image's size.
- /// </summary>
- /// <since_tizen> 6 </since_tizen>
- /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
- [EditorBrowsable(EditorBrowsableState.Never)]
- public Size CheckImageSize
- {
- get
- {
- return itemDataStyle.CheckImage?.Size;
- }
- set
- {
- CreateCheckImageAttributes();
- itemDataStyle.CheckImage.Size = value;
- }
- }
-
- /// <summary>
- /// DropDown item's check image's right space.
- /// </summary>
- /// <since_tizen> 6 </since_tizen>
- /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
- [EditorBrowsable(EditorBrowsableState.Never)]
- public int CheckImageGapToBoundary
- {
- get
- {
- return itemDataStyle.CheckImageGapToBoundary;
- }
- set
- {
- itemDataStyle.CheckImageGapToBoundary = value;
- }
- }
-
- /// <summary>
- /// Flag to decide DropDown item is selected or not.
- /// </summary>
- /// <since_tizen> 6 </since_tizen>
- /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
- [EditorBrowsable(EditorBrowsableState.Never)]
- public bool IsSelected
- {
- get
- {
- return itemDataStyle.IsSelected;
- }
- set
- {
- itemDataStyle.IsSelected = value;
- }
- }
-
- private void Initialize()
- {
- if (itemDataStyle == null)
- {
- throw new Exception("Button attribute parse error.");
- }
- }
-
- private void CreateTextAttributes()
- {
- if(itemDataStyle.Text== null)
- {
- itemDataStyle.Text= new TextLabelStyle
- {
- PositionUsesPivotPoint = true,
- ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft,
- PivotPoint = Tizen.NUI.PivotPoint.TopLeft,
- WidthResizePolicy = ResizePolicyType.UseNaturalSize,
- HeightResizePolicy = ResizePolicyType.FillToParent,
- VerticalAlignment = VerticalAlignment.Center,
- HorizontalAlignment = HorizontalAlignment.Begin,
- };
- }
- }
-
- private void CreateIconAttributes()
- {
- if (itemDataStyle.Icon== null)
- {
- itemDataStyle.Icon= new ImageViewStyle
- {
- PositionUsesPivotPoint = true,
- ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft,
- PivotPoint = Tizen.NUI.PivotPoint.TopLeft,
- };
- }
- }
-
- private void CreateCheckImageAttributes()
- {
- if (itemDataStyle.CheckImage== null)
- {
- itemDataStyle.CheckImage= new ImageViewStyle
- {
- PositionUsesPivotPoint = true,
- ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft,
- PivotPoint = Tizen.NUI.PivotPoint.TopLeft,
- };
- }
- }
- }
#endregion
-
- #region DropDownItemView
- /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
- [EditorBrowsable(EditorBrowsableState.Never)]
- internal class DropDownItemView : Control
- {
- private TextLabel mText = null;
- private ImageView mIcon = null;
- private ImageView mCheck = null;
-
- /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
- [EditorBrowsable(EditorBrowsableState.Never)]
- public DropDownItemView() : base()
- {
- }
-
- /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
- [EditorBrowsable(EditorBrowsableState.Never)]
- public Selector<Color> BackgroundColorSelector
- {
- get;
- set;
- }
-
- /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
- [EditorBrowsable(EditorBrowsableState.Never)]
- public string Text
- {
- get
- {
- if(mText == null)
- {
- return null;
- }
- return mText.Text;
- }
- set
- {
- CreateText();
- mText.Text = value;
- }
- }
-
- /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
- [EditorBrowsable(EditorBrowsableState.Never)]
- public string FontFamily
- {
- get
- {
- if (mText == null)
- {
- return null;
- }
- return mText.FontFamily;
- }
- set
- {
- CreateText();
- mText.FontFamily = value;
- }
- }
-
- /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
- [EditorBrowsable(EditorBrowsableState.Never)]
- public float? PointSize
- {
- get
- {
- if (mText == null)
- {
- return 0;
- }
- return mText.PointSize;
- }
- set
- {
- CreateText();
- mText.PointSize = (float)value;
- }
- }
-
- /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
- [EditorBrowsable(EditorBrowsableState.Never)]
- public Color TextColor
- {
- get
- {
- if (mText == null)
- {
- return null;
- }
- return mText.TextColor;
- }
- set
- {
- CreateText();
- mText.TextColor = value;
- }
- }
-
- /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
- [EditorBrowsable(EditorBrowsableState.Never)]
- public Position TextPosition
- {
- get
- {
- if (mText == null)
- {
- return null;
- }
- return mText.Position;
- }
- set
- {
- CreateText();
- mText.Position = value;
- }
- }
-
- /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
- [EditorBrowsable(EditorBrowsableState.Never)]
- public string IconResourceUrl
- {
- get
- {
- if (mIcon == null)
- {
- return null;
- }
- return mIcon.ResourceUrl;
- }
- set
- {
- CreateIcon();
- mIcon.ResourceUrl = value;
- }
- }
-
- /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
- [EditorBrowsable(EditorBrowsableState.Never)]
- public Size IconSize
- {
- get
- {
- if (mIcon == null)
- {
- return null;
- }
- return mIcon.Size;
- }
- set
- {
- CreateIcon();
- mIcon.Size = value;
- }
- }
-
- /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
- [EditorBrowsable(EditorBrowsableState.Never)]
- public Position IconPosition
- {
- get
- {
- if (mIcon == null)
- {
- return null;
- }
- return mIcon.Position;
- }
- set
- {
- CreateIcon();
- mIcon.Position = value;
- }
- }
-
- /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
- [EditorBrowsable(EditorBrowsableState.Never)]
- public string CheckResourceUrl
- {
- get
- {
- if (mCheck == null)
- {
- return null;
- }
- return mCheck.ResourceUrl;
- }
- set
- {
- CreateCheckImage();
- mCheck.ResourceUrl = value;
- }
- }
-
- /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
- [EditorBrowsable(EditorBrowsableState.Never)]
- public Position CheckPosition
- {
- get
- {
- if (mCheck == null)
- {
- return null;
- }
- return mCheck.Position;
- }
- set
- {
- CreateCheckImage();
- mCheck.Position = value;
- }
- }
-
- /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
- [EditorBrowsable(EditorBrowsableState.Never)]
- public Size CheckImageSize
- {
- get
- {
- if (mCheck == null)
- {
- return null;
- }
- return mCheck.Size;
- }
- set
- {
- CreateCheckImage();
- mCheck.Size = value;
- }
- }
-
- /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
- [EditorBrowsable(EditorBrowsableState.Never)]
- public bool IsSelected
- {
- get
- {
- if (mCheck == null)
- {
- return false;
- }
- return mCheck.Visibility;
- }
- set
- {
- CreateCheckImage();
- if(value)
- {
- mCheck.Show();
- }
- else
- {
- mCheck.Hide();
- }
- }
- }
-
- /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
- [EditorBrowsable(EditorBrowsableState.Never)]
- protected override void Dispose(DisposeTypes type)
- {
- if (disposed)
- {
- return;
- }
-
- if (type == DisposeTypes.Explicit)
- {
- if (mText != null)
- {
- Remove(mText);
- mText.Dispose();
- mText = null;
- }
-
- if (mIcon != null)
- {
- Remove(mIcon);
- mIcon.Dispose();
- mIcon = null;
- }
-
- if (mCheck != null)
- {
- Remove(mCheck);
- mCheck.Dispose();
- mCheck = null;
- }
- }
- base.Dispose(type);
- }
-
- /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
- [EditorBrowsable(EditorBrowsableState.Never)]
- protected override ViewStyle GetViewStyle()
- {
- return null;
- }
-
- private void CreateIcon()
- {
- if(mIcon == null)
- {
- mIcon = new ImageView()
- {
- PositionUsesPivotPoint = true,
- ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft,
- PivotPoint = Tizen.NUI.PivotPoint.TopLeft,
- };
- Add(mIcon);
- }
- }
-
- private void CreateText()
- {
- if (mText == null)
- {
- mText = new TextLabel()
- {
- PositionUsesPivotPoint = true,
- ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft,
- PivotPoint = Tizen.NUI.PivotPoint.TopLeft,
- WidthResizePolicy = ResizePolicyType.UseNaturalSize,
- HeightResizePolicy = ResizePolicyType.FillToParent,
- VerticalAlignment = VerticalAlignment.Center,
- HorizontalAlignment = HorizontalAlignment.Begin,
- };
- Add(mText);
- }
- }
-
- private void CreateCheckImage()
- {
- if (mCheck == null)
- {
- mCheck = new ImageView()
- {
- PositionUsesPivotPoint = true,
- ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft,
- PivotPoint = Tizen.NUI.PivotPoint.TopLeft,
- Name = "checkedImage",
- };
- Add(mCheck);
- }
- mCheck.Hide();
- }
- }
- #endregion
-
- #region DropDownListBridge
-
- /// <summary>
- /// DropDownListBridge is bridge to connect item data and an item View.
- /// </summary>
- /// <since_tizen> 6 </since_tizen>
- /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
- [EditorBrowsable(EditorBrowsableState.Never)]
- public class DropDownListBridge
- {
- private List<DropDownDataItem> itemDataList = new List<DropDownDataItem>();
-
- internal bool AdapterPurge {get;set;} = false; // Set to true if adapter content changed since last iteration.
-
- /// <summary>
- /// Creates a new instance of a DropDownListBridge.
- /// </summary>
- /// <since_tizen> 6 </since_tizen>
- /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
- [EditorBrowsable(EditorBrowsableState.Never)]
- public DropDownListBridge()
- {
- }
-
- /// <summary>
- /// Insert data. The inserted data will be added to the special position by index automatically.
- /// </summary>
- /// <param name="position">Position index where will be inserted.</param>
- /// <param name="data">Item data which will apply to tab item view.</param>
- /// <since_tizen> 6 </since_tizen>
- /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
- [EditorBrowsable(EditorBrowsableState.Never)]
- public void InsertData(int position, DropDownDataItem data)
- {
- if(position == -1)
- {
- position = itemDataList.Count;
- }
- itemDataList.Insert(position, data);
- AdapterPurge = true;
- }
-
- /// <summary>
- /// Remove data by position.
- /// </summary>
- /// <param name="position">Position index where will be removed.</param>
- /// <since_tizen> 6 </since_tizen>
- /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
- [EditorBrowsable(EditorBrowsableState.Never)]
- public void RemoveData(int position)
- {
- itemDataList.RemoveAt(position);
- AdapterPurge = true;
- }
-
- /// <summary>
- /// Get data by position.
- /// </summary>
- /// <param name="position">Position index where will be gotten.</param>
- /// <since_tizen> 6 </since_tizen>
- /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
- [EditorBrowsable(EditorBrowsableState.Never)]
- public DropDownDataItem GetData(int position)
- {
- return itemDataList[position];
- }
-
- /// <summary>
- /// Get view holder by view type.
- /// </summary>
- /// <since_tizen> 6 </since_tizen>
- /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
- [EditorBrowsable(EditorBrowsableState.Never)]
- public ViewHolder OnCreateViewHolder()
- {
- ViewHolder viewHolder = new ViewHolder(new DropDownItemView());
-
- return viewHolder;
- }
-
- /// <summary>
- /// Bind ViewHolder with View.
- /// </summary>
- /// <param name="holder">View holder.</param>
- /// <param name="position">Position index of source data.</param>
- /// <since_tizen> 6 </since_tizen>
- /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
- [EditorBrowsable(EditorBrowsableState.Never)]
- public void BindViewHolder(ViewHolder holder, int position)
- {
- DropDownDataItem listItemData = itemDataList[position];
- if(listItemData == null)
- {
- return;
- }
- DropDownItemView listItemView = holder.ItemView as DropDownItemView;
- listItemView.Name = "Item" + position;
- if (listItemData.Size != null)
- {
- if (listItemData.Size.Width > 0)
- {
- holder.ItemView.WidthSpecification = (int)listItemData.Size.Width;
- }
- else
- {
- holder.ItemView.WidthSpecification = LayoutParamPolicies.MatchParent;
- }
-
- if (listItemData.Size.Height > 0)
- {
- holder.ItemView.HeightSpecification = (int)listItemData.Size.Height;
- }
- else
- {
- holder.ItemView.HeightSpecification = LayoutParamPolicies.MatchParent;
- }
- }
-
- if (listItemView != null)
- {
- listItemView.BackgroundColorSelector = listItemData.BackgroundColorSelector;
- if (listItemData.Text != null)
- {
- listItemView.Text = listItemData.Text;
- listItemView.PointSize = listItemData.PointSize;
- listItemView.FontFamily = listItemData.FontFamily;
- listItemView.TextPosition = listItemData.TextPosition;
- }
-
- if (listItemData.IconResourceUrl != null)
- {
- listItemView.IconResourceUrl = listItemData.IconResourceUrl;
- listItemView.IconSize = listItemData.IconSize;
- if (listItemView.IconSize != null)
- {
- listItemView.IconPosition = new Position(listItemData.IconPosition.X, (listItemView.Size2D.Height - listItemView.IconSize.Height) / 2);
- }
- }
-
- if (listItemData.CheckImageResourceUrl != null)
- {
- listItemView.CheckResourceUrl = listItemData.CheckImageResourceUrl;
- listItemView.CheckImageSize = listItemData.CheckImageSize;
- if (listItemView.CheckImageSize != null)
- {
- listItemView.CheckPosition = new Position(listItemView.Size2D.Width - listItemData.CheckImageGapToBoundary - listItemView.CheckImageSize.Width, (listItemView.Size2D.Height - listItemView.CheckImageSize.Height) / 2);
- }
- }
-
- listItemView.IsSelected = listItemData.IsSelected;
- }
- }
-
- /// <summary>
- /// Destroy view holder, it can be override.
- /// </summary>
- /// <param name="holder">View holder.</param>
- /// <since_tizen> 6 </since_tizen>
- /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
- [EditorBrowsable(EditorBrowsableState.Never)]
- public void OnDestroyViewHolder(ViewHolder holder)
- {
- if (holder.ItemView != null)
- {
- holder.ItemView.Dispose();
- }
- }
-
- /// <summary>
- /// Get item count, it can be override.
- /// </summary>
- /// <since_tizen> 6 </since_tizen>
- /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
- [EditorBrowsable(EditorBrowsableState.Never)]
- public int GetItemCount()
- {
- return itemDataList.Count;
- }
- }
- #endregion
-
- #region ViewHolder
-
- /// <summary>
- /// A ViewHolder is a class that holds a View created from DropDownListBridge data.
- /// </summary>
- /// <since_tizen> 6 </since_tizen>
- /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
- [EditorBrowsable(EditorBrowsableState.Never)]
- public class ViewHolder
- {
- /// <summary>
- /// ViewHolder constructor.
- /// </summary>
- /// <param name="itemView">View</param>
- /// <since_tizen> 6 </since_tizen>
- /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
- [EditorBrowsable(EditorBrowsableState.Never)]
- public ViewHolder(View itemView)
- {
- if (itemView == null)
- {
- throw new ArgumentNullException("itemView may not be null");
- }
- this.ItemView = itemView;
- }
-
- /// <summary>
- /// Returns the view.
- /// </summary>
- /// <since_tizen> 6 </since_tizen>
- /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
- [EditorBrowsable(EditorBrowsableState.Never)]
- public View ItemView { get; }
-
- internal bool IsBound
- {
- get;
- set;
- }
-
- }
-
- #endregion
-
}
}