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.Components;
19 using Tizen.NUI.Binding;
21 namespace Tizen.NUI.Wearable
24 /// CircularScrollbarStyle is a class which saves CircularScrollbar's ux data.
26 [EditorBrowsable(EditorBrowsableState.Never)]
27 public class CircularScrollbarStyle : ControlStyle
31 /// <summary>Bindable property of Thickness</summary>
32 [EditorBrowsable(EditorBrowsableState.Never)]
33 public static readonly BindableProperty ThicknessProperty = BindableProperty.Create(nameof(Thickness), typeof(float?), typeof(CircularScrollbarStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
35 ((CircularScrollbarStyle)bindable).thickness = (float?)newValue;
37 defaultValueCreator: (bindable) =>
39 return ((CircularScrollbarStyle)bindable).thickness;
42 /// <summary>Bindable property of TrackSweepAngle</summary>
43 [EditorBrowsable(EditorBrowsableState.Never)]
44 public static readonly BindableProperty TrackSweepAngleProperty = BindableProperty.Create(nameof(TrackSweepAngle), typeof(float?), typeof(CircularScrollbarStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
46 ((CircularScrollbarStyle)bindable).trackSweepAngle = (float?)newValue;
48 defaultValueCreator: (bindable) =>
50 return ((CircularScrollbarStyle)bindable).trackSweepAngle;
53 /// <summary>Bindable property of TrackColor</summary>
54 [EditorBrowsable(EditorBrowsableState.Never)]
55 public static readonly BindableProperty TrackColorProperty = BindableProperty.Create(nameof(TrackColor), typeof(Color), typeof(CircularScrollbarStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
57 ((CircularScrollbarStyle)bindable).trackColor = (Color)newValue;
59 defaultValueCreator: (bindable) =>
61 return ((CircularScrollbarStyle)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(CircularScrollbarStyle), null, propertyChanged: (bindable, oldValue, newValue) =>
68 ((CircularScrollbarStyle)bindable).thumbColor = (Color)newValue;
70 defaultValueCreator: (bindable) =>
72 return ((CircularScrollbarStyle)bindable).thumbColor;
75 private float? thickness;
76 private float? trackSweepAngle;
77 private Color trackColor;
78 private Color thumbColor;
86 /// Creates a new instance of a CircularScrollbarStyle.
88 [EditorBrowsable(EditorBrowsableState.Never)]
89 public CircularScrollbarStyle() : base()
97 /// <param name="style">Create ScrollbarStyle by style customized by user.</param>
98 [EditorBrowsable(EditorBrowsableState.Never)]
99 public CircularScrollbarStyle(CircularScrollbarStyle style) : base(style)
101 this.CopyFrom(style);
105 /// Static constructor to initialize bindable properties when loading.
107 static CircularScrollbarStyle()
111 #endregion Constructors
117 /// The thickness of the scrollbar and track.
119 [EditorBrowsable(EditorBrowsableState.Never)]
120 public float? Thickness
122 get => (float?)GetValue(ThicknessProperty);
123 set => SetValue(ThicknessProperty, value);
127 /// The sweep angle of track area in degrees.
130 /// Values below 6 degrees are treated as 6 degrees.
131 /// Values exceeding 180 degrees are treated as 180 degrees.
133 [EditorBrowsable(EditorBrowsableState.Never)]
134 public float? TrackSweepAngle
136 get => (float?)GetValue(TrackSweepAngleProperty);
137 set => SetValue(TrackSweepAngleProperty, value);
141 /// The color of the track part.
143 [EditorBrowsable(EditorBrowsableState.Never)]
144 public Color TrackColor
146 get => (Color)GetValue(TrackColorProperty);
147 set => SetValue(TrackColorProperty, value);
151 /// The color of the thumb part.
153 [EditorBrowsable(EditorBrowsableState.Never)]
154 public Color ThumbColor
156 get => (Color)GetValue(ThumbColorProperty);
157 set => SetValue(ThumbColorProperty, value);
160 #endregion Properties
166 [EditorBrowsable(EditorBrowsableState.Never)]
167 public override void CopyFrom(BindableObject bindableObject)
169 base.CopyFrom(bindableObject);
171 var style = bindableObject as CircularScrollbarStyle;
175 Thickness = style.Thickness;
176 TrackSweepAngle = style.TrackSweepAngle;
177 TrackColor = style.TrackColor;
178 ThumbColor = style.ThumbColor;
182 private void Initialize()
185 TrackSweepAngle = 60.0f;
186 TrackColor = new Color(1.0f, 1.0f, 1.0f, 0.15f);
187 ThumbColor = new Color(0.6f, 0.6f, 0.6f, 1.0f);
188 WidthResizePolicy = ResizePolicyType.FillToParent;
189 HeightResizePolicy = ResizePolicyType.FillToParent;