+++ /dev/null
-using System;
-using System.ComponentModel;
-using Tizen.NUI.BaseComponents;
-
-namespace Tizen.NUI.Components
-{
- public partial class DropDown
- {
- /// <summary>
- /// DropDownDataItem 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 DropDownDataItem
- {
- internal 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()
- {
- itemDataStyle = ThemeManager.GetStyle("Tizen.NUI.Components.DropDown.DropDownDataItem") as DropDownItemStyle;
- 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 viewStyle = StyleManager.Instance.GetViewStyle(style);
- if (viewStyle == null)
- {
- throw new InvalidOperationException($"There is no style {style}");
- }
- itemDataStyle = viewStyle 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.
- /// </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 Selector<Color> BackgroundColor
- {
- get
- {
- return itemDataStyle.BackgroundColor;
- }
- set
- {
- if (null != itemDataStyle)
- {
- if (null == itemDataStyle.BackgroundColor)
- {
- itemDataStyle.BackgroundColor = new Selector<Color>();
- }
- itemDataStyle.BackgroundColor.Clone(value);
- }
- }
- }
-
- /// <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 itemDataStyle.Text?.Text?.All;
- }
- set
- {
- if (null == itemDataStyle.Text.Text)
- {
- itemDataStyle.Text.Text = new Selector<string> { All = value };
- }
- else
- {
- itemDataStyle.Text.Text = 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 itemDataStyle.Text?.PointSize?.All ?? 0;
- }
- set
- {
- if (null == itemDataStyle.Text.PointSize)
- {
- itemDataStyle.Text.PointSize = new Selector<float?> { All = value };
- }
- else
- {
- itemDataStyle.Text.PointSize = 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 itemDataStyle.Text.FontFamily?.All;
- }
- set
- {
- if (null == itemDataStyle.Text.FontFamily)
- {
- itemDataStyle.Text.FontFamily = new Selector<string> { All = value };
- }
- else
- {
- 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
- {
- 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
- {
- if (null == itemDataStyle.Icon.ResourceUrl)
- {
- itemDataStyle.Icon.ResourceUrl = new Selector<string> { All = value };
- }
- else
- {
- itemDataStyle.Icon.ResourceUrl = 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
- {
- 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
- {
- 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
- {
- if (null == itemDataStyle.CheckImage.ResourceUrl)
- {
- itemDataStyle.CheckImage.ResourceUrl = new Selector<string> { All = value };
- }
- else
- {
- itemDataStyle.CheckImage.ResourceUrl = 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
- {
- 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("DropDownDataItem style parse error.");
- }
- }
- }
- }
-}
+++ /dev/null
-using System.ComponentModel;
-using Tizen.NUI.BaseComponents;
-
-namespace Tizen.NUI.Components
-{
- public partial class DropDown
- {
- /// 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
- {
- return (null == mText) ? null : 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
- {
- return (null == mText) ? null : 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
- {
- return (null == mText) ? 0 : 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
- {
- return (null == mText) ? null : 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
- {
- return (null == mText) ? null : 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
- {
- return (null == mIcon) ? null : 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
- {
- return (null == mIcon) ? null : 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
- {
- return (null == mIcon) ? null : 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
- {
- return (null == mCheck) ? null : 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
- {
- return (null == mCheck) ? null : 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
- {
- return (null == mCheck) ? null : 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
- {
- return (null == mCheck) ? false : mCheck.Visibility;
- }
- set
- {
- CreateCheckImage();
- if (value)
- {
- ControlState = ControlState.Selected;
- mCheck.Show();
- }
- else
- {
- ControlState = ControlState.Normal;
- 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);
- }
-
- /// <summary>
- /// Get DropDownItemView style.
- /// </summary>
- /// <returns>The empty.</returns>
- /// 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 CreateViewStyle()
- {
- return new DropDownItemStyle();
- }
-
- 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,
- Text = "List item",
- };
- 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();
- }
- }
- }
-}
+++ /dev/null
-using System.Collections.Generic;
-using System.ComponentModel;
-using Tizen.NUI.BaseComponents;
-
-namespace Tizen.NUI.Components
-{
- public partial class DropDown
- {
-
- /// <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)
- {
- if (null == holder) return;
- DropDownDataItem listItemData = itemDataList[position];
- if (listItemData == null)
- {
- return;
- }
- DropDownItemView listItemView = holder.ItemView as DropDownItemView;
- if (listItemView == null)
- {
- return;
- }
- 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.BackgroundColor;
- 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;
-
- if (null != listItemData.CheckImageSize)
- {
- 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 (null == holder) return;
- 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;
- }
- }
- }
-}
+++ /dev/null
-/*
- * Copyright(c) 2019 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-using System;
-using System.Collections.Generic;
-using Tizen.NUI.BaseComponents;
-using System.ComponentModel;
-using Tizen.NUI.Binding;
-using Tizen.NUI.Accessibility;
-
-namespace Tizen.NUI.Components
-{
- /// <summary>
- /// DropDown is one kind of common component, a dropdown allows the user click dropdown button to choose one value from a 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 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.dropDownStyle.ListPadding.CopyFrom((Extents)newValue);
- instance.UpdateDropDown();
- }
- },
- defaultValueCreator: (bindable) =>
- {
- var instance = (DropDown)bindable;
- return instance.dropDownStyle.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.dropDownStyle.SelectedItemIndex || instance.adapter == null || selectedItemIndex < 0 || selectedItemIndex >= instance.adapter.GetItemCount())
- {
- return;
- }
- instance.SetListItemToSelected((uint)selectedItemIndex);
- }
- },
- defaultValueCreator: (bindable) =>
- {
- var instance = (DropDown)bindable;
- return instance.dropDownStyle.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.dropDownStyle.ListMargin.CopyFrom((Extents)newValue);
- instance.UpdateDropDown();
- }
- },
- defaultValueCreator: (bindable) =>
- {
- var instance = (DropDown)bindable;
- return instance.dropDownStyle.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.dropDownStyle.ListRelativeOrientation = (ListOrientation)newValue;
- instance.UpdateDropDown();
- }
- },
- defaultValueCreator: (bindable) =>
- {
- var instance = (DropDown)bindable;
- return instance.dropDownStyle.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.dropDownStyle.SpaceBetweenButtonTextAndIcon = (int)newValue;
- }
- },
- defaultValueCreator: (bindable) =>
- {
- var instance = (DropDown)bindable;
- return instance.dropDownStyle.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 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 DropDownItemView selectedItemView = null;
- private TapGestureDetector tapGestureDetector = null;
-
- private bool itemPressed = false;
-
- static DropDown() { }
-
- /// <summary>
- /// Creates a new instance of a 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 DropDown() : base()
- {
- AccessibilityManager.Instance.SetAccessibilityAttribute(this, AccessibilityManager.AccessibilityAttribute.Trait, "DropDown");
- }
-
- /// <summary>
- /// Creates a new instance of a DropDown with style.
- /// </summary>
- /// <param name="style">Create DropDown 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 DropDown(string style) : base(style)
- {
- AccessibilityManager.Instance.SetAccessibilityAttribute(this, AccessibilityManager.AccessibilityAttribute.Trait, "DropDown");
- }
-
- /// <summary>
- /// Creates a new instance of a DropDown with style.
- /// </summary>
- /// <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 dropDownStyle) : base(dropDownStyle)
- {
- AccessibilityManager.Instance.SetAccessibilityAttribute(this, AccessibilityManager.AccessibilityAttribute.Trait, "DropDown");
- }
-
- /// <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 EventHandler<ItemClickEventArgs> ItemClickEvent;
-
- /// <summary>
- /// 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.
- [EditorBrowsable(EditorBrowsableState.Never)]
- public enum ListOrientation
- {
- /// <summary>
- /// Left.
- /// </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)]
- Left,
- /// <summary>
- /// Right.
- /// </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)]
- Right,
- }
-
- /// <summary>
- /// Get or set header text.
- /// </summary>
- /// 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
- {
- 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;
- }
- internal set
- {
- headerText = value;
- }
- }
-
- /// <summary>
- /// Get or set button.
- /// </summary>
- /// 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
- {
- if (null == button)
- {
- button = new Button()
- {
- ParentOrigin = NUI.ParentOrigin.TopLeft,
- PivotPoint = NUI.PivotPoint.TopLeft,
- PositionUsesPivotPoint = true,
- HeightResizePolicy = ResizePolicyType.FitToChildren,
- IconRelativeOrientation = Button.IconOrientation.Right,
- Name = "DropDownButton"
- };
- button.ClickEvent += ButtonClickEvent;
- Add(button);
-
- if (null == buttonText)
- {
- buttonText = new TextLabel();
- }
- }
- return button;
- }
- internal set
- {
- button = value;
- }
- }
-
- /// <summary>
- /// Get or set the background image of list.
- /// </summary>
- /// 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
- {
- 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;
- }
- internal set
- {
- listBackgroundImage = value;
- }
- }
-
- /// <summary>
- /// 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
- {
- var result = new DropDownStyle(dropDownStyle);
- result.CopyPropertiesFromView(this);
- result.Button.CopyPropertiesFromView(Button);
- result.HeaderText.CopyPropertiesFromView(HeaderText);
- result.ListBackgroundImage.CopyPropertiesFromView(ListBackgroundImage);
- return result;
- }
- }
-
- /// <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 int SpaceBetweenButtonTextAndIcon
- {
- get => (int)GetValue(SpaceBetweenButtonTextAndIconProperty);
- set => SetValue(SpaceBetweenButtonTextAndIconProperty, value);
- }
-
- /// <summary>
- /// 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 ListOrientation ListRelativeOrientation
- {
- get => (ListOrientation)GetValue(ListRelativeOrientationProperty);
- set => SetValue(ListRelativeOrientationProperty, value);
- }
-
- /// <summary>
- /// 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 Extents ListMargin
- {
- get
- {
- 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>
- /// 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 int SelectedItemIndex
- {
- get => (int)GetValue(SelectedItemIndexProperty);
- set => SetValue(SelectedItemIndexProperty, value);
- }
-
- /// <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.
- public Extents ListPadding
- {
- get
- {
- 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);
- }
-
- private DropDownStyle dropDownStyle => ViewStyle as DropDownStyle;
-
- /// <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(DropDownDataItem itemData)
- {
- // Add item to adaptor, will be added to list via AddItemAt during OnUpdate()
- int insertionPosition = adapter.GetItemCount();
- adapter.InsertData(insertionPosition, 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)
- {
- if (index < 0 || index >= adapter?.GetItemCount()) return;
- if (null == dropDownMenuFullList) return;
-
- if (dropDownStyle.SelectedItemIndex == index)
- {
- dropDownStyle.SelectedItemIndex = -1;
- }
- else if (dropDownStyle.SelectedItemIndex > index)
- {
- dropDownStyle.SelectedItemIndex--;
- }
-
- adapter?.RemoveData(index);
-
- if (index < dropDownMenuFullList.ChildCount)
- {
- View childToRemove = dropDownMenuFullList.GetChildAt((uint)index);
- if (childToRemove)
- {
- childToRemove.TouchEvent -= ListItemTouchEvent;
- dropDownMenuFullList.Remove(childToRemove);
- dropDownMenuFullList?.Layout?.RequestLayout();
- }
- }
- }
-
- /// <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(DropDownDataItem item, int index)
- {
- if (index < 0 || index >= adapter.GetItemCount())
- {
- return;
- }
-
- if (dropDownStyle.SelectedItemIndex >= index)
- {
- dropDownStyle.SelectedItemIndex++;
- }
-
- adapter.InsertData(index, item);
- }
-
- /// <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)
- {
- if (scrollableBase == null)
- {
- return;
- }
- Tizen.Log.Error("DropDown", "Feature unsupported");
- }
-
- /// <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 (scrollableBase == null)
- {
- return;
- }
- Tizen.Log.Error("DropDown", "Feature unsupported");
- }
-
- /// 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.ApplyStyle(viewStyle);
-
- 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();
- }
- }
-
- /// <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()
- {
- if (null == scrollableBase || null == listBackgroundImage || null == dropDownMenuFullList) return;
- if (null == 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.
- Size dropDownPaddingSize = new Size((dropDownStyle.ListPadding.Start + dropDownStyle.ListPadding.End), (dropDownStyle.ListPadding.Top + dropDownStyle.ListPadding.Bottom), 0);
- scrollableBase.Size = ListBackgroundImage.Size - dropDownPaddingSize;
- dropDownPaddingSize.Dispose();
- scrollableBase.Position2D = new Position2D(dropDownStyle.ListPadding.Start, dropDownStyle.ListPadding.Top);
-
- int listBackgroundImageX = 0;
- int listBackgroundImageY = 0;
- if (dropDownStyle.ListRelativeOrientation == ListOrientation.Left)
- {
- listBackgroundImageX = (int)dropDownStyle.ListMargin.Start;
- listBackgroundImageY = (int)dropDownStyle.ListMargin.Top;
- }
- else if (dropDownStyle.ListRelativeOrientation == ListOrientation.Right)
- {
- listBackgroundImageX = -(int)dropDownStyle.ListMargin.End;
- listBackgroundImageY = (int)dropDownStyle.ListMargin.Top;
- }
- listBackgroundImage.Position2D = new Position2D(listBackgroundImageX, listBackgroundImageY);
- dropDownMenuFullList?.Layout?.RequestLayout();
- }
-
- /// <summary>
- /// update.
- /// </summary>
- protected override void OnUpdate()
- {
- float buttonTextWidth = 0;
- if (null != buttonText)
- {
- buttonText.Text = Button.TextLabel.Text;
- buttonText.PointSize = Button.TextLabel.PointSize;
- buttonTextWidth = buttonText.NaturalSize.Width;
- }
- float fitWidth = (Button.Icon.Size?.Width ?? 48) + dropDownStyle.SpaceBetweenButtonTextAndIcon + buttonTextWidth;
- fitWidth += (button.IconPadding.Start + button.IconPadding.End);
- button.SizeWidth = Math.Max(button.Size.Width, fitWidth);
- RelayoutRequest();
-
- 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
- if (dropDownStyle.SelectedItemIndex > 0)
- {
- SetListItemToSelected((uint)dropDownStyle.SelectedItemIndex, selectedItemView);
- }
- }
-
- /// <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;
- }
-
- if (type == DisposeTypes.Explicit)
- {
- Utility.Dispose(headerText);
- Utility.Dispose(buttonText);
- Utility.Dispose(button);
- Utility.Dispose(scrollableBase);
- Utility.Dispose(dropDownMenuFullList);
- Utility.Dispose(listBackgroundImage);
- }
-
- base.Dispose(type);
- }
-
- /// <summary>
- /// 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 CreateViewStyle()
- {
- return new DropDownStyle();
- }
-
- private void AddItemAt(DropDownDataItem itemData, int index)
- {
- ViewHolder viewHolder = adapter.OnCreateViewHolder();
- if (!viewHolder.IsBound)
- {
- adapter.BindViewHolder(viewHolder, index);
- viewHolder.IsBound = true;
- }
-
- if (tapGestureDetector == null)
- {
- tapGestureDetector = new TapGestureDetector();
- }
- View view = viewHolder.ItemView;
- view.ApplyStyle(itemData.itemDataStyle);
- view.TouchEvent += ListItemTouchEvent;
- dropDownMenuFullList.Add(view);
- }
-
- private void OnClickEvent(object sender, ItemClickEventArgs e)
- {
- ItemClickEvent?.Invoke(sender, e);
- }
-
- private void CreateButtonText()
- {
- if (null == buttonText)
- {
- buttonText = new TextLabel();
- }
- }
-
- private void CreateButton()
- {
- 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()
- {
- LinearLayout linear = new LinearLayout()
- {
- LinearOrientation = LinearLayout.Orientation.Vertical,
- };
-
- dropDownMenuFullList = new View()
- {
- 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();
- }
-
- private View GetViewFromIndex(uint index)
- {
- if ((index < dropDownMenuFullList.ChildCount) && (index >= 0))
- {
- return dropDownMenuFullList.GetChildAt(index);
- }
- else
- {
- return null;
- }
- }
-
- private void SetListItemToSelected(DropDownItemView view)
- {
- if (dropDownMenuFullList == null || view == null || view == selectedItemView)
- {
- return;
- }
-
- uint newSelectedIndex = 0;
- for (; newSelectedIndex < dropDownMenuFullList.ChildCount; newSelectedIndex++)
- {
- var itemView = dropDownMenuFullList.GetChildAt(newSelectedIndex) as DropDownItemView;
- if (itemView == view)
- {
- SetListItemToSelected(newSelectedIndex, view);
- return;
- }
- }
- }
-
- private void SetListItemToSelected(uint index)
- {
- if (dropDownMenuFullList == null || index == dropDownStyle.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(dropDownStyle.SelectedItemIndex).IsSelected = false;
- }
-
- if (view == null || index >= dropDownMenuFullList.ChildCount)
- {
- dropDownStyle.SelectedItemIndex = -1;
- selectedItemView = null;
- return;
- }
-
- dropDownStyle.SelectedItemIndex = (int)index;
- selectedItemView = view;
- selectedItemView.IsSelected = true;
- adapter.GetData(dropDownStyle.SelectedItemIndex).IsSelected = true;
- dropDownMenuFullList.Layout?.RequestLayout();
- }
-
- private bool ListItemTouchEvent(object sender, TouchEventArgs e)
- {
- PointStateType state = e.Touch.GetState(0);
- DropDownItemView touchedView = sender as DropDownItemView;
- if (touchedView == null)
- {
- return true;
- }
-
- touchedView.OnTouch(e.Touch); // Handle control state change
-
- switch (state)
- {
- 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)
- {
- if (itemPressed) // if Down was previously sent without motion (Scrolling) in-between then a clicked event occurred.
- {
- // List item clicked
- Console.WriteLine("Tapped{0}", touchedView.Name);
- SetListItemToSelected(touchedView);
- button.Text = touchedView.Text;
- button.Show();
- listBackgroundImage.Hide();
- }
- }
- 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>
- /// 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 { 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>
- /// 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)
- {
- ItemView = itemView ?? throw new ArgumentNullException(nameof(itemView), "itemView may not be null");
- }
-
- /// <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
- }
-}
+++ /dev/null
-/*
- * Copyright(c) 2019 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-using System.ComponentModel;
-using Tizen.NUI.BaseComponents;
-using Tizen.NUI.Binding;
-using static Tizen.NUI.Components.DropDown;
-
-namespace Tizen.NUI.Components
-{
- /// <summary>
- /// DropDownStyle is a class which saves DropDown's ux 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 DropDownStyle : ControlStyle
- {
- /// 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(DropDownStyle), 0, propertyChanged: (bindable, oldValue, newValue) =>
- {
- var dropDownStyle = (DropDownStyle)bindable;
- dropDownStyle.spaceBetweenButtonTextAndIcon = (int)newValue;
- },
- defaultValueCreator: (bindable) =>
- {
- var dropDownStyle = (DropDownStyle)bindable;
- return dropDownStyle.spaceBetweenButtonTextAndIcon;
- });
- /// 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(DropDownStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
- {
- var dropDownStyle = (DropDownStyle)bindable;
- dropDownStyle.listRelativeOrientation = (ListOrientation?)newValue;
- },
- defaultValueCreator: (bindable) =>
- {
- var dropDownStyle = (DropDownStyle)bindable;
- return dropDownStyle.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 ListMarginProperty = BindableProperty.Create(nameof(ListMargin), typeof(Extents), typeof(DropDownStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
- {
- ((DropDownStyle)bindable).listMargin = newValue == null ? null : new Extents((Extents)newValue);
- },
- defaultValueCreator: (bindable) =>
- {
- var dropDownStyle = (DropDownStyle)bindable;
- return dropDownStyle.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 SelectedItemIndexProperty = BindableProperty.Create(nameof(SelectedItemIndex), typeof(int), typeof(DropDownStyle), 0, propertyChanged: (bindable, oldValue, newValue) =>
- {
- var dropDownStyle = (DropDownStyle)bindable;
- dropDownStyle.selectedItemIndex = (int)newValue;
- },
- defaultValueCreator: (bindable) =>
- {
- var dropDownStyle = (DropDownStyle)bindable;
- return dropDownStyle.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 ListPaddingProperty = BindableProperty.Create(nameof(ListPadding), typeof(Extents), typeof(DropDownStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
- {
- ((DropDownStyle)bindable).listPadding = newValue == null ? null : new Extents((Extents)newValue);
- },
- defaultValueCreator: (bindable) =>
- {
- var dropDownStyle = (DropDownStyle)bindable;
- return dropDownStyle.listPadding;
- });
-
- private Extents listMargin;
- private Extents listPadding;
- private int spaceBetweenButtonTextAndIcon = 0;
- private ListOrientation? listRelativeOrientation = ListOrientation.Left;
- private int selectedItemIndex = 0;
-
- static DropDownStyle() { }
-
- /// <summary>
- /// Creates a new instance of a DropDownStyle.
- /// </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 DropDownStyle() : base() { }
-
- /// <summary>
- /// Creates a new instance of a DropDownStyle with style.
- /// </summary>
- /// <param name="style">Create DropDownStyle 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 DropDownStyle(DropDownStyle style) : base(style)
- {
- }
-
- /// <summary>
- /// DropDown button's 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 ButtonStyle Button { get; set; } = new ButtonStyle();
-
- /// <summary>
- /// Header text's 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 TextLabelStyle HeaderText { get; set; } = new TextLabelStyle();
-
- /// <summary>
- /// List background image's 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 ImageViewStyle ListBackgroundImage { get; set; } = new ImageViewStyle();
-
- /// <summary>
- /// Space between button text and button icon.
- /// </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 SpaceBetweenButtonTextAndIcon
- {
- get => (int)GetValue(SpaceBetweenButtonTextAndIconProperty);
- set => SetValue(SpaceBetweenButtonTextAndIconProperty, value);
- }
-
- /// <summary>
- /// List relative orientation.
- /// </summary>
- /// <since_tizen> 6 </since_tizen>
- /// 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 ListOrientation? ListRelativeOrientation
- {
- get => (ListOrientation?)GetValue(ListRelativeOrientationProperty);
- set => SetValue(ListRelativeOrientationProperty, value);
- }
-
- /// <summary>
- /// List margin.
- /// </summary>
- /// <since_tizen> 6 </since_tizen>
- /// 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 Extents ListMargin
- {
- get => ((Extents)GetValue(ListMarginProperty)) ?? (listMargin = new Extents(0, 0, 0, 0));
- set => SetValue(ListMarginProperty, value);
- }
-
- /// 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 SelectedItemIndex
- {
- get => (int)GetValue(SelectedItemIndexProperty);
- set => SetValue(SelectedItemIndexProperty, value);
- }
-
- /// <summary>
- /// List padding.
- /// </summary>
- /// <since_tizen> 6 </since_tizen>
- /// 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 Extents ListPadding
- {
- get => ((Extents)GetValue(ListPaddingProperty)) ?? (listPadding = new Extents(0, 0, 0, 0));
- set => SetValue(ListPaddingProperty, value);
- }
-
- /// <inheritdoc/>
- [EditorBrowsable(EditorBrowsableState.Never)]
- public override void CopyFrom(BindableObject bindableObject)
- {
- base.CopyFrom(bindableObject);
-
- if (bindableObject is DropDownStyle dropDownStyle)
- {
- Button.CopyFrom(dropDownStyle.Button);
- HeaderText.CopyFrom(dropDownStyle.HeaderText);
- ListBackgroundImage.CopyFrom(dropDownStyle.ListBackgroundImage);
- }
- }
- }
-
- /// <summary>
- /// DropDownItemStyle is a class which saves DropDownItem's ux 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 DropDownItemStyle : ControlStyle
- {
- /// <summary>
- /// Creates a new instance of a DropDownItemStyle.
- /// </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 DropDownItemStyle() : base() { }
-
- /// <summary>
- /// Creates a new instance of a DropDownItemStyle with style.
- /// </summary>
- /// <param name="style">Create DropDownItemStyle 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 DropDownItemStyle(DropDownItemStyle style) : base(style)
- {
- }
-
- /// <summary>
- /// Text's 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 TextLabelStyle Text { get; set; } = new TextLabelStyle();
-
- /// <summary>
- /// Icon's 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 ImageViewStyle Icon { get; set; } = new ImageViewStyle();
-
- /// <summary>
- /// Check image's 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 ImageViewStyle CheckImage { get; set; } = new ImageViewStyle();
-
- /// <summary>
- /// Gap of Check image to boundary.
- /// </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; set; }
-
- /// <summary>
- /// Flag to decide 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; set; }
-
- /// <inheritdoc/>
- [EditorBrowsable(EditorBrowsableState.Never)]
- public override void CopyFrom(BindableObject bindableObject)
- {
- base.CopyFrom(bindableObject);
-
- if (bindableObject is DropDownItemStyle dropDownItemStyle)
- {
- Text.CopyFrom(dropDownItemStyle.Text);
- Icon.CopyFrom(dropDownItemStyle.Icon);
- CheckImage.CopyFrom(dropDownItemStyle.CheckImage);
- CheckImageGapToBoundary = dropDownItemStyle.CheckImageGapToBoundary;
- IsSelected = dropDownItemStyle.IsSelected;
- }
- }
- }
-}