From: Jiyun Yang Date: Fri, 14 Mar 2025 07:34:55 +0000 (+0900) Subject: [NUI] Remove UIColor constructor with vector4 and etc. X-Git-Tag: submit/tizen/20250401.115655~1^2~10 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=298d84ab662ee9ac6fe11ff1969a93144a4458ce;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git [NUI] Remove UIColor constructor with vector4 and etc. * Remove UIColor constructor with vector4 type. * Add predefined colors: Yellow, Cyan, Magenta, Gray Signed-off-by: Jiyun Yang --- diff --git a/src/Tizen.NUI.Extension/Markup/TextEditorExtensions.cs b/src/Tizen.NUI.Extension/Markup/TextEditorExtensions.cs index 9362ccaa3..01d56ee19 100644 --- a/src/Tizen.NUI.Extension/Markup/TextEditorExtensions.cs +++ b/src/Tizen.NUI.Extension/Markup/TextEditorExtensions.cs @@ -894,7 +894,7 @@ namespace Tizen.NUI.Extension public static UIColor TextColor(this TextEditor view) { //FIXME: we need to set UI value type directly without converting reference value. - return new UIColor(view.TextColor); + return UIColor.From(view.TextColor); } /// @@ -905,7 +905,7 @@ namespace Tizen.NUI.Extension public static UIColor PlaceholderTextColor(this TextEditor view) { //FIXME: we need to set UI value type directly without converting reference value. - return new UIColor(view.PlaceholderTextColor); + return UIColor.From(view.PlaceholderTextColor); } /// @@ -916,7 +916,7 @@ namespace Tizen.NUI.Extension public static UIColor PrimaryCursorColor(this TextEditor view) { //FIXME: we need to set UI value type directly without converting reference value. - return new UIColor(view.PrimaryCursorColor); + return UIColor.From(view.PrimaryCursorColor); } /// @@ -927,7 +927,7 @@ namespace Tizen.NUI.Extension public static UIColor SecondaryCursorColor(this TextEditor view) { //FIXME: we need to set UI value type directly without converting reference value. - return new UIColor(view.SecondaryCursorColor); + return UIColor.From(view.SecondaryCursorColor); } /// @@ -938,7 +938,7 @@ namespace Tizen.NUI.Extension public static UIColor SelectionHighlightColor(this TextEditor view) { //FIXME: we need to set UI value type directly without converting reference value. - return new UIColor(view.SelectionHighlightColor); + return UIColor.From(view.SelectionHighlightColor); } /// @@ -949,7 +949,7 @@ namespace Tizen.NUI.Extension public static UIColor InputColor(this TextEditor view) { //FIXME: we need to set UI value type directly without converting reference value. - return new UIColor(view.InputColor); + return UIColor.From(view.InputColor); } } } diff --git a/src/Tizen.NUI.Extension/Markup/TextFieldExtensions.cs b/src/Tizen.NUI.Extension/Markup/TextFieldExtensions.cs index 4afd7756a..dc8668039 100644 --- a/src/Tizen.NUI.Extension/Markup/TextFieldExtensions.cs +++ b/src/Tizen.NUI.Extension/Markup/TextFieldExtensions.cs @@ -867,7 +867,7 @@ namespace Tizen.NUI.Extension public static UIColor TextColor(this TextField view) { //FIXME: we need to set UI value type directly without converting reference value. - return new UIColor(view.TextColor); + return UIColor.From(view.TextColor); } /// @@ -878,7 +878,7 @@ namespace Tizen.NUI.Extension public static UIColor PlaceholderTextColor(this TextField view) { //FIXME: we need to set UI value type directly without converting reference value. - return new UIColor(view.PlaceholderTextColor); + return UIColor.From(view.PlaceholderTextColor); } /// @@ -889,7 +889,7 @@ namespace Tizen.NUI.Extension public static UIColor PrimaryCursorColor(this TextField view) { //FIXME: we need to set UI value type directly without converting reference value. - return new UIColor(view.PrimaryCursorColor); + return UIColor.From(view.PrimaryCursorColor); } /// @@ -900,7 +900,7 @@ namespace Tizen.NUI.Extension public static UIColor SecondaryCursorColor(this TextField view) { //FIXME: we need to set UI value type directly without converting reference value. - return new UIColor(view.SecondaryCursorColor); + return UIColor.From(view.SecondaryCursorColor); } /// @@ -911,7 +911,7 @@ namespace Tizen.NUI.Extension public static UIColor SelectionHighlightColor(this TextField view) { //FIXME: we need to set UI value type directly without converting reference value. - return new UIColor(view.SelectionHighlightColor); + return UIColor.From(view.SelectionHighlightColor); } /// @@ -922,7 +922,7 @@ namespace Tizen.NUI.Extension public static UIColor InputColor(this TextField view) { //FIXME: we need to set UI value type directly without converting reference value. - return new UIColor(view.InputColor); + return UIColor.From(view.InputColor); } } } diff --git a/src/Tizen.NUI.Extension/Markup/TextLabelExtensions.cs b/src/Tizen.NUI.Extension/Markup/TextLabelExtensions.cs index 507abb7a0..98277b68f 100644 --- a/src/Tizen.NUI.Extension/Markup/TextLabelExtensions.cs +++ b/src/Tizen.NUI.Extension/Markup/TextLabelExtensions.cs @@ -504,7 +504,7 @@ namespace Tizen.NUI.Extension public static UIColor TextColor(this TextLabel view) { //FIXME: we need to set UI value type directly without converting reference value. - return new UIColor(view.TextColor); + return UIColor.From(view.TextColor); } } } diff --git a/src/Tizen.NUI.Extension/Markup/ViewExtensions.cs b/src/Tizen.NUI.Extension/Markup/ViewExtensions.cs index 0976d2870..03b7eaa38 100644 --- a/src/Tizen.NUI.Extension/Markup/ViewExtensions.cs +++ b/src/Tizen.NUI.Extension/Markup/ViewExtensions.cs @@ -648,7 +648,7 @@ namespace Tizen.NUI.Extension var color = view.Color; //FIXME: we need to set UI value type directly without converting reference value. - return color != null ? new UIColor(color) : UIColor.Transparent; + return color != null ? UIColor.From(color) : UIColor.Transparent; } /// @@ -693,7 +693,7 @@ namespace Tizen.NUI.Extension var color = view.BorderlineColor; //FIXME: we need to set UI value type directly without converting reference value. - return color != null ? new UIColor(color) : UIColor.Transparent; + return color != null ? UIColor.From(color) : UIColor.Transparent; } } } diff --git a/src/Tizen.NUI/src/devel/Lite/UIColor.cs b/src/Tizen.NUI/src/devel/Lite/UIColor.cs index 48d7d7af0..d145dcc3c 100644 --- a/src/Tizen.NUI/src/devel/Lite/UIColor.cs +++ b/src/Tizen.NUI/src/devel/Lite/UIColor.cs @@ -46,6 +46,11 @@ namespace Tizen.NUI /// public static readonly UIColor White = new (1, 1, 1, 1); + /// + /// The gray color. + /// + public static readonly UIColor Gray = new (0.5f, 0.5f, 0.5f, 1); + /// /// The red color. /// @@ -61,6 +66,21 @@ namespace Tizen.NUI /// public static readonly UIColor Blue = new (0, 0, 1, 1); + /// + /// The yellow color. + /// + public static readonly UIColor Yellow = new (1, 1, 0, 1); + + /// + /// The cyan color. + /// + public static readonly UIColor Cyan = new (0, 1, 1, 1); + + /// + /// The magenta color. + /// + public static readonly UIColor Magenta = new (1, 0, 1, 1); + private float _r; // multiply alpha for token private float _g; // fixed alpha for token private float _b; @@ -123,10 +143,6 @@ namespace Tizen.NUI _tokenId = tokenId; } - internal UIColor(NUI.Vector4 vector4) : this(vector4.X, vector4.Y, vector4.Z, vector4.W) - { - } - /// /// Gets a value indicating whether this is default. /// @@ -231,6 +247,8 @@ namespace Tizen.NUI /// The unique identifier of the token. public static UIColor Token(string id) => new (id, 1f); + internal static UIColor From(NUI.Vector4 vector4) => new UIColor(vector4.X, vector4.Y, vector4.Z, vector4.W); + /// /// Compares two UIColor for equality. /// diff --git a/src/Tizen.NUI/src/internal/Common/Object.cs b/src/Tizen.NUI/src/internal/Common/Object.cs index c44467b7d..b9547a394 100755 --- a/src/Tizen.NUI/src/internal/Common/Object.cs +++ b/src/Tizen.NUI/src/internal/Common/Object.cs @@ -361,7 +361,7 @@ namespace Tizen.NUI vector4.Reset(); _ = Interop.View.InternalRetrievingVisualPropertyVector4(actor, visualIndex, visualPropertyIndex, vector4.SwigCPtr); NDalicPINVOKE.ThrowExceptionIfExists(); - return new UIColor(vector4); + return UIColor.From(vector4); }, actor, visualIndex, visualPropertyIndex); } diff --git a/src/Tizen.NUI/src/public/BaseComponents/ViewLiteProperty.cs b/src/Tizen.NUI/src/public/BaseComponents/ViewLiteProperty.cs index 67a2c67b5..f2addb5ec 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/ViewLiteProperty.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/ViewLiteProperty.cs @@ -80,7 +80,7 @@ namespace Tizen.NUI.BaseComponents var shadow = new Shadow(map); return new UIShadow() { - Color = new UIColor(shadow.Color), + Color = UIColor.From(shadow.Color), BlurRadius = shadow.BlurRadius, OffsetX = shadow.Offset.X, OffsetY = shadow.Offset.Y,