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;
21 namespace Tizen.NUI.Components
24 /// ScrollbarStyle is a class which saves Scrollbar's style data.
26 [EditorBrowsable(EditorBrowsableState.Never)]
27 public class ScrollbarStyle : ViewStyle
31 /// <summary>Bindable property of TrackThickness</summary>
32 [EditorBrowsable(EditorBrowsableState.Never)]
33 public static readonly BindableProperty TrackThicknessProperty = BindableProperty.Create(nameof(TrackThickness), typeof(float?), typeof(ScrollbarStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
35 ((ScrollbarStyle)bindable).trackThickness = (float?)newValue;
37 defaultValueCreator: (bindable) =>
39 return ((ScrollbarStyle)bindable).trackThickness;
42 /// <summary>Bindable property of ThumbThickness</summary>
43 [EditorBrowsable(EditorBrowsableState.Never)]
44 public static readonly BindableProperty ThumbThicknessProperty = BindableProperty.Create(nameof(ThumbThickness), typeof(float?), typeof(ScrollbarStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
46 ((ScrollbarStyle)bindable).thumbThickness = (float?)newValue;
48 defaultValueCreator: (bindable) =>
50 return ((ScrollbarStyle)bindable).thumbThickness;
53 /// <summary>Bindable property of TrackColor</summary>
54 [EditorBrowsable(EditorBrowsableState.Never)]
55 public static readonly BindableProperty TrackColorProperty = BindableProperty.Create(nameof(TrackColor), typeof(Color), typeof(ScrollbarStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
57 ((ScrollbarStyle)bindable).trackColor = (Color)newValue;
59 defaultValueCreator: (bindable) =>
61 return ((ScrollbarStyle)bindable).trackColor;
64 /// <summary>Bindable property of ThumbColor</summary>
65 [EditorBrowsable(EditorBrowsableState.Never)]
66 public static readonly BindableProperty ThumbColorProperty = BindableProperty.Create(nameof(ThumbColor), typeof(Color), typeof(ScrollbarStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
68 ((ScrollbarStyle)bindable).thumbColor = (Color)newValue;
70 defaultValueCreator: (bindable) =>
72 return ((ScrollbarStyle)bindable).thumbColor;
75 /// <summary>Bindable property of TrackPadding</summary>
76 [EditorBrowsable(EditorBrowsableState.Never)]
77 public static readonly BindableProperty TrackPaddingProperty = BindableProperty.Create(nameof(TrackPadding), typeof(Extents), typeof(ScrollbarStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
79 ((ScrollbarStyle)bindable).trackPadding = (Extents)newValue;
81 defaultValueCreator: (bindable) =>
83 return ((ScrollbarStyle)bindable).trackPadding;
86 private float? trackThickness;
87 private float? thumbThickness;
88 private Color trackColor;
89 private Color thumbColor;
90 private Extents trackPadding;
98 /// Creates a new instance of a ScrollbarStyle.
100 [EditorBrowsable(EditorBrowsableState.Never)]
101 public ScrollbarStyle() : base()
107 /// Copy constructor.
109 /// <param name="style">Create ScrollbarStyle by style customized by user.</param>
110 [EditorBrowsable(EditorBrowsableState.Never)]
111 public ScrollbarStyle(ScrollbarStyle style) : base(style)
113 this.CopyFrom(style);
117 /// Static constructor to initialize bindable properties when loading.
119 static ScrollbarStyle()
123 #endregion Constructors
129 /// The thickness of the track.
131 [EditorBrowsable(EditorBrowsableState.Never)]
132 public float? TrackThickness
134 get => (float?)GetValue(TrackThicknessProperty);
135 set => SetValue(TrackThicknessProperty, value);
139 /// The thickness of the thumb.
141 [EditorBrowsable(EditorBrowsableState.Never)]
142 public float? ThumbThickness
144 get => (float?)GetValue(ThumbThicknessProperty);
145 set => SetValue(ThumbThicknessProperty, value);
149 /// The color of the track part.
151 [EditorBrowsable(EditorBrowsableState.Never)]
152 public Color TrackColor
154 get => (Color)GetValue(TrackColorProperty);
155 set => SetValue(TrackColorProperty, value);
159 /// The color of the thumb part.
161 [EditorBrowsable(EditorBrowsableState.Never)]
162 public Color ThumbColor
164 get => (Color)GetValue(ThumbColorProperty);
165 set => SetValue(ThumbColorProperty, value);
169 /// The padding value of the track.
171 [EditorBrowsable(EditorBrowsableState.Never)]
172 public Extents TrackPadding
174 get => (Extents)GetValue(TrackPaddingProperty);
175 set => SetValue(TrackPaddingProperty, value);
178 #endregion Properties
184 [EditorBrowsable(EditorBrowsableState.Never)]
185 public override void CopyFrom(BindableObject bindableObject)
187 base.CopyFrom(bindableObject);
189 var style = bindableObject as ScrollbarStyle;
193 TrackThickness = style.TrackThickness;
194 ThumbThickness = style.ThumbThickness;
195 TrackColor = style.TrackColor;
196 ThumbColor = style.ThumbColor;
197 TrackPadding = style.TrackPadding;
201 private void Initialize()
203 TrackThickness = 6.0f;
204 ThumbThickness = 6.0f;
205 TrackColor = new Color(1.0f, 1.0f, 1.0f, 0.15f);
206 ThumbColor = new Color(0.6f, 0.6f, 0.6f, 1.0f);
208 WidthResizePolicy = ResizePolicyType.FillToParent;
209 HeightResizePolicy = ResizePolicyType.FillToParent;