/* * Copyright(c) 2021 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.BaseComponents; using Tizen.NUI.Binding; using static Tizen.NUI.Components.Slider; namespace Tizen.NUI.Components { /// /// SliderStyle is a class which saves Slider's ux data. /// /// 8 public class SliderStyle : ControlStyle { /// /// IndicatorTypeProperty /// [EditorBrowsable(EditorBrowsableState.Never)] public static readonly BindableProperty IndicatorTypeProperty = BindableProperty.Create(nameof(IndicatorType), typeof(IndicatorType?), typeof(SliderStyle), null, propertyChanged: (bindable, oldValue, newValue) => { var instance = (SliderStyle)bindable; if (newValue != null) { instance.privateIndicatorType = (IndicatorType)newValue; } }, defaultValueCreator: (bindable) => { var instance = (SliderStyle)bindable; return instance.privateIndicatorType; }); /// /// SpaceBetweenTrackAndIndicatorProperty /// [EditorBrowsable(EditorBrowsableState.Never)] public static readonly BindableProperty SpaceBetweenTrackAndIndicatorProperty = BindableProperty.Create(nameof(SpaceBetweenTrackAndIndicator), typeof(uint?), typeof(SliderStyle), null, propertyChanged: (bindable, oldValue, newValue) => { var instance = (SliderStyle)bindable; if (newValue != null) { instance.privateSpaceBetweenTrackAndIndicator = (uint?)newValue; } }, defaultValueCreator: (bindable) => { var instance = (SliderStyle)bindable; return instance.privateSpaceBetweenTrackAndIndicator; }); /// /// TrackThicknessProperty /// [EditorBrowsable(EditorBrowsableState.Never)] public static readonly BindableProperty TrackThicknessProperty = BindableProperty.Create(nameof(TrackThickness), typeof(uint?), typeof(SliderStyle), null, propertyChanged: (bindable, oldValue, newValue) => { var instance = (SliderStyle)bindable; if (newValue != null) { instance.privateTrackThickness = (uint?)newValue; } }, defaultValueCreator: (bindable) => { var instance = (SliderStyle)bindable; return instance.privateTrackThickness; }); /// /// TrackPaddingProperty /// [EditorBrowsable(EditorBrowsableState.Never)] public static readonly BindableProperty TrackPaddingProperty = BindableProperty.Create(nameof(TrackPadding), typeof(Extents), typeof(SliderStyle), null, propertyChanged: (bindable, oldValue, newValue) => { ((SliderStyle)bindable).trackPadding = newValue == null ? null : new Extents((Extents)newValue); }, defaultValueCreator: (bindable) => { var instance = (SliderStyle)bindable; return instance.trackPadding; }); private IndicatorType? privateIndicatorType = Slider.IndicatorType.None; private uint? privateTrackThickness; private uint? privateSpaceBetweenTrackAndIndicator; private Extents trackPadding; static SliderStyle() { } /// /// Creates a new instance of a SliderStyle. /// /// 8 public SliderStyle() : base() { } /// /// Creates a new instance of a SliderStyle with style. /// /// Create SliderStyle by style customized by user. /// 8 public SliderStyle(SliderStyle style) : base(style) { } /// /// Get or set background track. /// /// 8 public ImageViewStyle Track { get; set; } = new ImageViewStyle(); /// /// Get or set slided track. /// /// 8 public ImageViewStyle Progress { get; set; } = new ImageViewStyle(); /// /// Get or set thumb. /// /// 8 public ImageViewStyle Thumb { get; set; } = new ImageViewStyle(); /// /// Get or set background warning track. /// /// This will be public opened later after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] public ImageViewStyle WarningTrack { get; set; } = new ImageViewStyle(); /// /// Get or set slided warning track. /// /// This will be public opened later after ACR done. Before ACR, need to be hidden as inhouse API. [EditorBrowsable(EditorBrowsableState.Never)] public ImageViewStyle WarningProgress { get; set; } = new ImageViewStyle(); /// /// Get or set low indicator image. /// /// 8 public ImageViewStyle LowIndicatorImage { get; set; } = new ImageViewStyle(); /// /// Get or set high indicator image. /// /// 8 public ImageViewStyle HighIndicatorImage { get; set; } = new ImageViewStyle(); /// /// Get or set low indicator text. /// /// 8 public TextLabelStyle LowIndicator { get; set; } = new TextLabelStyle(); /// /// Get or set high indicator text. /// /// 8 public TextLabelStyle HighIndicator { get; set; } = new TextLabelStyle(); /// /// Get or set the value indicator text. /// /// 9 public TextLabelStyle ValueIndicatorText { get; set; } = new TextLabelStyle(); /// /// Get or set the value indicator image. /// /// 9 public ImageViewStyle ValueIndicatorImage { get; set; } = new ImageViewStyle(); /// /// Get or set Indicator type /// /// 8 public IndicatorType? IndicatorType { get => (IndicatorType?)GetValue(IndicatorTypeProperty); set => SetValue(IndicatorTypeProperty, value); } /// /// Get or set track thickness /// /// 8 public uint? TrackThickness { get => (uint?)GetValue(TrackThicknessProperty); set => SetValue(TrackThicknessProperty, value); } /// /// Get or set space between track and indicator /// /// 8 public uint? SpaceBetweenTrackAndIndicator { get => (uint?)GetValue(SpaceBetweenTrackAndIndicatorProperty); set => SetValue(SpaceBetweenTrackAndIndicatorProperty, value); } /// /// Get or set space between track and indicator /// /// 8 public Extents TrackPadding { get => ((Extents)GetValue(TrackPaddingProperty)) ?? (trackPadding = new Extents(0, 0, 0, 0)); set => SetValue(TrackPaddingProperty, value); } /// /// 8 public override void CopyFrom(BindableObject bindableObject) { base.CopyFrom(bindableObject); if (bindableObject is SliderStyle sliderStyle) { Track.CopyFrom(sliderStyle.Track); Progress.CopyFrom(sliderStyle.Progress); Thumb.CopyFrom(sliderStyle.Thumb); WarningTrack.CopyFrom(sliderStyle.WarningTrack); WarningProgress.CopyFrom(sliderStyle.WarningProgress); LowIndicatorImage.CopyFrom(sliderStyle.LowIndicatorImage); HighIndicatorImage.CopyFrom(sliderStyle.HighIndicatorImage); LowIndicator.CopyFrom(sliderStyle.LowIndicator); HighIndicator.CopyFrom(sliderStyle.HighIndicator); ValueIndicatorText.CopyFrom(sliderStyle.ValueIndicatorText); ValueIndicatorImage.CopyFrom(sliderStyle.ValueIndicatorImage); } } /// /// Dispose SliderStyle and all children on it. /// /// true in order to free managed objects [EditorBrowsable(EditorBrowsableState.Never)] protected override void Dispose(bool disposing) { if (disposing) { trackPadding?.Dispose(); } base.Dispose(disposing); } } }