[NUI] Introduce Cutout Property (#6137)
authorChihun Jeong <50663828+ANZ1217@users.noreply.github.com>
Fri, 17 May 2024 01:12:58 +0000 (10:12 +0900)
committerEunki Hong <h.pichulia@gmail.com>
Mon, 20 May 2024 05:41:19 +0000 (14:41 +0900)
Add Cutout Property.

When Cutout is set to true, Elements such as background or shadow behind the text become transparent.
Therefore, when you adjust the transparency of text, you can see the back through the entire TextLabel.

https://review.tizen.org/gerrit/c/platform/core/uifw/dali-toolkit/+/308898
https://review.tizen.org/gerrit/c/platform/core/uifw/dali-csharp-binder/+/310591

Co-authored-by: ANZ1217 <chihun.jeong@samsung.com>
src/Tizen.NUI/src/internal/Interop/Interop.TextLabel.cs
src/Tizen.NUI/src/public/BaseComponents/TextLabel.cs
src/Tizen.NUI/src/public/BaseComponents/TextLabelBindableProperty.cs

index bc9ea2b9126a926849228b8d0bf15fb1cf1c2aef..7f6f6757f1d527926acc68a942e892bb2592df51 100755 (executable)
@@ -189,6 +189,9 @@ namespace Tizen.NUI
 
             [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_TextLabel_Property_REMOVE_BACK_INSET_get")]
             public static extern int RemoveBackInsetGet();
+
+            [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_TextLabel_Property_CUTOUT_get")]
+            public static extern int CutoutGet();
         }
     }
 }
index 7967f7cafa80d2b6b1235a153939873f0ee9a461..8a86f8c2287b600f20f7531d5eeba485f54ee08c 100755 (executable)
@@ -214,6 +214,9 @@ namespace Tizen.NUI.BaseComponents
 
                 UnderlineHeightProperty = BindableProperty.Create(nameof(UnderlineHeight), typeof(float), typeof(TextLabel), 0.0f, 
                     propertyChanged: SetInternalUnderlineHeightProperty, defaultValueCreator: GetInternalUnderlineHeightProperty);
+
+                CutoutProperty = BindableProperty.Create(nameof(Cutout), typeof(bool), typeof(TextLabel), false,
+                    propertyChanged: SetInternalCutoutProperty, defaultValueCreator: GetInternalCutoutProperty);
             }
         }
 
@@ -2461,6 +2464,53 @@ namespace Tizen.NUI.BaseComponents
             }
         }
 
+        /// <summary>
+        /// The cutout property.
+        /// </summary>
+        /// <remarks>
+        /// When Cutout is set to true, Elements such as background or shadow behind the text become transparent.<br />
+        /// Therefore, when you adjust the transparency of text, you can see the back through the entire TextLabel.<br />
+        /// It is recommended to set Cutout to false when Text's transparency is 1.<br />
+        /// </remarks>
+        /// <example>
+        /// The following example demonstrates how to use the Cutout method. <br />
+        /// Pixels in which glyph exists become transparent and the back of TextLabel become visible.<br />
+        /// <code>
+        /// TextLabel label = new TextLabel()
+        /// {
+        ///     Cutout = true,
+        ///     TextColor = new Color(0.0f, 0.0f, 0.0f, 0.0f);
+        /// };
+        /// </code>
+        /// </example>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public bool Cutout
+        {
+            get
+            {
+                if (NUIApplication.IsUsingXaml)
+                {
+                    return (bool)GetValue(CutoutProperty);
+                }
+                else
+                {
+                    return (bool)GetInternalCutoutProperty(this);
+                }
+            }
+            set
+            {
+                if (NUIApplication.IsUsingXaml)
+                {
+                    SetValue(CutoutProperty, value);
+                }
+                else
+                {
+                    SetInternalCutoutProperty(this, null, value);
+                }
+                NotifyPropertyChanged();
+            }
+        }
+
         private TextLabelSelectorData EnsureSelectorData() => selectorData ?? (selectorData = new TextLabelSelectorData());
 
         /// <summary>
@@ -2686,6 +2736,7 @@ namespace Tizen.NUI.BaseComponents
             internal static readonly int AnchorClickedColor = Interop.TextLabel.AnchorClickedColorGet();
             internal static readonly int RemoveFrontInset = Interop.TextLabel.RemoveFrontInsetGet();
             internal static readonly int RemoveBackInset = Interop.TextLabel.RemoveBackInsetGet();
+            internal static readonly int Cutout = Interop.TextLabel.CutoutGet();
 
 
             internal static void Preload()
index 072079d97b5f487be6b42f169f2718d6a748a366..7fa40904c24e4a16585629ff9a25a57f922e933d 100755 (executable)
@@ -933,6 +933,26 @@ namespace Tizen.NUI.BaseComponents
             return instance.InternalUnderlineHeight;
         }
 
+        /// <summary>
+        /// CutoutProperty
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public static readonly BindableProperty CutoutProperty = null;
+        internal static void SetInternalCutoutProperty(BindableObject bindable, object oldValue, object newValue)
+        {
+            var textLabel = (TextLabel)bindable;
+            if (newValue != null)
+            {
+                Object.InternalSetPropertyBool(textLabel.SwigCPtr, TextLabel.Property.Cutout, (bool)newValue);
+            }
+        }
+        internal static object GetInternalCutoutProperty(BindableObject bindable)
+        {
+            var textLabel = (TextLabel)bindable;
+
+            return Object.InternalGetPropertyBool(textLabel.SwigCPtr, TextLabel.Property.Cutout);
+        }
+
         internal Selector<string> TranslatableTextSelector
         {
             get => GetSelector<string>(selectorData?.TranslatableText, TextLabel.TranslatableTextProperty);