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("IndicatorType", typeof(IndicatorType?), typeof(SliderStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
36 var instance = (Tizen.NUI.Components.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("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("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("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 /// Creates a new instance of a SliderStyle.
95 /// <since_tizen> 6 </since_tizen>
96 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
97 [EditorBrowsable(EditorBrowsableState.Never)]
98 public SliderStyle() : base()
100 IndicatorType = Slider.IndicatorType.None;
105 /// Creates a new instance of a SliderStyle with style.
107 /// <param name="style">Create SliderStyle by style customized by user.</param>
108 /// <since_tizen> 6 </since_tizen>
109 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
110 [EditorBrowsable(EditorBrowsableState.Never)]
111 public SliderStyle(SliderStyle style) : base(style)
120 this.CopyFrom(style);
122 IndicatorType = style.IndicatorType;
126 /// Get or set background track.
128 /// <since_tizen> 6 </since_tizen>
129 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
130 [EditorBrowsable(EditorBrowsableState.Never)]
131 public ImageViewStyle Track { get; set; }
134 /// Get or set slided track.
136 /// <since_tizen> 6 </since_tizen>
137 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
138 [EditorBrowsable(EditorBrowsableState.Never)]
139 public ImageViewStyle Progress { get; set; }
142 /// Get or set thumb.
144 /// <since_tizen> 6 </since_tizen>
145 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
146 [EditorBrowsable(EditorBrowsableState.Never)]
147 public ImageViewStyle Thumb { get; set; }
150 /// Get or set low indicator image.
152 /// <since_tizen> 6 </since_tizen>
153 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
154 [EditorBrowsable(EditorBrowsableState.Never)]
155 public ImageViewStyle LowIndicatorImage { get; set; }
158 /// Get or set high indicator image.
160 /// <since_tizen> 6 </since_tizen>
161 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
162 [EditorBrowsable(EditorBrowsableState.Never)]
163 public ImageViewStyle HighIndicatorImage { get; set; }
166 /// Get or set low indicator text.
168 /// <since_tizen> 6 </since_tizen>
169 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
170 [EditorBrowsable(EditorBrowsableState.Never)]
171 public TextLabelStyle LowIndicator { get; set; }
174 /// Get or set high indicator text.
176 /// <since_tizen> 6 </since_tizen>
177 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
178 [EditorBrowsable(EditorBrowsableState.Never)]
179 public TextLabelStyle HighIndicator { get; set; }
182 /// Get or set Indicator type
184 /// <since_tizen> 6 </since_tizen>
185 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
186 [EditorBrowsable(EditorBrowsableState.Never)]
187 public IndicatorType? IndicatorType
189 get => (IndicatorType?)GetValue(IndicatorTypeProperty);
190 set => SetValue(IndicatorTypeProperty, value);
193 private IndicatorType? privateIndicatorType { get; set; }
196 /// Get or set track thickness
198 /// <since_tizen> 6 </since_tizen>
199 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
200 [EditorBrowsable(EditorBrowsableState.Never)]
201 public uint? TrackThickness
203 get => (uint?)GetValue(TrackThicknessProperty);
204 set => SetValue(TrackThicknessProperty, value);
206 private uint? privateTrackThickness { get; set; }
209 /// Get or set space between track and indicator
211 /// <since_tizen> 6 </since_tizen>
212 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
213 [EditorBrowsable(EditorBrowsableState.Never)]
214 public uint? SpaceBetweenTrackAndIndicator
216 get => (uint?)GetValue(SpaceBetweenTrackAndIndicatorProperty);
217 set => SetValue(SpaceBetweenTrackAndIndicatorProperty, value);
219 private uint? privateSpaceBetweenTrackAndIndicator { get; set; }
222 /// Get or set space between track and indicator
224 /// <since_tizen> 6 </since_tizen>
225 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
226 [EditorBrowsable(EditorBrowsableState.Never)]
227 public Extents TrackPadding
229 get => (Extents)GetValue(TrackPaddingProperty);
230 set => SetValue(TrackPaddingProperty, value);
232 private Extents _trackPadding;
233 private Extents trackPadding
237 if (null == _trackPadding)
239 _trackPadding = new Extents((ushort start, ushort end, ushort top, ushort bottom)=>
241 Extents extents = new Extents(start, end, top, bottom);
242 _trackPadding.CopyFrom(extents);
245 return _trackPadding;
250 /// Attributes's clone function.
252 /// <since_tizen> 6 </since_tizen>
253 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
254 [EditorBrowsable(EditorBrowsableState.Never)]
255 public override void CopyFrom(BindableObject bindableObject)
257 base.CopyFrom(bindableObject);
259 SliderStyle sliderAttributes = bindableObject as SliderStyle;
261 if (null != sliderAttributes)
263 if (sliderAttributes.Track != null)
267 Track = new ImageViewStyle();
269 Track.CopyFrom(sliderAttributes.Track);
272 if (sliderAttributes.Progress != null)
274 if (null == Progress)
276 Progress = new ImageViewStyle();
278 Progress.CopyFrom(sliderAttributes.Progress);
281 if (sliderAttributes.Thumb != null)
285 Thumb = new ImageViewStyle();
287 Thumb.CopyFrom(sliderAttributes.Thumb);
290 if (sliderAttributes.LowIndicatorImage != null)
292 if (null == LowIndicatorImage)
294 LowIndicatorImage = new ImageViewStyle();
296 LowIndicatorImage.CopyFrom(sliderAttributes.LowIndicatorImage);
299 if (sliderAttributes.HighIndicatorImage != null)
301 if (null == HighIndicatorImage)
303 HighIndicatorImage = new ImageViewStyle();
305 HighIndicatorImage.CopyFrom(sliderAttributes.HighIndicatorImage);
308 if (sliderAttributes.LowIndicator != null)
310 if (null == LowIndicator)
312 LowIndicator = new TextLabelStyle();
314 LowIndicator.CopyFrom(sliderAttributes.LowIndicator);
317 if (sliderAttributes.HighIndicator != null)
319 if (null == HighIndicator)
321 HighIndicator = new TextLabelStyle();
323 HighIndicator.CopyFrom(sliderAttributes.HighIndicator);
326 if (sliderAttributes.TrackThickness != null)
328 TrackThickness = sliderAttributes.TrackThickness;
331 if (sliderAttributes.TrackPadding != null)
333 TrackPadding = sliderAttributes.TrackPadding;
338 private void InitSubStyle()
340 Track = new ImageViewStyle();
341 Progress = new ImageViewStyle();
342 Thumb = new ImageViewStyle();
343 LowIndicatorImage = new ImageViewStyle();
344 HighIndicatorImage = new ImageViewStyle();
345 LowIndicator = new TextLabelStyle();
346 HighIndicator = new TextLabelStyle();