[NUI] Add SetOutline, GetOutline to Text Components
authorBowon Ryu <bowon.ryu@samsung.com>
Tue, 10 Aug 2021 07:13:07 +0000 (16:13 +0900)
committerdongsug-song <35130733+dongsug-song@users.noreply.github.com>
Wed, 18 Aug 2021 03:10:44 +0000 (12:10 +0900)
Add a Outline struct to pass data of DALi Outline PropertyMap.
The Outline struct can be used as an argument to
SetOutline and GetOutline methods.

// example
var outline = new Tizen.NUI.Text.Outline();
outline.Width = 2.0f;
outline.Color = new Color("#45B39D");
label.SetOutline(outline);

Signed-off-by: Bowon Ryu <bowon.ryu@samsung.com>
src/Tizen.NUI/src/public/BaseComponents/TextEditor.cs
src/Tizen.NUI/src/public/BaseComponents/TextField.cs
src/Tizen.NUI/src/public/BaseComponents/TextLabel.cs
src/Tizen.NUI/src/public/BaseComponents/TextUtils.cs
src/Tizen.NUI/src/public/Common/NUIConstants.cs

index 61546ef..398cf6e 100755 (executable)
@@ -1014,6 +1014,43 @@ namespace Tizen.NUI.BaseComponents
         }
 
         /// <summary>
+        /// Set Outline to TextEditor. <br />
+        /// </summary>
+        /// <param name="outline">The Outline</param>
+        /// <remarks>
+        /// SetOutline specifies the outline of the text through <see cref="Tizen.NUI.Text.Outline"/>. <br />
+        /// </remarks>
+        /// <example>
+        /// The following example demonstrates how to use the SetOutline method.
+        /// <code>
+        /// var outline = new Tizen.NUI.Text.Outline();
+        /// outline.Width = 2.0f;
+        /// outline.Color = new Color("#45B39D");
+        /// editor.SetOutline(outline);
+        /// </code>
+        /// </example>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public void SetOutline(Outline outline)
+        {
+            SetProperty(TextEditor.Property.OUTLINE, new PropertyValue(TextUtils.GetOutlineMap(outline)));
+        }
+
+        /// <summary>
+        /// Get Outline from TextEditor. <br />
+        /// </summary>
+        /// <returns>The Outline</returns>
+        /// <remarks>
+        /// <see cref="Tizen.NUI.Text.Outline"/>
+        /// </remarks>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public Outline GetOutline()
+        {
+            var map = new PropertyMap();
+            GetProperty(TextEditor.Property.OUTLINE).Get(map);
+            return TextUtils.GetOutlineStruct(map);
+        }
+
+        /// <summary>
         /// The InputOutline property.
         /// </summary>
         /// <since_tizen> 3 </since_tizen>
index cfdd049..e24d9ee 100755 (executable)
@@ -1252,6 +1252,43 @@ namespace Tizen.NUI.BaseComponents
         }
 
         /// <summary>
+        /// Set Outline to TextField. <br />
+        /// </summary>
+        /// <param name="outline">The Outline</param>
+        /// <remarks>
+        /// SetOutline specifies the outline of the text through <see cref="Tizen.NUI.Text.Outline"/>. <br />
+        /// </remarks>
+        /// <example>
+        /// The following example demonstrates how to use the SetOutline method.
+        /// <code>
+        /// var outline = new Tizen.NUI.Text.Outline();
+        /// outline.Width = 2.0f;
+        /// outline.Color = new Color("#45B39D");
+        /// field.SetOutline(outline);
+        /// </code>
+        /// </example>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public void SetOutline(Outline outline)
+        {
+            SetProperty(TextField.Property.OUTLINE, new PropertyValue(TextUtils.GetOutlineMap(outline)));
+        }
+
+        /// <summary>
+        /// Get Outline from TextField. <br />
+        /// </summary>
+        /// <returns>The Outline</returns>
+        /// <remarks>
+        /// <see cref="Tizen.NUI.Text.Outline"/>
+        /// </remarks>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public Outline GetOutline()
+        {
+            var map = new PropertyMap();
+            GetProperty(TextField.Property.OUTLINE).Get(map);
+            return TextUtils.GetOutlineStruct(map);
+        }
+
+        /// <summary>
         /// The InputOutline property.
         /// </summary>
         /// <since_tizen> 3 </since_tizen>
index 7dab9c5..872ae7d 100755 (executable)
@@ -861,6 +861,43 @@ namespace Tizen.NUI.BaseComponents
         }
 
         /// <summary>
