/* * Copyright(c) 2019 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ using System.ComponentModel; using Tizen.NUI.Components; using Tizen.NUI.Binding; namespace Tizen.NUI.Wearable { /// /// CircularScrollbarStyle is a class which saves CircularScrollbar's ux data. /// [EditorBrowsable(EditorBrowsableState.Never)] public class CircularScrollbarStyle : ControlStyle { #region Fields /// Bindable property of Thickness [EditorBrowsable(EditorBrowsableState.Never)] public static readonly BindableProperty ThicknessProperty = BindableProperty.Create(nameof(Thickness), typeof(float?), typeof(CircularScrollbarStyle), null, propertyChanged: (bindable, oldValue, newValue) => { ((CircularScrollbarStyle)bindable).thickness = (float?)newValue; }, defaultValueCreator: (bindable) => { return ((CircularScrollbarStyle)bindable).thickness; }); /// Bindable property of TrackSweepAngle [EditorBrowsable(EditorBrowsableState.Never)] public static readonly BindableProperty TrackSweepAngleProperty = BindableProperty.Create(nameof(TrackSweepAngle), typeof(float?), typeof(CircularScrollbarStyle), null, propertyChanged: (bindable, oldValue, newValue) => { ((CircularScrollbarStyle)bindable).trackSweepAngle = (float?)newValue; }, defaultValueCreator: (bindable) => { return ((CircularScrollbarStyle)bindable).trackSweepAngle; }); /// Bindable property of TrackColor [EditorBrowsable(EditorBrowsableState.Never)] public static readonly BindableProperty TrackColorProperty = BindableProperty.Create(nameof(TrackColor), typeof(Color), typeof(CircularScrollbarStyle), null, propertyChanged: (bindable, oldValue, newValue) => { ((CircularScrollbarStyle)bindable).trackColor = (Color)newValue; }, defaultValueCreator: (bindable) => { return ((CircularScrollbarStyle)bindable).trackColor; }); /// Bindable property of ThumbColor [EditorBrowsable(EditorBrowsableState.Never)] public static readonly BindableProperty ThumbColorProperty = BindableProperty.Create(nameof(ThumbColor), typeof(Color), typeof(CircularScrollbarStyle), null, propertyChanged: (bindable, oldValue, newValue) => { ((CircularScrollbarStyle)bindable).thumbColor = (Color)newValue; }, defaultValueCreator: (bindable) => { return ((CircularScrollbarStyle)bindable).thumbColor; }); private float? thickness; private float? trackSweepAngle; private Color trackColor; private Color thumbColor; #endregion Fields #region Constructors /// /// Creates a new instance of a CircularScrollbarStyle. /// [EditorBrowsable(EditorBrowsableState.Never)] public CircularScrollbarStyle() : base() { Initialize(); } /// /// Copy constructor. /// /// Create ScrollbarStyle by style customized by user. [EditorBrowsable(EditorBrowsableState.Never)] public CircularScrollbarStyle(CircularScrollbarStyle style) : base(style) { this.CopyFrom(style); } /// /// Static constructor to initialize bindable properties when loading. /// static CircularScrollbarStyle() { } #endregion Constructors #region Properties /// /// The thickness of the scrollbar and track. /// [EditorBrowsable(EditorBrowsableState.Never)] public float? Thickness { get => (float?)GetValue(ThicknessProperty); set => SetValue(ThicknessProperty, value); } /// /// The sweep angle of track area in degrees. /// /// /// Values below 6 degrees are treated as 6 degrees. /// Values exceeding 180 degrees are treated as 180 degrees. /// [EditorBrowsable(EditorBrowsableState.Never)] public float? TrackSweepAngle { get => (float?)GetValue(TrackSweepAngleProperty); set => SetValue(TrackSweepAngleProperty, value); } /// /// The color of the track part. /// [EditorBrowsable(EditorBrowsableState.Never)] public Color TrackColor { get => (Color)GetValue(TrackColorProperty); set => SetValue(TrackColorProperty, value); } /// /// The color of the thumb part. /// [EditorBrowsable(EditorBrowsableState.Never)] public Color ThumbColor { get => (Color)GetValue(ThumbColorProperty); set => SetValue(ThumbColorProperty, value); } #endregion Properties #region Methods /// [EditorBrowsable(EditorBrowsableState.Never)] public override void CopyFrom(BindableObject bindableObject) { base.CopyFrom(bindableObject); var style = bindableObject as CircularScrollbarStyle; if (null != style) { Thickness = style.Thickness; TrackSweepAngle = style.TrackSweepAngle; TrackColor = style.TrackColor; ThumbColor = style.ThumbColor; } } private void Initialize() { Thickness = 10.0f; TrackSweepAngle = 60.0f; TrackColor = new Color(1.0f, 1.0f, 1.0f, 0.15f); ThumbColor = new Color(0.6f, 0.6f, 0.6f, 1.0f); WidthResizePolicy = ResizePolicyType.FillToParent; HeightResizePolicy = ResizePolicyType.FillToParent; } #endregion Methods } }