2 * Copyright(c) 2019 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 static Tizen.NUI.Components.Slider;
22 namespace Tizen.NUI.Components
25 /// SliderStyle is a class which saves Slider's ux data.
27 /// <since_tizen> 6 </since_tizen>
28 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
29 [EditorBrowsable(EditorBrowsableState.Never)]
30 public class SliderStyle : ControlStyle
32 /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
33 [EditorBrowsable(EditorBrowsableState.Never)]
34 public static readonly BindableProperty IndicatorTypeProperty = BindableProperty.Create(nameof(IndicatorType), typeof(IndicatorType?), typeof(SliderStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
36 var instance = (SliderStyle)bindable;
39 instance.privateIndicatorType = (IndicatorType)newValue;
42 defaultValueCreator: (bindable) =>
44 var instance = (SliderStyle)bindable;
45 return instance.privateIndicatorType;
47 /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
48 [EditorBrowsable(EditorBrowsableState.Never)]
49 public static readonly BindableProperty SpaceBetweenTrackAndIndicatorProperty = BindableProperty.Create(nameof(SpaceBetweenTrackAndIndicator), typeof(uint?), typeof(SliderStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
51 var instance = (SliderStyle)bindable;
54 instance.privateSpaceBetweenTrackAndIndicator = (uint?)newValue;
57 defaultValueCreator: (bindable) =>
59 var instance = (SliderStyle)bindable;
60 return instance.privateSpaceBetweenTrackAndIndicator;
62 /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
63 [EditorBrowsable(EditorBrowsableState.Never)]
64 public static readonly BindableProperty TrackThicknessProperty = BindableProperty.Create(nameof(TrackThickness), typeof(uint?), typeof(SliderStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
66 var instance = (SliderStyle)bindable;
69 instance.privateTrackThickness = (uint?)newValue;
72 defaultValueCreator: (bindable) =>
74 var instance = (SliderStyle)bindable;
75 return instance.privateTrackThickness;
77 /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
78 [EditorBrowsable(EditorBrowsableState.Never)]
79 public static readonly BindableProperty TrackPaddingProperty = BindableProperty.Create(nameof(TrackPadding), typeof(Extents), typeof(SliderStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
81 var instance = (SliderStyle)bindable;
84 instance.trackPadding.CopyFrom((Extents)newValue);
87 defaultValueCreator: (bindable) =>
89 var instance = (SliderStyle)bindable;
90 return instance.trackPadding;
93 static SliderStyle() { }
96 /// Creates a new instance of a SliderStyle.
98 /// <since_tizen> 6 </since_tizen>
99 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
100 [EditorBrowsable(EditorBrowsableState.Never)]
101 public SliderStyle() : base()
103 IndicatorType = Slider.IndicatorType.None;
108 /// Creates a new instance of a SliderStyle with style.
110 /// <param name="style">Create SliderStyle by style customized by user.</param>
111 /// <since_tizen> 6 </since_tizen>
112 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
113 [EditorBrowsable(EditorBrowsableState.Never)]
114 public SliderStyle(SliderStyle style) : base(style)
123 this.CopyFrom(style);
125 IndicatorType = style.IndicatorType;
129 /// Get or set background track.
131 /// <since_tizen> 6 </since_tizen>
132 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
133 [EditorBrowsable(EditorBrowsableState.Never)]
134 public ImageViewStyle Track { get; set; }
137 /// Get or set slided track.
139 /// <since_tizen> 6 </since_tizen>
140 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
141 [EditorBrowsable(EditorBrowsableState.Never)]
142 public ImageViewStyle Progress { get; set; }
145 /// Get or set thumb.
147 /// <since_tizen> 6 </since_tizen>
148 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
149 [EditorBrowsable(EditorBrowsableState.Never)]
150 public ImageViewStyle Thumb { get; set; }
153 /// Get or set low indicator image.
155 /// <since_tizen> 6 </since_tizen>
156 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
157 [EditorBrowsable(EditorBrowsableState.Never)]
158 public ImageViewStyle LowIndicatorImage { get; set; }
161 /// Get or set high indicator image.
163 /// <since_tizen> 6 </since_tizen>
164 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
165 [EditorBrowsable(EditorBrowsableState.Never)]
166 public ImageViewStyle HighIndicatorImage { get; set; }
169 /// Get or set low indicator text.
171 /// <since_tizen> 6 </since_tizen>
172 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
173 [EditorBrowsable(EditorBrowsableState.Never)]
174 public TextLabelStyle LowIndicator { get; set; }
177 /// Get or set high indicator text.
179 /// <since_tizen> 6 </since_tizen>
180 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
181 [EditorBrowsable(EditorBrowsableState.Never)]
182 public TextLabelStyle HighIndicator { get; set; }
185 /// Get or set Indicator type
187 /// <since_tizen> 6 </since_tizen>
188 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
189 [EditorBrowsable(EditorBrowsableState.Never)]
190 public IndicatorType? IndicatorType
192 get => (IndicatorType?)GetValue(IndicatorTypeProperty);
193 set => SetValue(IndicatorTypeProperty, value);
196 private IndicatorType? privateIndicatorType { get; set; }
199 /// Get or set track thickness
201 /// <since_tizen> 6 </since_tizen>
202 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
203 [EditorBrowsable(EditorBrowsableState.Never)]
204 public uint? TrackThickness
206 get => (uint?)GetValue(TrackThicknessProperty);
207 set => SetValue(TrackThicknessProperty, value);
209 private uint? privateTrackThickness { get; set; }
212 /// Get or set space between track and indicator
214 /// <since_tizen> 6 </since_tizen>
215 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
216 [EditorBrowsable(EditorBrowsableState.Never)]
217 public uint? SpaceBetweenTrackAndIndicator
219 get => (uint?)GetValue(SpaceBetweenTrackAndIndicatorProperty);
220 set => SetValue(SpaceBetweenTrackAndIndicatorProperty, value);
222 private uint? privateSpaceBetweenTrackAndIndicator { get; set; }
225 /// Get or set space between track and indicator
227 /// <since_tizen> 6 </since_tizen>
228 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
229 [EditorBrowsable(EditorBrowsableState.Never)]
230 public Extents TrackPadding
232 get => (Extents)GetValue(TrackPaddingProperty);
233 set => SetValue(TrackPaddingProperty, value);
235 private Extents _trackPadding;
236 private Extents trackPadding
240 if (null == _trackPadding)
242 _trackPadding = new Extents((ushort start, ushort end, ushort top, ushort bottom)=>
244 Extents extents = new Extents(start, end, top, bottom);
245 _trackPadding.CopyFrom(extents);
248 return _trackPadding;
253 /// Attributes's clone function.
255 /// <since_tizen> 6 </since_tizen>
256 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
257 [EditorBrowsable(EditorBrowsableState.Never)]
258 public override void CopyFrom(BindableObject bindableObject)
260 base.CopyFrom(bindableObject);
262 SliderStyle sliderAttributes = bindableObject as SliderStyle;
264 if (null != sliderAttributes)
266 if (sliderAttributes.Track != null)
270 Track = new ImageViewStyle();
272 Track.CopyFrom(sliderAttributes.Track);
275 if (sliderAttributes.Progress != null)
277 if (null == Progress)
279 Progress = new ImageViewStyle();
281 Progress.CopyFrom(sliderAttributes.Progress);
284 if (sliderAttributes.Thumb != null)
288 Thumb = new ImageViewStyle();
290 Thumb.CopyFrom(sliderAttributes.Thumb);
293 if (sliderAttributes.LowIndicatorImage != null)
295 if (null == LowIndicatorImage)
297 LowIndicatorImage = new ImageViewStyle();
299 LowIndicatorImage.CopyFrom(sliderAttributes.LowIndicatorImage);
302 if (sliderAttributes.HighIndicatorImage != null)
304 if (null == HighIndicatorImage)
306 HighIndicatorImage = new ImageViewStyle();
308 HighIndicatorImage.CopyFrom(sliderAttributes.HighIndicatorImage);
311 if (sliderAttributes.LowIndicator != null)
313 if (null == LowIndicator)
315 LowIndicator = new TextLabelStyle();
317 LowIndicator.CopyFrom(sliderAttributes.LowIndicator);
320 if (sliderAttributes.HighIndicator != null)
322 if (null == HighIndicator)
324 HighIndicator = new TextLabelStyle();
326 HighIndicator.CopyFrom(sliderAttributes.HighIndicator);
329 if (sliderAttributes.TrackThickness != null)
331 TrackThickness = sliderAttributes.TrackThickness;
334 if (sliderAttributes.TrackPadding != null)
336 TrackPadding = sliderAttributes.TrackPadding;
341 private void InitSubStyle()
343 Track = new ImageViewStyle();
344 Progress = new ImageViewStyle();
345 Thumb = new ImageViewStyle();
346 LowIndicatorImage = new ImageViewStyle();
347 HighIndicatorImage = new ImageViewStyle();
348 LowIndicator = new TextLabelStyle();
349 HighIndicator = new TextLabelStyle();