From 4389bdc8eb5a4ad3852956870d0dfe119d8e04ef Mon Sep 17 00:00:00 2001 From: zhouleonlei <56956725+zhouleonlei@users.noreply.github.com> Date: Thu, 16 Jul 2020 15:29:34 +0800 Subject: [PATCH] [NUI] Remove bindings between Style and View (#1788) * [NUI] Remove bindings between Style and View * [NUI] Hide toast.style * [NUI] Style of BaseComponent returns copied style. Style of BaseComponent returns copied style. * Add API to create ViewStyle from a View instance. (ViewStyle.CopyPropertiesFromView) * Fix TriggerableSelector to get valid property value from its view. * BaseComponent may not own style instance so reduce size of selectors in BaseComponents. * Fix bugs in applying or retreiving style. Signed-off-by: Jiyun Yang Co-authored-by: Jiyun Yang --- .../Controls/Button.Internal.cs | 57 ++-- src/Tizen.NUI.Components/Controls/Button.cs | 215 +++++-------- src/Tizen.NUI.Components/Controls/ButtonGroup.cs | 26 +- src/Tizen.NUI.Components/Controls/CheckBox.cs | 16 + src/Tizen.NUI.Components/Controls/Control.cs | 10 +- src/Tizen.NUI.Components/Controls/DropDown.cs | 97 +++--- .../Controls/Extension/LottieButtonExtension.cs | 11 +- .../Controls/Extension/SwitchExtension.cs | 4 + src/Tizen.NUI.Components/Controls/Loading.cs | 36 ++- src/Tizen.NUI.Components/Controls/Pagination.cs | 56 ++-- src/Tizen.NUI.Components/Controls/Popup.cs | 133 ++++---- src/Tizen.NUI.Components/Controls/Progress.cs | 58 ++-- src/Tizen.NUI.Components/Controls/RadioButton.cs | 16 + src/Tizen.NUI.Components/Controls/Scrollbar.cs | 31 +- src/Tizen.NUI.Components/Controls/SelectButton.cs | 3 +- .../Controls/Slider.Internal.cs | 38 ++- src/Tizen.NUI.Components/Controls/Slider.cs | 114 ++++--- src/Tizen.NUI.Components/Controls/Switch.cs | 67 ++-- src/Tizen.NUI.Components/Controls/Tab.cs | 113 ++++--- src/Tizen.NUI.Components/Controls/Toast.cs | 63 ++-- .../PreloadStyle/DefaultTheme.cs | 3 +- src/Tizen.NUI.Components/Style/ButtonStyle.cs | 16 +- src/Tizen.NUI.Components/Style/ControlStyle.cs | 1 + src/Tizen.NUI.Components/Style/PaginationStyle.cs | 2 +- src/Tizen.NUI.Components/Style/PopupStyle.cs | 4 +- src/Tizen.NUI.Components/Style/SwitchStyle.cs | 5 +- src/Tizen.NUI.Components/Style/TabStyle.cs | 10 - src/Tizen.NUI.Components/Utils/Selector.cs | 138 ++++---- .../src/public/CircularProgress.cs | 26 +- .../src/public/CircularScrollbar.cs | 40 ++- .../src/public/CircularSlider.cs | 31 +- src/Tizen.NUI.Wearable/src/public/Popup.cs | 6 +- src/Tizen.NUI.Wearable/src/public/Title.cs | 11 +- .../src/public/BaseComponents/ImageView.cs | 82 ++--- .../public/BaseComponents/Style/ImageViewStyle.cs | 23 +- .../src/public/BaseComponents/Style/Selector.cs | 351 ++++++++++----------- .../BaseComponents/Style/StateValueCollection.cs | 9 +- .../public/BaseComponents/Style/TextFieldStyle.cs | 65 ++-- .../public/BaseComponents/Style/TextLabelStyle.cs | 60 ++-- .../src/public/BaseComponents/Style/ViewStyle.cs | 49 ++- .../Style/ViewStyleBindableProperty.cs | 151 ++++++--- .../src/public/BaseComponents/TextField.cs | 216 ++----------- .../BaseComponents/TextFieldBindableProperty.cs | 83 +++++ .../public/BaseComponents/TextFieldSelectorData.cs | 55 ++++ .../src/public/BaseComponents/TextLabel.cs | 187 +++-------- .../BaseComponents/TextLabelBindableProperty.cs | 72 ++++- .../public/BaseComponents/TextLabelSelectorData.cs | 52 +++ src/Tizen.NUI/src/public/BaseComponents/View.cs | 226 +++---------- .../public/BaseComponents/ViewBindableProperty.cs | 142 +++++---- .../src/public/BaseComponents/ViewInternal.cs | 109 ++----- .../src/public/BaseComponents/ViewSelectorData.cs | 80 +++++ src/Tizen.NUI/src/public/Color.cs | 9 + src/Tizen.NUI/src/public/Vector2.cs | 9 + .../src/public/ViewProperty/ICloneable.cs | 37 --- .../src/public/ViewProperty/ImageShadow.cs | 13 +- src/Tizen.NUI/src/public/ViewProperty/Shadow.cs | 11 +- .../src/public/ViewProperty/ShadowBase.cs | 4 +- .../src/public/ViewProperty/TextShadow.cs | 15 +- 58 files changed, 1786 insertions(+), 1781 deletions(-) mode change 100644 => 100755 src/Tizen.NUI.Components/Controls/Scrollbar.cs create mode 100644 src/Tizen.NUI/src/public/BaseComponents/TextFieldSelectorData.cs create mode 100644 src/Tizen.NUI/src/public/BaseComponents/TextLabelSelectorData.cs create mode 100644 src/Tizen.NUI/src/public/BaseComponents/ViewSelectorData.cs delete mode 100644 src/Tizen.NUI/src/public/ViewProperty/ICloneable.cs diff --git a/src/Tizen.NUI.Components/Controls/Button.Internal.cs b/src/Tizen.NUI.Components/Controls/Button.Internal.cs index 840bf73..10652bc 100755 --- a/src/Tizen.NUI.Components/Controls/Button.Internal.cs +++ b/src/Tizen.NUI.Components/Controls/Button.Internal.cs @@ -13,16 +13,8 @@ namespace Tizen.NUI.Components private EventHandler stateChangeHandler; - private bool isSelected = false; - private bool isEnabled = true; private bool isPressed = false; - - private StringSelector textSelector = new StringSelector(); - private StringSelector translatableTextSelector = new StringSelector(); - private ColorSelector textColorSelector = new ColorSelector(); - private FloatSelector pointSizeSelector = new FloatSelector(); - - private StringSelector iconURLSelector = new StringSelector(); + private bool styleApplied = false; /// /// The ButtonExtension instance that is injected by ButtonStyle. @@ -98,6 +90,8 @@ namespace Tizen.NUI.Components [EditorBrowsable(EditorBrowsableState.Never)] protected void UpdateState() { + if (!styleApplied) return; + ControlState sourceState = ControlState; ControlState targetState; @@ -137,21 +131,21 @@ namespace Tizen.NUI.Components [EditorBrowsable(EditorBrowsableState.Never)] protected virtual void MeasureText() { - if (Style.IconRelativeOrientation == null || Icon == null || TextLabel == null) + if (Icon == null || TextLabel == null) { return; } TextLabel.WidthResizePolicy = ResizePolicyType.Fixed; TextLabel.HeightResizePolicy = ResizePolicyType.Fixed; - int textPaddingStart = Style.TextPadding.Start; - int textPaddingEnd = Style.TextPadding.End; - int textPaddingTop = Style.TextPadding.Top; - int textPaddingBottom = Style.TextPadding.Bottom; + int textPaddingStart = buttonStyle.TextPadding.Start; + int textPaddingEnd = buttonStyle.TextPadding.End; + int textPaddingTop = buttonStyle.TextPadding.Top; + int textPaddingBottom = buttonStyle.TextPadding.Bottom; - int iconPaddingStart = Style.IconPadding.Start; - int iconPaddingEnd = Style.IconPadding.End; - int iconPaddingTop = Style.IconPadding.Top; - int iconPaddingBottom = Style.IconPadding.Bottom; + int iconPaddingStart = buttonStyle.IconPadding.Start; + int iconPaddingEnd = buttonStyle.IconPadding.End; + int iconPaddingTop = buttonStyle.IconPadding.Top; + int iconPaddingBottom = buttonStyle.IconPadding.Bottom; if (IconRelativeOrientation == IconOrientation.Top || IconRelativeOrientation == IconOrientation.Bottom) { @@ -173,7 +167,7 @@ namespace Tizen.NUI.Components [EditorBrowsable(EditorBrowsableState.Never)] protected virtual void LayoutChild() { - if (Style.IconRelativeOrientation == null || Icon == null || TextLabel == null) + if (Icon == null || TextLabel == null) { return; } @@ -181,15 +175,15 @@ namespace Tizen.NUI.Components var buttonIcon = Icon; var buttonText = TextLabel; - int textPaddingStart = Style.TextPadding.Start; - int textPaddingEnd = Style.TextPadding.End; - int textPaddingTop = Style.TextPadding.Top; - int textPaddingBottom = Style.TextPadding.Bottom; + int textPaddingStart = buttonStyle.TextPadding.Start; + int textPaddingEnd = buttonStyle.TextPadding.End; + int textPaddingTop = buttonStyle.TextPadding.Top; + int textPaddingBottom = buttonStyle.TextPadding.Bottom; - int iconPaddingStart = Style.IconPadding.Start; - int iconPaddingEnd = Style.IconPadding.End; - int iconPaddingTop = Style.IconPadding.Top; - int iconPaddingBottom = Style.IconPadding.Bottom; + int iconPaddingStart = buttonStyle.IconPadding.Start; + int iconPaddingEnd = buttonStyle.IconPadding.End; + int iconPaddingTop = buttonStyle.IconPadding.Top; + int iconPaddingBottom = buttonStyle.IconPadding.Bottom; switch (IconRelativeOrientation) { @@ -289,7 +283,7 @@ namespace Tizen.NUI.Components ButtonStyle buttonStyle = StyleManager.Instance.GetViewStyle(StyleName) as ButtonStyle; if (buttonStyle != null) { - Style.CopyFrom(buttonStyle); + ApplyStyle(buttonStyle); UpdateUIContent(); } } @@ -335,9 +329,9 @@ namespace Tizen.NUI.Components var stateEnabled = !controlStateChangedInfo.CurrentState.Contains(ControlState.Disabled); - if (isEnabled != stateEnabled) + if (IsEnabled != stateEnabled) { - isEnabled = stateEnabled; + IsEnabled = stateEnabled; } var statePressed = controlStateChangedInfo.CurrentState.Contains(ControlState.Pressed); @@ -354,7 +348,6 @@ namespace Tizen.NUI.Components /// 6 private void Initialize() { - var style = (ButtonStyle)Style; EnableControlStatePropagation = true; UpdateState(); LayoutDirectionChanged += OnLayoutDirectionChanged; @@ -365,7 +358,7 @@ namespace Tizen.NUI.Components MeasureText(); LayoutChild(); - Sensitive = isEnabled; + Sensitive = IsEnabled; } private void OnLayoutDirectionChanged(object sender, LayoutDirectionChangedEventArgs e) diff --git a/src/Tizen.NUI.Components/Controls/Button.cs b/src/Tizen.NUI.Components/Controls/Button.cs index c45c3d2..1662feb 100755 --- a/src/Tizen.NUI.Components/Controls/Button.cs +++ b/src/Tizen.NUI.Components/Controls/Button.cs @@ -36,9 +36,9 @@ namespace Tizen.NUI.Components var instance = (Button)bindable; if (newValue != null) { - if (instance.Style != null && instance.Style.IconRelativeOrientation != (IconOrientation?)newValue) + if (instance.buttonStyle != null && instance.buttonStyle.IconRelativeOrientation != (IconOrientation?)newValue) { - instance.Style.IconRelativeOrientation = (IconOrientation?)newValue; + instance.buttonStyle.IconRelativeOrientation = (IconOrientation?)newValue; instance.UpdateUIContent(); } } @@ -46,7 +46,7 @@ namespace Tizen.NUI.Components defaultValueCreator: (bindable) => { var instance = (Button)bindable; - return instance.Style?.IconRelativeOrientation; + return instance.buttonStyle?.IconRelativeOrientation; }); /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] @@ -55,14 +55,17 @@ namespace Tizen.NUI.Components var instance = (Button)bindable; if (newValue != null) { - instance.isEnabled = (bool)newValue; - instance.UpdateState(); + if (instance.buttonStyle != null && (!instance.styleApplied || instance.buttonStyle.IsEnabled != (bool)newValue)) + { + instance.buttonStyle.IsEnabled = (bool)newValue; + instance.UpdateState(); + } } }, defaultValueCreator: (bindable) => { var instance = (Button)bindable; - return instance.isEnabled; + return instance.buttonStyle?.IsEnabled ?? true; }); /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] @@ -71,14 +74,17 @@ namespace Tizen.NUI.Components var instance = (Button)bindable; if (newValue != null) { - instance.isSelected = (bool)newValue; - instance.UpdateState(); + if (instance.buttonStyle != null && instance.IsSelectable && (!instance.styleApplied || instance.buttonStyle.IsSelected != (bool)newValue)) + { + instance.buttonStyle.IsSelected = (bool)newValue; + instance.UpdateState(); + } } }, defaultValueCreator: (bindable) => { var instance = (Button)bindable; - return instance.isSelected; + return instance.IsSelectable && (instance.buttonStyle.IsSelected ?? false); }); /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] @@ -87,45 +93,48 @@ namespace Tizen.NUI.Components var instance = (Button)bindable; if (newValue != null) { - instance.Style.IsSelectable = (bool)newValue; + if (instance.buttonStyle != null && (!instance.styleApplied || instance.buttonStyle.IsSelectable != (bool)newValue)) + { + instance.buttonStyle.IsSelectable = (bool)newValue; + } } }, defaultValueCreator: (bindable) => { var instance = (Button)bindable; - return instance.Style?.IsSelectable ?? false; + return instance.buttonStyle?.IsSelectable ?? false; }); /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] public static readonly BindableProperty IconPaddingProperty = BindableProperty.Create(nameof(IconPadding), typeof(Extents), typeof(Button), null, propertyChanged: (bindable, oldValue, newValue) => { var instance = (Button)bindable; - if (null != newValue && null != instance.Style?.IconPadding) + if (null != newValue && null != instance.buttonStyle?.IconPadding) { - instance.Style.IconPadding.CopyFrom((Extents)newValue); + instance.buttonStyle.IconPadding.CopyFrom((Extents)newValue); instance.UpdateUIContent(); } }, defaultValueCreator: (bindable) => { var instance = (Button)bindable; - return instance.Style?.IconPadding; + return instance.buttonStyle?.IconPadding; }); /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] public static readonly BindableProperty TextPaddingProperty = BindableProperty.Create(nameof(TextPadding), typeof(Extents), typeof(Button), null, propertyChanged: (bindable, oldValue, newValue) => { var instance = (Button)bindable; - if (null != newValue && null != instance.Style?.TextPadding) + if (null != newValue && null != instance.buttonStyle?.TextPadding) { - instance.Style.TextPadding.CopyFrom((Extents)newValue); + instance.buttonStyle.TextPadding.CopyFrom((Extents)newValue); instance.UpdateUIContent(); } }, defaultValueCreator: (bindable) => { var instance = (Button)bindable; - return instance.Style?.TextPadding; + return instance.buttonStyle?.TextPadding; }); static Button() { } @@ -298,7 +307,18 @@ namespace Tizen.NUI.Components /// Style setting is possible by using constructor or the function of ApplyStyle(ViewStyle viewStyle) /// /// 8 - public new ButtonStyle Style => ViewStyle as ButtonStyle; + 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; + } + } /// /// The text of Button. @@ -308,14 +328,11 @@ namespace Tizen.NUI.Components { get { - return Style?.Text?.Text?.GetValue(ControlState); + return TextLabel.Text; } set { - if (null != Style?.Text) - { - Style.Text.Text = value; - } + TextLabel.Text = value; } } @@ -343,14 +360,11 @@ namespace Tizen.NUI.Components { get { - return Style?.Text?.TranslatableText?.All; + return TextLabel.TranslatableText; } set { - if (null != Style?.Text) - { - Style.Text.TranslatableText = value; - } + TextLabel.TranslatableText = value; } } @@ -362,14 +376,11 @@ namespace Tizen.NUI.Components { get { - return Style?.Text?.PointSize?.All ?? 0; + return TextLabel.PointSize; } set { - if (null != Style?.Text) - { - Style.Text.PointSize = value; - } + TextLabel.PointSize = value; } } @@ -381,14 +392,11 @@ namespace Tizen.NUI.Components { get { - return Style?.Text?.FontFamily.All; + return TextLabel.FontFamily; } set { - if (null != Style?.Text) - { - Style.Text.FontFamily = value; - } + TextLabel.FontFamily = value; } } @@ -400,14 +408,11 @@ namespace Tizen.NUI.Components { get { - return Style?.Text?.TextColor?.All; + return TextLabel.TextColor; } set { - if (null != Style?.Text) - { - Style.Text.TextColor = value; - } + TextLabel.TextColor = value; } } @@ -419,14 +424,11 @@ namespace Tizen.NUI.Components { get { - return Style?.Text?.HorizontalAlignment ?? HorizontalAlignment.Center; + return TextLabel.HorizontalAlignment; } set { - if (null != Style?.Text) - { - Style.Text.HorizontalAlignment = value; - } + TextLabel.HorizontalAlignment = value; } } @@ -438,135 +440,67 @@ namespace Tizen.NUI.Components { get { - return Style?.Icon?.ResourceUrl?.All; + return Icon.ResourceUrl; } set { - if (null != Style?.Icon) - { - Style.Icon.ResourceUrl = value; - } + Icon.ResourceUrl = value; } } /// /// Text string selector in Button. + /// Getter returns copied selector value if exist, null otherwise. /// /// 6 public StringSelector TextSelector { - get - { - return textSelector; - } - set - { - if (value == null || textSelector == null) - { - Tizen.Log.Fatal("NUI", "[Exception] Button.TextSelector is null"); - throw new NullReferenceException("Button.TextSelector is null"); - } - else - { - textSelector.Clone(value); - } - } + get => buttonText == null ? null : new StringSelector((Selector)buttonText.GetValue(TextLabel.TextSelectorProperty)); + set => buttonText?.SetValue(TextLabel.TextSelectorProperty, value); } /// /// Translateable text string selector in Button. + /// Getter returns copied selector value if exist, null otherwise. /// /// 6 public StringSelector TranslatableTextSelector { - get - { - return translatableTextSelector; - } - set - { - if (value == null || translatableTextSelector == null) - { - Tizen.Log.Fatal("NUI", "[Exception] Button.TranslatableTextSelector is null"); - throw new NullReferenceException("Button.TranslatableTextSelector is null"); - } - else - { - translatableTextSelector.Clone(value); - } - } + get => buttonText == null ? null : new StringSelector((Selector)buttonText.GetValue(TextLabel.TranslatableTextSelectorProperty)); + set => buttonText?.SetValue(TextLabel.TranslatableTextSelectorProperty, value); } /// /// Text color selector in Button. + /// Getter returns copied selector value if exist, null otherwise. /// /// 6 public ColorSelector TextColorSelector { - get - { - return textColorSelector; - } - set - { - if (value == null || textColorSelector == null) - { - Tizen.Log.Fatal("NUI", "[Exception] Button.textColorSelector is null"); - throw new NullReferenceException("Button.textColorSelector is null"); - } - else - { - textColorSelector.Clone(value); - } - } + get => buttonText == null ? null : new ColorSelector((Selector)buttonText.GetValue(TextLabel.TextColorSelectorProperty)); + set => buttonText?.SetValue(TextLabel.TextColorSelectorProperty, value); } /// /// Text font size selector in Button. + /// Getter returns copied selector value if exist, null otherwise. /// /// 6 public FloatSelector PointSizeSelector { - get - { - return pointSizeSelector; - } - set - { - if (value == null || pointSizeSelector == null) - { - Tizen.Log.Fatal("NUI", "[Exception] Button.pointSizeSelector is null"); - throw new NullReferenceException("Button.pointSizeSelector is null"); - } - else - { - pointSizeSelector.Clone(value); - } - } + get => buttonText == null ? null : new FloatSelector((Selector)buttonText.GetValue(TextLabel.PointSizeSelectorProperty)); + set => buttonText?.SetValue(TextLabel.PointSizeSelectorProperty, value); } /// /// Icon image's resource url selector in Button. + /// Getter returns copied selector value if exist, null otherwise. /// /// 6 public StringSelector IconURLSelector { - get - { - return iconURLSelector; - } - set - { - if (value == null || iconURLSelector == null) - { - Tizen.Log.Fatal("NUI", "[Exception] Button.iconURLSelector is null"); - throw new NullReferenceException("Button.iconURLSelector is null"); - } - else - { - iconURLSelector.Clone(value); - } - } + get => buttonIcon == null ? null : new StringSelector((Selector)buttonText.GetValue(ImageView.ResourceUrlSelectorProperty)); + set => buttonIcon?.SetValue(ImageView.ResourceUrlSelectorProperty, value); } /// @@ -637,6 +571,8 @@ namespace Tizen.NUI.Components set => SetValue(TextPaddingProperty, value); } + private ButtonStyle buttonStyle => ViewStyle as ButtonStyle; + /// /// Called after a key event is received by the view that has had its focus set. /// @@ -662,11 +598,11 @@ namespace Tizen.NUI.Components { if (key.KeyPressedName == "Return") { - bool clicked = isPressed && isEnabled; + bool clicked = isPressed && IsEnabled; isPressed = false; - if (Style.IsSelectable != null && Style.IsSelectable == true) + if (IsSelectable) { IsSelected = !IsSelected; } @@ -734,11 +670,11 @@ namespace Tizen.NUI.Components return true; case PointStateType.Up: { - bool clicked = isPressed && isEnabled; + bool clicked = isPressed && IsEnabled; isPressed = false; - if (Style.IsSelectable != null && Style.IsSelectable == true) + if (IsSelectable) { Extension?.SetTouchInfo(touch); IsSelected = !IsSelected; @@ -770,9 +706,10 @@ namespace Tizen.NUI.Components /// 8 public override void ApplyStyle(ViewStyle viewStyle) { + styleApplied = false; + base.ApplyStyle(viewStyle); - ButtonStyle buttonStyle = viewStyle as ButtonStyle; if (null != buttonStyle) { Extension = buttonStyle.CreateExtension(); @@ -791,6 +728,8 @@ namespace Tizen.NUI.Components Icon?.ApplyStyle(buttonStyle.Icon); } } + + styleApplied = true; } /// diff --git a/src/Tizen.NUI.Components/Controls/ButtonGroup.cs b/src/Tizen.NUI.Components/Controls/ButtonGroup.cs index 7f47b75..8859ca8 100755 --- a/src/Tizen.NUI.Components/Controls/ButtonGroup.cs +++ b/src/Tizen.NUI.Components/Controls/ButtonGroup.cs @@ -38,7 +38,7 @@ namespace Tizen.NUI.Components { foreach (Button btn in btGroup.itemGroup) { - btn.Style.SizeHeight = (float)newValue; + btn.SizeHeight = (float)newValue; } btGroup.itemheight = (float)newValue; } @@ -58,7 +58,7 @@ namespace Tizen.NUI.Components { foreach (Button btn in btGroup.itemGroup) { - btn.Style.Text.PointSize = (float)newValue; + btn.TextLabel.PointSize = (float)newValue; } btGroup.itemPointSize = (float)newValue; } @@ -78,7 +78,7 @@ namespace Tizen.NUI.Components { foreach (Button btn in btGroup.itemGroup) { - btn.Style.Text.FontFamily = (string)newValue; + btn.TextLabel.FontFamily = (string)newValue; } btGroup.itemFontFamily = (string)newValue; } @@ -98,7 +98,7 @@ namespace Tizen.NUI.Components { foreach (Button btn in btGroup.itemGroup) { - btn.Style.Text.TextColor = (Color)newValue; + btn.TextLabel.TextColor = (Color)newValue; } btGroup.itemTextColor = (Color)newValue; } @@ -118,7 +118,7 @@ namespace Tizen.NUI.Components { foreach (Button btn in btGroup.itemGroup) { - btn.Style.Text.HorizontalAlignment = (HorizontalAlignment)newValue; + btn.TextLabel.HorizontalAlignment = (HorizontalAlignment)newValue; } btGroup.itemTextAlignment = (HorizontalAlignment)newValue; } @@ -138,7 +138,7 @@ namespace Tizen.NUI.Components { foreach (Button btn in btGroup.itemGroup) { - btn.Style.Overlay.BackgroundColor = (Selector)newValue; + btn.OverlayImage.BackgroundColor = ((Selector)newValue).All; } btGroup.overLayBackgroundColorSelector = (Selector)newValue; } @@ -157,12 +157,8 @@ namespace Tizen.NUI.Components if (btGroup.itemGroup != null && newValue != null) { foreach (Button btn in btGroup.itemGroup) - { - if (btn.Style.BackgroundImage == null) - { - btn.Style.BackgroundImage = new Selector(); - } - btn.Style.BackgroundImage = (string)newValue; + { + btn.BackgroundImage = (string)newValue; } btGroup.itemBackgroundImageUrl = (string)newValue; } @@ -203,7 +199,7 @@ namespace Tizen.NUI.Components var shadow = (ImageShadow)newValue; foreach (Button btn in btGroup.itemGroup) { - btn.Style.ImageShadow = new ImageShadow(shadow); + btn.ImageShadow = new ImageShadow(shadow); } btGroup.itemImageShadow = new ImageShadow(shadow); } @@ -363,7 +359,7 @@ namespace Tizen.NUI.Components { for (int i = Count - 1; i >= 0; i--) { - itemGroup[i].Style.PositionX = pos; + itemGroup[i].PositionX = pos; pos += (int)(itemGroup[i].Size.Width); } } @@ -371,7 +367,7 @@ namespace Tizen.NUI.Components { for (int i = 0; i < Count; i++) { - itemGroup[i].Style.PositionX = pos; + itemGroup[i].PositionX = pos; pos += (int)(itemGroup[i].Size.Width); } } diff --git a/src/Tizen.NUI.Components/Controls/CheckBox.cs b/src/Tizen.NUI.Components/Controls/CheckBox.cs index bc3d837..a032508 100755 --- a/src/Tizen.NUI.Components/Controls/CheckBox.cs +++ b/src/Tizen.NUI.Components/Controls/CheckBox.cs @@ -15,6 +15,7 @@ * */ using System.ComponentModel; +using Tizen.NUI.BaseComponents; namespace Tizen.NUI.Components { @@ -59,5 +60,20 @@ namespace Tizen.NUI.Components base.ItemGroup = value; } } + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override void ApplyStyle(ViewStyle viewStyle) + { + if (viewStyle is ButtonStyle buttonStyle) + { + if (buttonStyle.IsSelectable == null) + { + buttonStyle.IsSelectable = true; + } + + base.ApplyStyle(buttonStyle); + } + } } } diff --git a/src/Tizen.NUI.Components/Controls/Control.cs b/src/Tizen.NUI.Components/Controls/Control.cs index 54e86c8..60575ad 100755 --- a/src/Tizen.NUI.Components/Controls/Control.cs +++ b/src/Tizen.NUI.Components/Controls/Control.cs @@ -50,7 +50,7 @@ namespace Tizen.NUI.Components /// 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 => ViewStyle as ControlStyle; + public new ControlStyle Style => (ControlStyle)ViewStyle.Clone(); static Control() { } @@ -293,10 +293,6 @@ namespace Tizen.NUI.Components /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] - protected virtual void RegisterDetectionOfSubstyleChanges() { } - - /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] protected override ViewStyle CreateViewStyle() { return new ControlStyle(); @@ -304,10 +300,6 @@ namespace Tizen.NUI.Components private void Initialize() { - ControlState = ControlState.Normal; - - RegisterDetectionOfSubstyleChanges(); - LeaveRequired = true; StateFocusableOnTouchMode = false; diff --git a/src/Tizen.NUI.Components/Controls/DropDown.cs b/src/Tizen.NUI.Components/Controls/DropDown.cs index b9737fe..e8fcda0 100755 --- a/src/Tizen.NUI.Components/Controls/DropDown.cs +++ b/src/Tizen.NUI.Components/Controls/DropDown.cs @@ -37,14 +37,14 @@ namespace Tizen.NUI.Components var instance = (DropDown)bindable; if (newValue != null) { - instance.listPadding.CopyFrom((Extents)newValue); + instance.dropDownStyle.ListPadding.CopyFrom((Extents)newValue); instance.UpdateDropDown(); } }, defaultValueCreator: (bindable) => { var instance = (DropDown)bindable; - return instance.listPadding; + return instance.dropDownStyle.ListPadding; }); /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] @@ -54,7 +54,7 @@ namespace Tizen.NUI.Components if (newValue != null) { int selectedItemIndex = (int)newValue; - if (selectedItemIndex == instance.selectedItemIndex || instance.adapter == null || selectedItemIndex < 0 || selectedItemIndex >= instance.adapter.GetItemCount()) + if (selectedItemIndex == instance.dropDownStyle.SelectedItemIndex || instance.adapter == null || selectedItemIndex < 0 || selectedItemIndex >= instance.adapter.GetItemCount()) { return; } @@ -64,7 +64,7 @@ namespace Tizen.NUI.Components defaultValueCreator: (bindable) => { var instance = (DropDown)bindable; - return instance.selectedItemIndex; + return instance.dropDownStyle.SelectedItemIndex; }); /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] @@ -73,14 +73,14 @@ namespace Tizen.NUI.Components var instance = (DropDown)bindable; if (newValue != null) { - instance.listMargin.CopyFrom((Extents)newValue); + instance.dropDownStyle.ListMargin.CopyFrom((Extents)newValue); instance.UpdateDropDown(); } }, defaultValueCreator: (bindable) => { var instance = (DropDown)bindable; - return instance.listMargin; + return instance.dropDownStyle.ListMargin; }); /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] @@ -89,14 +89,14 @@ namespace Tizen.NUI.Components var instance = (DropDown)bindable; if (newValue != null) { - instance.listRelativeOrientation = (ListOrientation)newValue; + instance.dropDownStyle.ListRelativeOrientation = (ListOrientation)newValue; instance.UpdateDropDown(); } }, defaultValueCreator: (bindable) => { var instance = (DropDown)bindable; - return instance.listRelativeOrientation; + return instance.dropDownStyle.ListRelativeOrientation; }); /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] @@ -105,13 +105,13 @@ namespace Tizen.NUI.Components var instance = (DropDown)bindable; if (newValue != null) { - instance.spaceBetweenButtonTextAndIcon = (int)newValue; + instance.dropDownStyle.SpaceBetweenButtonTextAndIcon = (int)newValue; } }, defaultValueCreator: (bindable) => { var instance = (DropDown)bindable; - return instance.spaceBetweenButtonTextAndIcon; + return instance.dropDownStyle.SpaceBetweenButtonTextAndIcon; }); #region DropDown @@ -128,11 +128,6 @@ namespace Tizen.NUI.Components private DropDownItemView selectedItemView = null; private TapGestureDetector tapGestureDetector = null; - private Extents listMargin = new Extents(0, 0, 0, 0); - private Extents listPadding = new Extents(0, 0, 0, 0); - private ListOrientation listRelativeOrientation = ListOrientation.Left; - private int selectedItemIndex = -1; - private int spaceBetweenButtonTextAndIcon = 0; private bool itemPressed = false; static DropDown() { } @@ -309,14 +304,18 @@ namespace Tizen.NUI.Components /// /// This will be public opened in tizen_next after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] - //public new DropDownStyle Style - //{ - // get - // { - // return new DropDownStyle(ViewStyle as DropDownStyle); - // } - //} - public new DropDownStyle Style => ViewStyle as DropDownStyle; + public new DropDownStyle Style + { + get + { + var result = new DropDownStyle(dropDownStyle); + result.CopyPropertiesFromView(this); + result.Button.CopyPropertiesFromView(Button); + result.HeaderText.CopyPropertiesFromView(HeaderText); + result.ListBackgroundImage.CopyPropertiesFromView(ListBackgroundImage); + return result; + } + } /// /// Space between button text and button icon in DropDown. @@ -381,6 +380,8 @@ namespace Tizen.NUI.Components set => SetValue(ListPaddingProperty, value); } + private DropDownStyle dropDownStyle => ViewStyle as DropDownStyle; + /// /// Add list item by item data. The added item will be added to end of all items automatically. /// @@ -407,13 +408,13 @@ namespace Tizen.NUI.Components if (index < 0 || index >= adapter?.GetItemCount()) return; if (null == dropDownMenuFullList) return; - if (selectedItemIndex == index) + if (dropDownStyle.SelectedItemIndex == index) { - selectedItemIndex = -1; + dropDownStyle.SelectedItemIndex = -1; } - else if(selectedItemIndex > index) + else if(dropDownStyle.SelectedItemIndex > index) { - selectedItemIndex--; + dropDownStyle.SelectedItemIndex--; } adapter?.RemoveData(index); @@ -445,9 +446,9 @@ namespace Tizen.NUI.Components return; } - if (selectedItemIndex >= index) + if (dropDownStyle.SelectedItemIndex >= index) { - selectedItemIndex++; + dropDownStyle.SelectedItemIndex++; } adapter.InsertData(index, item); @@ -518,22 +519,22 @@ namespace Tizen.NUI.Components protected void UpdateDropDown() { if (null == scrollableBase || null == listBackgroundImage || null == dropDownMenuFullList) return; - if (null == Style.ListBackgroundImage.Size) return; + if (null == ListBackgroundImage.Size) return; // Resize and position scrolling list within the drop down list container. Can be used to position list in relation to the background image. - scrollableBase.Size = Style.ListBackgroundImage.Size - new Size((listPadding.Start + listPadding.End), (listPadding.Top + listPadding.Bottom), 0); - scrollableBase.Position2D = new Position2D(listPadding.Start, listPadding.Top); + scrollableBase.Size = ListBackgroundImage.Size - new Size((dropDownStyle.ListPadding.Start + dropDownStyle.ListPadding.End), (dropDownStyle.ListPadding.Top + dropDownStyle.ListPadding.Bottom), 0); + scrollableBase.Position2D = new Position2D(dropDownStyle.ListPadding.Start, dropDownStyle.ListPadding.Top); int listBackgroundImageX = 0; int listBackgroundImageY = 0; - if (listRelativeOrientation == ListOrientation.Left) + if (dropDownStyle.ListRelativeOrientation == ListOrientation.Left) { - listBackgroundImageX = (int)listMargin.Start; - listBackgroundImageY = (int)listMargin.Top; + listBackgroundImageX = (int)dropDownStyle.ListMargin.Start; + listBackgroundImageY = (int)dropDownStyle.ListMargin.Top; } - else if (listRelativeOrientation == ListOrientation.Right) + else if (dropDownStyle.ListRelativeOrientation == ListOrientation.Right) { - listBackgroundImageX = -(int)listMargin.End; - listBackgroundImageY = (int)listMargin.Top; + listBackgroundImageX = -(int)dropDownStyle.ListMargin.End; + listBackgroundImageY = (int)dropDownStyle.ListMargin.Top; } listBackgroundImage.Position2D = new Position2D(listBackgroundImageX, listBackgroundImageY); dropDownMenuFullList?.Layout?.RequestLayout(); @@ -547,11 +548,11 @@ namespace Tizen.NUI.Components float buttonTextWidth = 0; if (null != buttonText) { - buttonText.Text = Style.Button.Text.Text.All; - buttonText.PointSize = Style.Button.Text.PointSize?.GetValue(ControlState) ?? StyleManager.PointSizeNormal; + buttonText.Text = Button.TextLabel.Text; + buttonText.PointSize = Button.TextLabel.PointSize; buttonTextWidth = buttonText.NaturalSize.Width; } - float fitWidth = (Style.Button.Icon.Size?.Width ?? 48) + Style.SpaceBetweenButtonTextAndIcon + buttonTextWidth; + float fitWidth = (Button.Icon.Size?.Width ?? 48) + dropDownStyle.SpaceBetweenButtonTextAndIcon + buttonTextWidth; fitWidth += (button.IconPadding.Start + button.IconPadding.End); button.Size.Width = Math.Max(button.Size.Width, fitWidth); RelayoutRequest(); @@ -567,9 +568,9 @@ namespace Tizen.NUI.Components } } // Set selection icon on View - if (selectedItemIndex > 0) + if (dropDownStyle.SelectedItemIndex > 0) { - SetListItemToSelected((uint)selectedItemIndex, selectedItemView); + SetListItemToSelected((uint)dropDownStyle.SelectedItemIndex, selectedItemView); } } @@ -721,7 +722,7 @@ namespace Tizen.NUI.Components private void SetListItemToSelected(uint index) { - if (dropDownMenuFullList == null || index == selectedItemIndex) + if (dropDownMenuFullList == null || index == dropDownStyle.SelectedItemIndex) { return; } @@ -739,20 +740,20 @@ namespace Tizen.NUI.Components if (selectedItemView != null) { selectedItemView.IsSelected = false; - adapter.GetData(selectedItemIndex).IsSelected = false; + adapter.GetData(dropDownStyle.SelectedItemIndex).IsSelected = false; } if (view == null || index >= dropDownMenuFullList.ChildCount) { - selectedItemIndex = -1; + dropDownStyle.SelectedItemIndex = -1; selectedItemView = null; return; } - selectedItemIndex = (int)index; + dropDownStyle.SelectedItemIndex = (int)index; selectedItemView = view; selectedItemView.IsSelected = true; - adapter.GetData(selectedItemIndex).IsSelected = true; + adapter.GetData(dropDownStyle.SelectedItemIndex).IsSelected = true; dropDownMenuFullList.Layout?.RequestLayout(); } diff --git a/src/Tizen.NUI.Components/Controls/Extension/LottieButtonExtension.cs b/src/Tizen.NUI.Components/Controls/Extension/LottieButtonExtension.cs index 26d3ee6..cdb194b 100644 --- a/src/Tizen.NUI.Components/Controls/Extension/LottieButtonExtension.cs +++ b/src/Tizen.NUI.Components/Controls/Extension/LottieButtonExtension.cs @@ -70,12 +70,19 @@ namespace Tizen.NUI.Components.Extension var lottieStyle = (ILottieButtonStyle)button.Style; lottieView.URL = lottieStyle.LottieUrl; lottieView.StopBehavior = LottieAnimationView.StopBehaviorType.MaximumFrame; - lottieStyle.PlayRange?.GetValue(ControlState.Normal)?.Show(lottieView, true); + if (lottieStyle.PlayRange != null && lottieStyle.PlayRange.GetValue(ControlState.Normal, out var result)) + { + result.Show(lottieView, true); + } } internal static void UpdateLottieView(Button button, ControlState previousState, LottieAnimationView lottieView) { - ((ILottieButtonStyle)button.Style).PlayRange?.GetValue(button.ControlState)?.Show(lottieView, !previousState.Contains(ControlState.Pressed)); + var lottieStyle = ((ILottieButtonStyle)button.Style); + if (lottieStyle.PlayRange != null && lottieStyle.PlayRange.GetValue(button.ControlState, out var result)) + { + result.Show(lottieView, !previousState.Contains(ControlState.Pressed)); + } } } } diff --git a/src/Tizen.NUI.Components/Controls/Extension/SwitchExtension.cs b/src/Tizen.NUI.Components/Controls/Extension/SwitchExtension.cs index 2215068..8868d8b 100644 --- a/src/Tizen.NUI.Components/Controls/Extension/SwitchExtension.cs +++ b/src/Tizen.NUI.Components/Controls/Extension/SwitchExtension.cs @@ -50,6 +50,10 @@ namespace Tizen.NUI.Components.Extension [EditorBrowsable(EditorBrowsableState.Never)] public virtual ImageView OnCreateThumb(Switch switchButton, ImageView thumb) { + if (switchButton.IsSelected) + { + OnSelectedChanged(switchButton); + } return thumb; } diff --git a/src/Tizen.NUI.Components/Controls/Loading.cs b/src/Tizen.NUI.Components/Controls/Loading.cs index dba3544..a45c0fc 100755 --- a/src/Tizen.NUI.Components/Controls/Loading.cs +++ b/src/Tizen.NUI.Components/Controls/Loading.cs @@ -35,14 +35,14 @@ namespace Tizen.NUI.Components var instance = (Loading)bindable; if (newValue != null) { - instance.Style.Images = (string[])newValue; + instance.loadingStyle.Images = (string[])newValue; instance.imageVisual.URLS = new List((string[])newValue); } }, defaultValueCreator: (bindable) => { var instance = (Loading)bindable; - return instance.Style.Images; + return instance.loadingStyle.Images; }); /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] @@ -74,7 +74,7 @@ namespace Tizen.NUI.Components int frameRate = (int)newValue; if (0 != frameRate) //It will crash if 0 { - instance.Style.FrameRate.All = frameRate; + instance.loadingStyle.FrameRate.All = frameRate; instance.imageVisual.FrameDelay = 1000.0f / frameRate; } } @@ -82,10 +82,11 @@ namespace Tizen.NUI.Components defaultValueCreator: (bindable) => { var instance = (Loading)bindable; - return instance.Style.FrameRate?.All ?? (int)(1000/16.6f); + return instance.loadingStyle.FrameRate?.All ?? (int)(1000/16.6f); }); private AnimatedImageVisual imageVisual = null; + private LoadingStyle loadingStyle => ViewStyle as LoadingStyle; static Loading() { } @@ -120,9 +121,22 @@ namespace Tizen.NUI.Components /// /// Get style of loading. + /// Return a copied Style instance of Loading /// + /// + /// 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) + /// > /// 8 - public new LoadingStyle Style => ViewStyle as LoadingStyle; + public new LoadingStyle Style + { + get + { + var result = new LoadingStyle(loadingStyle); + result.CopyPropertiesFromView(this); + return result; + } + } /// /// Gets or sets loading image resource array. @@ -225,17 +239,17 @@ namespace Tizen.NUI.Components private void UpdateVisual() { - if (null != Style.Images) + if (null != loadingStyle.Images) { - imageVisual.URLS = new List(Style.Images); + imageVisual.URLS = new List(loadingStyle.Images); } - if (null != Style.FrameRate?.All && 0 != Style.FrameRate.All.Value) + if (null != loadingStyle.FrameRate?.All && 0 != loadingStyle.FrameRate.All.Value) { - imageVisual.FrameDelay = 1000.0f / (float)Style.FrameRate.All.Value; + imageVisual.FrameDelay = 1000.0f / (float)loadingStyle.FrameRate.All.Value; } - if (null != Style.LoadingSize) + if (null != loadingStyle.LoadingSize) { - this.Size = new Size2D((int)Style.LoadingSize.Width, (int)Style.LoadingSize.Height); + this.Size = new Size2D((int)loadingStyle.LoadingSize.Width, (int)loadingStyle.LoadingSize.Height); } } } diff --git a/src/Tizen.NUI.Components/Controls/Pagination.cs b/src/Tizen.NUI.Components/Controls/Pagination.cs index 08c4587..c3781bb 100755 --- a/src/Tizen.NUI.Components/Controls/Pagination.cs +++ b/src/Tizen.NUI.Components/Controls/Pagination.cs @@ -33,6 +33,7 @@ namespace Tizen.NUI.Components private int indicatorCount = 0; private int selectedIndex = -1; + private PaginationStyle paginationStyle => ViewStyle as PaginationStyle; static Pagination() { } @@ -68,8 +69,17 @@ namespace Tizen.NUI.Components /// /// Get style of pagination. /// + /// This will be public opened in tizen_next after ACR done. Before ACR, need to be hidden as inhouse API. /// 8 - public new PaginationStyle Style => ViewStyle as PaginationStyle; + public new PaginationStyle Style + { + get + { + var result = new PaginationStyle(paginationStyle); + result.CopyPropertiesFromView(this); + return result; + } + } /// /// Gets or sets the size of the indicator. @@ -79,15 +89,15 @@ namespace Tizen.NUI.Components { get { - return Style?.IndicatorSize; + return paginationStyle?.IndicatorSize; } set { - if (value == null || Style == null) + if (value == null || paginationStyle == null) { return; } - Style.IndicatorSize = value; + paginationStyle.IndicatorSize = value; UpdateVisual(); } } @@ -100,15 +110,15 @@ namespace Tizen.NUI.Components { get { - return Style?.IndicatorImageUrl; + return paginationStyle?.IndicatorImageUrl; } set { - if (value == null || Style == null) + if (value == null || paginationStyle == null) { return; } - Style.IndicatorImageUrl = value; + paginationStyle.IndicatorImageUrl = value; UpdateVisual(); } } @@ -121,11 +131,11 @@ namespace Tizen.NUI.Components { get { - return (int)Style?.IndicatorSpacing; + return (int)paginationStyle?.IndicatorSpacing; } set { - Style.IndicatorSpacing = value; + paginationStyle.IndicatorSpacing = value; UpdateVisual(); } } @@ -226,7 +236,7 @@ namespace Tizen.NUI.Components protected virtual void SelectOut(VisualMap selectOutIndicator) { if (!(selectOutIndicator is ImageVisual visual)) return; - visual.URL = Style?.IndicatorImageUrl.Normal; + visual.URL = paginationStyle?.IndicatorImageUrl.Normal; visual.Opacity = 0.5f; } @@ -238,7 +248,7 @@ namespace Tizen.NUI.Components protected virtual void SelectIn(VisualMap selectInIndicator) { if (!(selectInIndicator is ImageVisual visual)) return; - visual.URL = Style?.IndicatorImageUrl.Selected; + visual.URL = paginationStyle?.IndicatorImageUrl.Selected; visual.Opacity = 1.0f; } @@ -291,51 +301,51 @@ namespace Tizen.NUI.Components private void CreateIndicator() { - if (Style == null) + if (paginationStyle == null) { return; } ImageVisual indicator = new ImageVisual { - URL = Style.IndicatorImageUrl.Normal, - Size = new Size2D((int)Style.IndicatorSize.Width, (int)Style.IndicatorSize.Height), + URL = paginationStyle.IndicatorImageUrl.Normal, + Size = new Size2D((int)paginationStyle.IndicatorSize.Width, (int)paginationStyle.IndicatorSize.Height), Opacity = 0.5f, }; - indicator.Position = new Vector2((int)(Style.IndicatorSize.Width + Style.IndicatorSpacing) * indicatorList.Count, 0); + indicator.Position = new Position2D((int)(paginationStyle.IndicatorSize.Width + paginationStyle.IndicatorSpacing) * indicatorList.Count, 0); container.AddVisual("Indicator" + indicatorList.Count, indicator); indicatorList.Add(indicator); } private void UpdateContainer() { - if (Style == null) + if (paginationStyle == null) { return; } if (indicatorList.Count > 0) { - container.SizeWidth = (Style.IndicatorSize.Width + Style.IndicatorSpacing) * indicatorList.Count - Style.IndicatorSpacing; + container.SizeWidth = (paginationStyle.IndicatorSize.Width + paginationStyle.IndicatorSpacing) * indicatorList.Count - paginationStyle.IndicatorSpacing; } else { container.SizeWidth = 0; } - container.SizeHeight = Style.IndicatorSize.Height; + container.SizeHeight = paginationStyle.IndicatorSize.Height; container.PositionX = (int)((this.SizeWidth - container.SizeWidth) / 2); } private void UpdateVisual() { - if (null == Style.IndicatorSize) return; - if (null == Style.IndicatorImageUrl) return; + if (null == paginationStyle.IndicatorSize) return; + if (null == paginationStyle.IndicatorImageUrl) return; if (indicatorCount < 0) return; for (int i = 0; i < indicatorList.Count; i++) { ImageVisual indicator = indicatorList[i]; - indicator.URL = Style.IndicatorImageUrl.Normal; - indicator.Size = new Size2D((int)Style.IndicatorSize.Width, (int)Style.IndicatorSize.Height); - indicator.Position = new Vector2((int)(Style.IndicatorSize.Width + Style.IndicatorSpacing) * i, 0); + indicator.URL = paginationStyle.IndicatorImageUrl.Normal; + indicator.Size = new Size2D((int)paginationStyle.IndicatorSize.Width, (int)paginationStyle.IndicatorSize.Height); + indicator.Position = new Position2D((int)(paginationStyle.IndicatorSize.Width + paginationStyle.IndicatorSpacing) * i, 0); } } } diff --git a/src/Tizen.NUI.Components/Controls/Popup.cs b/src/Tizen.NUI.Components/Controls/Popup.cs index 3b66487..9a44d4a 100755 --- a/src/Tizen.NUI.Components/Controls/Popup.cs +++ b/src/Tizen.NUI.Components/Controls/Popup.cs @@ -35,9 +35,9 @@ namespace Tizen.NUI.Components 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?.Style?.Buttons?.Size != null ) + if (newValue != null && instance?.popupStyle?.Buttons?.Size != null ) { - instance.Style.Buttons.Size.Height = (int)newValue; + instance.popupStyle.Buttons.Size.Height = (int)newValue; instance.btGroup.Itemheight = (int)newValue; instance.UpdateView(); } @@ -45,7 +45,7 @@ namespace Tizen.NUI.Components defaultValueCreator: (bindable) => { var instance = (Popup)bindable; - return (int)(instance.Style?.Buttons?.Size?.Height ?? 0); + return (int)(instance.popupStyle?.Buttons?.Size?.Height ?? 0); }); /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API. @@ -55,9 +55,9 @@ namespace Tizen.NUI.Components var instance = (Popup)bindable; if (newValue != null) { - if (instance.Style?.Buttons?.Text != null) + if (instance.popupStyle?.Buttons?.Text != null) { - instance.Style.Buttons.Text.PointSize = (float)newValue; + instance.popupStyle.Buttons.Text.PointSize = (float)newValue; } instance.btGroup.ItemPointSize = (float)newValue; } @@ -65,7 +65,7 @@ namespace Tizen.NUI.Components defaultValueCreator: (bindable) => { var instance = (Popup)bindable; - return instance.Style?.Buttons?.Text?.PointSize?.All ?? 0; + return instance.popupStyle?.Buttons?.Text?.PointSize?.All ?? 0; }); /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API. @@ -75,14 +75,14 @@ namespace Tizen.NUI.Components var instance = (Popup)bindable; if (newValue != null) { - instance.Style.Buttons.Text.FontFamily = (string)newValue; + instance.popupStyle.Buttons.Text.FontFamily = (string)newValue; instance.btGroup.ItemFontFamily = (string)newValue; } }, defaultValueCreator: (bindable) => { var instance = (Popup)bindable; - return instance.Style?.Buttons?.Text?.FontFamily.All; + return instance.popupStyle?.Buttons?.Text?.FontFamily.All; }); /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API. @@ -92,9 +92,9 @@ namespace Tizen.NUI.Components var instance = (Popup)bindable; if (newValue != null) { - if (instance.Style?.Buttons?.Text != null) + if (instance.popupStyle?.Buttons?.Text != null) { - instance.Style.Buttons.Text.TextColor = (Color)newValue; + instance.popupStyle.Buttons.Text.TextColor = (Color)newValue; } instance.btGroup.ItemTextColor = (Color)newValue; } @@ -102,7 +102,7 @@ namespace Tizen.NUI.Components defaultValueCreator: (bindable) => { var instance = (Popup)bindable; - return instance.Style?.Buttons?.Text?.TextColor?.All; + return instance.popupStyle?.Buttons?.Text?.TextColor?.All; }); /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API. @@ -112,14 +112,14 @@ namespace Tizen.NUI.Components var instance = (Popup)bindable; if (newValue != null) { - instance.Style.Buttons.Overlay.BackgroundColor = (Selector)newValue; + instance.popupStyle.Buttons.Overlay.BackgroundColor = (Selector)newValue; instance.btGroup.OverLayBackgroundColorSelector = (Selector)newValue; } }, defaultValueCreator: (bindable) => { var instance = (Popup)bindable; - return instance.Style?.Buttons?.Overlay?.BackgroundColor; + return instance.popupStyle?.Buttons?.Overlay?.BackgroundColor; }); /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API. @@ -129,14 +129,14 @@ namespace Tizen.NUI.Components var instance = (Popup)bindable; if (newValue != null) { - instance.Style.Buttons.Text.HorizontalAlignment = (HorizontalAlignment)newValue; + instance.popupStyle.Buttons.Text.HorizontalAlignment = (HorizontalAlignment)newValue; instance.btGroup.ItemTextAlignment = (HorizontalAlignment)newValue; } }, defaultValueCreator: (bindable) => { var instance = (Popup)bindable; - return instance.Style?.Buttons?.Text?.HorizontalAlignment ?? HorizontalAlignment.Center; + return instance.popupStyle?.Buttons?.Text?.HorizontalAlignment ?? HorizontalAlignment.Center; }); /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API. @@ -146,18 +146,19 @@ namespace Tizen.NUI.Components var instance = (Popup)bindable; if (newValue != null) { - if (instance.Style.Buttons.BackgroundImage == null) + if (instance.popupStyle.Buttons.BackgroundImage == null) { - instance.Style.Buttons.BackgroundImage = new Selector(); + instance.popupStyle.Buttons.BackgroundImage = new Selector(); } + instance.popupStyle.Buttons.BackgroundColor = new Selector(); + instance.popupStyle.Buttons.BackgroundImage = (string)newValue; instance.btGroup.ItemBackgroundImageUrl = (string)newValue; - instance.Style.Buttons.BackgroundImage = (string)newValue; } }, defaultValueCreator: (bindable) => { var instance = (Popup)bindable; - return instance.Style?.Buttons?.BackgroundImage?.All; + return instance.popupStyle?.Buttons?.BackgroundImage?.All; }); /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API. @@ -167,18 +168,18 @@ namespace Tizen.NUI.Components var instance = (Popup)bindable; if (newValue != null) { - if (instance.Style.Buttons.BackgroundImageBorder == null) + if (instance.popupStyle.Buttons.BackgroundImageBorder == null) { - instance.Style.Buttons.BackgroundImageBorder = new Selector(); + instance.popupStyle.Buttons.BackgroundImageBorder = new Selector(); } - instance.Style.Buttons.BackgroundImageBorder = (Rectangle)newValue; + instance.popupStyle.Buttons.BackgroundImageBorder = (Rectangle)newValue; instance.btGroup.ItemBackgroundBorder = (Rectangle)newValue; } }, defaultValueCreator: (bindable) => { var instance = (Popup)bindable; - return instance.Style?.Buttons?.BackgroundImageBorder?.All; + return instance.popupStyle?.Buttons?.BackgroundImageBorder?.All; }); /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API. @@ -188,15 +189,16 @@ namespace Tizen.NUI.Components var instance = (Popup)bindable; ImageShadow shadow = (ImageShadow)newValue; instance.btGroup.ItemImageShadow = new ImageShadow(shadow); - instance.Style.Buttons.ImageShadow = new ImageShadow(shadow); + instance.popupStyle.Buttons.ImageShadow = new ImageShadow(shadow); }, defaultValueCreator: (bindable) => { var instance = (Popup)bindable; - return instance.Style?.Buttons?.ImageShadow?.All; + return instance.popupStyle?.Buttons?.ImageShadow?.All; }); + private PopupStyle popupStyle => ViewStyle as PopupStyle; private TextLabel titleText; private ButtonGroup btGroup = null; private Window window = null; @@ -266,10 +268,10 @@ namespace Tizen.NUI.Components [EditorBrowsable(EditorBrowsableState.Never)] public void AddButton(string buttonText) { - if (Style.Buttons != null) + if (popupStyle.Buttons != null) { - Button btn = new Button(Style.Buttons); - btn.Style.Text.Text = buttonText; + Button btn = new Button(popupStyle.Buttons); + btn.Text = buttonText; btn.ClickEvent += ButtonClickEvent; btGroup.AddItem(btn); UpdateView(); @@ -291,9 +293,9 @@ namespace Tizen.NUI.Components [EditorBrowsable(EditorBrowsableState.Never)] public void AddButton(string buttonText, ButtonStyle style) { - if (Style.Buttons != null && style != null) + if (popupStyle.Buttons != null && style != null) { - Style.Buttons.CopyFrom(style); + popupStyle.Buttons.CopyFrom(style); AddButton(buttonText); } } @@ -334,7 +336,16 @@ namespace Tizen.NUI.Components /// Get style of popup. /// [EditorBrowsable(EditorBrowsableState.Never)] - public new PopupStyle Style => ViewStyle as PopupStyle; + public new PopupStyle Style + { + get + { + var result = new PopupStyle(popupStyle); + result.CopyPropertiesFromView(this); + result.Title.CopyPropertiesFromView(titleText); + return result; + } + } /// /// Popup Title. @@ -366,15 +377,15 @@ namespace Tizen.NUI.Components { get { - return Style?.Title?.Text?.All; + return popupStyle?.Title?.Text?.All; } set { if (value != null) { - if (Style?.Title != null) + if (popupStyle?.Title != null) { - Style.Title.Text = value; + popupStyle.Title.Text = value; } } } @@ -389,13 +400,13 @@ namespace Tizen.NUI.Components { get { - return Style?.Title?.PointSize?.All ?? 0; + return popupStyle?.Title?.PointSize?.All ?? 0; } set { - if (Style?.Title != null) + if (popupStyle?.Title != null) { - Style.Title.PointSize = value; + popupStyle.Title.PointSize = value; } } } @@ -409,13 +420,13 @@ namespace Tizen.NUI.Components { get { - return Style?.Title?.TextColor?.All; + return popupStyle?.Title?.TextColor?.All; } set { - if (Style?.Title != null) + if (popupStyle?.Title != null) { - Style.Title.TextColor = value; + popupStyle.Title.TextColor = value; } } } @@ -429,11 +440,11 @@ namespace Tizen.NUI.Components { get { - return Style?.Title?.HorizontalAlignment ?? HorizontalAlignment.Center; + return popupStyle?.Title?.HorizontalAlignment ?? HorizontalAlignment.Center; } set { - Style.Title.HorizontalAlignment = value; + popupStyle.Title.HorizontalAlignment = value; } } @@ -446,11 +457,11 @@ namespace Tizen.NUI.Components { get { - return Style?.Title?.Position ?? new Position(0, 0, 0); + return popupStyle?.Title?.Position ?? new Position(0, 0, 0); } set { - Style.Title.Position = value; + popupStyle.Title.Position = value; } } @@ -463,13 +474,13 @@ namespace Tizen.NUI.Components { get { - return (int)(Style?.Title?.Size?.Height ?? 0); + return (int)(popupStyle?.Title?.Size?.Height ?? 0); } set { - if (Style?.Title?.Size != null) + if (popupStyle?.Title?.Size != null) { - Style.Title.Size.Height = value; + popupStyle.Title.Size.Height = value; } } } @@ -755,12 +766,10 @@ namespace Tizen.NUI.Components [EditorBrowsable(EditorBrowsableState.Never)] protected override void OnThemeChangedEvent(object sender, StyleManager.ThemeChangeEventArgs e) { - PopupStyle popupStyle = StyleManager.Instance.GetViewStyle(StyleName) as PopupStyle; - if (popupStyle != null) + PopupStyle ppStyle = StyleManager.Instance.GetViewStyle(StyleName) as PopupStyle; + if (ppStyle != null) { - string strSaveTitleText = TitleText; - Style.CopyFrom(popupStyle); - Style.Title.Text = strSaveTitleText; + ApplyStyle(ppStyle); UpdateView(); } } @@ -790,7 +799,7 @@ namespace Tizen.NUI.Components private void UpdateView() { - btGroup.UpdateButton(Style.Buttons); + btGroup.UpdateButton(popupStyle.Buttons); UpdateContentView(); UpdateTitle(); } @@ -816,7 +825,7 @@ namespace Tizen.NUI.Components { if (e.PropertyName.Equals("LayoutDirection")) { - btGroup.UpdateButton(Style.Buttons); + btGroup.UpdateButton(popupStyle.Buttons); } } @@ -826,21 +835,21 @@ namespace Tizen.NUI.Components int titleY = 0; int titleH = 0; int buttonH = 0; - string strText = Style.Title.Text.All; - if (!string.IsNullOrEmpty(strText) && Style.Title.Size != null) + string strText = Title.Text; + if (!string.IsNullOrEmpty(strText) && Title.Size != null) { titleH = (int)titleText.Size.Height; } - if (!string.IsNullOrEmpty(strText) && Style.Title.Position != null) + if (!string.IsNullOrEmpty(strText) && Title.Position != null) { - titleX = (int)Style.Title.Position.X; - titleY = (int)Style.Title.Position.Y; + titleX = (int)Title.Position.X; + titleY = (int)Title.Position.Y; } - if (btGroup.Count != 0 && Style?.Buttons?.Size != null ) + if (btGroup.Count != 0 && popupStyle?.Buttons?.Size != null ) { - buttonH = (int)Style.Buttons.Size.Height; + buttonH = (int)popupStyle.Buttons.Size.Height; } ContentView.Size = new Size(Size.Width - titleX * 2, Size.Height - titleY - titleH - buttonH); ContentView.Position = new Position(titleX, titleY + titleH); @@ -849,7 +858,7 @@ namespace Tizen.NUI.Components private void UpdateTitle() { - if (titleText != null && string.IsNullOrEmpty(Style.Title.Text.All) && Style.Title.Size != null) + if (titleText != null && string.IsNullOrEmpty(popupStyle.Title.Text.All) && popupStyle.Title.Size != null) { titleText.RaiseToTop(); } diff --git a/src/Tizen.NUI.Components/Controls/Progress.cs b/src/Tizen.NUI.Components/Controls/Progress.cs index c33e609..8270116 100755 --- a/src/Tizen.NUI.Components/Controls/Progress.cs +++ b/src/Tizen.NUI.Components/Controls/Progress.cs @@ -131,6 +131,7 @@ namespace Tizen.NUI.Components private float minValue = 0; private float currentValue = 0; private float bufferValue = 0; + private ProgressStyle progressStyle => ViewStyle as ProgressStyle; static Progress() { } /// @@ -191,7 +192,18 @@ namespace Tizen.NUI.Components /// Get style of progress. /// /// 8 - public new ProgressStyle Style => ViewStyle as ProgressStyle; + 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; + } + } /// /// The property to get/set Track image object URL of the Progress. @@ -201,13 +213,13 @@ namespace Tizen.NUI.Components { get { - return Style?.Track?.ResourceUrl?.All; + return progressStyle?.Track?.ResourceUrl?.All; } set { - if (null != Style?.Track) + if (null != progressStyle?.Track) { - Style.Track.ResourceUrl = value; + progressStyle.Track.ResourceUrl = value; } } } @@ -220,13 +232,13 @@ namespace Tizen.NUI.Components { get { - return Style?.Progress?.ResourceUrl?.All; + return progressStyle?.Progress?.ResourceUrl?.All; } set { - if (null != Style?.Progress) + if (null != progressStyle?.Progress) { - Style.Progress.ResourceUrl = value; + progressStyle.Progress.ResourceUrl = value; } } } @@ -239,13 +251,13 @@ namespace Tizen.NUI.Components { get { - return Style?.Buffer?.ResourceUrl?.All; + return progressStyle?.Buffer?.ResourceUrl?.All; } set { - if (null != Style?.Buffer) + if (null != progressStyle?.Buffer) { - Style.Buffer.ResourceUrl = value; + progressStyle.Buffer.ResourceUrl = value; RelayoutRequest(); } } @@ -259,13 +271,13 @@ namespace Tizen.NUI.Components { get { - return Style?.Track?.BackgroundColor?.All; + return progressStyle?.Track?.BackgroundColor?.All; } set { - if (null != Style?.Track) + if (null != progressStyle?.Track) { - Style.Track.BackgroundColor = value; + progressStyle.Track.BackgroundColor = value; } } } @@ -278,13 +290,13 @@ namespace Tizen.NUI.Components { get { - return Style?.Progress?.BackgroundColor?.All; + return progressStyle?.Progress?.BackgroundColor?.All; } set { - if (null != Style?.Progress) + if (null != progressStyle?.Progress) { - Style.Progress.BackgroundColor = value; + progressStyle.Progress.BackgroundColor = value; } } } @@ -297,13 +309,13 @@ namespace Tizen.NUI.Components { get { - return Style?.Buffer?.BackgroundColor?.All; + return progressStyle?.Buffer?.BackgroundColor?.All; } set { - if (null != Style?.Buffer) + if (null != progressStyle?.Buffer) { - Style.Buffer.BackgroundColor = value; + progressStyle.Buffer.BackgroundColor = value; } } } @@ -425,7 +437,7 @@ namespace Tizen.NUI.Components ProgressStyle tempStyle = StyleManager.Instance.GetViewStyle(StyleName) as ProgressStyle; if (null != tempStyle) { - Style.CopyFrom(tempStyle); + progressStyle.CopyFrom(tempStyle); RelayoutRequest(); } } @@ -533,7 +545,7 @@ namespace Tizen.NUI.Components PivotPoint = NUI.PivotPoint.TopLeft }; Add(trackImage); - trackImage.ApplyStyle(Style.Track); + trackImage.ApplyStyle(progressStyle.Track); } } @@ -550,7 +562,7 @@ namespace Tizen.NUI.Components PivotPoint = Tizen.NUI.PivotPoint.TopLeft }; Add(progressImage); - progressImage.ApplyStyle(Style.Progress); + progressImage.ApplyStyle(progressStyle.Progress); } } @@ -567,7 +579,7 @@ namespace Tizen.NUI.Components PivotPoint = Tizen.NUI.PivotPoint.TopLeft }; Add(bufferImage); - bufferImage.ApplyStyle(Style.Buffer); + bufferImage.ApplyStyle(progressStyle.Buffer); } } } diff --git a/src/Tizen.NUI.Components/Controls/RadioButton.cs b/src/Tizen.NUI.Components/Controls/RadioButton.cs index 2fc5003..4791cd8 100755 --- a/src/Tizen.NUI.Components/Controls/RadioButton.cs +++ b/src/Tizen.NUI.Components/Controls/RadioButton.cs @@ -15,6 +15,7 @@ * */ using System.ComponentModel; +using Tizen.NUI.BaseComponents; namespace Tizen.NUI.Components { @@ -69,6 +70,21 @@ namespace Tizen.NUI.Components } } + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override void ApplyStyle(ViewStyle viewStyle) + { + if (viewStyle is ButtonStyle buttonStyle) + { + if (buttonStyle.IsSelectable == null) + { + buttonStyle.IsSelectable = true; + } + + base.ApplyStyle(buttonStyle); + } + } + /// /// Set CheckState to true after selecting RadioButton. /// diff --git a/src/Tizen.NUI.Components/Controls/Scrollbar.cs b/src/Tizen.NUI.Components/Controls/Scrollbar.cs old mode 100644 new mode 100755 index 1c8a359..1059fca --- a/src/Tizen.NUI.Components/Controls/Scrollbar.cs +++ b/src/Tizen.NUI.Components/Controls/Scrollbar.cs @@ -36,12 +36,12 @@ namespace Tizen.NUI.Components var instance = ((Scrollbar)bindable); var thickness = (float?)newValue; - instance.Style.TrackThickness = thickness; + instance.scrollbarStyle.TrackThickness = thickness; instance.UpdateTrackThickness(thickness ?? 0); }, defaultValueCreator: (bindable) => { - return ((Scrollbar)bindable).Style.TrackThickness ?? 0; + return ((Scrollbar)bindable).scrollbarStyle.TrackThickness ?? 0; }); /// Bindable property of ThumbThickness @@ -51,12 +51,12 @@ namespace Tizen.NUI.Components var instance = ((Scrollbar)bindable); var thickness = (float?)newValue; - instance.Style.ThumbThickness = thickness; + instance.scrollbarStyle.ThumbThickness = thickness; instance.UpdateThumbThickness(thickness ?? 0); }, defaultValueCreator: (bindable) => { - return ((Scrollbar)bindable).Style.ThumbThickness ?? 0; + return ((Scrollbar)bindable).scrollbarStyle.ThumbThickness ?? 0; }); /// Bindable property of TrackColor @@ -66,12 +66,12 @@ namespace Tizen.NUI.Components var instance = ((Scrollbar)bindable); var color = (Color)newValue; - instance.Style.TrackColor = color; + instance.scrollbarStyle.TrackColor = color; instance.UpdateTrackColor(color); }, defaultValueCreator: (bindable) => { - return ((Scrollbar)bindable).Style.TrackColor; + return ((Scrollbar)bindable).scrollbarStyle.TrackColor; }); /// Bindable property of ThumbColor @@ -81,12 +81,12 @@ namespace Tizen.NUI.Components var instance = ((Scrollbar)bindable); var color = (Color)newValue; - instance.Style.ThumbColor = color; + instance.scrollbarStyle.ThumbColor = color; instance.UpdateThumbColor(color); }, defaultValueCreator: (bindable) => { - return ((Scrollbar)bindable).Style.ThumbColor; + return ((Scrollbar)bindable).scrollbarStyle.ThumbColor; }); /// Bindable property of TrackPadding @@ -96,12 +96,12 @@ namespace Tizen.NUI.Components var instance = ((Scrollbar)bindable); var trackPadding = (Extents)newValue; - instance.Style.TrackPadding = trackPadding; + instance.scrollbarStyle.TrackPadding = trackPadding; instance.UpdateTrackPadding(trackPadding); }, defaultValueCreator: (bindable) => { - return ((Scrollbar)bindable).Style.TrackPadding; + return ((Scrollbar)bindable).scrollbarStyle.TrackPadding; }); private ColorVisual trackVisual; @@ -110,6 +110,7 @@ namespace Tizen.NUI.Components private Animation thumbSizeAnimation; private Calculator calculator; private Size containerSize = new Size(0, 0); + private ScrollbarStyle scrollbarStyle => ViewStyle as ScrollbarStyle; #endregion Fields @@ -164,7 +165,15 @@ namespace Tizen.NUI.Components /// Style setting is possible by using constructor or the function of ApplyStyle(ViewStyle viewStyle) /// [EditorBrowsable(EditorBrowsableState.Never)] - public new ScrollbarStyle Style => ViewStyle as ScrollbarStyle; + public new ScrollbarStyle Style + { + get + { + var result = new ScrollbarStyle(scrollbarStyle); + result.CopyPropertiesFromView(this); + return result; + } + } /// /// The thickness of the track. diff --git a/src/Tizen.NUI.Components/Controls/SelectButton.cs b/src/Tizen.NUI.Components/Controls/SelectButton.cs index 0a41b99..65ed893 100755 --- a/src/Tizen.NUI.Components/Controls/SelectButton.cs +++ b/src/Tizen.NUI.Components/Controls/SelectButton.cs @@ -203,8 +203,7 @@ namespace Tizen.NUI.Components private void Initialize() { - if (null == Style) return; - Style.IsSelectable = true; + IsSelectable = true; } private void OnSelect() diff --git a/src/Tizen.NUI.Components/Controls/Slider.Internal.cs b/src/Tizen.NUI.Components/Controls/Slider.Internal.cs index f31bccc..d5c1883 100755 --- a/src/Tizen.NUI.Components/Controls/Slider.Internal.cs +++ b/src/Tizen.NUI.Components/Controls/Slider.Internal.cs @@ -49,8 +49,6 @@ namespace Tizen.NUI.Components bool isFocused = false; bool isPressed = false; - private StringSelector thumbImageURLSelector = new StringSelector(); - private void Initialize() { currentSlidedOffset = 0; @@ -379,13 +377,13 @@ namespace Tizen.NUI.Components } else { - if (lowIndicatorImage != null && Style != null && Style.LowIndicatorImage != null && Style.LowIndicatorImage.Size != null) + if (lowIndicatorImage != null && lowIndicatorImage != null && lowIndicatorImage.Size != null) { - lowIndicatorImage.Size = Style.LowIndicatorImage.Size; + lowIndicatorImage.Size = sliderStyle.LowIndicatorImage.Size; } - if (lowIndicatorText != null && Style != null && Style.LowIndicator != null && Style.LowIndicator.Size != null) + if (lowIndicatorText != null && lowIndicatorText != null && lowIndicatorText.Size != null) { - lowIndicatorText.Size = Style.LowIndicator.Size; + lowIndicatorText.Size = sliderStyle.LowIndicator.Size; } } } @@ -499,9 +497,9 @@ namespace Tizen.NUI.Components } else { - if (Style != null && Style.TrackThickness != null) + if (sliderStyle != null && sliderStyle.TrackThickness != null) { - curTrackThickness = Style.TrackThickness.Value; + curTrackThickness = sliderStyle.TrackThickness.Value; } } return curTrackThickness; @@ -516,9 +514,9 @@ namespace Tizen.NUI.Components } else { - if (Style != null && Style.TrackPadding != null) + if (sliderStyle != null && sliderStyle.TrackPadding != null) { - curSpace = Style.TrackPadding.Start; + curSpace = sliderStyle.TrackPadding.Start; } } return curSpace; @@ -527,9 +525,9 @@ namespace Tizen.NUI.Components private IndicatorType CurrentIndicatorType() { IndicatorType type = IndicatorType.None; - if (Style != null) + if (sliderStyle != null) { - type = (IndicatorType)Style.IndicatorType; + type = (IndicatorType)sliderStyle.IndicatorType; } return type; } @@ -543,9 +541,9 @@ namespace Tizen.NUI.Components } else { - if (Style != null && Style.LowIndicatorImage != null && Style.LowIndicatorImage.Size != null) + if (sliderStyle != null && sliderStyle.LowIndicatorImage != null && sliderStyle.LowIndicatorImage.Size != null) { - size = Style.LowIndicatorImage.Size; + size = sliderStyle.LowIndicatorImage.Size; } } return size; @@ -560,9 +558,9 @@ namespace Tizen.NUI.Components } else { - if (Style != null && Style.HighIndicatorImage != null && Style.HighIndicatorImage.Size != null) + if (sliderStyle != null && sliderStyle.HighIndicatorImage != null && sliderStyle.HighIndicatorImage.Size != null) { - size = Style.HighIndicatorImage.Size; + size = sliderStyle.HighIndicatorImage.Size; } } return size; @@ -577,9 +575,9 @@ namespace Tizen.NUI.Components } else { - if (Style != null && Style.LowIndicator != null && Style.LowIndicator.Size != null) + if (sliderStyle != null && sliderStyle.LowIndicator != null && sliderStyle.LowIndicator.Size != null) { - size = Style.LowIndicator.Size; + size = sliderStyle.LowIndicator.Size; } } return size; @@ -594,9 +592,9 @@ namespace Tizen.NUI.Components } else { - if (Style != null && Style.HighIndicator != null && Style.HighIndicator.Size != null) + if (sliderStyle != null && sliderStyle.HighIndicator != null && sliderStyle.HighIndicator.Size != null) { - size = Style.HighIndicator.Size; + size = sliderStyle.HighIndicator.Size; } } return size; diff --git a/src/Tizen.NUI.Components/Controls/Slider.cs b/src/Tizen.NUI.Components/Controls/Slider.cs index 30b6f18..9bf9703 100755 --- a/src/Tizen.NUI.Components/Controls/Slider.cs +++ b/src/Tizen.NUI.Components/Controls/Slider.cs @@ -192,10 +192,34 @@ namespace Tizen.NUI.Components } /// - /// Get style of slider. + /// Return a copied Style instance of Slider /// + /// + /// 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) + /// /// 8 - public new SliderStyle Style => ViewStyle as SliderStyle; + 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); + return result; + } + } + + /// + /// Return a copied Style instance of Slider + /// + private SliderStyle sliderStyle => ViewStyle as SliderStyle; /// /// Gets or sets the direction type of slider. @@ -296,11 +320,15 @@ namespace Tizen.NUI.Components { get { - return Style.Thumb?.Size; + return thumbImage?.Size; } set { - Style.Thumb.Size = value; + if (null != thumbImage) + { + thumbImage.Size = value; + sliderStyle.Thumb.Size = value; + } } } @@ -312,39 +340,27 @@ namespace Tizen.NUI.Components { get { - return Style?.Thumb?.ResourceUrl?.All; + return thumbImage?.ResourceUrl; } set { - if (null != Style?.Thumb) + if (null != thumbImage) { - Style.Thumb.ResourceUrl = value; + thumbImage.ResourceUrl = value; + sliderStyle.Thumb.ResourceUrl = value; } } } /// /// Gets or sets the resource url selector of the thumb image object. + /// Getter returns copied selector value if exist, null otherwise. /// /// 6 public StringSelector ThumbImageURLSelector { - get - { - return thumbImageURLSelector; - } - set - { - if (value == null || thumbImageURLSelector == null) - { - Tizen.Log.Fatal("NUI", "[Exception] Slider.ThumbImageURLSelector is null"); - throw new NullReferenceException("Slider.ThumbImageURLSelector is null"); - } - else - { - thumbImageURLSelector.Clone(value); - } - } + get => thumbImage == null ? null : new StringSelector((Selector)thumbImage.GetValue(ImageView.ResourceUrlSelectorProperty)); + set => thumbImage?.SetValue(ImageView.ResourceUrlSelectorProperty, value); } /// @@ -355,13 +371,14 @@ namespace Tizen.NUI.Components { get { - return Style?.Track?.BackgroundColor?.All; + return bgTrackImage?.BackgroundColor; } set { - if (null != Style?.Track) + if (null != bgTrackImage) { - Style.Track.BackgroundColor = value; + bgTrackImage.BackgroundColor = value; + sliderStyle.Track.BackgroundColor = value; } } } @@ -374,13 +391,14 @@ namespace Tizen.NUI.Components { get { - return Style?.Progress?.BackgroundColor?.All; + return slidedTrackImage?.BackgroundColor; } set { - if (null != Style?.Progress) + if (null != slidedTrackImage) { - Style.Progress.BackgroundColor = value; + slidedTrackImage.BackgroundColor = value; + sliderStyle.Progress.BackgroundColor = value; } } } @@ -409,13 +427,14 @@ namespace Tizen.NUI.Components { get { - return Style?.LowIndicatorImage?.ResourceUrl?.All; + return lowIndicatorImage?.ResourceUrl; } set { - if (null != Style?.LowIndicatorImage) + if (null != lowIndicatorImage) { - Style.LowIndicatorImage.ResourceUrl = value; + lowIndicatorImage.ResourceUrl = value; + sliderStyle.LowIndicatorImage.ResourceUrl = value; } } } @@ -428,13 +447,14 @@ namespace Tizen.NUI.Components { get { - return Style?.HighIndicatorImage?.ResourceUrl?.All; + return highIndicatorImage?.ResourceUrl; } set { - if (null != Style?.HighIndicatorImage) + if (null != highIndicatorImage) { - Style.HighIndicatorImage.ResourceUrl = value; + highIndicatorImage.ResourceUrl = value; + sliderStyle.HighIndicatorImage.ResourceUrl = value; } } } @@ -447,13 +467,14 @@ namespace Tizen.NUI.Components { get { - return Style?.LowIndicator?.Text?.All; + return lowIndicatorText?.Text; } set { - if (null != Style?.LowIndicator) + if (null != lowIndicatorText) { - Style.LowIndicator.Text= value; + lowIndicatorText.Text= value; + sliderStyle.LowIndicator.Text= value; } } } @@ -466,13 +487,14 @@ namespace Tizen.NUI.Components { get { - return Style?.HighIndicator?.Text?.All; + return highIndicatorText?.Text; } set { - if (null != Style?.HighIndicator) + if (null != highIndicatorText) { - Style.HighIndicator.Text = value; + highIndicatorText.Text = value; + sliderStyle.HighIndicator.Text = value; } } } @@ -505,11 +527,15 @@ namespace Tizen.NUI.Components { get { - return Style.HighIndicator.Size; + return highIndicatorText?.Size; } set { - Style.HighIndicator.Size = value; + if (null != highIndicatorText) + { + highIndicatorText.Size = value; + sliderStyle.HighIndicator.Size = value; + } } } @@ -773,7 +799,7 @@ namespace Tizen.NUI.Components SliderStyle sliderStyle = StyleManager.Instance.GetViewStyle(StyleName) as SliderStyle; if (sliderStyle != null) { - Style?.CopyFrom(sliderStyle); + ApplyStyle(sliderStyle); RelayoutRequest(); } } diff --git a/src/Tizen.NUI.Components/Controls/Switch.cs b/src/Tizen.NUI.Components/Controls/Switch.cs index 28e12ce..f658e40 100755 --- a/src/Tizen.NUI.Components/Controls/Switch.cs +++ b/src/Tizen.NUI.Components/Controls/Switch.cs @@ -69,10 +69,24 @@ namespace Tizen.NUI.Components public event EventHandler SelectedEvent; /// - /// Get style of switch. + /// Return a copied Style instance of Switch /// + /// + /// 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) + /// /// 8 - public new SwitchStyle Style => ViewStyle as SwitchStyle; + 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; + } + } /// /// Apply style to switch. @@ -173,19 +187,8 @@ namespace Tizen.NUI.Components /// 6 public StringSelector SwitchBackgroundImageURLSelector { - get - { - StringSelector strSl = new StringSelector(); - strSl.Clone(Style?.Track?.ResourceUrl); - return strSl; - } - set - { - if (null != value && null != Style?.Track) - { - Style.Track.ResourceUrl = value; - } - } + get => track == null ? null : new StringSelector((Selector)thumb.GetValue(ImageView.ResourceUrlSelectorProperty)); + set => track?.SetValue(ImageView.ResourceUrlSelectorProperty, value); } /// @@ -196,36 +199,23 @@ namespace Tizen.NUI.Components { get { - return Style?.Thumb?.ResourceUrl?.All; + return Thumb.ResourceUrl; } set { - if (null != value && null != Style?.Thumb) - { - Style.Thumb.ResourceUrl = value; - } + Thumb.ResourceUrl = value; } } /// /// Handler image's resource url selector in Switch. + /// Getter returns copied selector value if exist, null otherwise. /// /// 6 public StringSelector SwitchHandlerImageURLSelector { - get - { - StringSelector strSl = new StringSelector(); - strSl.Clone(Style?.Thumb?.ResourceUrl); - return strSl; - } - set - { - if (null != value && null != Style?.Thumb) - { - Style.Thumb.ResourceUrl = value; - } - } + get => thumb == null ? null : new StringSelector((Selector)thumb.GetValue(ImageView.ResourceUrlSelectorProperty)); + set => thumb?.SetValue(ImageView.ResourceUrlSelectorProperty, value); } /// @@ -236,14 +226,11 @@ namespace Tizen.NUI.Components { get { - return Style?.Thumb?.Size; + return Thumb.Size; } set { - if (null != Style?.Thumb) - { - Style.Thumb.Size = value; - } + Thumb.Size = value; } } @@ -319,7 +306,7 @@ namespace Tizen.NUI.Components private void Initialize() { - Style.IsSelectable = true; + IsSelectable = true; } /// @@ -333,7 +320,7 @@ namespace Tizen.NUI.Components SwitchStyle switchStyle = StyleManager.Instance.GetViewStyle(StyleName) as SwitchStyle; if (null != switchStyle) { - Style.CopyFrom(switchStyle); + ApplyStyle(switchStyle); } } diff --git a/src/Tizen.NUI.Components/Controls/Tab.cs b/src/Tizen.NUI.Components/Controls/Tab.cs index a48d3ed..b569788 100755 --- a/src/Tizen.NUI.Components/Controls/Tab.cs +++ b/src/Tizen.NUI.Components/Controls/Tab.cs @@ -36,6 +36,8 @@ namespace Tizen.NUI.Components private Animation underlineAni = null; private bool isNeedAnimation = false; private Extents space; + private TabStyle tabStyle => ViewStyle as TabStyle; + static Tab() { } /// @@ -76,10 +78,23 @@ namespace Tizen.NUI.Components public event EventHandler ItemChangedEvent; /// - /// Get style of tab. + /// Return a copied Style instance of Tab /// + /// + /// 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) + /// /// 8 - public new TabStyle Style => ViewStyle as TabStyle; + public new TabStyle Style + { + get + { + var result = new TabStyle(tabStyle); + result.CopyPropertiesFromView(this); + result.UnderLine.CopyPropertiesFromView(underline); + return result; + } + } [EditorBrowsable(EditorBrowsableState.Never)] public View Underline @@ -134,13 +149,13 @@ namespace Tizen.NUI.Components { get { - return Style?.UseTextNaturalSize ?? false; + return tabStyle?.UseTextNaturalSize ?? false; } set { - if (null != Style) + if (null != tabStyle) { - Style.UseTextNaturalSize = value; + tabStyle.UseTextNaturalSize = value; RelayoutRequest(); } } @@ -155,13 +170,13 @@ namespace Tizen.NUI.Components { get { - return Style?.ItemSpace ?? 0; + return tabStyle?.ItemSpace ?? 0; } set { - if (null != Style) + if (null != tabStyle) { - Style.ItemSpace = value; + tabStyle.ItemSpace = value; RelayoutRequest(); } } @@ -198,18 +213,18 @@ namespace Tizen.NUI.Components } set { - if(null != value && null != Style?.ItemPadding) + if(null != value && null != tabStyle?.ItemPadding) { - Style.ItemPadding.CopyFrom(value); + tabStyle.ItemPadding.CopyFrom(value); if (null == space) { space = new Extents((ushort start, ushort end, ushort top, ushort bottom) => { - Style.ItemPadding.Start = start; - Style.ItemPadding.End = end; - Style.ItemPadding.Top = top; - Style.ItemPadding.Bottom = bottom; + tabStyle.ItemPadding.Start = start; + tabStyle.ItemPadding.End = end; + tabStyle.ItemPadding.Top = top; + tabStyle.ItemPadding.Bottom = bottom; RelayoutRequest(); }, value.Start, value.End, value.Top, value.Bottom); } @@ -232,14 +247,15 @@ namespace Tizen.NUI.Components { get { - return Style?.UnderLine?.Size; + return Underline.Size; } set { - if (null != Style?.UnderLine) + if (null != tabStyle?.UnderLine) { - Style.UnderLine.Size = value; + tabStyle.UnderLine.Size = value; } + Underline.Size = value; } } @@ -252,14 +268,15 @@ namespace Tizen.NUI.Components { get { - return Style?.UnderLine?.BackgroundColor?.All; + return Underline.BackgroundColor; } set { - if (null != Style?.UnderLine) + if (null != tabStyle?.BackgroundColor) { - Style.UnderLine.BackgroundColor = value; + tabStyle.UnderLine.BackgroundColor = value; } + Underline.BackgroundColor = value; } } @@ -272,13 +289,14 @@ namespace Tizen.NUI.Components { get { - return Style?.Text?.PointSize?.All ?? 0; + return tabStyle?.Text?.PointSize?.All ?? 0; } set { - if (null != Style?.Text) + if (null != tabStyle?.Text) { - Style.Text.PointSize = value; + tabStyle.Text.PointSize = value; + RelayoutRequest(); } } } @@ -292,13 +310,14 @@ namespace Tizen.NUI.Components { get { - return Style?.Text?.FontFamily?.All; + return tabStyle?.Text?.FontFamily?.All; } set { - if (null != Style?.Text) + if (null != tabStyle?.Text) { - Style.Text.FontFamily = value; + tabStyle.Text.FontFamily = value; + RelayoutRequest(); } } } @@ -312,13 +331,14 @@ namespace Tizen.NUI.Components { get { - return Style?.Text?.TextColor?.All; + return tabStyle?.Text?.TextColor?.All; } set { - if (null != Style?.Text) + if (null != tabStyle?.Text) { - Style.Text.TextColor = value; + tabStyle.Text.TextColor = value; + RelayoutRequest(); } } } @@ -488,7 +508,7 @@ namespace Tizen.NUI.Components TabStyle tabStyle = StyleManager.Instance.GetViewStyle(StyleName) as TabStyle; if (tabStyle != null) { - Style.CopyFrom(tabStyle); + ApplyStyle(tabStyle); } } @@ -511,13 +531,13 @@ namespace Tizen.NUI.Components return; } - int preX = (int)Style.ItemPadding.Start; + int preX = (int)tabStyle?.ItemPadding.Start; int preW = 0; - int itemSpace = Style.ItemSpace; + int itemSpace = (null != tabStyle) ? tabStyle.ItemSpace : 0; if (LayoutDirection == ViewLayoutDirectionType.LTR) { - if (Style.UseTextNaturalSize == true) + if (tabStyle?.UseTextNaturalSize == true) { for (int i = 0; i < totalNum; i++) { @@ -530,7 +550,7 @@ namespace Tizen.NUI.Components } else { - preW = (Size2D.Width - (int)Style.ItemPadding.Start - (int)Style.ItemPadding.End) / totalNum; + preW = (Size2D.Width - (int)tabStyle?.ItemPadding.Start - (int)tabStyle?.ItemPadding.End) / totalNum; for (int i = 0; i < totalNum; i++) { itemList[i].Position2D.X = preX; @@ -542,8 +562,8 @@ namespace Tizen.NUI.Components } else { - preX = (int)Style.ItemPadding.End; - if (Style.UseTextNaturalSize == true) + preX = (int)tabStyle?.ItemPadding.End; + if (tabStyle?.UseTextNaturalSize == true) { int w = Size2D.Width; for (int i = 0; i < totalNum; i++) @@ -557,7 +577,7 @@ namespace Tizen.NUI.Components } else { - preW = (Size2D.Width - (int)Style.ItemPadding.Start - (int)Style.ItemPadding.End) / totalNum; + preW = (Size2D.Width - (int)tabStyle?.ItemPadding.Start - (int)tabStyle?.ItemPadding.End) / totalNum; for (int i = totalNum - 1; i >= 0; i--) { itemList[i].Position2D.X = preX; @@ -582,16 +602,16 @@ namespace Tizen.NUI.Components private void AddItemByIndex(TabItemData itemData, int index) { - if (null == itemData) return; + if (null == itemData || null == tabStyle) return; int h = 0; - int topSpace = (int)Style.ItemPadding.Top; - if (Style.UnderLine != null && Style.UnderLine.Size != null) + int topSpace = (int)tabStyle.ItemPadding.Top; + if (Underline.Size != null) { - h = (int)Style.UnderLine.Size.Height; + h = (int)Underline.Size.Height; } Tab.TabItem item = new TabItem(); - item.TextItem.ApplyStyle(Style.Text); + item.TextItem.ApplyStyle(tabStyle.Text); item.Text = itemData.Text; item.Size2D.Height = Size2D.Height - h - topSpace; @@ -638,16 +658,15 @@ namespace Tizen.NUI.Components private void UpdateUnderLinePos() { - if (underline == null || Style.UnderLine == null || Style.UnderLine.Size == null - || itemList == null || itemList.Count <= 0) + if (underline == null || Underline.Size == null || itemList == null || itemList.Count <= 0) { return; } - Style.UnderLine.Size.Width = itemList[curIndex].Size2D.Width; + Underline.Size.Width = itemList[curIndex].Size2D.Width; - underline.Size2D = new Size2D(itemList[curIndex].Size2D.Width, (int)Style.UnderLine.Size.Height); - underline.BackgroundColor = Style.UnderLine.BackgroundColor.All; + underline.Size2D = new Size2D(itemList[curIndex].Size2D.Width, (int)Underline.Size.Height); + underline.BackgroundColor = tabStyle.UnderLine.BackgroundColor.All; if (isNeedAnimation) { CreateUnderLineAnimation(); diff --git a/src/Tizen.NUI.Components/Controls/Toast.cs b/src/Tizen.NUI.Components/Controls/Toast.cs index 5c2cb9c..c8cafad 100755 --- a/src/Tizen.NUI.Components/Controls/Toast.cs +++ b/src/Tizen.NUI.Components/Controls/Toast.cs @@ -38,7 +38,10 @@ namespace Tizen.NUI.Components if (newValue != null) { instance.strText = (string)(newValue); - instance.Style.Text.Text = instance.strText; + if (null != instance.textLabel) + { + instance.textLabel.Text = instance.strText; + } } }, defaultValueCreator: (bindable) => @@ -54,14 +57,18 @@ namespace Tizen.NUI.Components var instance = (Toast)bindable; if (newValue != null) { - instance.Style.Duration = (uint)newValue; + instance.toastStyle.Duration = (uint)newValue; + if (instance.timer == null) + { + instance.timer = new Timer(instance.duration); + } instance.timer.Interval = (uint)newValue; } }, defaultValueCreator: (bindable) => { var instance = (Toast)bindable; - return instance.Style.Duration ?? instance.duration; + return instance.toastStyle.Duration ?? instance.duration; }); /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API. @@ -81,12 +88,26 @@ namespace Tizen.NUI.Components private string strText = null; private Timer timer = null; private readonly uint duration = 3000; + private ToastStyle toastStyle => ViewStyle as ToastStyle; /// - /// Get style of toast. + /// Return a copied Style instance of Toast /// + /// + /// 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) + /// [EditorBrowsable(EditorBrowsableState.Never)] - public new ToastStyle Style => ViewStyle as ToastStyle; + public new ToastStyle Style + { + get + { + var result = new ToastStyle(toastStyle); + result.CopyPropertiesFromView(this); + result.Text.CopyPropertiesFromView(textLabel); + return result; + } + } static Toast() { } /// @@ -139,13 +160,13 @@ namespace Tizen.NUI.Components { get { - return (float)Style?.Text?.PointSize?.All; + return (float)textLabel?.PointSize; } set { - if (null != Style?.Text) + if (null != textLabel) { - Style.Text.PointSize = value; + textLabel.PointSize = value; } } } @@ -159,13 +180,13 @@ namespace Tizen.NUI.Components { get { - return Style?.Text?.FontFamily?.All; + return textLabel?.FontFamily; } set { - if (null != Style?.Text) + if (null != textLabel) { - Style.Text.FontFamily = value; + textLabel.FontFamily = value; } } } @@ -179,13 +200,13 @@ namespace Tizen.NUI.Components { get { - return Style?.Text?.TextColor?.All; + return textLabel?.TextColor; } set { - if (null != Style?.Text) + if (null != textLabel) { - Style.Text.TextColor = value; + textLabel.TextColor = value; } } } @@ -199,13 +220,13 @@ namespace Tizen.NUI.Components { get { - return Style?.Text?.HorizontalAlignment ?? HorizontalAlignment.Center; + return textLabel?.HorizontalAlignment ?? HorizontalAlignment.Center; } set { - if (null != Style?.Text) + if (null != textLabel) { - Style.Text.HorizontalAlignment = value; + textLabel.HorizontalAlignment = value; } } } @@ -248,13 +269,13 @@ namespace Tizen.NUI.Components { get { - return Style.Text.Padding; + return textLabel?.Padding; } set { - if (null != value && null != Style.Text) + if (null != value && null != textLabel) { - Style.Text.Padding.CopyFrom(value); + textLabel.Padding.CopyFrom(value); } } } @@ -363,7 +384,7 @@ namespace Tizen.NUI.Components } this.VisibilityChanged += OnVisibilityChanged; - timer = new Timer(Style.Duration ?? duration); + timer = new Timer(toastStyle.Duration ?? duration); timer.Tick += OnTick; } diff --git a/src/Tizen.NUI.Components/PreloadStyle/DefaultTheme.cs b/src/Tizen.NUI.Components/PreloadStyle/DefaultTheme.cs index c02534f..caf96f6 100755 --- a/src/Tizen.NUI.Components/PreloadStyle/DefaultTheme.cs +++ b/src/Tizen.NUI.Components/PreloadStyle/DefaultTheme.cs @@ -181,7 +181,6 @@ namespace Tizen.NUI.Components { Url = StyleManager.GetFrameworkResourcePath("nui_component_default_popup_shadow.png"), Border = new Rectangle(24, 24, 24, 24), - Offset = new Vector2(-24, -24), Extents = new Vector2(48, 48), }, Title = new TextLabelStyle @@ -335,6 +334,8 @@ namespace Tizen.NUI.Components Track = new ImageViewStyle { Size = new Size(96, 60), + WidthResizePolicy = ResizePolicyType.Fixed, + HeightResizePolicy = ResizePolicyType.Fixed, ResourceUrl = new Selector { Normal = StyleManager.GetFrameworkResourcePath("nui_component_default_switch_track_n.png"), diff --git a/src/Tizen.NUI.Components/Style/ButtonStyle.cs b/src/Tizen.NUI.Components/Style/ButtonStyle.cs index aa9f258..21fb114 100755 --- a/src/Tizen.NUI.Components/Style/ButtonStyle.cs +++ b/src/Tizen.NUI.Components/Style/ButtonStyle.cs @@ -44,10 +44,7 @@ namespace Tizen.NUI.Components public static readonly BindableProperty IsSelectedProperty = BindableProperty.Create(nameof(IsSelected), typeof(bool?), typeof(ButtonStyle), null, propertyChanged: (bindable, oldValue, newValue) => { var buttonStyle = (ButtonStyle)bindable; - if (buttonStyle.IsSelectable != null && buttonStyle.IsSelectable == true) - { - buttonStyle.isSelected = (bool?)newValue; - } + buttonStyle.isSelected = (bool?)newValue; }, defaultValueCreator: (bindable) => { @@ -252,9 +249,6 @@ namespace Tizen.NUI.Components { Icon?.CopyFrom(buttonStyle.Icon); } - - IsSelectable = buttonStyle.IsSelectable; - IconRelativeOrientation = buttonStyle.IconRelativeOrientation; } } @@ -301,7 +295,6 @@ namespace Tizen.NUI.Components WidthResizePolicy = ResizePolicyType.FillToParent, HeightResizePolicy = ResizePolicyType.FillToParent }; - Overlay.PropertyChanged += SubStyleCalledEvent; Text = new TextLabelStyle() { @@ -313,7 +306,6 @@ namespace Tizen.NUI.Components HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center }; - Text.PropertyChanged += SubStyleCalledEvent; Icon = new ImageViewStyle() { @@ -321,16 +313,10 @@ namespace Tizen.NUI.Components ParentOrigin = Tizen.NUI.ParentOrigin.Center, PivotPoint = Tizen.NUI.PivotPoint.Center, }; - Icon.PropertyChanged += SubStyleCalledEvent; IconRelativeOrientation = Button.IconOrientation.Left; } - private void SubStyleCalledEvent(object sender, global::System.EventArgs e) - { - OnPropertyChanged(); - } - private void OnIconPaddingChanged(ushort start, ushort end, ushort top, ushort bottom) { IconPadding = new Extents(start, end, top, bottom); diff --git a/src/Tizen.NUI.Components/Style/ControlStyle.cs b/src/Tizen.NUI.Components/Style/ControlStyle.cs index b93f642..7674a4a 100755 --- a/src/Tizen.NUI.Components/Style/ControlStyle.cs +++ b/src/Tizen.NUI.Components/Style/ControlStyle.cs @@ -50,6 +50,7 @@ namespace Tizen.NUI.Components InitSubstyle(); } + /// /// Creates a new instance of a ControlStyle with style. /// diff --git a/src/Tizen.NUI.Components/Style/PaginationStyle.cs b/src/Tizen.NUI.Components/Style/PaginationStyle.cs index 1b59161..e081291 100755 --- a/src/Tizen.NUI.Components/Style/PaginationStyle.cs +++ b/src/Tizen.NUI.Components/Style/PaginationStyle.cs @@ -41,7 +41,7 @@ namespace Tizen.NUI.Components /// 8 public PaginationStyle(PaginationStyle style) : base(style) { - if (null == style) return; + if (null == style) return; this.CopyFrom(style); } diff --git a/src/Tizen.NUI.Components/Style/PopupStyle.cs b/src/Tizen.NUI.Components/Style/PopupStyle.cs index 760db21..fe4f36a 100755 --- a/src/Tizen.NUI.Components/Style/PopupStyle.cs +++ b/src/Tizen.NUI.Components/Style/PopupStyle.cs @@ -44,7 +44,8 @@ namespace Tizen.NUI.Components [EditorBrowsable(EditorBrowsableState.Never)] public PopupStyle(PopupStyle style) : base(style) { - InitSubStyle(); + Title = new TextLabelStyle(); + Buttons = new ButtonStyle(); this.CopyFrom(style); } @@ -95,7 +96,6 @@ namespace Tizen.NUI.Components Title = new TextLabelStyle() { - Size = new Size(0, 0), PositionUsesPivotPoint = true, ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft, PivotPoint = Tizen.NUI.PivotPoint.TopLeft, diff --git a/src/Tizen.NUI.Components/Style/SwitchStyle.cs b/src/Tizen.NUI.Components/Style/SwitchStyle.cs index c424b0d..f3dc359 100755 --- a/src/Tizen.NUI.Components/Style/SwitchStyle.cs +++ b/src/Tizen.NUI.Components/Style/SwitchStyle.cs @@ -50,7 +50,9 @@ namespace Tizen.NUI.Components return; } - InitSubStyle(); + IsSelectable = true; + Track = new ImageViewStyle(); + Thumb = new ImageViewStyle(); this.CopyFrom(style); } @@ -101,6 +103,7 @@ namespace Tizen.NUI.Components private void InitSubStyle() { + IsSelectable = true; Track = new ImageViewStyle() { PositionUsesPivotPoint = true, diff --git a/src/Tizen.NUI.Components/Style/TabStyle.cs b/src/Tizen.NUI.Components/Style/TabStyle.cs index 5848c6c..d07ce37 100755 --- a/src/Tizen.NUI.Components/Style/TabStyle.cs +++ b/src/Tizen.NUI.Components/Style/TabStyle.cs @@ -77,16 +77,6 @@ namespace Tizen.NUI.Components } ItemSpace = style.ItemSpace; UseTextNaturalSize = style.UseTextNaturalSize; - - if (null != style.UnderLine) - { - UnderLine?.CopyFrom(style.UnderLine); - } - - if (null != style.Text) - { - Text?.CopyFrom(style.Text); - } } /// diff --git a/src/Tizen.NUI.Components/Utils/Selector.cs b/src/Tizen.NUI.Components/Utils/Selector.cs index 935fd53..26b5e63 100755 --- a/src/Tizen.NUI.Components/Utils/Selector.cs +++ b/src/Tizen.NUI.Components/Utils/Selector.cs @@ -33,11 +33,9 @@ namespace Tizen.NUI.Components /// 6 /// 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 IntSelector Clone() + public new IntSelector Clone() { - IntSelector selector = new IntSelector(); - selector.Clone(this); - return selector; + return (IntSelector)base.Clone(); } } @@ -50,16 +48,30 @@ namespace Tizen.NUI.Components public class FloatSelector : Selector { /// + /// Default constructor. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public FloatSelector() : base() + { + } + + /// + /// Constructor with base class object. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public FloatSelector(Selector selector) : base(selector) + { + } + + /// /// Float selector clone function. /// /// 6 /// 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 FloatSelector Clone() + public new FloatSelector Clone() { - FloatSelector selector = new FloatSelector(); - selector.Clone(this); - return selector; + return (FloatSelector)base.Clone(); } } /// @@ -74,11 +86,9 @@ namespace Tizen.NUI.Components /// 6 /// 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 BoolSelector Clone() + public new BoolSelector Clone() { - BoolSelector selector = new BoolSelector(); - selector.Clone(this); - return selector; + return (BoolSelector)base.Clone(); } } /// @@ -90,16 +100,30 @@ namespace Tizen.NUI.Components public class StringSelector : Selector { /// + /// Default constructor. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public StringSelector() : base() + { + } + + /// + /// Constructor with base class object. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public StringSelector(Selector selector) : base(selector) + { + } + + /// /// String selector clone function. /// /// 6 /// 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 StringSelector Clone() + public new StringSelector Clone() { - StringSelector selector = new StringSelector(); - selector.Clone(this); - return selector; + return (StringSelector)base.Clone(); } } @@ -112,16 +136,30 @@ namespace Tizen.NUI.Components public class ColorSelector : Selector { /// + /// Default constructor. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public ColorSelector() : base() + { + } + + /// + /// Constructor with base class object. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public ColorSelector(Selector selector) : base(selector) + { + } + + /// /// Color selector clone function. /// /// 6 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] - public ColorSelector Clone() + public new ColorSelector Clone() { - ColorSelector selector = new ColorSelector(); - selector.Clone(this); - return selector; + return (ColorSelector)base.Clone(); } } @@ -137,11 +175,9 @@ namespace Tizen.NUI.Components /// 6 /// 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 Size2DSelector Clone() + public new Size2DSelector Clone() { - Size2DSelector selector = new Size2DSelector(); - selector.Clone(this); - return selector; + return (Size2DSelector)base.Clone(); } } /// @@ -156,11 +192,9 @@ namespace Tizen.NUI.Components /// 6 /// 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 Position2DSelector Clone() + public new Position2DSelector Clone() { - Position2DSelector selector = new Position2DSelector(); - selector.Clone(this); - return selector; + return (Position2DSelector)base.Clone(); } } @@ -176,11 +210,9 @@ namespace Tizen.NUI.Components /// 6 /// 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 PositionSelector Clone() + public new PositionSelector Clone() { - PositionSelector selector = new PositionSelector(); - selector.Clone(this); - return selector; + return (PositionSelector)base.Clone(); } } @@ -198,11 +230,9 @@ namespace Tizen.NUI.Components /// 6 /// 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 Vector2Selector Clone() + public new Vector2Selector Clone() { - Vector2Selector selector = new Vector2Selector(); - selector.Clone(this); - return selector; + return (Vector2Selector)base.Clone(); } } @@ -218,11 +248,9 @@ namespace Tizen.NUI.Components /// 6 /// 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 Vector3Selector Clone() + public new Vector3Selector Clone() { - Vector3Selector selector = new Vector3Selector(); - selector.Clone(this); - return selector; + return (Vector3Selector)base.Clone(); } } @@ -240,11 +268,9 @@ namespace Tizen.NUI.Components /// 6 /// 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 RectangleSelector Clone() + public new RectangleSelector Clone() { - RectangleSelector selector = new RectangleSelector(); - selector.Clone(this); - return selector; + return (RectangleSelector)base.Clone(); } } @@ -260,11 +286,9 @@ namespace Tizen.NUI.Components /// 6 /// 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 HorizontalAlignmentSelector Clone() + public new HorizontalAlignmentSelector Clone() { - HorizontalAlignmentSelector selector = new HorizontalAlignmentSelector(); - selector.Clone(this); - return selector; + return (HorizontalAlignmentSelector)base.Clone(); } } /// @@ -279,11 +303,9 @@ namespace Tizen.NUI.Components /// 6 /// 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 VerticalAlignmentSelector Clone() + public new VerticalAlignmentSelector Clone() { - VerticalAlignmentSelector selector = new VerticalAlignmentSelector(); - selector.Clone(this); - return selector; + return (VerticalAlignmentSelector)base.Clone(); } } @@ -299,11 +321,9 @@ namespace Tizen.NUI.Components /// 6 /// 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 AutoScrollStopModeSelector Clone() + public new AutoScrollStopModeSelector Clone() { - AutoScrollStopModeSelector selector = new AutoScrollStopModeSelector(); - selector.Clone(this); - return selector; + return (AutoScrollStopModeSelector)base.Clone(); } } @@ -319,11 +339,9 @@ namespace Tizen.NUI.Components /// 6 /// 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 ResizePolicyTypeSelector Clone() + public new ResizePolicyTypeSelector Clone() { - ResizePolicyTypeSelector selector = new ResizePolicyTypeSelector(); - selector.Clone(this); - return selector; + return (ResizePolicyTypeSelector)base.Clone(); } } diff --git a/src/Tizen.NUI.Wearable/src/public/CircularProgress.cs b/src/Tizen.NUI.Wearable/src/public/CircularProgress.cs index efc0da1..c302013 100755 --- a/src/Tizen.NUI.Wearable/src/public/CircularProgress.cs +++ b/src/Tizen.NUI.Wearable/src/public/CircularProgress.cs @@ -36,14 +36,12 @@ namespace Tizen.NUI.Wearable public static readonly BindableProperty ThicknessProperty = BindableProperty.Create(nameof(Thickness), typeof(float), typeof(CircularProgress), default(float), propertyChanged: (bindable, oldValue, newValue) => { var instance = ((CircularProgress)bindable); - - // TODO Set viewStyle.Thickness after style refactoring done. - instance.UpdateVisualThickness((float)newValue); }, defaultValueCreator: (bindable) => { - return ((CircularProgress)bindable).Style.Thickness; + var instance = (CircularProgress)bindable; + return instance.trackVisual == null ? 0 : instance.trackVisual.Thickness; }); /// Bindable property of MaxValue @@ -106,14 +104,11 @@ namespace Tizen.NUI.Wearable public static readonly BindableProperty TrackColorProperty = BindableProperty.Create(nameof(TrackColor), typeof(Color), typeof(CircularProgress), null, propertyChanged: (bindable, oldValue, newValue) => { var instance = (CircularProgress)bindable; - - // TODO : Set viewStyle.TrackColor after style refactoring done. - instance.UpdateTrackVisualColor((Color)newValue); }, defaultValueCreator: (bindable) => { - return ((CircularProgress)bindable).Style.TrackColor; + return ((CircularProgress)bindable).trackVisual?.MixColor; }); /// Bindable property of ProgressColor @@ -121,14 +116,11 @@ namespace Tizen.NUI.Wearable public static readonly BindableProperty ProgressColorProperty = BindableProperty.Create(nameof(ProgressColor), typeof(Color), typeof(CircularProgress), null, propertyChanged: (bindable, oldValue, newValue) => { var instance = (CircularProgress)bindable; - - // TODO : Set viewStyle.ProgressColor after style refactoring done. - instance.UpdateProgressVisualColor((Color)newValue); }, defaultValueCreator: (bindable) => { - return ((CircularProgress)bindable).Style.ProgressColor; + return ((CircularProgress)bindable).progressVisual?.MixColor; }); /// Bindable property of IsEnabled @@ -210,7 +202,15 @@ namespace Tizen.NUI.Wearable /// Style setting is possible by using constructor or the function of ApplyStyle(ViewStyle viewStyle) /// [EditorBrowsable(EditorBrowsableState.Never)] - public new CircularProgressStyle Style => ViewStyle as CircularProgressStyle; + public new CircularProgressStyle Style + { + get + { + var result = new CircularProgressStyle(ViewStyle as CircularProgressStyle); + result.CopyPropertiesFromView(this); + return result; + } + } /// /// The thickness of the track and progress. diff --git a/src/Tizen.NUI.Wearable/src/public/CircularScrollbar.cs b/src/Tizen.NUI.Wearable/src/public/CircularScrollbar.cs index e4d8811..d369d59 100644 --- a/src/Tizen.NUI.Wearable/src/public/CircularScrollbar.cs +++ b/src/Tizen.NUI.Wearable/src/public/CircularScrollbar.cs @@ -36,14 +36,12 @@ namespace Tizen.NUI.Wearable public static readonly BindableProperty ThicknessProperty = BindableProperty.Create(nameof(Thickness), typeof(float), typeof(CircularScrollbar), default(float), propertyChanged: (bindable, oldValue, newValue) => { var instance = ((CircularScrollbar)bindable); - var thickness = (float?)newValue; - - instance.Style.Thickness = thickness; - instance.UpdateVisualThickness(thickness ?? 0); + instance.UpdateVisualThickness((float?)newValue ?? 0); }, defaultValueCreator: (bindable) => { - return ((CircularScrollbar)bindable).Style.Thickness ?? 0; + var instance = (CircularScrollbar)bindable; + return instance.trackVisual == null ? 0 : instance.trackVisual.Thickness; }); /// Bindable property of TrackSweepAngle @@ -51,14 +49,12 @@ namespace Tizen.NUI.Wearable public static readonly BindableProperty TrackSweepAngleProperty = BindableProperty.Create(nameof(TrackSweepAngle), typeof(float), typeof(CircularScrollbar), default(float), propertyChanged: (bindable, oldValue, newValue) => { var instance = ((CircularScrollbar)bindable); - var angle = (float?)newValue; - - instance.Style.TrackSweepAngle = angle; - instance.UpdateTrackVisualSweepAngle(angle ?? 0); + instance.UpdateTrackVisualSweepAngle((float?)newValue ?? 0); }, defaultValueCreator: (bindable) => { - return ((CircularScrollbar)bindable).Style.TrackSweepAngle ?? 0; + var instance = (CircularScrollbar)bindable; + return instance.trackVisual == null ? 0 : instance.trackVisual.SweepAngle; }); /// Bindable property of TrackColor @@ -66,14 +62,11 @@ namespace Tizen.NUI.Wearable public static readonly BindableProperty TrackColorProperty = BindableProperty.Create(nameof(TrackColor), typeof(Color), typeof(CircularScrollbar), null, propertyChanged: (bindable, oldValue, newValue) => { var instance = ((CircularScrollbar)bindable); - var color = (Color)newValue; - - instance.Style.TrackColor = color; - instance.UpdateTrackVisualColor(color); + instance.UpdateTrackVisualColor((Color)newValue); }, defaultValueCreator: (bindable) => { - return ((CircularScrollbar)bindable).Style.TrackColor; + return ((CircularScrollbar)bindable).trackVisual?.MixColor; }); /// Bindable property of ThumbColor @@ -81,14 +74,11 @@ namespace Tizen.NUI.Wearable public static readonly BindableProperty ThumbColorProperty = BindableProperty.Create(nameof(ThumbColor), typeof(Color), typeof(CircularScrollbar), null, propertyChanged: (bindable, oldValue, newValue) => { var instance = ((CircularScrollbar)bindable); - var color = (Color)newValue; - - instance.Style.ThumbColor = color; - instance.UpdateThumbVisualColor(color); + instance.UpdateThumbVisualColor((Color)newValue); }, defaultValueCreator: (bindable) => { - return ((CircularScrollbar)bindable).Style.ThumbColor; + return ((CircularScrollbar)bindable).thumbVisual?.MixColor; }); private ArcVisual trackVisual; @@ -154,7 +144,15 @@ namespace Tizen.NUI.Wearable /// Style setting is possible by using constructor or the function of ApplyStyle(ViewStyle viewStyle) /// [EditorBrowsable(EditorBrowsableState.Never)] - public new CircularScrollbarStyle Style => ViewStyle as CircularScrollbarStyle; + public new CircularScrollbarStyle Style + { + get + { + var result = new CircularScrollbarStyle(ViewStyle as CircularScrollbarStyle); + result.CopyPropertiesFromView(this); + return result; + } + } /// /// The thickness of the scrollbar and track. diff --git a/src/Tizen.NUI.Wearable/src/public/CircularSlider.cs b/src/Tizen.NUI.Wearable/src/public/CircularSlider.cs index 44d45c6..d7bece1 100755 --- a/src/Tizen.NUI.Wearable/src/public/CircularSlider.cs +++ b/src/Tizen.NUI.Wearable/src/public/CircularSlider.cs @@ -55,14 +55,12 @@ namespace Tizen.NUI.Wearable public static readonly BindableProperty ThicknessProperty = BindableProperty.Create(nameof(Thickness), typeof(float), typeof(CircularSlider), default(float), propertyChanged: (bindable, oldValue, newValue) => { var instance = ((CircularSlider)bindable); - - // TODO Set viewStyle.Thickness after style refactoring done. - instance.UpdateVisualThickness((float)newValue); }, defaultValueCreator: (bindable) => { - return ((CircularSlider)bindable).Style.Thickness; + var instance = (CircularSlider)bindable; + return instance.trackVisual == null ? 0 : instance.trackVisual.Thickness; }); /// Bindable property of MaxValue @@ -125,14 +123,11 @@ namespace Tizen.NUI.Wearable public static readonly BindableProperty TrackColorProperty = BindableProperty.Create(nameof(TrackColor), typeof(Color), typeof(CircularSlider), null, propertyChanged: (bindable, oldValue, newValue) => { var instance = (CircularSlider)bindable; - - // TODO : Set viewStyle.TrackColor after style refactoring done. - instance.UpdateTrackVisualColor((Color)newValue); }, defaultValueCreator: (bindable) => { - return ((CircularSlider)bindable).Style.TrackColor; + return ((CircularSlider)bindable).trackVisual?.MixColor; }); /// Bindable property of ProgressColor @@ -140,14 +135,11 @@ namespace Tizen.NUI.Wearable public static readonly BindableProperty ProgressColorProperty = BindableProperty.Create(nameof(ProgressColor), typeof(Color), typeof(CircularSlider), null, propertyChanged: (bindable, oldValue, newValue) => { var instance = (CircularSlider)bindable; - - // TODO : Set viewStyle.ProgressColor after style refactoring done. - instance.UpdateProgressVisualColor((Color)newValue); }, defaultValueCreator: (bindable) => { - return ((CircularSlider)bindable).Style.ProgressColor; + return ((CircularSlider)bindable).progressVisual?.MixColor; }); /// Bindable property of ThumbSize @@ -172,14 +164,11 @@ namespace Tizen.NUI.Wearable public static readonly BindableProperty ThumbColorProperty = BindableProperty.Create(nameof(ThumbColor), typeof(Color), typeof(CircularSlider), null, propertyChanged: (bindable, oldValue, newValue) => { var instance = (CircularSlider)bindable; - - // TODO : Set viewStyle.ThumbColor after style refactoring done. - instance.UpdateThumbVisualColor((Color)newValue); }, defaultValueCreator: (bindable) => { - return ((CircularSlider)bindable).Style.ThumbColor; + return ((CircularSlider)bindable).thumbVisual?.MixColor; }); /// Bindable property of IsEnabled @@ -263,7 +252,15 @@ namespace Tizen.NUI.Wearable /// Style setting is possible by using constructor or the function of ApplyStyle(ViewStyle viewStyle) /// [EditorBrowsable(EditorBrowsableState.Never)] - public new CircularSliderStyle Style => ViewStyle as CircularSliderStyle; + public new CircularSliderStyle Style + { + get + { + var result = new CircularSliderStyle(ViewStyle as CircularSliderStyle); + result.CopyPropertiesFromView(this); + return result; + } + } /// /// The thickness of the track and progress. diff --git a/src/Tizen.NUI.Wearable/src/public/Popup.cs b/src/Tizen.NUI.Wearable/src/public/Popup.cs index 98f52ba..48ee21c 100755 --- a/src/Tizen.NUI.Wearable/src/public/Popup.cs +++ b/src/Tizen.NUI.Wearable/src/public/Popup.cs @@ -207,11 +207,11 @@ namespace Tizen.NUI.Wearable leftButton.PositionUsesPivotPoint = true; leftButton.ParentOrigin = NUI.ParentOrigin.CenterLeft; leftButton.PivotPoint = NUI.PivotPoint.CenterLeft; - leftButton.Style.Overlay.SiblingOrder = 100; + leftButton.OverlayImage.SiblingOrder = 100; button.PositionUsesPivotPoint = true; button.ParentOrigin = NUI.ParentOrigin.CenterRight; button.PivotPoint = NUI.PivotPoint.CenterRight; - button.Style.Overlay.SiblingOrder = 100; + button.OverlayImage.SiblingOrder = 100; } } else @@ -220,7 +220,7 @@ namespace Tizen.NUI.Wearable buttonList.Add(index, button); Add(button); button.RaiseToTop(); - button.Style.Overlay.SiblingOrder = 100; //will be fixed. + button.OverlayImage.SiblingOrder = 100; //will be fixed. if (position == ButtonPosition.Left) { button.PositionUsesPivotPoint = true; diff --git a/src/Tizen.NUI.Wearable/src/public/Title.cs b/src/Tizen.NUI.Wearable/src/public/Title.cs index 104ae6a..c6f7265 100755 --- a/src/Tizen.NUI.Wearable/src/public/Title.cs +++ b/src/Tizen.NUI.Wearable/src/public/Title.cs @@ -78,7 +78,16 @@ namespace Tizen.NUI.Components Initialize(); } - public TextLabelStyle Style => ViewStyle as TextLabelStyle; + /// + /// Return a copied Style instance of the Title. + /// + /// + /// 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 . + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public new TextLabelStyle Style => ViewStyle as TextLabelStyle; + /// /// The constructor of the Title class with specific Style. /// diff --git a/src/Tizen.NUI/src/public/BaseComponents/ImageView.cs b/src/Tizen.NUI/src/public/BaseComponents/ImageView.cs index bf602f7..0985953 100644 --- a/src/Tizen.NUI/src/public/BaseComponents/ImageView.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/ImageView.cs @@ -161,9 +161,9 @@ namespace Tizen.NUI.BaseComponents [EditorBrowsable(EditorBrowsableState.Never)] public static readonly BindableProperty BorderProperty = BindableProperty.Create("Border", typeof(Rectangle), typeof(ImageView), null, propertyChanged: (bindable, oldValue, newValue) => { + var imageView = (ImageView)bindable; if(newValue != null) { - var imageView = (ImageView)bindable; imageView._border = (Rectangle)newValue; imageView.UpdateImage(NpatchImageVisualProperty.Border, new PropertyValue(imageView._border)); } @@ -233,6 +233,28 @@ namespace Tizen.NUI.BaseComponents return ret; }); + internal static readonly BindableProperty ResourceUrlSelectorProperty = BindableProperty.Create("ResourceUrlSelector", typeof(Selector), typeof(ImageView), null, propertyChanged: (bindable, oldValue, newValue) => + { + var imageView = (ImageView)bindable; + imageView.resourceUrlSelector.Update(imageView, (Selector)newValue, true); + }, + defaultValueCreator: (bindable) => + { + var imageView = (ImageView)bindable; + return imageView.resourceUrlSelector.Get(imageView); + }); + + internal static readonly BindableProperty BorderSelectorProperty = BindableProperty.Create("BorderSelector", typeof(Selector), typeof(ImageView), null, propertyChanged: (bindable, oldValue, newValue) => + { + var imageView = (ImageView)bindable; + imageView.borderSelector.Update(imageView, (Selector)newValue, true); + }, + defaultValueCreator: (bindable) => + { + var imageView = (ImageView)bindable; + return imageView.borderSelector.Get(imageView); + }); + private EventHandler _resourceReadyEventHandler; private ResourceReadyEventCallbackType _resourceReadyEventCallback; private EventHandler _resourceLoadedEventHandler; @@ -244,10 +266,12 @@ namespace Tizen.NUI.BaseComponents private string _alphaMaskUrl = null; private int _desired_width = -1; private int _desired_height = -1; + private readonly TriggerableSelector resourceUrlSelector = new TriggerableSelector(ResourceUrlProperty); + private readonly TriggerableSelector borderSelector = new TriggerableSelector(BorderProperty); /// 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 ImageViewStyle Style => ViewStyle as ImageViewStyle; + public new ImageViewStyle Style => new ImageViewStyle(this); /// /// Creates an initialized ImageView. @@ -426,6 +450,7 @@ namespace Tizen.NUI.BaseComponents set { SetValue(ResourceUrlProperty, value); + resourceUrlSelector.UpdateIfNeeds(this, value); NotifyPropertyChanged(); } } @@ -556,6 +581,7 @@ namespace Tizen.NUI.BaseComponents set { SetValue(BorderProperty, value); + borderSelector.UpdateIfNeeds(this, value); NotifyPropertyChanged(); } } @@ -991,9 +1017,9 @@ namespace Tizen.NUI.BaseComponents return ret; } - internal override void UpdateCornerRadius(float value, bool needToListenStateChanged) + internal override void UpdateCornerRadius(float value) { - base.UpdateCornerRadius(value, needToListenStateChanged); + base.UpdateCornerRadius(value); UpdateImage(0, null); } @@ -1003,52 +1029,6 @@ namespace Tizen.NUI.BaseComponents return (ResourceLoadingStatusType)Interop.View.View_GetVisualResourceStatus(this.swigCPtr, Property.IMAGE); } - internal static readonly BindableProperty ResourceUrlSelectorProperty = BindableProperty.Create("ResourceUrlSelector", typeof(Selector), typeof(ImageView), null, propertyChanged: (bindable, oldValue, newValue) => - { - var imageView = (ImageView)bindable; - imageView.resourceUrlSelector.Clone((Selector)newValue); - }, - defaultValueCreator: (bindable) => - { - var imageView = (ImageView)bindable; - return imageView.resourceUrlSelector; - }); - private TriggerableSelector _resourceUrlSelector; - private TriggerableSelector resourceUrlSelector - { - get - { - if (null == _resourceUrlSelector) - { - _resourceUrlSelector = new TriggerableSelector(this, ResourceUrlProperty); - } - return _resourceUrlSelector; - } - } - - internal static readonly BindableProperty BorderSelectorProperty = BindableProperty.Create("BorderSelector", typeof(Selector), typeof(ImageView), null, propertyChanged: (bindable, oldValue, newValue) => - { - var imageView = (ImageView)bindable; - imageView.borderSelector.Clone((Selector)newValue); - }, - defaultValueCreator: (bindable) => - { - var imageView = (ImageView)bindable; - return imageView.borderSelector; - }); - private TriggerableSelector _borderSelector; - private TriggerableSelector borderSelector - { - get - { - if (null == _borderSelector) - { - _borderSelector = new TriggerableSelector(this, BorderProperty); - } - return _borderSelector; - } - } - /// /// you can override it to clean-up your own resources. /// @@ -1068,6 +1048,8 @@ namespace Tizen.NUI.BaseComponents //You should release all of your own disposable objects here. _border?.Dispose(); _border = null; + borderSelector.Reset(this); + resourceUrlSelector.Reset(this); } base.Dispose(type); diff --git a/src/Tizen.NUI/src/public/BaseComponents/Style/ImageViewStyle.cs b/src/Tizen.NUI/src/public/BaseComponents/Style/ImageViewStyle.cs index 2982520..d3f24ef 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/Style/ImageViewStyle.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/Style/ImageViewStyle.cs @@ -32,8 +32,7 @@ namespace Tizen.NUI.BaseComponents public static readonly BindableProperty ResourceUrlSelectorProperty = BindableProperty.Create("ResourceUrlSelector", typeof(Selector), typeof(ImageViewStyle), null, propertyChanged: (bindable, oldValue, newValue) => { var imageViewStyle = (ImageViewStyle)bindable; - if (null == imageViewStyle.resourceUrlSelector) imageViewStyle.resourceUrlSelector = new Selector(); - imageViewStyle.resourceUrlSelector.Clone(null == newValue ? new Selector() : (Selector)newValue); + imageViewStyle.resourceUrlSelector = ((Selector)newValue)?.Clone(); }, defaultValueCreator: (bindable) => { @@ -69,8 +68,7 @@ namespace Tizen.NUI.BaseComponents public static readonly BindableProperty BorderSelectorProperty = BindableProperty.Create("BorderSelector", typeof(Selector), typeof(ImageViewStyle), null, propertyChanged: (bindable, oldValue, newValue) => { var imageViewStyle = (ImageViewStyle)bindable; - if (null == imageViewStyle.borderSelector) imageViewStyle.borderSelector = new Selector(); - imageViewStyle.borderSelector.Clone(null == newValue ? new Selector() : (Selector)newValue); + imageViewStyle.borderSelector = ((Selector)newValue)?.Clone(); }, defaultValueCreator: (bindable) => { @@ -124,6 +122,23 @@ namespace Tizen.NUI.BaseComponents static ImageViewStyle() { } + /// + /// Create an empty instance. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public ImageViewStyle() + { + } + + /// + /// Create an instance and set properties from the given ImageView. + /// + /// The ImageView instance that includes property data. + [EditorBrowsable(EditorBrowsableState.Never)] + public ImageViewStyle(ImageView imageView) : base(imageView) + { + } + /// 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 bool? PreMultipliedAlpha diff --git a/src/Tizen.NUI/src/public/BaseComponents/Style/Selector.cs b/src/Tizen.NUI/src/public/BaseComponents/Style/Selector.cs index cfe1894..ebf5b1f 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/Style/Selector.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/Style/Selector.cs @@ -29,13 +29,13 @@ namespace Tizen.NUI.BaseComponents [EditorBrowsable(EditorBrowsableState.Never)] public class Selector : StateValueCollection { + private readonly bool cloneable = typeof(T).IsAssignableFrom(typeof(ICloneable)); + /// 6 /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API. public static implicit operator Selector(T value) { - Selector selector = new Selector(); - selector.All = value; - return selector; + return new Selector(value); } /// Default Contructor @@ -48,9 +48,17 @@ namespace Tizen.NUI.BaseComponents [EditorBrowsable(EditorBrowsableState.Never)] public Selector(T value) : this() { - All = value; + All = cloneable ? (T)((ICloneable)value)?.Clone() : value; + } + + /// Copy constructor + [EditorBrowsable(EditorBrowsableState.Never)] + public Selector(Selector value) : this() + { + Clone(value); } + /// /// All State. /// @@ -166,274 +174,237 @@ namespace Tizen.NUI.BaseComponents /// /// 6 /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API. + /// True if the selector has a given state value, false otherwise. [EditorBrowsable(EditorBrowsableState.Never)] - public T GetValue(ControlState state) + public bool GetValue(ControlState state, out T result) { if (All != null) { - return All; + result = All; + + return true; } - StateValuePair value = Find(x => x.State == state); - if (value.Value != null) + result = default; + + int index = StateValueList.FindIndex(x => x.State == state); + if (index >= 0) { - return value.Value; + result = StateValueList[index].Value; + return true; } if (state.IsCombined) { - value = Find(x => state.Contains(x.State)); - if (value.Value != null) + index = StateValueList.FindIndex(x => state.Contains(x.State)); + if (index >= 0) { - return value.Value; + result = StateValueList[index].Value; + return true; } } - return Other; + index = StateValueList.FindIndex(x => x.State == ControlState.Other); + if (index >= 0) + { + result = StateValueList[index].Value; + return true; + } + + return false; } - /// - /// Clone function. - /// - /// 6 - /// 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 void Clone(Selector selector) + public override void Clear() { - All = selector.All; - Normal = selector.Normal; - Focused = selector.Focused; - Pressed = selector.Pressed; - Disabled = selector.Disabled; - Selected = selector.Selected; - DisabledSelected = selector.DisabledSelected; - DisabledFocused = selector.DisabledFocused; - SelectedFocused = selector.SelectedFocused; - Other = selector.Other; + All = default; + base.Clear(); } - internal void Clone(Selector other) where U : T, Tizen.NUI.Internal.ICloneable + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override string ToString() { - // TODO Apply constraint to the Selector (not to Clone method) - - All = (T)(other.All)?.Clone(); - Normal = (T)(other.Normal)?.Clone(); - Focused = (T)(other.Focused)?.Clone(); - Pressed = (T)(other.Pressed)?.Clone(); - Disabled = (T)(other.Disabled)?.Clone(); - Selected = (T)(other.Selected)?.Clone(); - DisabledSelected = (T)(other.DisabledSelected)?.Clone(); - DisabledFocused = (T)(other.DisabledFocused)?.Clone(); - SelectedFocused = (T)(other.SelectedFocused)?.Clone(); - Other = (T)(other.Other)?.Clone(); - } + string result = $"[All, {All}]"; - internal bool HasMultiValue() - { - return All == null; - } - } + foreach (var item in StateValueList) + { + result += $", {item}"; + } - /// 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 class TriggerableSelector : Selector - { - public TriggerableSelector(View view, BindableProperty bindableProperty) - { - targetView = view; - targetBindableProperty = bindableProperty; - view.ControlStateChangeEventInternal += OnViewControlState; + return result; } /// - /// Clone function. + /// Clone itself. + /// If type T implements ICloneable, it calls Clone() method to clone values, otherwise use operator=. /// /// 6 /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] - public new void Clone(Selector selector) + public Selector Clone() { - base.Clone(selector); - - if (null != targetView && null != GetValue(targetView.ControlState)) - { - targetView.SetValue(targetBindableProperty, GetValue(targetView.ControlState)); - } + var cloned = new Selector(); + cloned.Clone(this); + return cloned; } - private void OnViewControlState(object obj, View.ControlStateChangedEventArgs controlStateChangedInfo) + /// + /// Copy values from other selector. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public void Clone(Selector other) { - View view = obj as View; - if (null != view && null != GetValue(controlStateChangedInfo.CurrentState)) + Clear(); + + if (cloneable) { - view.SetValue(targetBindableProperty, GetValue(controlStateChangedInfo.CurrentState)); + All = (T)((ICloneable)other.All)?.Clone(); + foreach (var item in other.StateValueList) + { + AddWithoutCheck(new StateValuePair(item.State, (T)((ICloneable)item.Value)?.Clone())); + } + } + else + { + All = other.All; + foreach (var item in other.StateValueList) + { + AddWithoutCheck(item); + } } } - private View targetView; - private BindableProperty targetBindableProperty; + internal bool HasMultiValue() + { + return StateValueList.Count > 1; + } } /// - /// A class that helps binding a non-selector property in View to selector property in ViewStyle. + /// This will be attached to a View to detect ControlState change. /// - internal class ViewSelector + [EditorBrowsable(EditorBrowsableState.Never)] + public class TriggerableSelector { - protected Selector selector; - protected View view; - protected EventHandler controlStateChanged; + /// + /// Create an TriggerableSelector. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public delegate T ValueGetter(View view); - internal ViewSelector(View view, EventHandler controlStateChanged) - { - if (view == null || controlStateChanged == null) - { - throw new global::System.ArgumentNullException(); - } - this.view = view; - this.controlStateChanged = controlStateChanged; - this.selector = null; - } + private readonly BindableProperty targetBindableProperty; + private readonly ValueGetter propertyGetter; + private bool dirty = true; + private Selector selector; - internal T GetValue() + /// + /// Create an TriggerableSelector. + /// + /// The TriggerableSelector will change this bindable property value when the view's ControlState has changed. + /// It is optional value in case the target bindable property getter is not proper to use. + [EditorBrowsable(EditorBrowsableState.Never)] + public TriggerableSelector(BindableProperty targetBindableProperty, ValueGetter propertyGetter = null) { - return selector == null ? default(T) : selector.GetValue(view.ControlState); + this.targetBindableProperty = targetBindableProperty; + this.propertyGetter = propertyGetter; } - internal void Set(object value) + /// + /// Return the containing selector. It can be null. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Selector Get(View view) { - bool hadMultiValue = HasMultiValue(); - var type = value?.GetType(); + if (!dirty) return selector; - if (type == typeof(T)) - { - CopyValueToSelector((T)value); - } - else if (type == typeof(Selector)) - { - CopySelectorToSelector((Selector)value); - } - else if (type == Nullable.GetUnderlyingType(typeof(T))) + T value = default; + + if (propertyGetter != null) { - CopyValueToSelector((T)value); + value = propertyGetter(view); } else { - selector = null; + value = (T)view.GetValue(targetBindableProperty); } - if (hadMultiValue != HasMultiValue()) - { - if (hadMultiValue) view.ControlStateChangeEventInternal -= controlStateChanged; - else view.ControlStateChangeEventInternal += controlStateChanged; - } - } + Selector converted = value == null ? null : new Selector(value); + Update(view, converted); - protected virtual void CopyValueToSelector(T value) - { - selector = new Selector(); - selector.All = value; + return selector; } - protected virtual void CopySelectorToSelector(Selector value) + /// + /// Update containing selector from the other selector. + /// + /// The View that is affected by this TriggerableSelector. + /// The copy target. + /// Whether it updates the target view after update the selector or not. + [EditorBrowsable(EditorBrowsableState.Never)] + public void Update(View view, Selector otherSelector, bool updateView = false) { - selector = new Selector(); - selector.Clone(value); - } + Reset(view); - internal void Clear() - { - if (HasMultiValue()) + if (otherSelector == null) { - view.ControlStateChangeEventInternal -= controlStateChanged; + return; } - selector = null; - } - - internal bool IsEmpty() - { - return selector == null; - } - protected bool HasMultiValue() - { - return (selector != null && selector.All == null); - } - } - - /// - /// ViewSelector class for ICloneable type - /// - internal class CloneableViewSelector : ViewSelector where T : Tizen.NUI.Internal.ICloneable - { - internal CloneableViewSelector(View view, EventHandler controlStateChanged) : base(view, controlStateChanged) - { - } + selector = otherSelector.Clone(); - protected override void CopyValueToSelector(T value) - { - selector = new Selector(); - selector.All = (T)((T)value).Clone(); - } + if (otherSelector.HasMultiValue()) + { + view.ControlStateChangeEventInternal += OnViewControlState; + } - protected override void CopySelectorToSelector(Selector value) - { - selector = new Selector(); - selector.Clone((Selector)value); + if (updateView && otherSelector.GetValue(view.ControlState, out var value)) + { + view.SetValue(targetBindableProperty, value); + } } - } - internal static class SelectorHelper - { /// - /// For the object type of T or Selector T, convert it to Selector T and return the cloned one. - /// Otherwise, return null.
+ /// Update containing selector value from a single value. + /// Note that, it updates lazily if possible. + /// If you need to udpate directly, please use . ///
- static internal Selector CopyCloneable(object value) where T : class, Tizen.NUI.Internal.ICloneable + /// The View that is affected by this TriggerableSelector. + /// The copy target. + [EditorBrowsable(EditorBrowsableState.Never)] + public void UpdateIfNeeds(View view, T value) { - if (null != value) + if (selector != null && selector.HasMultiValue()) { - var type = value.GetType(); - - if (type == typeof(Selector)) - { - var result = new Selector(); - result.Clone((Selector)value); - return result; - } - - if (type == typeof(T)) - { - return new Selector((T)((T)value).Clone()); - } + Selector converted = value == null ? null : new Selector(value); + Update(view, converted); + return; } - return null; + dirty = true; } /// - /// For the value type of T or Selector T, convert it to Selector T and return the cloned one. - /// Otherwise, return null.
+ /// Reset selector and listeners. ///
- static internal Selector CopyValue(object value) + /// The View that is affected by this TriggerableSelector. + [EditorBrowsable(EditorBrowsableState.Never)] + public void Reset(View view) { - if (null != value) - { - var type = value.GetType(); - - if (type == typeof(Selector)) - { - var result = new Selector(); - result.Clone((Selector)value); - return result; - } + view.ControlStateChangeEventInternal -= OnViewControlState; + selector?.Clear(); + selector = null; + dirty = false; + } - if (type == typeof(T)) - { - return new Selector((T)value); - } + private void OnViewControlState(object obj, View.ControlStateChangedEventArgs controlStateChangedInfo) + { + View view = obj as View; + if (null != view && selector.GetValue(controlStateChangedInfo.CurrentState, out var value)) + { + view.SetValue(targetBindableProperty, value); } - - return null; } } } diff --git a/src/Tizen.NUI/src/public/BaseComponents/Style/StateValueCollection.cs b/src/Tizen.NUI/src/public/BaseComponents/Style/StateValueCollection.cs index b2e005e..eb9376a 100644 --- a/src/Tizen.NUI/src/public/BaseComponents/Style/StateValueCollection.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/Style/StateValueCollection.cs @@ -61,7 +61,7 @@ namespace Tizen.NUI.BaseComponents /// [EditorBrowsable(EditorBrowsableState.Never)] - public void Clear() => StateValueList.Clear(); + public virtual void Clear() => StateValueList.Clear(); /// [EditorBrowsable(EditorBrowsableState.Never)] @@ -89,5 +89,12 @@ namespace Tizen.NUI.BaseComponents /// The first element that matches the conditions defined by the specified predicate, /// if found; otherwise, the default value for type . public StateValuePair Find(Predicate> match) => StateValueList.Find(match); + + /// + /// Add a without duplication check. + /// + /// The StateValuePair item to add. + [EditorBrowsable(EditorBrowsableState.Never)] + internal void AddWithoutCheck(StateValuePair item) => StateValueList.Add(item); } } \ No newline at end of file diff --git a/src/Tizen.NUI/src/public/BaseComponents/Style/TextFieldStyle.cs b/src/Tizen.NUI/src/public/BaseComponents/Style/TextFieldStyle.cs index 4b90dbe..9fc70a6 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/Style/TextFieldStyle.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/Style/TextFieldStyle.cs @@ -32,11 +32,7 @@ namespace Tizen.NUI.BaseComponents public static readonly BindableProperty TranslatableTextSelectorProperty = BindableProperty.Create("TranslatableTextSelector", typeof(Selector), typeof(TextFieldStyle), null, propertyChanged: (bindable, oldValue, newValue) => { var textFieldStyle = (TextFieldStyle)bindable; - if (null == textFieldStyle.translatableTextSelector) - { - textFieldStyle.translatableTextSelector = new Selector(); - } - textFieldStyle.translatableTextSelector.Clone(null == newValue ? new Selector() : (Selector)newValue); + textFieldStyle.translatableTextSelector = ((Selector)newValue)?.Clone(); }, defaultValueCreator: (bindable) => { @@ -48,11 +44,7 @@ namespace Tizen.NUI.BaseComponents public static readonly BindableProperty TranslatablePlaceholderTextSelectorProperty = BindableProperty.Create("TranslatablePlaceholderTextSelector", typeof(Selector), typeof(TextFieldStyle), null, propertyChanged: (bindable, oldValue, newValue) => { var textFieldStyle = (TextFieldStyle)bindable; - if (null == textFieldStyle.translatablePlaceholderTextSelector) - { - textFieldStyle.translatablePlaceholderTextSelector = new Selector(); - } - textFieldStyle.translatablePlaceholderTextSelector.Clone(null == newValue ? new Selector() : (Selector)newValue); + textFieldStyle.translatablePlaceholderTextSelector = ((Selector)newValue)?.Clone(); }, defaultValueCreator: (bindable) => { @@ -64,11 +56,7 @@ namespace Tizen.NUI.BaseComponents public static readonly BindableProperty TextSelectorProperty = BindableProperty.Create(nameof(Text), typeof(Selector), typeof(TextFieldStyle), null, propertyChanged: (bindable, oldValue, newValue) => { var textFieldStyle = (TextFieldStyle)bindable; - if (null == textFieldStyle.textSelector) - { - textFieldStyle.textSelector = new Selector(); - } - textFieldStyle.textSelector.Clone(null == newValue ? new Selector() : (Selector)newValue); + textFieldStyle.textSelector = ((Selector)newValue)?.Clone(); }, defaultValueCreator: (bindable) => { @@ -80,11 +68,7 @@ namespace Tizen.NUI.BaseComponents public static readonly BindableProperty FontFamilySelectorProperty = BindableProperty.Create("FontFamilySelector", typeof(Selector), typeof(TextFieldStyle), null, propertyChanged: (bindable, oldValue, newValue) => { var textFieldStyle = (TextFieldStyle)bindable; - if (null == textFieldStyle.fontFamilySelector) - { - textFieldStyle.fontFamilySelector = new Selector(); - } - textFieldStyle.fontFamilySelector.Clone(null == newValue ? new Selector() : (Selector)newValue); + textFieldStyle.fontFamilySelector = ((Selector)newValue)?.Clone(); }, defaultValueCreator: (bindable) => { @@ -96,11 +80,7 @@ namespace Tizen.NUI.BaseComponents public static readonly BindableProperty PointSizeSelectorProperty = BindableProperty.Create("PointSizeSelector", typeof(Selector), typeof(TextFieldStyle), null, propertyChanged: (bindable, oldValue, newValue) => { var textFieldStyle = (TextFieldStyle)bindable; - if (null == textFieldStyle.pointSizeSelector) - { - textFieldStyle.pointSizeSelector = new Selector(); - } - textFieldStyle.pointSizeSelector.Clone(null == newValue ? new Selector() : (Selector)newValue); + textFieldStyle.pointSizeSelector = ((Selector)newValue)?.Clone(); }, defaultValueCreator: (bindable) => { @@ -112,11 +92,7 @@ namespace Tizen.NUI.BaseComponents public static readonly BindableProperty TextColorSelectorProperty = BindableProperty.Create("TextColorSelector", typeof(Selector), typeof(TextFieldStyle), null, propertyChanged: (bindable, oldValue, newValue) => { var textFieldStyle = (TextFieldStyle)bindable; - if (null == textFieldStyle.textColorSelector) - { - textFieldStyle.textColorSelector = new Selector(); - } - textFieldStyle.textColorSelector.Clone(null == newValue ? new Selector() : (Selector)newValue); + textFieldStyle.textColorSelector = ((Selector)newValue)?.Clone(); }, defaultValueCreator: (bindable) => { @@ -128,11 +104,7 @@ namespace Tizen.NUI.BaseComponents public static readonly BindableProperty PlaceholderTextColorSelectorProperty = BindableProperty.Create("PlaceholderTextColorSelector", typeof(Selector), typeof(TextFieldStyle), null, propertyChanged: (bindable, oldValue, newValue) => { var textFieldStyle = (TextFieldStyle)bindable; - if (null == textFieldStyle.placeholderTextColorSelector) - { - textFieldStyle.placeholderTextColorSelector = new Selector(); - } - textFieldStyle.placeholderTextColorSelector.Clone(null == newValue ? new Selector() : (Selector)newValue); + textFieldStyle.placeholderTextColorSelector = ((Selector)newValue)?.Clone(); }, defaultValueCreator: (bindable) => { @@ -144,11 +116,7 @@ namespace Tizen.NUI.BaseComponents public static readonly BindableProperty PrimaryCursorColorSelectorProperty = BindableProperty.Create("PrimaryCursorColorSelector", typeof(Selector), typeof(TextFieldStyle), null, propertyChanged: (bindable, oldValue, newValue) => { var textFieldStyle = (TextFieldStyle)bindable; - if (null == textFieldStyle.primaryCursorColorSelector) - { - textFieldStyle.primaryCursorColorSelector = new Selector(); - } - textFieldStyle.primaryCursorColorSelector.Clone(null == newValue ? new Selector() : (Selector)newValue); + textFieldStyle.primaryCursorColorSelector = ((Selector)newValue)?.Clone(); }, defaultValueCreator: (bindable) => { @@ -558,6 +526,23 @@ namespace Tizen.NUI.BaseComponents static TextFieldStyle() { } + /// + /// Create an empty instance. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public TextFieldStyle() + { + } + + /// + /// Create an instance and set properties from the given TextField. + /// + /// The TextField instance that includes property data. + [EditorBrowsable(EditorBrowsableState.Never)] + public TextFieldStyle(TextField textField) : base(textField) + { + } + /// 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 Selector TranslatableText diff --git a/src/Tizen.NUI/src/public/BaseComponents/Style/TextLabelStyle.cs b/src/Tizen.NUI/src/public/BaseComponents/Style/TextLabelStyle.cs index f478ea3..ef3d298 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/Style/TextLabelStyle.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/Style/TextLabelStyle.cs @@ -31,66 +31,51 @@ namespace Tizen.NUI.BaseComponents [EditorBrowsable(EditorBrowsableState.Never)] public static readonly BindableProperty TranslatableTextSelectorProperty = BindableProperty.Create("TranslatableTextSelector", typeof(Selector), typeof(TextLabelStyle), null, propertyChanged: (bindable, oldValue, newValue) => { - var textFieldStyle = (TextLabelStyle)bindable; - if (null == textFieldStyle.translatableTextSelector) textFieldStyle.translatableTextSelector = new Selector(); - textFieldStyle.translatableTextSelector.Clone(null == newValue ? new Selector() : (Selector)newValue); + ((TextLabelStyle)bindable).translatableTextSelector = ((Selector)newValue)?.Clone(); }, defaultValueCreator: (bindable) => { - var textFieldStyle = (TextLabelStyle)bindable; - return textFieldStyle.translatableTextSelector; + return ((TextLabelStyle)bindable).translatableTextSelector; }); /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] public static readonly BindableProperty TextSelectorProperty = BindableProperty.Create("TextSelector", typeof(Selector), typeof(TextLabelStyle), null, propertyChanged: (bindable, oldValue, newValue) => { - var textFieldStyle = (TextLabelStyle)bindable; - if (null == textFieldStyle.textSelector) textFieldStyle.textSelector = new Selector(); - textFieldStyle.textSelector.Clone(null == newValue ? new Selector() : (Selector)newValue); + ((TextLabelStyle)bindable).textSelector = ((Selector)newValue)?.Clone(); }, defaultValueCreator: (bindable) => { - var textFieldStyle = (TextLabelStyle)bindable; - return textFieldStyle.textSelector; + return ((TextLabelStyle)bindable).textSelector; }); /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] public static readonly BindableProperty FontFamilySelectorProperty = BindableProperty.Create("FontFamilySelector", typeof(Selector), typeof(TextLabelStyle), null, propertyChanged: (bindable, oldValue, newValue) => { - var textFieldStyle = (TextLabelStyle)bindable; - if (null == textFieldStyle.fontFamilySelector) textFieldStyle.fontFamilySelector = new Selector(); - textFieldStyle.fontFamilySelector.Clone(null == newValue ? new Selector() : (Selector)newValue); + ((TextLabelStyle)bindable).fontFamilySelector = ((Selector)newValue)?.Clone(); }, defaultValueCreator: (bindable) => { - var textFieldStyle = (TextLabelStyle)bindable; - return textFieldStyle.fontFamilySelector; + return ((TextLabelStyle)bindable).fontFamilySelector; }); /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] public static readonly BindableProperty PointSizeSelectorProperty = BindableProperty.Create("PointSizeSelector", typeof(Selector), typeof(TextLabelStyle), null, propertyChanged: (bindable, oldValue, newValue) => { - var textFieldStyle = (TextLabelStyle)bindable; - if (null == textFieldStyle.pointSizeSelector) textFieldStyle.pointSizeSelector = new Selector(); - textFieldStyle.pointSizeSelector.Clone(null == newValue ? new Selector() : (Selector)newValue); + ((TextLabelStyle)bindable).pointSizeSelector = ((Selector)newValue)?.Clone(); }, defaultValueCreator: (bindable) => { - var textFieldStyle = (TextLabelStyle)bindable; - return textFieldStyle.pointSizeSelector; + return ((TextLabelStyle)bindable).pointSizeSelector; }); /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] public static readonly BindableProperty TextColorSelectorProperty = BindableProperty.Create("TextColorSelector", typeof(Selector), typeof(TextLabelStyle), null, propertyChanged: (bindable, oldValue, newValue) => { - var textFieldStyle = (TextLabelStyle)bindable; - if (null == textFieldStyle.textColorSelector) textFieldStyle.textColorSelector = new Selector(); - textFieldStyle.textColorSelector.Clone(null == newValue ? new Selector() : (Selector)newValue); + ((TextLabelStyle)bindable).textColorSelector = ((Selector)newValue)?.Clone(); }, defaultValueCreator: (bindable) => { - var textFieldStyle = (TextLabelStyle)bindable; - return textFieldStyle.textColorSelector; + return ((TextLabelStyle)bindable).textColorSelector; }); /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API. @@ -299,15 +284,13 @@ namespace Tizen.NUI.BaseComponents }); /// A BindableProperty for ImageShadow [EditorBrowsable(EditorBrowsableState.Never)] - public static readonly BindableProperty TextShadowProperty = BindableProperty.Create(nameof(TextShadow), typeof(Selector), typeof(TextLabelStyle), null, propertyChanged: (bindable, oldValue, newValue) => + public static readonly BindableProperty TextShadowProperty = BindableProperty.Create("TextShadowSelector", typeof(Selector), typeof(TextLabelStyle), null, propertyChanged: (bindable, oldValue, newValue) => { - var textLabelStyle = (TextLabelStyle)bindable; - textLabelStyle.textShadow = SelectorHelper.CopyCloneable(newValue); + ((TextLabelStyle)bindable).textShadow = ((Selector)newValue)?.Clone(); }, defaultValueCreator: (bindable) => { - var textLabelStyle = (TextLabelStyle)bindable; - return textLabelStyle.textShadow; + return ((TextLabelStyle)bindable).textShadow; }); private bool? multiLine; @@ -336,6 +319,23 @@ namespace Tizen.NUI.BaseComponents static TextLabelStyle() { } + /// + /// Create an empty instance. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public TextLabelStyle() + { + } + + /// + /// Create an instance and set properties from the given TextLabel. + /// + /// The TextLabel instance that includes property data. + [EditorBrowsable(EditorBrowsableState.Never)] + public TextLabelStyle(TextLabel textLabel) : base(textLabel) + { + } + /// 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 Selector TranslatableText diff --git a/src/Tizen.NUI/src/public/BaseComponents/Style/ViewStyle.cs b/src/Tizen.NUI/src/public/BaseComponents/Style/ViewStyle.cs index 9fa6bc8..0d0cf0a 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/Style/ViewStyle.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/Style/ViewStyle.cs @@ -15,6 +15,7 @@ * */ using System; +using System.Collections.Generic; using System.ComponentModel; using Tizen.NUI.Binding; @@ -28,7 +29,6 @@ namespace Tizen.NUI.BaseComponents public partial class ViewStyle : BindableObject { private string styleName; - private string backgroundImage; private View.States? state; private View.States? subState; private float? flex; @@ -44,23 +44,13 @@ namespace Tizen.NUI.BaseComponents private View upFocusableView; private View downFocusableView; private bool? focusable; - private Size2D size2D; - private Position2D position2D; private bool? positionUsesPivotPoint; private int? siblingOrder; private Position parentOrigin; private Position pivotPoint; - private float? sizeWidth; - private float? sizeHeight; private Position position; - private float? positionX; - private float? positionY; - private float? positionZ; private Rotation orientation; private Vector3 scale; - private float? scaleX; - private float? scaleY; - private float? scaleZ; private string name; private bool? sensitive; private bool? leaveRequired; @@ -109,6 +99,16 @@ namespace Tizen.NUI.BaseComponents } } + /// + /// Create an instance and set properties from the given view. + /// + /// The View that includes property data. + [EditorBrowsable(EditorBrowsableState.Never)] + public ViewStyle(View view) + { + CopyPropertiesFromView(view); + } + /// 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 string StyleName @@ -660,9 +660,34 @@ namespace Tizen.NUI.BaseComponents set => SetValue(CornerRadiusProperty, value); } + /// + /// Set style's bindable properties from the view. + /// + /// The view that includes property data. + [EditorBrowsable(EditorBrowsableState.Never)] + public virtual void CopyPropertiesFromView(View view) + { + if (view == null) return; + + BindableProperty.GetBindablePropertysOfType(GetType(), out var styleProperties); + BindableProperty.GetBindablePropertysOfType(view.GetType(), out var viewProperties); + + + if (styleProperties == null || viewProperties == null) return; + + foreach (var stylePropertyItem in styleProperties) + { + viewProperties.TryGetValue(stylePropertyItem.Key, out var viewProperty); + + if (viewProperty == null) continue; + + SetValue(stylePropertyItem.Value, view.GetValue(viewProperty)); + } + } + internal ViewStyle CreateInstance() { - return (ViewStyle)Activator.CreateInstance(GetType());; + return (ViewStyle)Activator.CreateInstance(GetType()); } internal ViewStyle Clone() diff --git a/src/Tizen.NUI/src/public/BaseComponents/Style/ViewStyleBindableProperty.cs b/src/Tizen.NUI/src/public/BaseComponents/Style/ViewStyleBindableProperty.cs index 056bd18..fcdd29b 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/Style/ViewStyleBindableProperty.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/Style/ViewStyleBindableProperty.cs @@ -38,8 +38,16 @@ namespace Tizen.NUI.BaseComponents public static readonly BindableProperty BackgroundImageSelectorProperty = BindableProperty.Create("BackgroundImageSelector", typeof(Selector), typeof(ViewStyle), null, propertyChanged: (bindable, oldValue, newValue) => { var viewStyle = (ViewStyle)bindable; - if (null == viewStyle.backgroundImageSelector) viewStyle.backgroundImageSelector = new Selector(); - viewStyle.backgroundImageSelector.Clone(null == newValue ? new Selector() : (Selector)newValue); + + if (newValue == null) + { + viewStyle.backgroundImageSelector = null; + } + else + { + viewStyle.backgroundImageSelector = ((Selector)newValue).Clone(); + viewStyle.backgroundColorSelector = null; + } }, defaultValueCreator: (bindable) => { @@ -231,20 +239,18 @@ namespace Tizen.NUI.BaseComponents public static readonly BindableProperty Size2DProperty = BindableProperty.Create(nameof(Size2D), typeof(Size2D), typeof(ViewStyle), null, propertyChanged: (bindable, oldValue, newValue) => { var viewStyle = (ViewStyle)bindable; - viewStyle.size2D = (Size2D)newValue; + viewStyle.size = newValue == null ? null : new Size((Size2D)newValue); }, defaultValueCreator: (bindable) => { var viewStyle = (ViewStyle)bindable; - return viewStyle.size2D; + return viewStyle.size == null ? null : (Size2D)viewStyle.size; }); /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] public static readonly BindableProperty OpacitySelectorProperty = BindableProperty.Create("OpacitySelector", typeof(Selector), typeof(ViewStyle), null, propertyChanged: (bindable, oldValue, newValue) => { - var viewStyle = (ViewStyle)bindable; - if (null == viewStyle.opacitySelector) viewStyle.opacitySelector = new Selector(); - viewStyle.opacitySelector.Clone(null == newValue ? new Selector() : (Selector)newValue); + ((ViewStyle)bindable).opacitySelector = ((Selector)newValue)?.Clone(); }, defaultValueCreator: (bindable) => { @@ -256,12 +262,12 @@ namespace Tizen.NUI.BaseComponents public static readonly BindableProperty Position2DProperty = BindableProperty.Create(nameof(Position2D), typeof(Position2D), typeof(ViewStyle), null, propertyChanged: (bindable, oldValue, newValue) => { var viewStyle = (ViewStyle)bindable; - viewStyle.position2D = (Position2D)newValue; + viewStyle.position = newValue == null ? null : new Position((Position2D)newValue); }, defaultValueCreator: (bindable) => { var viewStyle = (ViewStyle)bindable; - return viewStyle.position2D; + return viewStyle.position == null ? null : new Position2D(viewStyle.position); }); /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] @@ -316,24 +322,36 @@ namespace Tizen.NUI.BaseComponents public static readonly BindableProperty SizeWidthProperty = BindableProperty.Create(nameof(SizeWidth), typeof(float?), typeof(ViewStyle), null, propertyChanged: (bindable, oldValue, newValue) => { var viewStyle = (ViewStyle)bindable; - viewStyle.sizeWidth = (float?)newValue; + if (newValue != null) + { + if (viewStyle.size == null) + { + viewStyle.size = new Size(); + } + viewStyle.size.Width = (float)newValue; + } }, defaultValueCreator: (bindable) => { - var viewStyle = (ViewStyle)bindable; - return viewStyle.sizeWidth; + return ((ViewStyle)bindable).size?.Width; }); /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] public static readonly BindableProperty SizeHeightProperty = BindableProperty.Create(nameof(SizeHeight), typeof(float?), typeof(ViewStyle), null, propertyChanged: (bindable, oldValue, newValue) => { var viewStyle = (ViewStyle)bindable; - viewStyle.sizeHeight = (float?)newValue; + if (newValue != null) + { + if (viewStyle.size == null) + { + viewStyle.size = new Size(); + } + viewStyle.size.Height = (float)newValue; + } }, defaultValueCreator: (bindable) => { - var viewStyle = (ViewStyle)bindable; - return viewStyle.sizeHeight; + return ((ViewStyle)bindable).size?.Height; }); /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] @@ -352,36 +370,54 @@ namespace Tizen.NUI.BaseComponents public static readonly BindableProperty PositionXProperty = BindableProperty.Create(nameof(PositionX), typeof(float?), typeof(ViewStyle), null, propertyChanged: (bindable, oldValue, newValue) => { var viewStyle = (ViewStyle)bindable; - viewStyle.positionX = (float?)newValue; + if (newValue != null) + { + if (viewStyle.position == null) + { + viewStyle.position = new Position(); + } + viewStyle.position.X = (float)newValue; + } }, defaultValueCreator: (bindable) => { - var viewStyle = (ViewStyle)bindable; - return viewStyle.positionX; + return ((ViewStyle)bindable).position?.X; }); /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] public static readonly BindableProperty PositionYProperty = BindableProperty.Create(nameof(PositionY), typeof(float?), typeof(ViewStyle), null, propertyChanged: (bindable, oldValue, newValue) => { var viewStyle = (ViewStyle)bindable; - viewStyle.positionY = (float?)newValue; + if (newValue != null) + { + if (viewStyle.position == null) + { + viewStyle.position = new Position(); + } + viewStyle.position.Y = (float)newValue; + } }, defaultValueCreator: (bindable) => { - var viewStyle = (ViewStyle)bindable; - return viewStyle.positionY; + return ((ViewStyle)bindable).position?.Y; }); /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] public static readonly BindableProperty PositionZProperty = BindableProperty.Create(nameof(PositionZ), typeof(float?), typeof(ViewStyle), null, propertyChanged: (bindable, oldValue, newValue) => { var viewStyle = (ViewStyle)bindable; - viewStyle.positionZ = (float?)newValue; + if (newValue != null) + { + if (viewStyle.position == null) + { + viewStyle.position = new Position(); + } + viewStyle.position.Z = (float)newValue; + } }, defaultValueCreator: (bindable) => { - var viewStyle = (ViewStyle)bindable; - return viewStyle.positionZ; + return ((ViewStyle)bindable).position?.Z; }); /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] @@ -412,36 +448,54 @@ namespace Tizen.NUI.BaseComponents public static readonly BindableProperty ScaleXProperty = BindableProperty.Create(nameof(ScaleX), typeof(float?), typeof(ViewStyle), null, propertyChanged: (bindable, oldValue, newValue) => { var viewStyle = (ViewStyle)bindable; - viewStyle.scaleX = (float?)newValue; + if (newValue != null) + { + if (viewStyle.scale == null) + { + viewStyle.scale = new Vector3(); + } + viewStyle.scale.X = (float)newValue; + } }, defaultValueCreator: (bindable) => { - var viewStyle = (ViewStyle)bindable; - return viewStyle.scaleX; + return ((ViewStyle)bindable).scale?.X; }); /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] public static readonly BindableProperty ScaleYProperty = BindableProperty.Create(nameof(ScaleY), typeof(float?), typeof(ViewStyle), null, propertyChanged: (bindable, oldValue, newValue) => { var viewStyle = (ViewStyle)bindable; - viewStyle.scaleY = (float?)newValue; + if (newValue != null) + { + if (viewStyle.scale == null) + { + viewStyle.scale = new Vector3(); + } + viewStyle.scale.Y = (float)newValue; + } }, defaultValueCreator: (bindable) => { - var viewStyle = (ViewStyle)bindable; - return viewStyle.scaleY; + return ((ViewStyle)bindable).scale?.Y; }); /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] public static readonly BindableProperty ScaleZProperty = BindableProperty.Create(nameof(ScaleZ), typeof(float?), typeof(ViewStyle), null, propertyChanged: (bindable, oldValue, newValue) => { var viewStyle = (ViewStyle)bindable; - viewStyle.scaleZ = (float?)newValue; + if (newValue != null) + { + if (viewStyle.scale == null) + { + viewStyle.scale = new Vector3(); + } + viewStyle.scale.Z = (float)newValue; + } }, defaultValueCreator: (bindable) => { - var viewStyle = (ViewStyle)bindable; - return viewStyle.scaleZ; + return ((ViewStyle)bindable).scale?.Z; }); /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] @@ -714,8 +768,17 @@ namespace Tizen.NUI.BaseComponents public static readonly BindableProperty BackgroundColorSelectorProperty = BindableProperty.Create("BackgroundColorSelector", typeof(Selector), typeof(ViewStyle), null, propertyChanged: (bindable, oldValue, newValue) => { var viewStyle = (ViewStyle)bindable; - if (null == viewStyle.backgroundColorSelector) viewStyle.backgroundColorSelector = new Selector(); - viewStyle.backgroundColorSelector.Clone(null == newValue ? new Selector() : (Selector)newValue); + + if (newValue == null) + { + viewStyle.backgroundColorSelector = null; + } + else + { + viewStyle.backgroundColorSelector = ((Selector)newValue).Clone(); + viewStyle.backgroundImageSelector = null; + } + }, defaultValueCreator: (bindable) => { @@ -726,9 +789,7 @@ namespace Tizen.NUI.BaseComponents [EditorBrowsable(EditorBrowsableState.Never)] public static readonly BindableProperty ColorSelectorProperty = BindableProperty.Create("ColorSelector", typeof(Selector), typeof(ViewStyle), null, propertyChanged: (bindable, oldValue, newValue) => { - var viewStyle = (ViewStyle)bindable; - if (null == viewStyle.colorSelector) viewStyle.colorSelector = new Selector(); - viewStyle.colorSelector.Clone(null == newValue ? new Selector() : (Selector)newValue); + ((ViewStyle)bindable).colorSelector = ((Selector)newValue)?.Clone(); }, defaultValueCreator: (bindable) => { @@ -740,10 +801,7 @@ namespace Tizen.NUI.BaseComponents [EditorBrowsable(EditorBrowsableState.Never)] public static readonly BindableProperty BackgroundImageBorderSelectorProperty = BindableProperty.Create("BackgroundImageBorderSelector", typeof(Selector), typeof(ViewStyle), null, propertyChanged: (bindable, oldValue, newValue) => { - var viewStyle = (ViewStyle)bindable; - if (null == viewStyle.backgroundImageBorderSelector) viewStyle.backgroundImageBorderSelector = new Selector(); - - viewStyle.backgroundImageBorderSelector.Clone(newValue == null ? new Selector() : (Selector)newValue); + ((ViewStyle)bindable).backgroundImageBorderSelector = ((Selector)newValue)?.Clone(); }, defaultValueCreator: (bindable) => { @@ -757,8 +815,7 @@ namespace Tizen.NUI.BaseComponents { var viewStyle = (ViewStyle)bindable; - viewStyle.imageShadow = (Selector)newValue; - + viewStyle.imageShadow = ((Selector)newValue)?.Clone(); viewStyle.boxShadow = null; }, defaultValueCreator: (bindable) => @@ -773,8 +830,7 @@ namespace Tizen.NUI.BaseComponents { var viewStyle = (ViewStyle)bindable; - viewStyle.boxShadow = (Selector)newValue; - + viewStyle.boxShadow = ((Selector)newValue)?.Clone(); viewStyle.imageShadow = null; }, defaultValueCreator: (bindable) => @@ -787,8 +843,7 @@ namespace Tizen.NUI.BaseComponents [EditorBrowsable(EditorBrowsableState.Never)] public static readonly BindableProperty CornerRadiusProperty = BindableProperty.Create("CornerRadiusSelector", typeof(Selector), typeof(ViewStyle), null, propertyChanged: (bindable, oldValue, newValue) => { - var viewStyle = (ViewStyle)bindable; - viewStyle.cornerRadius = (Selector)(newValue); + ((ViewStyle)bindable).cornerRadius = ((Selector)(newValue))?.Clone(); }, defaultValueCreator: (bindable) => { diff --git a/src/Tizen.NUI/src/public/BaseComponents/TextField.cs b/src/Tizen.NUI/src/public/BaseComponents/TextField.cs index 062ac73..a2849ea 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/TextField.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/TextField.cs @@ -34,12 +34,13 @@ namespace Tizen.NUI.BaseComponents private string textFieldPlaceHolderTextSid = null; private bool systemlangTextFlag = false; private InputMethodContext inputMethodCotext = null; + private TextFieldSelectorData selectorData; static TextField() { } /// 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 TextFieldStyle Style => ViewStyle as TextFieldStyle; + public new TextFieldStyle Style => new TextFieldStyle(this); /// /// Creates the TextField control. @@ -121,6 +122,7 @@ namespace Tizen.NUI.BaseComponents } set { + selectorData?.TranslatableText.UpdateIfNeeds(this, value); SetValue(TranslatableTextProperty, value); } } @@ -159,6 +161,7 @@ namespace Tizen.NUI.BaseComponents set { SetValue(TranslatablePlaceholderTextProperty, value); + selectorData?.TranslatablePlaceholderText.UpdateIfNeeds(this, value); } } private string translatablePlaceholderText @@ -192,6 +195,7 @@ namespace Tizen.NUI.BaseComponents set { SetValueAndForceSendChangeSignal(TextProperty, value); + selectorData?.Text.UpdateIfNeeds(this, value); NotifyPropertyChanged(); } } @@ -243,6 +247,7 @@ namespace Tizen.NUI.BaseComponents set { SetValue(FontFamilyProperty, value); + selectorData?.FontFamily.UpdateIfNeeds(this, value); NotifyPropertyChanged(); } } @@ -277,6 +282,7 @@ namespace Tizen.NUI.BaseComponents set { SetValue(PointSizeProperty, value); + selectorData?.PointSize.UpdateIfNeeds(this, value); NotifyPropertyChanged(); } } @@ -367,6 +373,7 @@ namespace Tizen.NUI.BaseComponents set { SetValue(TextColorProperty, value); + selectorData?.TextColor.UpdateIfNeeds(this, value); NotifyPropertyChanged(); } } @@ -388,6 +395,7 @@ namespace Tizen.NUI.BaseComponents set { SetValue(PlaceholderTextColorProperty, value); + selectorData?.PlaceholderTextColor.UpdateIfNeeds(this, value); NotifyPropertyChanged(); } } @@ -465,6 +473,7 @@ namespace Tizen.NUI.BaseComponents set { SetValue(PrimaryCursorColorProperty, value); + selectorData?.PrimaryCursorColor.UpdateIfNeeds(this, value); NotifyPropertyChanged(); } } @@ -1232,6 +1241,18 @@ namespace Tizen.NUI.BaseComponents } } + private TextFieldSelectorData SelectorData + { + get + { + if (selectorData == null) + { + selectorData = new TextFieldSelectorData(); + } + return selectorData; + } + } + /// /// Get the InputMethodContext instance. /// @@ -1296,6 +1317,14 @@ namespace Tizen.NUI.BaseComponents return; } + if (type == DisposeTypes.Explicit) + { + //Called by User + //Release your own managed resources here. + //You should release all of your own disposable objects here. + selectorData?.Reset(this); + } + //Release your own unmanaged resources here. //You should not access any managed member here except static instance. //because the execution order of Finalizes is non-deterministic. @@ -1430,191 +1459,6 @@ namespace Tizen.NUI.BaseComponents } } - internal static readonly BindableProperty TranslatableTextSelectorProperty = BindableProperty.Create("TranslatableTextSelector", typeof(Selector), typeof(TextField), null, propertyChanged: (bindable, oldValue, newValue) => - { - var textField = (TextField)bindable; - textField.translatableTextSelector.Clone((Selector)newValue); - }, - defaultValueCreator: (bindable) => - { - var textField = (TextField)bindable; - return textField.translatableTextSelector; - }); - internal static readonly BindableProperty TranslatablePlaceholderTextSelectorProperty = BindableProperty.Create("TranslatablePlaceholderTextSelector", typeof(Selector), typeof(TextField), null, propertyChanged: (bindable, oldValue, newValue) => - { - var textField = (TextField)bindable; - textField.translatablePlaceholderTextSelector.Clone((Selector)newValue); - }, - defaultValueCreator: (bindable) => - { - var textField = (TextField)bindable; - return textField.translatablePlaceholderTextSelector; - }); - internal static readonly BindableProperty TextSelectorProperty = BindableProperty.Create("TextSelector", typeof(Selector), typeof(TextField), null, propertyChanged: (bindable, oldValue, newValue) => - { - var textField = (TextField)bindable; - textField.textSelector.Clone((Selector)newValue); - }, - defaultValueCreator: (bindable) => - { - var textField = (TextField)bindable; - return textField.textSelector; - }); - internal static readonly BindableProperty FontFamilySelectorProperty = BindableProperty.Create("FontFamilySelector", typeof(Selector), typeof(TextField), null, propertyChanged: (bindable, oldValue, newValue) => - { - var textField = (TextField)bindable; - textField.fontFamilySelector.Clone((Selector)newValue); - }, - defaultValueCreator: (bindable) => - { - var textField = (TextField)bindable; - return textField.fontFamilySelector; - }); - internal static readonly BindableProperty PointSizeSelectorProperty = BindableProperty.Create("PointSizeSelector", typeof(Selector), typeof(TextField), null, propertyChanged: (bindable, oldValue, newValue) => - { - var textField = (TextField)bindable; - textField.pointSizeSelector.Clone((Selector)newValue); - }, - defaultValueCreator: (bindable) => - { - var textField = (TextField)bindable; - return textField.pointSizeSelector; - }); - internal static readonly BindableProperty TextColorSelectorProperty = BindableProperty.Create("TextColorSelector", typeof(Selector), typeof(TextField), null, propertyChanged: (bindable, oldValue, newValue) => - { - var textField = (TextField)bindable; - textField.textColorSelector.Clone((Selector)newValue); - }, - defaultValueCreator: (bindable) => - { - var textField = (TextField)bindable; - return textField.textColorSelector; - }); - internal static readonly BindableProperty PlaceholderTextColorSelectorProperty = BindableProperty.Create("PlaceholderTextColorSelector", typeof(Selector), typeof(TextField), null, propertyChanged: (bindable, oldValue, newValue) => - { - var textField = (TextField)bindable; - textField.placeholderTextColorSelector.Clone((Selector)newValue); - }, - defaultValueCreator: (bindable) => - { - var textField = (TextField)bindable; - return textField.placeholderTextColorSelector; - }); - internal static readonly BindableProperty PrimaryCursorColorSelectorProperty = BindableProperty.Create("PrimaryCursorColorSelector", typeof(Selector), typeof(TextField), null, propertyChanged: (bindable, oldValue, newValue) => - { - var textField = (TextField)bindable; - textField.primaryCursorColorSelector.Clone((Selector)newValue); - }, - defaultValueCreator: (bindable) => - { - var textField = (TextField)bindable; - return textField.primaryCursorColorSelector; - }); - - private TriggerableSelector _translatableTextSelector; - private TriggerableSelector translatableTextSelector - { - get - { - if (null == _translatableTextSelector) - { - _translatableTextSelector = new TriggerableSelector(this, TranslatableTextProperty); - } - return _translatableTextSelector; - } - } - - private TriggerableSelector _translatablePlaceholderTextSelector; - private TriggerableSelector translatablePlaceholderTextSelector - { - get - { - if (null == _translatablePlaceholderTextSelector) - { - _translatablePlaceholderTextSelector = new TriggerableSelector(this, TranslatablePlaceholderTextProperty); - } - return _translatablePlaceholderTextSelector; - } - } - - private TriggerableSelector _textSelector; - private TriggerableSelector textSelector - { - get - { - if (null == _textSelector) - { - _textSelector = new TriggerableSelector(this, TextProperty); - } - return _textSelector; - } - } - - private TriggerableSelector _fontFamilySelector; - private TriggerableSelector fontFamilySelector - { - get - { - if (null == _fontFamilySelector) - { - _fontFamilySelector = new TriggerableSelector(this, FontFamilyProperty); - } - return _fontFamilySelector; - } - } - - private TriggerableSelector _textColorSelector; - private TriggerableSelector textColorSelector - { - get - { - if (null == _textColorSelector) - { - _textColorSelector = new TriggerableSelector(this, TextColorProperty); - } - return _textColorSelector; - } - } - - private TriggerableSelector _pointSizeSelector; - private TriggerableSelector pointSizeSelector - { - get - { - if (null == _pointSizeSelector) - { - _pointSizeSelector = new TriggerableSelector(this, PointSizeProperty); - } - return _pointSizeSelector; - } - } - - private TriggerableSelector _placeholderTextColorSelector; - private TriggerableSelector placeholderTextColorSelector - { - get - { - if (null == _placeholderTextColorSelector) - { - _placeholderTextColorSelector = new TriggerableSelector(this, PlaceholderTextColorProperty); - } - return _placeholderTextColorSelector; - } - } - - private TriggerableSelector _primaryCursorColorSelector; - private TriggerableSelector primaryCursorColorSelector - { - get - { - if (null == _primaryCursorColorSelector) - { - _primaryCursorColorSelector = new TriggerableSelector(this, PrimaryCursorColorProperty); - } - return _primaryCursorColorSelector; - } - } - private void OnDecorationBoundingBoxChanged(int x, int y, int width, int height) { DecorationBoundingBox = new Rectangle(x, y, width, height); diff --git a/src/Tizen.NUI/src/public/BaseComponents/TextFieldBindableProperty.cs b/src/Tizen.NUI/src/public/BaseComponents/TextFieldBindableProperty.cs index f084ccb..5ea8eb5 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/TextFieldBindableProperty.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/TextFieldBindableProperty.cs @@ -969,5 +969,88 @@ namespace Tizen.NUI.BaseComponents Tizen.NUI.Object.GetProperty(textField.swigCPtr, TextField.Property.MATCH_SYSTEM_LANGUAGE_DIRECTION).Get(out temp); return (bool)temp; }); + + #region Selectors + internal static readonly BindableProperty TranslatableTextSelectorProperty = BindableProperty.Create("TranslatableTextSelector", typeof(Selector), typeof(TextField), null, propertyChanged: (bindable, oldValue, newValue) => + { + var textField = (TextField)bindable; + textField.SelectorData.TranslatableText.Update(textField, (Selector)newValue, true); + }, + defaultValueCreator: (bindable) => + { + var textField = (TextField)bindable; + return textField.SelectorData.TranslatableText.Get(textField); + }); + internal static readonly BindableProperty TranslatablePlaceholderTextSelectorProperty = BindableProperty.Create("TranslatablePlaceholderTextSelector", typeof(Selector), typeof(TextField), null, propertyChanged: (bindable, oldValue, newValue) => + { + var textField = (TextField)bindable; + textField.SelectorData.TranslatablePlaceholderText.Update(textField, (Selector)newValue, true); + }, + defaultValueCreator: (bindable) => + { + var textField = (TextField)bindable; + return textField.SelectorData.TranslatablePlaceholderText.Get(textField); + }); + internal static readonly BindableProperty TextSelectorProperty = BindableProperty.Create("TextSelector", typeof(Selector), typeof(TextField), null, propertyChanged: (bindable, oldValue, newValue) => + { + var textField = (TextField)bindable; + textField.SelectorData.Text.Update(textField, (Selector)newValue, true); + }, + defaultValueCreator: (bindable) => + { + var textField = (TextField)bindable; + return textField.SelectorData.Text.Get(textField); + }); + internal static readonly BindableProperty FontFamilySelectorProperty = BindableProperty.Create("FontFamilySelector", typeof(Selector), typeof(TextField), null, propertyChanged: (bindable, oldValue, newValue) => + { + var textField = (TextField)bindable; + textField.SelectorData.FontFamily.Update(textField, (Selector)newValue, true); + }, + defaultValueCreator: (bindable) => + { + var textField = (TextField)bindable; + return textField.SelectorData.FontFamily.Get(textField); + }); + internal static readonly BindableProperty PointSizeSelectorProperty = BindableProperty.Create("PointSizeSelector", typeof(Selector), typeof(TextField), null, propertyChanged: (bindable, oldValue, newValue) => + { + var textField = (TextField)bindable; + textField.SelectorData.PointSize.Update(textField, (Selector)newValue, true); + }, + defaultValueCreator: (bindable) => + { + var textField = (TextField)bindable; + return textField.SelectorData.PointSize.Get(textField); + }); + internal static readonly BindableProperty TextColorSelectorProperty = BindableProperty.Create("TextColorSelector", typeof(Selector), typeof(TextField), null, propertyChanged: (bindable, oldValue, newValue) => + { + var textField = (TextField)bindable; + textField.SelectorData.TextColor.Update(textField, (Selector)newValue, true); + }, + defaultValueCreator: (bindable) => + { + var textField = (TextField)bindable; + return textField.SelectorData.TextColor.Get(textField); + }); + internal static readonly BindableProperty PlaceholderTextColorSelectorProperty = BindableProperty.Create("PlaceholderTextColorSelector", typeof(Selector), typeof(TextField), null, propertyChanged: (bindable, oldValue, newValue) => + { + var textField = (TextField)bindable; + textField.SelectorData.PlaceholderTextColor.Update(textField, (Selector)newValue, true); + }, + defaultValueCreator: (bindable) => + { + var textField = (TextField)bindable; + return textField.SelectorData.PlaceholderTextColor.Get(textField); + }); + internal static readonly BindableProperty PrimaryCursorColorSelectorProperty = BindableProperty.Create("PrimaryCursorColorSelector", typeof(Selector), typeof(TextField), null, propertyChanged: (bindable, oldValue, newValue) => + { + var textField = (TextField)bindable; + textField.SelectorData.PrimaryCursorColor.Update(textField, (Selector)newValue, true); + }, + defaultValueCreator: (bindable) => + { + var textField = (TextField)bindable; + return textField.SelectorData.PrimaryCursorColor.Get(textField); + }); + #endregion } } diff --git a/src/Tizen.NUI/src/public/BaseComponents/TextFieldSelectorData.cs b/src/Tizen.NUI/src/public/BaseComponents/TextFieldSelectorData.cs new file mode 100644 index 0000000..797284d --- /dev/null +++ b/src/Tizen.NUI/src/public/BaseComponents/TextFieldSelectorData.cs @@ -0,0 +1,55 @@ +/* + * Copyright(c) 2020 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +namespace Tizen.NUI.BaseComponents +{ + /// + /// The class storing extra data for a TextField to optimize size of it. + /// + internal class TextFieldSelectorData : TextLabelSelectorData + { + public TriggerableSelector TranslatablePlaceholderText { get; } = new TriggerableSelector(TextField.TranslatablePlaceholderTextProperty); + public TriggerableSelector PlaceholderTextColor { get; } = new TriggerableSelector(TextField.PlaceholderTextColorProperty, delegate (View view) + { + Vector4 color = new Vector4(); + if (view.GetProperty(TextField.Property.PLACEHOLDER_TEXT_COLOR).Get(color)) + { + return color; + } + return null; + }); + + public TriggerableSelector PrimaryCursorColor { get; } = new TriggerableSelector(TextField.PrimaryCursorColorProperty, delegate (View view) + { + Vector4 color = new Vector4(0.0f, 0.0f, 0.0f, 0.0f); + if (view.GetProperty(TextField.Property.PRIMARY_CURSOR_COLOR).Get(color)) + { + return color; + } + return null; + }); + + public override void Reset(View view) + { + TranslatablePlaceholderText.Reset(view); + PlaceholderTextColor.Reset(view); + PrimaryCursorColor.Reset(view); + + base.Reset(view); + } + } +} diff --git a/src/Tizen.NUI/src/public/BaseComponents/TextLabel.cs b/src/Tizen.NUI/src/public/BaseComponents/TextLabel.cs index ff0a074..1b2757c 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/TextLabel.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/TextLabel.cs @@ -36,12 +36,17 @@ namespace Tizen.NUI.BaseComponents private string textLabelSid = null; private bool systemlangTextFlag = false; + private TextLabelSelectorData selectorData; - private CloneableViewSelector textShadow; - - /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API. + /// + /// Return a copied Style instance of the TextLabel. + /// + /// + /// 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 . + /// [EditorBrowsable(EditorBrowsableState.Never)] - public TextLabelStyle Style => ViewStyle as TextLabelStyle; + public new TextLabelStyle Style => new TextLabelStyle(this); /// /// Creates the TextLabel control. @@ -136,13 +141,13 @@ namespace Tizen.NUI.BaseComponents set { SetValue(TranslatableTextProperty, value); + selectorData?.TranslatableText.UpdateIfNeeds(this, value); } } private string translatableText { get { - string temp = (string)GetValue(TranslatableTextProperty); return textLabelSid; } set @@ -185,6 +190,7 @@ namespace Tizen.NUI.BaseComponents set { SetValue(TextProperty, value); + selectorData?.Text.UpdateIfNeeds(this, value); NotifyPropertyChangedAndRequestLayout(); } } @@ -203,6 +209,7 @@ namespace Tizen.NUI.BaseComponents set { SetValue(FontFamilyProperty, value); + selectorData?.FontFamily.UpdateIfNeeds(this, value); NotifyPropertyChangedAndRequestLayout(); } } @@ -239,6 +246,7 @@ namespace Tizen.NUI.BaseComponents set { SetValue(PointSizeProperty, value); + selectorData?.PointSize.UpdateIfNeeds(this, value); NotifyPropertyChangedAndRequestLayout(); } } @@ -317,6 +325,7 @@ namespace Tizen.NUI.BaseComponents set { SetValue(TextColorProperty, value); + selectorData?.TextColor.UpdateIfNeeds(this, value); NotifyPropertyChanged(); } } @@ -628,12 +637,12 @@ namespace Tizen.NUI.BaseComponents { get { - var value = (TextShadow)GetValue(TextShadowProperty); - return value == null ? null : new TextShadow(value, OnTextShadowChanged); + return (TextShadow)GetValue(TextShadowProperty); } set { SetValue(TextShadowProperty, value); + selectorData?.TextShadow.UpdateIfNeeds(this, value); NotifyPropertyChanged(); } } @@ -872,6 +881,18 @@ namespace Tizen.NUI.BaseComponents } } + private TextLabelSelectorData SelectorData + { + get + { + if (selectorData == null) + { + selectorData = new TextLabelSelectorData(); + } + return selectorData; + } + } + /// /// Downcasts a handle to textLabel handle /// @@ -893,6 +914,26 @@ namespace Tizen.NUI.BaseComponents return ret; } + /// + [EditorBrowsable(EditorBrowsableState.Never)] + protected override void Dispose(DisposeTypes type) + { + if (disposed) + { + return; + } + + if (type == DisposeTypes.Explicit) + { + //Called by User + //Release your own managed resources here. + //You should release all of your own disposable objects here. + selectorData?.Reset(this); + } + + base.Dispose(type); + } + internal static global::System.Runtime.InteropServices.HandleRef getCPtr(TextLabel obj) { return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; @@ -916,122 +957,6 @@ namespace Tizen.NUI.BaseComponents return new TextLabelStyle(); } - internal static readonly BindableProperty TranslatableTextSelectorProperty = BindableProperty.Create("TranslatableTextSelector", typeof(Selector), typeof(TextLabel), null, propertyChanged: (bindable, oldValue, newValue) => - { - var textLabel = (TextLabel)bindable; - textLabel.TranslatableTextSelector.Clone((Selector)newValue); - }, - defaultValueCreator: (bindable) => - { - var textLabel = (TextLabel)bindable; - return textLabel.TranslatableTextSelector; - }); - internal static readonly BindableProperty TextSelectorProperty = BindableProperty.Create("TextSelector", typeof(Selector), typeof(TextLabel), null, propertyChanged: (bindable, oldValue, newValue) => - { - var textLabel = (TextLabel)bindable; - textLabel.textSelector.Clone((Selector)newValue); - }, - defaultValueCreator: (bindable) => - { - var textLabel = (TextLabel)bindable; - return textLabel.textSelector; - }); - internal static readonly BindableProperty FontFamilySelectorProperty = BindableProperty.Create("FontFamilySelector", typeof(Selector), typeof(TextLabel), null, propertyChanged: (bindable, oldValue, newValue) => - { - var textLabel = (TextLabel)bindable; - textLabel.fontFamilySelector.Clone((Selector)newValue); - }, - defaultValueCreator: (bindable) => - { - var textLabel = (TextLabel)bindable; - return textLabel.fontFamilySelector; - }); - internal static readonly BindableProperty PointSizeSelectorProperty = BindableProperty.Create("PointSizeSelector", typeof(Selector), typeof(TextLabel), null, propertyChanged: (bindable, oldValue, newValue) => - { - var textLabel = (TextLabel)bindable; - textLabel.pointSizeSelector.Clone((Selector)newValue); - }, - defaultValueCreator: (bindable) => - { - var textLabel = (TextLabel)bindable; - return textLabel.pointSizeSelector; - }); - internal static readonly BindableProperty TextColorSelectorProperty = BindableProperty.Create("TextColorSelector", typeof(Selector), typeof(TextLabel), null, propertyChanged: (bindable, oldValue, newValue) => - { - var textLabel = (TextLabel)bindable; - textLabel.textColorSelector.Clone((Selector)newValue); - }, - defaultValueCreator: (bindable) => - { - var textLabel = (TextLabel)bindable; - return textLabel.textColorSelector; - }); - - private TriggerableSelector translatableTextSelector; - private TriggerableSelector TranslatableTextSelector - { - get - { - if (null == translatableTextSelector) - { - translatableTextSelector = new TriggerableSelector(this, TranslatableTextProperty); - } - return translatableTextSelector; - } - } - - private TriggerableSelector _textSelector; - private TriggerableSelector textSelector - { - get - { - if (null == _textSelector) - { - _textSelector = new TriggerableSelector(this, TextProperty); - } - return _textSelector; - } - } - - private TriggerableSelector _fontFamilySelector; - private TriggerableSelector fontFamilySelector - { - get - { - if (null == _fontFamilySelector) - { - _fontFamilySelector = new TriggerableSelector(this, FontFamilyProperty); - } - return _fontFamilySelector; - } - } - - private TriggerableSelector _textColorSelector; - private TriggerableSelector textColorSelector - { - get - { - if (null == _textColorSelector) - { - _textColorSelector = new TriggerableSelector(this, TextColorProperty); - } - return _textColorSelector; - } - } - - private TriggerableSelector _pointSizeSelector; - private TriggerableSelector pointSizeSelector - { - get - { - if (null == _pointSizeSelector) - { - _pointSizeSelector = new TriggerableSelector(this, PointSizeProperty); - } - return _pointSizeSelector; - } - } - /// /// Invoked whenever the binding context of the textlabel changes. Implement this method to add class handling for this event. /// @@ -1100,21 +1025,5 @@ namespace Tizen.NUI.BaseComponents { UnderlineColor = new Vector4(x, y, z, w); } - - private void OnTextShadowChanged(TextShadow instance) - { - TextShadow = instance; - } - - private void OnControlStateChangedForShadow(object obj, ControlStateChangedEventArgs controlStateChangedInfo) - { - UpdateTextShadowVisual(); - } - - private void UpdateTextShadowVisual() - { - TextShadow shadow = (textShadow != null && !textShadow.IsEmpty()) ? textShadow.GetValue() : textShadow?.GetValue(); - Object.SetProperty(swigCPtr, Property.SHADOW, TextShadow.ToPropertyValue(shadow)); - } } } diff --git a/src/Tizen.NUI/src/public/BaseComponents/TextLabelBindableProperty.cs b/src/Tizen.NUI/src/public/BaseComponents/TextLabelBindableProperty.cs index 7f419cd..5dd86fe 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/TextLabelBindableProperty.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/TextLabelBindableProperty.cs @@ -337,14 +337,15 @@ namespace Tizen.NUI.BaseComponents var textLabel = (TextLabel)bindable; if (newValue != null) { - (textLabel.textShadow ?? (textLabel.textShadow = new CloneableViewSelector(textLabel, textLabel.OnControlStateChangedForShadow))).Set(newValue); - Object.SetProperty(textLabel.swigCPtr, Property.SHADOW, TextShadow.ToPropertyValue(textLabel.textShadow.GetValue())); + Object.SetProperty(textLabel.swigCPtr, Property.SHADOW, TextShadow.ToPropertyValue((TextShadow)newValue)); } }, defaultValueCreator: (bindable) => { var textLabel = (TextLabel)bindable; - return textLabel.textShadow?.GetValue(); + PropertyMap temp = new PropertyMap(); + Tizen.NUI.Object.GetProperty(textLabel.swigCPtr, TextLabel.Property.SHADOW).Get(temp); + return temp.Empty() ? null : new TextShadow(temp); }); /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] @@ -542,5 +543,70 @@ namespace Tizen.NUI.BaseComponents return temp; }); + + #region Selectors + internal static readonly BindableProperty TranslatableTextSelectorProperty = BindableProperty.Create("TranslatableTextSelector", typeof(Selector), typeof(TextLabel), null, propertyChanged: (bindable, oldValue, newValue) => + { + var textLabel = (TextLabel)bindable; + textLabel.SelectorData.TranslatableText.Update(textLabel, (Selector)newValue, true); + }, + defaultValueCreator: (bindable) => + { + var textLabel = (TextLabel)bindable; + return textLabel.SelectorData.TranslatableText.Get(textLabel); + }); + internal static readonly BindableProperty TextSelectorProperty = BindableProperty.Create("TextSelector", typeof(Selector), typeof(TextLabel), null, propertyChanged: (bindable, oldValue, newValue) => + { + var textLabel = (TextLabel)bindable; + textLabel.SelectorData.Text.Update(textLabel, (Selector)newValue, true); + }, + defaultValueCreator: (bindable) => + { + var textLabel = (TextLabel)bindable; + return textLabel.SelectorData.Text.Get(textLabel); + }); + internal static readonly BindableProperty FontFamilySelectorProperty = BindableProperty.Create("FontFamilySelector", typeof(Selector), typeof(TextLabel), null, propertyChanged: (bindable, oldValue, newValue) => + { + var textLabel = (TextLabel)bindable; + textLabel.SelectorData.FontFamily.Update(textLabel, (Selector)newValue, true); + }, + defaultValueCreator: (bindable) => + { + var textLabel = (TextLabel)bindable; + return textLabel.SelectorData.FontFamily.Get(textLabel); + }); + internal static readonly BindableProperty PointSizeSelectorProperty = BindableProperty.Create("PointSizeSelector", typeof(Selector), typeof(TextLabel), null, propertyChanged: (bindable, oldValue, newValue) => + { + var textLabel = (TextLabel)bindable; + textLabel.SelectorData.PointSize.Update(textLabel, (Selector)newValue, true); + }, + defaultValueCreator: (bindable) => + { + var textLabel = (TextLabel)bindable; + return textLabel.SelectorData.PointSize.Get(textLabel); + }); + internal static readonly BindableProperty TextColorSelectorProperty = BindableProperty.Create("TextColorSelector", typeof(Selector), typeof(TextLabel), null, propertyChanged: (bindable, oldValue, newValue) => + { + var textLabel = (TextLabel)bindable; + textLabel.SelectorData.TextColor.Update(textLabel, (Selector)newValue, true); + }, + defaultValueCreator: (bindable) => + { + var textLabel = (TextLabel)bindable; + return textLabel.SelectorData.TextColor.Get(textLabel); + }); + + internal static readonly BindableProperty TextShadowSelectorProperty = BindableProperty.Create("TextShadowSelector", typeof(Selector), typeof(TextLabel), null, propertyChanged: (bindable, oldValue, newValue) => + { + var textLabel = (TextLabel)bindable; + textLabel.SelectorData.TextShadow.Update(textLabel, (Selector)newValue, true); + }, + defaultValueCreator: (bindable) => + { + var textLabel = (TextLabel)bindable; + return textLabel.SelectorData.TextShadow.Get(textLabel); + }); + #endregion + } } diff --git a/src/Tizen.NUI/src/public/BaseComponents/TextLabelSelectorData.cs b/src/Tizen.NUI/src/public/BaseComponents/TextLabelSelectorData.cs new file mode 100644 index 0000000..4f7231e --- /dev/null +++ b/src/Tizen.NUI/src/public/BaseComponents/TextLabelSelectorData.cs @@ -0,0 +1,52 @@ +/* + * Copyright(c) 2020 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +namespace Tizen.NUI.BaseComponents +{ + /// + /// The class storing extra data for a TextLabel to optimize size of it. + /// + internal class TextLabelSelectorData + { + public TriggerableSelector TranslatableText { get; } = new TriggerableSelector(TextLabel.TranslatableTextProperty); + public TriggerableSelector Text { get; } = new TriggerableSelector(TextLabel.TextProperty); + public TriggerableSelector FontFamily { get; } = new TriggerableSelector(TextLabel.FontFamilyProperty); + public TriggerableSelector TextColor { get; } = new TriggerableSelector(TextLabel.TextColorProperty, GetTextColor); + public TriggerableSelector PointSize { get; } = new TriggerableSelector(TextLabel.PointSizeProperty); + public TriggerableSelector TextShadow { get; } = new TriggerableSelector(TextLabel.TextShadowProperty); + + public virtual void Reset(View view) + { + TranslatableText.Reset(view); + Text.Reset(view); + FontFamily.Reset(view); + TextColor.Reset(view); + PointSize.Reset(view); + TextShadow.Reset(view); + } + + private static Color GetTextColor(View view) + { + Color color = new Color(); + if (view.GetProperty(TextLabel.Property.TEXT_COLOR).Get(color)) + { + return color; + } + return null; + } + } +} diff --git a/src/Tizen.NUI/src/public/BaseComponents/View.cs b/src/Tizen.NUI/src/public/BaseComponents/View.cs index cc9b814..2af0d11 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/View.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/View.cs @@ -60,16 +60,22 @@ namespace Tizen.NUI.BaseComponents private Dictionary transDictionary = new Dictionary(); private string[] transitionNames; private bool controlStatePropagation = false; + private ViewStyle viewStyle; internal Size2D sizeSetExplicitly = new Size2D(); // Store size set by API, will be used in place of NaturalSize if not set. internal BackgroundExtraData backgroundExtraData; static View() {} + /// - /// The Style instance binded with this View. + /// Return a copied Style instance of View. /// - private ViewStyle viewStyle; + /// + /// It returns copied Style instance and changing it does not effect to the View. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public ViewStyle Style => new ViewStyle(this); /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] @@ -99,7 +105,7 @@ namespace Tizen.NUI.BaseComponents [EditorBrowsable(EditorBrowsableState.Never)] public View(ViewStyle viewStyle) : this(Interop.View.View_New(), true) { - this.ViewStyle.CopyFrom(viewStyle); + ApplyStyle((viewStyle == null) ? GetViewStyle() : viewStyle.Clone()); } /// @@ -127,14 +133,7 @@ namespace Tizen.NUI.BaseComponents internal View(global::System.IntPtr cPtr, bool cMemoryOwn, ViewStyle viewStyle, bool shown = true) : this(cPtr, cMemoryOwn, shown) { - if (this.viewStyle == null) - { - ApplyStyle((viewStyle == null) ? GetViewStyle() : viewStyle.Clone()); - } - else - { - this.viewStyle.CopyFrom(viewStyle); - } + ApplyStyle((viewStyle == null) ? GetViewStyle() : viewStyle.Clone()); } internal View(global::System.IntPtr cPtr, bool cMemoryOwn, bool shown = true) : base(Interop.View.View_SWIGUpcast(cPtr), cMemoryOwn) @@ -269,16 +268,12 @@ namespace Tizen.NUI.BaseComponents } set { - if (viewStyle != null) - { - viewStyle.BackgroundImage = null; - viewStyle.BackgroundColor = value; - } - else + SetValue(BackgroundColorProperty, value); + if (selectorData != null) { - SetValue(BackgroundColorProperty, value); + selectorData.BackgroundImage.Reset(this); + selectorData.BackgroundColor.UpdateIfNeeds(this, value); } - NotifyPropertyChanged(); } } @@ -295,16 +290,12 @@ namespace Tizen.NUI.BaseComponents } set { - if (viewStyle != null) - { - viewStyle.BackgroundColor = null; - viewStyle.BackgroundImage = value; - } - else + SetValue(BackgroundImageProperty, value); + if (selectorData != null) { - SetValue(BackgroundImageProperty, value); + selectorData.BackgroundColor.Reset(this); + selectorData.BackgroundImage.UpdateIfNeeds(this, value); } - NotifyPropertyChanged(); } } @@ -322,15 +313,8 @@ namespace Tizen.NUI.BaseComponents } set { - if (viewStyle != null) - { - viewStyle.BackgroundImageBorder = value; - } - else - { - SetValue(BackgroundImageBorderProperty, value); - } - + SetValue(BackgroundImageBorderProperty, value); + selectorData?.BackgroundImageBorder.UpdateIfNeeds(this, value); NotifyPropertyChanged(); } } @@ -357,7 +341,7 @@ namespace Tizen.NUI.BaseComponents /// It is null by default. /// /// - /// Gettter returns copied instance of current shadow. + /// Getter returns copied instance of current shadow. /// /// /// The mutually exclusive with "BoxShadow". @@ -372,6 +356,11 @@ namespace Tizen.NUI.BaseComponents set { SetValue(ImageShadowProperty, value); + if (selectorData != null) + { + selectorData.BoxShadow.Reset(this); + selectorData.ImageShadow.UpdateIfNeeds(this, value); + } NotifyPropertyChanged(); } } @@ -396,6 +385,11 @@ namespace Tizen.NUI.BaseComponents set { SetValue(BoxShadowProperty, value); + if (selectorData != null) + { + selectorData.ImageShadow.Reset(this); + selectorData.BoxShadow.UpdateIfNeeds(this, value); + } NotifyPropertyChanged(); } } @@ -415,6 +409,7 @@ namespace Tizen.NUI.BaseComponents set { SetValue(CornerRadiusProperty, value); + selectorData?.CornerRadius.UpdateIfNeeds(this, value); NotifyPropertyChanged(); } } @@ -802,15 +797,8 @@ namespace Tizen.NUI.BaseComponents } set { - if (viewStyle != null) - { - viewStyle.Opacity = value; - } - else - { - SetValue(OpacityProperty, value); - } - + SetValue(OpacityProperty, value); + selectorData?.Opacity.UpdateIfNeeds(this, value); NotifyPropertyChanged(); } } @@ -2103,15 +2091,8 @@ namespace Tizen.NUI.BaseComponents } set { - if (viewStyle != null) - { - viewStyle.Color = value; - } - else - { - SetValue(ColorProperty, value); - } - + SetValue(ColorProperty, value); + selectorData?.Color.UpdateIfNeeds(this, value); NotifyPropertyChanged(); } } @@ -2333,138 +2314,11 @@ namespace Tizen.NUI.BaseComponents { } - internal static readonly BindableProperty BackgroundImageSelectorProperty = BindableProperty.Create("BackgroundImageSelector", typeof(Selector), typeof(View), null, propertyChanged: (bindable, oldValue, newValue) => - { - var view = (View)bindable; - view.backgroundImageSelector.Clone((Selector)newValue); - }, - defaultValueCreator: (bindable) => - { - var view = (View)bindable; - return view.backgroundImageSelector; - }); - private TriggerableSelector _backgroundImageSelector; - private TriggerableSelector backgroundImageSelector - { - get - { - if (null == _backgroundImageSelector) - { - _backgroundImageSelector = new TriggerableSelector(this, BackgroundImageProperty); - } - return _backgroundImageSelector; - } - } - internal static readonly BindableProperty BackgroundColorSelectorProperty = BindableProperty.Create("BackgroundColorSelector", typeof(Selector), typeof(View), null, propertyChanged: (bindable, oldValue, newValue) => - { - var view = (View)bindable; - view.backgroundColorSelector.Clone((Selector)newValue); - }, - defaultValueCreator: (bindable) => - { - var view = (View)bindable; - return view.backgroundColorSelector; - }); - private TriggerableSelector _backgroundColorSelector; - private TriggerableSelector backgroundColorSelector - { - get - { - if (null == _backgroundColorSelector) - { - _backgroundColorSelector = new TriggerableSelector(this, BackgroundColorProperty); - } - return _backgroundColorSelector; - } - } - - internal static readonly BindableProperty ColorSelectorProperty = BindableProperty.Create("ColorSelector", typeof(Selector), typeof(View), null, propertyChanged: (bindable, oldValue, newValue) => - { - var view = (View)bindable; - view.colorSelector.Clone((Selector)newValue); - }, - defaultValueCreator: (bindable) => - { - var view = (View)bindable; - return view.colorSelector; - }); - - private TriggerableSelector _colorSelector; - private TriggerableSelector colorSelector - { - get - { - if (null == _colorSelector) - { - _colorSelector = new TriggerableSelector(this, ColorProperty); - } - return _colorSelector; - } - } - - internal static readonly BindableProperty BackgroundImageBorderSelectorProperty = BindableProperty.Create("BackgroundImageBorderSelector", typeof(Selector), typeof(View), null, propertyChanged: (bindable, oldValue, newValue) => - { - var view = (View)bindable; - view.backgroundImageBorderSelector.Clone((Selector)newValue); - }, - defaultValueCreator: (bindable) => - { - var view = (View)bindable; - return view.backgroundImageBorderSelector; - }); - private TriggerableSelector _backgroundImageBorderSelector; - private TriggerableSelector backgroundImageBorderSelector - { - get - { - if (null == _backgroundImageBorderSelector) - { - _backgroundImageBorderSelector = new TriggerableSelector(this, BackgroundImageBorderProperty); - } - return _backgroundImageBorderSelector; - } - } - internal static readonly BindableProperty OpacitySelectorProperty = BindableProperty.Create("OpacitySelector", typeof(Selector), typeof(View), null, propertyChanged: (bindable, oldValue, newValue) => - { - var view = (View)bindable; - view.opacitySelector.Clone((Selector)newValue); - }, - defaultValueCreator: (bindable) => - { - var view = (View)bindable; - return view.opacitySelector; - }); - private TriggerableSelector _opacitySelector; - private TriggerableSelector opacitySelector - { - get - { - if (null == _opacitySelector) - { - _opacitySelector = new TriggerableSelector(this, OpacityProperty); - } - return _opacitySelector; - } - } - /// 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 virtual void ApplyStyle(ViewStyle viewStyle) { - if (null == viewStyle) - { - return; - } - - if (this.viewStyle == viewStyle) - { - return; - } - - if (null != this.viewStyle) - { - simpleBinding.Clear(); - } + if (null == viewStyle || this.viewStyle == viewStyle) return; this.viewStyle = viewStyle; @@ -2492,15 +2346,9 @@ namespace Tizen.NUI.BaseComponents { SetValue(viewProperty, value); } - - simpleBinding.Bind(viewStyle, keyValuePair.Value, this, viewProperty, BindingDirection.TwoWay); } } } } - - /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - private BundledPipe simpleBinding = new BundledPipe(); } } diff --git a/src/Tizen.NUI/src/public/BaseComponents/ViewBindableProperty.cs b/src/Tizen.NUI/src/public/BaseComponents/ViewBindableProperty.cs index a7cf505..ac46ce4 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/ViewBindableProperty.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/ViewBindableProperty.cs @@ -53,7 +53,6 @@ namespace Tizen.NUI.BaseComponents public static readonly BindableProperty BackgroundColorProperty = BindableProperty.Create("BackgroundColor", typeof(Color), typeof(View), null, propertyChanged: (bindable, oldValue, newValue) => { var view = (View)bindable; - if (newValue != null) { if (view.backgroundExtraData == null) @@ -610,6 +609,7 @@ namespace Tizen.NUI.BaseComponents public static readonly BindableProperty OpacityProperty = BindableProperty.Create("Opacity", typeof(float), typeof(View), default(float), propertyChanged: (bindable, oldValue, newValue) => { var view = (View)bindable; + if (newValue != null) { Tizen.NUI.Object.SetProperty(view.swigCPtr, View.Property.OPACITY, new Tizen.NUI.PropertyValue((float)newValue)); @@ -1502,137 +1502,163 @@ namespace Tizen.NUI.BaseComponents public static readonly BindableProperty ImageShadowProperty = BindableProperty.Create(nameof(ImageShadow), typeof(ImageShadow), typeof(View), null, propertyChanged: (bindable, oldValue, newValue) => { var shadow = (ImageShadow)newValue; - var view = (View)bindable; - - view.SetValue(View.ImageShadowSelectorProperty, shadow == null ? null : new Selector() { All = shadow, }); + Tizen.NUI.Object.SetProperty(view.swigCPtr, View.Property.SHADOW, shadow == null ? new PropertyValue() : shadow.ToPropertyValue(view)); }, defaultValueCreator: (bindable) => { var view = (View)bindable; - if (view.viewStyle != null) - { - return view.viewStyle.ImageShadow?.GetValue(view.ControlState); - } - PropertyMap map = new PropertyMap(); - Tizen.NUI.Object.GetProperty(view.swigCPtr, View.Property.SHADOW).Get(map); var shadow = new ImageShadow(map); - return shadow.IsEmpty() ? null : shadow; }); /// - /// ImageShadow Selector Property for binding to ViewStyle + /// Shadow Property /// [EditorBrowsable(EditorBrowsableState.Never)] - public static readonly BindableProperty ImageShadowSelectorProperty = BindableProperty.Create("ImageShadowSelector", typeof(Selector), typeof(View), null, propertyChanged: (bindable, oldValue, newValue) => + public static readonly BindableProperty BoxShadowProperty = BindableProperty.Create(nameof(BoxShadow), typeof(Shadow), typeof(View), null, propertyChanged: (bindable, oldValue, newValue) => { + var shadow = (Shadow)newValue; var view = (View)bindable; - - var shadowSelector = (Selector)newValue; - - view.UpdateShadow(shadowSelector?.GetValue(view.ControlState), shadowSelector == null ? false : shadowSelector.HasMultiValue()); + Tizen.NUI.Object.SetProperty(view.swigCPtr, View.Property.SHADOW, shadow == null ? new PropertyValue() : shadow.ToPropertyValue(view)); }, defaultValueCreator: (bindable) => { var view = (View)bindable; - return view.viewStyle?.ImageShadow; + PropertyMap map = new PropertyMap(); + Tizen.NUI.Object.GetProperty(view.swigCPtr, View.Property.SHADOW).Get(map); + + var shadow = new Shadow(map); + return shadow.IsEmpty() ? null : shadow; }); /// - /// Shadow Property + /// CornerRadius Property /// [EditorBrowsable(EditorBrowsableState.Never)] - public static readonly BindableProperty BoxShadowProperty = BindableProperty.Create(nameof(BoxShadow), typeof(Shadow), typeof(View), null, propertyChanged: (bindable, oldValue, newValue) => + public static readonly BindableProperty CornerRadiusProperty = BindableProperty.Create(nameof(CornerRadius), typeof(float), typeof(View), default(float), propertyChanged: (bindable, oldValue, newValue) => { - var shadow = (Shadow)newValue; - var view = (View)bindable; - - view.SetValue(View.BoxShadowSelectorProperty, shadow == null ? null : new Selector() { All = shadow, }); + view.UpdateCornerRadius((float)newValue); }, defaultValueCreator: (bindable) => { var view = (View)bindable; - - if (view.viewStyle != null) - { - return view.viewStyle.BoxShadow?.GetValue(view.ControlState); - } - - PropertyMap map = new PropertyMap(); - - Tizen.NUI.Object.GetProperty(view.swigCPtr, View.Property.SHADOW).Get(map); - - var shadow = new Shadow(map); - - return shadow.IsEmpty() ? null : shadow; + return view.backgroundExtraData == null ? 0 : view.backgroundExtraData.CornerRadius; }); /// - /// BoxShadow Selector Property for binding to ViewStyle + /// XamlStyleProperty /// [EditorBrowsable(EditorBrowsableState.Never)] - public static readonly BindableProperty BoxShadowSelectorProperty = BindableProperty.Create("BoxShadowSelector", typeof(Selector), typeof(View), null, propertyChanged: (bindable, oldValue, newValue) => + public static readonly BindableProperty XamlStyleProperty = BindableProperty.Create("XamlStyle", typeof(Style), typeof(View), default(Style), propertyChanged: (bindable, oldvalue, newvalue) => ((View)bindable)._mergedStyle.Style = (Style)newvalue); + + + #region Selectors + internal static readonly BindableProperty BackgroundImageSelectorProperty = BindableProperty.Create("BackgroundImageSelector", typeof(Selector), typeof(View), null, propertyChanged: (bindable, oldValue, newValue) => + { + var view = (View)bindable; + view.SelectorData.BackgroundImage.Update(view, (Selector)newValue, true); + }, + defaultValueCreator: (bindable) => { var view = (View)bindable; + return view.SelectorData.BackgroundImage.Get(view); + }); - var shadowSelector = (Selector)newValue; + internal static readonly BindableProperty BackgroundColorSelectorProperty = BindableProperty.Create("BackgroundColorSelector", typeof(Selector), typeof(View), null, propertyChanged: (bindable, oldValue, newValue) => + { + var view = (View)bindable; + view.SelectorData.BackgroundColor.Update(view, (Selector)newValue, true); + }, + defaultValueCreator: (bindable) => + { + var view = (View)bindable; + return view.SelectorData.BackgroundColor.Get(view); + }); - view.UpdateShadow(shadowSelector?.GetValue(view.ControlState), shadowSelector == null ? false : shadowSelector.HasMultiValue()); + internal static readonly BindableProperty BackgroundImageBorderSelectorProperty = BindableProperty.Create("BackgroundImageBorderSelector", typeof(Selector), typeof(View), null, propertyChanged: (bindable, oldValue, newValue) => + { + var view = (View)bindable; + view.SelectorData.BackgroundImageBorder.Update(view, (Selector)newValue, true); }, defaultValueCreator: (bindable) => { var view = (View)bindable; + return view.SelectorData.BackgroundImageBorder.Get(view); + }); - return view.viewStyle?.BoxShadow; + internal static readonly BindableProperty ColorSelectorProperty = BindableProperty.Create("ColorSelector", typeof(Selector), typeof(View), null, propertyChanged: (bindable, oldValue, newValue) => + { + var view = (View)bindable; + view.SelectorData.Color.Update(view, (Selector)newValue, true); + }, + defaultValueCreator: (bindable) => + { + var view = (View)bindable; + return view.SelectorData.Color.Get(view); + }); + + internal static readonly BindableProperty OpacitySelectorProperty = BindableProperty.Create("OpacitySelector", typeof(Selector), typeof(View), null, propertyChanged: (bindable, oldValue, newValue) => + { + var view = (View)bindable; + view.SelectorData.Opacity.Update(view, (Selector)newValue, true); + }, + defaultValueCreator: (bindable) => + { + var view = (View)bindable; + return view.SelectorData.Opacity.Get(view); }); /// - /// CornerRadius Property + /// ImageShadow Selector Property for binding to ViewStyle /// [EditorBrowsable(EditorBrowsableState.Never)] - public static readonly BindableProperty CornerRadiusProperty = BindableProperty.Create(nameof(CornerRadius), typeof(float), typeof(View), default(float), propertyChanged: (bindable, oldValue, newValue) => + public static readonly BindableProperty ImageShadowSelectorProperty = BindableProperty.Create("ImageShadowSelector", typeof(Selector), typeof(View), null, propertyChanged: (bindable, oldValue, newValue) => { var view = (View)bindable; - - view.SetValue(View.CornerRadiusSelectorProperty, new Selector() { All = (float)newValue, }); + view.SelectorData.ImageShadow.Update(view, (Selector)newValue, true); }, defaultValueCreator: (bindable) => { var view = (View)bindable; - - return view.backgroundExtraData == null ? 0 : view.backgroundExtraData.CornerRadius; + return view.SelectorData.ImageShadow.Get(view); }); /// - /// CornerRadius Selector Property + /// BoxShadow Selector Property for binding to ViewStyle /// [EditorBrowsable(EditorBrowsableState.Never)] - public static readonly BindableProperty CornerRadiusSelectorProperty = BindableProperty.Create("CornerRadiusSelector", typeof(Selector), typeof(View), null, propertyChanged: (bindable, oldValue, newValue) => + public static readonly BindableProperty BoxShadowSelectorProperty = BindableProperty.Create("BoxShadowSelector", typeof(Selector), typeof(View), null, propertyChanged: (bindable, oldValue, newValue) => { var view = (View)bindable; - - var cornerRadiusSelector = (Selector)newValue; - - view.UpdateCornerRadius(cornerRadiusSelector?.GetValue(view.ControlState) ?? 0, cornerRadiusSelector == null ? false : cornerRadiusSelector.HasMultiValue()); + view.SelectorData.BoxShadow.Update(view, (Selector)newValue, true); }, defaultValueCreator: (bindable) => { var view = (View)bindable; - - return view.viewStyle?.CornerRadius; + return view.SelectorData.BoxShadow.Get(view); }); /// - /// XamlStyleProperty + /// CornerRadius Selector Property /// [EditorBrowsable(EditorBrowsableState.Never)] - public static readonly BindableProperty XamlStyleProperty = BindableProperty.Create("XamlStyle", typeof(Style), typeof(View), default(Style), propertyChanged: (bindable, oldvalue, newvalue) => ((View)bindable)._mergedStyle.Style = (Style)newvalue); + public static readonly BindableProperty CornerRadiusSelectorProperty = BindableProperty.Create("CornerRadiusSelector", typeof(Selector), typeof(View), null, propertyChanged: (bindable, oldValue, newValue) => + { + var view = (View)bindable; + view.SelectorData.CornerRadius.Update(view, (Selector)newValue, true); + }, + defaultValueCreator: (bindable) => + { + var view = (View)bindable; + return view.SelectorData.CornerRadius.Get(view); + }); + #endregion } } diff --git a/src/Tizen.NUI/src/public/BaseComponents/ViewInternal.cs b/src/Tizen.NUI/src/public/BaseComponents/ViewInternal.cs index 9617922..34d55cf 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/ViewInternal.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/ViewInternal.cs @@ -32,6 +32,8 @@ namespace Tizen.NUI.BaseComponents public partial class View { private MergedStyle mergedStyle = null; + private ViewSelectorData selectorData; + internal MergedStyle _mergedStyle { get @@ -307,6 +309,18 @@ namespace Tizen.NUI.BaseComponents } } + private ViewSelectorData SelectorData + { + get + { + if (selectorData == null) + { + selectorData = new ViewSelectorData(); + } + return selectorData; + } + } + internal void Raise() { var parentChildren = GetParent()?.Children; @@ -1013,15 +1027,8 @@ namespace Tizen.NUI.BaseComponents return (ResourceLoadingStatusType)Interop.View.View_GetVisualResourceStatus(this.swigCPtr, Property.BACKGROUND); } - internal virtual void UpdateCornerRadius(float value, bool needToListenStateChanged) + internal virtual void UpdateCornerRadius(float value) { - ControlStateChangeEventInternal -= OnControlStateChangedForCornerRadius; - - if (needToListenStateChanged) - { - ControlStateChangeEventInternal += OnControlStateChangedForCornerRadius; - } - if (value != 0) { (backgroundExtraData ?? (backgroundExtraData = new BackgroundExtraData())).CornerRadius = value; @@ -1053,6 +1060,14 @@ namespace Tizen.NUI.BaseComponents //_mergedStyle = null; + if (type == DisposeTypes.Explicit) + { + //Called by User + //Release your own managed resources here. + //You should release all of your own disposable objects here. + selectorData?.Reset(this); + } + //Release your own unmanaged resources here. //You should not access any managed member here except static instance. //because the execution order of Finalizes is non-deterministic. @@ -1076,11 +1091,6 @@ namespace Tizen.NUI.BaseComponents view.InternalParent = null; } - simpleBinding.Dispose(); - simpleBinding = null; - - viewStyle = null; - base.Dispose(type); } @@ -1293,79 +1303,6 @@ namespace Tizen.NUI.BaseComponents SizeModeFactor = new Vector3(x, y, z); } - private void OnControlStateChangedForShadow(object obj, ControlStateChangedEventArgs controlStateChangedInfo) - { - var boxShadowSelector = (Selector)GetValue(BoxShadowSelectorProperty); - - if (boxShadowSelector != null) - { - ShadowBase prevShadow = boxShadowSelector.GetValue(controlStateChangedInfo.PreviousState); - - var boxShadow = boxShadowSelector.GetValue(controlStateChangedInfo.CurrentState); - - if (boxShadow == prevShadow) - { - return; - } - - Tizen.NUI.Object.SetProperty(swigCPtr, View.Property.SHADOW, boxShadow == null ? new PropertyValue() : boxShadow.ToPropertyValue(this)); - - return; - } - - var imageShadowSelector = (Selector)GetValue(ImageShadowSelectorProperty); - - if (imageShadowSelector != null) - { - ShadowBase prevShadow = imageShadowSelector?.GetValue(controlStateChangedInfo.PreviousState); - - var imageShadow = imageShadowSelector.GetValue(controlStateChangedInfo.CurrentState); - - if (imageShadow == prevShadow) - { - return; - } - - Tizen.NUI.Object.SetProperty(swigCPtr, View.Property.SHADOW, imageShadow == null ? new PropertyValue() : imageShadow.ToPropertyValue(this)); - } - } - - private void UpdateShadow(ShadowBase shadow, bool needToListenStateChanged) - { - ControlStateChangeEventInternal -= OnControlStateChangedForShadow; - - if (shadow == null) - { - Tizen.NUI.Object.SetProperty(swigCPtr, View.Property.SHADOW, new PropertyValue()); - } - else - { - Tizen.NUI.Object.SetProperty(swigCPtr, View.Property.SHADOW, shadow.ToPropertyValue(this)); - } - - if (needToListenStateChanged) - { - ControlStateChangeEventInternal += OnControlStateChangedForShadow; - } - } - - private void OnControlStateChangedForCornerRadius(object obj, ControlStateChangedEventArgs controlStateChangedInfo) - { - var selector = (Selector)GetValue(CornerRadiusSelectorProperty); - - if (selector == null) - { - return; - } - - float? currentCornerRadius = selector.GetValue(controlStateChangedInfo.CurrentState); - - if (selector.GetValue(controlStateChangedInfo.PreviousState) == currentCornerRadius) - { - UpdateCornerRadius(currentCornerRadius ?? 0, true); - } - } - private void UpdateShadowCornerRadius(float value) { // TODO Update corner radius property only whe DALi supports visual property update. diff --git a/src/Tizen.NUI/src/public/BaseComponents/ViewSelectorData.cs b/src/Tizen.NUI/src/public/BaseComponents/ViewSelectorData.cs new file mode 100644 index 0000000..a977e65 --- /dev/null +++ b/src/Tizen.NUI/src/public/BaseComponents/ViewSelectorData.cs @@ -0,0 +1,80 @@ +/* + * Copyright(c) 2020 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +namespace Tizen.NUI.BaseComponents +{ + /// + /// The class storing extra data for a View to optimize size of it. + /// + internal class ViewSelectorData + { + public TriggerableSelector BackgroundColor { get; } = new TriggerableSelector(View.BackgroundColorProperty, delegate(View view) + { + var background = view.Background; + int visualType = 0; + background.Find(Visual.Property.Type)?.Get(out visualType); + + if (visualType == (int)Visual.Type.Color) + { + Color backgroundColor = new Color(0.0f, 0.0f, 0.0f, 0.0f); + background.Find(ColorVisualProperty.MixColor)?.Get(backgroundColor); + return backgroundColor; + } + return null; + }); + public TriggerableSelector BackgroundImage { get; } = new TriggerableSelector(View.BackgroundImageProperty, delegate(View view) + { + var background = view.Background; + int visualType = 0; + background.Find(Visual.Property.Type)?.Get(out visualType); + + if ((visualType == (int)Visual.Type.Image) || (visualType == (int)Visual.Type.NPatch)) + { + string backgroundImage = ""; + background.Find(ImageVisualProperty.URL)?.Get(out backgroundImage); + return backgroundImage; + } + return null; + }); + public TriggerableSelector BackgroundImageBorder { get; } = new TriggerableSelector(View.BackgroundImageBorderProperty); + public TriggerableSelector Color { get; } = new TriggerableSelector(View.ColorProperty, delegate(View view) + { + Color color = new Color(); + if (view.GetProperty(Interop.ActorProperty.Actor_Property_COLOR_get()).Get(color)) + { + return color; + } + return null; + }); + public TriggerableSelector Opacity { get; } = new TriggerableSelector(View.OpacityProperty); + public TriggerableSelector ImageShadow { get; } = new TriggerableSelector(View.ImageShadowProperty); + public TriggerableSelector BoxShadow { get; } = new TriggerableSelector(View.BoxShadowProperty); + public TriggerableSelector CornerRadius { get; } = new TriggerableSelector(View.CornerRadiusProperty); + + public void Reset(View view) + { + BackgroundColor.Reset(view); + BackgroundImage.Reset(view); + BackgroundImageBorder.Reset(view); + Color.Reset(view); + Opacity.Reset(view); + ImageShadow.Reset(view); + BoxShadow.Reset(view); + CornerRadius.Reset(view); + } + } +} diff --git a/src/Tizen.NUI/src/public/Color.cs b/src/Tizen.NUI/src/public/Color.cs index 8aafc54..78737ce 100755 --- a/src/Tizen.NUI/src/public/Color.cs +++ b/src/Tizen.NUI/src/public/Color.cs @@ -141,6 +141,15 @@ namespace Tizen.NUI } } + /// + /// The copy constructor. + /// + /// The copy target. + [EditorBrowsable(EditorBrowsableState.Never)] + public Color(Color other) : this(other.R, other.G, other.B, other.A) + { + } + internal Color(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn) { hashDummy = false; diff --git a/src/Tizen.NUI/src/public/Vector2.cs b/src/Tizen.NUI/src/public/Vector2.cs index 27c75cb..00900b5 100755 --- a/src/Tizen.NUI/src/public/Vector2.cs +++ b/src/Tizen.NUI/src/public/Vector2.cs @@ -59,6 +59,15 @@ namespace Tizen.NUI } /// + /// The copy constructor. + /// + /// The copy target. + [EditorBrowsable(EditorBrowsableState.Never)] + public Vector2(Vector2 other) : this(other.X, other.Y) + { + } + + /// /// The constructor. /// /// Vector3 to create this vector from. diff --git a/src/Tizen.NUI/src/public/ViewProperty/ICloneable.cs b/src/Tizen.NUI/src/public/ViewProperty/ICloneable.cs deleted file mode 100644 index 83ef182..0000000 --- a/src/Tizen.NUI/src/public/ViewProperty/ICloneable.cs +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright(c) 2020 Samsung Electronics Co., Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -using System.ComponentModel; - -namespace Tizen.NUI.Internal -{ - - /// - /// The class that offer Clone method. - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public interface ICloneable - { - /// - /// Clone object - /// - [EditorBrowsable(EditorBrowsableState.Never)] - object Clone(); - } -} - - diff --git a/src/Tizen.NUI/src/public/ViewProperty/ImageShadow.cs b/src/Tizen.NUI/src/public/ViewProperty/ImageShadow.cs index 98049d4..02b5bfe 100644 --- a/src/Tizen.NUI/src/public/ViewProperty/ImageShadow.cs +++ b/src/Tizen.NUI/src/public/ViewProperty/ImageShadow.cs @@ -15,7 +15,8 @@ * */ - using System.ComponentModel; +using System; +using System.ComponentModel; namespace Tizen.NUI { @@ -24,7 +25,7 @@ namespace Tizen.NUI /// The Shadow composed of image for View /// [EditorBrowsable(EditorBrowsableState.Never)] - public class ImageShadow : ShadowBase + public class ImageShadow : ShadowBase, ICloneable { private static readonly Rectangle noBorder = new Rectangle(); @@ -34,7 +35,7 @@ namespace Tizen.NUI [EditorBrowsable(EditorBrowsableState.Never)] public ImageShadow() : base() { - Border = noBorder; + Border = new Rectangle(noBorder); } /// @@ -44,7 +45,7 @@ namespace Tizen.NUI public ImageShadow(string url, Rectangle border, Vector2 offset, Vector2 extents) : base(offset, extents) { Url = url; - Border = border; + Border = new Rectangle(border); } /// @@ -121,6 +122,10 @@ namespace Tizen.NUI } } + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public object Clone() => new ImageShadow(this); + internal override bool IsEmpty() { return string.IsNullOrEmpty(Url); diff --git a/src/Tizen.NUI/src/public/ViewProperty/Shadow.cs b/src/Tizen.NUI/src/public/ViewProperty/Shadow.cs index a0951d5..f66964a 100644 --- a/src/Tizen.NUI/src/public/ViewProperty/Shadow.cs +++ b/src/Tizen.NUI/src/public/ViewProperty/Shadow.cs @@ -15,7 +15,8 @@ * */ - using System.ComponentModel; +using System; +using System.ComponentModel; namespace Tizen.NUI { @@ -24,7 +25,7 @@ namespace Tizen.NUI /// Represents a shadow with color and blur radius for a View. /// [EditorBrowsable(EditorBrowsableState.Never)] - public class Shadow : ShadowBase + public class Shadow : ShadowBase, ICloneable { private static readonly Color noColor = new Color(0, 0, 0, 0); @@ -47,7 +48,7 @@ namespace Tizen.NUI public Shadow(float blurRadius, Vector2 offset, Color color, Vector2 extents) : base(offset, extents) { BlurRadius = blurRadius; - Color = color; + Color = new Color(color); } /// @@ -113,6 +114,10 @@ namespace Tizen.NUI } } + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public object Clone() => new Shadow(this); + internal override bool IsEmpty() { return (Color == null || Color.A == 0); diff --git a/src/Tizen.NUI/src/public/ViewProperty/ShadowBase.cs b/src/Tizen.NUI/src/public/ViewProperty/ShadowBase.cs index dfac507..07d0c45 100644 --- a/src/Tizen.NUI/src/public/ViewProperty/ShadowBase.cs +++ b/src/Tizen.NUI/src/public/ViewProperty/ShadowBase.cs @@ -45,8 +45,8 @@ namespace Tizen.NUI [EditorBrowsable(EditorBrowsableState.Never)] protected ShadowBase(Vector2 offset, Vector2 extents) { - Offset = offset; - Extents = extents; + Offset = new Vector2(offset); + Extents = new Vector2(extents); } /// diff --git a/src/Tizen.NUI/src/public/ViewProperty/TextShadow.cs b/src/Tizen.NUI/src/public/ViewProperty/TextShadow.cs index fcfcc52..210ff98 100755 --- a/src/Tizen.NUI/src/public/ViewProperty/TextShadow.cs +++ b/src/Tizen.NUI/src/public/ViewProperty/TextShadow.cs @@ -15,6 +15,7 @@ * */ +using System; using System.ComponentModel; namespace Tizen.NUI @@ -23,12 +24,11 @@ namespace Tizen.NUI /// The Text Shadow for TextLabel. /// [EditorBrowsable(EditorBrowsableState.Never)] - public class TextShadow : Internal.ICloneable + public class TextShadow : ICloneable { - private PropertyMap propertyMap = null; + private readonly PropertyMap propertyMap = null; internal delegate void PropertyChangedCallback(TextShadow instance); - internal PropertyChangedCallback OnPropertyChanged = null; /// /// Constructor @@ -85,7 +85,12 @@ namespace Tizen.NUI [EditorBrowsable(EditorBrowsableState.Never)] public float BlurRadius { get; } = 0.0f; - internal TextShadow(TextShadow other, PropertyChangedCallback callback = null) + internal TextShadow(PropertyMap propertyMap) + { + this.propertyMap = new PropertyMap(propertyMap); + } + + internal TextShadow(TextShadow other) { propertyMap = new PropertyMap(); @@ -97,8 +102,6 @@ namespace Tizen.NUI BlurRadius = other.BlurRadius; propertyMap["blurRadius"] = new PropertyValue(BlurRadius); - - OnPropertyChanged = callback; } static internal PropertyValue ToPropertyValue(TextShadow instance) -- 2.7.4