7506ae2de6a5237df57d5559c82bfcfb5f14fba2
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / Visuals / ArcVisual.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 using System.ComponentModel;
18
19 namespace Tizen.NUI
20 {
21     /// <summary>
22     /// A class encapsulating the property map of the arc visual.
23     /// </summary>
24     [EditorBrowsable(EditorBrowsableState.Never)]
25     public class ArcVisual : VisualMap
26     {
27         #region Fields
28
29         private float thickness;
30         private float startAngle;
31         private float sweepAngle;
32         private CapType cap;
33
34         #endregion Fields
35
36
37         #region Constructors
38
39         /// <summary>
40         /// Constructor.
41         /// </summary>
42         [EditorBrowsable(EditorBrowsableState.Never)]
43         public ArcVisual() : base()
44         {
45         }
46
47         #endregion Constructors
48
49
50         #region Enums
51
52         /// <summary>
53         /// Enumeration for the cap style of the arc line.
54         /// </summary>
55         [EditorBrowsable(EditorBrowsableState.Never)]
56         public enum CapType
57         {
58             /// <summary>
59             /// The arc does not extend beyond its two endpoints.
60             /// </summary>
61             [EditorBrowsable(EditorBrowsableState.Never)]
62             Butt,
63
64             /// <summary>
65             /// The arc will be extended by a half circle with the center at the end.
66             /// </summary>
67             [EditorBrowsable(EditorBrowsableState.Never)]
68             Round,
69         }
70
71         #endregion Enums
72
73
74         #region Properties
75
76         /// <summary>
77         /// The thickness of the arc.
78         /// </summary>
79         [EditorBrowsable(EditorBrowsableState.Never)]
80         public float Thickness
81         {
82             get => thickness;
83             set
84             {
85                 thickness = value;
86                 UpdateVisual();
87             }
88         }
89
90         /// <summary>
91         /// The start angle where the arc begins in degrees.
92         /// </summary>
93         [EditorBrowsable(EditorBrowsableState.Never)]
94         public float StartAngle
95         {
96             get => startAngle;
97             set
98             {
99                 startAngle = value;
100                 UpdateVisual();
101             }
102         }
103
104         /// <summary>
105         /// The sweep angle of the arc in degrees.
106         /// </summary>
107         [EditorBrowsable(EditorBrowsableState.Never)]
108         public float SweepAngle
109         {
110             get => sweepAngle;
111             set
112             {
113                 sweepAngle = value;
114                 UpdateVisual();
115             }
116         }
117
118         /// <summary>
119         /// The cap style of the arc.
120         /// </summary>
121         [EditorBrowsable(EditorBrowsableState.Never)]
122         public CapType Cap
123         {
124             get => cap;
125             set
126             {
127                 cap = value;
128                 UpdateVisual();
129             }
130         }
131
132         #endregion Properties
133
134
135         #region Methods
136
137         /// <inheritdoc/>
138         [EditorBrowsable(EditorBrowsableState.Never)]
139         protected override void ComposingPropertyMap()
140         {
141             _outputVisualMap = null;
142
143             base.ComposingPropertyMap();
144
145             _outputVisualMap.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Arc));
146             _outputVisualMap.Add(ArcVisualProperty.Thickness, new PropertyValue(Thickness < 0.0f ? 0.0f : Thickness));
147             _outputVisualMap.Add(ArcVisualProperty.StartAngle, new PropertyValue(StartAngle));
148             _outputVisualMap.Add(ArcVisualProperty.SweepAngle, new PropertyValue(SweepAngle));
149             _outputVisualMap.Add(ArcVisualProperty.Cap, new PropertyValue((int)Cap));
150         }
151
152         #endregion Methods
153     }
154 }