From: Bowon Ryu Date: Tue, 10 Aug 2021 06:25:27 +0000 (+0900) Subject: [NUI] Add SetShadow, GetShadow to Text Components X-Git-Tag: accepted/tizen/unified/20231205.024657~1601 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3e4fbe95f980d6751e7cf4e4b7cf2b0bc4b4deb4;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git [NUI] Add SetShadow, GetShadow to Text Components Add a Shadow struct to pass data of DALi Shadow PropertyMap. The Shadow struct can be used as an argument to SetShadow and GetShadow methods. // example var shadow = new Tizen.NUI.Text.Shadow(); shadow.Offset = new Vector2(3, 3); shadow.Color = new Color("#F1C40F"); shadow.BlurRadius = 4.0f; label.SetShadow(shadow); Signed-off-by: Bowon Ryu --- diff --git a/src/Tizen.NUI/src/public/BaseComponents/TextEditor.cs b/src/Tizen.NUI/src/public/BaseComponents/TextEditor.cs index 1404f55..61546ef 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/TextEditor.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/TextEditor.cs @@ -904,6 +904,43 @@ namespace Tizen.NUI.BaseComponents } /// + /// Set Shadow to TextEditor.
+ ///
+ /// The Shadow + /// + /// SetShadow specifies the shadow of the text through .
+ ///
+ /// + /// The following example demonstrates how to use the SetShadow method. + /// + /// var shadow = new Tizen.NUI.Text.Shadow(); + /// shadow.Offset = new Vector2(3, 3); + /// shadow.Color = new Color("#F1C40F"); + /// editor.SetShadow(shadow); + /// + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public void SetShadow(Tizen.NUI.Text.Shadow shadow) + { + SetProperty(TextEditor.Property.SHADOW, new PropertyValue(TextUtils.GetShadowMap(shadow))); + } + + /// + /// Get Shadow from TextEditor.
+ ///
+ /// The Shadow + /// + /// + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Tizen.NUI.Text.Shadow GetShadow() + { + var map = new PropertyMap(); + GetProperty(TextEditor.Property.SHADOW).Get(map); + return TextUtils.GetShadowStruct(map); + } + + /// /// The InputShadow property. /// /// 3 diff --git a/src/Tizen.NUI/src/public/BaseComponents/TextField.cs b/src/Tizen.NUI/src/public/BaseComponents/TextField.cs index 4556947..cfdd049 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/TextField.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/TextField.cs @@ -1142,6 +1142,43 @@ namespace Tizen.NUI.BaseComponents } /// + /// Set Shadow to TextField.
+ ///
+ /// The Shadow + /// + /// SetShadow specifies the shadow of the text through .
+ ///
+ /// + /// The following example demonstrates how to use the SetShadow method. + /// + /// var shadow = new Tizen.NUI.Text.Shadow(); + /// shadow.Offset = new Vector2(3, 3); + /// shadow.Color = new Color("#F1C40F"); + /// field.SetShadow(shadow); + /// + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public void SetShadow(Tizen.NUI.Text.Shadow shadow) + { + SetProperty(TextField.Property.SHADOW, new PropertyValue(TextUtils.GetShadowMap(shadow))); + } + + /// + /// Get Shadow from TextField.
+ ///
+ /// The Shadow + /// + /// + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Tizen.NUI.Text.Shadow GetShadow() + { + var map = new PropertyMap(); + GetProperty(TextField.Property.SHADOW).Get(map); + return TextUtils.GetShadowStruct(map); + } + + /// /// The InputShadow property. /// /// 3 diff --git a/src/Tizen.NUI/src/public/BaseComponents/TextLabel.cs b/src/Tizen.NUI/src/public/BaseComponents/TextLabel.cs index 0213950..7dab9c5 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/TextLabel.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/TextLabel.cs @@ -764,6 +764,44 @@ namespace Tizen.NUI.BaseComponents } /// + /// Set Shadow to TextLabel.
+ ///
+ /// The Shadow + /// + /// SetShadow specifies the shadow of the text through .
+ ///
+ /// + /// The following example demonstrates how to use the SetShadow method. + /// + /// var shadow = new Tizen.NUI.Text.Shadow(); + /// shadow.Offset = new Vector2(3, 3); + /// shadow.Color = new Color("#F1C40F"); + /// shadow.BlurRadius = 4.0f; + /// label.SetShadow(shadow); + /// + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public void SetShadow(Tizen.NUI.Text.Shadow shadow) + { + SetProperty(TextLabel.Property.SHADOW, new PropertyValue(TextUtils.GetShadowMap(shadow))); + } + + /// + /// Get Shadow from TextLabel.
+ ///
+ /// The Shadow + /// + /// + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Tizen.NUI.Text.Shadow GetShadow() + { + var map = new PropertyMap(); + GetProperty(TextLabel.Property.SHADOW).Get(map); + return TextUtils.GetShadowStruct(map); + } + + /// /// Describes a text shadow for a TextLabel. /// It is null by default. /// diff --git a/src/Tizen.NUI/src/public/BaseComponents/TextUtils.cs b/src/Tizen.NUI/src/public/BaseComponents/TextUtils.cs index 7e09557..3d1a546 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/TextUtils.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/TextUtils.cs @@ -1552,5 +1552,49 @@ namespace Tizen.NUI.BaseComponents return underline; } + /// + /// This method converts a Shadow struct to a PropertyMap and returns it. + /// The returned map can be used for set Shadow PropertyMap in the SetShadow method. + /// The Shadow struct value. + /// A PropertyMap for Shadow property. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static PropertyMap GetShadowMap(Tizen.NUI.Text.Shadow shadow) + { + var map = new PropertyMap(); + + if (shadow.Offset != null) + map.Add("offset", new PropertyValue(shadow.Offset)); + + if (shadow.Color != null) + map.Add("color", new PropertyValue(shadow.Color)); + + map.Add("blurRadius", new PropertyValue(shadow.BlurRadius)); + + return map; + } + + /// + /// This method converts a Shadow map to a struct and returns it. + /// The returned struct can be returned to the user as a Shadow in the GetShadow method. + /// The Shadow PropertyMap. + /// A Shadow struct. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static Tizen.NUI.Text.Shadow GetShadowStruct(PropertyMap map) + { + Vector2 offset = new Vector2(); + Color color = new Color(); + map.Find(0, "offset").Get(offset); + map.Find(0, "color").Get(color); + map.Find(0, "blurRadius").Get(out float blurRadius); + + var shadow = new Tizen.NUI.Text.Shadow(); + shadow.Offset = offset; + shadow.Color = color; + shadow.BlurRadius = blurRadius; + + return shadow; + } } } diff --git a/src/Tizen.NUI/src/public/Common/NUIConstants.cs b/src/Tizen.NUI/src/public/Common/NUIConstants.cs index 26dd027..e550438 100755 --- a/src/Tizen.NUI/src/public/Common/NUIConstants.cs +++ b/src/Tizen.NUI/src/public/Common/NUIConstants.cs @@ -2093,5 +2093,34 @@ namespace Tizen.NUI [EditorBrowsable(EditorBrowsableState.Never)] public float Height { get; set; } } + + /// + /// A struct to pass data of Shadow PropertyMap.
+ ///
+ /// + /// The Shadow struct is used as an argument to SetShadow and GetShadow methods.
+ /// See , , , , and .
+ ///
+ [EditorBrowsable(EditorBrowsableState.Never)] + public struct Shadow + { + /// + /// The color of the shadow (the default color is Color.Black). + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Color Color { get; set; } + + /// + /// The offset in pixels of the shadow (If not provided then the shadow is not enabled). + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public Vector2 Offset { get; set; } + + /// + /// The radius of the Gaussian blur for the soft shadow (If not provided then the soft shadow is not enabled). + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public float BlurRadius { get; set; } + } } }