[NUI] Add Color in ViewStyle (#1545)
authordongsug-song <35130733+dongsug-song@users.noreply.github.com>
Thu, 16 Apr 2020 11:57:31 +0000 (20:57 +0900)
committerGitHub <noreply@github.com>
Thu, 16 Apr 2020 11:57:31 +0000 (20:57 +0900)
src/Tizen.NUI.Components/Style/ToastStyle.cs
src/Tizen.NUI/src/public/BaseComponents/Style/ViewStyle.cs
src/Tizen.NUI/src/public/BaseComponents/View.cs
src/Tizen.NUI/src/public/BaseComponents/ViewBindableProperty.cs

index 61f899b..c3a6ba1 100755 (executable)
@@ -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,
             };
         }
     }
index 222b9a0..840c748 100755 (executable)
@@ -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<Color>), typeof(ViewStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
+        {
+            var viewStyle = (ViewStyle)bindable;
+            if (null == viewStyle.colorSelector) viewStyle.colorSelector = new Selector<Color>();
+            viewStyle.colorSelector.Clone(null == newValue ? new Selector<Color>() : (Selector<Color>)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<Rectangle>), typeof(ViewStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
@@ -851,6 +865,7 @@ namespace Tizen.NUI.BaseComponents
         private Selector<float?> opacitySelector;
         private Selector<Color> backgroundColorSelector;
         private Selector<Rectangle> backgroundImageBorderSelector;
+        private Selector<Color> colorSelector;
 
         static ViewStyle() {}
 
@@ -1357,6 +1372,20 @@ namespace Tizen.NUI.BaseComponents
             set => SetValue(BackgroundColorSelectorProperty, value);
         }
 
+        /// <summary>
+        /// Color
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public Selector<Color> Color
+        {
+            get
+            {
+                Selector<Color> color = (Selector<Color>)GetValue(ColorSelectorProperty);
+                return (null != color) ? color : colorSelector = new Selector<Color>();
+            }
+            set => SetValue(ColorSelectorProperty, value);
+        }
+
         /// <summary>View BackgroundBorder</summary>
         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
         [EditorBrowsable(EditorBrowsableState.Never)]
index fbb9be1..e6b1495 100755 (executable)
@@ -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<Color>), typeof(View), null, propertyChanged: (bindable, oldValue, newValue) =>
+        {
+            var view = (View)bindable;
+            view.colorSelector.Clone((Selector<Color>)newValue);
+        },
+        defaultValueCreator: (bindable) =>
+        {
+            var view = (View)bindable;
+            return view.colorSelector;
+        });
+
+        private TriggerableSelector<Color> _colorSelector;
+        private TriggerableSelector<Color> colorSelector
+        {
+            get
+            {
+                if (null == _colorSelector)
+                {
+                    _colorSelector = new TriggerableSelector<Color>(this, ColorProperty);
+                }
+                return _colorSelector;
+            }
+        }
+
         internal static readonly BindableProperty BackgroundImageBorderSelectorProperty = BindableProperty.Create("BackgroundImageBorderSelector", typeof(Selector<Rectangle>), typeof(View), null, propertyChanged: (bindable, oldValue, newValue) =>
         {
             var view = (View)bindable;
index cbc1eb6..7a0f54d 100755 (executable)
@@ -80,6 +80,26 @@ namespace Tizen.NUI.BaseComponents
             return backgroundColor;
         });
 
+        /// <summary>
+        /// ColorProperty
+        /// </summary>
+        [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;
+        });
+
         /// <summary> BackgroundImageProperty </summary>
         [EditorBrowsable(EditorBrowsableState.Never)]
         public static readonly BindableProperty BackgroundImageProperty = BindableProperty.Create("BackgroundImage", typeof(string), typeof(View), default(string), propertyChanged: (bindable, oldValue, newValue) =>