using System.Collections.Generic;
using Tizen.NUI.BaseComponents;
using System.ComponentModel;
+using Tizen.NUI.Binding;
namespace Tizen.NUI.Components
{
/// <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(nameof(ListPadding), typeof(Extents), typeof(DropDown), null, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var instance = (DropDown)bindable;
+ if (newValue != null)
+ {
+ instance.listPadding.CopyFrom((Extents)newValue);
+ instance.UpdateDropDown();
+ }
+ },
+ defaultValueCreator: (bindable) =>
+ {
+ 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 SelectedItemIndexProperty = BindableProperty.Create(nameof(SelectedItemIndex), typeof(int), typeof(DropDown), 0, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var instance = (DropDown)bindable;
+ if (newValue != null)
+ {
+ 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 = (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 ListMarginProperty = BindableProperty.Create(nameof(ListMargin), typeof(Extents), typeof(DropDown), null, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var instance = (DropDown)bindable;
+ if (newValue != null)
+ {
+ instance.listMargin.CopyFrom((Extents)newValue);
+ instance.UpdateDropDown();
+ }
+ },
+ defaultValueCreator: (bindable) =>
+ {
+ 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 ListRelativeOrientationProperty = BindableProperty.Create(nameof(ListRelativeOrientation), typeof(ListOrientation), typeof(DropDown), ListOrientation.Left, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var instance = (DropDown)bindable;
+ if (newValue != null)
+ {
+ instance.listRelativeOrientation = (ListOrientation)newValue;
+ instance.UpdateDropDown();
+ }
+ },
+ defaultValueCreator: (bindable) =>
+ {
+ 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(nameof(SpaceBetweenButtonTextAndIcon), typeof(int), typeof(DropDown), 0, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var instance = (DropDown)bindable;
+ if (newValue != null)
+ {
+ instance.spaceBetweenButtonTextAndIcon = (int)newValue;
+ }
+ },
+ defaultValueCreator: (bindable) =>
+ {
+ 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;
- private FlexibleView list = null;
+ // Component that scrolls the child added to it.
+ 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 DropDownAttributes dropDownAttributes = null;
- private DropDownItemView touchedView = 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 Extents listMargin = null;
- private Extents listPadding = null;
+ 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()
- {
- Initialize();
- }
+ public DropDown() : base() { }
+
/// <summary>
/// Creates a new instance of a DropDown with 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)]
- public DropDown(string style) : base(style)
- {
- Initialize();
- }
+ 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(DropDownAttributes attributes) : base(attributes)
+ public DropDown(DropDownStyle dropDownStyle) : base(dropDownStyle)
{
- Initialize();
}
/// <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 orientation.
+ /// List position in relation to the main 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.
}
/// <summary>
- /// Header text string 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.
+ /// This will be public opened in tizen_next after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
- public string HeaderText
+ public TextLabel HeaderText
{
get
{
- return dropDownAttributes.HeaderTextAttributes?.Text.All;
- }
- set
- {
- if (value != null)
+ if (null == headerText)
{
- CreateHeaderTextAttributes();
- if (dropDownAttributes.HeaderTextAttributes.Text == null)
+ headerText = new TextLabel()
{
- dropDownAttributes.HeaderTextAttributes.Text = new StringSelector();
- }
- dropDownAttributes.HeaderTextAttributes.Text.All = value;
- RelayoutRequest();
+ 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;
+ }
+ internal set
+ {
+ headerText = value;
}
}
/// <summary>
- /// Header text point size 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.
+ /// This will be public opened in tizen_next after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
- public float HeaderTextPointSize
+ public Button Button
{
get
{
- return dropDownAttributes.HeaderTextAttributes?.PointSize?.All ?? 0;
- }
- set
- {
- CreateHeaderTextAttributes();
- if (dropDownAttributes.HeaderTextAttributes.PointSize == null)
+ if (null == button)
{
- dropDownAttributes.HeaderTextAttributes.PointSize = new FloatSelector();
+ 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();
+ }
}
- dropDownAttributes.HeaderTextAttributes.PointSize.All = value;
- RelayoutRequest();
+ return button;
+ }
+ internal set
+ {
+ button = value;
}
}
/// <summary>
- /// Header text font family 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.
+ /// This will be public opened in tizen_next after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
- public string HeaderTextFontFamily
+ public ImageView ListBackgroundImage
{
get
{
- return dropDownAttributes.HeaderTextAttributes?.FontFamily;
+ 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
{
- CreateHeaderTextAttributes();
- dropDownAttributes.HeaderTextAttributes.FontFamily = value;
- RelayoutRequest();
+ listBackgroundImage = value;
}
}
/// <summary>
- /// Header text color in DropDown.
+ /// Return a copied Style instance of 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.
+ /// <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 Color HeaderTextColor
- {
- get
- {
- return dropDownAttributes.HeaderTextAttributes?.TextColor?.All;
- }
- set
- {
- CreateHeaderTextAttributes();
- if (dropDownAttributes.HeaderTextAttributes.TextColor == null)
- {
- dropDownAttributes.HeaderTextAttributes.TextColor = new ColorSelector();
- }
- dropDownAttributes.HeaderTextAttributes.TextColor.All = value;
- RelayoutRequest();
- }
- }
+ //public new DropDownStyle Style
+ //{
+ // get
+ // {
+ // return new DropDownStyle(ViewStyle as DropDownStyle);
+ // }
+ //}
+ public new DropDownStyle Style => ViewStyle as DropDownStyle;
/// <summary>
- /// Header text color selector in DropDown.
+ /// 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.
- [EditorBrowsable(EditorBrowsableState.Never)]
- public ColorSelector HeaderTextColorSelector
+ public int SpaceBetweenButtonTextAndIcon
{
- get
- {
- return dropDownAttributes.HeaderTextAttributes?.TextColor;
- }
- set
- {
- CreateHeaderTextAttributes();
- if (value != null)
- {
- dropDownAttributes.HeaderTextAttributes.TextColor = value.Clone() as ColorSelector;
- RelayoutRequest();
- }
- }
+ get => (int)GetValue(SpaceBetweenButtonTextAndIconProperty);
+ set => SetValue(SpaceBetweenButtonTextAndIconProperty, value);
}
/// <summary>
- /// Button text string in DropDown.
+ /// 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.
- [EditorBrowsable(EditorBrowsableState.Never)]
- public string ButtonText
+ public ListOrientation ListRelativeOrientation
{
- get
- {
- return dropDownAttributes.ButtonAttributes?.TextAttributes?.Text.All;
- }
- set
- {
- if (value != null)
- {
- CreateButtonTextAttributes();
- if (dropDownAttributes.ButtonAttributes.TextAttributes.Text == null)
- {
- dropDownAttributes.ButtonAttributes.TextAttributes.Text = new StringSelector();
- }
- dropDownAttributes.ButtonAttributes.TextAttributes.Text.All = value;
- RelayoutRequest();
- }
- }
+ get => (ListOrientation)GetValue(ListRelativeOrientationProperty);
+ set => SetValue(ListRelativeOrientationProperty, value);
}
/// <summary>
- /// Button text point size in DropDown.
+ /// 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.
- [EditorBrowsable(EditorBrowsableState.Never)]
- public float ButtonTextPointSize
+ public Extents ListMargin
{
get
{
- return dropDownAttributes.ButtonAttributes?.TextAttributes?.PointSize?.All ?? 0;
- }
- set
- {
- CreateButtonTextAttributes();
- if (dropDownAttributes.ButtonAttributes.TextAttributes.PointSize == null)
- {
- dropDownAttributes.ButtonAttributes.TextAttributes.PointSize = new FloatSelector();
- }
- dropDownAttributes.ButtonAttributes.TextAttributes.PointSize.All = value;
- RelayoutRequest();
+ 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>
- /// Button text font family 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.
- [EditorBrowsable(EditorBrowsableState.Never)]
- public string ButtonTextFontFamily
+ public int SelectedItemIndex
{
- get
- {
- return dropDownAttributes.ButtonAttributes?.TextAttributes?.FontFamily;
- }
- set
- {
- CreateButtonTextAttributes();
- dropDownAttributes.ButtonAttributes.TextAttributes.FontFamily = value;
- RelayoutRequest();
- }
+ get => (int)GetValue(SelectedItemIndexProperty);
+ set => SetValue(SelectedItemIndexProperty, value);
}
/// <summary>
- /// Button text color in DropDown.
+ /// List padding 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.
- [EditorBrowsable(EditorBrowsableState.Never)]
- public Color ButtonTextColor
+ public Extents ListPadding
{
get
{
- return dropDownAttributes.ButtonAttributes?.TextAttributes?.TextColor?.All;
- }
- set
- {
- CreateButtonTextAttributes();
- if (dropDownAttributes.ButtonAttributes.TextAttributes.TextColor == null)
- {
- dropDownAttributes.ButtonAttributes.TextAttributes.TextColor = new ColorSelector();
- }
- dropDownAttributes.ButtonAttributes.TextAttributes.TextColor.All = 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>
- /// Button text color selector in DropDown.
+ /// Add list item by item data. The added item will be added to end of all items automatically.
/// </summary>
+ /// <param name="itemData">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 ColorSelector ButtonTextColorSelector
+ public void AddItem(DropDownDataItem itemData)
{
- get
- {
- return dropDownAttributes.ButtonAttributes?.TextAttributes?.TextColor;
- }
- set
- {
- CreateButtonTextAttributes();
- if (value != null)
- {
- dropDownAttributes.ButtonAttributes.TextAttributes.TextColor = value.Clone() as ColorSelector;
- RelayoutRequest();
- }
- }
+ // Add item to adaptor, will be added to list via AddItemAt during OnUpdate()
+ int insertionPosition = adapter.GetItemCount();
+ adapter.InsertData(insertionPosition, itemData);
}
/// <summary>
- /// Button icon image's resource url in DropDown.
+ /// Delete list item by index.
/// </summary>
+ /// <param name="index">Position index where will be deleted.</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 string ButtonIconImageURL
+ public void DeleteItem(int index)
{
- get
+ if (index < 0 || index >= adapter?.GetItemCount()) return;
+ if (null == dropDownMenuFullList) return;
+
+ if (selectedItemIndex == index)
+ {
+ selectedItemIndex = -1;
+ }
+ else if(selectedItemIndex > index)
{
- return dropDownAttributes.ButtonAttributes?.IconAttributes?.ResourceURL.All;
+ selectedItemIndex--;
}
- set
+
+ adapter?.RemoveData(index);
+
+ if(index < dropDownMenuFullList.ChildCount)
{
- if (value != null)
+ View childToRemove = dropDownMenuFullList.GetChildAt((uint)index);
+ if (childToRemove)
{
- CreateButtonIconAttributes();
- if (dropDownAttributes.ButtonAttributes.IconAttributes.ResourceURL == null)
- {
- dropDownAttributes.ButtonAttributes.IconAttributes.ResourceURL = new StringSelector();
- }
- dropDownAttributes.ButtonAttributes.IconAttributes.ResourceURL.All = value;
- RelayoutRequest();
+ childToRemove.TouchEvent -= ListItemTouchEvent;
+ dropDownMenuFullList.Remove(childToRemove);
+ dropDownMenuFullList?.Layout?.RequestLayout();
}
}
}
/// <summary>
- /// Button icon image's size in DropDown.
+ /// Insert list item by item data. The inserted item will be added to the special position by index automatically.
/// </summary>
+ /// <param name="item">Item data which will apply to tab item view.</param>
+ /// <param name="index">Position index where will be inserted.</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 Size ButtonIconSize
+ public void InsertItem(DropDownDataItem item, int index)
{
- get
+ if (index < 0 || index >= adapter.GetItemCount())
{
- return dropDownAttributes.ButtonAttributes?.IconAttributes?.Size;
+ return;
}
- set
+
+ if (selectedItemIndex >= index)
{
- if (value != null)
- {
- CreateButtonIconAttributes();
- dropDownAttributes.ButtonAttributes.IconAttributes.Size = value;
- RelayoutRequest();
- }
+ selectedItemIndex++;
}
+
+ adapter.InsertData(index, item);
}
/// <summary>
- /// Space between button text and button icon in DropDown.
+ /// Add scroll bar to list.
/// </summary>
+ /// <param name="scrollBar">Scroll bar defined by user which will be added to list.</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 int SpaceBetweenButtonTextAndIcon
+ public void AttachScrollBar(ScrollBar scrollBar)
{
- get
- {
- return dropDownAttributes.SpaceBetweenButtonTextAndIcon;
- }
- set
+ if (scrollableBase == null)
{
- dropDownAttributes.SpaceBetweenButtonTextAndIcon = value;
- RelayoutRequest();
+ return;
}
+ Tizen.Log.Error("DropDown","Feature unsupported");
}
/// <summary>
- /// Left space in DropDown.
+ /// Detach scroll bar to 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 int LeftSpace
+ public void DetachScrollBar()
{
- get
- {
- return (int)dropDownAttributes.Space.X;
- }
- set
+ if (scrollableBase == null)
{
- dropDownAttributes.Space.X = value;
- RelayoutRequest();
+ return;
}
+ Tizen.Log.Error("DropDown","Feature unsupported");
}
- /// <summary>
- /// Right space 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.
+ /// 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 int RightSpace
+ public override void ApplyStyle(ViewStyle viewStyle)
{
- get
- {
- return (int)dropDownAttributes.Space.Y;
- }
- set
+ base.ApplyStyle(viewStyle);
+
+ DropDownStyle dropDownStyle = viewStyle as DropDownStyle;
+ if (null != dropDownStyle)
{
- dropDownAttributes.Space.Y = value;
- RelayoutRequest();
+ 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();
}
}
/// <summary>
- /// List background image's resource url in DropDown.
+ /// 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)]
- public string ListBackgroundImageURL
+ protected void UpdateDropDown()
{
- get
+ 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);
+
+ int listBackgroundImageX = 0;
+ int listBackgroundImageY = 0;
+ if (listRelativeOrientation == ListOrientation.Left)
{
- return dropDownAttributes.ListBackgroundImageAttributes?.ResourceURL?.All;
+ listBackgroundImageX = (int)listMargin.Start;
+ listBackgroundImageY = (int)listMargin.Top;
}
- set
+ else if (listRelativeOrientation == ListOrientation.Right)
{
- if (value != null)
- {
- CreateListBackgroundAttributes();
- if (dropDownAttributes.ListBackgroundImageAttributes.ResourceURL == null)
- {
- dropDownAttributes.ListBackgroundImageAttributes.ResourceURL = new StringSelector();
- }
- dropDownAttributes.ListBackgroundImageAttributes.ResourceURL.All = value;
- RelayoutRequest();
- }
+ listBackgroundImageX = -(int)listMargin.End;
+ listBackgroundImageY = (int)listMargin.Top;
}
+ listBackgroundImage.Position2D = new Position2D(listBackgroundImageX, listBackgroundImageY);
+ dropDownMenuFullList?.Layout?.RequestLayout();
}
/// <summary>
- /// List background image's border in DropDown.
+ /// update.
/// </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 Rectangle ListBackgroundImageBorder
+ protected override void OnUpdate()
{
- get
+ float buttonTextWidth = 0;
+ if (null != buttonText)
{
- return dropDownAttributes.ListBackgroundImageAttributes?.Border?.All;
+ buttonText.Text = Style.Button.Text.Text.All;
+ buttonText.PointSize = Style.Button.Text.PointSize?.GetValue(ControlState) ?? StyleManager.PointSizeNormal;
+ buttonTextWidth = buttonText.NaturalSize.Width;
}
- set
+ 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();
+
+ int numberOfItemsToAdd = adapter.GetItemCount();
+
+ if (adapter.AdapterPurge == true)
{
- if (value != null)
+ adapter.AdapterPurge = false;
+ for (int i = 0; i < numberOfItemsToAdd; i++)
{
- CreateListBackgroundAttributes();
- if (dropDownAttributes.ListBackgroundImageAttributes.Border == null)
- {
- dropDownAttributes.ListBackgroundImageAttributes.Border = new RectangleSelector();
- }
- dropDownAttributes.ListBackgroundImageAttributes.Border.All = value;
- RelayoutRequest();
+ AddItemAt(adapter.GetData(i), i);
}
}
+ // Set selection icon on View
+ if (selectedItemIndex > 0)
+ {
+ SetListItemToSelected((uint)selectedItemIndex, selectedItemView);
+ }
}
/// <summary>
- /// List relative orientation in DropDown.
+ /// 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)]
- public ListOrientation ListRelativeOrientation
+ protected override void Dispose(DisposeTypes type)
{
- get
+ if (disposed)
{
- return dropDownAttributes.ListRelativeOrientation;
+ return;
}
- set
+
+ if (type == DisposeTypes.Explicit)
{
- dropDownAttributes.ListRelativeOrientation = value;
- RelayoutRequest();
+ Utility.Dispose(headerText);
+ Utility.Dispose(buttonText);
+ Utility.Dispose(button);
+ Utility.Dispose(scrollableBase);
+ Utility.Dispose(dropDownMenuFullList);
+ Utility.Dispose(listBackgroundImage);
}
+
+ base.Dispose(type);
}
/// <summary>
- /// Space in list.
+ /// 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)]
- public Extents ListMargin
+ protected override ViewStyle CreateViewStyle()
{
- get
+ return new DropDownStyle();
+ }
+
+ private void AddItemAt(DropDownDataItem itemData,int index)
+ {
+ ViewHolder viewHolder = adapter.OnCreateViewHolder();
+ if (!viewHolder.IsBound)
{
- return listMargin;
+ adapter.BindViewHolder(viewHolder, index);
+ viewHolder.IsBound = true;
}
- set
- {
- dropDownAttributes.ListMargin.CopyFrom(value);
-
- if (null == listMargin)
- {
- listMargin = new Extents((ushort start, ushort end, ushort top, ushort bottom) =>
- {
- dropDownAttributes.ListMargin.Start = start;
- dropDownAttributes.ListMargin.End = end;
- dropDownAttributes.ListMargin.Top = top;
- dropDownAttributes.ListMargin.Bottom = bottom;
- RelayoutRequest();
- }, value.Start, value.End, value.Top, value.Bottom);
- }
- else
- {
- listMargin.CopyFrom(value);
- }
- RelayoutRequest();
+ if (tapGestureDetector == null)
+ {
+ tapGestureDetector = new TapGestureDetector();
}
+ View view = viewHolder.ItemView;
+ view.ApplyStyle(itemData.itemDataStyle);
+ view.TouchEvent += ListItemTouchEvent;
+ dropDownMenuFullList.Add(view);
}
- /// <summary>
- /// Focused 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.
- [EditorBrowsable(EditorBrowsableState.Never)]
- public int FocusedItemIndex
+ private void OnClickEvent(object sender, ItemClickEventArgs e)
{
- get
- {
- return dropDownAttributes.FocusedItemIndex;
- }
- set
+ ItemClickEvent?.Invoke(sender, e);
+ }
+
+ private void CreateButtonText()
+ {
+ if (null == buttonText)
{
- dropDownAttributes.FocusedItemIndex = value;
- RelayoutRequest();
+ buttonText = new TextLabel();
}
}
- /// <summary>
- /// 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.
- [EditorBrowsable(EditorBrowsableState.Never)]
- public int SelectedItemIndex
+ private void CreateButton()
{
- get
- {
- return selectedItemIndex;
- }
- set
+ if (null == button)
{
- if (value == selectedItemIndex || adapter == null || value >= adapter.GetItemCount())
+ button = new Button()
{
- return;
- }
- UpdateSelectedItem(value);
+ 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);
}
}
- /// <summary>
- /// List size 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.
- [EditorBrowsable(EditorBrowsableState.Never)]
- public Size ListSize
+ private void SetUpListContainer()
{
- get
+ LinearLayout linear = new LinearLayout()
{
- return dropDownAttributes.ListSize;
- }
- set
+ LinearOrientation = LinearLayout.Orientation.Vertical,
+ };
+
+ dropDownMenuFullList = new View()
{
- dropDownAttributes.ListSize = value;
- RelayoutRequest();
- }
+ Layout = linear,
+ Name = "DropDownMenuList",
+ WidthSpecification = LayoutParamPolicies.MatchParent,
+ HeightSpecification = LayoutParamPolicies.WrapContent,
+ Focusable = true,
+ };
+
+ scrollableBase = new ScrollableBase()
+ {
+ Name = "Scrollable",
+ };
+ scrollableBase.Add(dropDownMenuFullList);
+
+ listBackgroundImage.Add(scrollableBase);
+ listBackgroundImage.Hide();
}
- /// <summary>
- /// List padding 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.
- [EditorBrowsable(EditorBrowsableState.Never)]
- public Extents ListPadding
+ private View GetViewFromIndex(uint index)
{
- get
+ if ((index < dropDownMenuFullList.ChildCount) && (index >=0) )
{
- return listPadding;
+ return dropDownMenuFullList.GetChildAt(index);
}
- set
+ else
{
- dropDownAttributes.ListPadding.CopyFrom(value);
-
- if (null == listPadding)
- {
- listPadding = new Extents((ushort start, ushort end, ushort top, ushort bottom) =>
- {
- dropDownAttributes.ListPadding.Start = start;
- dropDownAttributes.ListPadding.End = end;
- dropDownAttributes.ListPadding.Top = top;
- dropDownAttributes.ListPadding.Bottom = bottom;
- RelayoutRequest();
- }, value.Start, value.End, value.Top, value.Bottom);
- }
- else
- {
- listMargin.CopyFrom(value);
- }
-
- RelayoutRequest();
+ return null;
}
}
- /// <summary>
- /// Add list item by item data. The added item will be added to end of all items automatically.
- /// </summary>
- /// <param name="itemData">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 AddItem(DropDownItemData itemData)
- {
- adapter.InsertData(-1, itemData);
- }
-
- /// <summary>
- /// Delete list item by index.
- /// </summary>
- /// <param name="index">Position index where will be deleted.</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 DeleteItem(int index)
+ private void SetListItemToSelected(DropDownItemView view)
{
- if(index < 0 || index >= adapter.GetItemCount())
+ if (dropDownMenuFullList == null || view == null || view == selectedItemView)
{
return;
}
- if (selectedItemIndex == index)
- {
- selectedItemIndex = -1;
- }
- else if(selectedItemIndex > index)
+ uint newSelectedIndex = 0;
+ for (; newSelectedIndex < dropDownMenuFullList.ChildCount; newSelectedIndex++)
{
- selectedItemIndex--;
+ var itemView = dropDownMenuFullList.GetChildAt(newSelectedIndex) as DropDownItemView;
+ if (itemView == view)
+ {
+ SetListItemToSelected(newSelectedIndex, view);
+ return;
+ }
}
-
- adapter.RemoveData(index);
}
- /// <summary>
- /// Insert list item by item data. The inserted item will be added to the special position by index automatically.
- /// </summary>
- /// <param name="item">Item data which will apply to tab item view.</param>
- /// <param name="index">Position index where will be inserted.</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 InsertItem(DropDownItemData item, int index)
+ private void SetListItemToSelected(uint index)
{
- if (index < 0 || index >= adapter.GetItemCount())
+ if (dropDownMenuFullList == null || index == selectedItemIndex)
{
return;
}
- if (selectedItemIndex >= index)
- {
- selectedItemIndex++;
- }
-
- adapter.InsertData(index, item);
+ SetListItemToSelected(index, GetViewFromIndex(index) as DropDownItemView);
}
- /// <summary>
- /// Add scroll bar to list.
- /// </summary>
- /// <param name="scrollBar">Scroll bar defined by user which will be added to list.</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 AttachScrollBar(ScrollBar scrollBar)
+ private void SetListItemToSelected(uint index, DropDownItemView view)
{
- if (list == null)
+ if (adapter == null)
{
return;
}
- list.AttachScrollBar(scrollBar);
- }
- /// <summary>
- /// Detach scroll bar to 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 void DetachScrollBar()
- {
- if (list == null)
+ if (selectedItemView != null)
{
- return;
+ selectedItemView.IsSelected = false;
+ adapter.GetData(selectedItemIndex).IsSelected = false;
}
- list.DetachScrollBar();
- }
- /// <summary>
- /// Update DropDown by attributes.
- /// </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 override void OnUpdate()
- {
- if (dropDownAttributes.HeaderTextAttributes != null)
+ if (view == null || index >= dropDownMenuFullList.ChildCount)
{
- if (headerText == null)
- {
- CreateHeaderText();
- }
- ApplyAttributes(headerText, dropDownAttributes.HeaderTextAttributes);
+ selectedItemIndex = -1;
+ selectedItemView = null;
+ return;
}
+ selectedItemIndex = (int)index;
+ selectedItemView = view;
+ selectedItemView.IsSelected = true;
+ adapter.GetData(selectedItemIndex).IsSelected = true;
+ dropDownMenuFullList.Layout?.RequestLayout();
+ }
- if (dropDownAttributes.ButtonAttributes != null)
- {
- if (button == null)
- {
- CreateButton();
- }
- if (dropDownAttributes.Space != null)
- {
- button.Position2D.X = (int)dropDownAttributes.Space.X;
- }
+ private bool ListItemTouchEvent(object sender, TouchEventArgs e)
+ {
+ PointStateType state = e.Touch.GetState(0);
+ DropDownItemView touchedView = sender as DropDownItemView;
- if (dropDownAttributes.ButtonAttributes.TextAttributes != null)
- {
- ApplyAttributes(buttonText, dropDownAttributes.ButtonAttributes.TextAttributes);
- button.TextSelector = dropDownAttributes.ButtonAttributes.TextAttributes.Text;
- if (dropDownAttributes.ButtonAttributes.TextAttributes.PointSize != null)
- {
- button.PointSize = dropDownAttributes.ButtonAttributes.TextAttributes.PointSize.All.Value;
- }
- button.FontFamily = dropDownAttributes.ButtonAttributes.TextAttributes.FontFamily;
- button.TextColorSelector = dropDownAttributes.ButtonAttributes.TextAttributes.TextColor;
- }
- if (dropDownAttributes.ButtonAttributes.IconAttributes != null)
- {
- button.IconURLSelector = dropDownAttributes.ButtonAttributes.IconAttributes.ResourceURL;
- int iconWidth = 0;
- int buttonTextWidth = 0;
- if (dropDownAttributes.ButtonAttributes.IconAttributes.Size != null)
- {
- iconWidth = (int)dropDownAttributes.ButtonAttributes.IconAttributes.Size.Width;
- }
- if (buttonText.NaturalSize2D != null)
- {
- buttonTextWidth = buttonText.NaturalSize2D.Width;
- }
- button.SizeWidth = iconWidth + dropDownAttributes.SpaceBetweenButtonTextAndIcon + buttonTextWidth;
- }
- }
+ touchedView.OnTouch(e.Touch); // Handle control state change
- if (dropDownAttributes.ListBackgroundImageAttributes != null)
+ switch (state)
{
- if (listBackgroundImage == null)
- {
- CreateListBackgroundImage();
- CreateList();
- }
- ApplyAttributes(listBackgroundImage, dropDownAttributes.ListBackgroundImageAttributes);
- list.FocusedItemIndex = dropDownAttributes.FocusedItemIndex;
- list.Size = dropDownAttributes.ListSize;
- list.Padding = dropDownAttributes.ListPadding;
-
- int listBackgroundImageX = 0;
- int listBackgroundImageY = 0;
- if (dropDownAttributes.ListRelativeOrientation == ListOrientation.Left)
- {
- if (dropDownAttributes.ListMargin != null)
- {
- listBackgroundImageX = (int)dropDownAttributes.ListMargin.Start;
- listBackgroundImageY = (int)dropDownAttributes.ListMargin.Top;
- }
- }
- else if (dropDownAttributes.ListRelativeOrientation == ListOrientation.Right)
- {
- if (dropDownAttributes.ListMargin != null)
+ case PointStateType.Down:
+ itemPressed = true; // if matched with a Up then a click event.
+ break;
+ case PointStateType.Motion:
+ itemPressed = false;
+ break;
+ case PointStateType.Up:
+ if (touchedView != null)
{
- int listWidth = 0;
- if (list.Size2D != null)
+ if (itemPressed) // if Down was previously sent without motion (Scrolling) in-between then a clicked event occurred.
{
- listWidth = list.Size2D.Width;
+ // List item clicked
+ Console.WriteLine("Tapped{0}", touchedView.Name);
+ SetListItemToSelected(touchedView);
+ button.Text = touchedView.Text;
+ button.Show();
+ listBackgroundImage.Hide();
}
- listBackgroundImageX = Size2D.Width - listWidth - (int)dropDownAttributes.ListMargin.End;
- listBackgroundImageY = (int)dropDownAttributes.ListMargin.Top;
}
- }
- listBackgroundImage.Position2D = new Position2D(listBackgroundImageX, listBackgroundImageY);
+ break;
+ default:
+ break;
}
+ return true;
+ }
+
+ private void ButtonClickEvent(object sender, Button.ClickEventArgs e)
+ {
+ button.Hide();
+ listBackgroundImage.Show();
+ dropDownMenuFullList?.Layout?.RequestLayout();
+ listBackgroundImage.RaiseToTop();
}
+ #endregion
+
+ #region ItemClickEventArgs
/// <summary>
- /// Dispose DropDown and all children on it.
+ /// ItemClickEventArgs is a class to record item click event arguments which will sent to user.
/// </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)
+ public class ItemClickEventArgs : EventArgs
{
- if (disposed)
- {
- return;
- }
-
- if (type == DisposeTypes.Explicit)
- {
- if (headerText != null)
- {
- Utility.Dispose(headerText);
- }
-
- if (buttonText != null)
- {
- Utility.Dispose(buttonText);
- }
-
- if (button != null)
- {
- Utility.Dispose(button);
- }
-
- if (list != null)
- {
- if (listBackgroundImage != null)
- {
- Utility.Dispose(listBackgroundImage);
- }
-
- Utility.Dispose(list);
- }
- }
-
- base.Dispose(type);
+ /// <summary> Clicked item index 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 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 { get; set; }
}
+ #endregion
+
+ #region ViewHolder
/// <summary>
- /// Get DropDown attribues.
+ /// 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)]
- protected override Attributes GetAttributes()
- {
- return new DropDownAttributes();
- }
-
- private void Initialize()
+ public class ViewHolder
{
- dropDownAttributes = attributes as DropDownAttributes;
- if (dropDownAttributes == null)
+ /// <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)
{
- throw new Exception("DropDown attribute parse error.");
+ ItemView = itemView ?? throw new ArgumentNullException(nameof(itemView), "itemView may not be null");
}
- ApplyAttributes(this, dropDownAttributes);
- }
-
- private void OnClickEvent(object sender, ItemClickEventArgs e)
- {
- ItemClickEvent?.Invoke(sender, e);
- }
-
- private void CreateHeaderText()
- {
- headerText = new TextLabel();
- headerText.Name = "DropDownHeaderText";
- Add(headerText);
- }
-
- private void CreateButton()
- {
- button = new Button()
- {
- PositionUsesPivotPoint = true,
- ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft,
- PivotPoint = Tizen.NUI.PivotPoint.TopLeft,
- HeightResizePolicy = ResizePolicyType.FillToParent,
- IconRelativeOrientation = Button.IconOrientation.Right,
- };
- button.Name = "DropDownButton";
- button.ClickEvent += ButtonClickEvent;
- Add(button);
-
- buttonText = new TextLabel()
- {
- 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();
- }
-
- private void CreateList()
- {
- list = new FlexibleView();
- list.Name = "DropDownList";
- LinearLayoutManager layoutManager = new LinearLayoutManager(LinearLayoutManager.VERTICAL);
- list.SetLayoutManager(layoutManager);
- list.SetAdapter(adapter);
- list.Focusable = true;
- list.ItemTouchEvent += ListItemTouchEvent;
- list.ItemClickEvent += ListItemClickEvent;
- listBackgroundImage.Add(list);
- listBackgroundImage.Hide();
- }
-
- private void ListItemClickEvent(object sender, FlexibleView.ItemClickEventArgs e)
- {
- if (e.ClickedView != null)
- {
- UpdateSelectedItem(e.ClickedView.AdapterPosition);
- ItemClickEventArgs args = new ItemClickEventArgs();
- args.Index = e.ClickedView.AdapterPosition;
- args.Text = (e.ClickedView.ItemView as DropDownItemView)?.Text;
- OnClickEvent(this, args);
- }
+ /// <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; }
- listBackgroundImage.Hide();
+ internal bool IsBound { get; set; }
}
- private void ListItemTouchEvent(object sender, FlexibleView.ItemTouchEventArgs e)
- {
- PointStateType state = e.Touch.GetState(0);
- switch (state)
- {
- case PointStateType.Down:
- if (e.TouchedView != null)
- {
- touchedView = e.TouchedView.ItemView as DropDownItemView;
- if (touchedView != null && touchedView.BackgroundColorSelector != null)
- {
- touchedView.BackgroundColor = touchedView.BackgroundColorSelector.GetValue(ControlStates.Pressed);
- }
- }
- break;
- case PointStateType.Motion:
- if (touchedView != null && touchedView.BackgroundColorSelector != null)
- {
- touchedView.BackgroundColor = touchedView.BackgroundColorSelector.GetValue(ControlStates.Normal);
- }
- break;
- case PointStateType.Up:
- if (touchedView != null && touchedView.BackgroundColorSelector != null)
- {
- touchedView.BackgroundColor = touchedView.BackgroundColorSelector.GetValue(ControlStates.Selected);
- }
- break;
- default:
- break;
- }
- }
-
- private void UpdateSelectedItem(int index)
- {
- if (selectedItemIndex != -1)
- {
- DropDownItemData data = adapter.GetData(selectedItemIndex);
- if(data != null)
- {
- data.IsSelected = false;
- }
- DropDownItemView view = list?.FindViewHolderForAdapterPosition(selectedItemIndex)?.ItemView as DropDownItemView;
- if (view != null)
- {
- view.IsSelected = false;
- }
- }
-
- if (index != -1)
- {
- DropDownItemData data = adapter.GetData(index);
- if (data != null)
- {
- data.IsSelected = true;
- }
- DropDownItemView view = list?.FindViewHolderForAdapterPosition(index)?.ItemView as DropDownItemView;
- if (view != null)
- {
- view.IsSelected = true;
- button.Text = view.Text;
- }
- }
-
- selectedItemIndex = index;
- }
-
- private void CreateListBackgroundImage()
- {
- 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)
- {
- listBackgroundImage.Show();
- }
-
- private void CreateHeaderTextAttributes()
- {
- if (dropDownAttributes.HeaderTextAttributes == null)
- {
- dropDownAttributes.HeaderTextAttributes = new TextAttributes()
- {
- 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 (dropDownAttributes.ButtonAttributes == null)
- {
- dropDownAttributes.ButtonAttributes = new ButtonAttributes();
- }
- }
-
- private void CreateButtonTextAttributes()
- {
- CreateButtonAttributes();
-
- if (dropDownAttributes.ButtonAttributes.TextAttributes == null)
- {
- dropDownAttributes.ButtonAttributes.TextAttributes = new TextAttributes
- {
- 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 (dropDownAttributes.ButtonAttributes.IconAttributes == null)
- {
- dropDownAttributes.ButtonAttributes.IconAttributes = new ImageAttributes
- {
- PositionUsesPivotPoint = true,
- ParentOrigin = Tizen.NUI.ParentOrigin.CenterRight,
- PivotPoint = Tizen.NUI.PivotPoint.CenterRight,
- };
- }
- }
-
- private void CreateListBackgroundAttributes()
- {
- if (dropDownAttributes.ListBackgroundImageAttributes == null)
- {
- dropDownAttributes.ListBackgroundImageAttributes = new ImageAttributes
- {
- PositionUsesPivotPoint = true,
- ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft,
- PivotPoint = Tizen.NUI.PivotPoint.TopLeft,
- };
- }
- }
- #endregion
-
- #region ItemClickEventArgs
- /// <summary>
- /// ItemClickEventArgs is a class to record item click event arguments which will sent to user.
- /// </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 ItemClickEventArgs : EventArgs
- {
- /// <summary> Clicked item index 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 int Index;
- /// <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;
- }
- #endregion
-
- #region DropDownItemData
- /// <summary>
- /// DropDownItemData is a class to record all data which will be applied to DropDown item.
- /// </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 DropDownItemData
- {
- private DropDownItemAttributes itemDataAttributes = new DropDownItemAttributes();
-
- /// <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 DropDownItemData()
- {
- Initalize();
- }
-
- /// <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 DropDownItemData(string style)
- {
- if(style != null)
- {
- Attributes attributes = StyleManager.Instance.GetAttributes(style);
- if(attributes == null)
- {
- throw new InvalidOperationException($"There is no style {style}");
- }
- itemDataAttributes = attributes as DropDownItemAttributes;
- }
- Initalize();
- }
-
- /// <summary>
- /// Creates a new instance of a DropDownItemData with attributes.
- /// </summary>
- /// <param name="attributes">Create DropDownItemData by attributes 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 DropDownItemData(DropDownItemAttributes attributes)
- {
- itemDataAttributes = attributes.Clone() as DropDownItemAttributes;
- Initalize();
- }
-
- /// <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 itemDataAttributes.Size;
- }
- set
- {
- itemDataAttributes.Size = value;
- }
- }
-
- /// <summary>
- /// DropDown item background color selector.
- /// </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 ColorSelector BackgroundColorSelector
- {
- get
- {
- return itemDataAttributes.BackgroundColor;
- }
- set
- {
- if (itemDataAttributes.BackgroundColor == null)
- {
- itemDataAttributes.BackgroundColor = value.Clone() as ColorSelector;
- }
- else
- {
- itemDataAttributes.BackgroundColor = value.Clone();
- }
-
- }
- }
-
- /// <summary>
- /// DropDown item text string.
- /// </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 itemDataAttributes.TextAttributes?.Text?.All;
- }
- set
- {
- CreateTextAttributes();
- if (itemDataAttributes.TextAttributes.Text == null)
- {
- itemDataAttributes.TextAttributes.Text = new StringSelector { All = value };
- }
- else
- {
- itemDataAttributes.TextAttributes.Text.All = value;
- }
- }
- }
-
- /// <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 itemDataAttributes.TextAttributes?.PointSize?.All ?? 0;
- }
- set
- {
- CreateTextAttributes();
- if (itemDataAttributes.TextAttributes.PointSize == null)
- {
- itemDataAttributes.TextAttributes.PointSize = new FloatSelector { All = value };
- }
- else
- {
- itemDataAttributes.TextAttributes.PointSize.All = value;
- }
- }
- }
-
- /// <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 itemDataAttributes.TextAttributes?.FontFamily;
- }
- set
- {
- CreateTextAttributes();
- itemDataAttributes.TextAttributes.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 itemDataAttributes.TextAttributes?.Position;
- }
- set
- {
- CreateTextAttributes();
- itemDataAttributes.TextAttributes.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 itemDataAttributes.IconAttributes?.ResourceURL?.All;
- }
- set
- {
- CreateIconAttributes();
- if (itemDataAttributes.IconAttributes.ResourceURL == null)
- {
- itemDataAttributes.IconAttributes.ResourceURL = new StringSelector { All = value };
- }
- else
- {
- itemDataAttributes.IconAttributes.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 itemDataAttributes.IconAttributes?.Size;
- }
- set
- {
- CreateIconAttributes();
- itemDataAttributes.IconAttributes.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 itemDataAttributes.IconAttributes.Position;
- }
- set
- {
- CreateIconAttributes();
- itemDataAttributes.IconAttributes.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 itemDataAttributes.CheckImageAttributes?.ResourceURL?.All;
- }
- set
- {
- CreateCheckImageAttributes();
- if (itemDataAttributes.CheckImageAttributes.ResourceURL == null)
- {
- itemDataAttributes.CheckImageAttributes.ResourceURL = new StringSelector { All = value };
- }
- else
- {
- itemDataAttributes.CheckImageAttributes.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 itemDataAttributes.CheckImageAttributes?.Size;
- }
- set
- {
- CreateCheckImageAttributes();
- itemDataAttributes.CheckImageAttributes.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 CheckImageRightSpace
- {
- get
- {
- return itemDataAttributes.CheckImageGapToBoundary;
- }
- set
- {
- itemDataAttributes.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 itemDataAttributes.IsSelected;
- }
- set
- {
- itemDataAttributes.IsSelected = value;
- }
- }
-
- private void Initalize()
- {
- if (itemDataAttributes == null)
- {
- throw new Exception("Button attribute parse error.");
- }
- }
-
- private void CreateTextAttributes()
- {
- if(itemDataAttributes.TextAttributes == null)
- {
- itemDataAttributes.TextAttributes = new TextAttributes
- {
- 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 (itemDataAttributes.IconAttributes == null)
- {
- itemDataAttributes.IconAttributes = new ImageAttributes
- {
- PositionUsesPivotPoint = true,
- ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft,
- PivotPoint = Tizen.NUI.PivotPoint.TopLeft,
- };
- }
- }
-
- private void CreateCheckImageAttributes()
- {
- if (itemDataAttributes.CheckImageAttributes == null)
- {
- itemDataAttributes.CheckImageAttributes = new ImageAttributes
- {
- 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 ColorSelector 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 = 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 Attributes GetAttributes()
- {
- 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,
- };
- Add(mCheck);
- }
- mCheck.Hide();
- }
- }
- #endregion
-
- #region DropDownListBridge
-
- /// <summary>
- /// DropDownListBridge is bridge to contact item data and 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 : FlexibleView.Adapter
- {
- private List<DropDownItemData> mDatas = new List<DropDownItemData>();
-
- /// <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, DropDownItemData data)
- {
- if(position == -1)
- {
- position = mDatas.Count;
- }
- mDatas.Insert(position, data);
- NotifyItemInserted(position);
- }
-
- /// <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)
- {
- mDatas.RemoveAt(position);
- NotifyItemRemoved(position);
- }
-
- /// <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 DropDownItemData GetData(int position)
- {
- return mDatas[position];
- }
-
- /// <summary>
- /// Get view holder by view type.
- /// </summary>
- /// <param name="viewType">Create 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 override FlexibleView.ViewHolder OnCreateViewHolder(int viewType)
- {
- FlexibleView.ViewHolder viewHolder = new FlexibleView.ViewHolder(new DropDownItemView());
-
- return viewHolder;
- }
-
- /// <summary>
- /// Binder view holder, it can be override.
- /// </summary>
- /// <param name="holder">View holder.</param>
- /// <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 override void OnBindViewHolder(FlexibleView.ViewHolder holder, int position)
- {
- DropDownItemData listItemData = mDatas[position];
- if(listItemData == null)
- {
- return;
- }
- DropDownItemView listItemView = holder.ItemView as DropDownItemView;
- listItemView.Name = "Item" + position;
- if (listItemData.Size != null)
- {
- holder.ItemView.Size = listItemData.Size;
- }
-
- 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.CheckImageRightSpace - 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 override void OnDestroyViewHolder(FlexibleView.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 override int GetItemCount()
- {
- return mDatas.Count;
- }
- }
#endregion
}
}