[NUI] Add StartOffset of GradientVisual
authorChihun Jeong <50663828+ANZ1217@users.noreply.github.com>
Thu, 8 May 2025 05:01:01 +0000 (14:01 +0900)
committertscholb <scholb.kim@samsung.com>
Thu, 8 May 2025 07:09:13 +0000 (16:09 +0900)
### Description of Change ###
Add StartOffset of GradientVisual.
Start offset is the offset value that shifts the starting position of the gradient.
0.0 is start position of gradient, 1.0 is end position of gradient.
It is possible to set the startOffset outside the [0, 1] range.
For example, you can animate it from 0.5 to 1.5.

How to use:
Animation anim = new Animation(1000);
anim.AnimateTo(bgView, "gradient.StartOffset", 1.0f);
anim.Play();

src/Tizen.NUI/src/internal/Common/PropertyHelper.cs
src/Tizen.NUI/src/internal/Interop/Interop.GradientVisual.cs
src/Tizen.NUI/src/internal/NativeBinding/NDalic.cs
src/Tizen.NUI/src/internal/XamlBinding/NUIConstantExtension.cs
src/Tizen.NUI/src/public/Visuals/GradientVisual.cs
src/Tizen.NUI/src/public/Visuals/VisualConstants.cs

index f5a23b5bbe3907916690176b097bd94819b313d5..6efae8ec4656cf8b38d73ae959c9d601d6d58f85 100755 (executable)
@@ -53,6 +53,7 @@ namespace Tizen.NUI
             { "imageShadow.Offset",         new VisualPropertyData(View.Property.SHADOW, (int)VisualTransformPropertyType.Offset) },
             { "shadow.CornerRadius",        new VisualPropertyData(View.Property.SHADOW, Visual.Property.CornerRadius, ObjectIntToFloat) },
             { "shadow.CornerSquareness",    new VisualPropertyData(View.Property.SHADOW, Visual.Property.CornerSquareness, ObjectIntToFloat) },
+            { "gradient.StartOffset",       new VisualPropertyData(View.Property.BACKGROUND, GradientVisualProperty.StartOffset, ObjectIntToFloat) },
         };
         private static readonly Dictionary<string, VisualPropertyData> visualPropertyUpperCaseTable = new Dictionary<string, VisualPropertyData>()
         {
index 5bddf63600ad54903bc80a5c934c907ff7650c85..bc3ec58464192b994cee6a5e7d347a37038dfa96 100755 (executable)
@@ -44,6 +44,8 @@ namespace Tizen.NUI
 
             [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_GRADIENT_VISUAL_SPREAD_METHOD_get")]
             public static extern int GradientVisualSpreadMethodGet();
+            [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_GRADIENT_VISUAL_START_OFFSET_get")]
+            public static extern int GradientVisualStartOffsetGet();
         }
     }
 }
index 8e0d37d0f0c58b181a9f6f1c2fe55c9bfcd7d301..63cb73344e4b126a0ea1aa28ee86fe97dbd14c85 100755 (executable)
@@ -367,6 +367,7 @@ namespace Tizen.NUI
         internal static readonly int GradientVisualStopColor = Interop.NDalicGradientVisual.GradientVisualStopColorGet();
         internal static readonly int GradientVisualUnits = Interop.NDalicGradientVisual.GradientVisualUnitsGet();
         internal static readonly int GradientVisualSpreadMethod = Interop.NDalicGradientVisual.GradientVisualSpreadMethodGet();
+        internal static readonly int GradientVisualStartOffset = Interop.NDalicGradientVisual.GradientVisualStartOffsetGet();
 
         internal static readonly int ImageVisualUrl = Interop.NDalicImageVisual.ImageVisualUrlGet();
         internal static readonly int ImageVisualAlphaMaskUrl = Interop.NDalicImageVisual.ImageVisualAlphaMaskUrlGet();
index c01744d506c398a66249c252b8e0a7d0b79f90cb..8ddc5b48eb3bc443564db5634e3518be10a51c41 100755 (executable)
@@ -54,6 +54,7 @@ namespace Tizen.NUI.Binding
             { "GradientVisualProperty.StopColor", GradientVisualProperty.StopColor },
             { "GradientVisualProperty.Units", GradientVisualProperty.Units },
             { "GradientVisualProperty.SpreadMethod", GradientVisualProperty.SpreadMethod },
+            { "GradientVisualProperty.StartOffset", GradientVisualProperty.StartOffset },
             // ImageVisualProperty
             { "ImageVisualProperty.URL", ImageVisualProperty.URL },
             { "ImageVisualProperty.AlphaMaskURL", ImageVisualProperty.AlphaMaskURL },
index 1eaaf2c175c086802f82c29bed666d6fd7782140..95a0dedda33b15664a5c2d836ac9dd2aa25d05a6 100755 (executable)
@@ -15,6 +15,8 @@
  *
  */
 
+using System.ComponentModel;
+
 namespace Tizen.NUI
 {
     /// <summary>
@@ -31,6 +33,7 @@ namespace Tizen.NUI
         private PropertyArray _stopColor;
         private GradientVisualUnitsType? _units;
         private GradientVisualSpreadMethodType? _spreadMethod;
+        private float? _startOffset;
 
         /// <summary>
         /// Default constructor of GradientVisual.
@@ -190,6 +193,25 @@ namespace Tizen.NUI
             }
         }
 
+        /// <summary>
+        /// Gets or sets the gradient's start position offset.<br />
+        /// If not supplied, the default is 0.0f.<br />
+        /// Optional.
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public float StartOffset
+        {
+            get
+            {
+                return _startOffset ?? (0.0f);
+            }
+            set
+            {
+                _startOffset = value;
+                UpdateVisual();
+            }
+        }
+
         /// <summary>
         /// Compose the out visual map.
         /// </summary>
@@ -236,6 +258,11 @@ namespace Tizen.NUI
                 {
                     _outputVisualMap.Add(GradientVisualProperty.SpreadMethod, (int)_spreadMethod);
                 }
+
+                if (_startOffset != null)
+                {
+                    _outputVisualMap.Add(GradientVisualProperty.StartOffset, (float)_startOffset);
+                }
                 base.ComposingPropertyMap();
             }
         }
index f2e1436fa219d0c38675783f9100e75f655ae637..e8492afa36cdeccc12ba2540e712cf6da548394a 100755 (executable)
@@ -753,6 +753,11 @@ namespace Tizen.NUI
         /// </summary>
         /// <since_tizen> 3 </since_tizen>
         public static readonly int SpreadMethod = NDalic.GradientVisualSpreadMethod;
+        /// <summary>
+        /// Sets the gradient's start position offset.
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public static readonly int StartOffset = NDalic.GradientVisualStartOffset;
     }
 
     /// <summary>