2 * Copyright(c) 2021 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> 8 </since_tizen>
28 public class SliderStyle : ControlStyle
31 /// IndicatorTypeProperty
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;
49 /// SpaceBetweenTrackAndIndicatorProperty
51 [EditorBrowsable(EditorBrowsableState.Never)]
52 public static readonly BindableProperty SpaceBetweenTrackAndIndicatorProperty = BindableProperty.Create(nameof(SpaceBetweenTrackAndIndicator), typeof(uint?), typeof(SliderStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
54 var instance = (SliderStyle)bindable;
57 instance.privateSpaceBetweenTrackAndIndicator = (uint?)newValue;
60 defaultValueCreator: (bindable) =>
62 var instance = (SliderStyle)bindable;
63 return instance.privateSpaceBetweenTrackAndIndicator;
67 /// TrackThicknessProperty
69 [EditorBrowsable(EditorBrowsableState.Never)]
70 public static readonly BindableProperty TrackThicknessProperty = BindableProperty.Create(nameof(TrackThickness), typeof(uint?), typeof(SliderStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
72 var instance = (SliderStyle)bindable;
75 instance.privateTrackThickness = (uint?)newValue;
78 defaultValueCreator: (bindable) =>
80 var instance = (SliderStyle)bindable;
81 return instance.privateTrackThickness;
85 /// TrackPaddingProperty
87 [EditorBrowsable(EditorBrowsableState.Never)]
88 public static readonly BindableProperty TrackPaddingProperty = BindableProperty.Create(nameof(TrackPadding), typeof(Extents), typeof(SliderStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
90 ((SliderStyle)bindable).trackPadding = newValue == null ? null : new Extents((Extents)newValue);
92 defaultValueCreator: (bindable) =>
94 var instance = (SliderStyle)bindable;
95 return instance.trackPadding;
98 private IndicatorType? privateIndicatorType = Slider.IndicatorType.None;
99 private uint? privateTrackThickness;
100 private uint? privateSpaceBetweenTrackAndIndicator;
101 private Extents trackPadding;
103 static SliderStyle() { }
106 /// Creates a new instance of a SliderStyle.
108 /// <since_tizen> 8 </since_tizen>
109 public SliderStyle() : base()
114 /// Creates a new instance of a SliderStyle with style.
116 /// <param name="style">Create SliderStyle by style customized by user.</param>
117 /// <since_tizen> 8 </since_tizen>
118 public SliderStyle(SliderStyle style) : base(style)
123 /// Get or set background track.
125 /// <since_tizen> 8 </since_tizen>
126 public ImageViewStyle Track { get; set; } = new ImageViewStyle();
129 /// Get or set slided track.
131 /// <since_tizen> 8 </since_tizen>
132 public ImageViewStyle Progress { get; set; } = new ImageViewStyle();
135 /// Get or set thumb.
137 /// <since_tizen> 8 </since_tizen>
138 public ImageViewStyle Thumb { get; set; } = new ImageViewStyle();
141 /// Get or set background warning track.
143 /// This will be public opened later after ACR done. Before ACR, need to be hidden as inhouse API.
144 [EditorBrowsable(EditorBrowsableState.Never)]
145 public ImageViewStyle WarningTrack { get; set; } = new ImageViewStyle();
148 /// Get or set slided warning track.
150 /// This will be public opened later after ACR done. Before ACR, need to be hidden as inhouse API.
151 [EditorBrowsable(EditorBrowsableState.Never)]
152 public ImageViewStyle WarningProgress { get; set; } = new ImageViewStyle();
155 /// Get or set low indicator image.
157 /// <since_tizen> 8 </since_tizen>
158 public ImageViewStyle LowIndicatorImage { get; set; } = new ImageViewStyle();
161 /// Get or set high indicator image.
163 /// <since_tizen> 8 </since_tizen>
164 public ImageViewStyle HighIndicatorImage { get; set; } = new ImageViewStyle();
167 /// Get or set low indicator text.
169 /// <since_tizen> 8 </since_tizen>
170 public TextLabelStyle LowIndicator { get; set; } = new TextLabelStyle();
173 /// Get or set high indicator text.
175 /// <since_tizen> 8 </since_tizen>
176 public TextLabelStyle HighIndicator { get; set; } = new TextLabelStyle();
179 /// Get or set the value indicator text.
181 /// <since_tizen> 9 </since_tizen>
182 public TextLabelStyle ValueIndicatorText { get; set; } = new TextLabelStyle();
185 /// Get or set the value indicator image.
187 /// <since_tizen> 9 </since_tizen>
188 public ImageViewStyle ValueIndicatorImage { get; set; } = new ImageViewStyle();
191 /// Get or set Indicator type
193 /// <since_tizen> 8 </since_tizen>
194 public IndicatorType? IndicatorType
196 get => (IndicatorType?)GetValue(IndicatorTypeProperty);
197 set => SetValue(IndicatorTypeProperty, value);
201 /// Get or set track thickness
203 /// <since_tizen> 8 </since_tizen>
204 public uint? TrackThickness
206 get => (uint?)GetValue(TrackThicknessProperty);
207 set => SetValue(TrackThicknessProperty, value);
211 /// Get or set space between track and indicator
213 /// <since_tizen> 8 </since_tizen>
214 public uint? SpaceBetweenTrackAndIndicator
216 get => (uint?)GetValue(SpaceBetweenTrackAndIndicatorProperty);
217 set => SetValue(SpaceBetweenTrackAndIndicatorProperty, value);
221 /// Get or set space between track and indicator
223 /// <since_tizen> 8 </since_tizen>
224 public Extents TrackPadding
226 get => ((Extents)GetValue(TrackPaddingProperty)) ?? (trackPadding = new Extents(0, 0, 0, 0));
227 set => SetValue(TrackPaddingProperty, value);
231 /// <since_tizen> 8 </since_tizen>
232 public override void CopyFrom(BindableObject bindableObject)
234 base.CopyFrom(bindableObject);
236 if (bindableObject is SliderStyle sliderStyle)
238 Track.CopyFrom(sliderStyle.Track);
239 Progress.CopyFrom(sliderStyle.Progress);
240 Thumb.CopyFrom(sliderStyle.Thumb);
241 WarningTrack.CopyFrom(sliderStyle.WarningTrack);
242 WarningProgress.CopyFrom(sliderStyle.WarningProgress);
243 LowIndicatorImage.CopyFrom(sliderStyle.LowIndicatorImage);
244 HighIndicatorImage.CopyFrom(sliderStyle.HighIndicatorImage);
245 LowIndicator.CopyFrom(sliderStyle.LowIndicator);
246 HighIndicator.CopyFrom(sliderStyle.HighIndicator);
247 ValueIndicatorText.CopyFrom(sliderStyle.ValueIndicatorText);
248 ValueIndicatorImage.CopyFrom(sliderStyle.ValueIndicatorImage);
253 /// Dispose SliderStyle and all children on it.
255 /// <param name="disposing">true in order to free managed objects</param>
256 [EditorBrowsable(EditorBrowsableState.Never)]
257 protected override void Dispose(bool disposing)
261 trackPadding?.Dispose();
264 base.Dispose(disposing);