2 * Copyright(c) 2020 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 using System.ComponentModel;
24 /// The Text Shadow for TextLabel.
26 [EditorBrowsable(EditorBrowsableState.Never)]
27 public class TextShadow : ICloneable
29 private readonly PropertyMap propertyMap = null;
31 internal delegate void PropertyChangedCallback(TextShadow instance);
36 [EditorBrowsable(EditorBrowsableState.Never)]
37 public TextShadow(Color color, Vector2 offset, float blurRadius)
39 propertyMap = new PropertyMap();
42 propertyMap["color"] = PropertyValue.CreateWithGuard(Color);
45 propertyMap["offset"] = PropertyValue.CreateWithGuard(Offset);
47 BlurRadius = blurRadius;
48 propertyMap["blurRadius"] = new PropertyValue(BlurRadius);
54 [EditorBrowsable(EditorBrowsableState.Never)]
57 return new TextShadow((Color)Color?.Clone(), Offset, BlurRadius);
61 /// Deep copy method (static)
62 /// This provides nullity check.
64 [EditorBrowsable(EditorBrowsableState.Never)]
65 public static object Clone(TextShadow instance)
67 return instance == null ? null : new TextShadow(instance.Color, instance.Offset, instance.BlurRadius);
71 /// The color for the shadow of text.
73 [EditorBrowsable(EditorBrowsableState.Never)]
74 public Color Color { get; } = Color.Black;
77 /// The offset for the shadow of text.
79 [EditorBrowsable(EditorBrowsableState.Never)]
80 public Vector2 Offset { get; } = Vector2.Zero;
83 /// The blur radius of the shadow of text.
85 [EditorBrowsable(EditorBrowsableState.Never)]
86 public float BlurRadius { get; } = 0.0f;
88 internal TextShadow(PropertyMap propertyMap)
90 this.propertyMap = new PropertyMap(propertyMap);
93 internal TextShadow(TextShadow other)
95 propertyMap = new PropertyMap();
98 propertyMap["color"] = PropertyValue.CreateWithGuard(Color);
100 Offset = other.Offset;
101 propertyMap["offset"] = PropertyValue.CreateWithGuard(Offset);
103 BlurRadius = other.BlurRadius;
104 propertyMap["blurRadius"] = new PropertyValue(BlurRadius);
107 static internal PropertyValue ToPropertyValue(TextShadow instance)
109 if (instance == null)
111 return new PropertyValue();
114 return new PropertyValue(instance.propertyMap);