From: dongsug-song <35130733+dongsug-song@users.noreply.github.com> Date: Thu, 16 Apr 2020 11:57:31 +0000 (+0900) Subject: [NUI] Add Color in ViewStyle (#1545) X-Git-Tag: accepted/tizen/unified/20210219.040944~781 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=59f0ce4e1ceb630f186547e9c8b22f02edd78825;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git [NUI] Add Color in ViewStyle (#1545) --- diff --git a/src/Tizen.NUI.Components/Style/ToastStyle.cs b/src/Tizen.NUI.Components/Style/ToastStyle.cs index 61f899b..c3a6ba1 100755 --- a/src/Tizen.NUI.Components/Style/ToastStyle.cs +++ b/src/Tizen.NUI.Components/Style/ToastStyle.cs @@ -90,7 +90,7 @@ namespace Tizen.NUI.Components HeightResizePolicy = ResizePolicyType.UseNaturalSize, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, - TextColor = Color.White + TextColor = Tizen.NUI.Color.White, }; } } diff --git a/src/Tizen.NUI/src/public/BaseComponents/Style/ViewStyle.cs b/src/Tizen.NUI/src/public/BaseComponents/Style/ViewStyle.cs index 222b9a0..840c748 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/Style/ViewStyle.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/Style/ViewStyle.cs @@ -729,6 +729,20 @@ namespace Tizen.NUI.BaseComponents var viewStyle = (ViewStyle)bindable; return viewStyle.backgroundColorSelector; }); + + [EditorBrowsable(EditorBrowsableState.Never)] + public static readonly BindableProperty ColorSelectorProperty = BindableProperty.Create("ColorSelector", typeof(Selector), typeof(ViewStyle), null, propertyChanged: (bindable, oldValue, newValue) => + { + var viewStyle = (ViewStyle)bindable; + if (null == viewStyle.colorSelector) viewStyle.colorSelector = new Selector(); + viewStyle.colorSelector.Clone(null == newValue ? new Selector() : (Selector)newValue); + }, + defaultValueCreator: (bindable) => + { + var viewStyle = (ViewStyle)bindable; + return viewStyle.colorSelector; + }); + /// 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 BackgroundImageBorderSelectorProperty = BindableProperty.Create("BackgroundImageBorderSelector", typeof(Selector), typeof(ViewStyle), null, propertyChanged: (bindable, oldValue, newValue) => @@ -851,6 +865,7 @@ namespace Tizen.NUI.BaseComponents private Selector opacitySelector; private Selector backgroundColorSelector; private Selector backgroundImageBorderSelector; + private Selector colorSelector; static ViewStyle() {} @@ -1357,6 +1372,20 @@ namespace Tizen.NUI.BaseComponents set => SetValue(BackgroundColorSelectorProperty, value); } + /// + /// Color + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Selector Color + { + get + { + Selector color = (Selector)GetValue(ColorSelectorProperty); + return (null != color) ? color : colorSelector = new Selector(); + } + set => SetValue(ColorSelectorProperty, value); + } + /// View BackgroundBorder /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] diff --git a/src/Tizen.NUI/src/public/BaseComponents/View.cs b/src/Tizen.NUI/src/public/BaseComponents/View.cs index fbb9be1..e6b1495 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/View.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/View.cs @@ -2119,13 +2119,13 @@ namespace Tizen.NUI.BaseComponents { get { - Vector4 temp = new Vector4(0.0f, 0.0f, 0.0f, 0.0f); - GetProperty(Interop.ActorProperty.Actor_Property_COLOR_get()).Get(temp); + Color temp = (Color)GetValue(ColorProperty); return new Color(OnColorChanged, temp.R, temp.G, temp.B, temp.A); } set { - SetColor(value); + SetValue(ColorProperty, value); + NotifyPropertyChanged(); } } @@ -2363,6 +2363,31 @@ namespace Tizen.NUI.BaseComponents return _backgroundColorSelector; } } + + internal static readonly BindableProperty ColorSelectorProperty = BindableProperty.Create("ColorSelector", typeof(Selector), typeof(View), null, propertyChanged: (bindable, oldValue, newValue) => + { + var view = (View)bindable; + view.colorSelector.Clone((Selector)newValue); + }, + defaultValueCreator: (bindable) => + { + var view = (View)bindable; + return view.colorSelector; + }); + + private TriggerableSelector _colorSelector; + private TriggerableSelector colorSelector + { + get + { + if (null == _colorSelector) + { + _colorSelector = new TriggerableSelector(this, ColorProperty); + } + return _colorSelector; + } + } + internal static readonly BindableProperty BackgroundImageBorderSelectorProperty = BindableProperty.Create("BackgroundImageBorderSelector", typeof(Selector), typeof(View), null, propertyChanged: (bindable, oldValue, newValue) => { var view = (View)bindable; diff --git a/src/Tizen.NUI/src/public/BaseComponents/ViewBindableProperty.cs b/src/Tizen.NUI/src/public/BaseComponents/ViewBindableProperty.cs index cbc1eb6..7a0f54d 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/ViewBindableProperty.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/ViewBindableProperty.cs @@ -80,6 +80,26 @@ namespace Tizen.NUI.BaseComponents return backgroundColor; }); + /// + /// ColorProperty + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static readonly BindableProperty ColorProperty = BindableProperty.Create("Color", typeof(Color), typeof(View), null, propertyChanged: (bindable, oldValue, newValue) => + { + var view = (View)bindable; + if (newValue != null) + { + view.SetColor((Color)newValue); + } + }, + defaultValueCreator: (bindable) => + { + var view = (View)bindable; + Color color = new Color(0.0f, 0.0f, 0.0f, 0.0f); + view.GetProperty(Interop.ActorProperty.Actor_Property_COLOR_get()).Get(color); + return color; + }); + /// BackgroundImageProperty [EditorBrowsable(EditorBrowsableState.Never)] public static readonly BindableProperty BackgroundImageProperty = BindableProperty.Create("BackgroundImage", typeof(string), typeof(View), default(string), propertyChanged: (bindable, oldValue, newValue) =>