Replace duplicate documentation of CopyFrom with inheritdoc
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI.Components / Style / SliderStyle.cs
1 /*
2  * Copyright(c) 2021 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17 using System.ComponentModel;
18 using Tizen.NUI.BaseComponents;
19 using Tizen.NUI.Binding;
20 using static Tizen.NUI.Components.Slider;
21
22 namespace Tizen.NUI.Components
23 {
24     /// <summary>
25     /// SliderStyle is a class which saves Slider's ux data.
26     /// </summary>
27     /// <since_tizen> 8 </since_tizen>
28     public class SliderStyle : ControlStyle
29     {
30         /// <summary>
31         /// IndicatorTypeProperty
32         /// </summary>
33         [EditorBrowsable(EditorBrowsableState.Never)]
34         public static readonly BindableProperty IndicatorTypeProperty = BindableProperty.Create(nameof(IndicatorType), typeof(IndicatorType?), typeof(SliderStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
35         {
36             var instance = (SliderStyle)bindable;
37             if (newValue != null)
38             {
39                 instance.privateIndicatorType = (IndicatorType)newValue;
40             }
41         },
42         defaultValueCreator: (bindable) =>
43         {
44             var instance = (SliderStyle)bindable;
45             return instance.privateIndicatorType;
46         });
47
48         /// <summary>
49         /// SpaceBetweenTrackAndIndicatorProperty
50         /// </summary>
51         [EditorBrowsable(EditorBrowsableState.Never)]
52         public static readonly BindableProperty SpaceBetweenTrackAndIndicatorProperty = BindableProperty.Create(nameof(SpaceBetweenTrackAndIndicator), typeof(uint?), typeof(SliderStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
53         {
54             var instance = (SliderStyle)bindable;
55             if (newValue != null)
56             {
57                 instance.privateSpaceBetweenTrackAndIndicator = (uint?)newValue;
58             }
59         },
60         defaultValueCreator: (bindable) =>
61         {
62             var instance = (SliderStyle)bindable;
63             return instance.privateSpaceBetweenTrackAndIndicator;
64         });
65
66         /// <summary>
67         /// TrackThicknessProperty
68         /// </summary>
69         [EditorBrowsable(EditorBrowsableState.Never)]
70         public static readonly BindableProperty TrackThicknessProperty = BindableProperty.Create(nameof(TrackThickness), typeof(uint?), typeof(SliderStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
71         {
72             var instance = (SliderStyle)bindable;
73             if (newValue != null)
74             {
75                 instance.privateTrackThickness = (uint?)newValue;
76             }
77         },
78         defaultValueCreator: (bindable) =>
79         {
80             var instance = (SliderStyle)bindable;
81             return instance.privateTrackThickness;
82         });
83
84         /// <summary>
85         /// TrackPaddingProperty
86         /// </summary>
87         [EditorBrowsable(EditorBrowsableState.Never)]
88         public static readonly BindableProperty TrackPaddingProperty = BindableProperty.Create(nameof(TrackPadding), typeof(Extents), typeof(SliderStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
89         {
90             ((SliderStyle)bindable).trackPadding = newValue == null ? null : new Extents((Extents)newValue);
91         },
92         defaultValueCreator: (bindable) =>
93         {
94             var instance = (SliderStyle)bindable;
95             return instance.trackPadding;
96         });
97
98         private IndicatorType? privateIndicatorType = Slider.IndicatorType.None;
99         private uint? privateTrackThickness;
100         private uint? privateSpaceBetweenTrackAndIndicator;
101         private Extents trackPadding;
102
103         static SliderStyle() { }
104
105         /// <summary>
106         /// Creates a new instance of a SliderStyle.
107         /// </summary>
108         /// <since_tizen> 8 </since_tizen>
109         public SliderStyle() : base()
110         {
111         }
112
113         /// <summary>
114         /// Creates a new instance of a SliderStyle with style.
115         /// </summary>
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)
119         {
120         }
121
122         /// <summary>
123         /// Get or set background track.
124         /// </summary>
125         /// <since_tizen> 8 </since_tizen>
126         public ImageViewStyle Track { get; set; } = new ImageViewStyle();
127
128         /// <summary>
129         /// Get or set slided track.
130         /// </summary>
131         /// <since_tizen> 8 </since_tizen>
132         public ImageViewStyle Progress { get; set; } = new ImageViewStyle();
133
134         /// <summary>
135         /// Get or set thumb.
136         /// </summary>
137         /// <since_tizen> 8 </since_tizen>
138         public ImageViewStyle Thumb { get; set; } = new ImageViewStyle();
139
140         /// <summary>
141         /// Get or set background warning track.
142         /// </summary>
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();
146
147         /// <summary>
148         /// Get or set slided warning track.
149         /// </summary>
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();
153
154         /// <summary>
155         /// Get or set low indicator image.
156         /// </summary>
157         /// <since_tizen> 8 </since_tizen>
158         public ImageViewStyle LowIndicatorImage { get; set; } = new ImageViewStyle();
159
160         /// <summary>
161         /// Get or set high indicator image.
162         /// </summary>
163         /// <since_tizen> 8 </since_tizen>
164         public ImageViewStyle HighIndicatorImage { get; set; } = new ImageViewStyle();
165
166         /// <summary>
167         /// Get or set low indicator text.
168         /// </summary>
169         /// <since_tizen> 8 </since_tizen>
170         public TextLabelStyle LowIndicator { get; set; } = new TextLabelStyle();
171
172         /// <summary>
173         /// Get or set high indicator text.
174         /// </summary>
175         /// <since_tizen> 8 </since_tizen>
176         public TextLabelStyle HighIndicator { get; set; } = new TextLabelStyle();
177
178         /// <summary>
179         /// Get or set the value indicator text.
180         /// </summary>
181         /// <since_tizen> 9 </since_tizen>
182         public TextLabelStyle ValueIndicatorText { get; set; } = new TextLabelStyle();
183
184         /// <summary>
185         /// Get or set the value indicator image.
186         /// </summary>
187         /// <since_tizen> 9 </since_tizen>
188         public ImageViewStyle ValueIndicatorImage { get; set; } = new ImageViewStyle();
189
190         /// <summary>
191         /// Get or set Indicator type
192         /// </summary>
193         /// <since_tizen> 8 </since_tizen>
194         public IndicatorType? IndicatorType
195         {
196             get => (IndicatorType?)GetValue(IndicatorTypeProperty);
197             set => SetValue(IndicatorTypeProperty, value);
198         }
199
200         /// <summary>
201         /// Get or set track thickness
202         /// </summary>
203         /// <since_tizen> 8 </since_tizen>
204         public uint? TrackThickness
205         {
206             get => (uint?)GetValue(TrackThicknessProperty);
207             set => SetValue(TrackThicknessProperty, value);
208         }
209
210         /// <summary>
211         /// Get or set space between track and indicator
212         /// </summary>
213         /// <since_tizen> 8 </since_tizen>
214         public uint? SpaceBetweenTrackAndIndicator
215         {
216             get => (uint?)GetValue(SpaceBetweenTrackAndIndicatorProperty);
217             set => SetValue(SpaceBetweenTrackAndIndicatorProperty, value);
218         }
219
220         /// <summary>
221         /// Get or set space between track and indicator
222         /// </summary>
223         /// <since_tizen> 8 </since_tizen>
224         public Extents TrackPadding
225         {
226             get => ((Extents)GetValue(TrackPaddingProperty)) ?? (trackPadding = new Extents(0, 0, 0, 0));
227             set => SetValue(TrackPaddingProperty, value);
228         }
229
230         /// <inheritdoc/>
231         /// <since_tizen> 8 </since_tizen>
232         public override void CopyFrom(BindableObject bindableObject)
233         {
234             base.CopyFrom(bindableObject);
235
236             if (bindableObject is SliderStyle sliderStyle)
237             {
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);
249             }
250         }
251
252         /// <summary>
253         /// Dispose SliderStyle and all children on it.
254         /// </summary>
255         /// <param name="disposing">true in order to free managed objects</param>
256         [EditorBrowsable(EditorBrowsableState.Never)]
257         protected override void Dispose(bool disposing)
258         {
259             if (disposing)
260             {
261                 trackPadding?.Dispose();
262             }
263
264             base.Dispose(disposing);
265         }
266     }
267 }