[NUI] Add ThemeManager (#2034)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI.Wearable / src / public / WearableStyle / CircularSliderStyle.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 using Tizen.NUI.BaseComponents;
19 using Tizen.NUI.Binding;
20 using Tizen.NUI.Components;
21
22 namespace Tizen.NUI.Wearable
23 {
24     /// <summary>
25     /// CircularSliderStyle is a class which saves CircularSlider's ux data.
26     /// </summary>
27     [EditorBrowsable(EditorBrowsableState.Never)]
28     public class CircularSliderStyle : ControlStyle
29     {
30         /// <summary>Bindable property of Thickness</summary>
31         [EditorBrowsable(EditorBrowsableState.Never)]
32         public static readonly BindableProperty ThicknessProperty = BindableProperty.Create(nameof(Thickness), typeof(float?), typeof(CircularSliderStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
33         {
34             ((CircularSliderStyle)bindable).thickness = (float?)newValue;
35         },
36         defaultValueCreator: (bindable) =>
37         {
38             return ((CircularSliderStyle)bindable).thickness;
39         });
40
41         /// <summary>Bindable property of MaxValue</summary>
42         [EditorBrowsable(EditorBrowsableState.Never)]
43         public static readonly BindableProperty MaxValueProperty = BindableProperty.Create(nameof(MaxValue), typeof(float), typeof(CircularSliderStyle), default(float), propertyChanged: (bindable, oldValue, newValue) =>
44         {
45             ((CircularSliderStyle)bindable).maxValue = (float)newValue;
46         },
47         defaultValueCreator: (bindable) =>
48         {
49             return ((CircularSliderStyle)bindable).maxValue;
50         });
51
52         /// <summary>Bindable property of MinValue</summary>
53         [EditorBrowsable(EditorBrowsableState.Never)]
54         public static readonly BindableProperty MinValueProperty = BindableProperty.Create(nameof(MinValue), typeof(float), typeof(CircularSliderStyle), default(float), propertyChanged: (bindable, oldValue, newValue) =>
55         {
56             ((CircularSliderStyle)bindable).minValue = (float)newValue;
57         },
58         defaultValueCreator: (bindable) =>
59         {
60             return ((CircularSliderStyle)bindable).minValue;
61         });
62
63         /// <summary>Bindable property of CurrentValue</summary>
64         [EditorBrowsable(EditorBrowsableState.Never)]
65         public static readonly BindableProperty CurrentValueProperty = BindableProperty.Create(nameof(CurrentValue), typeof(float), typeof(CircularSliderStyle), default(float), propertyChanged: (bindable, oldValue, newValue) =>
66         {
67             ((CircularSliderStyle)bindable).currentValue = (float)newValue;
68         },
69         defaultValueCreator: (bindable) =>
70         {
71             return ((CircularSliderStyle)bindable).currentValue;
72         });
73
74         /// <summary>Bindable property of TrackColor</summary>
75         [EditorBrowsable(EditorBrowsableState.Never)]
76         public static readonly BindableProperty TrackColorProperty = BindableProperty.Create(nameof(TrackColor), typeof(Color), typeof(CircularSliderStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
77         {
78             ((CircularSliderStyle)bindable).trackColor = newValue == null ? null : new Color((Color)newValue);
79         },
80         defaultValueCreator: (bindable) =>
81         {
82             return ((CircularSliderStyle)bindable).trackColor;
83         });
84
85         /// <summary>Bindable property of ProgressColor</summary>
86         [EditorBrowsable(EditorBrowsableState.Never)]
87         public static readonly BindableProperty ProgressColorProperty = BindableProperty.Create(nameof(ProgressColor), typeof(Color), typeof(CircularSliderStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
88         {
89             ((CircularSliderStyle)bindable).progressColor = newValue == null ? null : new Color((Color)newValue);
90         },
91         defaultValueCreator: (bindable) =>
92         {
93             return ((CircularSliderStyle)bindable).progressColor;
94         });
95
96         /// <summary>Bindable property of ThumbSize</summary>
97         [EditorBrowsable(EditorBrowsableState.Never)]
98         public static readonly BindableProperty ThumbSizeProperty = BindableProperty.Create(nameof(ThumbSize), typeof(Size), typeof(CircularSliderStyle), new Size(0,0), propertyChanged: (bindable, oldValue, newValue) =>
99         {
100             ((CircularSliderStyle)bindable).thumbSize = (Size)newValue;
101         },
102         defaultValueCreator: (bindable) =>
103         {
104             return ((CircularSliderStyle)bindable).thumbSize;
105         });
106
107         /// <summary>Bindable property of ThumbColor</summary>
108         [EditorBrowsable(EditorBrowsableState.Never)]
109         public static readonly BindableProperty ThumbColorProperty = BindableProperty.Create(nameof(ThumbColor), typeof(Color), typeof(CircularSliderStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
110         {
111             ((CircularSliderStyle)bindable).thumbColor = newValue == null ? null : new Color((Color)newValue);
112         },
113         defaultValueCreator: (bindable) =>
114         {
115             return ((CircularSliderStyle)bindable).thumbColor;
116         });
117
118         /// <summary>Bindable property of IsEnabled</summary>
119         [EditorBrowsable(EditorBrowsableState.Never)]
120         public static readonly BindableProperty IsEnabledProperty = BindableProperty.Create(nameof(IsEnabled), typeof(bool?), typeof(CircularSliderStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
121         {
122             ((CircularSliderStyle)bindable).isEnabled = (bool?)newValue;
123         },
124         defaultValueCreator: (bindable) =>
125         {
126             return ((CircularSliderStyle)bindable).isEnabled;
127         });
128
129         private float? thickness;
130         private float maxValue;
131         private float minValue;
132         private float currentValue;
133         private Color trackColor;
134         private Color progressColor;
135         private Color thumbColor;
136         private Size thumbSize;
137         private bool? isEnabled;
138
139         static CircularSliderStyle() { }
140
141         /// <summary>
142         /// Creates a new instance of a CircularSliderStyle.
143         /// </summary>
144         [EditorBrowsable(EditorBrowsableState.Never)]
145         public CircularSliderStyle() : base()
146         {
147             Initialize();
148         }
149
150         /// <summary>
151         /// Creates a new instance of a CircularSliderStyle with style.
152         /// </summary>
153         /// <param name="style">Create CircularSliderStyle by style customized by user.</param>
154         [EditorBrowsable(EditorBrowsableState.Never)]
155         public CircularSliderStyle(CircularSliderStyle style) : base(style)
156         {
157         }
158
159         /// <summary>
160         /// The thickness of the track and progress.
161         /// </summary>
162         [EditorBrowsable(EditorBrowsableState.Never)]
163         public float? Thickness
164         {
165             get
166             {
167                 return (float?)GetValue(ThicknessProperty);
168             }
169             set
170             {
171                 SetValue(ThicknessProperty, value);
172             }
173         }
174
175         /// <summary>
176         /// The property to get/set the maximum value of the CircularSlider.
177         /// </summary>
178         [EditorBrowsable(EditorBrowsableState.Never)]
179         public float MaxValue
180         {
181             get
182             {
183                 return (float)GetValue(MaxValueProperty);
184             }
185             set
186             {
187                 SetValue(MaxValueProperty, value);
188             }
189         }
190
191         /// <summary>
192         /// The property to get/set the minim value of the CircularSlider.
193         /// </summary>
194         [EditorBrowsable(EditorBrowsableState.Never)]
195         public float MinValue
196         {
197             get
198             {
199                 return (float)GetValue(MinValueProperty);
200             }
201             set
202             {
203                 SetValue(MinValueProperty, value);
204             }
205         }
206
207         /// <summary>
208         /// The property to get/set the current value of the CircularSlider.
209         /// </summary>
210         [EditorBrowsable(EditorBrowsableState.Never)]
211         public float CurrentValue
212         {
213             get
214             {
215                 return (float)GetValue(CurrentValueProperty);
216             }
217             set
218             {
219                 SetValue(CurrentValueProperty, value);
220             }
221         }
222
223         /// <summary>
224         /// The property to get/set Track object color of the CircularSlider.
225         /// </summary>
226         [EditorBrowsable(EditorBrowsableState.Never)]
227         public Color TrackColor
228         {
229             get
230             {
231                 return (Color)GetValue(TrackColorProperty);
232             }
233             set
234             {
235                 SetValue(TrackColorProperty, value);
236             }
237         }
238
239         /// <summary>
240         /// The property to get/set Progress object color of the CircularSlider.
241         /// </summary>
242         [EditorBrowsable(EditorBrowsableState.Never)]
243         public Color ProgressColor
244         {
245             get
246             {
247                 return (Color)GetValue(ProgressColorProperty);
248             }
249             set
250             {
251                 SetValue(ProgressColorProperty, value);
252             }
253         }
254
255         /// <summary>
256         /// Gets or sets the size of the thumb of Slider.
257         /// </summary>
258         [EditorBrowsable(EditorBrowsableState.Never)]
259         public Size ThumbSize
260         {
261             get
262             {
263                 return (Size)GetValue(ThumbSizeProperty);
264             }
265             set
266             {
267                 SetValue(ThumbSizeProperty, value);
268             }
269         }
270
271         /// <summary>
272         /// The property to get/set Thumb object color of the CircularSlider.
273         /// </summary>
274         [EditorBrowsable(EditorBrowsableState.Never)]
275         public Color ThumbColor
276         {
277             get
278             {
279                 return (Color)GetValue(ThumbColorProperty);
280             }
281             set
282             {
283                 SetValue(ThumbColorProperty, value);
284             }
285         }
286
287         /// <summary>
288         /// Flag to be enabled or disabled in CircularSlider.
289         /// </summary>
290         /// <since_tizen> 8 </since_tizen>
291         public bool? IsEnabled
292         {
293             get
294             {
295                 return (bool?)GetValue(IsEnabledProperty);
296             }
297             set
298             {
299                 SetValue(IsEnabledProperty, value);
300             }
301         }
302
303         private void Initialize()
304         {
305             isEnabled = true;
306             thickness = 6.0f;
307             maxValue = 100.0f;
308             minValue = 0.0f;
309             currentValue = 0.0f;
310             trackColor = new Color(0.0f, 0.16f, 0.30f, 1.0f); // #002A4D
311             progressColor = new Color(0.0f, 0.55f, 1.0f, 1.0f); // #008CFF
312             thumbSize = new Size(19, 19);
313             thumbColor = new Color(0.0f, 0.55f, 1.0f, 1.0f); // #008CFF
314         }
315     }
316 }