[NUI] Add RenderMode to TextLabel
authorBowon Ryu <bowon.ryu@samsung.com>
Wed, 10 Jul 2024 11:05:33 +0000 (20:05 +0900)
committerJiyun Yang <ji.yang@samsung.com>
Wed, 21 Aug 2024 06:10:37 +0000 (15:10 +0900)
Sync : default, synchronous text loading.
AsyncAuto : automatically requests an asynchronous text load in OnRelayout.
AsyncManual : users should manually request rendering using the async text method.

All text rendering processes (update/layout/render) are performed asynchronously in AsyncAuto and AsyncManual.

Removed unnecessary properties.

Signed-off-by: Bowon Ryu <bowon.ryu@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
src/Tizen.NUI/src/public/Common/NUIConstants.cs

index 48849662d907d5108d0a16193916b06d1c033ff4..bbb09ebdcbf0511e278126775e4e7b4871218890 100755 (executable)
@@ -193,6 +193,9 @@ namespace Tizen.NUI
             [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_TextLabel_Property_CUTOUT_get")]
             public static extern int CutoutGet();
 
+            [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_TextLabel_Property_RENDER_MODE_get")]
+            public static extern int RenderModeGet();
+
             [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_TextLabel_RequestAsyncRenderWithFixedSize")]
             public static extern void RequestAsyncRenderWithFixedSize(global::System.Runtime.InteropServices.HandleRef textLabelRef, float width, float height);
 
index f3e0a8b54718d2e1b2609c4363891e7c6ab9a0fe..16c0022a91496145d712f48cecd02f442f02ee2f 100755 (executable)
@@ -217,6 +217,9 @@ namespace Tizen.NUI.BaseComponents
 
                 CutoutProperty = BindableProperty.Create(nameof(Cutout), typeof(bool), typeof(TextLabel), false,
                     propertyChanged: SetInternalCutoutProperty, defaultValueCreator: GetInternalCutoutProperty);
+
+                RenderModeProperty = BindableProperty.Create(nameof(RenderMode), typeof(TextRenderMode), typeof(TextLabel), TextRenderMode.Sync,
+                    propertyChanged: SetInternalRenderModeProperty, defaultValueCreator: GetInternalRenderModeProperty);
             }
         }
 
@@ -326,7 +329,7 @@ namespace Tizen.NUI.BaseComponents
         /// <param name="width">The width of text to render.</param>
         /// <param name="height">The height of text to render.</param>
         /// <remarks>
-        /// Only works when AsyncLoad is true.
+        /// Only works when AsyncMode.
         /// </remarks>
         [EditorBrowsable(EditorBrowsableState.Never)]
         public void RequestAsyncRenderWithFixedSize(float width, float height)
@@ -341,7 +344,7 @@ namespace Tizen.NUI.BaseComponents
         /// <param name="width">The width of text to render.</param>
         /// <param name="heightConstraint">The maximum available height of text to render.</param>
         /// <remarks>
-        /// Only works when AsyncLoad is true.<br />
+        /// Only works when AsyncMode.<br />
         /// The height is determined by the content of the text when rendered with the given width.<br />
         /// The result will be the same as the height returned by GetHeightForWidth.
         /// If the heightConstraint is given, the maximum height will be the heightConstraint.
@@ -2563,6 +2566,44 @@ namespace Tizen.NUI.BaseComponents
             }
         }
 
+        /// <summary>
+        /// The RenderMode property.
+        /// </summary>
+        /// <remarks>
+        /// Sync : default, synchronous text loading.<br />
+        /// AsyncAuto : automatically requests an asynchronous text load in OnRelayout.<br />
+        /// AsyncManual : users should manually request rendering using the async text method.<br />
+        /// All text rendering processes (update/layout/render) are performed asynchronously in AsyncAuto and AsyncManual.
+        /// </remarks>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public TextRenderMode RenderMode
+        {
+            get
+            {
+                if (NUIApplication.IsUsingXaml)
+                {
+                    return (TextRenderMode)GetValue(RenderModeProperty);
+                }
+                else
+                {
+                    return (TextRenderMode)GetInternalRenderModeProperty(this);
+                }
+            }
+            set
+            {
+                if (NUIApplication.IsUsingXaml)
+                {
+                    SetValue(RenderModeProperty, value);
+                }
+                else
+                {
+                    SetInternalRenderModeProperty(this, null, value);
+                }
+                NotifyPropertyChanged();
+            }
+        }
+
+
         private TextLabelSelectorData EnsureSelectorData() => selectorData ?? (selectorData = new TextLabelSelectorData());
 
         /// <summary>
@@ -2789,6 +2830,7 @@ namespace Tizen.NUI.BaseComponents
             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 readonly int RenderMode = Interop.TextLabel.RenderModeGet();
 
 
             internal static void Preload()
index 7fa40904c24e4a16585629ff9a25a57f922e933d..1e94fac9b740ed5c9d583ce9f5c95a4f5b147a42 100755 (executable)
@@ -953,6 +953,26 @@ namespace Tizen.NUI.BaseComponents
             return Object.InternalGetPropertyBool(textLabel.SwigCPtr, TextLabel.Property.Cutout);
         }
 
+        /// <summary>
+        /// RenderModeProperty
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public static readonly BindableProperty RenderModeProperty = null;
+        internal static void SetInternalRenderModeProperty(BindableObject bindable, object oldValue, object newValue)
+        {
+            var textLabel = (TextLabel)bindable;
+            if (newValue != null)
+            {
+                Object.InternalSetPropertyInt(textLabel.SwigCPtr, TextLabel.Property.RenderMode, (int)newValue);
+            }
+        }
+        internal static object GetInternalRenderModeProperty(BindableObject bindable)
+        {
+            var textLabel = (TextLabel)bindable;
+
+            return (TextRenderMode)Object.InternalGetPropertyInt(textLabel.SwigCPtr, TextLabel.Property.RenderMode);
+        }
+
         internal Selector<string> TranslatableTextSelector
         {
             get => GetSelector<string>(selectorData?.TranslatableText, TextLabel.TranslatableTextProperty);
index 0ece9f70b8f871785f376693e8a9abc445161718..65523d4d70a455471b44082db50110fa3ed69228 100755 (executable)
@@ -2207,6 +2207,28 @@ namespace Tizen.NUI
         PixelSize
     }
 
+    /// <summary>
+    /// Enumeration for the render mode of text.
+    /// </summary>
+    [EditorBrowsable(EditorBrowsableState.Never)]
+    public enum TextRenderMode
+    {
+        /// <summary>
+        /// default, synchronous text loading.
+        /// </summary>
+        Sync,
+
+        /// <summary>
+        /// automatically requests an asynchronous text load in OnRelayout.
+        /// </summary>
+        AsyncAuto,
+
+        /// <summary>
+        /// users should manually request rendering using the async text method.
+        /// </summary>
+        AsyncManual
+    }
+
     /// <summary>
     /// Pre-defined SlideTransition Direction
     /// </summary>