/*
* 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.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
{
/// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
[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;
});
/// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
[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;
});
/// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
[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;
});
/// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
[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 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 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);
}
///
/// Style's clone function.
///
/// The style that need to copy.
/// 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);
LowIndicatorImage.CopyFrom(sliderStyle.LowIndicatorImage);
HighIndicatorImage.CopyFrom(sliderStyle.HighIndicatorImage);
LowIndicator.CopyFrom(sliderStyle.LowIndicator);
HighIndicator.CopyFrom(sliderStyle.HighIndicator);
}
}
///
/// Dispose SliderStyle and all children on it.
///
/// Dispose type.
[EditorBrowsable(EditorBrowsableState.Never)]
protected override void Dispose(DisposeTypes type)
{
if (disposed)
{
return;
}
if (type == DisposeTypes.Explicit)
{
trackPadding?.Dispose();
}
base.Dispose(type);
}
}
}