[NUI] Add ImageView.ImageColor property for Image visual's MixColor
authorEunki, Hong <eunkiki.hong@samsung.com>
Wed, 26 Jul 2023 04:00:00 +0000 (13:00 +0900)
committerEunki Hong <h.pichulia@gmail.com>
Wed, 9 Aug 2023 07:58:31 +0000 (16:58 +0900)
Add some property to control the mix color of ImageView's image visual

Signed-off-by: Eunki, Hong <eunkiki.hong@samsung.com>
src/Tizen.NUI/src/public/BaseComponents/ImageView.cs
src/Tizen.NUI/src/public/BaseComponents/ImageViewBindableProperty.cs

index 95ecb53..352b3de 100755 (executable)
@@ -66,6 +66,7 @@ namespace Tizen.NUI.BaseComponents
             ImageVisualProperty.WrapModeU,
             ImageVisualProperty.WrapModeV,
             ImageVisualProperty.SynchronousLoading,
+            Visual.Property.MixColor,
             Visual.Property.PremultipliedAlpha,
             ImageVisualProperty.OrientationCorrection,
             ImageVisualProperty.FastTrackUploading,
@@ -1278,6 +1279,39 @@ namespace Tizen.NUI.BaseComponents
             }
         }
 
+        /// <summary>
+        /// The mixed color value for the image.
+        /// </summary>
+        /// <remarks>
+        /// <para>
+        /// The property cascade chaining set is not recommended.
+        /// </para>
+        /// </remarks>
+        /// <example>
+        /// This way is recommended for setting the property
+        /// <code>
+        /// var imageView = new ImageView();
+        /// imageView.ImageColor = new Color(0.5f, 0.1f, 0.0f, 1.0f);
+        /// </code>
+        /// This way to set the property is prohibited
+        /// <code>
+        /// imageView.ImageColor.R = 0.5f; //This does not guarantee a proper operation
+        /// </code>
+        /// </example>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public Color ImageColor
+        {
+            get
+            {
+                return (Color)GetValue(ImageColorProperty);
+            }
+            set
+            {
+                SetValue(ImageColorProperty, value);
+                NotifyPropertyChanged();
+            }
+        }
+
         internal Selector<string> ResourceUrlSelector
         {
             get => GetSelector<string>(resourceUrlSelector, ImageView.ResourceUrlProperty);
index a312065..5ea4767 100755 (executable)
@@ -579,5 +579,27 @@ namespace Tizen.NUI.BaseComponents
             var imageView = (ImageView)bindable;
             return Object.InternalGetPropertyBool(imageView.SwigCPtr, ImageView.Property.TransitionEffect);
         }));
+
+        /// <summary>
+        /// ImageColorProperty
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public static readonly BindableProperty ImageColorProperty = BindableProperty.Create(nameof(ImageColor), typeof(Color), typeof(ImageView), null, propertyChanged: (bindable, oldValue, newValue) =>
+        {
+            var imageView = (ImageView)bindable;
+            if (newValue != null)
+            {
+                imageView.UpdateImage(Visual.Property.MixColor, new PropertyValue((Color)newValue));
+            }
+        },
+        defaultValueCreator: (bindable) =>
+        {
+            var imageView = (ImageView)bindable;
+            Color ret = new Color();
+
+            imageView.GetCachedImageVisualProperty(Visual.Property.MixColor)?.Get(ret);
+
+            return ret;
+        });
     }
 }