1 // Copyright (c) 2024 Samsung Electronics Co., Ltd.
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
7 // http://www.apache.org/licenses/LICENSE-2.0
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
16 using System.Runtime.InteropServices;
17 using System.Collections.Generic;
19 using System.ComponentModel;
21 namespace Tizen.NUI.Visuals
24 /// Simple visual to render a solid color.
26 [EditorBrowsable(EditorBrowsableState.Never)]
27 public class ColorVisual : VisualBase
31 /// Creates an visual object.
33 [EditorBrowsable(EditorBrowsableState.Never)]
34 public ColorVisual() : this(Interop.VisualObject.VisualObjectNew(), true)
36 NDalicPINVOKE.ThrowExceptionIfExists();
39 internal ColorVisual(global::System.IntPtr cPtr, bool cMemoryOwn) : this(cPtr, cMemoryOwn, cMemoryOwn)
43 internal ColorVisual(global::System.IntPtr cPtr, bool cMemoryOwn, bool cRegister) : base(cPtr, cMemoryOwn, cRegister)
45 Type = (int)Tizen.NUI.Visual.Type.Color;
49 #region Visual Properties
51 /// Blur radius for this visual
54 /// This property will ignore BorderlineWidth property when we set BlurRadius property at least one time.
56 [EditorBrowsable(EditorBrowsableState.Never)]
57 public float BlurRadius
61 UpdateVisualProperty((int)Tizen.NUI.ColorVisualProperty.BlurRadius, new PropertyValue(value), false);
66 var propertyValue = GetCachedVisualProperty((int)Tizen.NUI.ColorVisualProperty.BlurRadius);
67 propertyValue?.Get(out ret);
73 #region Decorated Visual Properties
75 /// The radius for the rounded corners of the visual.
76 /// The values in Vector4 are used in clockwise order from top-left to bottom-left : Vector4(top-left-corner, top-right-corner, bottom-right-corner, bottom-left-corner).
77 /// Each radius will clamp internally to the half of smaller of the visual's width or height.
79 [EditorBrowsable(EditorBrowsableState.Never)]
80 public Vector4 CornerRadius
84 UpdateVisualProperty((int)Tizen.NUI.Visual.Property.CornerRadius, new PropertyValue(value), false);
88 Vector4 ret = new Vector4();
89 var propertyValue = GetCachedVisualProperty((int)Tizen.NUI.Visual.Property.CornerRadius);
90 propertyValue?.Get(ret);
96 /// Whether the CornerRadius property value is relative (percentage [0.0f to 0.5f] of the visual size) or absolute (in world units).
97 /// It is absolute by default.
98 /// When the policy is relative, the corner radius is relative to the smaller of the visual's width and height.
100 [EditorBrowsable(EditorBrowsableState.Never)]
101 public VisualTransformPolicyType CornerRadiusPolicy
105 UpdateVisualProperty((int)Tizen.NUI.Visual.Property.CornerRadiusPolicy, new PropertyValue((int)value), false);
109 int ret = (int)VisualTransformPolicyType.Absolute;
110 var propertyValue = GetCachedVisualProperty((int)Tizen.NUI.Visual.Property.CornerRadiusPolicy);
111 propertyValue?.Get(out ret);
112 return (VisualTransformPolicyType)ret;
117 /// The width for the borderline of the visual.
119 [EditorBrowsable(EditorBrowsableState.Never)]
120 public float BorderlineWidth
124 UpdateVisualProperty((int)Tizen.NUI.Visual.Property.BorderlineWidth, new PropertyValue(value), false);
129 var propertyValue = GetCachedVisualProperty((int)Tizen.NUI.Visual.Property.BorderlineWidth);
130 propertyValue?.Get(out ret);
136 /// The color for the borderline of the visual.
137 /// It is Color.Black by default.
139 [EditorBrowsable(EditorBrowsableState.Never)]
140 public Color BorderlineColor
144 UpdateVisualProperty((int)Tizen.NUI.Visual.Property.BorderlineColor, new PropertyValue(value), false);
148 Color ret = new Color(0.0f, 0.0f, 0.0f, 1.0f);
149 var propertyValue = GetCachedVisualProperty((int)Tizen.NUI.Visual.Property.BorderlineColor);
150 propertyValue?.Get(ret);
156 /// The Relative offset for the borderline of the visual.
157 /// Recommended range : [-1.0f to 1.0f].
158 /// If -1.0f, draw borderline inside of the visual.
159 /// If 1.0f, draw borderline outside of the visual.
160 /// If 0.0f, draw borderline half inside and half outside.
161 /// It is 0.0f by default.
163 [EditorBrowsable(EditorBrowsableState.Never)]
164 public float BorderlineOffset
168 UpdateVisualProperty((int)Tizen.NUI.Visual.Property.BorderlineOffset, new PropertyValue(value), false);
173 var propertyValue = GetCachedVisualProperty((int)Tizen.NUI.Visual.Property.BorderlineOffset);
174 propertyValue?.Get(out ret);