From ad88ea080c5383d7d071f7e044b8c0409ad6063c Mon Sep 17 00:00:00 2001 From: Jiyun Yang Date: Fri, 31 Jan 2025 16:30:55 +0900 Subject: [PATCH] [NUI] UICorner includes the a relative flag Signed-off-by: Jiyun Yang --- .../Markup/ViewExtensions.cs | 14 +++++---- src/Tizen.NUI/src/devel/Lite/UICorner.cs | 31 +++++++++++++++++-- 2 files changed, 37 insertions(+), 8 deletions(-) diff --git a/src/Tizen.NUI.Extension/Markup/ViewExtensions.cs b/src/Tizen.NUI.Extension/Markup/ViewExtensions.cs index b81b49cbd9b..1f802fe9824 100644 --- a/src/Tizen.NUI.Extension/Markup/ViewExtensions.cs +++ b/src/Tizen.NUI.Extension/Markup/ViewExtensions.cs @@ -239,9 +239,10 @@ public static T PositionY(this T view, float y) where T : View /// The uniform corner value. /// Sets the corner radius policy to relative. The default is false. /// The view itself. + /// This sets both and at once. public static T CornerRadius(this T view, float uniform, bool isRelative = false) where T : View { - return view.CornerRadius(new UICorner(uniform, uniform, uniform, uniform), isRelative); + return view.CornerRadius(new UICorner(uniform, isRelative)); } /// @@ -255,9 +256,10 @@ public static T CornerRadius(this T view, float uniform, bool isRelative = fa /// The bottom-left value. /// Sets the corner radius policy to relative. The default is false. /// The view itself. + /// This sets both and at once. public static T CornerRadius(this T view, float topLeft, float topRight, float bottomRight, float bottomLeft, bool isRelative = false) where T : View { - return view.CornerRadius(new UICorner(topLeft, topRight, bottomRight, bottomLeft), isRelative); + return view.CornerRadius(new UICorner(topLeft, topRight, bottomRight, bottomLeft, isRelative)); } /// @@ -266,13 +268,13 @@ public static T CornerRadius(this T view, float topLeft, float topRight, floa /// The type of the view. /// The extension target. /// The corner value. - /// Sets the corner radius policy to relative. The default is false. /// The view itself. - public static T CornerRadius(this T view, UICorner corner, bool isRelative = false) where T : View + /// This sets both and at once. + public static T CornerRadius(this T view, UICorner corner) where T : View { // TODO Do not create Vector4 here view.CornerRadius = corner.ToReferenceType(); - view.CornerRadiusPolicy = isRelative ? VisualTransformPolicyType.Relative : VisualTransformPolicyType.Absolute; + view.CornerRadiusPolicy = corner.IsRelative ? VisualTransformPolicyType.Relative : VisualTransformPolicyType.Absolute; return view; } @@ -644,7 +646,7 @@ public static UICorner CornerRadius(this View view) { // TODO Do not use Vector4 here var corner = view.CornerRadius; - return new UICorner(corner.X, corner.Y, corner.Z, corner.W); + return new UICorner(corner.X, corner.Y, corner.Z, corner.W, view.CornerRadiusPolicy == VisualTransformPolicyType.Relative); } /// diff --git a/src/Tizen.NUI/src/devel/Lite/UICorner.cs b/src/Tizen.NUI/src/devel/Lite/UICorner.cs index 87c3da528cd..40d00453fd2 100644 --- a/src/Tizen.NUI/src/devel/Lite/UICorner.cs +++ b/src/Tizen.NUI/src/devel/Lite/UICorner.cs @@ -38,7 +38,27 @@ public struct UICorner /// Initializes a new instance of the struct. /// /// The uniform corner value. - public UICorner(float uniform) : this(uniform, uniform, uniform, uniform) + public UICorner(float uniform) : this(uniform, false) + { + } + + /// + /// Initializes a new instance of the struct. + /// + /// The uniform corner value. + /// Whether the values should be considered as relative to target box size. + public UICorner(float uniform, bool isRelative) : this(uniform, uniform, uniform, uniform, isRelative) + { + } + + /// + /// Initializes a new instance of the struct. + /// + /// The top-left value. + /// The top-right value. + /// The bottom-right value. + /// The bottom-left value. + public UICorner(float topLeft, float topRight, float bottomRight, float bottomLeft) : this(topLeft, topRight, bottomRight, bottomLeft, false) { } @@ -49,12 +69,14 @@ public UICorner(float uniform) : this(uniform, uniform, uniform, uniform) /// The top-right value. /// The bottom-right value. /// The bottom-left value. - public UICorner(float topLeft, float topRight, float bottomRight, float bottomLeft) + /// Whether the values should be considered as relative to target box size. + public UICorner(float topLeft, float topRight, float bottomRight, float bottomLeft, bool isRelative) { TopLeft = topLeft; TopRight = topRight; BottomRight = bottomRight; BottomLeft = bottomLeft; + IsRelative = isRelative; } /// @@ -87,6 +109,11 @@ public UICorner(float topLeft, float topRight, float bottomRight, float bottomLe /// public float BottomLeft { get; } + /// + /// Gets a value indicating whether the values are relative to target box size. + /// + public bool IsRelative { get; } + internal readonly NUI.Vector4 ToReferenceType() => new NUI.Vector4(TopLeft, TopRight, BottomRight, BottomLeft); } }