* [NUI] Theme change do not overwrite user set properties.
* Note that this works only for the bindable properties.
Signed-off-by: Jiyun Yang <ji.yang@samsung.com>
* [NUI] Components share style instance in a theme
Hence a component should not modify connected style instance.
{
base.OnInitialize();
SetAccessibilityConstructor(Role.PushButton);
+
+ AccessibilityHighlightable = true;
+ EnableControlStatePropagation = true;
+ LayoutDirectionChanged += OnLayoutDirectionChanged;
+
+ AccessibilityManager.Instance.SetAccessibilityAttribute(this, AccessibilityManager.AccessibilityAttribute.Trait, "Button");
+
+#if PROFILE_MOBILE
+ Feedback = true;
+#endif
}
/// <inheritdoc/>
}
}
- /// <summary>
- /// It is hijack by using protected, style copy problem when class inherited from Button.
- /// </summary>
- /// <since_tizen> 6 </since_tizen>
- private void Initialize()
- {
- AccessibilityHighlightable = true;
- EnableControlStatePropagation = true;
- UpdateState();
- LayoutDirectionChanged += OnLayoutDirectionChanged;
-
- AccessibilityManager.Instance.SetAccessibilityAttribute(this, AccessibilityManager.AccessibilityAttribute.Trait, "Button");
-
-#if PROFILE_MOBILE
- Feedback = true;
-#endif
- }
-
private void UpdateUIContent()
{
MeasureText();
/*
- * Copyright(c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright(c) 2021 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.
if (instance.isEnabled != newEnabled)
{
instance.isEnabled = newEnabled;
-
- if (instance.buttonStyle != null)
- {
- instance.buttonStyle.IsEnabled = newEnabled;
- }
-
instance.UpdateState();
}
}
{
instance.isSelected = newSelected;
- if (instance.buttonStyle != null)
- {
- instance.buttonStyle.IsSelected = newSelected;
- }
-
if (instance.isSelectable)
{
instance.UpdateState();
if (instance.isSelectable != newSelectable)
{
instance.isSelectable = newSelectable;
-
- if (instance.buttonStyle != null)
- {
- instance.buttonStyle.IsSelectable = newSelectable;
- }
-
instance.UpdateState();
}
}
/// <since_tizen> 6 </since_tizen>
public Button() : base()
{
- Initialize();
}
/// <summary>
/// <since_tizen> 8 </since_tizen>
public Button(string style) : base(style)
{
- Initialize();
}
/// <summary>
/// <since_tizen> 8 </since_tizen>
public Button(ButtonStyle buttonStyle) : base(buttonStyle)
{
- Initialize();
}
/// <summary>
}
/// <summary>
- /// Return a copied Style instance of Button
+ /// Return currently applied style.
/// </summary>
/// <remarks>
- /// It returns copied Style instance and changing it does not effect to the Button.
- /// Style setting is possible by using constructor or the function of ApplyStyle(ViewStyle viewStyle)
+ /// Modifying contents in style may cause unexpected behaviour.
/// </remarks>
/// <since_tizen> 8 </since_tizen>
- public new ButtonStyle Style
- {
- get
- {
- var result = (ButtonStyle)ViewStyle.Clone();
- result.CopyPropertiesFromView(this);
- result.Text.CopyPropertiesFromView(TextLabel);
- result.Icon.CopyPropertiesFromView(Icon);
- result.Overlay.CopyPropertiesFromView(OverlayImage);
- return result;
- }
- }
+ public ButtonStyle Style => (ButtonStyle)(ViewStyle as ButtonStyle)?.Clone();
/// <summary>
/// The text of Button.
set => SetValue(TextPaddingProperty, value);
}
- private ButtonStyle buttonStyle => ViewStyle as ButtonStyle;
-
/// <summary>
/// Called after a key event is received by the view that has had its focus set.
/// </summary>
base.ApplyStyle(viewStyle);
- if (null != buttonStyle)
+ if (viewStyle is ButtonStyle buttonStyle)
{
Extension = buttonStyle.CreateExtension();
if (buttonStyle.Overlay != null)
}
styleApplied = true;
+ UpdateState();
}
/// <summary>
/*
- * Copyright(c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright(c) 2021 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.
public override void OnInitialize()
{
base.OnInitialize();
+
SetAccessibilityConstructor(Role.CheckBox);
}
/// <inheritdoc/>
[EditorBrowsable(EditorBrowsableState.Never)]
- public override void ApplyStyle(ViewStyle viewStyle)
- {
- if (viewStyle is ButtonStyle buttonStyle)
- {
- if (buttonStyle.IsSelectable == null)
- {
- buttonStyle.IsSelectable = true;
- }
-
- base.ApplyStyle(buttonStyle);
- }
- }
-
- /// <inheritdoc/>
- [EditorBrowsable(EditorBrowsableState.Never)]
protected override ImageView CreateIcon()
{
return new ImageView
private Feedback feedback = null;
- /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
- [EditorBrowsable(EditorBrowsableState.Never)]
- public ControlStyle Style => (ControlStyle)ViewStyle.Clone();
-
static Control()
{
ThemeManager.AddPackageTheme(DefaultThemeCreator.Instance);
[EditorBrowsable(EditorBrowsableState.Never)]
public Control(ControlStyle style) : base(style)
{
- Initialize();
}
/// <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 Control(string styleName) : this(ThemeManager.GetStyle(styleName) as ControlStyle)
+ public Control(string styleName) : this(new ControlStyle() /* Apply empty style */)
{
if (ThemeManager.GetStyle(styleName) == null)
{
throw new InvalidOperationException($"There is no style {styleName}");
}
- this.styleName = styleName;
- ThemeChangeSensitive = true;
+ StyleName = styleName;
}
/// <summary>
base.Dispose(type);
}
- /// <summary>
- /// OnInitialize
- /// </summary>
+ /// <inheritdoc/>
public override void OnInitialize()
{
base.OnInitialize();
+
+ LeaveRequired = true;
+ StateFocusableOnTouchMode = false;
+ EnableControlState = true;
}
/// <summary>
// If the OnThemeChangedEvent is not implemented, ApplyStyle()
base.OnThemeChanged(sender, e);
}
-
- private void Initialize()
- {
- LeaveRequired = true;
-
- StateFocusableOnTouchMode = false;
-
- EnableControlState = true;
- }
}
}
}
if (mScrollBar.Direction == ScrollBar.DirectionType.Vertical)
{
- mScrollBar.Style.Thumb.Size = new Size(thickness, length);
+ mScrollBar.ThumbSize = new Size(thickness, length);
}
else
{
- mScrollBar.Style.Thumb.Size = new Size(length, thickness);
+ mScrollBar.ThumbSize = new Size(length, thickness);
}
mScrollBar.MinValue = 0;
mScrollBar.MaxValue = (int)(range - extent);
var instance = (ScrollBar)bindable;
if (newValue != null)
{
- instance.Style.Direction = (DirectionType?)newValue;
+ instance.direction = (DirectionType)newValue;
instance.UpdateValue();
}
},
defaultValueCreator: (bindable) =>
{
var instance = (ScrollBar)bindable;
- return instance.Style.Direction;
+ return instance.direction;
});
/// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
[EditorBrowsable(EditorBrowsableState.Never)]
var instance = (ScrollBar)bindable;
if (newValue != null)
{
- instance.Style.Duration = (uint)newValue;
+ instance.duration = (uint)newValue;
if (instance.scrollAniPlayer != null)
{
instance.scrollAniPlayer.Duration = (int)(uint)newValue;
defaultValueCreator: (bindable) =>
{
var instance = (ScrollBar)bindable;
- return instance.Style.Duration;
+ return instance.duration;
});
private ImageView trackImage;
private int minValue;
private int maxValue;
private int curValue;
+ private DirectionType direction = DirectionType.Horizontal;
+ private uint duration;
static ScrollBar() { }
/// <summary>
[Obsolete("Deprecated in API8; Will be removed in API10")]
public ScrollBar() : base()
{
- Initialize();
}
/// <summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public ScrollBar(string style) : base(style)
{
- Initialize();
}
/// <summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public ScrollBar(ScrollBarStyle scrollBarStyle) : base(scrollBarStyle)
{
- Initialize();
}
/// <summary>
#region public property
/// <summary>
- /// Get style of scrollbar.
- /// </summary>
- [EditorBrowsable(EditorBrowsableState.Never)]
- public new ScrollBarStyle Style => ViewStyle as ScrollBarStyle;
-
- /// <summary>
/// The property to get/set the direction of the ScrollBar.
/// </summary>
/// <since_tizen> 6 </since_tizen>
{
get
{
- return Style?.Thumb?.Size;
+ return thumbImage?.Size;
}
set
{
- if (null != Style?.Thumb)
+ if (thumbImage != null)
{
- Style.Thumb.Size = value;
+ thumbImage.Size = value;
RelayoutRequest();
}
}
{
get
{
- return Style?.Track?.ResourceUrl?.All;
+ return trackImage?.ResourceUrl;
}
set
{
- if (null != Style?.Track)
+ if (trackImage != null)
{
- Style.Track.ResourceUrl = value;
+ trackImage.ResourceUrl = value;
RelayoutRequest();
}
}
{
get
{
- return Style?.Track?.BackgroundColor?.All;
+ return trackImage?.BackgroundColor;
}
set
{
- if (null != Style?.Track)
+ if (trackImage != null)
{
- Style.Track.BackgroundColor = value;
- RelayoutRequest();
+ trackImage.BackgroundColor = value;
}
}
}
{
get
{
- return Style?.Thumb?.BackgroundColor?.All;
+ return thumbImage?.BackgroundColor;
}
set
{
- if (null != Style?.Thumb)
+ if (thumbImage != null)
{
- Style.Thumb.BackgroundColor = value;
- RelayoutRequest();
+ thumbImage.BackgroundColor = value;
}
}
}
return new ScrollBarStyle();
}
- private void Initialize()
+ /// <inheritdoc/>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override void OnInitialize()
{
+ base.OnInitialize();
+
this.Focusable = false;
trackImage = new ImageView
PivotPoint = Tizen.NUI.PivotPoint.CenterLeft
};
this.Add(trackImage);
- trackImage.ApplyStyle(Style.Track);
+
thumbImage = new ImageView
{
PivotPoint = Tizen.NUI.PivotPoint.CenterLeft
};
this.Add(thumbImage);
- thumbImage.ApplyStyle(Style.Thumb);
+
scrollAniPlayer = new Animation(334);
scrollAniPlayer.DefaultAlphaFunction = new AlphaFunction(AlphaFunction.BuiltinFunctions.Linear);
LayoutDirectionChanged += OnLayoutDirectionChanged;
}
+ /// <inheritdoc/>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override void ApplyStyle(ViewStyle style)
+ {
+ base.ApplyStyle(style);
+
+ if (style is ScrollBarStyle scrollBarStyle)
+ {
+ trackImage.ApplyStyle(scrollBarStyle.Track);
+ thumbImage.ApplyStyle(scrollBarStyle.Thumb);
+ UpdateValue();
+ }
+ }
+
private void OnLayoutDirectionChanged(object sender, LayoutDirectionChangedEventArgs e)
{
RelayoutRequest();
float height = (float)Size2D.Height;
float thumbW = 0.0f;
float thumbH = 0.0f;
- if (Style.Thumb.Size == null)
+ if (thumbImage == null || thumbImage.Size == null)
{
return;
}
else
{
- thumbW = Style.Thumb.Size.Width;
- thumbH = Style.Thumb.Size.Height;
+ thumbW = thumbImage.Size.Width;
+ thumbH = thumbImage.Size.Height;
}
float ratio = (float)(curValue - minValue) / (float)(maxValue - minValue);
- if (Style.Direction == DirectionType.Horizontal)
+ if (direction == DirectionType.Horizontal)
{
if (LayoutDirection == ViewLayoutDirectionType.RTL)
{
if (enableAni) enableAni = false;
}
- private DirectionType CurrentDirection()
- {
- DirectionType dir = DirectionType.Horizontal;
- if (null != Style.Direction)
- {
- dir = Style.Direction.Value;
- }
- return dir;
- }
-
private int CalculateCurrentValue(float offset, DirectionType dir)
{
if (dir == DirectionType.Horizontal)
/*
- * Copyright(c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright(c) 2021 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.
* limitations under the License.
*
*/
-using System;
+
using System.Collections.Generic;
using System.ComponentModel;
+using System.Diagnostics;
using Tizen.NUI.BaseComponents;
using Tizen.NUI.Binding;
using Tizen.NUI.Accessibility;
/// <since_tizen> 6 </since_tizen>
public class Loading : Control
{
- /// <summary>The ImageArray bindable property.</summary>
+ /// <summary>The ImageList bindable property.</summary>
[EditorBrowsable(EditorBrowsableState.Never)]
- public static readonly BindableProperty ImageArrayProperty = BindableProperty.Create(nameof(ImageArray), typeof(string[]), typeof(Loading), null, propertyChanged: (bindable, oldValue, newValue) =>
+ public static readonly BindableProperty ImageListProperty = BindableProperty.Create(nameof(ImageList), typeof(IList<string>), typeof(Loading), null, propertyChanged: (bindable, oldValue, newValue) =>
{
- var instance = (Loading)bindable;
- if (newValue != null)
- {
- instance.loadingStyle.Images = (string[])newValue;
- instance.imageVisual.URLS = instance.loadingStyle.ImageList as List<string>;
- }
+ Debug.Assert(((Loading)bindable).imageVisual != null);
+
+ var newList = newValue as List<string>;
+ ((Loading)bindable).imageVisual.URLS = newList == null ? new List<string>() : newList;
},
defaultValueCreator: (bindable) =>
{
- var instance = (Loading)bindable;
- return instance.loadingStyle.Images;
+ Debug.Assert(((Loading)bindable).imageVisual != null);
+ return ((Loading)bindable).imageVisual.URLS;
});
- /// <summary>The ImageList bindable property.</summary>
+ /// <summary>The Size bindable property.</summary>
[EditorBrowsable(EditorBrowsableState.Never)]
- public static readonly BindableProperty ImageListProperty = BindableProperty.Create(nameof(ImageList), typeof(IList<string>), typeof(Loading), null, propertyChanged: (bindable, oldValue, newValue) =>
+ public new static readonly BindableProperty SizeProperty = BindableProperty.Create(nameof(Size), typeof(Size), typeof(Loading), new Size(0, 0), propertyChanged: (bindable, oldValue, newValue) =>
{
var instance = (Loading)bindable;
if (newValue != null)
{
- var newValueList = newValue as List<string>;
- instance.loadingStyle.ImageList = newValueList;
- if (instance.imageVisual != null) instance.imageVisual.URLS = newValueList;
+ Size size = (Size)newValue;
+ ((View)bindable).Size = size;
}
},
defaultValueCreator: (bindable) =>
{
- return ((Loading)bindable).loadingStyle.ImageList;
- });
- /// <summary>The Size bindable property.</summary>
- [EditorBrowsable(EditorBrowsableState.Never)]
- public new static readonly BindableProperty SizeProperty = BindableProperty.Create(nameof(Size), typeof(Size), typeof(Loading), new Size(0, 0), propertyChanged: (bindable, oldValue, newValue) =>
- {
- var instance = (Loading)bindable;
- if (newValue != null)
- {
- Size size = (Size)newValue;
- ((View)bindable).Size = size;
- instance.loadingStyle.LoadingSize = size;
- }
- },
- defaultValueCreator: (bindable) =>
- {
var instance = (View)bindable;
return instance.Size;
});
/// <summary>The FrameRate bindable property.</summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public static readonly BindableProperty FrameRateProperty = BindableProperty.Create(nameof(FrameRate), typeof(int), typeof(Loading), (int)(1000 / 16.6f), propertyChanged: (bindable, oldValue, newValue) =>
- {
- var instance = (Loading)bindable;
- if (newValue != null)
- {
- int frameRate = (int)newValue;
- if (0 != frameRate) //It will crash if 0
- {
- instance.loadingStyle.FrameRate = frameRate;
- instance.imageVisual.FrameDelay = 1000.0f / frameRate;
- }
- }
- },
+ {
+ Debug.Assert(((Loading)bindable).imageVisual != null);
+
+ int frameRate = (int)newValue;
+ if (0 != frameRate) //It will crash if 0
+ {
+ ((Loading)bindable).imageVisual.FrameDelay = 1000.0f / frameRate;
+ }
+ },
defaultValueCreator: (bindable) =>
{
- var instance = (Loading)bindable;
- return instance.loadingStyle.FrameRate?.All ?? (int)(1000 / 16.6f);
+ Debug.Assert(((Loading)bindable).imageVisual != null);
+ return ((Loading)bindable).imageVisual.FrameDelay * 1000.0f;
});
private AnimatedImageVisual imageVisual = null;
- private LoadingStyle loadingStyle => ViewStyle as LoadingStyle;
internal new class Property
{
/// <since_tizen> 6 </since_tizen>
public Loading() : base()
{
- Initialize();
}
/// <summary>
/// <since_tizen> 8 </since_tizen>
public Loading(string style) : base(style)
{
- Initialize();
}
/// <summary>
/// <since_tizen> 8 </since_tizen>
public Loading(LoadingStyle loadingStyle) : base(loadingStyle)
{
- Initialize();
}
/// <summary>
- /// Get style of loading.
- /// Return a copied Style instance of Loading
+ /// Return currently applied style.
/// </summary>
/// <remarks>
- /// It returns copied Style instance and changing it does not effect to the Loading.
- /// Style setting is possible by using constructor or the function of ApplyStyle(ViewStyle viewStyle)
- /// </remarks>>
+ /// Modifying contents in style may cause unexpected behaviour.
+ /// </remarks>
/// <since_tizen> 8 </since_tizen>
- public new LoadingStyle Style
- {
- get
- {
- var result = new LoadingStyle(loadingStyle);
- result.CopyPropertiesFromView(this);
- return result;
- }
- }
+ public LoadingStyle Style => (LoadingStyle)(ViewStyle as LoadingStyle)?.Clone();
/// <summary>
/// Gets or sets loading image resource array.
/// <since_tizen> 6 </since_tizen>
public string[] ImageArray
{
- get
- {
- return (string[])GetValue(ImageArrayProperty);
- }
- set
- {
- SetValue(ImageArrayProperty, value);
- }
+ get => (GetValue(ImageListProperty) as List<string>).ToArray();
+ set => SetValue(ImageListProperty, value == null ? new List<string>() : new List<string>((string[])value));
}
/// <summary>
}
}
+ /// <inheritdoc/>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override void OnInitialize()
+ {
+ base.OnInitialize();
+
+ imageVisual = new AnimatedImageVisual()
+ {
+ URLS = new List<string>(),
+ FrameDelay = 16.6f,
+ LoopCount = -1,
+ Position = new Vector2(0, 0),
+ Origin = Visual.AlignType.Center,
+ AnchorPoint = Visual.AlignType.Center,
+ SizePolicy = VisualTransformPolicyType.Relative,
+ Size = new Size2D(1, 1)
+ };
+
+ this.AddVisual("loadingImageVisual", imageVisual);
+
+ AccessibilityManager.Instance.SetAccessibilityAttribute(this, AccessibilityManager.AccessibilityAttribute.Trait, "Loading");
+ }
+
+ /// <inheritdoc/>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override void ApplyStyle(ViewStyle viewStyle)
+ {
+ base.ApplyStyle(viewStyle);
+
+ Debug.Assert(imageVisual != null);
+
+ if (viewStyle is LoadingStyle loadingStyle)
+ {
+ if (loadingStyle.Images != null)
+ {
+ imageVisual.URLS = loadingStyle.ImageList as List<string>;
+ }
+
+ if (loadingStyle.LoadingSize != null)
+ {
+ Size = loadingStyle.LoadingSize;
+ }
+ }
+ }
+
/// <summary>
/// Get Loading style.
/// </summary>
base.Dispose(type);
}
- private void Initialize()
- {
- imageVisual = new AnimatedImageVisual()
- {
- URLS = new List<string>(),
- FrameDelay = 16.6f,
- LoopCount = -1,
- Position = new Vector2(0, 0),
- Origin = Visual.AlignType.Center,
- AnchorPoint = Visual.AlignType.Center,
- SizePolicy = VisualTransformPolicyType.Relative,
- Size = new Size2D(1, 1)
- };
-
- UpdateVisual();
-
- this.AddVisual("loadingImageVisual", imageVisual);
-
- AccessibilityManager.Instance.SetAccessibilityAttribute(this, AccessibilityManager.AccessibilityAttribute.Trait, "Loading");
- }
-
- private void UpdateVisual()
- {
- if (null != loadingStyle.Images)
- {
- loadingStyle.ImageList = new List<string>(loadingStyle.Images);
- imageVisual.URLS = loadingStyle.ImageList as List<string>;
- }
- if (null != loadingStyle.FrameRate?.All && 0 != loadingStyle.FrameRate.All.Value)
- {
- imageVisual.FrameDelay = 1000.0f / (float)loadingStyle.FrameRate.All.Value;
- }
- }
-
/// <summary>
/// Play Loading Animation.
/// </summary>
/*
- * Copyright(c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright(c) 2021 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.
* limitations under the License.
*
*/
+
using System;
using System.Collections.Generic;
using System.ComponentModel;
+using System.Diagnostics;
using Tizen.NUI.BaseComponents;
+using Tizen.NUI.Binding;
namespace Tizen.NUI.Components
{
/// <since_tizen> 8 </since_tizen>
public class Pagination : Control
{
- private VisualView container;
+ /// <summary>The IndicatorSize bindable property.</summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public static readonly BindableProperty IndicatorSizeProperty = BindableProperty.Create(nameof(IndicatorSize), typeof(Size), typeof(Pagination), null, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ if (newValue != null)
+ {
+ var pagination = (Pagination)bindable;
+ pagination.indicatorSize = new Size((Size)newValue);
+ pagination.UpdateVisual();
+ pagination.UpdateContainer();
+ }
+ },
+ defaultValueCreator: (bindable) =>
+ {
+ return ((Pagination)bindable).indicatorSize;
+ });
+ /// <summary>The IndicatorImageUrlSelector bindable property.</summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public static readonly BindableProperty IndicatorImageUrlProperty = BindableProperty.Create("IndicatorImageUrl", typeof(Selector<string>), typeof(Pagination), null, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var pagination = (Pagination)bindable;
+ pagination.indicatorImageUrl = ((Selector<string>)newValue)?.Clone();
+ pagination.UpdateVisual();
+ },
+ defaultValueCreator: (bindable) =>
+ {
+ return ((Pagination)bindable).indicatorImageUrl;
+ });
+
+ /// <summary>The IndicatorSpacing bindable property.</summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public static readonly BindableProperty IndicatorSpacingProperty = BindableProperty.Create(nameof(IndicatorSpacing), typeof(int), typeof(Pagination), default(int), propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ var pagination = (Pagination)bindable;
+ pagination.indicatorSpacing = (int)newValue;
+ pagination.UpdateVisual();
+ },
+ defaultValueCreator: (bindable) =>
+ {
+ return ((Pagination)bindable).indicatorSpacing;
+ });
+
+ private VisualView container;
+ private Size indicatorSize = new Size(10, 10);
+ private Selector<string> indicatorImageUrl;
+ private int indicatorSpacing;
private List<ImageVisual> indicatorList = new List<ImageVisual>();
private int indicatorCount = 0;
- private int selectedIndex = -1;
- private PaginationStyle paginationStyle => ViewStyle as PaginationStyle;
+ private int selectedIndex = 0;
private Color indicatorColor;
private Color selectedIndicatorColor;
/// <since_tizen> 8 </since_tizen>
public Pagination() : base()
{
- Initialize();
}
/// <summary>
/// <since_tizen> 8 </since_tizen>
public Pagination(string style) : base(style)
{
- Initialize();
}
/// <summary>
/// <since_tizen> 8 </since_tizen>
public Pagination(PaginationStyle paginationStyle) : base(paginationStyle)
{
- Initialize();
}
/// <summary>
- /// Get style of pagination.
+ /// Return currently applied style.
/// </summary>
- /// This will be public opened in tizen_next after ACR done. Before ACR, need to be hidden as inhouse API.
+ /// <remarks>
+ /// Modifying contents in style may cause unexpected behaviour.
+ /// </remarks>
/// <since_tizen> 8 </since_tizen>
- public new PaginationStyle Style
- {
- get
- {
- var result = new PaginationStyle(paginationStyle);
- result.CopyPropertiesFromView(this);
- return result;
- }
- }
+ public PaginationStyle Style => (PaginationStyle)(ViewStyle as PaginationStyle)?.Clone();
/// <summary>
/// Gets or sets the size of the indicator.
/// <since_tizen> 8 </since_tizen>
public Size IndicatorSize
{
- get
- {
- return paginationStyle?.IndicatorSize;
- }
- set
- {
- if (value == null || paginationStyle == null)
- {
- return;
- }
- paginationStyle.IndicatorSize = value;
- UpdateVisual();
- UpdateContainer();
- }
+ get => (Size)GetValue(IndicatorSizeProperty);
+ set => SetValue(IndicatorSizeProperty, value);
}
/// <summary>
/// <since_tizen> 8 </since_tizen>
public Selector<string> IndicatorImageUrl
{
- get
- {
- return paginationStyle?.IndicatorImageUrl;
- }
- set
- {
- if (value == null || paginationStyle == null)
- {
- return;
- }
- paginationStyle.IndicatorImageUrl = value;
- UpdateVisual();
- }
+ get => (Selector<string>)GetValue(IndicatorImageUrlProperty);
+ set => SetValue(IndicatorImageUrlProperty, value);
}
/// <summary>
/// <since_tizen> 8 </since_tizen>
public int IndicatorSpacing
{
- get
- {
- return (int)paginationStyle?.IndicatorSpacing;
- }
- set
- {
- if (paginationStyle != null)
- {
- paginationStyle.IndicatorSpacing = value;
- UpdateVisual();
- }
- }
+ get => (int)GetValue(IndicatorSpacingProperty);
+ set => SetValue(IndicatorSpacingProperty, value);
}
}
set
{
- if (indicatorCount == value || indicatorCount < 0)
+ if (indicatorCount == value || value < 0)
{
return;
}
prevLastIndex = LastIndicatorIndex;
for (int i = indicatorCount; i < value; i++)
{
- CreateIndicator();
+ CreateIndicator(i);
}
}
else
if (selectedIndex >= value)
{
- selectedIndex = 0;
- SelectIn(indicatorList[selectedIndex]);
+ selectedIndex = Math.Max(0, value - 1);
+
+ if (value > 0)
+ {
+ SelectIn(indicatorList[selectedIndex]);
+ }
}
}
indicatorCount = value;
- if (lastIndicatorImageUrl != null && paginationStyle != null && indicatorCount > 0)
+ if (lastIndicatorImageUrl != null && indicatorImageUrl != null && indicatorCount > 0)
{
- if (prevLastIndex >= 0 && paginationStyle.IndicatorImageUrl != null)
+ if (prevLastIndex >= 0)
{
- indicatorList[prevLastIndex].URL = prevLastIndex == selectedIndex ? paginationStyle.IndicatorImageUrl.Selected : paginationStyle.IndicatorImageUrl.Normal;
+ indicatorList[prevLastIndex].URL = prevLastIndex == selectedIndex ? indicatorImageUrl.Selected : indicatorImageUrl.Normal;
}
indicatorList[LastIndicatorIndex].URL = IsLastSelected ? lastIndicatorImageUrl.Selected : lastIndicatorImageUrl.Normal;
}
}
set
{
- if (selectedIndex == value)
+ var refinedValue = Math.Max(0, Math.Min(value, indicatorCount - 1));
+
+ if (selectedIndex == refinedValue)
{
return;
}
- if (selectedIndex >= 0 && selectedIndex < indicatorCount)
- {
- SelectOut(indicatorList[selectedIndex]);
- }
- selectedIndex = value;
- if (selectedIndex >= 0 && selectedIndex < indicatorCount)
- {
- SelectIn(indicatorList[selectedIndex]);
- }
+
+ Debug.Assert(refinedValue >= 0 && refinedValue < indicatorCount);
+ Debug.Assert(selectedIndex >= 0 && selectedIndex < indicatorCount);
+
+ SelectOut(indicatorList[selectedIndex]);
+
+ selectedIndex = refinedValue;
+
+ SelectIn(indicatorList[selectedIndex]);
}
}
return new Position(indicatorList[index].Position.X + container.PositionX, indicatorList[index].Position.Y + container.PositionY);
}
+ /// <inheritdoc/>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override void OnInitialize()
+ {
+ base.OnInitialize();
+
+ container = new VisualView()
+ {
+ Name = "Container",
+ ParentOrigin = Tizen.NUI.ParentOrigin.CenterLeft,
+ PivotPoint = Tizen.NUI.PivotPoint.CenterLeft,
+ PositionUsesPivotPoint = true,
+ };
+ this.Add(container);
+
+ //TODO: Apply color properties from PaginationStyle class.
+ indicatorColor = new Color(1.0f, 1.0f, 1.0f, 0.5f);
+ selectedIndicatorColor = new Color(1.0f, 1.0f, 1.0f, 1.0f);
+ }
+
/// <summary>
/// You can override it to do your select out operation.
/// </summary>
protected virtual void SelectOut(VisualMap selectOutIndicator)
{
if (!(selectOutIndicator is ImageVisual visual)) return;
- visual.URL = ((IsLastSelected && lastIndicatorImageUrl != null) ? lastIndicatorImageUrl : paginationStyle?.IndicatorImageUrl)?.Normal;
+ visual.URL = ((IsLastSelected && lastIndicatorImageUrl != null) ? lastIndicatorImageUrl : indicatorImageUrl)?.Normal;
if (indicatorColor == null)
{
protected virtual void SelectIn(VisualMap selectInIndicator)
{
if (!(selectInIndicator is ImageVisual visual)) return;
- visual.URL = ((IsLastSelected && lastIndicatorImageUrl != null) ? lastIndicatorImageUrl : paginationStyle?.IndicatorImageUrl)?.Selected;
+ visual.URL = ((IsLastSelected && lastIndicatorImageUrl != null) ? lastIndicatorImageUrl : indicatorImageUrl)?.Selected;
if (selectedIndicatorColor == null)
{
base.Dispose(type);
}
- private void Initialize()
+ private void CreateIndicator(int index)
{
- container = new VisualView()
- {
- Name = "Container",
- ParentOrigin = Tizen.NUI.ParentOrigin.CenterLeft,
- PivotPoint = Tizen.NUI.PivotPoint.CenterLeft,
- PositionUsesPivotPoint = true,
- };
- this.Add(container);
+ Debug.Assert(indicatorSize != null);
- //TODO: Apply color properties from PaginationStyle class.
- indicatorColor = new Color(1.0f, 1.0f, 1.0f, 0.5f);
- selectedIndicatorColor = new Color(1.0f, 1.0f, 1.0f, 1.0f);
- }
-
- private void CreateIndicator()
- {
- if (paginationStyle == null)
- {
- return;
- }
- if (paginationStyle.IndicatorSize == null)
- {
- paginationStyle.IndicatorSize = new Size(0, 0);
- }
ImageVisual indicator = new ImageVisual
{
- URL = paginationStyle.IndicatorImageUrl?.Normal,
- Size = new Size2D((int)paginationStyle.IndicatorSize.Width, (int)paginationStyle.IndicatorSize.Height),
+ URL = indicatorImageUrl?.Normal,
+ Size = indicatorSize,
//TODO: Apply color properties from PaginationStyle class.
MixColor = (indicatorColor == null) ? new Color(1.0f, 1.0f, 1.0f, 0.5f) : indicatorColor,
Opacity = (indicatorColor == null) ? 0.5f : indicatorColor.A
};
- indicator.Position = new Vector2((int)(paginationStyle.IndicatorSize.Width + paginationStyle.IndicatorSpacing) * indicatorList.Count, 0);
+ indicator.Position = new Vector2((int)(indicatorSize.Width + indicatorSpacing) * indicatorList.Count, 0);
container.AddVisual("Indicator" + indicatorList.Count, indicator);
indicatorList.Add(indicator);
+
+ if (index == selectedIndex)
+ {
+ SelectIn(indicatorList[selectedIndex]);
+ }
}
private void UpdateContainer()
{
- if (paginationStyle == null)
- {
- return;
- }
+ Debug.Assert(indicatorSize != null);
+
if (indicatorList.Count > 0)
{
- container.SizeWidth = (paginationStyle.IndicatorSize.Width + paginationStyle.IndicatorSpacing) * indicatorList.Count - paginationStyle.IndicatorSpacing;
+ container.SizeWidth = (indicatorSize.Width + indicatorSpacing) * indicatorList.Count - indicatorSpacing;
}
else
{
container.SizeWidth = 0;
}
- container.SizeHeight = paginationStyle.IndicatorSize.Height;
+ container.SizeHeight = indicatorSize.Height;
container.PositionX = (int)((this.SizeWidth - container.SizeWidth) / 2);
}
private void UpdateVisual()
{
- if (null == paginationStyle?.IndicatorSize) return;
- if (null == paginationStyle?.IndicatorImageUrl) return;
- if (indicatorCount < 0) return;
+ Debug.Assert(indicatorSize != null);
+
+ if (indicatorImageUrl == null)
+ {
+ return;
+ }
for (int i = 0; i < indicatorList.Count; i++)
{
ImageVisual indicator = indicatorList[i];
- indicator.URL = paginationStyle.IndicatorImageUrl?.Normal;
- indicator.Size = new Size2D((int)paginationStyle.IndicatorSize.Width, (int)paginationStyle.IndicatorSize.Height);
- indicator.Position = new Vector2((int)(paginationStyle.IndicatorSize.Width + paginationStyle.IndicatorSpacing) * i, 0);
+ indicator.URL = indicatorImageUrl?.Normal;
+ indicator.Size = indicatorSize;
+ indicator.Position = new Vector2((int)(indicatorSize.Width + indicatorSpacing) * i, 0);
}
if (lastIndicatorImageUrl != null && indicatorCount > 0)
/*
- * Copyright(c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright(c) 2021 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.
public static readonly BindableProperty ButtonHeightProperty = BindableProperty.Create(nameof(ButtonHeight), typeof(int), typeof(Popup), default(int), propertyChanged: (bindable, oldValue, newValue) =>
{
var instance = (Popup)bindable;
- if (newValue != null && instance?.popupStyle?.Buttons?.Size != null)
+ if (newValue != null)
{
- instance.popupStyle.Buttons.SizeHeight = (int)newValue;
instance.btGroup.Itemheight = (int)newValue;
instance.UpdateView();
}
},
defaultValueCreator: (bindable) =>
{
- var instance = (Popup)bindable;
- return (int)(instance.popupStyle?.Buttons?.Size?.Height ?? 0);
+ return (int)((Popup)bindable).btGroup.Itemheight;
});
/// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
var instance = (Popup)bindable;
if (newValue != null)
{
- if (instance.popupStyle?.Buttons?.Text != null)
- {
- instance.popupStyle.Buttons.Text.PointSize = (float)newValue;
- }
instance.btGroup.ItemPointSize = (float)newValue;
}
},
defaultValueCreator: (bindable) =>
{
- var instance = (Popup)bindable;
- return instance.popupStyle?.Buttons?.Text?.PointSize?.All ?? 0;
+ return ((Popup)bindable).btGroup.ItemPointSize;
});
/// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
var instance = (Popup)bindable;
if (newValue != null)
{
- instance.popupStyle.Buttons.Text.FontFamily = (string)newValue;
instance.btGroup.ItemFontFamily = (string)newValue;
}
},
defaultValueCreator: (bindable) =>
{
- var instance = (Popup)bindable;
- return instance.popupStyle?.Buttons?.Text?.FontFamily.All;
+ return ((Popup)bindable).btGroup.ItemFontFamily;
});
/// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
var instance = (Popup)bindable;
if (newValue != null)
{
- if (instance.popupStyle?.Buttons?.Text != null)
- {
- instance.popupStyle.Buttons.Text.TextColor = (Color)newValue;
- }
instance.btGroup.ItemTextColor = (Color)newValue;
}
},
defaultValueCreator: (bindable) =>
{
- var instance = (Popup)bindable;
- return instance.popupStyle?.Buttons?.Text?.TextColor?.All;
+ return ((Popup)bindable).btGroup.ItemTextColor;
});
/// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
var instance = (Popup)bindable;
if (newValue != null)
{
- instance.popupStyle.Buttons.Overlay.BackgroundColor = (Selector<Color>)newValue;
instance.btGroup.OverLayBackgroundColorSelector = (Selector<Color>)newValue;
}
},
defaultValueCreator: (bindable) =>
{
- var instance = (Popup)bindable;
- return instance.popupStyle?.Buttons?.Overlay?.BackgroundColor;
+ return ((Popup)bindable).btGroup.OverLayBackgroundColorSelector;
});
/// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
var instance = (Popup)bindable;
if (newValue != null)
{
- instance.popupStyle.Buttons.Text.HorizontalAlignment = (HorizontalAlignment)newValue;
instance.btGroup.ItemTextAlignment = (HorizontalAlignment)newValue;
}
},
defaultValueCreator: (bindable) =>
{
- var instance = (Popup)bindable;
- return instance.popupStyle?.Buttons?.Text?.HorizontalAlignment ?? HorizontalAlignment.Center;
+ return ((Popup)bindable).btGroup.ItemTextAlignment;
});
/// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
var instance = (Popup)bindable;
if (newValue != null)
{
- if (instance.popupStyle.Buttons.BackgroundImage == null)
- {
- instance.popupStyle.Buttons.BackgroundImage = new Selector<string>();
- }
- instance.popupStyle.Buttons.BackgroundColor = new Selector<Color>();
- instance.popupStyle.Buttons.BackgroundImage = (string)newValue;
instance.btGroup.ItemBackgroundImageUrl = (string)newValue;
}
},
defaultValueCreator: (bindable) =>
{
- var instance = (Popup)bindable;
- return instance.popupStyle?.Buttons?.BackgroundImage?.All;
+ return ((Popup)bindable).btGroup.ItemBackgroundImageUrl;
});
/// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
var instance = (Popup)bindable;
if (newValue != null)
{
- if (instance.popupStyle.Buttons.BackgroundImageBorder == null)
- {
- instance.popupStyle.Buttons.BackgroundImageBorder = new Selector<Rectangle>();
- }
- instance.popupStyle.Buttons.BackgroundImageBorder = (Rectangle)newValue;
instance.btGroup.ItemBackgroundBorder = (Rectangle)newValue;
}
},
defaultValueCreator: (bindable) =>
{
- var instance = (Popup)bindable;
- return instance.popupStyle?.Buttons?.BackgroundImageBorder?.All;
+ return ((Popup)bindable).btGroup.ItemBackgroundBorder;
});
/// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
var instance = (Popup)bindable;
ImageShadow shadow = (ImageShadow)newValue;
instance.btGroup.ItemImageShadow = new ImageShadow(shadow);
- instance.popupStyle.Buttons.ImageShadow = new ImageShadow(shadow);
},
defaultValueCreator: (bindable) =>
{
- var instance = (Popup)bindable;
- return instance.popupStyle?.Buttons?.ImageShadow?.All;
+ return ((Popup)bindable).btGroup.ItemImageShadow;
});
-
- private PopupStyle popupStyle => ViewStyle as PopupStyle;
private TextLabel titleText;
private ButtonGroup btGroup = null;
private Window window = null;
private Layer container = new Layer();
+ private ButtonStyle buttonStyle = new ButtonStyle();
+
static Popup() { }
/// <summary>
[Obsolete("Deprecated in API8; Will be removed in API10")]
public Popup() : base()
{
- Initialize();
}
/// <summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public Popup(string style) : base(style)
{
- Initialize();
}
/// <summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public Popup(PopupStyle popupStyle) : base(popupStyle)
{
- Initialize();
}
/// 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 AddButton(string buttonText)
{
- if (popupStyle.Buttons != null)
- {
- Button btn = new Button(popupStyle.Buttons);
- btn.Text = buttonText;
- btn.ClickEvent += ButtonClickEvent;
- btGroup.AddItem(btn);
- UpdateView();
- }
+ Button btn = new Button(buttonStyle);
+ btn.Text = buttonText;
+ btn.ClickEvent += ButtonClickEvent;
+ btGroup.AddItem(btn);
+ UpdateView();
}
/// <summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public void AddButton(string buttonText, ButtonStyle style)
{
- if (popupStyle.Buttons != null && style != null)
- {
- popupStyle.Buttons.CopyFrom(style);
- AddButton(buttonText);
- }
+ Button btn = new Button(style);
+ btn.Text = buttonText;
+ btn.ClickEvent += ButtonClickEvent;
+ btGroup.AddItem(btn);
+ UpdateView();
}
/// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
public event EventHandler<ButtonClickEventArgs> PopupButtonClickEvent;
/// <summary>
- /// Get style of popup.
- /// </summary>
- [EditorBrowsable(EditorBrowsableState.Never)]
- public new PopupStyle Style
- {
- get
- {
- var result = new PopupStyle(popupStyle);
- result.CopyPropertiesFromView(this);
- result.Title.CopyPropertiesFromView(titleText);
- return result;
- }
- }
-
- /// <summary>
/// Popup Title.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
[Obsolete("Deprecated in API8; Will be removed in API10")]
public string TitleText
{
- get
- {
- return popupStyle?.Title?.Text?.All;
- }
- set
- {
- if (value != null)
- {
- if (popupStyle?.Title != null)
- {
- popupStyle.Title.Text = value;
- }
- }
- }
+ get => Title.Text;
+ set => Title.Text = value;
}
/// <summary>
[Obsolete("Deprecated in API8; Will be removed in API10")]
public float TitlePointSize
{
- get
- {
- return popupStyle?.Title?.PointSize?.All ?? 0;
- }
- set
- {
- if (popupStyle?.Title != null)
- {
- popupStyle.Title.PointSize = value;
- }
- }
+ get => Title.PointSize;
+ set => Title.PointSize = value;
}
/// <summary>
[Obsolete("Deprecated in API8; Will be removed in API10")]
public Color TitleTextColor
{
- get
- {
- return popupStyle?.Title?.TextColor?.All;
- }
- set
- {
- if (popupStyle?.Title != null)
- {
- popupStyle.Title.TextColor = value;
- }
- }
+ get => Title.TextColor;
+ set => Title.TextColor = value;
}
/// <summary>
[Obsolete("Deprecated in API8; Will be removed in API10")]
public HorizontalAlignment TitleTextHorizontalAlignment
{
- get
- {
- return popupStyle?.Title?.HorizontalAlignment ?? HorizontalAlignment.Center;
- }
- set
- {
- popupStyle.Title.HorizontalAlignment = value;
- }
+ get => Title.HorizontalAlignment;
+ set => Title.HorizontalAlignment = value;
}
/// <summary>
[Obsolete("Deprecated in API8; Will be removed in API10")]
public Position TitleTextPosition
{
- get
- {
- return popupStyle?.Title?.Position ?? new Position(0, 0, 0);
- }
- set
- {
- popupStyle.Title.Position = value;
- }
+ get => Title.Position;
+ set => Title.Position = value;
}
/// <summary>
[Obsolete("Deprecated in API8; Will be removed in API10")]
public int TitleHeight
{
- get
- {
- return (int)(popupStyle?.Title?.Size?.Height ?? 0);
- }
- set
- {
- if (popupStyle?.Title?.Size != null)
- {
- popupStyle.Title.SizeHeight = value;
- }
- }
+ get => (int)Title.SizeHeight;
+ set => Title.SizeHeight = (int)value;
}
/// <summary>
btGroup.Dispose();
btGroup = null;
}
+
+ buttonStyle?.Dispose();
}
base.Dispose(type);
if (viewStyle is PopupStyle ppStyle)
{
- if (ppStyle.Buttons == null)
+ if (ppStyle.Buttons?.SizeHeight != null)
{
- ppStyle.Buttons = new ButtonStyle();
+ ButtonHeight = (int)ppStyle.Buttons.SizeHeight;
}
- if (ppStyle.Buttons.PositionUsesPivotPoint == null) ppStyle.Buttons.PositionUsesPivotPoint = true;
- if (ppStyle.Buttons.ParentOrigin == null) ppStyle.Buttons.ParentOrigin = Tizen.NUI.ParentOrigin.BottomLeft;
- if (ppStyle.Buttons.PivotPoint == null) ppStyle.Buttons.PivotPoint = Tizen.NUI.PivotPoint.BottomLeft;
+ buttonStyle = (ButtonStyle)ppStyle.Buttons?.Clone();
+ if (buttonStyle.PositionUsesPivotPoint == null) buttonStyle.PositionUsesPivotPoint = true;
+ if (buttonStyle.ParentOrigin == null) buttonStyle.ParentOrigin = Tizen.NUI.ParentOrigin.BottomLeft;
+ if (buttonStyle.PivotPoint == null) buttonStyle.PivotPoint = Tizen.NUI.PivotPoint.BottomLeft;
if (btGroup != null)
{
for (int i = 0; i < btGroup.Count; i++)
{
- GetButton(i)?.ApplyStyle(ppStyle.Buttons);
+ var button = GetButton(i);
+ button.ApplyStyle(buttonStyle);
}
}
UpdateView();
}
- private void Initialize()
+ /// <summary>
+ /// Initialize AT-SPI object.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override void OnInitialize()
{
+ base.OnInitialize();
+ SetAccessibilityConstructor(Role.Dialog);
+ AppendAccessibilityAttribute("sub-role", "Alert");
+
container.Add(this);
container.SetTouchConsumed(true);
container.SetHoverConsumed(true);
}
/// <summary>
- /// Initialize AT-SPI object.
- /// </summary>
- [EditorBrowsable(EditorBrowsableState.Never)]
- public override void OnInitialize()
- {
- base.OnInitialize();
- SetAccessibilityConstructor(Role.Dialog);
- AppendAccessibilityAttribute("sub-role", "Alert");
- }
-
- /// <summary>
/// Informs AT-SPI bridge about the set of AT-SPI states associated with this object.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
private void UpdateView()
{
- if (popupStyle == null) return;
- btGroup.UpdateButton(popupStyle.Buttons);
+ btGroup.UpdateButton(buttonStyle);
UpdateContentView();
UpdateTitle();
}
{
if (e.PropertyName.Equals("LayoutDirection"))
{
- btGroup.UpdateButton(popupStyle.Buttons);
+ btGroup.UpdateButton(buttonStyle);
}
}
titleY = (int)Title.Position.Y;
}
- if (btGroup.Count != 0 && popupStyle?.Buttons?.Size != null)
+ if (btGroup.Count != 0)
{
- buttonH = (int)popupStyle.Buttons.Size.Height;
+ buttonH = ButtonHeight;
}
ContentView.Size = new Size(Size.Width - titleX * 2, Size.Height - titleY - titleH - buttonH);
ContentView.Position = new Position(titleX, titleY + titleH);
private void UpdateTitle()
{
- if (titleText != null && string.IsNullOrEmpty(popupStyle.Title.Text.All) && popupStyle.Title.Size != null)
+ if (titleText != null && string.IsNullOrEmpty(Title.Text) && Title.Size != null)
{
titleText.RaiseToTop();
}
/*
- * Copyright(c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright(c) 2021 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.
using Tizen.NUI.BaseComponents;
using Tizen.NUI.Binding;
using System.ComponentModel;
+using System.Diagnostics;
namespace Tizen.NUI.Components
{
private float minValue = 0;
private float currentValue = 0;
private float bufferValue = 0;
- private ProgressStyle progressStyle => ViewStyle as ProgressStyle;
static Progress() { }
/// <summary>
/// <since_tizen> 6 </since_tizen>
public Progress() : base()
{
- Initialize();
}
/// <summary>
/// <since_tizen> 8 </since_tizen>
public Progress(string style) : base(style)
{
- Initialize();
}
/// <summary>
/// <since_tizen> 8 </since_tizen>
public Progress(ProgressStyle progressStyle) : base(progressStyle)
{
- Initialize();
}
/// <summary>
}
/// <summary>
- /// Get style of progress.
+ /// Return currently applied style.
/// </summary>
+ /// <remarks>
+ /// Modifying contents in style may cause unexpected behaviour.
+ /// </remarks>
/// <since_tizen> 8 </since_tizen>
- public new ProgressStyle Style
- {
- get
- {
- var result = new ProgressStyle(progressStyle);
- result.CopyPropertiesFromView(this);
- result.Track.CopyPropertiesFromView(trackImage);
- result.Progress.CopyPropertiesFromView(progressImage);
- result.Buffer.CopyPropertiesFromView(bufferImage);
- return result;
- }
- }
+ public ProgressStyle Style => (ProgressStyle)(ViewStyle as ProgressStyle)?.Clone();
/// <summary>
/// The property to get/set Track image object URL of the Progress.
/// <since_tizen> 6 </since_tizen>
public string TrackImageURL
{
- get
- {
- return progressStyle?.Track?.ResourceUrl?.All;
- }
- set
- {
- if (null != progressStyle?.Track)
- {
- progressStyle.Track.ResourceUrl = value;
- }
- }
+ get => trackImage.ResourceUrl;
+ set => trackImage.ResourceUrl = value;
}
/// <summary>
/// <since_tizen> 6 </since_tizen>
public string ProgressImageURL
{
- get
- {
- return progressStyle?.Progress?.ResourceUrl?.All;
- }
- set
- {
- if (null != progressStyle?.Progress)
- {
- progressStyle.Progress.ResourceUrl = value;
- }
- }
+ get => progressImage.ResourceUrl;
+ set => progressImage.ResourceUrl = value;
}
/// <summary>
/// <since_tizen> 6 </since_tizen>
public string BufferImageURL
{
- get
- {
- return progressStyle?.Buffer?.ResourceUrl?.All;
- }
- set
- {
- if (null != progressStyle?.Buffer)
- {
- progressStyle.Buffer.ResourceUrl = value;
- RelayoutRequest();
- }
- }
+ get => bufferImage.ResourceUrl;
+ set => bufferImage.ResourceUrl = value;
}
/// <summary>
/// <since_tizen> 6 </since_tizen>
public Color TrackColor
{
- get
- {
- return progressStyle?.Track?.BackgroundColor?.All;
- }
- set
- {
- if (null != progressStyle?.Track)
- {
- progressStyle.Track.BackgroundColor = value;
- }
- }
+ get => trackImage.BackgroundColor;
+ set => trackImage.BackgroundColor = value;
}
/// <summary>
/// <since_tizen> 6 </since_tizen>
public Color ProgressColor
{
- get
- {
- return progressStyle?.Progress?.BackgroundColor?.All;
- }
- set
- {
- if (null != progressStyle?.Progress)
- {
- progressStyle.Progress.BackgroundColor = value;
- }
- }
+ get => progressImage.BackgroundColor;
+ set => progressImage.BackgroundColor = value;
}
/// <summary>
/// <since_tizen> 6 </since_tizen>
public Color BufferColor
{
- get
- {
- return progressStyle?.Buffer?.BackgroundColor?.All;
- }
- set
- {
- if (null != progressStyle?.Buffer)
- {
- progressStyle.Buffer.BackgroundColor = value;
- }
- }
+ get => bufferImage.BackgroundColor;
+ set => bufferImage.BackgroundColor = value;
}
/// <summary>
}
}
+ /// <inheritdoc/>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override void OnInitialize()
+ {
+ base.OnInitialize();
+ // create necessary components
+ InitializeTrack();
+ InitializeBuffer();
+ InitializeProgress();
+ }
+
+ /// <inheritdoc/>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override void ApplyStyle(ViewStyle style)
+ {
+ base.ApplyStyle(style);
+
+ if (style is ProgressStyle progressStyle)
+ {
+ Debug.Assert(trackImage != null);
+ Debug.Assert(progressImage != null);
+ Debug.Assert(bufferImage != null);
+
+ trackImage.ApplyStyle(progressStyle.Track);
+ progressImage.ApplyStyle(progressStyle.Progress);
+ bufferImage.ApplyStyle(progressStyle.Buffer);
+ }
+ }
+
/// <summary>
/// Dispose Progress and all children on it.
/// </summary>
}
}
- private void Initialize()
- {
- // create necessary components
- InitializeTrack();
- InitializeBuffer();
- InitializeProgress();
- }
-
private void InitializeTrack()
{
if (null == trackImage)
PivotPoint = NUI.PivotPoint.TopLeft
};
Add(trackImage);
- trackImage.ApplyStyle(progressStyle.Track);
}
}
PivotPoint = Tizen.NUI.PivotPoint.TopLeft
};
Add(progressImage);
- progressImage.ApplyStyle(progressStyle.Progress);
}
}
PivotPoint = Tizen.NUI.PivotPoint.TopLeft
};
Add(bufferImage);
- bufferImage.ApplyStyle(progressStyle.Buffer);
}
}
}
/*
- * Copyright(c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright(c) 2021 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.
/// <inheritdoc/>
[EditorBrowsable(EditorBrowsableState.Never)]
- public override void ApplyStyle(ViewStyle viewStyle)
- {
- if (viewStyle is ButtonStyle buttonStyle)
- {
- if (buttonStyle.IsSelectable == null)
- {
- buttonStyle.IsSelectable = true;
- }
-
- base.ApplyStyle(buttonStyle);
- }
- }
-
- /// <inheritdoc/>
- [EditorBrowsable(EditorBrowsableState.Never)]
protected override ImageView CreateIcon()
{
return new ImageView
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() { }
/// <summary>
private Size prevSize;
private DefaultLinearItemStyle ItemStyle => ViewStyle as DefaultLinearItemStyle;
- /// <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 DefaultLinearItemStyle Style
- {
- get
- {
- var result = new DefaultLinearItemStyle(ItemStyle);
- result.CopyPropertiesFromView(this);
- if (itemLabel) result.Label.CopyPropertiesFromView(itemLabel);
- if (itemSubLabel) result.SubLabel.CopyPropertiesFromView(itemSubLabel);
- if (itemIcon) result.Icon.CopyPropertiesFromView(itemIcon);
- if (itemExtra) result.Extra.CopyPropertiesFromView(itemExtra);
- if (itemSeperator) result.Seperator.CopyPropertiesFromView(itemSeperator);
-
- return result;
- }
- }
-
static DefaultLinearItem() { }
/// <summary>
private Size prevSize;
private DefaultTitleItemStyle ItemStyle => ViewStyle as DefaultTitleItemStyle;
- /// <summary>
- /// Return a copied Style instance of DefaultTitleItem
- /// </summary>
- /// <remarks>
- /// It returns copied Style instance and changing it does not effect to the DefaultTitleItem.
- /// Style setting is possible by using constructor or the function of ApplyStyle(ViewStyle viewStyle)
- /// </remarks>
- [EditorBrowsable(EditorBrowsableState.Never)]
- public new DefaultTitleItemStyle Style
- {
- get
- {
- var result = new DefaultTitleItemStyle(ItemStyle);
- result.CopyPropertiesFromView(this);
- if (itemLabel) result.Label.CopyPropertiesFromView(itemLabel);
- if (itemIcon) result.Icon.CopyPropertiesFromView(itemIcon);
- if (itemSeperator) result.Seperator.CopyPropertiesFromView(itemSeperator);
-
- return result;
- }
- }
-
static DefaultTitleItem() { }
/// <summary>
if (instance.isEnabled != newEnabled)
{
instance.isEnabled = newEnabled;
- if (instance.ItemStyle != null)
- {
- instance.ItemStyle.IsEnabled = newEnabled;
- }
instance.UpdateState();
}
}
{
instance.isSelected = newSelected;
- if (instance.ItemStyle != null)
- {
- instance.ItemStyle.IsSelected = newSelected;
- }
-
if (instance.isSelectable)
{
instance.UpdateState();
if (instance.isSelectable != newSelectable)
{
instance.isSelectable = newSelectable;
-
- if (instance.ItemStyle != null)
- {
- instance.ItemStyle.IsSelectable = newSelectable;
- }
-
instance.UpdateState();
}
}
private bool isEnabled = true;
private RecyclerViewItemStyle ItemStyle => ViewStyle as RecyclerViewItemStyle;
- /// <summary>
- /// Return a copied Style instance of Toast
- /// </summary>
- /// <remarks>
- /// It returns copied Style instance and changing it does not effect to the Toast.
- /// Style setting is possible by using constructor or the function of ApplyStyle(ViewStyle viewStyle)
- /// </remarks>
- [EditorBrowsable(EditorBrowsableState.Never)]
- public new RecyclerViewItemStyle Style
- {
- get
- {
- var result = new RecyclerViewItemStyle(ItemStyle);
- result.CopyPropertiesFromView(this);
- return result;
- }
- }
-
static RecyclerViewItem() { }
/// <summary>
*/
using System;
using System.ComponentModel;
+using System.Diagnostics;
using Tizen.NUI.BaseComponents;
using Tizen.NUI.Binding;
/// <summary>Bindable property of TrackThickness</summary>
[EditorBrowsable(EditorBrowsableState.Never)]
- public static readonly BindableProperty TrackThicknessProperty = BindableProperty.Create(nameof(TrackThickness), typeof(float), typeof(Scrollbar), default(float), propertyChanged: (bindable, oldValue, newValue) =>
- {
- var instance = ((Scrollbar)bindable);
- var thickness = (float?)newValue;
-
- instance.scrollbarStyle.TrackThickness = thickness;
- instance.UpdateTrackThickness(thickness ?? 0);
- },
- defaultValueCreator: (bindable) =>
- {
- return ((Scrollbar)bindable).scrollbarStyle.TrackThickness ?? 0;
- });
+ public static readonly BindableProperty TrackThicknessProperty = BindableProperty.Create(nameof(TrackThickness), typeof(float), typeof(Scrollbar), default(float),
+ propertyChanged: (bindable, oldValue, newValue) => ((Scrollbar)bindable).UpdateTrackThickness((float?)newValue ?? 0),
+ defaultValueCreator: (bindable) => ((Scrollbar)bindable).trackThickness
+ );
/// <summary>Bindable property of ThumbThickness</summary>
[EditorBrowsable(EditorBrowsableState.Never)]
- public static readonly BindableProperty ThumbThicknessProperty = BindableProperty.Create(nameof(ThumbThickness), typeof(float), typeof(Scrollbar), default(float), propertyChanged: (bindable, oldValue, newValue) =>
- {
- var instance = ((Scrollbar)bindable);
- var thickness = (float?)newValue;
-
- instance.scrollbarStyle.ThumbThickness = thickness;
- instance.UpdateThumbThickness(thickness ?? 0);
- },
- defaultValueCreator: (bindable) =>
- {
- return ((Scrollbar)bindable).scrollbarStyle.ThumbThickness ?? 0;
- });
+ public static readonly BindableProperty ThumbThicknessProperty = BindableProperty.Create(nameof(ThumbThickness), typeof(float), typeof(Scrollbar), default(float),
+ propertyChanged: (bindable, oldValue, newValue) => ((Scrollbar)bindable).UpdateThumbThickness((float?)newValue ?? 0),
+ defaultValueCreator: (bindable) => ((Scrollbar)bindable).thumbThickness
+ );
/// <summary>Bindable property of TrackColor</summary>
[EditorBrowsable(EditorBrowsableState.Never)]
- public static readonly BindableProperty TrackColorProperty = BindableProperty.Create(nameof(TrackColor), typeof(Color), typeof(Scrollbar), null, propertyChanged: (bindable, oldValue, newValue) =>
- {
- var instance = ((Scrollbar)bindable);
- var color = (Color)newValue;
-
- instance.scrollbarStyle.TrackColor = color;
- instance.UpdateTrackColor(color);
- },
- defaultValueCreator: (bindable) =>
- {
- return ((Scrollbar)bindable).scrollbarStyle.TrackColor;
- });
+ public static readonly BindableProperty TrackColorProperty = BindableProperty.Create(nameof(TrackColor), typeof(Color), typeof(Scrollbar), null,
+ propertyChanged: (bindable, oldValue, newValue) => ((Scrollbar)bindable).UpdateTrackColor((Color)newValue),
+ defaultValueCreator: (bindable) => ((Scrollbar)bindable).trackVisual.MixColor
+ );
/// <summary>Bindable property of ThumbColor</summary>
[EditorBrowsable(EditorBrowsableState.Never)]
- public static readonly BindableProperty ThumbColorProperty = BindableProperty.Create(nameof(ThumbColor), typeof(Color), typeof(Scrollbar), null, propertyChanged: (bindable, oldValue, newValue) =>
- {
- var instance = ((Scrollbar)bindable);
- var color = (Color)newValue;
-
- instance.scrollbarStyle.ThumbColor = color;
- instance.UpdateThumbColor(color);
- },
- defaultValueCreator: (bindable) =>
- {
- return ((Scrollbar)bindable).scrollbarStyle.ThumbColor;
- });
+ public static readonly BindableProperty ThumbColorProperty = BindableProperty.Create(nameof(ThumbColor), typeof(Color), typeof(Scrollbar), null,
+ propertyChanged: (bindable, oldValue, newValue) => ((Scrollbar)bindable).UpdateThumbColor((Color)newValue),
+ defaultValueCreator: (bindable) => ((Scrollbar)bindable).thumbVisual.MixColor
+ );
/// <summary>Bindable property of TrackPadding</summary>
[EditorBrowsable(EditorBrowsableState.Never)]
- public static readonly BindableProperty TrackPaddingProperty = BindableProperty.Create(nameof(TrackPadding), typeof(Extents), typeof(Scrollbar), null, propertyChanged: (bindable, oldValue, newValue) =>
- {
- var instance = ((Scrollbar)bindable);
- var trackPadding = (Extents)newValue;
-
- instance.scrollbarStyle.TrackPadding = trackPadding;
- instance.UpdateTrackPadding(trackPadding);
- },
- defaultValueCreator: (bindable) =>
- {
- return ((Scrollbar)bindable).scrollbarStyle.TrackPadding;
- });
+ public static readonly BindableProperty TrackPaddingProperty = BindableProperty.Create(nameof(TrackPadding), typeof(Extents), typeof(Scrollbar), null,
+ propertyChanged: (bindable, oldValue, newValue) => ((Scrollbar)bindable).UpdateTrackPadding((Extents)newValue),
+ defaultValueCreator: (bindable) => ((Scrollbar)bindable).trackPadding
+ );
private ColorVisual trackVisual;
private ColorVisual thumbVisual;
private Animation thumbSizeAnimation;
private Calculator calculator;
private Size containerSize = new Size(0, 0);
- private ScrollbarStyle scrollbarStyle => ViewStyle as ScrollbarStyle;
private bool mScrollEnabled = true;
private float previousPosition;
+ private float trackThickness;
+ private float thumbThickness;
+ private PaddingType trackPadding;
#endregion Fields
/// <inheritdoc/>
[EditorBrowsable(EditorBrowsableState.Never)]
+ public override void OnInitialize()
+ {
+ base.OnInitialize();
+
+ trackVisual = new ColorVisual
+ {
+ SuppressUpdateVisual = true,
+ SizePolicy = VisualTransformPolicyType.Absolute,
+ MixColor = Color.Transparent,
+ };
+ AddVisual("Track", trackVisual);
+
+ thumbVisual = new ColorVisual
+ {
+ SuppressUpdateVisual = true,
+ SizePolicy = VisualTransformPolicyType.Absolute,
+ MixColor = Color.Transparent,
+ };
+ AddVisual("Thumb", thumbVisual);
+ }
+
+ /// <inheritdoc/>
+ [EditorBrowsable(EditorBrowsableState.Never)]
public override void Initialize(float contentLength, float viewportLength, float currentPosition, bool isHorizontal = false)
{
if (isHorizontal)
thumbSizeAnimation?.Stop();
thumbSizeAnimation = null;
- PaddingType ensuredPadding = EnsurePadding(TrackPadding);
- Size trackSize = calculator.CalculateTrackSize(TrackThickness, containerSize, ensuredPadding);
- Vector2 trackPosition = calculator.CalculateTrackPosition(ensuredPadding);
+ Size trackSize = calculator.CalculateTrackSize(TrackThickness, containerSize, trackPadding);
+ Vector2 trackPosition = calculator.CalculateTrackPosition(trackPadding);
Size thumbSize = calculator.CalculateThumbSize(ThumbThickness, trackSize);
- Vector2 thumbPosition = calculator.CalculateThumbPosition(trackSize, thumbSize, ensuredPadding);
-
- trackVisual = new ColorVisual
- {
- SuppressUpdateVisual = true,
- MixColor = TrackColor,
- SizePolicy = VisualTransformPolicyType.Absolute,
- Origin = calculator.CalculatorTrackAlign(),
- AnchorPoint = calculator.CalculatorTrackAlign(),
- Size = trackSize,
- Position = trackPosition,
- };
+ Vector2 thumbPosition = calculator.CalculateThumbPosition(trackSize, thumbSize, trackPadding);
- AddVisual("Track", trackVisual);
+ Debug.Assert(trackVisual != null && thumbVisual != null);
- thumbVisual = new ColorVisual
- {
- SuppressUpdateVisual = true,
- MixColor = ThumbColor,
- SizePolicy = VisualTransformPolicyType.Absolute,
- Origin = calculator.CalculatorThumbAlign(),
- AnchorPoint = calculator.CalculatorThumbAlign(),
- Opacity = calculator.CalculateThumbVisibility() ? 1.0f : 0.0f,
- Size = thumbSize,
- Position = thumbPosition,
- };
+ trackVisual.MixColor = TrackColor;
+ trackVisual.Origin = calculator.CalculatorTrackAlign();
+ trackVisual.AnchorPoint = calculator.CalculatorTrackAlign();
+ trackVisual.Size = trackSize;
+ trackVisual.Position = trackPosition;
+ trackVisual.UpdateVisual(true);
- AddVisual("Thumb", thumbVisual);
+ thumbVisual.MixColor = ThumbColor;
+ thumbVisual.Origin = calculator.CalculatorThumbAlign();
+ thumbVisual.AnchorPoint = calculator.CalculatorThumbAlign();
+ thumbVisual.Opacity = calculator.CalculateThumbVisibility() ? 1.0f : 0.0f;
+ thumbVisual.Size = thumbSize;
+ thumbVisual.Position = thumbPosition;
+ thumbVisual.UpdateVisual(true);
}
/// <inheritdoc/>
calculator.currentPosition = position;
thumbVisual.Size = calculator.CalculateThumbSize(ThumbThickness, trackVisual.Size);
- thumbVisual.Position = calculator.CalculateThumbScrollPosition(trackVisual.Size, thumbVisual.Position, EnsurePadding(TrackPadding));
+ thumbVisual.Position = calculator.CalculateThumbScrollPosition(trackVisual.Size, thumbVisual.Position, trackPadding);
thumbVisual.Opacity = calculator.CalculateThumbVisibility() ? 1.0f : 0.0f;
if (durationMs == 0)
previousPosition = calculator.currentPosition;
calculator.currentPosition = position;
- thumbVisual.Position = calculator.CalculateThumbScrollPosition(trackVisual.Size, thumbVisual.Position, EnsurePadding(TrackPadding));
+ thumbVisual.Position = calculator.CalculateThumbScrollPosition(trackVisual.Size, thumbVisual.Position, trackPadding);
if (durationMs == 0)
{
return;
}
- PaddingType ensuredPadding = EnsurePadding(TrackPadding);
- trackVisual.Size = calculator.CalculateTrackSize(TrackThickness, containerSize, ensuredPadding);
- trackVisual.Position = calculator.CalculateTrackPosition(ensuredPadding);
+ trackVisual.Size = calculator.CalculateTrackSize(TrackThickness, containerSize, trackPadding);
+ trackVisual.Position = calculator.CalculateTrackPosition(trackPadding);
thumbVisual.Size = calculator.CalculateThumbSize(ThumbThickness, trackVisual.Size);
- thumbVisual.Position = calculator.CalculateThumbPosition(trackVisual.Size, thumbVisual.Size, ensuredPadding);
+ thumbVisual.Position = calculator.CalculateThumbPosition(trackVisual.Size, thumbVisual.Size, trackPadding);
trackVisual.UpdateVisual(true);
thumbVisual.UpdateVisual(true);
[EditorBrowsable(EditorBrowsableState.Never)]
protected virtual void UpdateTrackThickness(float thickness)
{
- if (trackVisual == null)
+ trackThickness = thickness;
+
+ if (calculator == null)
{
return;
}
- trackVisual.Size = calculator.CalculateTrackSize(thickness, containerSize, EnsurePadding(TrackPadding));
+ trackVisual.Size = calculator.CalculateTrackSize(thickness, containerSize, trackPadding);
trackVisual.UpdateVisual(true);
}
[EditorBrowsable(EditorBrowsableState.Never)]
protected virtual void UpdateThumbThickness(float thickness)
{
- if (thumbVisual == null)
+ thumbThickness = thickness;
+
+ if (calculator == null)
{
return;
}
/// <summary>
/// Update TrackPadding property of the scrollbar.
/// </summary>
- /// <param name="trackPadding">The padding of the track.</param>
- protected virtual void UpdateTrackPadding(Extents trackPadding)
+ /// <param name="padding">The padding of the track.</param>
+ protected virtual void UpdateTrackPadding(Extents padding)
{
+ trackPadding = padding == null ? new PaddingType(0, 0, 0, 0) : new PaddingType(padding.Start, padding.End, padding.Top, padding.Bottom);
+
if (calculator == null)
{
return;
}
- PaddingType ensuredPadding = EnsurePadding(trackPadding);
- trackVisual.Size = calculator.CalculateTrackSize(TrackThickness, containerSize, ensuredPadding);
- trackVisual.Position = calculator.CalculateTrackPosition(ensuredPadding);
+ trackVisual.Size = calculator.CalculateTrackSize(TrackThickness, containerSize, trackPadding);
+ trackVisual.Position = calculator.CalculateTrackPosition(trackPadding);
thumbVisual.Size = calculator.CalculateThumbSize(ThumbThickness, trackVisual.Size);
- thumbVisual.Position = calculator.CalculateThumbPaddingPosition(trackVisual.Size, thumbVisual.Size, thumbVisual.Position, ensuredPadding);
+ thumbVisual.Position = calculator.CalculateThumbPaddingPosition(trackVisual.Size, thumbVisual.Size, thumbVisual.Position, trackPadding);
trackVisual.UpdateVisual(true);
thumbVisual.UpdateVisual(true);
}
}
- private PaddingType EnsurePadding(Extents padding) => padding == null ? new PaddingType(0, 0, 0, 0) : new PaddingType(padding.Start, padding.End, padding.Top, padding.Bottom);
+ // private PaddingType EnsurePadding(Extents padding) => padding == null ? new PaddingType(0, 0, 0, 0) : new PaddingType(padding.Start, padding.End, padding.Top, padding.Bottom);
#endregion Methods
/*
- * Copyright(c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright(c) 2021 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.
[EditorBrowsable(EditorBrowsableState.Never)]
public SelectButton() : base()
{
- Initialize();
}
/// <summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public SelectButton(string style) : base(style)
{
- Initialize();
}
/// <summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public SelectButton(ButtonStyle buttonStyle) : base(buttonStyle)
{
- Initialize();
}
/// <summary>
}
}
+ /// <inheritdoc/>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override void OnInitialize()
+ {
+ base.OnInitialize();
+ IsSelectable = true;
+ }
+
/// <summary>
/// Dispose SelectButton and all children on it.
/// </summary>
{
}
- private void Initialize()
- {
- IsSelectable = true;
- }
-
/// <inheritdoc/>
[EditorBrowsable(EditorBrowsableState.Never)]
protected override void OnControlStateChanged(ControlStateChangedEventArgs info)
{
if (lowIndicatorImage != null && lowIndicatorImage != null && lowIndicatorImage.Size != null)
{
- lowIndicatorImage.Size = sliderStyle.LowIndicatorImage.Size;
+ lowIndicatorImage.Size = lowIndicatorSize ?? (ViewStyle as SliderStyle)?.LowIndicatorImage.Size;
}
if (lowIndicatorText != null && lowIndicatorText != null && lowIndicatorText.Size != null)
{
- lowIndicatorText.Size = sliderStyle.LowIndicator.Size;
+ lowIndicatorText.Size = lowIndicatorSize ?? (ViewStyle as SliderStyle)?.LowIndicator.Size;
}
}
}
}
else
{
- if (sliderStyle != null && sliderStyle.TrackThickness != null)
+ if (ViewStyle is SliderStyle sliderStyle && sliderStyle.TrackThickness != null)
{
curTrackThickness = sliderStyle.TrackThickness.Value;
}
}
else
{
- if (sliderStyle != null && sliderStyle.TrackPadding != null)
+ if (ViewStyle is SliderStyle sliderStyle && sliderStyle.TrackPadding != null)
{
curSpace = sliderStyle.TrackPadding.Start;
}
private IndicatorType CurrentIndicatorType()
{
IndicatorType type = IndicatorType.None;
- if (sliderStyle != null)
+ if (ViewStyle is SliderStyle sliderStyle)
{
type = (IndicatorType)sliderStyle.IndicatorType;
}
}
else
{
- if (sliderStyle != null && sliderStyle.LowIndicatorImage != null && sliderStyle.LowIndicatorImage.Size != null)
+ if (ViewStyle is SliderStyle sliderStyle && sliderStyle.LowIndicatorImage != null && sliderStyle.LowIndicatorImage.Size != null)
{
size = sliderStyle.LowIndicatorImage.Size;
}
}
else
{
- if (sliderStyle != null && sliderStyle.HighIndicatorImage != null && sliderStyle.HighIndicatorImage.Size != null)
+ if (ViewStyle is SliderStyle sliderStyle && sliderStyle.HighIndicatorImage != null && sliderStyle.HighIndicatorImage.Size != null)
{
size = sliderStyle.HighIndicatorImage.Size;
}
}
else
{
- if (sliderStyle != null && sliderStyle.LowIndicator != null && sliderStyle.LowIndicator.Size != null)
+ if (ViewStyle is SliderStyle sliderStyle && sliderStyle.LowIndicator != null && sliderStyle.LowIndicator.Size != null)
{
size = sliderStyle.LowIndicator.Size;
}
}
else
{
- if (sliderStyle != null && sliderStyle.HighIndicator != null && sliderStyle.HighIndicator.Size != null)
+ if (ViewStyle is SliderStyle sliderStyle && sliderStyle.HighIndicator != null && sliderStyle.HighIndicator.Size != null)
{
size = sliderStyle.HighIndicator.Size;
}
{
string newText = (string)newValue;
instance.valueIndicatorText.Text = newText;
- if (instance.sliderStyle != null)
- {
- instance.sliderStyle.ValueIndicatorText.Text = newText;
- }
}
},
defaultValueCreator: (bindable) =>
}
/// <summary>
- /// Return a copied Style instance of Slider
+ /// Return currently applied style.
/// </summary>
/// <remarks>
- /// It returns copied Style instance and changing it does not effect to the Slider.
- /// Style setting is possible by using constructor or the function of ApplyStyle(ViewStyle viewStyle)
+ /// Modifying contents in style may cause unexpected behaviour.
/// </remarks>
/// <since_tizen> 8 </since_tizen>
- public new SliderStyle Style
- {
- get
- {
- var result = new SliderStyle(sliderStyle);
- result.CopyPropertiesFromView(this);
- result.Track.CopyPropertiesFromView(bgTrackImage);
- result.Progress.CopyPropertiesFromView(slidedTrackImage);
- result.Thumb.CopyPropertiesFromView(thumbImage);
- result.LowIndicatorImage.CopyPropertiesFromView(lowIndicatorImage);
- result.HighIndicatorImage.CopyPropertiesFromView(highIndicatorImage);
- result.LowIndicator.CopyPropertiesFromView(lowIndicatorText);
- result.HighIndicator.CopyPropertiesFromView(highIndicatorText);
- result.ValueIndicatorText.CopyPropertiesFromView(valueIndicatorText);
- result.ValueIndicatorImage.CopyPropertiesFromView(valueIndicatorImage);
- return result;
- }
- }
-
- /// <summary>
- /// Return a copied Style instance of Slider
- /// </summary>
- private SliderStyle sliderStyle => ViewStyle as SliderStyle;
+ public SliderStyle Style => (SliderStyle)(ViewStyle as SliderStyle)?.Clone();
/// <summary>
/// Gets or sets the direction type of slider.
{
thumbImage.Size = value;
thumbSize = value;
- sliderStyle.Thumb.Size = value;
}
}
}
{
thumbImage.ResourceUrl = value;
thumbImageUrl = value;
- sliderStyle.Thumb.ResourceUrl = value;
}
}
}
{
thumbImage.BackgroundColor = value;
thumbColor = value;
- sliderStyle.Thumb.BackgroundColor = value;
}
}
}
if (null != bgTrackImage)
{
bgTrackImage.BackgroundColor = value;
- sliderStyle.Track.BackgroundColor = value;
}
}
}
if (null != slidedTrackImage)
{
slidedTrackImage.BackgroundColor = value;
- sliderStyle.Progress.BackgroundColor = value;
}
}
}
if (null != warningTrackImage)
{
warningTrackImage.BackgroundColor = value;
- sliderStyle.WarningTrack.BackgroundColor = value;
}
}
}
if (null != warningSlidedTrackImage)
{
warningSlidedTrackImage.BackgroundColor = value;
- sliderStyle.WarningProgress.BackgroundColor = value;
}
}
}
{
if (null == lowIndicatorImage) lowIndicatorImage = new ImageView();
lowIndicatorImage.ResourceUrl = value;
- sliderStyle.LowIndicatorImage.ResourceUrl = value;
}
}
{
if (null == highIndicatorImage) highIndicatorImage = new ImageView();
highIndicatorImage.ResourceUrl = value;
- sliderStyle.HighIndicatorImage.ResourceUrl = value;
}
}
if (null != lowIndicatorText)
{
lowIndicatorText.Text = value;
- sliderStyle.LowIndicator.Text = value;
}
}
}
if (null != highIndicatorText)
{
highIndicatorText.Text = value;
- sliderStyle.HighIndicator.Text = value;
}
}
}
if (null != highIndicatorText)
{
highIndicatorText.Size = value;
- sliderStyle.HighIndicator.Size = value;
}
}
}
if (null != valueIndicatorImage)
{
valueIndicatorImage.Size = value;
- sliderStyle.ValueIndicatorImage.Size = value;
}
}
}
if (null != valueIndicatorImage)
{
valueIndicatorImage.ResourceUrl = value;
- sliderStyle.ValueIndicatorImage.ResourceUrl = value;
}
}
}
/// <since_tizen> 6 </since_tizen>
public Switch() : base()
{
- Initialize();
}
/// <summary>
/// <since_tizen> 8 </since_tizen>
public Switch(string style) : base(style)
{
- Initialize();
}
/// <summary>
/// <since_tizen> 8 </since_tizen>
public Switch(SwitchStyle switchStyle) : base(switchStyle)
{
- Initialize();
}
/// <summary>
{
base.OnInitialize();
SetAccessibilityConstructor(Role.ToggleButton);
+ IsSelectable = true;
+#if PROFILE_MOBILE
+ Feedback = true;
+#endif
}
/// <summary>
public event EventHandler<SelectedChangedEventArgs> SelectedChanged;
/// <summary>
- /// Return a copied Style instance of Switch
+ /// Return currently applied style.
/// </summary>
/// <remarks>
- /// It returns copied Style instance and changing it does not effect to the Switch.
- /// Style setting is possible by using constructor or the function of ApplyStyle(ViewStyle viewStyle)
+ /// Modifying contents in style may cause unexpected behaviour.
/// </remarks>
/// <since_tizen> 8 </since_tizen>
- public new SwitchStyle Style
- {
- get
- {
- var result = new SwitchStyle(ViewStyle as SwitchStyle);
- result.CopyPropertiesFromView(this);
- result.Track.CopyPropertiesFromView(Track);
- result.Thumb.CopyPropertiesFromView(Thumb);
- return result;
- }
- }
+ public new SwitchStyle Style => (SwitchStyle)(ViewStyle as SwitchStyle)?.Clone();
/// <summary>
/// Apply style to switch.
[EditorBrowsable(EditorBrowsableState.Never)]
public override void ApplyStyle(ViewStyle viewStyle)
{
- base.ApplyStyle(viewStyle);
-
SwitchStyle swStyle = viewStyle as SwitchStyle;
if (null != swStyle)
Thumb.ApplyStyle(swStyle.Thumb);
}
}
+
+ base.ApplyStyle(viewStyle);
}
/// <summary>
}
}
- private void Initialize()
- {
- IsSelectable = true;
-#if PROFILE_MOBILE
- Feedback = true;
-#endif
- }
-
private void OnSelect()
{
if (IsHighlighted)
public event EventHandler<ItemChangedEventArgs> ItemChangedEvent;
/// <summary>
- /// Return a copied Style instance of Tab
+ /// Return currently applied style.
/// </summary>
/// <remarks>
- /// It returns copied Style instance and changing it does not effect to the Tab.
- /// Style setting is possible by using constructor or the function of ApplyStyle(ViewStyle viewStyle)
+ /// Modifying contents in style may cause unexpected behaviour.
/// </remarks>
/// <since_tizen> 8 </since_tizen>
- public new TabStyle Style
- {
- get
- {
- var result = new TabStyle(tabStyle);
- result.CopyPropertiesFromView(this);
- result.UnderLine.CopyPropertiesFromView(underline);
- return result;
- }
- }
+ public TabStyle Style => (TabStyle)(ViewStyle as TabStyle)?.Clone();
/// <summary>
/// Get underline of Tab.
var instance = (Toast)bindable;
if (newValue != null)
{
- instance.toastStyle.Duration = (uint)newValue;
if (instance.timer == null)
{
instance.timer = new Timer(instance.duration);
defaultValueCreator: (bindable) =>
{
var instance = (Toast)bindable;
- return instance.toastStyle.Duration ?? instance.duration;
+ return instance.timer == null ? instance.duration : instance.timer.Interval;
});
/// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
private string strText = null;
private Timer timer = null;
private readonly uint duration = 3000;
- private ToastStyle toastStyle => ViewStyle as ToastStyle;
- /// <summary>
- /// Return a copied Style instance of Toast
- /// </summary>
- /// <remarks>
- /// It returns copied Style instance and changing it does not effect to the Toast.
- /// Style setting is possible by using constructor or the function of ApplyStyle(ViewStyle viewStyle)
- /// </remarks>
- [EditorBrowsable(EditorBrowsableState.Never)]
- public new ToastStyle Style
- {
- get
- {
- var result = new ToastStyle(toastStyle);
- result.CopyPropertiesFromView(this);
- result.Text.CopyPropertiesFromView(textLabel);
- return result;
- }
- }
static Toast() { }
/// <summary>
[Obsolete("Deprecated in API8; Will be removed in API10")]
public Toast() : base()
{
- Initialize();
}
/// <summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public Toast(ToastStyle toastStyle) : base(toastStyle)
{
- Initialize();
}
/// <summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public Toast(string style) : base(style)
{
- Initialize();
}
/// <summary>
}
}
+ /// <inheritdoc/>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override void OnInitialize()
+ {
+ base.OnInitialize();
+
+ WidthResizePolicy = ResizePolicyType.FitToChildren;
+ HeightResizePolicy = ResizePolicyType.FitToChildren;
+
+ textLabel = new TextLabel()
+ {
+ PositionUsesPivotPoint = true,
+ ParentOrigin = Tizen.NUI.ParentOrigin.Center,
+ PivotPoint = Tizen.NUI.PivotPoint.Center,
+ WidthResizePolicy = ResizePolicyType.UseNaturalSize,
+ HeightResizePolicy = ResizePolicyType.UseNaturalSize,
+ HorizontalAlignment = HorizontalAlignment.Center,
+ VerticalAlignment = VerticalAlignment.Center,
+ TextColor = Color.White,
+ };
+ this.Add(textLabel);
+
+ this.VisibilityChanged += OnVisibilityChanged;
+ timer = new Timer(duration);
+ timer.Tick += OnTick;
+ }
+
/// <summary>
/// Apply style to toast.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public override void ApplyStyle(ViewStyle viewStyle)
{
- WidthResizePolicy = ResizePolicyType.FitToChildren;
- HeightResizePolicy = ResizePolicyType.FitToChildren;
-
base.ApplyStyle(viewStyle);
- ToastStyle toastStyle = viewStyle as ToastStyle;
-
- if (null != toastStyle)
+ if (viewStyle is ToastStyle toastStyle)
{
- if (null == textLabel)
- {
- textLabel = new TextLabel()
- {
- PositionUsesPivotPoint = true,
- ParentOrigin = Tizen.NUI.ParentOrigin.Center,
- PivotPoint = Tizen.NUI.PivotPoint.Center,
- WidthResizePolicy = ResizePolicyType.UseNaturalSize,
- HeightResizePolicy = ResizePolicyType.UseNaturalSize,
- HorizontalAlignment = HorizontalAlignment.Center,
- VerticalAlignment = VerticalAlignment.Center,
- TextColor = Color.White,
- };
- this.Add(textLabel);
- }
textLabel.ApplyStyle(toastStyle.Text);
}
}
return new ToastStyle();
}
- private void Initialize()
- {
- if (null == textLabel)
- {
- textLabel = new TextLabel()
- {
- PositionUsesPivotPoint = true,
- ParentOrigin = Tizen.NUI.ParentOrigin.Center,
- PivotPoint = Tizen.NUI.PivotPoint.Center,
- WidthResizePolicy = ResizePolicyType.UseNaturalSize,
- HeightResizePolicy = ResizePolicyType.UseNaturalSize,
- HorizontalAlignment = HorizontalAlignment.Center,
- VerticalAlignment = VerticalAlignment.Center,
- TextColor = Color.White,
- };
- this.Add(textLabel);
- }
-
- this.VisibilityChanged += OnVisibilityChanged;
- timer = new Timer(toastStyle.Duration ?? duration);
- timer.Tick += OnTick;
- }
-
private bool OnTick(object sender, EventArgs e)
{
Hide();
/// <summary>The IndicatorImageUrlSelector bindable property.</summary>
[EditorBrowsable(EditorBrowsableState.Never)]
- public static readonly BindableProperty IndicatorImageUrlSelectorProperty = BindableProperty.Create("IndicatorImageUrlSelector", typeof(Selector<string>), typeof(PaginationStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
+ public static readonly BindableProperty IndicatorImageUrlSelectorProperty = BindableProperty.Create("IndicatorImageUrl", typeof(Selector<string>), typeof(PaginationStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
{
- ((PaginationStyle)bindable).indicatorImageUrl = ((Selector<string>)newValue)?.Clone();
+ ((PaginationStyle)bindable).indicatorImageUrl = (Selector<string>)newValue;
},
defaultValueCreator: (bindable) =>
{
{
Normal = FrameworkInformation.ResourcePath + "nui_component_default_pagination_normal_dot.png",
Selected = FrameworkInformation.ResourcePath + "nui_component_default_pagination_focus_dot.png",
- }
+ },
+ IndicatorSize = new Size(10, 10),
+ IndicatorSpacing = 10,
});
theme.AddStyleWithoutClone("Tizen.NUI.Components.Scrollbar", new ScrollbarStyle()
/*
- * Copyright(c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright(c) 2021 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.
private void Initialize()
{
- circularPaginationStyle = Style as CircularPaginationStyle;
+ circularPaginationStyle = ViewStyle as CircularPaginationStyle;
if (circularPaginationStyle == null)
{
throw new Exception("CircularPagination style is null.");
#region Properties
/// <summary>
- /// Return a copied Style instance of CircularProgress
- /// </summary>
- /// <remarks>
- /// It returns copied Style instance and changing it does not effect to the CircularProgress.
- /// Style setting is possible by using constructor or the function of ApplyStyle(ViewStyle viewStyle)
- /// </remarks>
- [EditorBrowsable(EditorBrowsableState.Never)]
- public new CircularProgressStyle Style
- {
- get
- {
- var result = new CircularProgressStyle(ViewStyle as CircularProgressStyle);
- result.CopyPropertiesFromView(this);
- return result;
- }
- }
-
- /// <summary>
/// The thickness of the track and progress.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
#region Properties
/// <summary>
- /// Return a copied Style instance of CircularScrollbar
- /// </summary>
- /// <remarks>
- /// It returns copied Style instance and changing it does not effect to the CircularScrollbar.
- /// Style setting is possible by using constructor or the function of ApplyStyle(ViewStyle viewStyle)
- /// </remarks>
- [EditorBrowsable(EditorBrowsableState.Never)]
- public CircularScrollbarStyle Style
- {
- get
- {
- var result = new CircularScrollbarStyle(ViewStyle as CircularScrollbarStyle);
- result.CopyPropertiesFromView(this);
- return result;
- }
- }
-
- /// <summary>
/// The thickness of the scrollbar and track.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
#region Properties
/// <summary>
- /// Return a copied Style instance of CircularSlider
- /// </summary>
- /// <remarks>
- /// It returns copied Style instance and changing it does not effect to the CircularSlider.
- /// Style setting is possible by using constructor or the function of ApplyStyle(ViewStyle viewStyle)
- /// </remarks>
- [EditorBrowsable(EditorBrowsableState.Never)]
- public new CircularSliderStyle Style
- {
- get
- {
- var result = new CircularSliderStyle(ViewStyle as CircularSliderStyle);
- result.CopyPropertiesFromView(this);
- return result;
- }
- }
-
- /// <summary>
/// The thickness of the track and progress.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
}
/// <summary>
- /// Return a copied Style instance of the Title.
- /// </summary>
- /// <remarks>
- /// It returns copied style instance so that changing it does not effect to the view.
- /// Style setting is possible by using constructor or the function of <see cref="View.ApplyStyle"/>.
- /// </remarks>
- [EditorBrowsable(EditorBrowsableState.Never)]
- public new TextLabelStyle Style => ViewStyle as TextLabelStyle;
-
- /// <summary>
/// The constructor of the Title class with specific Style.
/// </summary>
/// <param name="textLabelStyle">Construct Style</param>
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
/// <param name="behaviour">CustomView Behaviour</param>
/// <param name="viewStyle">CustomView ViewStyle</param>
[EditorBrowsable(EditorBrowsableState.Never)]
- public CustomView(string typeName, CustomViewBehaviour behaviour, ViewStyle viewStyle) : base(typeName, new ViewWrapperImpl(behaviour), viewStyle)
+ public CustomView(string typeName, CustomViewBehaviour behaviour, ViewStyle viewStyle) : this(typeName, behaviour)
{
- Initialize();
+ InitializeStyle(viewStyle);
}
/// <summary>
}
/// <summary>
- /// This method is called after the control has been initialized.<br />
+ /// This method is called after the CustomView has been initialized.<br />
+ /// After OnInitialize, the view will apply the style if it exists in the theme or it was given from constructor.<br />
/// Derived classes should do any second phase initialization by overriding this method.<br />
/// </summary>
/// <since_tizen> 3 </since_tizen>
viewWrapperImpl.OnTap = new ViewWrapperImpl.OnTapDelegate(OnTap);
viewWrapperImpl.OnLongPress = new ViewWrapperImpl.OnLongPressDelegate(OnLongPress);
- // Make sure CustomView is initialized.
- OnInitialize();
-
// Set the StyleName the name of the View
// We have to do this because the StyleManager on Native side can't workout it out
// This will also ensure that the style of views/visuals initialized above are applied by the style manager.
SetStyleName(this.GetType().Name);
+
+ OnInitialize();
}
}
}
}
}
+ private bool EqualsItem(T a, T b)
+ {
+ return Object.ReferenceEquals(a, b) || (a != null && a.Equals(b));
+ }
+
+ /// <summary>
+ /// Determines whether the specified object is equal to the current object.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override bool Equals(System.Object other)
+ {
+ var x = other as Selector<T>;
+
+ if (x == null || x.SelectorItems.Count != SelectorItems.Count)
+ {
+ return false;
+ }
+
+ if (!EqualsItem(All, x.All))
+ {
+ return false;
+ }
+
+ foreach (var item in SelectorItems)
+ {
+ var found = SelectorItems.Find(i => i.State == item.State);
+
+ if (found == null || !EqualsItem(item.Value, found.Value))
+ {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ /// <summary>
+ /// Serves as the default hash function.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public override int GetHashCode()
+ {
+ int hash = 17;
+ hash = (hash * 23) + (All == null ? 0 : All.GetHashCode());
+ hash = (hash * 23) + SelectorItems.Count;
+
+ // Order of items should not effect to the result value.
+ int itemSum = 0;
+ foreach (var item in SelectorItems)
+ {
+ itemSum += item.State.GetHashCode() + (item.Value == null ? 0 : item.Value.GetHashCode());
+ }
+
+ return (hash * 23) + itemSum;
+ }
+
internal bool HasMultiValue()
{
return SelectorItems.Count > 1;
return cloned;
}
- /// <summary>Create a cloned ViewStyle.</summary>
- [EditorBrowsable(EditorBrowsableState.Never)]
- public void Merge(ViewStyle other)
- {
- CopyFrom(other);
- }
-
/// <summary>
/// Release instance.
/// </summary>
{
return (ViewStyle)Activator.CreateInstance(GetType());
}
+
+ /// <summary>Merge other style into the current style without creating new one.</summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ internal void MergeDirectly(ViewStyle other)
+ {
+ CopyFrom(other);
+ }
+ }
+
+ /// <summary> Extension methods for ViewStyle class.</summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public static class ViewStyleExtension
+ {
+ /// <summary>Merge two styles into the new one.</summary>
+ /// <exception cref="ArgumentException">Thrown when failed because of an invalid parameter.</exception>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public static TOut Merge<TOut>(this TOut value, TOut other) where TOut : Tizen.NUI.BaseComponents.ViewStyle
+ {
+ var newStyle = value.Clone() as TOut;
+
+ newStyle.CopyFrom(other);
+
+ return newStyle;
+ }
}
}
/*
- * Copyright(c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright(c) 2021 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.
[EditorBrowsable(EditorBrowsableState.Never)]
public static bool LayoutingDisabled { get; set; } = true;
- /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
+ /// <summary>
+ /// The style instance applied to this view.
+ /// Note that please do not modify the ViewStyle.
+ /// Modifying ViewStyle will affect other views with same ViewStyle.
+ /// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
- public ViewStyle ViewStyle
+ protected ViewStyle ViewStyle
{
get
{
UpdateStyle();
}
- /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
+ private bool IsViewPropertyDirty(BindableProperty styleProperty)
+ {
+ if (dirtyPropertySet.Count == 0)
+ {
+ return false;
+ }
+
+ if (styleProperty.ReturnType.IsGenericType && styleProperty.ReturnType.GetGenericTypeDefinition() == typeof(Selector<>))
+ {
+ return dirtyPropertySet.Contains(styleProperty.PropertyName.Substring(0, styleProperty.PropertyName.Length - 8));
+ }
+
+ return dirtyPropertySet.Contains(styleProperty.PropertyName);
+ }
+
+ /// <summary>
+ /// Apply style instance to the view.
+ /// Basically it sets the bindable property to the value of the bindable property with same name in the style.
+ /// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public virtual void ApplyStyle(ViewStyle viewStyle)
{
- if (null == viewStyle || this.viewStyle == viewStyle) return;
+ if (viewStyle == null || this.viewStyle == viewStyle) return;
this.viewStyle = viewStyle;
return;
}
+ if (dirtyPropertySet == null)
+ {
+ dirtyPropertySet = new HashSet<string>();
+ }
+
BindableProperty.GetBindablePropertysOfType(GetType(), out var bindablePropertyOfView);
if (bindablePropertyOfView == null)
return;
}
- var dirtyProperties = new BindableProperty[viewStyle.DirtyProperties.Count];
- viewStyle.DirtyProperties.CopyTo(dirtyProperties);
+ var dirtyStyleProperties = new BindableProperty[viewStyle.DirtyProperties.Count];
+ viewStyle.DirtyProperties.CopyTo(dirtyStyleProperties);
- foreach (var sourceProperty in dirtyProperties)
+ foreach (var sourceProperty in dirtyStyleProperties)
{
+ if (blockSetDirty && IsViewPropertyDirty(sourceProperty))
+ {
+ // Skip applying theme style for a property set by user.
+ continue;
+ }
+
var sourceValue = viewStyle.GetValue(sourceProperty);
if (sourceValue == null)
*/
using System;
+using System.Collections.Generic;
using System.ComponentModel;
+using System.Runtime.CompilerServices;
namespace Tizen.NUI.BaseComponents
{
/// <since_tizen> 3 </since_tizen>
public partial class View
{
+ private static bool blockSetDirty = false;
private ViewSelectorData selectorData;
+ private HashSet<string> dirtyPropertySet;
internal string styleName;
shadow.Dispose();
}
- internal void UpdateStyle()
- {
- ViewStyle newStyle;
- if (styleName == null) newStyle = ThemeManager.GetStyle(GetType());
- else newStyle = ThemeManager.GetStyle(styleName);
-
- if (newStyle != null && (viewStyle == null || viewStyle.GetType() == newStyle.GetType())) ApplyStyle(newStyle);
- }
-
/// <summary>
/// Get selector value from the triggerable selector or related property.
/// </summary>
return false;
}
+ /// <summary>
+ /// Call this method from a child class to notify that a change happened on a property.
+ /// </summary>
+ /// <param name="propertyName">The name of the property that changed.</param>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ protected override void OnPropertyChanged([CallerMemberName] string propertyName = null)
+ {
+ base.OnPropertyChanged(propertyName);
+
+ if (!blockSetDirty)
+ {
+ dirtyPropertySet?.Add(propertyName);
+ }
+ }
+
private void DisConnectFromSignals()
{
// Save current CPtr.
SwigCPtr = currentCPtr;
}
+ /// <summary>
+ /// Apply initial style to the view.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ protected void InitializeStyle(ViewStyle style = null)
+ {
+ if (style != null) ApplyStyle(style); // Use given style
+ else UpdateStyle(); // Use style in the current theme
+ }
+
private View ConvertIdToView(uint id)
{
View view = GetParent()?.FindCurrentChildById(id);
return false;
}
- private void InitializeStyle(ViewStyle style)
+ private void UpdateStyle()
{
- if (style != null) ApplyStyle(style.Clone()); // Use given style
- else if (ThemeManager.ThemeApplied) UpdateStyle(); // Use style in the current theme
+ ViewStyle newStyle;
+ if (string.IsNullOrEmpty(styleName)) newStyle = ThemeManager.GetStyleWithoutClone(GetType());
+ else newStyle = ThemeManager.GetStyleWithoutClone(styleName);
+
+ if (newStyle != null)
+ {
+ blockSetDirty = true;
+ ApplyStyle(newStyle);
+ blockSetDirty = false;
+ }
}
private ViewSelectorData EnsureSelectorData() => selectorData ?? (selectorData = new ViewSelectorData());
/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
{
internal ViewWrapperImpl viewWrapperImpl;
- internal ViewWrapper(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn, null)
+ internal ViewWrapper(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
{
}
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
- internal ViewWrapper(string typeName, ViewWrapperImpl implementation, ViewStyle viewStyle) : base(Interop.ViewWrapper.New(typeName, ViewWrapperImpl.getCPtr(implementation)), true, viewStyle)
- {
- viewWrapperImpl = implementation;
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- }
-
/// This will not be public opened.
[EditorBrowsable(EditorBrowsableState.Never)]
protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
var baseStyle = item.Value?.Clone();
if (map.ContainsKey(item.Key))
{
- baseStyle.Merge(map[item.Key]);
+ baseStyle.MergeDirectly(map[item.Key]);
}
map[item.Key] = baseStyle;
}
if (map.TryGetValue(styleName, out ViewStyle style) && style != null && style.GetType() == value.GetType())
{
- style.Merge(value);
+ style.MergeDirectly(value);
}
else
{
}
else if (map.ContainsKey(item.Key) && !item.Value.SolidNull)
{
- map[item.Key].Merge(item.Value);
+ map[item.Key].MergeDirectly(item.Value);
}
else
{
}
else if (map.ContainsKey(item.Key) && !item.Value.SolidNull)
{
- map[item.Key].Merge(item.Value);
+ map[item.Key].MergeDirectly(item.Value);
}
else
{
}
}
- internal static bool ThemeApplied => defaultTheme.Count > 0 || (currentTheme != null && currentTheme.Count > 0);
+ private static bool ThemeApplied => defaultTheme.Count > 0 || (currentTheme != null && currentTheme.Count > 0);
/// <summary>
/// Apply theme to the NUI.
if (theme != null)
{
- CurrentTheme = theme;
+ defaultTheme = theme;
+ NotifyThemeChanged();
return true;
}
public static ViewStyle GetStyle(string styleName)
{
if (styleName == null) throw new ArgumentNullException(nameof(styleName));
-
- if (!ThemeApplied) return null;
-
- return (currentTheme?.GetStyle(styleName) ?? defaultTheme.GetStyle(styleName))?.Clone();
+ return GetStyleWithoutClone(styleName)?.Clone();
}
/// <summary>
public static ViewStyle GetStyle(Type viewType)
{
if (viewType == null) throw new ArgumentNullException(nameof(viewType));
+ return GetStyleWithoutClone(viewType)?.Clone();
+ }
+ /// <summary>
+ /// Load a style with style name in the current theme.
+ /// </summary>
+ /// <param name="styleName">The style name.</param>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ internal static ViewStyle GetStyleWithoutClone(string styleName)
+ {
+ if (!ThemeApplied) return null;
+
+ return currentTheme?.GetStyle(styleName) ?? defaultTheme.GetStyle(styleName);
+ }
+
+ /// <summary>
+ /// Load a style with View type in the current theme.
+ /// </summary>
+ /// <param name="viewType">The type of View.</param>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ internal static ViewStyle GetStyleWithoutClone(Type viewType)
+ {
if (!ThemeApplied) return null;
- return (currentTheme?.GetStyle(viewType) ?? defaultTheme.GetStyle(viewType))?.Clone();
+ return currentTheme?.GetStyle(viewType) ?? defaultTheme.GetStyle(viewType);
}
/// <summary>