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> 8 </since_tizen>
28 public class SliderStyle : ControlStyle
30 /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
31 [EditorBrowsable(EditorBrowsableState.Never)]
32 public static readonly BindableProperty IndicatorTypeProperty = BindableProperty.Create(nameof(IndicatorType), typeof(IndicatorType?), typeof(SliderStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
34 var instance = (SliderStyle)bindable;
37 instance.privateIndicatorType = (IndicatorType)newValue;
40 defaultValueCreator: (bindable) =>
42 var instance = (SliderStyle)bindable;
43 return instance.privateIndicatorType;
45 /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
46 [EditorBrowsable(EditorBrowsableState.Never)]
47 public static readonly BindableProperty SpaceBetweenTrackAndIndicatorProperty = BindableProperty.Create(nameof(SpaceBetweenTrackAndIndicator), typeof(uint?), typeof(SliderStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
49 var instance = (SliderStyle)bindable;
52 instance.privateSpaceBetweenTrackAndIndicator = (uint?)newValue;
55 defaultValueCreator: (bindable) =>
57 var instance = (SliderStyle)bindable;
58 return instance.privateSpaceBetweenTrackAndIndicator;
60 /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
61 [EditorBrowsable(EditorBrowsableState.Never)]
62 public static readonly BindableProperty TrackThicknessProperty = BindableProperty.Create(nameof(TrackThickness), typeof(uint?), typeof(SliderStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
64 var instance = (SliderStyle)bindable;
67 instance.privateTrackThickness = (uint?)newValue;
70 defaultValueCreator: (bindable) =>
72 var instance = (SliderStyle)bindable;
73 return instance.privateTrackThickness;
75 /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
76 [EditorBrowsable(EditorBrowsableState.Never)]
77 public static readonly BindableProperty TrackPaddingProperty = BindableProperty.Create(nameof(TrackPadding), typeof(Extents), typeof(SliderStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
79 ((SliderStyle)bindable).trackPadding = newValue == null ? null : new Extents((Extents)newValue);
81 defaultValueCreator: (bindable) =>
83 var instance = (SliderStyle)bindable;
84 return instance.trackPadding;
87 private IndicatorType? privateIndicatorType = Slider.IndicatorType.None;
88 private uint? privateTrackThickness;
89 private uint? privateSpaceBetweenTrackAndIndicator;
90 private Extents trackPadding;
92 static SliderStyle() { }
95 /// Creates a new instance of a SliderStyle.
97 /// <since_tizen> 8 </since_tizen>
98 public SliderStyle() : base()
103 /// Creates a new instance of a SliderStyle with style.
105 /// <param name="style">Create SliderStyle by style customized by user.</param>
106 /// <since_tizen> 8 </since_tizen>
107 public SliderStyle(SliderStyle style) : base(style)
112 /// Get or set background track.
114 /// <since_tizen> 8 </since_tizen>
115 public ImageViewStyle Track { get; set; } = new ImageViewStyle();
118 /// Get or set slided track.
120 /// <since_tizen> 8 </since_tizen>
121 public ImageViewStyle Progress { get; set; } = new ImageViewStyle();
124 /// Get or set thumb.
126 /// <since_tizen> 8 </since_tizen>
127 public ImageViewStyle Thumb { get; set; } = new ImageViewStyle();
130 /// Get or set low indicator image.
132 /// <since_tizen> 8 </since_tizen>
133 public ImageViewStyle LowIndicatorImage { get; set; } = new ImageViewStyle();
136 /// Get or set high indicator image.
138 /// <since_tizen> 8 </since_tizen>
139 public ImageViewStyle HighIndicatorImage { get; set; } = new ImageViewStyle();
142 /// Get or set low indicator text.
144 /// <since_tizen> 8 </since_tizen>
145 public TextLabelStyle LowIndicator { get; set; } = new TextLabelStyle();
148 /// Get or set high indicator text.
150 /// <since_tizen> 8 </since_tizen>
151 public TextLabelStyle HighIndicator { get; set; } = new TextLabelStyle();
154 /// Get or set Indicator type
156 /// <since_tizen> 8 </since_tizen>
157 public IndicatorType? IndicatorType
159 get => (IndicatorType?)GetValue(IndicatorTypeProperty);
160 set => SetValue(IndicatorTypeProperty, value);
164 /// Get or set track thickness
166 /// <since_tizen> 8 </since_tizen>
167 public uint? TrackThickness
169 get => (uint?)GetValue(TrackThicknessProperty);
170 set => SetValue(TrackThicknessProperty, value);
174 /// Get or set space between track and indicator
176 /// <since_tizen> 8 </since_tizen>
177 public uint? SpaceBetweenTrackAndIndicator
179 get => (uint?)GetValue(SpaceBetweenTrackAndIndicatorProperty);
180 set => SetValue(SpaceBetweenTrackAndIndicatorProperty, value);
184 /// Get or set space between track and indicator
186 /// <since_tizen> 8 </since_tizen>
187 public Extents TrackPadding
189 get => ((Extents)GetValue(TrackPaddingProperty)) ?? (trackPadding = new Extents(0, 0, 0, 0));
190 set => SetValue(TrackPaddingProperty, value);
194 /// Style's clone function.
196 /// <param name="bindableObject">The style that need to copy.</param>
197 /// <since_tizen> 8 </since_tizen>
198 public override void CopyFrom(BindableObject bindableObject)
200 base.CopyFrom(bindableObject);
202 if (bindableObject is SliderStyle sliderStyle)
204 Track.CopyFrom(sliderStyle.Track);
205 Progress.CopyFrom(sliderStyle.Progress);
206 Thumb.CopyFrom(sliderStyle.Thumb);
207 LowIndicatorImage.CopyFrom(sliderStyle.LowIndicatorImage);
208 HighIndicatorImage.CopyFrom(sliderStyle.HighIndicatorImage);
209 LowIndicator.CopyFrom(sliderStyle.LowIndicator);
210 HighIndicator.CopyFrom(sliderStyle.HighIndicator);
215 /// Dispose SliderStyle and all children on it.
217 /// <param name="type">Dispose type.</param>
218 [EditorBrowsable(EditorBrowsableState.Never)]
219 protected override void Dispose(DisposeTypes type)
226 if (type == DisposeTypes.Explicit)
228 trackPadding?.Dispose();