[NUI] Remove bindings between Style and View (#1788)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / ViewProperty / TextShadow.cs
1 /*
2  * Copyright(c) 2020 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17
18 using System;
19 using System.ComponentModel;
20
21 namespace Tizen.NUI
22 {
23     /// <summary>
24     /// The Text Shadow for TextLabel.
25     /// </summary>
26     [EditorBrowsable(EditorBrowsableState.Never)]
27     public class TextShadow : ICloneable
28     {
29         private readonly PropertyMap propertyMap = null;
30
31         internal delegate void PropertyChangedCallback(TextShadow instance);
32
33         /// <summary>
34         /// Constructor
35         /// </summary>
36         [EditorBrowsable(EditorBrowsableState.Never)]
37         public TextShadow(Color color, Vector2 offset, float blurRadius)
38         {
39             propertyMap = new PropertyMap();
40
41             Color = color;
42             propertyMap["color"] = PropertyValue.CreateWithGuard(Color);
43
44             Offset = offset;
45             propertyMap["offset"] = PropertyValue.CreateWithGuard(Offset);
46
47             BlurRadius = blurRadius;
48             propertyMap["blurRadius"] = new PropertyValue(BlurRadius);
49         }
50
51         /// <summary>
52         /// Deep copy method
53         /// </summary>
54         [EditorBrowsable(EditorBrowsableState.Never)]
55         public object Clone()
56         {
57             return new TextShadow(Color, Offset, BlurRadius);
58         }
59
60         /// <summary>
61         /// Deep copy method (static)
62         /// This provides nullity check.
63         /// </summary>
64         [EditorBrowsable(EditorBrowsableState.Never)]
65         public static object Clone(TextShadow instance)
66         {
67             return instance == null ? null : new TextShadow(instance.Color, instance.Offset, instance.BlurRadius);
68         }
69
70         /// <summary>
71         /// The color for the shadow of text.
72         /// </summary>
73         [EditorBrowsable(EditorBrowsableState.Never)]
74         public Color Color { get; } = Color.Black;
75
76         /// <summary>
77         /// The offset for the shadow of text.
78         /// </summary>
79         [EditorBrowsable(EditorBrowsableState.Never)]
80         public Vector2 Offset { get; } = Vector2.Zero;
81
82         /// <summary>
83         /// The blur radius of the shadow of text.
84         /// </summary>
85         [EditorBrowsable(EditorBrowsableState.Never)]
86         public float BlurRadius { get; } = 0.0f;
87
88         internal TextShadow(PropertyMap propertyMap)
89         {
90             this.propertyMap = new PropertyMap(propertyMap);
91         }
92
93         internal TextShadow(TextShadow other)
94         {
95             propertyMap = new PropertyMap();
96
97             Color = other.Color;
98             propertyMap["color"] = PropertyValue.CreateWithGuard(Color);
99
100             Offset = other.Offset;
101             propertyMap["offset"] = PropertyValue.CreateWithGuard(Offset);
102
103             BlurRadius = other.BlurRadius;
104             propertyMap["blurRadius"] = new PropertyValue(BlurRadius);
105         }
106
107         static internal PropertyValue ToPropertyValue(TextShadow instance)
108         {
109             if (instance == null)
110             {
111                 return new PropertyValue();
112             }
113
114             return new PropertyValue(instance.propertyMap);
115         }
116     }
117 }