using System;
using System.ComponentModel;
using Tizen.NUI.BaseComponents;
-using Tizen.NUI.Binding;
-using Tizen.NUI.Components.Extension;
using Tizen.NUI.Accessibility;
namespace Tizen.NUI.Components
/// DefaultGridItem may contain text or an icon.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
- public class DefaultGridItem : RecyclerViewItem
+ public partial class DefaultGridItem : RecyclerViewItem
{
- private TextLabel itemCaption;
+ private TextLabel itemLabel;
private ImageView itemImage;
private View itemBadge;
- private CaptionOrientation captionOrientation;
+ private LabelOrientation labelOrientation;
private bool layoutChanged;
private DefaultGridItemStyle ItemStyle => ViewStyle as DefaultGridItemStyle;
- /// <summary>
- /// Return a copied Style instance of DefaultLinearItem
- /// </summary>
- /// <remarks>
- /// It returns copied Style instance and changing it does not effect to the DefaultLinearItem.
- /// Style setting is possible by using constructor or the function of ApplyStyle(ViewStyle viewStyle)
- /// </remarks>
- [EditorBrowsable(EditorBrowsableState.Never)]
- public new DefaultGridItemStyle Style
- {
- get
- {
- var result = new DefaultGridItemStyle(ItemStyle);
- result.CopyPropertiesFromView(this);
- if (itemCaption) result.Caption.CopyPropertiesFromView(itemCaption);
- if (itemImage) result.Image.CopyPropertiesFromView(itemImage);
- if (itemBadge) result.Badge.CopyPropertiesFromView(itemBadge);
-
- return result;
- }
- }
-
- static DefaultGridItem() {}
+ static DefaultGridItem() { }
/// <summary>
/// Creates a new instance of DefaultGridItem.
[EditorBrowsable(EditorBrowsableState.Never)]
public DefaultGridItem() : base()
{
- Initialize();
}
/// <summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public DefaultGridItem(string style) : base(style)
{
- Initialize();
}
/// <summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public DefaultGridItem(DefaultGridItemStyle itemStyle) : base(itemStyle)
{
- Initialize();
}
/// <summary>
- /// Caption orientation.
+ /// Label orientation.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
- public enum CaptionOrientation
+ public enum LabelOrientation
{
/// <summary>
/// Outside of image bottom edge.
{
get
{
- if ( itemImage == null)
+ if (itemImage == null)
{
itemImage = CreateImage(ItemStyle.Image);
if (itemImage != null)
}
internal set
{
+ if (itemImage != null) Remove(itemImage);
itemImage = value;
+ if (itemImage != null)
+ {
+ //FIXME: User applied image's style can be overwritten!
+ if (ItemStyle != null) itemImage.ApplyStyle(ItemStyle.Image);
+ Add(itemImage);
+ itemImage.Relayout += OnImageRelayout;
+ }
layoutChanged = true;
}
}
{
get
{
+ return GetValue(BadgeProperty) as View;
+ }
+ set
+ {
+ SetValue(BadgeProperty, value);
+ NotifyPropertyChanged();
+ }
+ }
+ private View InternalBadge
+ {
+ get
+ {
return itemBadge;
}
set
{
- if (value == null)
- {
- Remove(itemBadge);
- }
+ if (itemBadge != null) Remove(itemBadge);
itemBadge = value;
if (itemBadge != null)
{
- itemBadge.ApplyStyle(ItemStyle.Badge);
+ //FIXME: User applied badge's style can be overwritten!
+ if (ItemStyle != null) itemBadge.ApplyStyle(ItemStyle.Badge);
Add(itemBadge);
}
layoutChanged = true;
}
}
-/* open when ImageView using Uri not string
- /// <summary>
- /// Image image's resource url in DefaultGridItem.
- /// </summary>
- [EditorBrowsable(EditorBrowsableState.Never)]
- public string ImageUrl
- {
- get
- {
- return Image.ResourceUrl;
- }
- set
- {
- Image.ResourceUrl = value;
- }
- }
-*/
+ /* open when ImageView using Uri not string
+ /// <summary>
+ /// Image image's resource url in DefaultGridItem.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public string ImageUrl
+ {
+ get
+ {
+ return Image.ResourceUrl;
+ }
+ set
+ {
+ Image.ResourceUrl = value;
+ }
+ }
+ */
/// <summary>
/// DefaultGridItem's text part.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
- public TextLabel Caption
+ public TextLabel Label
{
get
{
- if (itemCaption == null)
+ if (itemLabel == null)
{
- itemCaption = CreateLabel(ItemStyle.Caption);
- if (itemCaption != null)
+ itemLabel = CreateLabel(ItemStyle.Label);
+ if (itemLabel != null)
{
- Add(itemCaption);
+ Add(itemLabel);
layoutChanged = true;
}
}
- return itemCaption;
+ return itemLabel;
}
internal set
{
- itemCaption = value;
+ itemLabel = value;
layoutChanged = true;
- AccessibilityManager.Instance.SetAccessibilityAttribute(this, AccessibilityManager.AccessibilityAttribute.Label, itemCaption.Text);
+ AccessibilityManager.Instance.SetAccessibilityAttribute(this, AccessibilityManager.AccessibilityAttribute.Label, itemLabel.Text);
}
}
{
get
{
- return Caption.Text;
+ return GetValue(TextProperty) as string;
+ }
+ set
+ {
+ SetValue(TextProperty, value);
+ NotifyPropertyChanged();
+ }
+ }
+ private string InternalText
+ {
+ get
+ {
+ return Label.Text;
}
set
{
- Caption.Text = value;
+ Label.Text = value;
}
}
/// <summary>
- /// Caption relative orientation with image in DefaultGridItem.
+ /// Label relative orientation with image in DefaultGridItem.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
- public CaptionOrientation CaptionRelativeOrientation
+ public LabelOrientation LabelOrientationType
{
get
{
- return captionOrientation;
+ return (Tizen.NUI.Components.DefaultGridItem.LabelOrientation)GetValue(LabelOrientationTypeProperty);
}
set
{
- captionOrientation = value;
+ SetValue(LabelOrientationTypeProperty, value);
+ NotifyPropertyChanged();
+ }
+ }
+ private Tizen.NUI.Components.DefaultGridItem.LabelOrientation InternalLabelOrientationType
+ {
+ get
+ {
+ return labelOrientation;
+ }
+ set
+ {
+ labelOrientation = value;
layoutChanged = true;
}
}
base.ApplyStyle(viewStyle);
if (viewStyle != null && viewStyle is DefaultGridItemStyle defaultStyle)
{
- if (itemCaption != null)
- itemCaption.ApplyStyle(defaultStyle.Caption);
+ if (itemLabel != null)
+ itemLabel.ApplyStyle(defaultStyle.Label);
if (itemImage != null)
itemImage.ApplyStyle(defaultStyle.Image);
if (itemBadge != null)
return new ImageView(imageStyle);
}
- /// <inheritdoc/>
+ /// <inheritdoc/>
[EditorBrowsable(EditorBrowsableState.Never)]
protected override void MeasureChild()
{
//nothing to do.
- if (itemCaption)
+ if (itemLabel)
{
var pad = Padding;
- var margin = itemCaption.Margin;
- itemCaption.SizeWidth = SizeWidth - pad.Start - pad.End - margin.Start - margin.End;
+ var margin = itemLabel.Margin;
+ itemLabel.SizeWidth = SizeWidth - pad.Start - pad.End - margin.Start - margin.End;
}
}
RelativeLayout.SetRightRelativeOffset(itemImage, 1.0F);
RelativeLayout.SetHorizontalAlignment(itemImage, RelativeLayout.Alignment.Center);
- if (itemCaption != null)
+ if (itemLabel != null)
{
- itemCaption.RaiseAbove(itemImage);
- RelativeLayout.SetLeftTarget(itemCaption, itemImage);
- RelativeLayout.SetLeftRelativeOffset(itemCaption, 0.0F);
- RelativeLayout.SetRightTarget(itemCaption, itemImage);
- RelativeLayout.SetRightRelativeOffset(itemCaption, 1.0F);
- RelativeLayout.SetHorizontalAlignment(itemCaption, RelativeLayout.Alignment.Center);
- RelativeLayout.SetFillHorizontal(itemCaption, true);
+ itemLabel.RaiseAbove(itemImage);
+ RelativeLayout.SetLeftTarget(itemLabel, itemImage);
+ RelativeLayout.SetLeftRelativeOffset(itemLabel, 0.0F);
+ RelativeLayout.SetRightTarget(itemLabel, itemImage);
+ RelativeLayout.SetRightRelativeOffset(itemLabel, 1.0F);
+ RelativeLayout.SetHorizontalAlignment(itemLabel, RelativeLayout.Alignment.Center);
+ RelativeLayout.SetFillHorizontal(itemLabel, true);
}
else
{
RelativeLayout.SetHorizontalAlignment(itemBadge, RelativeLayout.Alignment.End);
}
- switch (captionOrientation)
+ switch (labelOrientation)
{
- case CaptionOrientation.OutsideBottom:
- if (itemCaption != null)
+ case LabelOrientation.OutsideBottom:
+ if (itemLabel != null)
{
- RelativeLayout.SetTopTarget(itemCaption, this);
- RelativeLayout.SetTopRelativeOffset(itemCaption, 1.0F);
- RelativeLayout.SetBottomTarget(itemCaption, this);
- RelativeLayout.SetBottomRelativeOffset(itemCaption, 1.0F);
- RelativeLayout.SetVerticalAlignment(itemCaption, RelativeLayout.Alignment.End);
+ RelativeLayout.SetTopTarget(itemLabel, this);
+ RelativeLayout.SetTopRelativeOffset(itemLabel, 1.0F);
+ RelativeLayout.SetBottomTarget(itemLabel, this);
+ RelativeLayout.SetBottomRelativeOffset(itemLabel, 1.0F);
+ RelativeLayout.SetVerticalAlignment(itemLabel, RelativeLayout.Alignment.End);
RelativeLayout.SetTopTarget(itemImage, this);
RelativeLayout.SetTopRelativeOffset(itemImage, 0.0F);
- RelativeLayout.SetBottomTarget(itemImage, itemCaption);
+ RelativeLayout.SetBottomTarget(itemImage, itemLabel);
RelativeLayout.SetBottomRelativeOffset(itemImage, 0.0F);
RelativeLayout.SetVerticalAlignment(itemImage, RelativeLayout.Alignment.Center);
}
}
break;
- case CaptionOrientation.OutsideTop:
- if (itemCaption != null)
+ case LabelOrientation.OutsideTop:
+ if (itemLabel != null)
{
- RelativeLayout.SetTopTarget(itemCaption, this);
- RelativeLayout.SetTopRelativeOffset(itemCaption, 0.0F);
- RelativeLayout.SetBottomTarget(itemCaption, this);
- RelativeLayout.SetBottomRelativeOffset(itemCaption, 0.0F);
- RelativeLayout.SetVerticalAlignment(itemCaption, RelativeLayout.Alignment.Start);
+ RelativeLayout.SetTopTarget(itemLabel, this);
+ RelativeLayout.SetTopRelativeOffset(itemLabel, 0.0F);
+ RelativeLayout.SetBottomTarget(itemLabel, this);
+ RelativeLayout.SetBottomRelativeOffset(itemLabel, 0.0F);
+ RelativeLayout.SetVerticalAlignment(itemLabel, RelativeLayout.Alignment.Start);
- RelativeLayout.SetTopTarget(itemImage, itemCaption);
+ RelativeLayout.SetTopTarget(itemImage, itemLabel);
RelativeLayout.SetTopRelativeOffset(itemImage, 1.0F);
RelativeLayout.SetBottomTarget(itemImage, this);
RelativeLayout.SetBottomRelativeOffset(itemImage, 1.0F);
}
break;
- case CaptionOrientation.InsideBottom:
- if (itemCaption != null)
+ case LabelOrientation.InsideBottom:
+ if (itemLabel != null)
{
- RelativeLayout.SetTopTarget(itemCaption, this);
- RelativeLayout.SetTopRelativeOffset(itemCaption, 1.0F);
- RelativeLayout.SetBottomTarget(itemCaption, this);
- RelativeLayout.SetBottomRelativeOffset(itemCaption, 1.0F);
- RelativeLayout.SetVerticalAlignment(itemCaption, RelativeLayout.Alignment.End);
+ RelativeLayout.SetTopTarget(itemLabel, this);
+ RelativeLayout.SetTopRelativeOffset(itemLabel, 1.0F);
+ RelativeLayout.SetBottomTarget(itemLabel, this);
+ RelativeLayout.SetBottomRelativeOffset(itemLabel, 1.0F);
+ RelativeLayout.SetVerticalAlignment(itemLabel, RelativeLayout.Alignment.End);
RelativeLayout.SetTopTarget(itemImage, this);
RelativeLayout.SetTopRelativeOffset(itemImage, 0.0F);
}
break;
- case CaptionOrientation.InsideTop:
- if (itemCaption != null)
+ case LabelOrientation.InsideTop:
+ if (itemLabel != null)
{
- RelativeLayout.SetTopTarget(itemCaption, this);
- RelativeLayout.SetTopRelativeOffset(itemCaption, 0.0F);
- RelativeLayout.SetBottomTarget(itemCaption, this);
- RelativeLayout.SetBottomRelativeOffset(itemCaption, 0.0F);
- RelativeLayout.SetVerticalAlignment(itemCaption, RelativeLayout.Alignment.Start);
+ RelativeLayout.SetTopTarget(itemLabel, this);
+ RelativeLayout.SetTopRelativeOffset(itemLabel, 0.0F);
+ RelativeLayout.SetBottomTarget(itemLabel, this);
+ RelativeLayout.SetBottomRelativeOffset(itemLabel, 0.0F);
+ RelativeLayout.SetVerticalAlignment(itemLabel, RelativeLayout.Alignment.Start);
RelativeLayout.SetTopTarget(itemImage, this);
RelativeLayout.SetTopRelativeOffset(itemImage, 0.0F);
}
- /// <inheritdoc/>
+ /// <summary>
+ /// Initializes AT-SPI object.
+ /// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
- private void Initialize()
+ public override void OnInitialize()
{
+ base.OnInitialize();
Layout = new RelativeLayout();
layoutChanged = true;
LayoutDirectionChanged += OnLayoutDirectionChanged;
{
//Extension : Extension?.OnDispose(this);
- if (itemImage != null)
+ // Arugable to disposing user-created members.
+ /*
+ if (itemBadge != null)
{
- Utility.Dispose(itemImage);
+ Utility.Dispose(itemBadge);
}
- if (itemCaption != null)
+ */
+
+ if (itemImage != null)
{
- Utility.Dispose(itemCaption);
+ Utility.Dispose(itemImage);
+ itemImage = null;
}
- if (itemBadge != null)
+ if (itemLabel != null)
{
- Utility.Dispose(itemBadge);
+ Utility.Dispose(itemLabel);
+ itemLabel = null;
}
+
}
base.Dispose(type);