+        /// Set Outline to TextLabel. <br />
+        /// </summary>
+        /// <param name="outline">The Outline</param>
+        /// <remarks>
+        /// SetOutline specifies the outline of the text through <see cref="Tizen.NUI.Text.Outline"/>. <br />
+        /// </remarks>
+        /// <example>
+        /// The following example demonstrates how to use the SetOutline method.
+        /// <code>
+        /// var outline = new Tizen.NUI.Text.Outline();
+        /// outline.Width = 2.0f;
+        /// outline.Color = new Color("#45B39D");
+        /// label.SetOutline(outline);
+        /// </code>
+        /// </example>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public void SetOutline(Outline outline)
+        {
+            SetProperty(TextLabel.Property.OUTLINE, new PropertyValue(TextUtils.GetOutlineMap(outline)));
+        }
+
+        /// <summary>
+        /// Get Outline from TextLabel. <br />
+        /// </summary>
+        /// <returns>The Outline</returns>
+        /// <remarks>
+        /// <see cref="Tizen.NUI.Text.Outline"/>
+        /// </remarks>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public Outline GetOutline()
+        {
+            var map = new PropertyMap();
+            GetProperty(TextLabel.Property.OUTLINE).Get(map);
+            return TextUtils.GetOutlineStruct(map);
+        }
+
+        /// <summary>
         /// The PixelSize property.<br />
         /// The size of font in pixels.<br />
         /// </summary>
index 3d1a546..a165137 100755 (executable)
@@ -1596,5 +1596,44 @@ namespace Tizen.NUI.BaseComponents
 
             return shadow;
         }
+
+        /// <summary>
+        /// This method converts a Outline struct to a PropertyMap and returns it.
+        /// The returned map can be used for set Outline PropertyMap in the SetOutline method.
+        /// <param name="outline">The Outline struct value.</param>
+        /// <returns> A PropertyMap for Outline property. </returns>
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public static PropertyMap GetOutlineMap(Outline outline)
+        {
+            var map = new PropertyMap();
+
+            if (outline.Color != null)
+                map.Add("color", new PropertyValue(outline.Color));
+
+            map.Add("width", new PropertyValue(outline.Width));
+
+            return map;
+        }
+
+        /// <summary>
+        /// This method converts a Outline map to a struct and returns it.
+        /// The returned struct can be returned to the user as a Outline in the GetOutline method.
+        /// <param name="map">The Outline PropertyMap.</param>
+        /// <returns> A Outline struct. </returns>
+        /// </summary>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public static Outline GetOutlineStruct(PropertyMap map)
+        {
+            Color color = new Color();
+            map.Find(0, "color").Get(color);
+            map.Find(0, "width").Get(out float width);
+
+            var outline = new Outline();
+            outline.Color = color;
+            outline.Width = width;
+
+            return outline;
+        }
     }
 }
index e550438..f57c096 100755 (executable)
@@ -2122,5 +2122,28 @@ namespace Tizen.NUI
             [EditorBrowsable(EditorBrowsableState.Never)]
             public float BlurRadius { get; set; }
         }
+
+        /// <summary>
+        /// A struct to pass data of Outline PropertyMap. <br />
+        /// </summary>
+        /// <remarks>
+        /// The Outline struct is used as an argument to SetOutline and GetOutline methods. <br />
+        /// See <see cref="Tizen.NUI.BaseComponents.TextLabel.SetOutline"/>, <see cref="Tizen.NUI.BaseComponents.TextLabel.GetOutline"/>, <see cref="Tizen.NUI.BaseComponents.TextField.SetOutline"/>, <see cref="Tizen.NUI.BaseComponents.TextField.GetOutline"/>, <see cref="Tizen.NUI.BaseComponents.TextEditor.SetOutline"/> and <see cref="Tizen.NUI.BaseComponents.TextEditor.GetOutline"/>. <br />
+        /// </remarks>
+        [EditorBrowsable(EditorBrowsableState.Never)]
+        public struct Outline
+        {
+            /// <summary>
+            /// The color of the outline (the default color is Color.White).
+            /// </summary>
+            [EditorBrowsable(EditorBrowsableState.Never)]
+            public Color Color { get; set; }
+
+            /// <summary>
+            /// The width in pixels of the outline (If not provided then the outline is not enabled).
+            /// </summary>
+            [EditorBrowsable(EditorBrowsableState.Never)]
+            public float Width { get; set; }
+        }
     }
 }