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.
17 using System.ComponentModel;
18 using Tizen.NUI.BaseComponents;
19 using Tizen.NUI.Binding;
20 using Tizen.NUI.Components;
22 namespace Tizen.NUI.Wearable
25 /// CircularSliderStyle is a class which saves CircularSlider's ux data.
27 [EditorBrowsable(EditorBrowsableState.Never)]
28 public class CircularSliderStyle : ControlStyle
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) =>
34 ((CircularSliderStyle)bindable).thickness = (float?)newValue;
36 defaultValueCreator: (bindable) =>
38 return ((CircularSliderStyle)bindable).thickness;
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) =>
45 ((CircularSliderStyle)bindable).maxValue = (float)newValue;
47 defaultValueCreator: (bindable) =>
49 return ((CircularSliderStyle)bindable).maxValue;
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) =>
56 ((CircularSliderStyle)bindable).minValue = (float)newValue;
58 defaultValueCreator: (bindable) =>
60 return ((CircularSliderStyle)bindable).minValue;
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) =>
67 ((CircularSliderStyle)bindable).currentValue = (float)newValue;
69 defaultValueCreator: (bindable) =>
71 return ((CircularSliderStyle)bindable).currentValue;
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) =>
78 ((CircularSliderStyle)bindable).trackColor = (Color)newValue;
80 defaultValueCreator: (bindable) =>
82 return ((CircularSliderStyle)bindable).trackColor;
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) =>
89 ((CircularSliderStyle)bindable).progressColor = (Color)newValue;
91 defaultValueCreator: (bindable) =>
93 return ((CircularSliderStyle)bindable).progressColor;
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) =>
100 ((CircularSliderStyle)bindable).thumbSize = (Size)newValue;
102 defaultValueCreator: (bindable) =>
104 return ((CircularSliderStyle)bindable).thumbSize;
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) =>
111 ((CircularSliderStyle)bindable).thumbColor = (Color)newValue;
113 defaultValueCreator: (bindable) =>
115 return ((CircularSliderStyle)bindable).thumbColor;
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) =>
122 ((CircularSliderStyle)bindable).isEnabled = (bool?)newValue;
124 defaultValueCreator: (bindable) =>
126 return ((CircularSliderStyle)bindable).isEnabled;
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;
139 static CircularSliderStyle() { }
142 /// Creates a new instance of a CircularSliderStyle.
144 [EditorBrowsable(EditorBrowsableState.Never)]
145 public CircularSliderStyle() : base()
151 /// Creates a new instance of a CircularSliderStyle with style.
153 /// <param name="style">Create CircularSliderStyle by style customized by user.</param>
154 [EditorBrowsable(EditorBrowsableState.Never)]
155 public CircularSliderStyle(CircularSliderStyle style) : base(style)
157 if (null == style) return;
158 this.CopyFrom(style);
162 /// The thickness of the track and progress.
164 [EditorBrowsable(EditorBrowsableState.Never)]
165 public float? Thickness
169 return (float?)GetValue(ThicknessProperty);
173 SetValue(ThicknessProperty, value);
178 /// The property to get/set the maximum value of the CircularSlider.
180 [EditorBrowsable(EditorBrowsableState.Never)]
181 public float MaxValue
185 return (float)GetValue(MaxValueProperty);
189 SetValue(MaxValueProperty, value);
194 /// The property to get/set the minim value of the CircularSlider.
196 [EditorBrowsable(EditorBrowsableState.Never)]
197 public float MinValue
201 return (float)GetValue(MinValueProperty);
205 SetValue(MinValueProperty, value);
210 /// The property to get/set the current value of the CircularSlider.
212 [EditorBrowsable(EditorBrowsableState.Never)]
213 public float CurrentValue
217 return (float)GetValue(CurrentValueProperty);
221 SetValue(CurrentValueProperty, value);
226 /// The property to get/set Track object color of the CircularSlider.
228 [EditorBrowsable(EditorBrowsableState.Never)]
229 public Color TrackColor
233 return (Color)GetValue(TrackColorProperty);
237 SetValue(TrackColorProperty, value);
242 /// The property to get/set Progress object color of the CircularSlider.
244 [EditorBrowsable(EditorBrowsableState.Never)]
245 public Color ProgressColor
249 return (Color)GetValue(ProgressColorProperty);
253 SetValue(ProgressColorProperty, value);
258 /// Gets or sets the size of the thumb of Slider.
260 [EditorBrowsable(EditorBrowsableState.Never)]
261 public Size ThumbSize
265 return (Size)GetValue(ThumbSizeProperty);
269 SetValue(ThumbSizeProperty, value);
274 /// The property to get/set Thumb object color of the CircularSlider.
276 [EditorBrowsable(EditorBrowsableState.Never)]
277 public Color ThumbColor
281 return (Color)GetValue(ThumbColorProperty);
285 SetValue(ThumbColorProperty, value);
290 /// Flag to be enabled or disabled in CircularSlider.
292 /// <since_tizen> 8 </since_tizen>
293 public bool? IsEnabled
297 return (bool?)GetValue(IsEnabledProperty);
301 SetValue(IsEnabledProperty, value);
306 /// Style's clone function.
308 /// <param name="bindableObject">The style that need to copy.</param>
309 [EditorBrowsable(EditorBrowsableState.Never)]
310 public override void CopyFrom(BindableObject bindableObject)
312 base.CopyFrom(bindableObject);
314 CircularSliderStyle progressStyle = bindableObject as CircularSliderStyle;
316 if (null != progressStyle)
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;
330 private void Initialize()
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