feat: :pressed, comparison.
This commit is contained in:
@@ -52,6 +52,7 @@
|
|||||||
<u:RangeTrack
|
<u:RangeTrack
|
||||||
Name="{x:Static u:RangeSlider.PART_Track}"
|
Name="{x:Static u:RangeSlider.PART_Track}"
|
||||||
Grid.Row="1"
|
Grid.Row="1"
|
||||||
|
Cursor="Hand"
|
||||||
HorizontalAlignment="Stretch"
|
HorizontalAlignment="Stretch"
|
||||||
VerticalAlignment="Stretch"
|
VerticalAlignment="Stretch"
|
||||||
Orientation="{Binding Orientation, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}"
|
Orientation="{Binding Orientation, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}"
|
||||||
@@ -142,6 +143,7 @@
|
|||||||
Ticks="{TemplateBinding Ticks}" />
|
Ticks="{TemplateBinding Ticks}" />
|
||||||
<u:RangeTrack
|
<u:RangeTrack
|
||||||
Name="{x:Static u:RangeSlider.PART_Track}"
|
Name="{x:Static u:RangeSlider.PART_Track}"
|
||||||
|
Cursor="Hand"
|
||||||
Grid.Column="1"
|
Grid.Column="1"
|
||||||
HorizontalAlignment="Stretch"
|
HorizontalAlignment="Stretch"
|
||||||
VerticalAlignment="Stretch"
|
VerticalAlignment="Stretch"
|
||||||
|
|||||||
@@ -13,12 +13,13 @@ using Avalonia.Utilities;
|
|||||||
namespace Ursa.Controls;
|
namespace Ursa.Controls;
|
||||||
|
|
||||||
[TemplatePart(PART_Track, typeof(RangeTrack))]
|
[TemplatePart(PART_Track, typeof(RangeTrack))]
|
||||||
[PseudoClasses(PC_Horizontal, PC_Vertical)]
|
[PseudoClasses(PC_Horizontal, PC_Vertical, PC_Pressed)]
|
||||||
public class RangeSlider: TemplatedControl
|
public class RangeSlider: TemplatedControl
|
||||||
{
|
{
|
||||||
public const string PART_Track = "PART_Track";
|
public const string PART_Track = "PART_Track";
|
||||||
private const string PC_Horizontal= ":horizontal";
|
private const string PC_Horizontal= ":horizontal";
|
||||||
private const string PC_Vertical = ":vertical";
|
private const string PC_Vertical = ":vertical";
|
||||||
|
private const string PC_Pressed = ":pressed";
|
||||||
|
|
||||||
private RangeTrack? _track;
|
private RangeTrack? _track;
|
||||||
private bool _isDragging;
|
private bool _isDragging;
|
||||||
@@ -26,6 +27,8 @@ public class RangeSlider: TemplatedControl
|
|||||||
private IDisposable? _pointerMoveDisposable;
|
private IDisposable? _pointerMoveDisposable;
|
||||||
private IDisposable? _pointerReleasedDisposable;
|
private IDisposable? _pointerReleasedDisposable;
|
||||||
|
|
||||||
|
private const double Tolerance = 0.0001;
|
||||||
|
|
||||||
public static readonly StyledProperty<double> MinimumProperty = RangeTrack.MinimumProperty.AddOwner<RangeSlider>();
|
public static readonly StyledProperty<double> MinimumProperty = RangeTrack.MinimumProperty.AddOwner<RangeSlider>();
|
||||||
public double Minimum
|
public double Minimum
|
||||||
{
|
{
|
||||||
@@ -144,7 +147,7 @@ public class RangeSlider: TemplatedControl
|
|||||||
{
|
{
|
||||||
var oldValue = args.OldValue.Value;
|
var oldValue = args.OldValue.Value;
|
||||||
var newValue = args.NewValue.Value;
|
var newValue = args.NewValue.Value;
|
||||||
if (oldValue != newValue)
|
if (Math.Abs(oldValue - newValue) > Tolerance)
|
||||||
{
|
{
|
||||||
RaiseEvent(new RangeValueChangedEventArgs(ValueChangedEvent, this, oldValue, newValue, isLower));
|
RaiseEvent(new RangeValueChangedEventArgs(ValueChangedEvent, this, oldValue, newValue, isLower));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ public class RangeTrack: Control
|
|||||||
private double _density;
|
private double _density;
|
||||||
private Vector _lastDrag;
|
private Vector _lastDrag;
|
||||||
|
|
||||||
|
private const double Tolerance = 0.0001;
|
||||||
|
|
||||||
public static readonly StyledProperty<double> MinimumProperty = AvaloniaProperty.Register<RangeTrack, double>(
|
public static readonly StyledProperty<double> MinimumProperty = AvaloniaProperty.Register<RangeTrack, double>(
|
||||||
nameof(Minimum), coerce: CoerceMinimum, defaultBindingMode:BindingMode.TwoWay);
|
nameof(Minimum), coerce: CoerceMinimum, defaultBindingMode:BindingMode.TwoWay);
|
||||||
|
|
||||||
@@ -165,7 +167,7 @@ public class RangeTrack: Control
|
|||||||
{
|
{
|
||||||
var oldValue = args.OldValue.Value;
|
var oldValue = args.OldValue.Value;
|
||||||
var newValue = args.NewValue.Value;
|
var newValue = args.NewValue.Value;
|
||||||
if (oldValue != newValue)
|
if (Math.Abs(oldValue - newValue) > Tolerance)
|
||||||
{
|
{
|
||||||
RaiseEvent(new RangeValueChangedEventArgs(ValueChangedEvent, this, oldValue, newValue, isLower));
|
RaiseEvent(new RangeValueChangedEventArgs(ValueChangedEvent, this, oldValue, newValue, isLower));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user