From 977cdfa040f098b76d78ced42b3e26efb1cf7377 Mon Sep 17 00:00:00 2001 From: Jiyun Yang Date: Tue, 15 Sep 2020 16:39:52 +0900 Subject: [PATCH] Revert "[NUI] Refactoring Theme and StyleManager (#1981)" (#2013) This reverts commit 3b9f27432d37bb9957f644f4b45d7bacc4914c10. Co-authored-by: dongsug-song <35130733+dongsug-song@users.noreply.github.com> --- .../Controls/Button.Internal.cs | 74 ++-- src/Tizen.NUI.Components/Controls/Button.cs | 121 +++--- src/Tizen.NUI.Components/Controls/Control.cs | 51 +-- .../Controls/DropDown.DropDownDataItem.cs | 2 +- .../Controls/Extension/LottieButtonExtension.cs | 4 - .../Controls/Extension/LottieSwitchExtension.cs | 4 - .../Controls/ImageScrollBar.cs | 16 + src/Tizen.NUI.Components/Controls/Loading.cs | 2 +- src/Tizen.NUI.Components/Controls/Popup.cs | 32 +- src/Tizen.NUI.Components/Controls/Progress.cs | 16 + src/Tizen.NUI.Components/Controls/Scrollbar.cs | 47 +-- src/Tizen.NUI.Components/Controls/Slider.cs | 16 + src/Tizen.NUI.Components/Controls/Switch.cs | 15 + src/Tizen.NUI.Components/Controls/Tab.cs | 15 + src/Tizen.NUI.Components/Controls/Toast.cs | 22 +- .../PreloadStyle/DefaultTheme.cs | 445 +++++++++++++++++++++ .../PreloadStyle/OverlayAnimationButtonStyle.cs | 2 +- .../PreloadStyle/WearableTheme.cs | 146 +++++++ src/Tizen.NUI.Components/Style/ButtonStyle.cs | 101 ++++- src/Tizen.NUI.Components/Style/ControlStyle.cs | 8 + src/Tizen.NUI.Components/Style/DropDownStyle.cs | 68 +++- src/Tizen.NUI.Components/Style/LoadingStyle.cs | 78 ++-- src/Tizen.NUI.Components/Style/PaginationStyle.cs | 72 +--- src/Tizen.NUI.Components/Style/PopupStyle.cs | 73 +++- src/Tizen.NUI.Components/Style/ProgressStyle.cs | 63 ++- src/Tizen.NUI.Components/Style/ScrollbarStyle.cs | 42 +- src/Tizen.NUI.Components/Style/SliderStyle.cs | 112 +++++- src/Tizen.NUI.Components/Style/SwitchStyle.cs | 52 ++- src/Tizen.NUI.Components/Style/TabStyle.cs | 61 ++- src/Tizen.NUI.Components/Style/Theme.cs | 88 ++++ src/Tizen.NUI.Components/Style/ToastStyle.cs | 54 +-- .../Tizen.NUI.Components.csproj | 2 +- src/Tizen.NUI.Components/Utils/StyleManager.cs | 186 ++++++--- ...izen.NUI.Components_Tizen.NUI.Theme.Common.xaml | 215 ---------- ...en.NUI.Components_Tizen.NUI.Theme.Wearable.xaml | 179 --------- src/Tizen.NUI.Wearable/Tizen.NUI.Wearable.csproj | 5 +- .../Tizen.NUI.Wearable_Tizen.NUI.Theme.Common.xaml | 30 -- ...izen.NUI.Wearable_Tizen.NUI.Theme.Wearable.xaml | 30 -- .../src/public/CircularProgress.cs | 2 +- .../src/public/CircularScrollbar.cs | 15 +- .../src/public/CircularSlider.cs | 2 +- src/Tizen.NUI.Wearable/src/public/Popup.cs | 4 +- .../WearableStyle/CircularPaginationStyle.cs | 90 ++--- .../public/WearableStyle/CircularProgressStyle.cs | 29 +- .../public/WearableStyle/CircularScrollbarStyle.cs | 38 +- .../public/WearableStyle/CircularSliderStyle.cs | 33 +- .../src/public/WearableStyle/PopupStyle.cs | 42 +- src/Tizen.NUI/Tizen.NUI.csproj | 6 - .../Theme/Tizen.NUI_Tizen.NUI.Theme.Common.xaml | 3 - .../Theme/Tizen.NUI_Tizen.NUI.Theme.Wearable.xaml | 3 - .../src/internal/Xaml/ApplyPropertiesVisitor.cs | 15 +- src/Tizen.NUI/src/internal/Xaml/XamlLoader.cs | 18 - src/Tizen.NUI/src/internal/Xaml/XamlParser.cs | 7 +- .../internal/XamlBinding/ExtentsTypeConverter.cs | 4 - .../src/public/BaseComponents/ImageView.cs | 4 +- .../public/BaseComponents/LottieAnimationView.cs | 31 +- .../public/BaseComponents/Style/ImageViewStyle.cs | 2 +- .../src/public/BaseComponents/Style/Selector.cs | 11 +- .../public/BaseComponents/Style/TextFieldStyle.cs | 2 +- .../public/BaseComponents/Style/TextLabelStyle.cs | 2 +- .../src/public/BaseComponents/Style/ViewStyle.cs | 50 +-- .../Style/ViewStyleBindableProperty.cs | 42 +- .../src/public/BaseComponents/TextField.cs | 2 - .../src/public/BaseComponents/TextLabel.cs | 2 - src/Tizen.NUI/src/public/BaseComponents/View.cs | 30 +- .../public/BaseComponents/ViewBindableProperty.cs | 23 -- .../src/public/BaseComponents/ViewInternal.cs | 4 - src/Tizen.NUI/src/public/Color.cs | 6 +- src/Tizen.NUI/src/public/Extents.cs | 7 +- src/Tizen.NUI/src/public/Position.cs | 6 +- src/Tizen.NUI/src/public/Position2D.cs | 6 +- src/Tizen.NUI/src/public/Rectangle.cs | 7 +- src/Tizen.NUI/src/public/Size.cs | 6 +- src/Tizen.NUI/src/public/Size2D.cs | 8 +- src/Tizen.NUI/src/public/StyleManager.cs | 7 - src/Tizen.NUI/src/public/Theme/Theme.cs | 229 ----------- .../src/public/Theme/ThemeChangedEventArgs.cs | 40 -- src/Tizen.NUI/src/public/Theme/ThemeManager.cs | 269 ------------- src/Tizen.NUI/src/public/Vector2.cs | 7 +- src/Tizen.NUI/src/public/Vector3.cs | 7 +- src/Tizen.NUI/src/public/Vector4.cs | 7 +- .../src/public/ViewProperty/ImageShadow.cs | 2 +- src/Tizen.NUI/src/public/ViewProperty/Shadow.cs | 2 +- .../src/public/ViewProperty/ShadowBase.cs | 4 +- .../src/public/ViewProperty/TextShadow.cs | 2 +- .../ApplicationResourcePathExtension.cs | 34 -- .../MarkupExtensions/NUIResourcePathExtension.cs | 34 -- .../src/public/XamlBinding/BindableObject.cs | 43 +- 88 files changed, 1862 insertions(+), 1936 deletions(-) create mode 100755 src/Tizen.NUI.Components/PreloadStyle/DefaultTheme.cs create mode 100644 src/Tizen.NUI.Components/PreloadStyle/WearableTheme.cs create mode 100755 src/Tizen.NUI.Components/Style/Theme.cs delete mode 100644 src/Tizen.NUI.Components/res/Theme/Tizen.NUI.Components_Tizen.NUI.Theme.Common.xaml delete mode 100644 src/Tizen.NUI.Components/res/Theme/Tizen.NUI.Components_Tizen.NUI.Theme.Wearable.xaml delete mode 100644 src/Tizen.NUI.Wearable/res/Theme/Tizen.NUI.Wearable_Tizen.NUI.Theme.Common.xaml delete mode 100644 src/Tizen.NUI.Wearable/res/Theme/Tizen.NUI.Wearable_Tizen.NUI.Theme.Wearable.xaml delete mode 100644 src/Tizen.NUI/res/Theme/Tizen.NUI_Tizen.NUI.Theme.Common.xaml delete mode 100644 src/Tizen.NUI/res/Theme/Tizen.NUI_Tizen.NUI.Theme.Wearable.xaml delete mode 100644 src/Tizen.NUI/src/public/Theme/Theme.cs delete mode 100644 src/Tizen.NUI/src/public/Theme/ThemeChangedEventArgs.cs delete mode 100644 src/Tizen.NUI/src/public/Theme/ThemeManager.cs delete mode 100644 src/Tizen.NUI/src/public/Xaml/MarkupExtensions/ApplicationResourcePathExtension.cs delete mode 100644 src/Tizen.NUI/src/public/Xaml/MarkupExtensions/NUIResourcePathExtension.cs diff --git a/src/Tizen.NUI.Components/Controls/Button.Internal.cs b/src/Tizen.NUI.Components/Controls/Button.Internal.cs index 9e7a3bd..9ab7334 100755 --- a/src/Tizen.NUI.Components/Controls/Button.Internal.cs +++ b/src/Tizen.NUI.Components/Controls/Button.Internal.cs @@ -30,16 +30,7 @@ namespace Tizen.NUI.Components [EditorBrowsable(EditorBrowsableState.Never)] protected virtual TextLabel CreateText() { - return new TextLabel - { - PositionUsesPivotPoint = true, - ParentOrigin = NUI.ParentOrigin.Center, - PivotPoint = NUI.PivotPoint.Center, - WidthResizePolicy = ResizePolicyType.FillToParent, - HeightResizePolicy = ResizePolicyType.FillToParent, - HorizontalAlignment = HorizontalAlignment.Center, - VerticalAlignment = VerticalAlignment.Center - }; + return new TextLabel(); } /// @@ -49,12 +40,7 @@ namespace Tizen.NUI.Components [EditorBrowsable(EditorBrowsableState.Never)] protected virtual ImageView CreateIcon() { - return new ImageView - { - PositionUsesPivotPoint = true, - ParentOrigin = NUI.ParentOrigin.Center, - PivotPoint = NUI.PivotPoint.Center - }; + return new ImageView(); } /// @@ -64,14 +50,7 @@ namespace Tizen.NUI.Components [EditorBrowsable(EditorBrowsableState.Never)] protected virtual ImageView CreateOverlayImage() { - return new ImageView - { - PositionUsesPivotPoint = true, - ParentOrigin = NUI.ParentOrigin.Center, - PivotPoint = NUI.PivotPoint.Center, - WidthResizePolicy = ResizePolicyType.FillToParent, - HeightResizePolicy = ResizePolicyType.FillToParent - }; + return new ImageView(); } /// @@ -206,12 +185,12 @@ namespace Tizen.NUI.Components [EditorBrowsable(EditorBrowsableState.Never)] protected virtual void MeasureText() { - if (buttonIcon == null || buttonText == null) + if (Icon == null || TextLabel == null) { return; } - buttonText.WidthResizePolicy = ResizePolicyType.Fixed; - buttonText.HeightResizePolicy = ResizePolicyType.Fixed; + TextLabel.WidthResizePolicy = ResizePolicyType.Fixed; + TextLabel.HeightResizePolicy = ResizePolicyType.Fixed; int textPaddingStart = buttonStyle.TextPadding.Start; int textPaddingEnd = buttonStyle.TextPadding.End; int textPaddingTop = buttonStyle.TextPadding.Top; @@ -224,13 +203,13 @@ namespace Tizen.NUI.Components if (IconRelativeOrientation == IconOrientation.Top || IconRelativeOrientation == IconOrientation.Bottom) { - buttonText.SizeWidth = SizeWidth - textPaddingStart - textPaddingEnd; - buttonText.SizeHeight = SizeHeight - textPaddingTop - textPaddingBottom - iconPaddingTop - iconPaddingBottom - buttonIcon.SizeHeight; + TextLabel.SizeWidth = SizeWidth - textPaddingStart - textPaddingEnd; + TextLabel.SizeHeight = SizeHeight - textPaddingTop - textPaddingBottom - iconPaddingTop - iconPaddingBottom - Icon.SizeHeight; } else { - buttonText.SizeWidth = SizeWidth - textPaddingStart - textPaddingEnd - iconPaddingStart - iconPaddingEnd - buttonIcon.SizeWidth; - buttonText.SizeHeight = SizeHeight - textPaddingTop - textPaddingBottom; + TextLabel.SizeWidth = SizeWidth - textPaddingStart - textPaddingEnd - iconPaddingStart - iconPaddingEnd - Icon.SizeWidth; + TextLabel.SizeHeight = SizeHeight - textPaddingTop - textPaddingBottom; } } @@ -242,11 +221,14 @@ namespace Tizen.NUI.Components [EditorBrowsable(EditorBrowsableState.Never)] protected virtual void LayoutChild() { - if (buttonIcon == null || buttonText == null) + if (Icon == null || TextLabel == null) { return; } + var buttonIcon = Icon; + var buttonText = TextLabel; + int textPaddingStart = buttonStyle.TextPadding.Start; int textPaddingEnd = buttonStyle.TextPadding.End; int textPaddingTop = buttonStyle.TextPadding.Top; @@ -345,6 +327,22 @@ namespace Tizen.NUI.Components } /// + /// Theme change callback when theme is changed, this callback will be trigger. + /// + /// The sender + /// The event data + [EditorBrowsable(EditorBrowsableState.Never)] + protected override void OnThemeChangedEvent(object sender, StyleManager.ThemeChangeEventArgs e) + { + ButtonStyle buttonStyle = StyleManager.Instance.GetViewStyle(StyleName) as ButtonStyle; + if (buttonStyle != null) + { + ApplyStyle(buttonStyle); + UpdateUIContent(); + } + } + + /// /// Dispose Button and all children on it. /// /// Dispose type. @@ -360,17 +358,17 @@ namespace Tizen.NUI.Components { Extension?.OnDispose(this); - if (buttonIcon != null) + if (Icon != null) { - Utility.Dispose(buttonIcon); + Utility.Dispose(Icon); } - if (buttonText != null) + if (TextLabel != null) { - Utility.Dispose(buttonText); + Utility.Dispose(TextLabel); } - if (overlayImage != null) + if (OverlayImage != null) { - Utility.Dispose(overlayImage); + Utility.Dispose(OverlayImage); } } diff --git a/src/Tizen.NUI.Components/Controls/Button.cs b/src/Tizen.NUI.Components/Controls/Button.cs index e8f3bf7..115ef2d 100755 --- a/src/Tizen.NUI.Components/Controls/Button.cs +++ b/src/Tizen.NUI.Components/Controls/Button.cs @@ -64,21 +64,18 @@ namespace Tizen.NUI.Components var instance = (Button)bindable; if (newValue != null) { - bool newEnabled = (bool)newValue; - if (instance.isEnabled != newEnabled) + if (instance.buttonStyle != null && (!instance.styleApplied || instance.buttonStyle.IsEnabled != (bool)newValue)) { - instance.isEnabled = newEnabled; - - if (instance.buttonStyle != null) - { - instance.buttonStyle.IsEnabled = newEnabled; - } - + instance.buttonStyle.IsEnabled = (bool)newValue; instance.UpdateState(); } } }, - defaultValueCreator: (bindable) => ((Button)bindable).isEnabled); + defaultValueCreator: (bindable) => + { + var instance = (Button)bindable; + 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)] public static readonly BindableProperty IsSelectedProperty = BindableProperty.Create(nameof(IsSelected), typeof(bool), typeof(Button), true, propertyChanged: (bindable, oldValue, newValue) => @@ -86,27 +83,17 @@ namespace Tizen.NUI.Components var instance = (Button)bindable; if (newValue != null) { - bool newSelected = (bool)newValue; - if (instance.isSelected != newSelected) + if (instance.buttonStyle != null && instance.IsSelectable && (!instance.styleApplied || instance.buttonStyle.IsSelected != (bool)newValue)) { - instance.isSelected = newSelected; - - if (instance.buttonStyle != null) - { - instance.buttonStyle.IsSelected = newSelected; - } - - if (instance.isSelectable) - { - instance.UpdateState(); - } + instance.buttonStyle.IsSelected = (bool)newValue; + instance.UpdateState(); } } }, defaultValueCreator: (bindable) => { var instance = (Button)bindable; - return instance.isSelectable && 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)] @@ -115,22 +102,17 @@ namespace Tizen.NUI.Components var instance = (Button)bindable; if (newValue != null) { - bool newSelectable = (bool)newValue; - if (instance.isSelectable != newSelectable) + if (instance.buttonStyle != null && (!instance.styleApplied || instance.buttonStyle.IsSelectable != (bool)newValue)) { - instance.isSelectable = newSelectable; - - if (instance.buttonStyle != null) - { - instance.buttonStyle.IsSelectable = newSelectable; - } - - instance.UpdateState(); + instance.buttonStyle.IsSelectable = (bool)newValue; } } }, - defaultValueCreator: (bindable) => ((Button)bindable).isSelectable); - + defaultValueCreator: (bindable) => + { + var instance = (Button)bindable; + 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) => @@ -164,10 +146,6 @@ namespace Tizen.NUI.Components return instance.buttonStyle?.TextPadding; }); - private bool isSelected = false; - private bool isSelectable = false; - private bool isEnabled = true; - static Button() { } /// @@ -272,11 +250,8 @@ namespace Tizen.NUI.Components { buttonIcon = Extension.OnCreateIcon(this, buttonIcon); } - if (null != buttonIcon) - { - Add(buttonIcon); - buttonIcon.Relayout += OnIconRelayout; - } + Add(buttonIcon); + buttonIcon.Relayout += OnIconRelayout; } return buttonIcon; } @@ -301,10 +276,9 @@ namespace Tizen.NUI.Components { overlayImage = Extension.OnCreateOverlayImage(this, overlayImage); } - if (null != overlayImage) - { - Add(overlayImage); - } + overlayImage.WidthResizePolicy = ResizePolicyType.FillToParent; + overlayImage.HeightResizePolicy = ResizePolicyType.FillToParent; + Add(overlayImage); } return overlayImage; } @@ -329,10 +303,9 @@ namespace Tizen.NUI.Components { buttonText = Extension.OnCreateText(this, buttonText); } - if (null != buttonText) - { - Add(buttonText); - } + buttonText.HorizontalAlignment = HorizontalAlignment.Center; + buttonText.VerticalAlignment = VerticalAlignment.Center; + Add(buttonText); } return buttonText; } @@ -810,5 +783,47 @@ namespace Tizen.NUI.Components [Obsolete("Deprecated in API8; Will be removed in API10")] public ControlStates CurrentState; } + + /// + /// Get current text part to the attached ButtonExtension. + /// + /// + /// It returns null if the passed extension is invalid. + /// + /// The extension instance that is currently attached to this Button. + /// The button's text part. + [EditorBrowsable(EditorBrowsableState.Never)] + public TextLabel GetCurrentText(ButtonExtension extension) + { + return (extension == Extension) ? TextLabel : null; + } + + /// + /// Get current icon part to the attached ButtonExtension. + /// + /// + /// It returns null if the passed extension is invalid. + /// + /// The extension instance that is currently attached to this Button. + /// The button's icon part. + [EditorBrowsable(EditorBrowsableState.Never)] + public ImageView GetCurrentIcon(ButtonExtension extension) + { + return (extension == Extension) ? Icon : null; + } + + /// + /// Get current overlay image part to the attached ButtonExtension. + /// + /// + /// It returns null if the passed extension is invalid. + /// + /// The extension instance that is currently attached to this Button. + /// The button's overlay image part. + [EditorBrowsable(EditorBrowsableState.Never)] + public ImageView GetCurrentOverlayImage(ButtonExtension extension) + { + return (extension == Extension) ? OverlayImage : null; + } } } diff --git a/src/Tizen.NUI.Components/Controls/Control.cs b/src/Tizen.NUI.Components/Controls/Control.cs index 1906135..54e9c93 100755 --- a/src/Tizen.NUI.Components/Controls/Control.cs +++ b/src/Tizen.NUI.Components/Controls/Control.cs @@ -40,8 +40,6 @@ namespace Tizen.NUI.Components public static readonly BindableProperty CommandParameterProperty = BindableProperty.Create("CommandParameter", typeof(object), typeof(Button), null, propertyChanged: (bindable, oldvalue, newvalue) => ((Button)bindable).CommandCanExecuteChanged(bindable, EventArgs.Empty)); - private bool onThemeChangedEventOverrideChecker; - /// Control style. /// 6 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. @@ -64,9 +62,18 @@ namespace Tizen.NUI.Components [EditorBrowsable(EditorBrowsableState.Never)] public Control() : base() { - ViewStyle viewStyle = ThemeManager.GetStyle(GetType()); + var cur_type = this.GetType(); + ViewStyle viewStyle = null; + + do + { + if (cur_type.Equals(typeof(Tizen.NUI.Components.Control))) break; + viewStyle = StyleManager.Instance.GetComponentStyle(cur_type); + cur_type = cur_type.BaseType; + } + while (viewStyle == null); - if (viewStyle != null && ViewStyle?.GetType() == viewStyle.GetType()) + if (viewStyle != null) { ApplyStyle(viewStyle); } @@ -103,7 +110,6 @@ namespace Tizen.NUI.Components ApplyStyle(viewStyle); this.StyleName = styleName; - ThemeChangeSensitive = true; Initialize(); } @@ -164,6 +170,7 @@ namespace Tizen.NUI.Components if (type == DisposeTypes.Explicit) { + StyleManager.Instance.ThemeChangedEvent -= OnThemeChangedEvent; tapGestureDetector.Detected -= OnTapGestureDetected; tapGestureDetector.Detach(this); } @@ -245,17 +252,13 @@ namespace Tizen.NUI.Components /// /// Theme change callback when theme is changed, this callback will be trigger. - /// Note that it is deprecated API.Please use OnThemeChanged instead. /// /// The sender /// The event data /// 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)] - protected virtual void OnThemeChangedEvent(object sender, StyleManager.ThemeChangeEventArgs e) - { - onThemeChangedEventOverrideChecker = false; - } + protected virtual void OnThemeChangedEvent(object sender, StyleManager.ThemeChangeEventArgs e) { } /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] @@ -264,32 +267,6 @@ namespace Tizen.NUI.Components return new ControlStyle(); } - /// - [EditorBrowsable(EditorBrowsableState.Never)] - protected override void OnThemeChanged(object sender, ThemeChangedEventArgs e) - { - // TODO Remove checker after update Tizen.FH.NUI. - onThemeChangedEventOverrideChecker = true; - - OnThemeChangedEvent(sender, new StyleManager.ThemeChangeEventArgs { CurrentTheme = e.ThemeId }); - - if (onThemeChangedEventOverrideChecker) return; - - // If the OnThemeChangedEvent is not implemented, ApplyStyle() - if (string.IsNullOrEmpty(StyleName)) - { - base.OnThemeChanged(sender, e); - return; - } - - ViewStyle newStyle = ThemeManager.GetStyle(StyleName); - - if (newStyle != null) - { - ApplyStyle(newStyle); - } - } - private void Initialize() { LeaveRequired = true; @@ -300,6 +277,8 @@ namespace Tizen.NUI.Components tapGestureDetector.Detected += OnTapGestureDetected; EnableControlState = true; + + StyleManager.Instance.ThemeChangedEvent += OnThemeChangedEvent; } } } diff --git a/src/Tizen.NUI.Components/Controls/DropDown.DropDownDataItem.cs b/src/Tizen.NUI.Components/Controls/DropDown.DropDownDataItem.cs index d03c56d..548a82f 100755 --- a/src/Tizen.NUI.Components/Controls/DropDown.DropDownDataItem.cs +++ b/src/Tizen.NUI.Components/Controls/DropDown.DropDownDataItem.cs @@ -24,7 +24,7 @@ namespace Tizen.NUI.Components [EditorBrowsable(EditorBrowsableState.Never)] public DropDownDataItem() { - itemDataStyle = (DropDownItemStyle)ThemeManager.GetStyle(typeof(DropDownDataItem)); + itemDataStyle = (DropDownItemStyle)StyleManager.Instance.GetComponentStyle(this.GetType()); Initialize(); } diff --git a/src/Tizen.NUI.Components/Controls/Extension/LottieButtonExtension.cs b/src/Tizen.NUI.Components/Controls/Extension/LottieButtonExtension.cs index 922e89a..cdb194b 100644 --- a/src/Tizen.NUI.Components/Controls/Extension/LottieButtonExtension.cs +++ b/src/Tizen.NUI.Components/Controls/Extension/LottieButtonExtension.cs @@ -48,10 +48,6 @@ namespace Tizen.NUI.Components.Extension [EditorBrowsable(EditorBrowsableState.Never)] public override ImageView OnCreateIcon(Button button, ImageView icon) { - LottieView.PositionUsesPivotPoint = true; - LottieView.ParentOrigin = NUI.ParentOrigin.Center; - LottieView.PivotPoint = NUI.PivotPoint.Center; - InitializeLottieView(button, LottieView); return LottieView; diff --git a/src/Tizen.NUI.Components/Controls/Extension/LottieSwitchExtension.cs b/src/Tizen.NUI.Components/Controls/Extension/LottieSwitchExtension.cs index e623242..246bde2 100644 --- a/src/Tizen.NUI.Components/Controls/Extension/LottieSwitchExtension.cs +++ b/src/Tizen.NUI.Components/Controls/Extension/LottieSwitchExtension.cs @@ -47,10 +47,6 @@ namespace Tizen.NUI.Components.Extension [EditorBrowsable(EditorBrowsableState.Never)] public override ImageView OnCreateIcon(Button button, ImageView icon) { - LottieView.PositionUsesPivotPoint = true; - LottieView.ParentOrigin = NUI.ParentOrigin.Center; - LottieView.PivotPoint = NUI.PivotPoint.Center; - LottieButtonExtension.InitializeLottieView(button, LottieView); return LottieView; diff --git a/src/Tizen.NUI.Components/Controls/ImageScrollBar.cs b/src/Tizen.NUI.Components/Controls/ImageScrollBar.cs index 8962036..4cfe86f 100755 --- a/src/Tizen.NUI.Components/Controls/ImageScrollBar.cs +++ b/src/Tizen.NUI.Components/Controls/ImageScrollBar.cs @@ -497,6 +497,22 @@ namespace Tizen.NUI.Components return new ScrollBarStyle(); } + /// + /// Theme change callback when theme is changed, this callback will be trigger. + /// + /// The sender + /// The event data + [EditorBrowsable(EditorBrowsableState.Never)] + protected override void OnThemeChangedEvent(object sender, StyleManager.ThemeChangeEventArgs e) + { + ScrollBarStyle tempStyle = StyleManager.Instance.GetViewStyle(StyleName) as ScrollBarStyle; + if (tempStyle != null) + { + Style.CopyFrom(tempStyle); + UpdateValue(); + } + } + private void Initialize() { this.Focusable = false; diff --git a/src/Tizen.NUI.Components/Controls/Loading.cs b/src/Tizen.NUI.Components/Controls/Loading.cs index df0245e..08da492 100755 --- a/src/Tizen.NUI.Components/Controls/Loading.cs +++ b/src/Tizen.NUI.Components/Controls/Loading.cs @@ -75,7 +75,7 @@ namespace Tizen.NUI.Components int frameRate = (int)newValue; if (0 != frameRate) //It will crash if 0 { - instance.loadingStyle.FrameRate = frameRate; + instance.loadingStyle.FrameRate.All = frameRate; instance.imageVisual.FrameDelay = 1000.0f / frameRate; } } diff --git a/src/Tizen.NUI.Components/Controls/Popup.cs b/src/Tizen.NUI.Components/Controls/Popup.cs index f0ffc67..9a44d4a 100755 --- a/src/Tizen.NUI.Components/Controls/Popup.cs +++ b/src/Tizen.NUI.Components/Controls/Popup.cs @@ -357,14 +357,7 @@ namespace Tizen.NUI.Components { if (null == titleText) { - titleText = new TextLabel - { - PositionUsesPivotPoint = true, - ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft, - PivotPoint = Tizen.NUI.PivotPoint.TopLeft, - HorizontalAlignment = HorizontalAlignment.Begin, - VerticalAlignment = VerticalAlignment.Bottom - }; + titleText = new TextLabel(); Add(titleText); } return titleText; @@ -750,12 +743,6 @@ namespace Tizen.NUI.Components PopupStyle ppStyle = viewStyle as PopupStyle; if (null != ppStyle) { - if (ppStyle.Buttons != null) - { - if (ppStyle.Buttons.PositionUsesPivotPoint == null) ppStyle.Buttons.PositionUsesPivotPoint = true; - if (ppStyle.Buttons.ParentOrigin == null) ppStyle.Buttons.ParentOrigin = Tizen.NUI.ParentOrigin.BottomLeft; - if (ppStyle.Buttons.PivotPoint == null) ppStyle.Buttons.PivotPoint = Tizen.NUI.PivotPoint.BottomLeft; - } Title.ApplyStyle(ppStyle.Title); Title.RaiseToTop(); } @@ -771,12 +758,20 @@ namespace Tizen.NUI.Components return new PopupStyle(); } - /// + /// + /// Theme change callback when theme is changed, this callback will be trigger. + /// + /// The sender + /// The event data [EditorBrowsable(EditorBrowsableState.Never)] - protected override void OnUpdate() + protected override void OnThemeChangedEvent(object sender, StyleManager.ThemeChangeEventArgs e) { - base.OnUpdate(); - UpdateView(); + PopupStyle ppStyle = StyleManager.Instance.GetViewStyle(StyleName) as PopupStyle; + if (ppStyle != null) + { + ApplyStyle(ppStyle); + UpdateView(); + } } private void Initialize() @@ -804,7 +799,6 @@ namespace Tizen.NUI.Components private void UpdateView() { - if (popupStyle == null) return; btGroup.UpdateButton(popupStyle.Buttons); UpdateContentView(); UpdateTitle(); diff --git a/src/Tizen.NUI.Components/Controls/Progress.cs b/src/Tizen.NUI.Components/Controls/Progress.cs index 5b18b4a..42f6ae0 100755 --- a/src/Tizen.NUI.Components/Controls/Progress.cs +++ b/src/Tizen.NUI.Components/Controls/Progress.cs @@ -426,6 +426,22 @@ namespace Tizen.NUI.Components } /// + /// Theme change callback when theme is changed, this callback will be trigger. + /// + /// The sender + /// The event data + [EditorBrowsable(EditorBrowsableState.Never)] + protected override void OnThemeChangedEvent(object sender, StyleManager.ThemeChangeEventArgs e) + { + ProgressStyle tempStyle = StyleManager.Instance.GetViewStyle(StyleName) as ProgressStyle; + if (null != tempStyle) + { + progressStyle.CopyFrom(tempStyle); + RelayoutRequest(); + } + } + + /// /// Change Image status. It can be override. /// /// 6 diff --git a/src/Tizen.NUI.Components/Controls/Scrollbar.cs b/src/Tizen.NUI.Components/Controls/Scrollbar.cs index 6780799..6a01a63 100755 --- a/src/Tizen.NUI.Components/Controls/Scrollbar.cs +++ b/src/Tizen.NUI.Components/Controls/Scrollbar.cs @@ -122,7 +122,7 @@ namespace Tizen.NUI.Components /// /// Create an empty Scrollbar. /// - public Scrollbar() : base(ThemeManager.GetStyle(typeof(Scrollbar))) + public Scrollbar() : base(new ScrollbarStyle()) { } @@ -134,7 +134,7 @@ namespace Tizen.NUI.Components /// The current position of the viewport in scrollable content area. This is the viewport's top position if the scroller is vertical, otherwise, left. /// Whether the direction of scrolling is horizontal or not. It is vertical by default. [EditorBrowsable(EditorBrowsableState.Never)] - public Scrollbar(float contentLength, float viewportLength, float currentPosition, bool isHorizontal = false) : this() + public Scrollbar(float contentLength, float viewportLength, float currentPosition, bool isHorizontal = false) : base(new ScrollbarStyle()) { Initialize(contentLength, viewportLength, currentPosition, isHorizontal); } @@ -402,25 +402,6 @@ namespace Tizen.NUI.Components /// [EditorBrowsable(EditorBrowsableState.Never)] - public override void ApplyStyle(ViewStyle viewStyle) - { - base.ApplyStyle(viewStyle); - - if (viewStyle is ScrollbarStyle scrollbarStyle) - { - // Apply essential look. - if (scrollbarStyle.TrackThickness == null) scrollbarStyle.TrackThickness = 6.0f; - if (scrollbarStyle.ThumbThickness == null) scrollbarStyle.ThumbThickness = 6.0f; - if (scrollbarStyle.TrackColor == null) scrollbarStyle.TrackColor = new Color(1.0f, 1.0f, 1.0f, 0.15f); - if (scrollbarStyle.ThumbColor == null) scrollbarStyle.ThumbColor = new Color(0.6f, 0.6f, 0.6f, 1.0f); - if (scrollbarStyle.TrackPadding == null) scrollbarStyle.TrackPadding = 4; - if (scrollbarStyle.WidthResizePolicy == null) scrollbarStyle.WidthResizePolicy = ResizePolicyType.FillToParent; - if (scrollbarStyle.HeightResizePolicy == null) scrollbarStyle.HeightResizePolicy = ResizePolicyType.FillToParent; - } - } - - /// - [EditorBrowsable(EditorBrowsableState.Never)] protected override ViewStyle CreateViewStyle() { return new ScrollbarStyle(); @@ -634,12 +615,12 @@ namespace Tizen.NUI.Components public override Size CalculateTrackSize(float thickness, Size containerSize, Extents trackPadding) { - return new Size(containerSize.Width - trackPadding?.Start??0 - trackPadding?.End??0, thickness); + return new Size(containerSize.Width - trackPadding.Start - trackPadding.End, thickness); } public override Vector2 CalculateTrackPosition(Extents trackPadding) { - return new Vector2(0, -trackPadding?.Bottom??0); + return new Vector2(0, -trackPadding.Bottom); } public override Size CalculateThumbSize(float thickness, Size trackSize) @@ -649,21 +630,21 @@ namespace Tizen.NUI.Components public override Vector2 CalculateThumbPosition(Size trackSize, Size thumbSize, Extents trackPadding) { - float padding = ((trackSize.Height - thumbSize.Height) / 2.0f) + trackPadding?.Bottom??0; + float padding = ((trackSize.Height - thumbSize.Height) / 2.0f) + trackPadding.Bottom; float pos = Math.Min(Math.Max(currentPosition, 0.0f), contentLength - visibleLength); - return new Vector2(trackPadding?.Start??0 + trackSize.Width * pos / contentLength, -padding); + return new Vector2(trackPadding.Start + trackSize.Width * pos / contentLength, -padding); } public override Vector2 CalculateThumbPaddingPosition(Size trackSize, Size thumbSize, Vector2 thumbCurrentPosition, Extents trackPadding) { - float padding = ((trackSize.Height - thumbSize.Height) / 2.0f) + trackPadding?.Bottom??0; + float padding = ((trackSize.Height - thumbSize.Height) / 2.0f) + trackPadding.Bottom; return new Vector2(thumbCurrentPosition.X, -padding); } public override Vector2 CalculateThumbScrollPosition(Size trackSize, Vector2 thumbCurrentPosition, Extents trackPadding) { float pos = Math.Min(Math.Max(currentPosition, 0.0f), contentLength - visibleLength); - return new Vector2(trackPadding?.Start??0 + trackSize.Width * pos / contentLength, thumbCurrentPosition.Y); + return new Vector2(trackPadding.Start + trackSize.Width * pos / contentLength, thumbCurrentPosition.Y); } } @@ -685,12 +666,12 @@ namespace Tizen.NUI.Components public override Size CalculateTrackSize(float thickness, Size containerSize, Extents trackPadding) { - return new Size(thickness, containerSize.Height - trackPadding?.Top??0 - trackPadding?.Bottom??0); + return new Size(thickness, containerSize.Height - trackPadding.Top - trackPadding.Bottom); } public override Vector2 CalculateTrackPosition(Extents trackPadding) { - return new Vector2(-trackPadding?.End??0, 0); + return new Vector2(-trackPadding.End, 0); } public override Size CalculateThumbSize(float thickness, Size trackSize) @@ -700,21 +681,21 @@ namespace Tizen.NUI.Components public override Vector2 CalculateThumbPosition(Size trackSize, Size thumbSize, Extents trackPadding) { - float padding = ((trackSize.Width - thumbSize.Width) / 2.0f) + trackPadding?.End??0; + float padding = ((trackSize.Width - thumbSize.Width) / 2.0f) + trackPadding.End; float pos = Math.Min(Math.Max(currentPosition, 0.0f), contentLength - visibleLength); - return new Vector2(-padding, trackPadding?.Top??0 + trackSize.Height * pos / contentLength); + return new Vector2(-padding, trackPadding.Top + trackSize.Height * pos / contentLength); } public override Vector2 CalculateThumbPaddingPosition(Size trackSize, Size thumbSize, Vector2 thumbCurrentPosition, Extents trackPadding) { - float padding = ((trackSize.Width - thumbSize.Width) / 2.0f) + trackPadding?.End??0; + float padding = ((trackSize.Width - thumbSize.Width) / 2.0f) + trackPadding.End; return new Vector2(-padding, thumbCurrentPosition.Y); } public override Vector2 CalculateThumbScrollPosition(Size trackSize, Vector2 thumbPosition, Extents trackPadding) { float pos = Math.Min(Math.Max(currentPosition, 0.0f), contentLength - visibleLength); - return new Vector2(thumbPosition.X, trackPadding?.Top??0 + trackSize.Height * pos / contentLength); + return new Vector2(thumbPosition.X, trackPadding.Top + trackSize.Height * pos / contentLength); } } diff --git a/src/Tizen.NUI.Components/Controls/Slider.cs b/src/Tizen.NUI.Components/Controls/Slider.cs index 80c7278..66d7bc6 100755 --- a/src/Tizen.NUI.Components/Controls/Slider.cs +++ b/src/Tizen.NUI.Components/Controls/Slider.cs @@ -904,6 +904,22 @@ namespace Tizen.NUI.Components UpdateValue(); } + /// + /// Theme change callback when theme is changed, this callback will be trigger. + /// + /// The sender + /// The event data + [EditorBrowsable(EditorBrowsableState.Never)] + protected override void OnThemeChangedEvent(object sender, StyleManager.ThemeChangeEventArgs e) + { + SliderStyle sliderStyle = StyleManager.Instance.GetViewStyle(StyleName) as SliderStyle; + if (sliderStyle != null) + { + ApplyStyle(sliderStyle); + RelayoutRequest(); + } + } + private void CalculateCurrentValueByGesture(float offset) { currentSlidedOffset += offset; diff --git a/src/Tizen.NUI.Components/Controls/Switch.cs b/src/Tizen.NUI.Components/Controls/Switch.cs index e0487ca..179c1eb 100755 --- a/src/Tizen.NUI.Components/Controls/Switch.cs +++ b/src/Tizen.NUI.Components/Controls/Switch.cs @@ -316,6 +316,21 @@ namespace Tizen.NUI.Components IsSelectable = true; } + /// + /// Theme change callback when theme is changed, this callback will be trigger. + /// + /// The sender + /// The event data + [EditorBrowsable(EditorBrowsableState.Never)] + protected override void OnThemeChangedEvent(object sender, StyleManager.ThemeChangeEventArgs e) + { + SwitchStyle switchStyle = StyleManager.Instance.GetViewStyle(StyleName) as SwitchStyle; + if (null != switchStyle) + { + ApplyStyle(switchStyle); + } + } + private void OnSelect() { ((SwitchExtension)Extension)?.OnSelectedChanged(this); diff --git a/src/Tizen.NUI.Components/Controls/Tab.cs b/src/Tizen.NUI.Components/Controls/Tab.cs index df33271..b569788 100755 --- a/src/Tizen.NUI.Components/Controls/Tab.cs +++ b/src/Tizen.NUI.Components/Controls/Tab.cs @@ -498,6 +498,21 @@ namespace Tizen.NUI.Components } /// + /// Theme change callback when theme is changed, this callback will be trigger. + /// + /// The sender + /// The event data + [EditorBrowsable(EditorBrowsableState.Never)] + protected override void OnThemeChangedEvent(object sender, StyleManager.ThemeChangeEventArgs e) + { + TabStyle tabStyle = StyleManager.Instance.GetViewStyle(StyleName) as TabStyle; + if (tabStyle != null) + { + ApplyStyle(tabStyle); + } + } + + /// /// Layout child in Tab and it can be override by user. /// /// 6 diff --git a/src/Tizen.NUI.Components/Controls/Toast.cs b/src/Tizen.NUI.Components/Controls/Toast.cs index 99b16dd..c8cafad 100755 --- a/src/Tizen.NUI.Components/Controls/Toast.cs +++ b/src/Tizen.NUI.Components/Controls/Toast.cs @@ -326,16 +326,7 @@ namespace Tizen.NUI.Components { if (null == textLabel) { - textLabel = new TextLabel() - { - PositionUsesPivotPoint = true, - ParentOrigin = Tizen.NUI.ParentOrigin.Center, - PivotPoint = Tizen.NUI.PivotPoint.Center, - WidthResizePolicy = ResizePolicyType.UseNaturalSize, - HeightResizePolicy = ResizePolicyType.UseNaturalSize, - HorizontalAlignment = HorizontalAlignment.Center, - VerticalAlignment = VerticalAlignment.Center, - }; + textLabel = new TextLabel(); this.Add(textLabel); } textLabel.ApplyStyle(toastStyle.Text); @@ -388,16 +379,7 @@ namespace Tizen.NUI.Components { if (null == textLabel) { - textLabel = new TextLabel() - { - PositionUsesPivotPoint = true, - ParentOrigin = Tizen.NUI.ParentOrigin.Center, - PivotPoint = Tizen.NUI.PivotPoint.Center, - WidthResizePolicy = ResizePolicyType.UseNaturalSize, - HeightResizePolicy = ResizePolicyType.UseNaturalSize, - HorizontalAlignment = HorizontalAlignment.Center, - VerticalAlignment = VerticalAlignment.Center, - }; + textLabel = new TextLabel(); this.Add(textLabel); } diff --git a/src/Tizen.NUI.Components/PreloadStyle/DefaultTheme.cs b/src/Tizen.NUI.Components/PreloadStyle/DefaultTheme.cs new file mode 100755 index 0000000..8ebd6fb --- /dev/null +++ b/src/Tizen.NUI.Components/PreloadStyle/DefaultTheme.cs @@ -0,0 +1,445 @@ +/* + * 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; +using Tizen.NUI.BaseComponents; + +namespace Tizen.NUI.Components +{ + /// + /// Interface that includes styles for all components for a default theme + /// + [EditorBrowsable(EditorBrowsableState.Never)] + internal class DefaultTheme : Theme + { + internal static Theme Instance { get; } = new DefaultTheme(); + + protected DefaultTheme() : base() + { + } + + protected override ButtonStyle GetButtonStyle() + { + return new ButtonStyle + { + Size = new Size(100, 45), + BackgroundColor = new Selector + { + Normal = new Color(0.88f, 0.88f, 0.88f, 1), + Pressed = new Color(0.77f, 0.77f, 0.77f, 1), + Disabled = new Color(0.88f, 0.88f, 0.88f, 1) + }, + Text = new TextLabelStyle + { + PointSize = new Selector { All = StyleManager.PointSizeNormal }, + WidthResizePolicy = ResizePolicyType.FillToParent, + HeightResizePolicy = ResizePolicyType.FillToParent, + HorizontalAlignment = HorizontalAlignment.Center, + VerticalAlignment = VerticalAlignment.Center, + TextColor = new Selector + { + Normal = new Color(0.22f, 0.22f, 0.22f, 1), + Pressed = new Color(0.11f, 0.11f, 0.11f, 1), + Disabled = new Color(0.66f, 0.66f, 0.66f, 1) + }, + Text = "Button", + } + }; + } + + protected override ButtonStyle GetCheckBoxStyle() + { + return new ButtonStyle + { + Size = new Size(30, 30), + Icon = new ImageViewStyle + { + WidthResizePolicy = ResizePolicyType.DimensionDependency, + HeightResizePolicy = ResizePolicyType.SizeRelativeToParent, + SizeModeFactor = new Vector3(1, 1, 1), + Opacity = new Selector + { + Normal = 1.0f, + Selected = 1.0f, + Disabled = 0.4f, + DisabledSelected = 0.4f + }, + BackgroundImage = new Selector + { + Normal = StyleManager.GetFrameworkResourcePath("nui_component_default_checkbox_bg_n.png"), + Pressed = StyleManager.GetFrameworkResourcePath("nui_component_default_checkbox_bg_p.png"), + Selected = StyleManager.GetFrameworkResourcePath("nui_component_default_checkbox_bg_p.png"), + Disabled = StyleManager.GetFrameworkResourcePath("nui_component_default_checkbox_bg_n.png"), + DisabledSelected = StyleManager.GetFrameworkResourcePath("nui_component_default_checkbox_bg_p.png"), + }, + ResourceUrl = new Selector + { + Normal = "", + Pressed = "", + Selected = StyleManager.GetFrameworkResourcePath("nui_component_default_checkbox_s.png"), + Disabled = "", + DisabledSelected = StyleManager.GetFrameworkResourcePath("nui_component_default_checkbox_s.png"), + } + }, + Text = new TextLabelStyle + { + PointSize = new Selector { All = StyleManager.PointSizeNormal }, + WidthResizePolicy = ResizePolicyType.FillToParent, + HeightResizePolicy = ResizePolicyType.FillToParent, + HorizontalAlignment = HorizontalAlignment.Center, + VerticalAlignment = VerticalAlignment.Center, + TextColor = new Selector + { + Normal = new Color(0.22f, 0.22f, 0.22f, 1), + Pressed = new Color(0.11f, 0.11f, 0.11f, 1), + Disabled = new Color(0.66f, 0.66f, 0.66f, 1) + } + } + }; + } + + protected override DropDownStyle GetDropDownStyle() + { + return new DropDownStyle + { + Position = new Position(50, 50), + Button = new ButtonStyle + { + ParentOrigin = ParentOrigin.TopLeft, + PivotPoint = PivotPoint.TopLeft, + BackgroundImage = new Selector + { + Normal = StyleManager.GetFrameworkResourcePath("nui_component_default_checkbox_bg_n.png"), + Pressed = StyleManager.GetFrameworkResourcePath("nui_component_default_checkbox_bg_p.png") + }, + BackgroundImageBorder = (Rectangle)6, + Text = new TextLabelStyle + { + Text = "Select an item", + PointSize = StyleManager.PointSizeNormal, + TextColor = Color.Black, + }, + Icon = new ImageViewStyle + { + Size = new Size(28, 28), + ResourceUrl = StyleManager.GetFrameworkResourcePath("nui_component_default_dropdown_button_icon.png"), + }, + IconRelativeOrientation = Button.IconOrientation.Right, + IconPadding = 6, + }, + ListBackgroundImage = new ImageViewStyle + { + ResourceUrl = StyleManager.GetFrameworkResourcePath("nui_component_default_dropdown_list_bg.png"), + Border = (Rectangle)6, + Size = new Size(280, 360), + }, + SpaceBetweenButtonTextAndIcon = 10, + ListPadding = 5, + }; + } + + protected override DropDownItemStyle GetDropDownItemStyle() + { + return new DropDownItemStyle + { + Size = new Size(360, 50), + BackgroundColor = new Selector + { + Pressed = new Color(0.05f, 0.63f, 0.9f, 1), + Selected = new Color(0.8f, 0.8f, 0.8f, 1), + Normal = new Color(1, 1, 1, 1), + }, + Text = new TextLabelStyle + { + PointSize = StyleManager.PointSizeNormal, + Position = new Position(28, 0), + Text = "List item", + }, + }; + } + + protected override PopupStyle GetPopupStyle() + { + return new PopupStyle + { + Size = new Size(500, 280), + BackgroundColor = new Color(0.9f, 0.9f, 0.9f, 1), + ImageShadow = new ImageShadow + { + Url = StyleManager.GetFrameworkResourcePath("nui_component_default_popup_shadow.png"), + Border = new Rectangle(24, 24, 24, 24), + Extents = new Vector2(48, 48), + }, + Title = new TextLabelStyle + { + PointSize = 16, + TextColor = Color.Black, + PositionUsesPivotPoint = true, + ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft, + PivotPoint = Tizen.NUI.PivotPoint.TopLeft, + HorizontalAlignment = HorizontalAlignment.Begin, + VerticalAlignment = VerticalAlignment.Bottom, + Padding = 20, + Text = "Title", + }, + Buttons = new ButtonStyle + { + Size = new Size(0, 80), + PositionUsesPivotPoint = true, + ParentOrigin = Tizen.NUI.ParentOrigin.BottomLeft, + PivotPoint = Tizen.NUI.PivotPoint.BottomLeft, + BackgroundColor = new Selector + { + Normal = new Color(1, 1, 1, 1), + Pressed = new Color(1, 1, 1, 0.5f), + }, + Overlay = new ImageViewStyle + { + PositionUsesPivotPoint = true, + ParentOrigin = Tizen.NUI.ParentOrigin.Center, + PivotPoint = Tizen.NUI.PivotPoint.Center, + WidthResizePolicy = ResizePolicyType.FillToParent, + HeightResizePolicy = ResizePolicyType.FillToParent, + BackgroundColor = new Selector + { + Normal = new Color(1.0f, 1.0f, 1.0f, 1.0f), + Pressed = new Color(0.0f, 0.0f, 0.0f, 0.1f), + Selected = new Color(1.0f, 1.0f, 1.0f, 1.0f), + } + }, + Text = new TextLabelStyle + { + PositionUsesPivotPoint = true, + ParentOrigin = Tizen.NUI.ParentOrigin.Center, + PivotPoint = Tizen.NUI.PivotPoint.Center, + HorizontalAlignment = HorizontalAlignment.Center, + VerticalAlignment = VerticalAlignment.Center, + TextColor = new Color(0.05f, 0.63f, 0.9f, 1) + }, + }, + }; + } + + protected override ProgressStyle GetProgressStyle() + { + return new ProgressStyle + { + Size = new Size(200, 5), + Track = new ImageViewStyle + { + BackgroundColor = new Color(0, 0, 0, 0.1f), + }, + Buffer = new ImageViewStyle + { + BackgroundColor = new Color(0.05f, 0.63f, 0.9f, 0.3f) + }, + Progress = new ImageViewStyle + { + BackgroundColor = new Color(0.05f, 0.63f, 0.9f, 1) + }, + }; + } + + protected override ButtonStyle GetRadioButtonStyle() + { + return new ButtonStyle + { + Size = new Size(30, 30), + Icon = new ImageViewStyle + { + WidthResizePolicy = ResizePolicyType.DimensionDependency, + HeightResizePolicy = ResizePolicyType.SizeRelativeToParent, + SizeModeFactor = new Vector3(1, 1, 1), + Opacity = new Selector + { + Normal = 1.0f, + Selected = 1.0f, + Disabled = 0.4f, + DisabledSelected = 0.4f + }, + BackgroundImage = new Selector + { + Normal = StyleManager.GetFrameworkResourcePath("nui_component_default_radiobutton_n.png"), + Pressed = StyleManager.GetFrameworkResourcePath("nui_component_default_radiobutton_p.png"), + Selected = StyleManager.GetFrameworkResourcePath("nui_component_default_radiobutton_s.png"), + Disabled = StyleManager.GetFrameworkResourcePath("nui_component_default_radiobutton_n.png"), + DisabledSelected = StyleManager.GetFrameworkResourcePath("nui_component_default_radiobutton_s.png"), + } + }, + Text = new TextLabelStyle + { + PointSize = new Selector { All = StyleManager.PointSizeNormal }, + WidthResizePolicy = ResizePolicyType.FillToParent, + HeightResizePolicy = ResizePolicyType.FillToParent, + HorizontalAlignment = HorizontalAlignment.Center, + VerticalAlignment = VerticalAlignment.Center, + TextColor = new Selector + { + Normal = new Color(0.22f, 0.22f, 0.22f, 1), + Pressed = new Color(0.11f, 0.11f, 0.11f, 1), + Disabled = new Color(0.66f, 0.66f, 0.66f, 1) + } + } + }; + } + + protected override SliderStyle GetSliderStyle() + { + return new SliderStyle + { + Size = new Size(200, 50), + TrackThickness = 5, + Track = new ImageViewStyle + { + BackgroundColor = new Color(0, 0, 0, 0.1f), + }, + + Progress = new ImageViewStyle + { + BackgroundColor = new Color(0.05f, 0.63f, 0.9f, 1), + }, + + Thumb = new ImageViewStyle + { + Size = new Size(50, 50), + Color = new Color("0ea1e6"), + ResourceUrl = StyleManager.GetFrameworkResourcePath("nui_component_default_slider_thumb_n.png"), + BackgroundImage = new Selector + { + Normal = "", + Pressed = StyleManager.GetFrameworkResourcePath("nui_component_default_slider_thumb_bg_p.png"), + } + }, + + }; + } + + protected override SwitchStyle GetSwitchStyle() + { + return new SwitchStyle + { + Size = new Size(96, 60), + 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"), + Selected = StyleManager.GetFrameworkResourcePath("nui_component_default_switch_track_s.png"), + Disabled = StyleManager.GetFrameworkResourcePath("nui_component_default_switch_track_d.png"), + DisabledSelected = StyleManager.GetFrameworkResourcePath("nui_component_default_switch_track_ds.png"), + }, + Border = new Rectangle(30, 30, 30, 30), + }, + Thumb = new ImageViewStyle + { + Size = new Size(60, 60), + ResourceUrl = new Selector + { + Normal = StyleManager.GetFrameworkResourcePath("nui_component_default_switch_thumb_n.png"), + Selected = StyleManager.GetFrameworkResourcePath("nui_component_default_switch_thumb_n.png"), + Disabled = StyleManager.GetFrameworkResourcePath("nui_component_default_switch_thumb_d.png"), + DisabledSelected = StyleManager.GetFrameworkResourcePath("nui_component_default_switch_thumb_d.png"), + }, + }, + Text = new TextLabelStyle + { + PointSize = new Selector { All = StyleManager.PointSizeNormal }, + WidthResizePolicy = ResizePolicyType.FillToParent, + HeightResizePolicy = ResizePolicyType.FillToParent, + HorizontalAlignment = HorizontalAlignment.Center, + VerticalAlignment = VerticalAlignment.Center, + TextColor = new Selector + { + Normal = new Color(0.22f, 0.22f, 0.22f, 1), + Pressed = new Color(0.11f, 0.11f, 0.11f, 1), + Disabled = new Color(0.66f, 0.66f, 0.66f, 1) + } + }, + }; + } + + protected override TabStyle GetTabStyle() + { + return new TabStyle + { + BackgroundColor = Color.Yellow, + Size = new Size(480, 80), + UnderLine = new ViewStyle + { + Size = new Size(0, 6), + PositionUsesPivotPoint = true, + ParentOrigin = Tizen.NUI.ParentOrigin.BottomLeft, + PivotPoint = Tizen.NUI.PivotPoint.BottomLeft, + BackgroundColor = new Color(0.05f, 0.63f, 0.9f, 1), + }, + Text = new TextLabelStyle + { + PointSize = StyleManager.PointSizeTitle, + TextColor = new Selector + { + Normal = Color.Black, + Selected = new Color(0.05f, 0.63f, 0.9f, 1), + }, + }, + }; + } + + protected override ToastStyle GetToastStyle() + { + return new ToastStyle + { + WidthResizePolicy = ResizePolicyType.FitToChildren, + HeightResizePolicy = ResizePolicyType.FitToChildren, + BackgroundColor = new Color(0, 0, 0, 0.8f), + Text = new TextLabelStyle() + { + PositionUsesPivotPoint = true, + ParentOrigin = Tizen.NUI.ParentOrigin.Center, + PivotPoint = Tizen.NUI.PivotPoint.Center, + WidthResizePolicy = ResizePolicyType.UseNaturalSize, + HeightResizePolicy = ResizePolicyType.UseNaturalSize, + HorizontalAlignment = HorizontalAlignment.Center, + VerticalAlignment = VerticalAlignment.Center, + TextColor = Color.White, + Padding = new Extents(12, 12, 8, 8), + } + }; + } + + protected override LoadingStyle GetLoadingStyle() + { + return new LoadingStyle + { + LoadingSize = new Size(100, 100) + }; + } + + protected override PaginationStyle GetPaginationStyle() + { + return new PaginationStyle + { + IndicatorImageUrl = new Selector() + { + Normal = StyleManager.GetFrameworkResourcePath("nui_component_default_pagination_normal_dot.png"), + Selected = StyleManager.GetFrameworkResourcePath("nui_component_default_pagination_focus_dot.png"), + }, + }; + } + } +} diff --git a/src/Tizen.NUI.Components/PreloadStyle/OverlayAnimationButtonStyle.cs b/src/Tizen.NUI.Components/PreloadStyle/OverlayAnimationButtonStyle.cs index eb634dc..9961a77 100644 --- a/src/Tizen.NUI.Components/PreloadStyle/OverlayAnimationButtonStyle.cs +++ b/src/Tizen.NUI.Components/PreloadStyle/OverlayAnimationButtonStyle.cs @@ -109,7 +109,7 @@ namespace Tizen.NUI.Components return; } - var overlayImage = button.OverlayImage; + var overlayImage = button.GetCurrentOverlayImage(this); if (overlayImage == null) { diff --git a/src/Tizen.NUI.Components/PreloadStyle/WearableTheme.cs b/src/Tizen.NUI.Components/PreloadStyle/WearableTheme.cs new file mode 100644 index 0000000..35ffe80 --- /dev/null +++ b/src/Tizen.NUI.Components/PreloadStyle/WearableTheme.cs @@ -0,0 +1,146 @@ +/* + * 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; +using Tizen.NUI.BaseComponents; +using Tizen.NUI.Components.Extension; + +namespace Tizen.NUI.Components +{ + /// + /// Interface that includes styles for all components for a wearable theme + /// + [EditorBrowsable(EditorBrowsableState.Never)] + internal class WearableTheme : DefaultTheme + { + internal static new Theme Instance { get; } = new WearableTheme(); + + private WearableTheme() : base() + { + } + + protected override ButtonStyle GetButtonStyle() + { + return new ButtonStyle + { + Size = new Size(210, 72), + CornerRadius = 36, + BackgroundColor = new Selector + { + Normal = new Color(0, 42f/255f, 77f/255f, 0.85f), + Pressed = new Color(0, 70f/255f, 128f/255f, 0.85f), + Disabled = new Color(61f/255f, 61f/255f, 61f/255f, 0.85f), + }, + Text = new TextLabelStyle + { + FontFamily = "SamsungOne 700", + PixelSize = 28, + TextColor = new Selector + { + Normal = new Color(56f/255f, 164f/255f, 252f/255f, 1), + Pressed = new Color(56f/255f, 164f/255f, 252f/255f, 1), + Disabled = new Color(1, 1, 1, 0.35f), + }, + Padding = new Extents(20, 20, 0, 0), + VerticalAlignment = VerticalAlignment.Center, + HorizontalAlignment = HorizontalAlignment.Center, + }, + Opacity = new Selector + { + Other = 1.0f, + Disabled = 0.3f, + } + }; + } + + protected override ButtonStyle GetCheckBoxStyle() + { + return new LottieButtonStyle + { + LottieUrl = StyleManager.GetFrameworkResourcePath("nui_wearable_checkbox_icon.json"), + PlayRange = new Selector + { + Selected = (0, 18), + Normal = (19, 36) + }, + Opacity = new Selector + { + Other = 1.0f, + Pressed = 0.6f, + Disabled = 0.3f, + }, + }; + } + + protected override ButtonStyle GetRadioButtonStyle() + { + return new LottieButtonStyle + { + LottieUrl = StyleManager.GetFrameworkResourcePath("nui_wearable_radiobutton_icon.json"), + PlayRange = new Selector + { + Selected = (0, 12), + Normal = (13, 25) + }, + Opacity = new Selector + { + Other = 1.0f, + Pressed = 0.6f, + Disabled = 0.3f, + }, + }; + } + + protected override SwitchStyle GetSwitchStyle() + { + return new LottieSwitchStyle + { + LottieUrl = StyleManager.GetFrameworkResourcePath("nui_wearable_switch_icon.json"), + PlayRange = new Selector + { + Selected = (0, 18), + Normal = (19, 36) + }, + Opacity = new Selector + { + Other = 1.0f, + Pressed = 0.6f, + Disabled = 0.3f, + }, + }; + } + + protected override LoadingStyle GetLoadingStyle() + { + return new LoadingStyle + { + LoadingSize = new Size(360, 360) + }; + } + + protected override PaginationStyle GetPaginationStyle() + { + return new PaginationStyle + { + IndicatorImageUrl = new Selector() + { + Normal = StyleManager.GetFrameworkResourcePath("nui_component_default_pagination_normal_dot.png"), + Selected = StyleManager.GetFrameworkResourcePath("nui_component_default_pagination_focus_dot.png"), + }, + }; + } + } +} diff --git a/src/Tizen.NUI.Components/Style/ButtonStyle.cs b/src/Tizen.NUI.Components/Style/ButtonStyle.cs index a133400..21fb114 100755 --- a/src/Tizen.NUI.Components/Style/ButtonStyle.cs +++ b/src/Tizen.NUI.Components/Style/ButtonStyle.cs @@ -79,7 +79,9 @@ namespace Tizen.NUI.Components [EditorBrowsable(EditorBrowsableState.Never)] public static readonly BindableProperty IconPaddingProperty = BindableProperty.Create(nameof(IconPadding), typeof(Extents), typeof(ButtonStyle), null, propertyChanged: (bindable, oldValue, newValue) => { - ((ButtonStyle)bindable).iconPadding = null == newValue ? null : new Extents((Extents)newValue); + var buttonStyle = (ButtonStyle)bindable; + if (null == buttonStyle.iconPadding) buttonStyle.iconPadding = new Extents(buttonStyle.OnIconPaddingChanged, 0, 0, 0, 0); + buttonStyle.iconPadding.CopyFrom(null == newValue ? new Extents() : (Extents)newValue); }, defaultValueCreator: (bindable) => { @@ -90,7 +92,9 @@ namespace Tizen.NUI.Components [EditorBrowsable(EditorBrowsableState.Never)] public static readonly BindableProperty TextPaddingProperty = BindableProperty.Create(nameof(TextPadding), typeof(Extents), typeof(ButtonStyle), null, propertyChanged: (bindable, oldValue, newValue) => { - ((ButtonStyle)bindable).textPadding = null == newValue ? null : new Extents((Extents)newValue); + var buttonStyle = (ButtonStyle)bindable; + if (null == buttonStyle.textPadding) buttonStyle.textPadding = new Extents(buttonStyle.OnTextPaddingChanged, 0, 0, 0, 0); + buttonStyle.textPadding.CopyFrom(null == newValue ? new Extents() : (Extents)newValue); }, defaultValueCreator: (bindable) => { @@ -101,7 +105,7 @@ namespace Tizen.NUI.Components private bool? isSelectable; private bool? isSelected; private bool? isEnabled; - private Button.IconOrientation? iconRelativeOrientation = Button.IconOrientation.Left; + private Button.IconOrientation? iconRelativeOrientation; private Extents iconPadding; private Extents textPadding; @@ -113,6 +117,7 @@ namespace Tizen.NUI.Components /// 8 public ButtonStyle() : base() { + InitSubStyle(); } /// @@ -122,25 +127,32 @@ namespace Tizen.NUI.Components /// 8 public ButtonStyle(ButtonStyle style) : base(style) { - } + if(style == null) + { + return; + } + InitSubStyle(); + + this.CopyFrom(style); + } /// /// Overlay image's Style. /// /// 8 - public ImageViewStyle Overlay { get; set; } = new ImageViewStyle(); + public ImageViewStyle Overlay { get; set; } /// /// Text's Style. /// /// 8 - public TextLabelStyle Text { get; set; } = new TextLabelStyle(); + public TextLabelStyle Text { get; set; } /// /// Icon's Style. /// /// 8 - public ImageViewStyle Icon { get; set; } = new ImageViewStyle(); + public ImageViewStyle Icon { get; set; } /// /// Flag to decide Button can be selected or not. @@ -188,7 +200,11 @@ namespace Tizen.NUI.Components /// 8 public Extents IconPadding { - get => ((Extents)GetValue(IconPaddingProperty)) ?? (iconPadding = new Extents()); + get + { + Extents padding = (Extents)GetValue(IconPaddingProperty); + return (null != padding) ? padding : iconPadding = new Extents(OnIconPaddingChanged, 0, 0, 0, 0); + } set => SetValue(IconPaddingProperty, value); } @@ -198,7 +214,11 @@ namespace Tizen.NUI.Components /// 8 public Extents TextPadding { - get => ((Extents)GetValue(TextPaddingProperty)) ?? (textPadding = new Extents()); + get + { + Extents padding = (Extents)GetValue(TextPaddingProperty); + return (null != padding) ? padding : textPadding = new Extents(OnTextPaddingChanged, 0, 0, 0, 0); + } set => SetValue(TextPaddingProperty, value); } @@ -211,11 +231,24 @@ namespace Tizen.NUI.Components { base.CopyFrom(bindableObject); - if (bindableObject is ButtonStyle buttonStyle) + ButtonStyle buttonStyle = bindableObject as ButtonStyle; + + if (null != buttonStyle) { - Overlay.CopyFrom(buttonStyle.Overlay); - Text.CopyFrom(buttonStyle.Text); - Icon.CopyFrom(buttonStyle.Icon); + if (null != buttonStyle.Overlay) + { + Overlay?.CopyFrom(buttonStyle.Overlay); + } + + if (null != buttonStyle.Text) + { + Text?.CopyFrom(buttonStyle.Text); + } + + if (null != buttonStyle.Icon) + { + Icon?.CopyFrom(buttonStyle.Icon); + } } } @@ -251,5 +284,47 @@ namespace Tizen.NUI.Components base.Dispose(type); } + + private void InitSubStyle() + { + Overlay = new ImageViewStyle() + { + PositionUsesPivotPoint = true, + ParentOrigin = Tizen.NUI.ParentOrigin.Center, + PivotPoint = Tizen.NUI.PivotPoint.Center, + WidthResizePolicy = ResizePolicyType.FillToParent, + HeightResizePolicy = ResizePolicyType.FillToParent + }; + + Text = new TextLabelStyle() + { + PositionUsesPivotPoint = true, + ParentOrigin = Tizen.NUI.ParentOrigin.Center, + PivotPoint = Tizen.NUI.PivotPoint.Center, + WidthResizePolicy = ResizePolicyType.FillToParent, + HeightResizePolicy = ResizePolicyType.FillToParent, + HorizontalAlignment = HorizontalAlignment.Center, + VerticalAlignment = VerticalAlignment.Center + }; + + Icon = new ImageViewStyle() + { + PositionUsesPivotPoint = true, + ParentOrigin = Tizen.NUI.ParentOrigin.Center, + PivotPoint = Tizen.NUI.PivotPoint.Center, + }; + + IconRelativeOrientation = Button.IconOrientation.Left; + } + + private void OnIconPaddingChanged(ushort start, ushort end, ushort top, ushort bottom) + { + IconPadding = new Extents(start, end, top, bottom); + } + + private void OnTextPaddingChanged(ushort start, ushort end, ushort top, ushort bottom) + { + TextPadding = 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 44cc34e..7674a4a 100755 --- a/src/Tizen.NUI.Components/Style/ControlStyle.cs +++ b/src/Tizen.NUI.Components/Style/ControlStyle.cs @@ -47,6 +47,7 @@ namespace Tizen.NUI.Components [EditorBrowsable(EditorBrowsableState.Never)] public ControlStyle() : base() { + InitSubstyle(); } @@ -59,6 +60,9 @@ namespace Tizen.NUI.Components [EditorBrowsable(EditorBrowsableState.Never)] public ControlStyle(ControlStyle style) : base(style) { + if(null == style) return; + + this.CopyFrom(style); } /// @@ -118,6 +122,10 @@ namespace Tizen.NUI.Components disposed = true; } + private void InitSubstyle() + { + } + private void SubStyleCalledEvent(object sender, global::System.EventArgs e) { OnPropertyChanged(); diff --git a/src/Tizen.NUI.Components/Style/DropDownStyle.cs b/src/Tizen.NUI.Components/Style/DropDownStyle.cs index 92ffdff..19ac02b 100755 --- a/src/Tizen.NUI.Components/Style/DropDownStyle.cs +++ b/src/Tizen.NUI.Components/Style/DropDownStyle.cs @@ -57,7 +57,9 @@ namespace Tizen.NUI.Components [EditorBrowsable(EditorBrowsableState.Never)] public static readonly BindableProperty ListMarginProperty = BindableProperty.Create(nameof(ListMargin), typeof(Extents), typeof(DropDownStyle), null, propertyChanged: (bindable, oldValue, newValue) => { - ((DropDownStyle)bindable).listMargin = newValue == null ? null : new Extents((Extents)newValue); + var dropDownStyle = (DropDownStyle)bindable; + if (null == dropDownStyle.listMargin) dropDownStyle.listMargin = new Extents(dropDownStyle.OnListMarginChanged, 0, 0, 0, 0); + dropDownStyle.listMargin.CopyFrom(null == newValue ? new Extents() : (Extents)newValue); }, defaultValueCreator: (bindable) => { @@ -80,7 +82,12 @@ namespace Tizen.NUI.Components [EditorBrowsable(EditorBrowsableState.Never)] public static readonly BindableProperty ListPaddingProperty = BindableProperty.Create(nameof(ListPadding), typeof(Extents), typeof(DropDownStyle), null, propertyChanged: (bindable, oldValue, newValue) => { - ((DropDownStyle)bindable).listPadding = newValue == null ? null : new Extents((Extents)newValue); + var dropDownStyle = (DropDownStyle)bindable; + if (null != newValue) + { + if (null == dropDownStyle.listPadding) dropDownStyle.listPadding = new Extents(dropDownStyle.OnListPaddingChanged, 0, 0, 0, 0); + dropDownStyle.listPadding.CopyFrom(null == newValue ? new Extents() : (Extents)newValue); + } }, defaultValueCreator: (bindable) => { @@ -113,6 +120,9 @@ namespace Tizen.NUI.Components [EditorBrowsable(EditorBrowsableState.Never)] public DropDownStyle(DropDownStyle style) : base(style) { + if(null == style) return; + + this.CopyFrom(style); } /// @@ -171,7 +181,11 @@ namespace Tizen.NUI.Components [EditorBrowsable(EditorBrowsableState.Never)] public Extents ListMargin { - get => ((Extents)GetValue(ListMarginProperty)) ?? (listMargin = new Extents(0, 0, 0, 0)); + get + { + Extents tmp = (Extents)GetValue(ListMarginProperty); + return (null != tmp) ? tmp : listMargin = new Extents(OnListMarginChanged, 0, 0, 0, 0); + } set => SetValue(ListMarginProperty, value); } @@ -191,23 +205,44 @@ namespace Tizen.NUI.Components [EditorBrowsable(EditorBrowsableState.Never)] public Extents ListPadding { - get => ((Extents)GetValue(ListPaddingProperty)) ?? (listPadding = new Extents(0, 0, 0, 0)); + get + { + Extents tmp = (Extents)GetValue(ListPaddingProperty); + return (null != tmp) ? tmp : listPadding = new Extents(OnListPaddingChanged, 0, 0, 0, 0); + } set => SetValue(ListPaddingProperty, value); } - /// + /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] public override void CopyFrom(BindableObject bindableObject) { base.CopyFrom(bindableObject); - if (bindableObject is DropDownStyle dropDownStyle) + DropDownStyle dropDownStyle = bindableObject as DropDownStyle; + + if (null != dropDownStyle) { - Button.CopyFrom(dropDownStyle.Button); - HeaderText.CopyFrom(dropDownStyle.HeaderText); - ListBackgroundImage.CopyFrom(dropDownStyle.ListBackgroundImage); + Button?.CopyFrom(dropDownStyle.Button); + HeaderText?.CopyFrom(dropDownStyle.HeaderText); + ListBackgroundImage?.CopyFrom(dropDownStyle.ListBackgroundImage); + SpaceBetweenButtonTextAndIcon = dropDownStyle.SpaceBetweenButtonTextAndIcon; + ListRelativeOrientation = dropDownStyle.ListRelativeOrientation; + ListMargin?.CopyFrom(dropDownStyle.ListMargin); + SelectedItemIndex = dropDownStyle.SelectedItemIndex; + ListPadding?.CopyFrom(dropDownStyle.ListPadding); } } + + private void OnListMarginChanged(ushort start, ushort end, ushort top, ushort bottom) + { + ListMargin = new Extents(start, end, top, bottom); + } + + private void OnListPaddingChanged(ushort start, ushort end, ushort top, ushort bottom) + { + ListPadding = new Extents(start, end, top, bottom); + } } /// @@ -235,6 +270,9 @@ namespace Tizen.NUI.Components [EditorBrowsable(EditorBrowsableState.Never)] public DropDownItemStyle(DropDownItemStyle style) : base(style) { + if(null == style) return; + + this.CopyFrom(style); } /// @@ -277,17 +315,19 @@ namespace Tizen.NUI.Components [EditorBrowsable(EditorBrowsableState.Never)] public bool IsSelected { get; set; } - /// + /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] public override void CopyFrom(BindableObject bindableObject) { base.CopyFrom(bindableObject); - if (bindableObject is DropDownItemStyle dropDownItemStyle) + DropDownItemStyle dropDownItemStyle = bindableObject as DropDownItemStyle; + + if (null != dropDownItemStyle) { - Text.CopyFrom(dropDownItemStyle.Text); - Icon.CopyFrom(dropDownItemStyle.Icon); - CheckImage.CopyFrom(dropDownItemStyle.CheckImage); + Text?.CopyFrom(dropDownItemStyle.Text); + Icon?.CopyFrom(dropDownItemStyle.Icon); + CheckImage?.CopyFrom(dropDownItemStyle.CheckImage); CheckImageGapToBoundary = dropDownItemStyle.CheckImageGapToBoundary; IsSelected = dropDownItemStyle.IsSelected; } diff --git a/src/Tizen.NUI.Components/Style/LoadingStyle.cs b/src/Tizen.NUI.Components/Style/LoadingStyle.cs index e6ce60b..08f757c 100755 --- a/src/Tizen.NUI.Components/Style/LoadingStyle.cs +++ b/src/Tizen.NUI.Components/Style/LoadingStyle.cs @@ -26,43 +26,6 @@ namespace Tizen.NUI.Components /// 8 public class LoadingStyle : ControlStyle { - /// The FrameRateSelector bindable property. - [EditorBrowsable(EditorBrowsableState.Never)] - public static readonly BindableProperty FrameRateSelectorProperty = BindableProperty.Create("FrameRateSelector", typeof(Selector), typeof(LoadingStyle), null, propertyChanged: (bindable, oldValue, newValue) => - { - ((LoadingStyle)bindable).frameRate = ((Selector)newValue)?.Clone(); - }, - defaultValueCreator: (bindable) => - { - return ((LoadingStyle)bindable).frameRate; - }); - - /// The LoadingSize bindable property. - [EditorBrowsable(EditorBrowsableState.Never)] - public static readonly BindableProperty LoadingSizeProperty = BindableProperty.Create(nameof(LoadingSize), typeof(Size), typeof(LoadingStyle), null, propertyChanged: (bindable, oldValue, newValue) => - { - ((LoadingStyle)bindable).loadingSize = newValue == null ? null : new Size((Size)newValue); - }, - defaultValueCreator: (bindable) => - { - return ((LoadingStyle)bindable).loadingSize; - }); - - /// The Images bindable property. - [EditorBrowsable(EditorBrowsableState.Never)] - public static readonly BindableProperty ImagesProperty = BindableProperty.Create(nameof(Images), typeof(string[]), typeof(LoadingStyle), null, propertyChanged: (bindable, oldValue, newValue) => - { - ((LoadingStyle)bindable).images = (string[])((string[])newValue)?.Clone(); - }, - defaultValueCreator: (bindable) => - { - return ((LoadingStyle)bindable).images; - }); - - private Selector frameRate; - private Size loadingSize; - private string[] images; - static LoadingStyle() { } /// @@ -78,37 +41,30 @@ namespace Tizen.NUI.Components /// 8 public LoadingStyle(LoadingStyle style) : base(style) { + if(null == style) + { + return; + } + this.CopyFrom(style); } /// /// Gets or sets loading image resources. /// /// 8 - public string[] Images - { - get => (string[])GetValue(ImagesProperty); - set => SetValue(ImagesProperty, value); - } + public string[] Images { get; set; } /// /// Gets or sets loading image size. /// /// 8 - public Size LoadingSize - { - get => (Size)GetValue(LoadingSizeProperty); - set => SetValue(LoadingSizeProperty, value); - } + public Size LoadingSize { get; set; } /// /// Gets or sets loading frame per second. /// /// 8 - public Selector FrameRate - { - get => (Selector)GetValue(FrameRateSelectorProperty); - set => SetValue(FrameRateSelectorProperty, value); - } + public Selector FrameRate { get; set; } = new Selector(); /// /// Style's clone function. @@ -118,6 +74,24 @@ namespace Tizen.NUI.Components public override void CopyFrom(BindableObject bindableObject) { base.CopyFrom(bindableObject); + + LoadingStyle loadingStyle = bindableObject as LoadingStyle; + + if (null != loadingStyle) + { + if (null != loadingStyle.FrameRate) + { + FrameRate?.Clone(loadingStyle.FrameRate); + } + if (null != loadingStyle.LoadingSize) + { + LoadingSize = loadingStyle.LoadingSize; + } + if (null != loadingStyle.Images) + { + Images = loadingStyle.Images; + } + } } } } diff --git a/src/Tizen.NUI.Components/Style/PaginationStyle.cs b/src/Tizen.NUI.Components/Style/PaginationStyle.cs index 403daab..e081291 100755 --- a/src/Tizen.NUI.Components/Style/PaginationStyle.cs +++ b/src/Tizen.NUI.Components/Style/PaginationStyle.cs @@ -26,43 +26,6 @@ namespace Tizen.NUI.Components /// 8 public class PaginationStyle : ControlStyle { - /// The IndicatorSize bindable property. - [EditorBrowsable(EditorBrowsableState.Never)] - public static readonly BindableProperty IndicatorSizeProperty = BindableProperty.Create(nameof(IndicatorSize), typeof(Size), typeof(PaginationStyle), null, propertyChanged: (bindable, oldValue, newValue) => - { - ((PaginationStyle)bindable).indicatorSize = newValue == null ? null : new Size((Size)newValue); - }, - defaultValueCreator: (bindable) => - { - return ((PaginationStyle)bindable).indicatorSize; - }); - - /// The IndicatorImageUrlSelector bindable property. - [EditorBrowsable(EditorBrowsableState.Never)] - public static readonly BindableProperty IndicatorImageUrlSelectorProperty = BindableProperty.Create("IndicatorImageUrlSelector", typeof(Selector), typeof(PaginationStyle), null, propertyChanged: (bindable, oldValue, newValue) => - { - ((PaginationStyle)bindable).indicatorImageUrl = ((Selector)newValue)?.Clone(); - }, - defaultValueCreator: (bindable) => - { - return ((PaginationStyle)bindable).indicatorImageUrl; - }); - - /// The IndicatorSpacing bindable property. - [EditorBrowsable(EditorBrowsableState.Never)] - public static readonly BindableProperty IndicatorSpacingProperty = BindableProperty.Create(nameof(IndicatorSpacing), typeof(int?), typeof(PaginationStyle), null, propertyChanged: (bindable, oldValue, newValue) => - { - ((PaginationStyle)bindable).indicatorSpacing = (int?)newValue; - }, - defaultValueCreator: (bindable) => - { - return ((PaginationStyle)bindable).indicatorSpacing; - }); - - private Size indicatorSize; - private Selector indicatorImageUrl; - private int? indicatorSpacing; - static PaginationStyle() { } /// @@ -78,37 +41,28 @@ namespace Tizen.NUI.Components /// 8 public PaginationStyle(PaginationStyle style) : base(style) { + if (null == style) return; + + this.CopyFrom(style); } /// /// Gets or sets the size of the indicator. /// /// 8 - public Size IndicatorSize - { - get => (Size)GetValue(IndicatorSizeProperty); - set => SetValue(IndicatorSizeProperty, value); - } + public Size IndicatorSize { get; set; } /// /// Gets or sets the resource of indicator. /// /// 8 - public Selector IndicatorImageUrl - { - get => (Selector)GetValue(IndicatorImageUrlSelectorProperty); - set => SetValue(IndicatorImageUrlSelectorProperty, value); - } + public Selector IndicatorImageUrl { get; set; } = new Selector(); /// /// Gets or sets the space of the indicator. /// /// 8 - public int IndicatorSpacing - { - get => ((int?)GetValue(IndicatorSpacingProperty)) ?? 0; - set => SetValue(IndicatorSpacingProperty, value); - } + public int IndicatorSpacing { get; set; } /// /// Retrieves a copy of PaginationStyle. @@ -118,6 +72,20 @@ namespace Tizen.NUI.Components public override void CopyFrom(BindableObject bindableObject) { base.CopyFrom(bindableObject); + + PaginationStyle paginationStyle = bindableObject as PaginationStyle; + if (null != paginationStyle) + { + if (null != paginationStyle.IndicatorSize) + { + IndicatorSize = new Size(paginationStyle.IndicatorSize.Width, paginationStyle.IndicatorSize.Height); + } + if (null != paginationStyle.IndicatorImageUrl) + { + IndicatorImageUrl?.Clone(paginationStyle.IndicatorImageUrl); + } + IndicatorSpacing = paginationStyle.IndicatorSpacing; + } } } } diff --git a/src/Tizen.NUI.Components/Style/PopupStyle.cs b/src/Tizen.NUI.Components/Style/PopupStyle.cs index acf3a0e..fe4f36a 100755 --- a/src/Tizen.NUI.Components/Style/PopupStyle.cs +++ b/src/Tizen.NUI.Components/Style/PopupStyle.cs @@ -34,6 +34,7 @@ namespace Tizen.NUI.Components [EditorBrowsable(EditorBrowsableState.Never)] public PopupStyle() : base() { + InitSubStyle(); } /// @@ -43,31 +44,91 @@ namespace Tizen.NUI.Components [EditorBrowsable(EditorBrowsableState.Never)] public PopupStyle(PopupStyle style) : base(style) { + Title = new TextLabelStyle(); + Buttons = new ButtonStyle(); + this.CopyFrom(style); } /// /// Title Text's style. /// [EditorBrowsable(EditorBrowsableState.Never)] - public TextLabelStyle Title { get; set; } = new TextLabelStyle(); + public TextLabelStyle Title { get; set; } /// /// Popup button's style. /// [EditorBrowsable(EditorBrowsableState.Never)] - public ButtonStyle Buttons { get; set; } = new ButtonStyle(); + public ButtonStyle Buttons { get; set; } - /// + /// + /// Style's clone function. + /// + /// The style that need to copy. [EditorBrowsable(EditorBrowsableState.Never)] public override void CopyFrom(BindableObject bindableObject) { base.CopyFrom(bindableObject); - if (bindableObject is PopupStyle popupStyle) + PopupStyle popupStyle = bindableObject as PopupStyle; + if (popupStyle != null) { - Title.CopyFrom(popupStyle.Title); - Buttons.CopyFrom(popupStyle.Buttons); + if (popupStyle.Title != null) + { + Title?.CopyFrom(popupStyle.Title); + } + + if (popupStyle.Buttons != null) + { + Buttons?.CopyFrom(popupStyle.Buttons); + } } } + + private void InitSubStyle() + { + // TODO Apply proper shadow as a default for a Popup + BoxShadow = new Shadow() + { + BlurRadius = 5, + Offset = new Vector2(5, 5), + }; + + Title = new TextLabelStyle() + { + PositionUsesPivotPoint = true, + ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft, + PivotPoint = Tizen.NUI.PivotPoint.TopLeft, + HorizontalAlignment = HorizontalAlignment.Begin, + VerticalAlignment = VerticalAlignment.Bottom + }; + + Buttons = new ButtonStyle() + { + Size = new Size(0, 0), + PositionUsesPivotPoint = true, + ParentOrigin = Tizen.NUI.ParentOrigin.BottomLeft, + PivotPoint = Tizen.NUI.PivotPoint.BottomLeft, + Overlay = new ImageViewStyle() + { + PositionUsesPivotPoint = true, + ParentOrigin = Tizen.NUI.ParentOrigin.Center, + PivotPoint = Tizen.NUI.PivotPoint.Center, + WidthResizePolicy = ResizePolicyType.FillToParent, + HeightResizePolicy = ResizePolicyType.FillToParent + }, + + Text = new TextLabelStyle() + { + PositionUsesPivotPoint = true, + ParentOrigin = Tizen.NUI.ParentOrigin.Center, + PivotPoint = Tizen.NUI.PivotPoint.Center, + WidthResizePolicy = ResizePolicyType.FillToParent, + HeightResizePolicy = ResizePolicyType.FillToParent, + HorizontalAlignment = HorizontalAlignment.Center, + VerticalAlignment = VerticalAlignment.Center + } + }; + } } } diff --git a/src/Tizen.NUI.Components/Style/ProgressStyle.cs b/src/Tizen.NUI.Components/Style/ProgressStyle.cs index f2d6b3f..0731b7e 100755 --- a/src/Tizen.NUI.Components/Style/ProgressStyle.cs +++ b/src/Tizen.NUI.Components/Style/ProgressStyle.cs @@ -34,6 +34,7 @@ namespace Tizen.NUI.Components /// 8 public ProgressStyle() : base() { + InitSubStyle(); } /// @@ -43,25 +44,30 @@ namespace Tizen.NUI.Components /// 8 public ProgressStyle(ProgressStyle style) : base(style) { + if (null == style) return; + + InitSubStyle(); + + this.CopyFrom(style); } /// /// Get or set track image. /// /// 8 - public ImageViewStyle Track { get; set; } = new ImageViewStyle(); + public ImageViewStyle Track { get; set; } /// /// Get or set progress image. /// /// 8 - public ImageViewStyle Progress { get; set; } = new ImageViewStyle(); + public ImageViewStyle Progress { get; set; } /// /// Get or set buffer image. /// /// 8 - public ImageViewStyle Buffer { get; set; } = new ImageViewStyle(); + public ImageViewStyle Buffer { get; set; } /// /// Style's clone function. @@ -72,12 +78,55 @@ namespace Tizen.NUI.Components { base.CopyFrom(bindableObject); - if (bindableObject is ProgressStyle progressStyle) + ProgressStyle progressStyle = bindableObject as ProgressStyle; + + if (null != progressStyle) { - Track.CopyFrom(progressStyle.Track); - Progress.CopyFrom(progressStyle.Progress); - Buffer.CopyFrom(progressStyle.Buffer); + if (null != progressStyle.Track) + { + Track?.CopyFrom(progressStyle.Track); + } + + if (null != progressStyle.Progress) + { + Progress?.CopyFrom(progressStyle.Progress); + } + + if (null != progressStyle.Buffer) + { + Buffer?.CopyFrom(progressStyle.Buffer); + } } } + + private void InitSubStyle() + { + Track = new ImageViewStyle() + { + WidthResizePolicy = ResizePolicyType.FillToParent, + HeightResizePolicy = ResizePolicyType.FillToParent, + PositionUsesPivotPoint = true, + ParentOrigin = NUI.ParentOrigin.TopLeft, + PivotPoint = NUI.PivotPoint.TopLeft + }; + + Progress = new ImageViewStyle() + { + WidthResizePolicy = ResizePolicyType.FillToParent, + HeightResizePolicy = ResizePolicyType.FillToParent, + PositionUsesPivotPoint = true, + ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft, + PivotPoint = Tizen.NUI.PivotPoint.TopLeft + }; + + Buffer = new ImageViewStyle() + { + WidthResizePolicy = ResizePolicyType.FillToParent, + HeightResizePolicy = ResizePolicyType.FillToParent, + PositionUsesPivotPoint = true, + ParentOrigin = Tizen.NUI.ParentOrigin.TopLeft, + PivotPoint = Tizen.NUI.PivotPoint.TopLeft + }; + } } } diff --git a/src/Tizen.NUI.Components/Style/ScrollbarStyle.cs b/src/Tizen.NUI.Components/Style/ScrollbarStyle.cs index 0e04010..1aea6d3 100644 --- a/src/Tizen.NUI.Components/Style/ScrollbarStyle.cs +++ b/src/Tizen.NUI.Components/Style/ScrollbarStyle.cs @@ -54,7 +54,7 @@ namespace Tizen.NUI.Components [EditorBrowsable(EditorBrowsableState.Never)] public static readonly BindableProperty TrackColorProperty = BindableProperty.Create(nameof(TrackColor), typeof(Color), typeof(ScrollbarStyle), null, propertyChanged: (bindable, oldValue, newValue) => { - ((ScrollbarStyle)bindable).trackColor = new Color((Color)newValue); + ((ScrollbarStyle)bindable).trackColor = (Color)newValue; }, defaultValueCreator: (bindable) => { @@ -65,7 +65,7 @@ namespace Tizen.NUI.Components [EditorBrowsable(EditorBrowsableState.Never)] public static readonly BindableProperty ThumbColorProperty = BindableProperty.Create(nameof(ThumbColor), typeof(Color), typeof(ScrollbarStyle), null, propertyChanged: (bindable, oldValue, newValue) => { - ((ScrollbarStyle)bindable).thumbColor = new Color((Color)newValue); + ((ScrollbarStyle)bindable).thumbColor = (Color)newValue; }, defaultValueCreator: (bindable) => { @@ -76,7 +76,7 @@ namespace Tizen.NUI.Components [EditorBrowsable(EditorBrowsableState.Never)] public static readonly BindableProperty TrackPaddingProperty = BindableProperty.Create(nameof(TrackPadding), typeof(Extents), typeof(ScrollbarStyle), null, propertyChanged: (bindable, oldValue, newValue) => { - ((ScrollbarStyle)bindable).trackPadding = new Extents((Extents)newValue); + ((ScrollbarStyle)bindable).trackPadding = (Extents)newValue; }, defaultValueCreator: (bindable) => { @@ -100,6 +100,7 @@ namespace Tizen.NUI.Components [EditorBrowsable(EditorBrowsableState.Never)] public ScrollbarStyle() : base() { + Initialize(); } /// @@ -109,6 +110,7 @@ namespace Tizen.NUI.Components [EditorBrowsable(EditorBrowsableState.Never)] public ScrollbarStyle(ScrollbarStyle style) : base(style) { + this.CopyFrom(style); } /// @@ -174,5 +176,39 @@ namespace Tizen.NUI.Components } #endregion Properties + + + #region Methods + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override void CopyFrom(BindableObject bindableObject) + { + base.CopyFrom(bindableObject); + + var style = bindableObject as ScrollbarStyle; + + if (null != style) + { + TrackThickness = style.TrackThickness; + ThumbThickness = style.ThumbThickness; + TrackColor = style.TrackColor; + ThumbColor = style.ThumbColor; + TrackPadding = style.TrackPadding; + } + } + + private void Initialize() + { + TrackThickness = 6.0f; + ThumbThickness = 6.0f; + TrackColor = new Color(1.0f, 1.0f, 1.0f, 0.15f); + ThumbColor = new Color(0.6f, 0.6f, 0.6f, 1.0f); + TrackPadding = 4; + WidthResizePolicy = ResizePolicyType.FillToParent; + HeightResizePolicy = ResizePolicyType.FillToParent; + } + + #endregion Methods } } diff --git a/src/Tizen.NUI.Components/Style/SliderStyle.cs b/src/Tizen.NUI.Components/Style/SliderStyle.cs index c97f84a..d7c578f 100755 --- a/src/Tizen.NUI.Components/Style/SliderStyle.cs +++ b/src/Tizen.NUI.Components/Style/SliderStyle.cs @@ -76,7 +76,12 @@ namespace Tizen.NUI.Components [EditorBrowsable(EditorBrowsableState.Never)] public static readonly BindableProperty TrackPaddingProperty = BindableProperty.Create(nameof(TrackPadding), typeof(Extents), typeof(SliderStyle), null, propertyChanged: (bindable, oldValue, newValue) => { - ((SliderStyle)bindable).trackPadding = newValue == null ? null : new Extents((Extents)newValue); + var instance = (SliderStyle)bindable; + if (newValue != null) + { + if (null == instance.trackPadding) instance.trackPadding = new Extents(instance.OnTrackPaddingChanged, 0, 0, 0, 0); + instance.trackPadding.CopyFrom(null == newValue ? new Extents() : (Extents)newValue); + } }, defaultValueCreator: (bindable) => { @@ -84,7 +89,7 @@ namespace Tizen.NUI.Components return instance.trackPadding; }); - private IndicatorType? privateIndicatorType = Slider.IndicatorType.None; + private IndicatorType? privateIndicatorType; private uint? privateTrackThickness; private uint? privateSpaceBetweenTrackAndIndicator; private Extents trackPadding; @@ -97,6 +102,8 @@ namespace Tizen.NUI.Components /// 8 public SliderStyle() : base() { + IndicatorType = Slider.IndicatorType.None; + InitSubStyle(); } /// @@ -106,49 +113,59 @@ namespace Tizen.NUI.Components /// 8 public SliderStyle(SliderStyle style) : base(style) { + if(style == null) + { + return; + } + + InitSubStyle(); + + this.CopyFrom(style); + + IndicatorType = style.IndicatorType; } /// /// Get or set background track. /// /// 8 - public ImageViewStyle Track { get; set; } = new ImageViewStyle(); + public ImageViewStyle Track { get; set; } /// /// Get or set slided track. /// /// 8 - public ImageViewStyle Progress { get; set; } = new ImageViewStyle(); + public ImageViewStyle Progress { get; set; } /// /// Get or set thumb. /// /// 8 - public ImageViewStyle Thumb { get; set; } = new ImageViewStyle(); + public ImageViewStyle Thumb { get; set; } /// /// Get or set low indicator image. /// /// 8 - public ImageViewStyle LowIndicatorImage { get; set; } = new ImageViewStyle(); + public ImageViewStyle LowIndicatorImage { get; set; } /// /// Get or set high indicator image. /// /// 8 - public ImageViewStyle HighIndicatorImage { get; set; } = new ImageViewStyle(); + public ImageViewStyle HighIndicatorImage { get; set; } /// /// Get or set low indicator text. /// /// 8 - public TextLabelStyle LowIndicator { get; set; } = new TextLabelStyle(); + public TextLabelStyle LowIndicator { get; set; } /// /// Get or set high indicator text. /// /// 8 - public TextLabelStyle HighIndicator { get; set; } = new TextLabelStyle(); + public TextLabelStyle HighIndicator { get; set; } /// /// Get or set Indicator type @@ -186,7 +203,11 @@ namespace Tizen.NUI.Components /// 8 public Extents TrackPadding { - get => ((Extents)GetValue(TrackPaddingProperty)) ?? (trackPadding = new Extents(0, 0, 0, 0)); + get + { + Extents tmp = (Extents)GetValue(TrackPaddingProperty); + return (null != tmp) ? tmp : trackPadding = new Extents(OnTrackPaddingChanged, 0, 0, 0, 0); + } set => SetValue(TrackPaddingProperty, value); } @@ -199,15 +220,54 @@ namespace Tizen.NUI.Components { base.CopyFrom(bindableObject); - if (bindableObject is SliderStyle sliderStyle) + SliderStyle sliderStyle = bindableObject as SliderStyle; + + if (null != sliderStyle) { - Track.CopyFrom(sliderStyle.Track); - Progress.CopyFrom(sliderStyle.Progress); - Thumb.CopyFrom(sliderStyle.Thumb); - LowIndicatorImage.CopyFrom(sliderStyle.LowIndicatorImage); - HighIndicatorImage.CopyFrom(sliderStyle.HighIndicatorImage); - LowIndicator.CopyFrom(sliderStyle.LowIndicator); - HighIndicator.CopyFrom(sliderStyle.HighIndicator); + if (sliderStyle.Track != null) + { + Track?.CopyFrom(sliderStyle.Track); + } + + if (sliderStyle.Progress != null) + { + Progress?.CopyFrom(sliderStyle.Progress); + } + + if (sliderStyle.Thumb != null) + { + Thumb?.CopyFrom(sliderStyle.Thumb); + } + + if (sliderStyle.LowIndicatorImage != null) + { + LowIndicatorImage?.CopyFrom(sliderStyle.LowIndicatorImage); + } + + if (sliderStyle.HighIndicatorImage != null) + { + HighIndicatorImage?.CopyFrom(sliderStyle.HighIndicatorImage); + } + + if (sliderStyle.LowIndicator != null) + { + LowIndicator?.CopyFrom(sliderStyle.LowIndicator); + } + + if (sliderStyle.HighIndicator != null) + { + HighIndicator?.CopyFrom(sliderStyle.HighIndicator); + } + + if (sliderStyle.TrackThickness != null) + { + TrackThickness = sliderStyle.TrackThickness; + } + + if (sliderStyle.TrackPadding != null) + { + TrackPadding = sliderStyle.TrackPadding; + } } } @@ -230,5 +290,21 @@ namespace Tizen.NUI.Components base.Dispose(type); } + + private void InitSubStyle() + { + Track = new ImageViewStyle(); + Progress = new ImageViewStyle(); + Thumb = new ImageViewStyle(); + LowIndicatorImage = new ImageViewStyle(); + HighIndicatorImage = new ImageViewStyle(); + LowIndicator = new TextLabelStyle(); + HighIndicator = new TextLabelStyle(); + } + + private void OnTrackPaddingChanged(ushort start, ushort end, ushort top, ushort bottom) + { + TrackPadding = new Extents(start, end, top, bottom); + } } } diff --git a/src/Tizen.NUI.Components/Style/SwitchStyle.cs b/src/Tizen.NUI.Components/Style/SwitchStyle.cs index 3039b99..f3dc359 100755 --- a/src/Tizen.NUI.Components/Style/SwitchStyle.cs +++ b/src/Tizen.NUI.Components/Style/SwitchStyle.cs @@ -35,6 +35,7 @@ namespace Tizen.NUI.Components /// 8 public SwitchStyle() : base() { + InitSubStyle(); } /// @@ -44,19 +45,29 @@ namespace Tizen.NUI.Components /// 8 public SwitchStyle(SwitchStyle style) : base(style) { + if(null == style) + { + return; + } + + IsSelectable = true; + Track = new ImageViewStyle(); + Thumb = new ImageViewStyle(); + + this.CopyFrom(style); } /// /// Thumb image's style. /// /// 8 - public ImageViewStyle Thumb { get; set; } = new ImageViewStyle(); + public ImageViewStyle Thumb { get; set; } /// /// Track image's style. /// /// 8 - public ImageViewStyle Track { get; set; } = new ImageViewStyle(); + public ImageViewStyle Track { get; set; } /// /// Style's clone function. @@ -67,10 +78,19 @@ namespace Tizen.NUI.Components { base.CopyFrom(bindableObject); - if (bindableObject is SwitchStyle switchStyle) + SwitchStyle switchStyle = bindableObject as SwitchStyle; + + if (null != switchStyle) { - Track.CopyFrom(switchStyle.Track); - Thumb.CopyFrom(switchStyle.Thumb); + if (null != switchStyle.Track) + { + Track?.CopyFrom(switchStyle.Track); + } + + if (null != switchStyle.Thumb) + { + Thumb?.CopyFrom(switchStyle.Thumb); + } } } @@ -80,5 +100,27 @@ namespace Tizen.NUI.Components { return new SlidingSwitchExtension(); } + + private void InitSubStyle() + { + IsSelectable = true; + Track = new ImageViewStyle() + { + PositionUsesPivotPoint = true, + ParentOrigin = Tizen.NUI.ParentOrigin.CenterLeft, + PivotPoint = Tizen.NUI.PivotPoint.CenterLeft, + WidthResizePolicy = ResizePolicyType.FillToParent, + HeightResizePolicy = ResizePolicyType.FillToParent + }; + + Thumb = new ImageViewStyle() + { + PositionUsesPivotPoint = true, + ParentOrigin = Tizen.NUI.ParentOrigin.CenterLeft, + PivotPoint = Tizen.NUI.PivotPoint.CenterLeft, + WidthResizePolicy = ResizePolicyType.Fixed, + HeightResizePolicy = ResizePolicyType.Fixed + }; + } } } diff --git a/src/Tizen.NUI.Components/Style/TabStyle.cs b/src/Tizen.NUI.Components/Style/TabStyle.cs index f3d2f10..d07ce37 100755 --- a/src/Tizen.NUI.Components/Style/TabStyle.cs +++ b/src/Tizen.NUI.Components/Style/TabStyle.cs @@ -37,6 +37,9 @@ namespace Tizen.NUI.Components ItemPadding = new Extents(0, 0, 0, 0); UseTextNaturalSize = false; ItemSpace = 0; + + UnderLine = new ViewStyle(); + Text = new TextLabelStyle(); } /// @@ -46,19 +49,47 @@ namespace Tizen.NUI.Components [EditorBrowsable(EditorBrowsableState.Never)] public TabStyle(TabStyle style) : base(style) { + UnderLine = new ViewStyle(); + Text = new TextLabelStyle(); + + if (null == style) + { + return; + } + + if (style.UnderLine != null) + { + UnderLine?.CopyFrom(style.UnderLine); + } + + if (style.Text != null) + { + Text?.CopyFrom(style.Text); + } + + if (style.ItemPadding != null) + { + ItemPadding = new Extents(style.ItemPadding.Start, style.ItemPadding.End, style.ItemPadding.Top, style.ItemPadding.Bottom); + } + else + { + ItemPadding = new Extents(0, 0, 0, 0); + } + ItemSpace = style.ItemSpace; + UseTextNaturalSize = style.UseTextNaturalSize; } /// /// UnderLine's style. /// [EditorBrowsable(EditorBrowsableState.Never)] - public ViewStyle UnderLine { get; set; } = new ViewStyle(); + public ViewStyle UnderLine { get; set; } /// /// Text's style. /// [EditorBrowsable(EditorBrowsableState.Never)] - public TextLabelStyle Text { get; set; } = new TextLabelStyle(); + public TextLabelStyle Text { get; set; } /// /// Flag to decide if item is fill with item text's natural width. @@ -78,19 +109,35 @@ namespace Tizen.NUI.Components [EditorBrowsable(EditorBrowsableState.Never)] public Extents ItemPadding { get; set; } - /// + /// + /// Style's clone function. + /// + /// The style that need to copy. [EditorBrowsable(EditorBrowsableState.Never)] public override void CopyFrom(BindableObject bindableObject) { base.CopyFrom(bindableObject); + TabStyle tabStyle = bindableObject as TabStyle; - if (bindableObject is TabStyle tabStyle) + if (null != tabStyle) { - UnderLine.CopyFrom(tabStyle.UnderLine); - Text.CopyFrom(tabStyle.Text); - ItemPadding = tabStyle.ItemPadding == null ? null : new Extents(tabStyle.ItemPadding); + if (null != tabStyle.ItemPadding) + { + ItemPadding?.CopyFrom(tabStyle.ItemPadding); + } + ItemSpace = tabStyle.ItemSpace; UseTextNaturalSize = tabStyle.UseTextNaturalSize; + + if (null != tabStyle.UnderLine) + { + UnderLine?.CopyFrom(tabStyle.UnderLine); + } + + if (null != tabStyle.Text) + { + Text?.CopyFrom(tabStyle.Text); + } } } } diff --git a/src/Tizen.NUI.Components/Style/Theme.cs b/src/Tizen.NUI.Components/Style/Theme.cs new file mode 100755 index 0000000..9e171cb --- /dev/null +++ b/src/Tizen.NUI.Components/Style/Theme.cs @@ -0,0 +1,88 @@ +/* + * 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; +using System.Collections.Generic; +using System.ComponentModel; +using Tizen.NUI.BaseComponents; + +namespace Tizen.NUI.Components +{ + /// + /// Interface that includes styles for all components for a theme + /// + [EditorBrowsable(EditorBrowsableState.Never)] + internal abstract class Theme + { + private Dictionary styleMap; + + protected Theme() + { + styleMap = new Dictionary(); + styleMap.Add(typeof(Button), GetButtonStyle); + styleMap.Add(typeof(CheckBox), GetCheckBoxStyle); + styleMap.Add(typeof(DropDown), GetDropDownStyle); + styleMap.Add(typeof(DropDown.DropDownDataItem), GetDropDownItemStyle); + styleMap.Add(typeof(Popup), GetPopupStyle); + styleMap.Add(typeof(Progress), GetProgressStyle); + styleMap.Add(typeof(RadioButton), GetRadioButtonStyle); + styleMap.Add(typeof(Slider), GetSliderStyle); + styleMap.Add(typeof(Switch), GetSwitchStyle); + styleMap.Add(typeof(Tab), GetTabStyle); + styleMap.Add(typeof(Toast), GetToastStyle); + styleMap.Add(typeof(Loading), GetLoadingStyle); + styleMap.Add(typeof(Pagination), GetPaginationStyle); + } + + internal delegate ViewStyle ComponentStyleGetter(); + + internal ViewStyle GetComponentStyle(Type type) + { + return styleMap.ContainsKey(type) ? styleMap[type]() : null; + } + + internal void OverwriteComponentStyle(Type type, ComponentStyleGetter styleGetter) + { + styleMap.Add(typeof(Toast), GetToastStyle); + } + + protected abstract ButtonStyle GetButtonStyle(); + + protected abstract ButtonStyle GetCheckBoxStyle(); + + protected abstract DropDownStyle GetDropDownStyle(); + + protected abstract DropDownItemStyle GetDropDownItemStyle(); + + protected abstract PopupStyle GetPopupStyle(); + + protected abstract ProgressStyle GetProgressStyle(); + + protected abstract ButtonStyle GetRadioButtonStyle(); + + protected abstract SliderStyle GetSliderStyle(); + + protected abstract SwitchStyle GetSwitchStyle(); + + protected abstract TabStyle GetTabStyle(); + + protected abstract ToastStyle GetToastStyle(); + + protected abstract LoadingStyle GetLoadingStyle(); + + protected abstract PaginationStyle GetPaginationStyle(); + } +} diff --git a/src/Tizen.NUI.Components/Style/ToastStyle.cs b/src/Tizen.NUI.Components/Style/ToastStyle.cs index 18d798d..94ddbe3 100755 --- a/src/Tizen.NUI.Components/Style/ToastStyle.cs +++ b/src/Tizen.NUI.Components/Style/ToastStyle.cs @@ -26,19 +26,6 @@ namespace Tizen.NUI.Components [EditorBrowsable(EditorBrowsableState.Never)] public class ToastStyle : ControlStyle { - /// The Duration bindable property. - [EditorBrowsable(EditorBrowsableState.Never)] - public static readonly BindableProperty DurationProperty = BindableProperty.Create(nameof(Duration), typeof(uint?), typeof(ToastStyle), null, propertyChanged: (bindable, oldValue, newValue) => - { - ((ToastStyle)bindable).duration = (uint?)newValue; - }, - defaultValueCreator: (bindable) => - { - return ((ToastStyle)bindable).duration; - }); - - private uint? duration; - static ToastStyle() { } /// @@ -47,6 +34,7 @@ namespace Tizen.NUI.Components [EditorBrowsable(EditorBrowsableState.Never)] public ToastStyle() : base() { + InitSubStyle(); } /// @@ -56,34 +44,54 @@ namespace Tizen.NUI.Components [EditorBrowsable(EditorBrowsableState.Never)] public ToastStyle(ToastStyle style) : base(style) { + InitSubStyle(); + this.CopyFrom(style); } /// /// Gets or sets toast show duration time. /// [EditorBrowsable(EditorBrowsableState.Never)] - public uint? Duration - { - get => (uint?)GetValue(DurationProperty); - set => SetValue(DurationProperty, value); - } + public uint? Duration { get; set; } /// /// Text's Style. /// [EditorBrowsable(EditorBrowsableState.Never)] - public TextLabelStyle Text { get; set; } = new TextLabelStyle(); + public TextLabelStyle Text { get; set; } - /// + /// + /// Style's clone function. + /// + /// The style that need to copy. [EditorBrowsable(EditorBrowsableState.Never)] public override void CopyFrom(BindableObject bindableObject) { base.CopyFrom(bindableObject); - - if (bindableObject is ToastStyle toastStyle) + ToastStyle toastStyle = bindableObject as ToastStyle; + if (toastStyle != null) { - Text.CopyFrom(toastStyle.Text); + if (null != toastStyle.Text) + { + Text?.CopyFrom(toastStyle.Text); + } + Duration = toastStyle.Duration; } } + + private void InitSubStyle() + { + Text = new TextLabelStyle() + { + PositionUsesPivotPoint = true, + ParentOrigin = Tizen.NUI.ParentOrigin.Center, + PivotPoint = Tizen.NUI.PivotPoint.Center, + WidthResizePolicy = ResizePolicyType.UseNaturalSize, + HeightResizePolicy = ResizePolicyType.UseNaturalSize, + HorizontalAlignment = HorizontalAlignment.Center, + VerticalAlignment = VerticalAlignment.Center, + TextColor = Tizen.NUI.Color.White, + }; + } } } diff --git a/src/Tizen.NUI.Components/Tizen.NUI.Components.csproj b/src/Tizen.NUI.Components/Tizen.NUI.Components.csproj index 2d4e029..616af37 100755 --- a/src/Tizen.NUI.Components/Tizen.NUI.Components.csproj +++ b/src/Tizen.NUI.Components/Tizen.NUI.Components.csproj @@ -11,7 +11,7 @@ - + PreserveNewest diff --git a/src/Tizen.NUI.Components/Utils/StyleManager.cs b/src/Tizen.NUI.Components/Utils/StyleManager.cs index 5a6887d..388e765 100755 --- a/src/Tizen.NUI.Components/Utils/StyleManager.cs +++ b/src/Tizen.NUI.Components/Utils/StyleManager.cs @@ -27,19 +27,53 @@ namespace Tizen.NUI.Components [EditorBrowsable(EditorBrowsableState.Never)] public sealed class StyleManager { + internal const float PointSizeNormal = 12; + internal const float PointSizeTitle = 16; + + private const string defaultThemeName = "DEFAULT"; //"default"; + private const string wearableThemeName = "WEARABLE"; //"wearable"; + + private string currentThemeName = defaultThemeName; + private Dictionary> themeStyleSet = new Dictionary>(); + private Dictionary defaultStyleSet = new Dictionary(); + + /// + /// (Theme name, Theme instance) + /// + private Dictionary> componentStyleByTheme = new Dictionary>(); + + /// + /// (Theme name, Theme instance) + /// + private Dictionary themeMap = new Dictionary(); + + private EventHandler themeChangeHandler; + + private Theme currentTheme; + /// /// StyleManager construct. /// private StyleManager() { - ThemeManager.ThemeChanged += OnThemeChanged; + SetInitialThemeByDeviceProfile(); } /// /// An event for the theme changed signal which can be used to subscribe or unsubscribe the event handler provided by the user.
///
[EditorBrowsable(EditorBrowsableState.Never)] - public event EventHandler ThemeChangedEvent; + public event EventHandler ThemeChangedEvent + { + add + { + themeChangeHandler += value; + } + remove + { + themeChangeHandler -= value; + } + } /// /// StyleManager static instance. @@ -55,38 +89,26 @@ namespace Tizen.NUI.Components { get { - return ThemeManager.CurrentTheme?.Id; + return currentThemeName; } + set { - if (value == null) return; - - var key = value.ToUpperInvariant(); - - if (key == Theme?.ToUpperInvariant()) return; - - if (!ThemeMap.ContainsKey(key) || ThemeMap[key] == null) + if (value != null && currentThemeName != value) { - ThemeMap[key] = new Theme() - { - Id = value - }; - } + currentThemeName = value.ToUpperInvariant(); + themeChangeHandler?.Invoke(null, new ThemeChangeEventArgs { CurrentTheme = currentThemeName }); - ThemeManager.CurrentTheme = ThemeMap[key]; + UpdateTheme(); + } } } /// - /// (Theme name, Theme instance) - /// - private Dictionary ThemeMap { get; } = new Dictionary { ["DEFAULT"] = ThemeManager.DefaultTheme }; - - /// /// Register style in StyleManager. /// /// Style name. - /// Theme id. + /// Theme. /// Style type. /// Flag to decide if it is default style. [EditorBrowsable(EditorBrowsableState.Never)] @@ -97,30 +119,32 @@ namespace Tizen.NUI.Components throw new InvalidOperationException($"style can't be null"); } - if (Activator.CreateInstance(styleType) is StyleBase styleBase) + if (theme == null || bDefault == true) { - var key = "DEFAULT"; - - if (theme != null) + if (defaultStyleSet.ContainsKey(style)) { - key = theme.ToUpperInvariant(); + throw new InvalidOperationException($"{style}] already be used"); } - - if (!ThemeMap.ContainsKey(key) || ThemeMap[key] == null) + else { - ThemeMap[key] = new Theme() - { - Id = theme ?? key - }; + defaultStyleSet.Add(style, Activator.CreateInstance(styleType) as StyleBase); } + return; + } - if (ThemeMap[key].HasStyle(style)) - { - throw new InvalidOperationException($"{style} already be used"); - } + theme = theme.ToUpperInvariant(); + + if (themeStyleSet.ContainsKey(style) && themeStyleSet[style].ContainsKey(theme)) + { + throw new InvalidOperationException($"{style}] already be used"); + } - ThemeMap[key][style] = styleBase.GetViewStyle(); + if (!themeStyleSet.ContainsKey(style)) + { + themeStyleSet.Add(style, new Dictionary()); } + + themeStyleSet[style].Add(theme, Activator.CreateInstance(styleType) as StyleBase); } /// @@ -136,7 +160,16 @@ namespace Tizen.NUI.Components return null; } - return (ThemeManager.CurrentTheme?.GetStyle(style) ?? ThemeManager.DefaultTheme?.GetStyle(style))?.Clone(); + if (themeStyleSet.ContainsKey(style) && themeStyleSet[style].ContainsKey(Theme)) + { + return (themeStyleSet[style][Theme])?.GetViewStyle(); + } + else if (defaultStyleSet.ContainsKey(style)) + { + return (defaultStyleSet[style])?.GetViewStyle(); + } + + return null; } /// @@ -153,15 +186,25 @@ namespace Tizen.NUI.Components throw new ArgumentException("The argument targetTheme must be specified"); } - var key = targetTheme.ToUpperInvariant(); - - if (!ThemeMap.ContainsKey(key) || ThemeMap[key] == null) + if (!themeMap.ContainsKey(targetTheme)) { Tizen.Log.Error("NUI", "The theme name should be a known one."); return; } - ThemeMap[key][component.Name] = (Activator.CreateInstance(style) as StyleBase).GetViewStyle(); + if (!componentStyleByTheme.ContainsKey(targetTheme)) + { + componentStyleByTheme.Add(targetTheme, new Dictionary()); + } + + if (componentStyleByTheme[targetTheme].ContainsKey(component)) + { + componentStyleByTheme[targetTheme][component] = Activator.CreateInstance(style) as StyleBase; + } + else + { + componentStyleByTheme[targetTheme].Add(component, Activator.CreateInstance(style) as StyleBase); + } } /// @@ -172,12 +215,12 @@ namespace Tizen.NUI.Components [EditorBrowsable(EditorBrowsableState.Never)] public ViewStyle GetComponentStyle(Type component) { - return ThemeManager.GetStyle(component.Name); - } + if (componentStyleByTheme.ContainsKey(currentThemeName) && componentStyleByTheme[currentThemeName].ContainsKey(component)) + { + return componentStyleByTheme[currentThemeName][component].GetViewStyle(); + } - private void OnThemeChanged(object target, ThemeChangedEventArgs args) - { - ThemeChangedEvent?.Invoke(null, new ThemeChangeEventArgs { CurrentTheme = args.ThemeId }); + return currentTheme.GetComponentStyle(component); } /// @@ -192,5 +235,52 @@ namespace Tizen.NUI.Components [EditorBrowsable(EditorBrowsableState.Never)] public string CurrentTheme; } + + internal static string GetFrameworkResourcePath(string resourceFileName) + { + return "/usr/share/dotnet.tizen/framework/res/" + resourceFileName; + } + + private void SetInitialThemeByDeviceProfile() + { + Theme wearableTheme = WearableTheme.Instance; + Theme defaultTheme = DefaultTheme.Instance; + themeMap.Add(wearableThemeName, wearableTheme); + themeMap.Add(defaultThemeName, defaultTheme); + + currentThemeName = defaultThemeName; + currentTheme = defaultTheme; + + string currentProfile; + + try + { + System.Information.TryGetValue("tizen.org/feature/profile", out currentProfile); + Tizen.Log.Info("NUI", "Profile for initial theme found : " + currentProfile); + } + catch + { + Tizen.Log.Error("NUI", "Unknown device profile\n"); + return; + } + + if (string.Equals(currentProfile, wearableThemeName)) + { + currentThemeName = wearableThemeName; + currentTheme = wearableTheme; + } + } + + private void UpdateTheme() + { + if (themeMap.ContainsKey(currentThemeName)) + { + currentTheme = themeMap[currentThemeName]; + } + else + { + currentTheme = DefaultTheme.Instance; + } + } } } diff --git a/src/Tizen.NUI.Components/res/Theme/Tizen.NUI.Components_Tizen.NUI.Theme.Common.xaml b/src/Tizen.NUI.Components/res/Theme/Tizen.NUI.Components_Tizen.NUI.Theme.Common.xaml deleted file mode 100644 index 44a882c..0000000 --- a/src/Tizen.NUI.Components/res/Theme/Tizen.NUI.Components_Tizen.NUI.Theme.Common.xaml +++ /dev/null @@ -1,215 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/Tizen.NUI.Components/res/Theme/Tizen.NUI.Components_Tizen.NUI.Theme.Wearable.xaml b/src/Tizen.NUI.Components/res/Theme/Tizen.NUI.Components_Tizen.NUI.Theme.Wearable.xaml deleted file mode 100644 index d8af9c6..0000000 --- a/src/Tizen.NUI.Components/res/Theme/Tizen.NUI.Components_Tizen.NUI.Theme.Wearable.xaml +++ /dev/null @@ -1,179 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/Tizen.NUI.Wearable/Tizen.NUI.Wearable.csproj b/src/Tizen.NUI.Wearable/Tizen.NUI.Wearable.csproj index c3ddd62..02efe79 100755 --- a/src/Tizen.NUI.Wearable/Tizen.NUI.Wearable.csproj +++ b/src/Tizen.NUI.Wearable/Tizen.NUI.Wearable.csproj @@ -16,7 +16,10 @@ - + + PreserveNewest + + PreserveNewest diff --git a/src/Tizen.NUI.Wearable/res/Theme/Tizen.NUI.Wearable_Tizen.NUI.Theme.Common.xaml b/src/Tizen.NUI.Wearable/res/Theme/Tizen.NUI.Wearable_Tizen.NUI.Theme.Common.xaml deleted file mode 100644 index 0d2618b..0000000 --- a/src/Tizen.NUI.Wearable/res/Theme/Tizen.NUI.Wearable_Tizen.NUI.Theme.Common.xaml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/Tizen.NUI.Wearable/res/Theme/Tizen.NUI.Wearable_Tizen.NUI.Theme.Wearable.xaml b/src/Tizen.NUI.Wearable/res/Theme/Tizen.NUI.Wearable_Tizen.NUI.Theme.Wearable.xaml deleted file mode 100644 index 14788c3..0000000 --- a/src/Tizen.NUI.Wearable/res/Theme/Tizen.NUI.Wearable_Tizen.NUI.Theme.Wearable.xaml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/Tizen.NUI.Wearable/src/public/CircularProgress.cs b/src/Tizen.NUI.Wearable/src/public/CircularProgress.cs index 61873ae..8402209 100755 --- a/src/Tizen.NUI.Wearable/src/public/CircularProgress.cs +++ b/src/Tizen.NUI.Wearable/src/public/CircularProgress.cs @@ -166,7 +166,7 @@ namespace Tizen.NUI.Wearable /// User can set its size. /// [EditorBrowsable(EditorBrowsableState.Never)] - public CircularProgress() : base() + public CircularProgress() : base(new CircularProgressStyle()) { Initialize(); } diff --git a/src/Tizen.NUI.Wearable/src/public/CircularScrollbar.cs b/src/Tizen.NUI.Wearable/src/public/CircularScrollbar.cs index c565e6c..abb046f 100644 --- a/src/Tizen.NUI.Wearable/src/public/CircularScrollbar.cs +++ b/src/Tizen.NUI.Wearable/src/public/CircularScrollbar.cs @@ -107,7 +107,7 @@ namespace Tizen.NUI.Wearable /// /// Create an empty CircularScrollbar. /// - public CircularScrollbar() : base() + public CircularScrollbar() : base(new CircularScrollbarStyle()) { } @@ -119,7 +119,7 @@ namespace Tizen.NUI.Wearable /// The current position of the viewport in scrollable content area. This is the viewport's top position if the scroller is vertical, otherwise, left. /// Whether the direction of scrolling is horizontal or not. It is vertical by default. [EditorBrowsable(EditorBrowsableState.Never)] - public CircularScrollbar(float contentLength, float viewportLength, float currentPosition, bool isHorizontal = false) : base(ThemeManager.GetStyle(typeof(CircularScrollbar))) + public CircularScrollbar(float contentLength, float viewportLength, float currentPosition, bool isHorizontal = false) : base(new CircularScrollbarStyle()) { Initialize(contentLength, viewportLength, currentPosition, isHorizontal); } @@ -381,17 +381,6 @@ namespace Tizen.NUI.Wearable /// [EditorBrowsable(EditorBrowsableState.Never)] - public override void ApplyStyle(ViewStyle viewStyle) - { - if (viewStyle == null) return; - if (viewStyle.WidthResizePolicy == null) viewStyle.WidthResizePolicy = ResizePolicyType.FillToParent; - if (viewStyle.HeightResizePolicy == null) viewStyle.HeightResizePolicy = ResizePolicyType.FillToParent; - - base.ApplyStyle(viewStyle); - } - - /// - [EditorBrowsable(EditorBrowsableState.Never)] protected override ViewStyle CreateViewStyle() { return new CircularScrollbarStyle(); diff --git a/src/Tizen.NUI.Wearable/src/public/CircularSlider.cs b/src/Tizen.NUI.Wearable/src/public/CircularSlider.cs index 5a1c7f1..792ff52 100755 --- a/src/Tizen.NUI.Wearable/src/public/CircularSlider.cs +++ b/src/Tizen.NUI.Wearable/src/public/CircularSlider.cs @@ -218,7 +218,7 @@ namespace Tizen.NUI.Wearable /// The constructor of CircularSlider. /// [EditorBrowsable(EditorBrowsableState.Never)] - public CircularSlider() : base() + public CircularSlider() : base(new CircularSliderStyle()) { Initialize(); } diff --git a/src/Tizen.NUI.Wearable/src/public/Popup.cs b/src/Tizen.NUI.Wearable/src/public/Popup.cs index 6038bc2..48ee21c 100755 --- a/src/Tizen.NUI.Wearable/src/public/Popup.cs +++ b/src/Tizen.NUI.Wearable/src/public/Popup.cs @@ -38,7 +38,7 @@ namespace Tizen.NUI.Wearable /// Constructor /// [EditorBrowsable(EditorBrowsableState.Never)] - public Popup() : base(ThemeManager.GetStyle("WearablePopup") as ControlStyle) + public Popup() : base() { initialize(); } @@ -437,7 +437,7 @@ namespace Tizen.NUI.Wearable private void initialize() { - popupStyle = ViewStyle as PopupStyle; + popupStyle = Style as PopupStyle; if (popupStyle == null) { throw new Exception("Popup style is null."); diff --git a/src/Tizen.NUI.Wearable/src/public/WearableStyle/CircularPaginationStyle.cs b/src/Tizen.NUI.Wearable/src/public/WearableStyle/CircularPaginationStyle.cs index 7a3d8a5..5528c92 100755 --- a/src/Tizen.NUI.Wearable/src/public/WearableStyle/CircularPaginationStyle.cs +++ b/src/Tizen.NUI.Wearable/src/public/WearableStyle/CircularPaginationStyle.cs @@ -29,43 +29,6 @@ namespace Tizen.NUI.Wearable [EditorBrowsable(EditorBrowsableState.Never)] public class CircularPaginationStyle : ControlStyle { - /// The IndicatorSize bindable property. - [EditorBrowsable(EditorBrowsableState.Never)] - public static readonly BindableProperty IndicatorSizeProperty = BindableProperty.Create(nameof(IndicatorSize), typeof(Size), typeof(CircularPaginationStyle), null, propertyChanged: (bindable, oldValue, newValue) => - { - ((CircularPaginationStyle)bindable).indicatorSize = newValue == null ? null : new Size((Size)newValue); - }, - defaultValueCreator: (bindable) => - { - return ((CircularPaginationStyle)bindable).indicatorSize; - }); - - /// The IndicatorImageUrlSelector bindable property. - [EditorBrowsable(EditorBrowsableState.Never)] - public static readonly BindableProperty IndicatorImageUrlSelectorProperty = BindableProperty.Create("IndicatorImageUrlSelector", typeof(Selector), typeof(CircularPaginationStyle), null, propertyChanged: (bindable, oldValue, newValue) => - { - ((CircularPaginationStyle)bindable).indicatorImageUrl = ((Selector)newValue)?.Clone(); - }, - defaultValueCreator: (bindable) => - { - return ((CircularPaginationStyle)bindable).indicatorImageUrl; - }); - - /// The CenterIndicatorImageUrlSelector bindable property. - [EditorBrowsable(EditorBrowsableState.Never)] - public static readonly BindableProperty CenterIndicatorImageUrlSelectorProperty = BindableProperty.Create("CenterIndicatorImageUrlSelector", typeof(Selector), typeof(CircularPaginationStyle), null, propertyChanged: (bindable, oldValue, newValue) => - { - ((CircularPaginationStyle)bindable).centerIndicatorImageUrl = ((Selector)newValue)?.Clone(); - }, - defaultValueCreator: (bindable) => - { - return ((CircularPaginationStyle)bindable).centerIndicatorImageUrl; - }); - - private Size indicatorSize; - private Selector indicatorImageUrl; - private Selector centerIndicatorImageUrl; - static CircularPaginationStyle() { } /// @@ -87,6 +50,9 @@ namespace Tizen.NUI.Wearable [EditorBrowsable(EditorBrowsableState.Never)] public CircularPaginationStyle(CircularPaginationStyle style) : base(style) { + if (null == style) return; + + this.CopyFrom(style); } /// @@ -95,11 +61,7 @@ namespace Tizen.NUI.Wearable /// 8 /// 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 Size IndicatorSize - { - get => (Size)GetValue(IndicatorSizeProperty); - set => SetValue(IndicatorSizeProperty, value); - } + public Size IndicatorSize { get; set; } /// /// Gets or sets the resource of indicator. @@ -107,11 +69,7 @@ namespace Tizen.NUI.Wearable /// 8 /// 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 IndicatorImageURL - { - get => (Selector)GetValue(IndicatorImageUrlSelectorProperty); - set => SetValue(IndicatorImageUrlSelectorProperty, value); - } + public Selector IndicatorImageURL { get; set; } = new Selector(); /// /// Gets or sets the resource of the center indicator. @@ -119,10 +77,34 @@ namespace Tizen.NUI.Wearable /// 8 /// 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 CenterIndicatorImageURL + public Selector CenterIndicatorImageURL { get; set; } = new Selector(); + + /// + /// Retrieves a copy of CircularPaginationStyle. + /// + /// 8 + /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API. + [EditorBrowsable(EditorBrowsableState.Never)] + public override void CopyFrom(BindableObject bindableObject) { - get => (Selector)GetValue(CenterIndicatorImageUrlSelectorProperty); - set => SetValue(CenterIndicatorImageUrlSelectorProperty, value); + base.CopyFrom(bindableObject); + + CircularPaginationStyle circularPaginationStyle = bindableObject as CircularPaginationStyle; + if (null != circularPaginationStyle) + { + if (null != circularPaginationStyle.IndicatorSize) + { + IndicatorSize = new Size(circularPaginationStyle.IndicatorSize.Width, circularPaginationStyle.IndicatorSize.Height); + } + if (null != circularPaginationStyle.IndicatorImageURL) + { + IndicatorImageURL?.Clone(circularPaginationStyle.IndicatorImageURL); + } + if (null != circularPaginationStyle.CenterIndicatorImageURL) + { + CenterIndicatorImageURL?.Clone(circularPaginationStyle.CenterIndicatorImageURL); + } + } } private void Initialize() @@ -130,13 +112,13 @@ namespace Tizen.NUI.Wearable IndicatorSize = new Size(10, 10); IndicatorImageURL = new Selector() { - Normal = Tizen.NUI.StyleManager.FrameworkResourcePath + "nui_component_default_pagination_normal_dot.png", - Selected = Tizen.NUI.StyleManager.FrameworkResourcePath + "nui_component_default_pagination_focus_dot.png", + Normal = "/usr/share/dotnet.tizen/framework/res/" + "nui_component_default_pagination_normal_dot.png", + Selected = "/usr/share/dotnet.tizen/framework/res/" + "nui_component_default_pagination_focus_dot.png", }; CenterIndicatorImageURL = new Selector() { - Normal = Tizen.NUI.StyleManager.FrameworkResourcePath + "nui_wearable_circular_pagination_center_normal_dot.png", - Selected = Tizen.NUI.StyleManager.FrameworkResourcePath + "nui_wearable_circular_pagination_center_focus_dot.png", + Normal = "/usr/share/dotnet.tizen/framework/res/" + "nui_wearable_circular_pagination_center_normal_dot.png", + Selected = "/usr/share/dotnet.tizen/framework/res/" + "nui_wearable_circular_pagination_center_focus_dot.png", }; } } diff --git a/src/Tizen.NUI.Wearable/src/public/WearableStyle/CircularProgressStyle.cs b/src/Tizen.NUI.Wearable/src/public/WearableStyle/CircularProgressStyle.cs index 05aef8e..d89c1d0 100755 --- a/src/Tizen.NUI.Wearable/src/public/WearableStyle/CircularProgressStyle.cs +++ b/src/Tizen.NUI.Wearable/src/public/WearableStyle/CircularProgressStyle.cs @@ -75,7 +75,7 @@ namespace Tizen.NUI.Wearable [EditorBrowsable(EditorBrowsableState.Never)] public static readonly BindableProperty TrackColorProperty = BindableProperty.Create(nameof(TrackColor), typeof(Color), typeof(CircularProgressStyle), null, propertyChanged: (bindable, oldValue, newValue) => { - ((CircularProgressStyle)bindable).trackColor = newValue == null ? null : new Color((Color)newValue); + ((CircularProgressStyle)bindable).trackColor = (Color)newValue; }, defaultValueCreator: (bindable) => { @@ -86,7 +86,7 @@ namespace Tizen.NUI.Wearable [EditorBrowsable(EditorBrowsableState.Never)] public static readonly BindableProperty ProgressColorProperty = BindableProperty.Create(nameof(ProgressColor), typeof(Color), typeof(CircularProgressStyle), null, propertyChanged: (bindable, oldValue, newValue) => { - ((CircularProgressStyle)bindable).progressColor = newValue == null ? null : new Color((Color)newValue); + ((CircularProgressStyle)bindable).progressColor = (Color)newValue; }, defaultValueCreator: (bindable) => { @@ -130,6 +130,8 @@ namespace Tizen.NUI.Wearable [EditorBrowsable(EditorBrowsableState.Never)] public CircularProgressStyle(CircularProgressStyle style) : base(style) { + if (null == style) return; + this.CopyFrom(style); } /// @@ -245,6 +247,29 @@ namespace Tizen.NUI.Wearable } /// + /// Style's clone function. + /// + /// The style that need to copy. + [EditorBrowsable(EditorBrowsableState.Never)] + public override void CopyFrom(BindableObject bindableObject) + { + base.CopyFrom(bindableObject); + + CircularProgressStyle progressStyle = bindableObject as CircularProgressStyle; + + if (null != progressStyle) + { + isEnabled = progressStyle.isEnabled; + thickness = progressStyle.Thickness; + maxValue = progressStyle.maxValue; + minValue = progressStyle.minValue; + currentValue = progressStyle.currentValue; + trackColor = progressStyle.trackColor; + progressColor = progressStyle.progressColor; + } + } + + /// /// Dispose CircularProgressStyle and all children on it. /// /// Dispose type. diff --git a/src/Tizen.NUI.Wearable/src/public/WearableStyle/CircularScrollbarStyle.cs b/src/Tizen.NUI.Wearable/src/public/WearableStyle/CircularScrollbarStyle.cs index 6c63231..218ff48 100644 --- a/src/Tizen.NUI.Wearable/src/public/WearableStyle/CircularScrollbarStyle.cs +++ b/src/Tizen.NUI.Wearable/src/public/WearableStyle/CircularScrollbarStyle.cs @@ -54,7 +54,7 @@ namespace Tizen.NUI.Wearable [EditorBrowsable(EditorBrowsableState.Never)] public static readonly BindableProperty TrackColorProperty = BindableProperty.Create(nameof(TrackColor), typeof(Color), typeof(CircularScrollbarStyle), null, propertyChanged: (bindable, oldValue, newValue) => { - ((CircularScrollbarStyle)bindable).trackColor = newValue == null ? null : new Color((Color)newValue); + ((CircularScrollbarStyle)bindable).trackColor = (Color)newValue; }, defaultValueCreator: (bindable) => { @@ -65,7 +65,7 @@ namespace Tizen.NUI.Wearable [EditorBrowsable(EditorBrowsableState.Never)] public static readonly BindableProperty ThumbColorProperty = BindableProperty.Create(nameof(ThumbColor), typeof(Color), typeof(CircularScrollbarStyle), null, propertyChanged: (bindable, oldValue, newValue) => { - ((CircularScrollbarStyle)bindable).thumbColor = newValue == null ? null : new Color((Color)newValue); + ((CircularScrollbarStyle)bindable).thumbColor = (Color)newValue; }, defaultValueCreator: (bindable) => { @@ -88,6 +88,7 @@ namespace Tizen.NUI.Wearable [EditorBrowsable(EditorBrowsableState.Never)] public CircularScrollbarStyle() : base() { + Initialize(); } /// @@ -97,6 +98,7 @@ namespace Tizen.NUI.Wearable [EditorBrowsable(EditorBrowsableState.Never)] public CircularScrollbarStyle(CircularScrollbarStyle style) : base(style) { + this.CopyFrom(style); } /// @@ -156,5 +158,37 @@ namespace Tizen.NUI.Wearable } #endregion Properties + + + #region Methods + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override void CopyFrom(BindableObject bindableObject) + { + base.CopyFrom(bindableObject); + + var style = bindableObject as CircularScrollbarStyle; + + if (null != style) + { + Thickness = style.Thickness; + TrackSweepAngle = style.TrackSweepAngle; + TrackColor = style.TrackColor; + ThumbColor = style.ThumbColor; + } + } + + private void Initialize() + { + Thickness = 10.0f; + TrackSweepAngle = 60.0f; + TrackColor = new Color(1.0f, 1.0f, 1.0f, 0.15f); + ThumbColor = new Color(0.6f, 0.6f, 0.6f, 1.0f); + WidthResizePolicy = ResizePolicyType.FillToParent; + HeightResizePolicy = ResizePolicyType.FillToParent; + } + + #endregion Methods } } diff --git a/src/Tizen.NUI.Wearable/src/public/WearableStyle/CircularSliderStyle.cs b/src/Tizen.NUI.Wearable/src/public/WearableStyle/CircularSliderStyle.cs index eae2cc6..cecf80b 100755 --- a/src/Tizen.NUI.Wearable/src/public/WearableStyle/CircularSliderStyle.cs +++ b/src/Tizen.NUI.Wearable/src/public/WearableStyle/CircularSliderStyle.cs @@ -75,7 +75,7 @@ namespace Tizen.NUI.Wearable [EditorBrowsable(EditorBrowsableState.Never)] public static readonly BindableProperty TrackColorProperty = BindableProperty.Create(nameof(TrackColor), typeof(Color), typeof(CircularSliderStyle), null, propertyChanged: (bindable, oldValue, newValue) => { - ((CircularSliderStyle)bindable).trackColor = newValue == null ? null : new Color((Color)newValue); + ((CircularSliderStyle)bindable).trackColor = (Color)newValue; }, defaultValueCreator: (bindable) => { @@ -86,7 +86,7 @@ namespace Tizen.NUI.Wearable [EditorBrowsable(EditorBrowsableState.Never)] public static readonly BindableProperty ProgressColorProperty = BindableProperty.Create(nameof(ProgressColor), typeof(Color), typeof(CircularSliderStyle), null, propertyChanged: (bindable, oldValue, newValue) => { - ((CircularSliderStyle)bindable).progressColor = newValue == null ? null : new Color((Color)newValue); + ((CircularSliderStyle)bindable).progressColor = (Color)newValue; }, defaultValueCreator: (bindable) => { @@ -108,7 +108,7 @@ namespace Tizen.NUI.Wearable [EditorBrowsable(EditorBrowsableState.Never)] public static readonly BindableProperty ThumbColorProperty = BindableProperty.Create(nameof(ThumbColor), typeof(Color), typeof(CircularSliderStyle), null, propertyChanged: (bindable, oldValue, newValue) => { - ((CircularSliderStyle)bindable).thumbColor = newValue == null ? null : new Color((Color)newValue); + ((CircularSliderStyle)bindable).thumbColor = (Color)newValue; }, defaultValueCreator: (bindable) => { @@ -154,6 +154,8 @@ namespace Tizen.NUI.Wearable [EditorBrowsable(EditorBrowsableState.Never)] public CircularSliderStyle(CircularSliderStyle style) : base(style) { + if (null == style) return; + this.CopyFrom(style); } /// @@ -300,6 +302,31 @@ namespace Tizen.NUI.Wearable } } + /// + /// Style's clone function. + /// + /// The style that need to copy. + [EditorBrowsable(EditorBrowsableState.Never)] + public override void CopyFrom(BindableObject bindableObject) + { + base.CopyFrom(bindableObject); + + CircularSliderStyle progressStyle = bindableObject as CircularSliderStyle; + + if (null != progressStyle) + { + isEnabled = progressStyle.isEnabled; + thickness = progressStyle.Thickness; + maxValue = progressStyle.maxValue; + minValue = progressStyle.minValue; + currentValue = progressStyle.currentValue; + trackColor = progressStyle.trackColor; + progressColor = progressStyle.progressColor; + thumbSize = progressStyle.thumbSize; + thumbColor = progressStyle.thumbColor; + } + } + private void Initialize() { isEnabled = true; diff --git a/src/Tizen.NUI.Wearable/src/public/WearableStyle/PopupStyle.cs b/src/Tizen.NUI.Wearable/src/public/WearableStyle/PopupStyle.cs index 90efa80..8f909af 100755 --- a/src/Tizen.NUI.Wearable/src/public/WearableStyle/PopupStyle.cs +++ b/src/Tizen.NUI.Wearable/src/public/WearableStyle/PopupStyle.cs @@ -15,6 +15,7 @@ * */ using System.ComponentModel; +using Tizen.NUI.BaseComponents; using Tizen.NUI.Binding; using Tizen.NUI.Components; @@ -26,19 +27,6 @@ namespace Tizen.NUI.Wearable [EditorBrowsable(EditorBrowsableState.Never)] public class PopupStyle : ControlStyle { - /// Bindable property of WrapContent - [EditorBrowsable(EditorBrowsableState.Never)] - public static readonly BindableProperty WrapContentProperty = BindableProperty.Create(nameof(WrapContent), typeof(bool?), typeof(PopupStyle), null, propertyChanged: (bindable, oldValue, newValue) => - { - ((PopupStyle)bindable).wrapContent = (bool?)newValue; - }, - defaultValueCreator: (bindable) => - { - return ((PopupStyle)bindable).wrapContent; - }); - - private bool? wrapContent; - static PopupStyle() { } /// @@ -56,6 +44,12 @@ namespace Tizen.NUI.Wearable [EditorBrowsable(EditorBrowsableState.Never)] public PopupStyle(PopupStyle style) : base(style) { + if (null == style) + { + return; + } + initSubStyle(); + CopyFrom(style); } /// @@ -64,8 +58,26 @@ namespace Tizen.NUI.Wearable [EditorBrowsable(EditorBrowsableState.Never)] public bool? WrapContent { - get => (bool?)GetValue(WrapContentProperty); - set => SetValue(WrapContentProperty, value); + get; + set; + } + + /// + /// Retrieves a copy of PopupStyle. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override void CopyFrom(BindableObject bindableObject) + { + base.CopyFrom(bindableObject); + + PopupStyle popupStyle = bindableObject as PopupStyle; + if (null != popupStyle) + { + if (null != popupStyle.WrapContent) + { + WrapContent = popupStyle.WrapContent; + } + } } private void initSubStyle() diff --git a/src/Tizen.NUI/Tizen.NUI.csproj b/src/Tizen.NUI/Tizen.NUI.csproj index d917aa6..c64bd04 100644 --- a/src/Tizen.NUI/Tizen.NUI.csproj +++ b/src/Tizen.NUI/Tizen.NUI.csproj @@ -34,10 +34,4 @@ - - - PreserveNewest - - - \ No newline at end of file diff --git a/src/Tizen.NUI/res/Theme/Tizen.NUI_Tizen.NUI.Theme.Common.xaml b/src/Tizen.NUI/res/Theme/Tizen.NUI_Tizen.NUI.Theme.Common.xaml deleted file mode 100644 index 7a494cf..0000000 --- a/src/Tizen.NUI/res/Theme/Tizen.NUI_Tizen.NUI.Theme.Common.xaml +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/src/Tizen.NUI/res/Theme/Tizen.NUI_Tizen.NUI.Theme.Wearable.xaml b/src/Tizen.NUI/res/Theme/Tizen.NUI_Tizen.NUI.Theme.Wearable.xaml deleted file mode 100644 index 07bee24..0000000 --- a/src/Tizen.NUI/res/Theme/Tizen.NUI_Tizen.NUI.Theme.Wearable.xaml +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/src/Tizen.NUI/src/internal/Xaml/ApplyPropertiesVisitor.cs b/src/Tizen.NUI/src/internal/Xaml/ApplyPropertiesVisitor.cs index 0594cd1..5b43fd2 100755 --- a/src/Tizen.NUI/src/internal/Xaml/ApplyPropertiesVisitor.cs +++ b/src/Tizen.NUI/src/internal/Xaml/ApplyPropertiesVisitor.cs @@ -120,17 +120,6 @@ namespace Tizen.NUI.Xaml //ResourceDictionary if (xpe == null && TryAddToResourceDictionary(source as ResourceDictionary, value, xKey, node, out xpe)) return; - - // Dictionary with string key - if (xpe == null && xKey != null) - { - var indexer = GetIndexer(source, typeof(string), value.GetType()); - if (indexer != null) - { - indexer.SetValue(source, value, new[] { xKey }); - return; - } - } // Collection element, implicit content, or implicit collection element. if (xpe == null && typeof(IEnumerable).IsAssignableFrom(Context.Types[parentElement]) && Context.Types[parentElement].GetRuntimeMethods().Any(mi => mi.Name == "Add" && mi.GetParameters().Length == 1)) { @@ -156,7 +145,7 @@ namespace Tizen.NUI.Xaml SetPropertyValue(source, name, value, Context.RootElement, node, Context, node); return; - } + } xpe = xpe ?? new XamlParseException($"Can not set the content of {((IElementNode)parentNode).XmlType.Name} as it doesn't have a ContentPropertyAttribute", node); if (Context.ExceptionHandler != null) @@ -756,7 +745,5 @@ namespace Tizen.NUI.Xaml SetPropertyValue(source, new XmlName("", runTimeName.Name), value, Context.RootElement, node, Context, node); return true; } - - private PropertyInfo GetIndexer(object source, Type keyType, Type valueType) => source.GetType().GetProperties().FirstOrDefault(p => p.Name == "Item" && p.PropertyType.IsAssignableFrom(valueType) && p.GetIndexParameters().Length != 0 && p.GetIndexParameters()[0].ParameterType == keyType); } } diff --git a/src/Tizen.NUI/src/internal/Xaml/XamlLoader.cs b/src/Tizen.NUI/src/internal/Xaml/XamlLoader.cs index faae3b2..5c26374 100755 --- a/src/Tizen.NUI/src/internal/Xaml/XamlLoader.cs +++ b/src/Tizen.NUI/src/internal/Xaml/XamlLoader.cs @@ -132,14 +132,6 @@ namespace Tizen.NUI.Xaml using (var textReader = new StringReader(xaml)) using (var reader = XmlReader.Create(textReader)) { - Load(view, reader); - } - } - - public static void Load(object view, XmlReader reader) - { - if (reader != null) - { while (reader.Read()) { //Skip until element @@ -179,16 +171,6 @@ namespace Tizen.NUI.Xaml using (var textreader = new StringReader(xaml)) using (var reader = XmlReader.Create(textreader)) { - inflatedView = Create(reader, doNotThrow); - } - return inflatedView; - } - - public static object Create(XmlReader reader, bool doNotThrow = false) - { - object inflatedView = null; - if (reader != null) - { while (reader.Read()) { //Skip until element diff --git a/src/Tizen.NUI/src/internal/Xaml/XamlParser.cs b/src/Tizen.NUI/src/internal/Xaml/XamlParser.cs index cc64340..183d61e 100755 --- a/src/Tizen.NUI/src/internal/Xaml/XamlParser.cs +++ b/src/Tizen.NUI/src/internal/Xaml/XamlParser.cs @@ -407,12 +407,7 @@ namespace Tizen.NUI.Xaml } if (type == null) - { - var message = $"Type {elementName} not found in xmlns {namespaceURI}\n"; - message += "\n - Make sure the all used assemblies (e.g. Tizen.NUI.Components) are included in the application project."; - message += "\n - Make sure the type and namespace are correct.\n"; - exception = new XamlParseException($"message", xmlInfo); - } + exception = new XamlParseException($"Type {elementName} not found in xmlns {namespaceURI}", xmlInfo); return type; } diff --git a/src/Tizen.NUI/src/internal/XamlBinding/ExtentsTypeConverter.cs b/src/Tizen.NUI/src/internal/XamlBinding/ExtentsTypeConverter.cs index 2c465ec..48195e6 100755 --- a/src/Tizen.NUI/src/internal/XamlBinding/ExtentsTypeConverter.cs +++ b/src/Tizen.NUI/src/internal/XamlBinding/ExtentsTypeConverter.cs @@ -21,10 +21,6 @@ namespace Tizen.NUI.Binding ushort.Parse(parts[2].Trim(), CultureInfo.InvariantCulture), ushort.Parse(parts[3].Trim(), CultureInfo.InvariantCulture)); } - else if (parts.Length == 1) - { - return new Extents(ushort.Parse(parts[0].Trim(), CultureInfo.InvariantCulture)); - } } throw new InvalidOperationException($"Cannot convert \"{value}\" into {typeof(Extents)}"); diff --git a/src/Tizen.NUI/src/public/BaseComponents/ImageView.cs b/src/Tizen.NUI/src/public/BaseComponents/ImageView.cs index a024ccd..a4049b6 100644 --- a/src/Tizen.NUI/src/public/BaseComponents/ImageView.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/ImageView.cs @@ -164,7 +164,7 @@ namespace Tizen.NUI.BaseComponents var imageView = (ImageView)bindable; if(newValue != null) { - imageView._border = new Rectangle((Rectangle)newValue); + imageView._border = (Rectangle)newValue; imageView.UpdateImage(NpatchImageVisualProperty.Border, new PropertyValue(imageView._border)); } }, @@ -348,8 +348,6 @@ namespace Tizen.NUI.BaseComponents internal ImageView(global::System.IntPtr cPtr, bool cMemoryOwn, bool shown = true) : base(Interop.ImageView.ImageView_SWIGUpcast(cPtr), cMemoryOwn) { - ApplyStyle(ThemeManager.GetStyle(nameof(ImageView))); - if (!shown) { SetVisible(false); diff --git a/src/Tizen.NUI/src/public/BaseComponents/LottieAnimationView.cs b/src/Tizen.NUI/src/public/BaseComponents/LottieAnimationView.cs index 82aabb3..7e9ebb3 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/LottieAnimationView.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/LottieAnimationView.cs @@ -835,7 +835,7 @@ namespace Tizen.NUI.BaseComponents /// A class containing frame informations for a LottieAnimationView. /// [EditorBrowsable(EditorBrowsableState.Never)] - public class LottieFrameInfo : ICloneable + public class LottieFrameInfo { /// /// Creates a new instance with a playing range. @@ -874,31 +874,6 @@ namespace Tizen.NUI.BaseComponents } /// - /// Create a new instance from string. - /// Possible input : "0, 10", "10" - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public static implicit operator LottieFrameInfo(string pair) - { - if (pair == null) - { - return null; - } - - string[] parts = pair.Split(','); - if (parts.Length == 1) - { - return new LottieFrameInfo(Int32.Parse(parts[0].Trim())); - } - else if (parts.Length == 2) - { - return new LottieFrameInfo(Int32.Parse(parts[0].Trim()), Int32.Parse(parts[1].Trim())); - } - - throw new InvalidCastException($"Can not convert string {pair} to LottieFrameInfo"); - } - - /// /// The start frame of the lottie animation. /// [EditorBrowsable(EditorBrowsableState.Never)] @@ -965,10 +940,6 @@ namespace Tizen.NUI.BaseComponents } } - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public object Clone() => new LottieFrameInfo(StartFrame, EndFrame); - private bool BeReadyToShow(LottieAnimationView lottieView) { // Validate input lottieView diff --git a/src/Tizen.NUI/src/public/BaseComponents/Style/ImageViewStyle.cs b/src/Tizen.NUI/src/public/BaseComponents/Style/ImageViewStyle.cs index 43c7d1e..d3f24ef 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/Style/ImageViewStyle.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/Style/ImageViewStyle.cs @@ -126,7 +126,7 @@ namespace Tizen.NUI.BaseComponents /// Create an empty instance. /// [EditorBrowsable(EditorBrowsableState.Never)] - public ImageViewStyle() : base() + public ImageViewStyle() { } diff --git a/src/Tizen.NUI/src/public/BaseComponents/Style/Selector.cs b/src/Tizen.NUI/src/public/BaseComponents/Style/Selector.cs index 2147223..ebf5b1f 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/Style/Selector.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/Style/Selector.cs @@ -24,13 +24,13 @@ namespace Tizen.NUI.BaseComponents /// /// Selector class, which is related by Control State, it is base class for other Selector. /// - /// The property type of the selector. if it's reference type, it should be of type that implement deep copy in . /// 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 class Selector : StateValueCollection { - private readonly bool isCloneable = typeof(ICloneable).IsAssignableFrom(typeof(T)); + 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) @@ -48,7 +48,7 @@ namespace Tizen.NUI.BaseComponents [EditorBrowsable(EditorBrowsableState.Never)] public Selector(T value) : this() { - All = isCloneable ? (T)((ICloneable)value)?.Clone() : value; + All = cloneable ? (T)((ICloneable)value)?.Clone() : value; } /// Copy constructor @@ -58,6 +58,7 @@ namespace Tizen.NUI.BaseComponents Clone(value); } + /// /// All State. /// @@ -237,7 +238,7 @@ namespace Tizen.NUI.BaseComponents /// /// Clone itself. - /// If type T implements ISelectorItem, it calls Clone() method to clone values, otherwise use operator=. + /// 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. @@ -257,7 +258,7 @@ namespace Tizen.NUI.BaseComponents { Clear(); - if (isCloneable) + if (cloneable) { All = (T)((ICloneable)other.All)?.Clone(); foreach (var item in other.StateValueList) diff --git a/src/Tizen.NUI/src/public/BaseComponents/Style/TextFieldStyle.cs b/src/Tizen.NUI/src/public/BaseComponents/Style/TextFieldStyle.cs index d969960..ea27493 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/Style/TextFieldStyle.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/Style/TextFieldStyle.cs @@ -530,7 +530,7 @@ namespace Tizen.NUI.BaseComponents /// Create an empty instance. /// [EditorBrowsable(EditorBrowsableState.Never)] - public TextFieldStyle() : base() + public TextFieldStyle() { } diff --git a/src/Tizen.NUI/src/public/BaseComponents/Style/TextLabelStyle.cs b/src/Tizen.NUI/src/public/BaseComponents/Style/TextLabelStyle.cs index b2bd019..ef3d298 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/Style/TextLabelStyle.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/Style/TextLabelStyle.cs @@ -323,7 +323,7 @@ namespace Tizen.NUI.BaseComponents /// Create an empty instance. /// [EditorBrowsable(EditorBrowsableState.Never)] - public TextLabelStyle() : base() + public TextLabelStyle() { } diff --git a/src/Tizen.NUI/src/public/BaseComponents/Style/ViewStyle.cs b/src/Tizen.NUI/src/public/BaseComponents/Style/ViewStyle.cs index a1c3f6e..19e3113 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/Style/ViewStyle.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/Style/ViewStyle.cs @@ -74,7 +74,6 @@ namespace Tizen.NUI.BaseComponents private Extents margin; private float? weight; private bool? enableControlState; - private bool? themeChangeSensitive; private Selector imageShadow; private Selector boxShadow; @@ -95,7 +94,10 @@ namespace Tizen.NUI.BaseComponents [EditorBrowsable(EditorBrowsableState.Never)] public ViewStyle(ViewStyle viewAttributes) { - CopyFrom(viewAttributes); + if (null != viewAttributes) + { + this.CopyFrom(viewAttributes); + } } /// @@ -687,27 +689,6 @@ namespace Tizen.NUI.BaseComponents } /// - /// The ThemeChangeSensitive value of the View. - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public bool? ThemeChangeSensitive - { - get => (bool?)GetValue(ThemeChangeSensitiveProperty); - set => SetValue(ThemeChangeSensitiveProperty, value); - } - - - /// - /// Allow null properties when merging it into other Theme. - /// If the value is true, the null properties reset target properties of the other ViewStyle with same key when merge. - /// It is used in , . - /// It is also used in when the Theme has a parent and needs to merge. - /// Please note that it is false by default. - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public bool SolidNull { get; set; } = false; - - /// /// Set style's bindable properties from the view. /// /// The view that includes property data. @@ -732,28 +713,17 @@ namespace Tizen.NUI.BaseComponents } } - /// Create a cloned ViewStyle. - [EditorBrowsable(EditorBrowsableState.Never)] - public ViewStyle Clone() + internal ViewStyle CreateInstance() { - var cloned = CreateInstance(); - cloned.CopyFrom(this); - - return cloned; + return (ViewStyle)Activator.CreateInstance(GetType()); } - /// Create a cloned ViewStyle. - [EditorBrowsable(EditorBrowsableState.Never)] - public void Merge(ViewStyle other) + internal ViewStyle Clone() { - AllowNullCopy = other?.SolidNull ?? false; - CopyFrom(other); - AllowNullCopy = false; - } + var cloned = CreateInstance(); + cloned.CopyFrom(this); - internal ViewStyle CreateInstance() - { - return (ViewStyle)Activator.CreateInstance(GetType()); + return cloned; } private void OnPaddingChanged(ushort start, ushort end, ushort top, ushort bottom) diff --git a/src/Tizen.NUI/src/public/BaseComponents/Style/ViewStyleBindableProperty.cs b/src/Tizen.NUI/src/public/BaseComponents/Style/ViewStyleBindableProperty.cs index 861577c..5146ba9 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/Style/ViewStyleBindableProperty.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/Style/ViewStyleBindableProperty.cs @@ -326,7 +326,6 @@ namespace Tizen.NUI.BaseComponents { if (viewStyle.size == null) { - if ((float)newValue == 0) return; viewStyle.size = new Size(); } viewStyle.size.Width = (float)newValue; @@ -345,7 +344,6 @@ namespace Tizen.NUI.BaseComponents { if (viewStyle.size == null) { - if ((float)newValue == 0) return; viewStyle.size = new Size(); } viewStyle.size.Height = (float)newValue; @@ -361,10 +359,6 @@ namespace Tizen.NUI.BaseComponents { var viewStyle = (ViewStyle)bindable; viewStyle.position = (Position)newValue; - if (viewStyle.position != null && viewStyle.position.X == 0 && viewStyle.position.Y == 0) - { - viewStyle.position = null; - } }, defaultValueCreator: (bindable) => { @@ -380,7 +374,6 @@ namespace Tizen.NUI.BaseComponents { if (viewStyle.position == null) { - if ((float)newValue == 0) return; viewStyle.position = new Position(); } viewStyle.position.X = (float)newValue; @@ -399,7 +392,6 @@ namespace Tizen.NUI.BaseComponents { if (viewStyle.position == null) { - if ((float)newValue == 0) return; viewStyle.position = new Position(); } viewStyle.position.Y = (float)newValue; @@ -418,7 +410,6 @@ namespace Tizen.NUI.BaseComponents { if (viewStyle.position == null) { - if ((float)newValue == 0) return; viewStyle.position = new Position(); } viewStyle.position.Z = (float)newValue; @@ -446,7 +437,6 @@ namespace Tizen.NUI.BaseComponents { var viewStyle = (ViewStyle)bindable; viewStyle.scale = (Vector3)newValue; - if (viewStyle.scale != null && viewStyle.scale.X == 1.0f && viewStyle.scale.Y == 1.0f && viewStyle.scale.Z == 1.0f) return; }, defaultValueCreator: (bindable) => { @@ -462,7 +452,6 @@ namespace Tizen.NUI.BaseComponents { if (viewStyle.scale == null) { - if ((float)newValue == 1.0f) return; viewStyle.scale = new Vector3(); } viewStyle.scale.X = (float)newValue; @@ -481,7 +470,6 @@ namespace Tizen.NUI.BaseComponents { if (viewStyle.scale == null) { - if ((float)newValue == 1.0f) return; viewStyle.scale = new Vector3(); } viewStyle.scale.Y = (float)newValue; @@ -500,7 +488,6 @@ namespace Tizen.NUI.BaseComponents { if (viewStyle.scale == null) { - if ((float)newValue == 1.0f) return; viewStyle.scale = new Vector3(); } viewStyle.scale.Z = (float)newValue; @@ -721,10 +708,6 @@ namespace Tizen.NUI.BaseComponents { var viewStyle = (ViewStyle)bindable; viewStyle.size = (Size)newValue; - if (viewStyle.size != null && viewStyle.size.Width == 0 && viewStyle.size.Height == 0) - { - viewStyle.size = null; - } }, defaultValueCreator: (bindable) => { @@ -833,11 +816,7 @@ namespace Tizen.NUI.BaseComponents var viewStyle = (ViewStyle)bindable; viewStyle.imageShadow = ((Selector)newValue)?.Clone(); - - if (viewStyle.imageShadow != null) - { - viewStyle.boxShadow = null; - } + viewStyle.boxShadow = null; }, defaultValueCreator: (bindable) => { @@ -852,11 +831,7 @@ namespace Tizen.NUI.BaseComponents var viewStyle = (ViewStyle)bindable; viewStyle.boxShadow = ((Selector)newValue)?.Clone(); - - if (viewStyle.boxShadow != null) - { - viewStyle.imageShadow = null; - } + viewStyle.imageShadow = null; }, defaultValueCreator: (bindable) => { @@ -888,18 +863,5 @@ namespace Tizen.NUI.BaseComponents { return ((ViewStyle)bindable).enableControlState; }); - - /// - /// EnableControlState property - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public static readonly BindableProperty ThemeChangeSensitiveProperty = BindableProperty.Create("ThemeChangeSensitive", typeof(bool?), typeof(ViewStyle), null, propertyChanged: (bindable, oldValue, newValue) => - { - ((ViewStyle)bindable).themeChangeSensitive = (bool?)newValue; - }, - defaultValueCreator: (bindable) => - { - return ((ViewStyle)bindable).themeChangeSensitive; - }); } } diff --git a/src/Tizen.NUI/src/public/BaseComponents/TextField.cs b/src/Tizen.NUI/src/public/BaseComponents/TextField.cs index 7668cac..2eb09c6 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/TextField.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/TextField.cs @@ -84,8 +84,6 @@ namespace Tizen.NUI.BaseComponents internal TextField(global::System.IntPtr cPtr, bool cMemoryOwn, bool shown = true) : base(Interop.TextField.TextField_SWIGUpcast(cPtr), cMemoryOwn) { - ApplyStyle(ThemeManager.GetStyle(nameof(TextField))); - if (!shown) { SetVisible(false); diff --git a/src/Tizen.NUI/src/public/BaseComponents/TextLabel.cs b/src/Tizen.NUI/src/public/BaseComponents/TextLabel.cs index 84f19b8..207b539 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/TextLabel.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/TextLabel.cs @@ -165,8 +165,6 @@ namespace Tizen.NUI.BaseComponents internal TextLabel(global::System.IntPtr cPtr, bool cMemoryOwn, bool shown = true) : base(Interop.TextLabel.TextLabel_SWIGUpcast(cPtr), cMemoryOwn) { - ApplyStyle(ThemeManager.GetStyle(nameof(TextLabel))); - if (!shown) { SetVisible(false); diff --git a/src/Tizen.NUI/src/public/BaseComponents/View.cs b/src/Tizen.NUI/src/public/BaseComponents/View.cs index 1f59293..7ab4403 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/View.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/View.cs @@ -61,7 +61,6 @@ namespace Tizen.NUI.BaseComponents private string[] transitionNames; private bool controlStatePropagation = false; private ViewStyle viewStyle; - private bool themeChangeSensitive = false; internal Size2D sizeSetExplicitly = new Size2D(); // Store size set by API, will be used in place of NaturalSize if not set. internal BackgroundExtraData backgroundExtraData; @@ -94,8 +93,9 @@ namespace Tizen.NUI.BaseComponents /// This will be public opened in next release of tizen after ACR done. Before ACR, it is used as HiddenAPI (InhouseAPI). [EditorBrowsable(EditorBrowsableState.Never)] - public View(ViewStyle viewStyle) : this(Interop.View.View_New(), true, viewStyle) + public View(ViewStyle viewStyle) : this(Interop.View.View_New(), true) { + ApplyStyle((viewStyle == null) ? GetViewStyle() : viewStyle.Clone()); } /// @@ -123,7 +123,7 @@ namespace Tizen.NUI.BaseComponents internal View(global::System.IntPtr cPtr, bool cMemoryOwn, ViewStyle viewStyle, bool shown = true) : this(cPtr, cMemoryOwn, shown) { - ApplyStyle((viewStyle == null) ? GetViewStyle() : viewStyle?.Clone()); + ApplyStyle((viewStyle == null) ? GetViewStyle() : viewStyle.Clone()); } internal View(global::System.IntPtr cPtr, bool cMemoryOwn, bool shown = true) : base(Interop.View.View_SWIGUpcast(cPtr), cMemoryOwn) @@ -2325,17 +2325,6 @@ namespace Tizen.NUI.BaseComponents } /// - /// If the value is true, the View will change its style as the theme changes. - /// It is false by default, unless it is Control instance created with specified style name. - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public bool ThemeChangeSensitive - { - get => (bool)GetValue(ThemeChangeSensitiveProperty); - set => SetValue(ThemeChangeSensitiveProperty, value); - } - - /// /// Get Style, it is abstract function and must be override. /// /// 6 @@ -2365,19 +2354,6 @@ namespace Tizen.NUI.BaseComponents { } - /// - /// - [EditorBrowsable(EditorBrowsableState.Never)] - protected virtual void OnThemeChanged(object sender, ThemeChangedEventArgs e) - { - ViewStyle newStyle = ThemeManager.GetStyle(GetType()); - - if (newStyle != null && viewStyle?.GetType() == newStyle.GetType()) - { - ApplyStyle(newStyle); - } - } - /// 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) diff --git a/src/Tizen.NUI/src/public/BaseComponents/ViewBindableProperty.cs b/src/Tizen.NUI/src/public/BaseComponents/ViewBindableProperty.cs index be4bec9..c1fda12 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/ViewBindableProperty.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/ViewBindableProperty.cs @@ -1600,29 +1600,6 @@ namespace Tizen.NUI.BaseComponents return ((View)bindable).enableControlState; }); - /// - /// ThemeChangeSensitive property - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public static readonly BindableProperty ThemeChangeSensitiveProperty = BindableProperty.Create(nameof(ThemeChangeSensitive), typeof(bool), typeof(View), false, propertyChanged: (bindable, oldValue, newValue) => - { - var view = (View)bindable; - view.themeChangeSensitive = (bool)newValue; - - if (view.themeChangeSensitive) - { - ThemeManager.ThemeChanged += view.OnThemeChanged; - } - else - { - ThemeManager.ThemeChanged -= view.OnThemeChanged; - } - }, - defaultValueCreator: (bindable) => - { - return ((View)bindable).themeChangeSensitive; - }); - #region Selectors internal static readonly BindableProperty BackgroundImageSelectorProperty = BindableProperty.Create("BackgroundImageSelector", typeof(Selector), typeof(View), null, propertyChanged: (bindable, oldValue, newValue) => { diff --git a/src/Tizen.NUI/src/public/BaseComponents/ViewInternal.cs b/src/Tizen.NUI/src/public/BaseComponents/ViewInternal.cs index 7a72cb6..73a469d 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/ViewInternal.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/ViewInternal.cs @@ -1071,10 +1071,6 @@ namespace Tizen.NUI.BaseComponents //Release your own managed resources here. //You should release all of your own disposable objects here. selectorData?.Reset(this); - if (themeChangeSensitive) - { - ThemeManager.ThemeChanged -= OnThemeChanged; - } } //Release your own unmanaged resources here. diff --git a/src/Tizen.NUI/src/public/Color.cs b/src/Tizen.NUI/src/public/Color.cs index 3778d54..eb8eb62 100755 --- a/src/Tizen.NUI/src/public/Color.cs +++ b/src/Tizen.NUI/src/public/Color.cs @@ -26,7 +26,7 @@ namespace Tizen.NUI /// The Color class. /// [Tizen.NUI.Binding.TypeConverter(typeof(ColorTypeConverter))] - public class Color : Disposable, ICloneable + public class Color : Disposable { /// /// Gets the black colored Color class. @@ -418,10 +418,6 @@ namespace Tizen.NUI return ret; } - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public object Clone() => new Color(this); - internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Color obj) { return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; diff --git a/src/Tizen.NUI/src/public/Extents.cs b/src/Tizen.NUI/src/public/Extents.cs index 2652b30..9ee8fd6 100755 --- a/src/Tizen.NUI/src/public/Extents.cs +++ b/src/Tizen.NUI/src/public/Extents.cs @@ -14,7 +14,6 @@ * limitations under the License. * */ -using System; using System.ComponentModel; using Tizen.NUI.Binding; @@ -25,7 +24,7 @@ namespace Tizen.NUI /// /// 4 [Binding.TypeConverter(typeof(ExtentsTypeConverter))] - public class Extents : Disposable, ICloneable + public class Extents : Disposable { @@ -228,10 +227,6 @@ namespace Tizen.NUI return ret; } - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public object Clone() => new Extents(this); - internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Extents obj) { return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; diff --git a/src/Tizen.NUI/src/public/Position.cs b/src/Tizen.NUI/src/public/Position.cs index f0060d6..bf22633 100755 --- a/src/Tizen.NUI/src/public/Position.cs +++ b/src/Tizen.NUI/src/public/Position.cs @@ -27,7 +27,7 @@ namespace Tizen.NUI /// /// 3 [Tizen.NUI.Binding.TypeConverter(typeof(PositionTypeConverter))] - public class Position : Disposable, ICloneable + public class Position : Disposable { /// @@ -826,10 +826,6 @@ namespace Tizen.NUI return ret; } - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public object Clone() => new Position(X, Y, Z); - internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Position obj) { return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; diff --git a/src/Tizen.NUI/src/public/Position2D.cs b/src/Tizen.NUI/src/public/Position2D.cs index 11204a8..48f2595 100755 --- a/src/Tizen.NUI/src/public/Position2D.cs +++ b/src/Tizen.NUI/src/public/Position2D.cs @@ -26,7 +26,7 @@ namespace Tizen.NUI /// /// 3 [Tizen.NUI.Binding.TypeConverter(typeof(Position2DTypeConverter))] - public class Position2D : Disposable, ICloneable + public class Position2D : Disposable { private Position2DChangedCallback callback = null; @@ -338,10 +338,6 @@ namespace Tizen.NUI return new Position2D((int)position.X, (int)position.Y); } - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public object Clone() => new Position2D(this); - internal static Position2D GetPosition2DFromPtr(global::System.IntPtr cPtr) { Position2D ret = new Position2D(cPtr, false); diff --git a/src/Tizen.NUI/src/public/Rectangle.cs b/src/Tizen.NUI/src/public/Rectangle.cs index 63241af..372f623 100755 --- a/src/Tizen.NUI/src/public/Rectangle.cs +++ b/src/Tizen.NUI/src/public/Rectangle.cs @@ -14,7 +14,6 @@ * limitations under the License. * */ -using System; using System.ComponentModel; using Tizen.NUI.Binding; @@ -25,7 +24,7 @@ namespace Tizen.NUI /// /// 3 [Binding.TypeConverter(typeof(RectangleTypeConverter))] - public class Rectangle : Disposable, ICloneable + public class Rectangle : Disposable { /// /// The constructor. @@ -458,10 +457,6 @@ namespace Tizen.NUI return ret; } - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public object Clone() => new Rectangle(this); - internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Rectangle obj) { return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; diff --git a/src/Tizen.NUI/src/public/Size.cs b/src/Tizen.NUI/src/public/Size.cs index 72a1014..16694f7 100755 --- a/src/Tizen.NUI/src/public/Size.cs +++ b/src/Tizen.NUI/src/public/Size.cs @@ -26,7 +26,7 @@ namespace Tizen.NUI /// /// 5 [Tizen.NUI.Binding.TypeConverter(typeof(SizeTypeConverter))] - public class Size : Disposable, ICloneable + public class Size : Disposable { /// @@ -305,10 +305,6 @@ namespace Tizen.NUI return ret; } - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public object Clone() => new Size(Width, Height, Depth); - /// /// The type cast operator, Size to Vector3. /// diff --git a/src/Tizen.NUI/src/public/Size2D.cs b/src/Tizen.NUI/src/public/Size2D.cs index 4da1854..2026762 100755 --- a/src/Tizen.NUI/src/public/Size2D.cs +++ b/src/Tizen.NUI/src/public/Size2D.cs @@ -14,9 +14,9 @@ * limitations under the License. * */ -using System; using System.ComponentModel; using Tizen.NUI.Binding; +using System.ComponentModel; namespace Tizen.NUI { @@ -25,7 +25,7 @@ namespace Tizen.NUI /// /// 3 [Tizen.NUI.Binding.TypeConverter(typeof(Size2DTypeConverter))] - public class Size2D : Disposable, ICloneable + public class Size2D : Disposable { private Size2DChangedCallback callback = null; @@ -297,10 +297,6 @@ namespace Tizen.NUI return ret; } - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public object Clone() => new Size2D(Width, Height); - internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Size2D obj) { return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; diff --git a/src/Tizen.NUI/src/public/StyleManager.cs b/src/Tizen.NUI/src/public/StyleManager.cs index c045b27..2484c1f 100755 --- a/src/Tizen.NUI/src/public/StyleManager.cs +++ b/src/Tizen.NUI/src/public/StyleManager.cs @@ -37,13 +37,6 @@ namespace Tizen.NUI private StyleChangedCallbackDelegate _styleManagerStyleChangedCallbackDelegate; /// - /// Internal use only. Do not open this API. - /// This is to get TizenFX resource path. It needs to be fixed to use application framework API in the future. - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public readonly static string FrameworkResourcePath = "/usr/share/dotnet.tizen/framework/res/"; - - /// /// Creates a StyleManager handle.
/// This can be initialized with StyleManager::Get().
///
diff --git a/src/Tizen.NUI/src/public/Theme/Theme.cs b/src/Tizen.NUI/src/public/Theme/Theme.cs deleted file mode 100644 index 1c40441..0000000 --- a/src/Tizen.NUI/src/public/Theme/Theme.cs +++ /dev/null @@ -1,229 +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; -using System.Collections; -using System.Collections.Generic; -using System.ComponentModel; -using System.Xml; -using Tizen.NUI.BaseComponents; -using Tizen.NUI.Binding; -using Tizen.NUI.Xaml; - -namespace Tizen.NUI -{ - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public class Theme : BindableObject - { - private readonly Dictionary map; - private string baseTheme; - - /// Create an empty theme. - [EditorBrowsable(EditorBrowsableState.Never)] - public Theme() - { - map = new Dictionary(); - } - - /// Create a new theme from the xaml file. - /// An absolute path to the xaml file. - /// Thrown when the given xamlFile is null or empty string. - /// Thrown when there are file IO problems. - /// Thrown when the content of the xaml file is not valid xaml form. - [EditorBrowsable(EditorBrowsableState.Never)] - public Theme(string xamlFile) : this() - { - if (string.IsNullOrEmpty(xamlFile)) - { - throw new ArgumentNullException("The xaml file path cannot be null or empty string", nameof(xamlFile)); - } - - try - { - using(var reader = XmlReader.Create(xamlFile)) - { - XamlLoader.Load(this, reader); - } - } - catch (global::System.IO.IOException e) - { - Tizen.Log.Info("NUI", $"Could not load \"{xamlFile}\".\n"); - throw e; - } - catch (Exception e) - { - Tizen.Log.Info("NUI", $"Could not parse \"{xamlFile}\".\n"); - Tizen.Log.Info("NUI", "Make sure the all used assemblies (e.g. Tizen.NUI.Components) are included in the application project.\n"); - Tizen.Log.Info("NUI", "Make sure the type and namespace are correct.\n"); - throw e; - } - } - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public string Id { get; set; } - - /// - /// For XAML. - /// The bulit-in theme id that will be used as base of this. - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public string BasedOn - { - get => baseTheme; - internal set - { - baseTheme = value; - - if (string.IsNullOrEmpty(baseTheme)) return; - - var baseThemeInstance = ThemeManager.GetBuiltinTheme(baseTheme); - - if (baseThemeInstance != null) - { - foreach (var item in baseThemeInstance) - { - var baseStyle = item.Value?.Clone(); - if (map.ContainsKey(item.Key)) - { - baseStyle.Merge(map[item.Key]); - } - map[item.Key] = baseStyle; - } - } - } - } - - /// Gets the number of steyls contained in the theme. - [EditorBrowsable(EditorBrowsableState.Never)] - public int Count => map.Count; - - /// - /// Note that it is not a normal indexer. - /// Setter will merge the new value with existing item. - /// - public ViewStyle this[string styleName] - { - get => map[styleName]; - set - { - if (map.TryGetValue(styleName, out ViewStyle style)) - { - style.Merge(value); - } - else - { - map[styleName] = value; - } - } - } - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public IEnumerator> GetEnumerator() => map.GetEnumerator(); - - /// - /// Removes all styles in the theme. - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public void Clear() => map.Clear(); - - /// - /// Determines whether the theme contains the specified style name. - /// - /// The given style name is null. - [EditorBrowsable(EditorBrowsableState.Never)] - public bool HasStyle(string styleName) => map.ContainsKey(styleName); - - /// - /// Removes the style with the specified style name. - /// - /// The given style name is null. - [EditorBrowsable(EditorBrowsableState.Never)] - public bool RemoveStyle(string styleName) => map.Remove(styleName); - - /// - /// Gets a style of given style name. - /// - /// The string key to find a ViewStyle. - /// Founded style instance. - [EditorBrowsable(EditorBrowsableState.Never)] - public ViewStyle GetStyle(string styleName) => map.ContainsKey(styleName) ? map[styleName] : null; - - /// - /// Adds the specified style name and value to the theme. - /// This replace existing value if the theme already has a style with given name. - /// - /// The style name to add. - /// The style instance to add. - [EditorBrowsable(EditorBrowsableState.Never)] - public void AddStyle(string styleName, ViewStyle value) => map[styleName] = value; - - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public object Clone() - { - var result = new Theme() - { - Id = this.Id, - }; - - foreach (var item in this) - { - result[item.Key] = item.Value?.Clone(); - } - return result; - } - - /// Merge other Theme into this. - /// An absolute path to the xaml file of the theme. - /// Thrown when the given xamlFile is null or empty string. - /// Thrown when there are file IO problems. - /// Thrown when the content of the xaml file is not valid xaml form. - [EditorBrowsable(EditorBrowsableState.Never)] - public void Merge(string xamlFile) - { - Merge(new Theme(xamlFile)); - } - - /// Merge other Theme into this. - /// The Theme. - [EditorBrowsable(EditorBrowsableState.Never)] - public void Merge(Theme theme) - { - if (theme == null) - throw new ArgumentNullException(nameof(theme)); - - foreach (var item in theme) - { - if (item.Value == null) - { - map[item.Key] = null; - } - else if (map.ContainsKey(item.Key) && !item.Value.SolidNull) - { - map[item.Key].Merge(theme.GetStyle(item.Key)); - } - else - { - map[item.Key] = theme.GetStyle(item.Key).Clone(); - } - } - } - } -} diff --git a/src/Tizen.NUI/src/public/Theme/ThemeChangedEventArgs.cs b/src/Tizen.NUI/src/public/Theme/ThemeChangedEventArgs.cs deleted file mode 100644 index 5f1c00e..0000000 --- a/src/Tizen.NUI/src/public/Theme/ThemeChangedEventArgs.cs +++ /dev/null @@ -1,40 +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; -using System.ComponentModel; - -namespace Tizen.NUI -{ - /// - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public class ThemeChangedEventArgs : EventArgs - { - /// - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public ThemeChangedEventArgs(string themeId) - { - ThemeId = themeId; - } - - /// - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public string ThemeId { get; } - } -} diff --git a/src/Tizen.NUI/src/public/Theme/ThemeManager.cs b/src/Tizen.NUI/src/public/Theme/ThemeManager.cs deleted file mode 100644 index 3d30fa0..0000000 --- a/src/Tizen.NUI/src/public/Theme/ThemeManager.cs +++ /dev/null @@ -1,269 +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. - * - */ -extern alias TizenSystemInformation; -using TizenSystemInformation.Tizen.System; -using System; -using System.Collections.Generic; -using System.ComponentModel; -using Tizen.NUI.Xaml; -using Tizen.NUI.BaseComponents; - -namespace Tizen.NUI -{ - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public static class ThemeManager - { - private enum Profile - { - Common = 0, - Mobile = 1, - TV = 2, - Wearable = 3 - } - - private static readonly string[] nuiThemeProjects = - { - "Tizen.NUI", - "Tizen.NUI.Components", - "Tizen.NUI.Wearable" - }; - - /// - /// Table that indicates deefault theme id by device profile. - /// Note that, the fallback of null value is Common value. - /// - private static readonly string[] profileDefaultTheme = - { - /* Common */ "Tizen.NUI.Theme.Common", - /* Mobile */ "Tizen.NUI.Theme.Common", - /* TV */ null, - /* Wearable */ "Tizen.NUI.Theme.Wearable", - }; - - private static Theme currentTheme; - private static List builtinThemes; // First item is default theme of the current profile. - private static bool isLoadingDefault = false; - private static Profile? currentProfile; - - /// - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public static event EventHandler ThemeChanged; - - internal static Theme CurrentTheme - { - get - { - if (currentTheme == null) - { - currentTheme = DefaultTheme; - } - return currentTheme; - } - set - { - currentTheme = value; - NotifyThemeChanged(); - } - } - - internal static Theme DefaultTheme - { - get => BuiltinThemes?[0]; - } - - private static List BuiltinThemes - { - get - { - if (builtinThemes == null && !isLoadingDefault) - { - isLoadingDefault = true; - - // Set the default theme as first item. - builtinThemes = new List - { - LoadBuiltinTheme(profileDefaultTheme[(int)CurrentProfile]) - }; - - isLoadingDefault = false; - } - return builtinThemes; - } - } - - private static Profile CurrentProfile - { - get - { - if (currentProfile == null) - { - currentProfile = Profile.Common; - string profileString = ""; - - try - { - Information.TryGetValue("tizen.org/feature/profile", out profileString); - Tizen.Log.Info("NUI", "Profile for initial theme found : " + profileString); - } - catch - { - Tizen.Log.Info("NUI", "Unknown device profile\n"); - } - finally - { - if (string.Equals(profileString, "mobile")) - { - currentProfile = Profile.Mobile; - } - else if (string.Equals(profileString, "tv")) - { - currentProfile = Profile.TV; - } - else if (string.Equals(profileString, "wearable")) - { - currentProfile = Profile.Wearable; - } - } - } - return (Profile)currentProfile; - } - } - - /// - /// Apply them to the NUI. - /// This changes look of the existing components with property on. - /// This also affects all components created afterwards. - /// - /// The theme instance to be applied. - /// The given theme is null. - [EditorBrowsable(EditorBrowsableState.Never)] - public static void ApplyTheme(Theme theme) - { - var newTheme = (Theme)theme?.Clone() ?? throw new ArgumentNullException($"Invalid theme."); - - if (string.IsNullOrEmpty(newTheme.Id)) - { - newTheme.Id = "NONAME"; - } - - CurrentTheme = newTheme; - } - - /// - /// Load a style with style name in the current theme. - /// For components, the style name is a component name (e.g. Button) in normal case. - /// - /// The style name - [EditorBrowsable(EditorBrowsableState.Never)] - public static ViewStyle GetStyle(string styleName) - { - if (styleName == null) - { - throw new ArgumentNullException(nameof(styleName)); - } - - return CurrentTheme?.GetStyle(styleName)?.Clone(); - } - - /// - /// Load a style for a View in the current theme. - /// - /// The type of View - [EditorBrowsable(EditorBrowsableState.Never)] - public static ViewStyle GetStyle(Type viewType) - { - if (viewType == null) - { - throw new ArgumentNullException(nameof(viewType)); - } - - var currentType = viewType; - ViewStyle resultStyle = null; - - do - { - if (currentType.Equals(typeof(Tizen.NUI.BaseComponents.View))) break; - resultStyle = GetStyle(currentType.Name)?.Clone(); - currentType = currentType.BaseType; - } - while (resultStyle == null && currentType != null); - - return resultStyle; - } - - /// - /// Get a cloned built-in theme. - /// - /// The built-in theme id. - [EditorBrowsable(EditorBrowsableState.Never)] - public static Theme GetBuiltinTheme(string themeId) - { - Theme result = null; - int index = BuiltinThemes.FindIndex(x => string.IsNullOrEmpty(x?.Id) && x.Id.Equals(themeId, StringComparison.OrdinalIgnoreCase)); - if (index > 0) - { - result = (Theme)BuiltinThemes[index]; - } - else - { - var theme = LoadBuiltinTheme(themeId); - BuiltinThemes.Add(theme); - result = theme; - } - return (Theme)result?.Clone(); - } - - private static Theme LoadBuiltinTheme(string id) - { - var loaded = new Theme() - { - Id = id, - }; - - if (string.IsNullOrEmpty(id)) return loaded; - - foreach (var project in nuiThemeProjects) - { - string path = StyleManager.FrameworkResourcePath + "/Theme/" + project + "_" + id + ".xaml"; - - try - { - loaded.Merge(path); - loaded.Id = id; - } - catch (XamlParseException) - { - Tizen.Log.Error("NUI", $"Could not find \"{path}\".\n"); - Tizen.Log.Error("NUI", $"The assemblies used in the file may not be included in the project.\n"); - } - catch (Exception) - { - Tizen.Log.Error("NUI", $"Could not load \"{path}\"\n"); - } - } - - return loaded; - } - - private static void NotifyThemeChanged() - { - ThemeChanged?.Invoke(null, new ThemeChangedEventArgs(CurrentTheme?.Id)); - } - } -} diff --git a/src/Tizen.NUI/src/public/Vector2.cs b/src/Tizen.NUI/src/public/Vector2.cs index f25465a..00900b5 100755 --- a/src/Tizen.NUI/src/public/Vector2.cs +++ b/src/Tizen.NUI/src/public/Vector2.cs @@ -14,7 +14,6 @@ * limitations under the License. * */ -using System; using System.ComponentModel; using Tizen.NUI.Binding; @@ -26,7 +25,7 @@ namespace Tizen.NUI ///
/// 3 [Binding.TypeConverter(typeof(Vector2TypeConverter))] - public class Vector2 : Disposable, ICloneable + public class Vector2 : Disposable { /// @@ -438,10 +437,6 @@ namespace Tizen.NUI if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public object Clone() => new Vector2(this); - /// /// Clamps the vector between minimum and maximum vectors. /// diff --git a/src/Tizen.NUI/src/public/Vector3.cs b/src/Tizen.NUI/src/public/Vector3.cs index 92f4817..bfe9afe 100755 --- a/src/Tizen.NUI/src/public/Vector3.cs +++ b/src/Tizen.NUI/src/public/Vector3.cs @@ -14,7 +14,6 @@ * limitations under the License. * */ -using System; using System.ComponentModel; using Tizen.NUI.Binding; @@ -26,7 +25,7 @@ namespace Tizen.NUI /// /// 3 [Binding.TypeConverter(typeof(Vector3TypeConverter))] - public class Vector3 : Disposable, ICloneable + public class Vector3 : Disposable { /// /// The constructor. @@ -595,10 +594,6 @@ namespace Tizen.NUI return ret; } - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public object Clone() => new Vector3(X, Y, Z); - internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Vector3 obj) { return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; diff --git a/src/Tizen.NUI/src/public/Vector4.cs b/src/Tizen.NUI/src/public/Vector4.cs index bf060c1..803a9d9 100755 --- a/src/Tizen.NUI/src/public/Vector4.cs +++ b/src/Tizen.NUI/src/public/Vector4.cs @@ -14,7 +14,6 @@ * limitations under the License. * */ -using System; using System.ComponentModel; using Tizen.NUI.Binding; @@ -26,7 +25,7 @@ namespace Tizen.NUI /// /// 3 [Binding.TypeConverter(typeof(Vector4TypeConverter))] - public class Vector4 : Disposable, ICloneable + public class Vector4 : Disposable { /// @@ -593,10 +592,6 @@ namespace Tizen.NUI if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public object Clone() => new Vector4(X, Y, Z, W); - internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Vector4 obj) { return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr; diff --git a/src/Tizen.NUI/src/public/ViewProperty/ImageShadow.cs b/src/Tizen.NUI/src/public/ViewProperty/ImageShadow.cs index 891351b..02b5bfe 100644 --- a/src/Tizen.NUI/src/public/ViewProperty/ImageShadow.cs +++ b/src/Tizen.NUI/src/public/ViewProperty/ImageShadow.cs @@ -45,7 +45,7 @@ namespace Tizen.NUI public ImageShadow(string url, Rectangle border, Vector2 offset, Vector2 extents) : base(offset, extents) { Url = url; - Border = border == null ? null : new Rectangle(border); + Border = new Rectangle(border); } /// diff --git a/src/Tizen.NUI/src/public/ViewProperty/Shadow.cs b/src/Tizen.NUI/src/public/ViewProperty/Shadow.cs index 680b010..f66964a 100644 --- a/src/Tizen.NUI/src/public/ViewProperty/Shadow.cs +++ b/src/Tizen.NUI/src/public/ViewProperty/Shadow.cs @@ -48,7 +48,7 @@ namespace Tizen.NUI public Shadow(float blurRadius, Vector2 offset, Color color, Vector2 extents) : base(offset, extents) { BlurRadius = blurRadius; - Color = color == null ? null : new Color(color); + Color = new Color(color); } /// diff --git a/src/Tizen.NUI/src/public/ViewProperty/ShadowBase.cs b/src/Tizen.NUI/src/public/ViewProperty/ShadowBase.cs index 2806e60..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 == null ? null : new Vector2(offset); - Extents = extents == null ? null : new Vector2(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 af116f8..210ff98 100755 --- a/src/Tizen.NUI/src/public/ViewProperty/TextShadow.cs +++ b/src/Tizen.NUI/src/public/ViewProperty/TextShadow.cs @@ -54,7 +54,7 @@ namespace Tizen.NUI [EditorBrowsable(EditorBrowsableState.Never)] public object Clone() { - return new TextShadow((Color)Color?.Clone(), Offset, BlurRadius); + return new TextShadow(Color, Offset, BlurRadius); } /// diff --git a/src/Tizen.NUI/src/public/Xaml/MarkupExtensions/ApplicationResourcePathExtension.cs b/src/Tizen.NUI/src/public/Xaml/MarkupExtensions/ApplicationResourcePathExtension.cs deleted file mode 100644 index cb8345b..0000000 --- a/src/Tizen.NUI/src/public/Xaml/MarkupExtensions/ApplicationResourcePathExtension.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System; -using System.ComponentModel; -using Tizen.NUI.Binding; - -namespace Tizen.NUI.Xaml -{ - /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - [ContentProperty(nameof(FilePath))] - [AcceptEmptyServiceProvider] - public class ApplicationResourcePathExtension : IMarkupExtension - { - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public ApplicationResourcePathExtension() - { - } - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public string FilePath { get; set; } - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public string ProvideValue(IServiceProvider serviceProvider) => Tizen.Applications.Application.Current.DirectoryInfo.Resource + FilePath; - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - object IMarkupExtension.ProvideValue(IServiceProvider serviceProvider) - { - return (this as IMarkupExtension).ProvideValue(serviceProvider); - } - } -} diff --git a/src/Tizen.NUI/src/public/Xaml/MarkupExtensions/NUIResourcePathExtension.cs b/src/Tizen.NUI/src/public/Xaml/MarkupExtensions/NUIResourcePathExtension.cs deleted file mode 100644 index 08e622b..0000000 --- a/src/Tizen.NUI/src/public/Xaml/MarkupExtensions/NUIResourcePathExtension.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System; -using System.ComponentModel; -using Tizen.NUI.Binding; - -namespace Tizen.NUI.Xaml -{ - /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API. - [EditorBrowsable(EditorBrowsableState.Never)] - [ContentProperty(nameof(FilePath))] - [AcceptEmptyServiceProvider] - public class NUIResourcePathExtension : IMarkupExtension - { - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public NUIResourcePathExtension() - { - } - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public string FilePath { get; set; } - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public string ProvideValue(IServiceProvider serviceProvider) => StyleManager.FrameworkResourcePath + FilePath; - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - object IMarkupExtension.ProvideValue(IServiceProvider serviceProvider) - { - return (this as IMarkupExtension).ProvideValue(serviceProvider); - } - } -} diff --git a/src/Tizen.NUI/src/public/XamlBinding/BindableObject.cs b/src/Tizen.NUI/src/public/XamlBinding/BindableObject.cs index 919aa2a..ab8b317 100755 --- a/src/Tizen.NUI/src/public/XamlBinding/BindableObject.cs +++ b/src/Tizen.NUI/src/public/XamlBinding/BindableObject.cs @@ -50,36 +50,35 @@ namespace Tizen.NUI.Binding [EditorBrowsable(EditorBrowsableState.Never)] public event PropertyChangedEventHandler PropertyChanged; - /// Whether to allow null value when . + /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] - protected static bool AllowNullCopy { get; set; } = false; - - /// Copy properties of other ViewStyle to this. - /// The other BindableProperty merge to this. - [EditorBrowsable(EditorBrowsableState.Never)] - public virtual void CopyFrom(BindableObject other) + public virtual void CopyFrom(BindableObject that) { - if (null == other) return; - - Type type1 = this.GetType(); - BindableProperty.GetBindablePropertysOfType(type1, out var nameToBindableProperty1); + if (null != that) + { + Dictionary nameToBindableProperty1; + Type type1 = this.GetType(); + BindableProperty.GetBindablePropertysOfType(type1, out nameToBindableProperty1); - Type type2 = other.GetType(); - BindableProperty.GetBindablePropertysOfType(type2, out var nameToBindableProperty2); + Dictionary nameToBindableProperty2; + Type type2 = that.GetType(); + BindableProperty.GetBindablePropertysOfType(type2, out nameToBindableProperty2); - if (null != nameToBindableProperty1) - { - foreach (KeyValuePair keyValuePair in nameToBindableProperty1) + if (null != nameToBindableProperty1) { - nameToBindableProperty2.TryGetValue(keyValuePair.Key, out var bindableProperty); - - if (null != bindableProperty) + foreach (KeyValuePair keyValuePair in nameToBindableProperty1) { - object value = other.GetValue(bindableProperty); + BindableProperty bindableProperty; + nameToBindableProperty2.TryGetValue(keyValuePair.Key, out bindableProperty); - if (AllowNullCopy || null != value) + if (null != bindableProperty) { - SetValue(keyValuePair.Value, value); + object value = that.GetValue(bindableProperty); + + if (null != value) + { + SetValue(keyValuePair.Value, value); + } } } } -- 2.7.4