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.Binding;
20 namespace Tizen.NUI.Components
23 /// ScrollbarStyle is a class which saves Scrollbar's style data.
25 [EditorBrowsable(EditorBrowsableState.Never)]
26 public class ScrollbarStyle : ControlStyle
30 /// <summary>Bindable property of TrackThickness</summary>
31 [EditorBrowsable(EditorBrowsableState.Never)]
32 public static readonly BindableProperty TrackThicknessProperty = BindableProperty.Create(nameof(TrackThickness), typeof(float?), typeof(ScrollbarStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
34 ((ScrollbarStyle)bindable).trackThickness = (float?)newValue;
36 defaultValueCreator: (bindable) =>
38 return ((ScrollbarStyle)bindable).trackThickness;
41 /// <summary>Bindable property of ThumbThickness</summary>
42 [EditorBrowsable(EditorBrowsableState.Never)]
43 public static readonly BindableProperty ThumbThicknessProperty = BindableProperty.Create(nameof(ThumbThickness), typeof(float?), typeof(ScrollbarStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
45 ((ScrollbarStyle)bindable).thumbThickness = (float?)newValue;
47 defaultValueCreator: (bindable) =>
49 return ((ScrollbarStyle)bindable).thumbThickness;
52 /// <summary>Bindable property of TrackColor</summary>
53 [EditorBrowsable(EditorBrowsableState.Never)]
54 public static readonly BindableProperty TrackColorProperty = BindableProperty.Create(nameof(TrackColor), typeof(Color), typeof(ScrollbarStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
56 ((ScrollbarStyle)bindable).trackColor = (Color)newValue;
58 defaultValueCreator: (bindable) =>
60 return ((ScrollbarStyle)bindable).trackColor;
63 /// <summary>Bindable property of ThumbColor</summary>
64 [EditorBrowsable(EditorBrowsableState.Never)]
65 public static readonly BindableProperty ThumbColorProperty = BindableProperty.Create(nameof(ThumbColor), typeof(Color), typeof(ScrollbarStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
67 ((ScrollbarStyle)bindable).thumbColor = (Color)newValue;
69 defaultValueCreator: (bindable) =>
71 return ((ScrollbarStyle)bindable).thumbColor;
74 /// <summary>Bindable property of TrackPadding</summary>
75 [EditorBrowsable(EditorBrowsableState.Never)]
76 public static readonly BindableProperty TrackPaddingProperty = BindableProperty.Create(nameof(TrackPadding), typeof(Extents), typeof(ScrollbarStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
78 ((ScrollbarStyle)bindable).trackPadding = (Extents)newValue;
80 defaultValueCreator: (bindable) =>
82 return ((ScrollbarStyle)bindable).trackPadding;
85 private float? trackThickness;
86 private float? thumbThickness;
87 private Color trackColor;
88 private Color thumbColor;
89 private Extents trackPadding;
97 /// Creates a new instance of a ScrollbarStyle.
99 [EditorBrowsable(EditorBrowsableState.Never)]
100 public ScrollbarStyle() : base()
106 /// Copy constructor.
108 /// <param name="style">Create ScrollbarStyle by style customized by user.</param>
109 [EditorBrowsable(EditorBrowsableState.Never)]
110 public ScrollbarStyle(ScrollbarStyle style) : base(style)
112 this.CopyFrom(style);
116 /// Static constructor to initialize bindable properties when loading.
118 static ScrollbarStyle()
122 #endregion Constructors
128 /// The thickness of the track.
130 [EditorBrowsable(EditorBrowsableState.Never)]
131 public float? TrackThickness
133 get => (float?)GetValue(TrackThicknessProperty);
134 set => SetValue(TrackThicknessProperty, value);
138 /// The thickness of the thumb.
140 [EditorBrowsable(EditorBrowsableState.Never)]
141 public float? ThumbThickness
143 get => (float?)GetValue(ThumbThicknessProperty);
144 set => SetValue(ThumbThicknessProperty, value);
148 /// The color of the track part.
150 [EditorBrowsable(EditorBrowsableState.Never)]
151 public Color TrackColor
153 get => (Color)GetValue(TrackColorProperty);
154 set => SetValue(TrackColorProperty, value);
158 /// The color of the thumb part.
160 [EditorBrowsable(EditorBrowsableState.Never)]
161 public Color ThumbColor
163 get => (Color)GetValue(ThumbColorProperty);
164 set => SetValue(ThumbColorProperty, value);
168 /// The padding value of the track.
170 [EditorBrowsable(EditorBrowsableState.Never)]
171 public Extents TrackPadding
173 get => (Extents)GetValue(TrackPaddingProperty);
174 set => SetValue(TrackPaddingProperty, value);
177 #endregion Properties
183 [EditorBrowsable(EditorBrowsableState.Never)]
184 public override void CopyFrom(BindableObject bindableObject)
186 base.CopyFrom(bindableObject);
188 var style = bindableObject as ScrollbarStyle;
192 TrackThickness = style.TrackThickness;
193 ThumbThickness = style.ThumbThickness;
194 TrackColor = style.TrackColor;
195 ThumbColor = style.ThumbColor;
196 TrackPadding = style.TrackPadding;
200 private void Initialize()
202 TrackThickness = 6.0f;
203 ThumbThickness = 6.0f;
204 TrackColor = new Color(1.0f, 1.0f, 1.0f, 0.15f);
205 ThumbColor = new Color(0.6f, 0.6f, 0.6f, 1.0f);
207 WidthResizePolicy = ResizePolicyType.FillToParent;
208 HeightResizePolicy = ResizePolicyType.FillToParent;