[NUI] Revert patch about StyleManager (#1970)
[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 = (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 = (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 = (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             if (null == style) return;
158             this.CopyFrom(style);
159         }
160
161         /// <summary>
162         /// The thickness of the track and progress.
163         /// </summary>
164         [EditorBrowsable(EditorBrowsableState.Never)]
165         public float? Thickness
166         {
167             get
168             {
169                 return (float?)GetValue(ThicknessProperty);
170             }
171             set
172             {
173                 SetValue(ThicknessProperty, value);
174             }
175         }
176
177         /// <summary>
178         /// The property to get/set the maximum value of the CircularSlider.
179         /// </summary>
180         [EditorBrowsable(EditorBrowsableState.Never)]
181         public float MaxValue
182         {
183             get
184             {
185                 return (float)GetValue(MaxValueProperty);
186             }
187             set
188             {
189                 SetValue(MaxValueProperty, value);
190             }
191         }
192
193         /// <summary>
194         /// The property to get/set the minim value of the CircularSlider.
195         /// </summary>
196         [EditorBrowsable(EditorBrowsableState.Never)]
197         public float MinValue
198         {
199             get
200             {
201                 return (float)GetValue(MinValueProperty);
202             }
203             set
204             {
205                 SetValue(MinValueProperty, value);
206             }
207         }
208
209         /// <summary>
210         /// The property to get/set the current value of the CircularSlider.
211         /// </summary>
212         [EditorBrowsable(EditorBrowsableState.Never)]
213         public float CurrentValue
214         {
215             get
216             {
217                 return (float)GetValue(CurrentValueProperty);
218             }
219             set
220             {
221                 SetValue(CurrentValueProperty, value);
222             }
223         }
224
225         /// <summary>
226         /// The property to get/set Track object color of the CircularSlider.
227         /// </summary>
228         [EditorBrowsable(EditorBrowsableState.Never)]
229         public Color TrackColor
230         {
231             get
232             {
233                 return (Color)GetValue(TrackColorProperty);
234             }
235             set
236             {
237                 SetValue(TrackColorProperty, value);
238             }
239         }
240
241         /// <summary>
242         /// The property to get/set Progress object color of the CircularSlider.
243         /// </summary>
244         [EditorBrowsable(EditorBrowsableState.Never)]
245         public Color ProgressColor
246         {
247             get
248             {
249                 return (Color)GetValue(ProgressColorProperty);
250             }
251             set
252             {
253                 SetValue(ProgressColorProperty, value);
254             }
255         }
256
257         /// <summary>
258         /// Gets or sets the size of the thumb of Slider.
259         /// </summary>
260         [EditorBrowsable(EditorBrowsableState.Never)]
261         public Size ThumbSize
262         {
263             get
264             {
265                 return (Size)GetValue(ThumbSizeProperty);
266             }
267             set
268             {
269                 SetValue(ThumbSizeProperty, value);
270             }
271         }
272
273         /// <summary>
274         /// The property to get/set Thumb object color of the CircularSlider.
275         /// </summary>
276         [EditorBrowsable(EditorBrowsableState.Never)]
277         public Color ThumbColor
278         {
279             get
280             {
281                 return (Color)GetValue(ThumbColorProperty);
282             }
283             set
284             {
285                 SetValue(ThumbColorProperty, value);
286             }
287         }
288
289         /// <summary>
290         /// Flag to be enabled or disabled in CircularSlider.
291         /// </summary>
292         /// <since_tizen> 8 </since_tizen>
293         public bool? IsEnabled
294         {
295             get
296             {
297                 return (bool?)GetValue(IsEnabledProperty);
298             }
299             set
300             {
301                 SetValue(IsEnabledProperty, value);
302             }
303         }
304
305         /// <summary>
306         /// Style's clone function.
307         /// </summary>
308         /// <param name="bindableObject">The style that need to copy.</param>
309         [EditorBrowsable(EditorBrowsableState.Never)]
310         public override void CopyFrom(BindableObject bindableObject)
311         {
312             base.CopyFrom(bindableObject);
313
314             CircularSliderStyle progressStyle = bindableObject as CircularSliderStyle;
315
316             if (null != progressStyle)
317             {
318                 isEnabled = progressStyle.isEnabled;
319                 thickness = progressStyle.Thickness;
320                 maxValue = progressStyle.maxValue;
321                 minValue = progressStyle.minValue;
322                 currentValue = progressStyle.currentValue;
323                 trackColor = progressStyle.trackColor;
324                 progressColor = progressStyle.progressColor;
325                 thumbSize = progressStyle.thumbSize;
326                 thumbColor = progressStyle.thumbColor;
327             }
328         }
329
330         private void Initialize()
331         {
332             isEnabled = true;
333             thickness = 6.0f;
334             maxValue = 100.0f;
335             minValue = 0.0f;
336             currentValue = 0.0f;
337             trackColor = new Color(0.0f, 0.16f, 0.30f, 1.0f); // #002A4D
338             progressColor = new Color(0.0f, 0.55f, 1.0f, 1.0f); // #008CFF
339             thumbSize = new Size(19, 19);
340             thumbColor = new Color(0.0f, 0.55f, 1.0f, 1.0f); // #008CFF
341         }
342     }
343 }