diff --git a/src/Avalonia.Controls/Button.cs b/src/Avalonia.Controls/Button.cs
index 52329b9c88..5b98a46dd0 100644
--- a/src/Avalonia.Controls/Button.cs
+++ b/src/Avalonia.Controls/Button.cs
@@ -2,13 +2,10 @@
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System;
-using System.Linq;
using System.Windows.Input;
using Avalonia.Data;
using Avalonia.Input;
using Avalonia.Interactivity;
-using Avalonia.Rendering;
-using Avalonia.VisualTree;
namespace Avalonia.Controls
{
@@ -68,7 +65,7 @@ namespace Avalonia.Controls
/// Defines the event.
///
public static readonly RoutedEvent ClickEvent =
- RoutedEvent.Register("Click", RoutingStrategies.Bubble);
+ RoutedEvent.Register(nameof(Click), RoutingStrategies.Bubble);
private ICommand _command;
@@ -78,7 +75,6 @@ namespace Avalonia.Controls
static Button()
{
FocusableProperty.OverrideDefaultValue(typeof(Button), true);
- ClickEvent.AddClassHandler(x => x.OnClick);
CommandProperty.Changed.Subscribe(CommandChanged);
IsDefaultProperty.Changed.Subscribe(IsDefaultChanged);
}
@@ -145,9 +141,7 @@ namespace Avalonia.Controls
if (IsDefault)
{
- var inputElement = e.Root as IInputElement;
-
- if (inputElement != null)
+ if (e.Root is IInputElement inputElement)
{
ListenForDefault(inputElement);
}
@@ -159,14 +153,14 @@ namespace Avalonia.Controls
{
if (e.Key == Key.Enter)
{
- RaiseClickEvent();
+ OnClick();
e.Handled = true;
}
else if (e.Key == Key.Space)
{
if (ClickMode == ClickMode.Press)
{
- RaiseClickEvent();
+ OnClick();
}
e.Handled = true;
@@ -182,7 +176,7 @@ namespace Avalonia.Controls
{
if (ClickMode == ClickMode.Release)
{
- RaiseClickEvent();
+ OnClick();
}
e.Handled = true;
@@ -196,9 +190,7 @@ namespace Avalonia.Controls
if (IsDefault)
{
- var inputElement = e.Root as IInputElement;
-
- if (inputElement != null)
+ if (e.Root is IInputElement inputElement)
{
StopListeningForDefault(inputElement);
}
@@ -208,9 +200,11 @@ namespace Avalonia.Controls
///
/// Invokes the event.
///
- /// The event args.
- protected virtual void OnClick(RoutedEventArgs e)
+ protected virtual void OnClick()
{
+ var e = new RoutedEventArgs(ClickEvent);
+ RaiseEvent(e);
+
if (Command != null)
{
Command.Execute(CommandParameter);
@@ -231,7 +225,7 @@ namespace Avalonia.Controls
if (ClickMode == ClickMode.Press)
{
- RaiseClickEvent();
+ OnClick();
}
}
}
@@ -249,7 +243,7 @@ namespace Avalonia.Controls
if (ClickMode == ClickMode.Release && new Rect(Bounds.Size).Contains(e.GetPosition(this)))
{
- RaiseClickEvent();
+ OnClick();
}
}
}
@@ -272,9 +266,7 @@ namespace Avalonia.Controls
/// The event args.
private static void CommandChanged(AvaloniaPropertyChangedEventArgs e)
{
- var button = e.Sender as Button;
-
- if (button != null)
+ if (e.Sender is Button button)
{
var oldCommand = e.OldValue as ICommand;
var newCommand = e.NewValue as ICommand;
@@ -301,9 +293,8 @@ namespace Avalonia.Controls
{
var button = e.Sender as Button;
var isDefault = (bool)e.NewValue;
- var inputRoot = button?.VisualRoot as IInputElement;
- if (inputRoot != null)
+ if (button?.VisualRoot is IInputElement inputRoot)
{
if (isDefault)
{
@@ -346,19 +337,6 @@ namespace Avalonia.Controls
root.RemoveHandler(KeyDownEvent, RootKeyDown);
}
- ///
- /// Raises the event.
- ///
- private void RaiseClickEvent()
- {
- RoutedEventArgs click = new RoutedEventArgs
- {
- RoutedEvent = ClickEvent,
- };
-
- RaiseEvent(click);
- }
-
///
/// Called when a key is pressed on the input root and the button .
///
@@ -368,7 +346,7 @@ namespace Avalonia.Controls
{
if (e.Key == Key.Enter && IsVisible && IsEnabled)
{
- RaiseClickEvent();
+ OnClick();
}
}
}
diff --git a/src/Avalonia.Controls/Primitives/RangeBase.cs b/src/Avalonia.Controls/Primitives/RangeBase.cs
index 878f76c033..b69dbba637 100644
--- a/src/Avalonia.Controls/Primitives/RangeBase.cs
+++ b/src/Avalonia.Controls/Primitives/RangeBase.cs
@@ -38,6 +38,18 @@ namespace Avalonia.Controls.Primitives
o => o.Value,
(o, v) => o.Value = v);
+ ///
+ /// Defines the property.
+ ///
+ public static readonly StyledProperty SmallChangeProperty =
+ AvaloniaProperty.Register(nameof(SmallChange), 0.1);
+
+ ///
+ /// Defines the property.
+ ///
+ public static readonly StyledProperty LargeChangeProperty =
+ AvaloniaProperty.Register(nameof(LargeChange), 1);
+
private double _minimum;
private double _maximum = 100.0;
private double _value;
@@ -103,6 +115,18 @@ namespace Avalonia.Controls.Primitives
}
}
+ public double SmallChange
+ {
+ get => GetValue(SmallChangeProperty);
+ set => SetValue(SmallChangeProperty, value);
+ }
+
+ public double LargeChange
+ {
+ get => GetValue(LargeChangeProperty);
+ set => SetValue(LargeChangeProperty, value);
+ }
+
///
/// Throws an exception if the double valus is NaN or Inf.
///
diff --git a/src/Avalonia.Controls/Primitives/ScrollBar.cs b/src/Avalonia.Controls/Primitives/ScrollBar.cs
index 1fab5ca4ad..0f69e4e5bc 100644
--- a/src/Avalonia.Controls/Primitives/ScrollBar.cs
+++ b/src/Avalonia.Controls/Primitives/ScrollBar.cs
@@ -5,6 +5,7 @@ using System;
using System.Reactive;
using System.Reactive.Linq;
using Avalonia.Data;
+using Avalonia.Interactivity;
namespace Avalonia.Controls.Primitives
{
@@ -31,13 +32,18 @@ namespace Avalonia.Controls.Primitives
public static readonly StyledProperty OrientationProperty =
AvaloniaProperty.Register(nameof(Orientation));
+ private Button _lineUpButton;
+ private Button _lineDownButton;
+ private Button _pageUpButton;
+ private Button _pageDownButton;
+
///
/// Initializes static members of the class.
///
static ScrollBar()
{
- PseudoClass(OrientationProperty, o => o == Avalonia.Controls.Orientation.Vertical, ":vertical");
- PseudoClass(OrientationProperty, o => o == Avalonia.Controls.Orientation.Horizontal, ":horizontal");
+ PseudoClass(OrientationProperty, o => o == Orientation.Vertical, ":vertical");
+ PseudoClass(OrientationProperty, o => o == Orientation.Horizontal, ":horizontal");
}
///
@@ -97,12 +103,101 @@ namespace Avalonia.Controls.Primitives
return false;
case ScrollBarVisibility.Auto:
- var viewportSize = ViewportSize;
- return double.IsNaN(viewportSize) || viewportSize < Maximum - Minimum;
+ return double.IsNaN(ViewportSize) || Maximum > 0;
default:
throw new InvalidOperationException("Invalid value for ScrollBar.Visibility.");
}
}
+
+ protected override void OnTemplateApplied(TemplateAppliedEventArgs e)
+ {
+ base.OnTemplateApplied(e);
+
+ if (_lineUpButton != null)
+ {
+ _lineUpButton.Click -= LineUpClick;
+ }
+
+ if (_lineDownButton != null)
+ {
+ _lineDownButton.Click -= LineDownClick;
+ }
+
+ if (_pageUpButton != null)
+ {
+ _pageUpButton.Click -= PageUpClick;
+ }
+
+ if (_pageDownButton != null)
+ {
+ _pageDownButton.Click -= PageDownClick;
+ }
+
+ _lineUpButton = e.NameScope.Find("PART_LineUpButton");
+ _lineDownButton = e.NameScope.Find("PART_LineDownButton");
+ _pageUpButton = e.NameScope.Find("PART_PageUpButton");
+ _pageDownButton = e.NameScope.Find("PART_PageDownButton");
+
+ if (_lineUpButton != null)
+ {
+ _lineUpButton.Click += LineUpClick;
+ }
+
+ if (_lineDownButton != null)
+ {
+ _lineDownButton.Click += LineDownClick;
+ }
+
+ if (_pageUpButton != null)
+ {
+ _pageUpButton.Click += PageUpClick;
+ }
+
+ if (_pageDownButton != null)
+ {
+ _pageDownButton.Click += PageDownClick;
+ }
+ }
+
+ private void LineUpClick(object sender, RoutedEventArgs e)
+ {
+ SmallDecrement();
+ }
+
+ private void LineDownClick(object sender, RoutedEventArgs e)
+ {
+ SmallIncrement();
+ }
+
+ private void PageUpClick(object sender, RoutedEventArgs e)
+ {
+ LargeDecrement();
+ }
+
+ private void PageDownClick(object sender, RoutedEventArgs e)
+ {
+ LargeIncrement();
+ }
+
+ private void SmallDecrement()
+ {
+ Value = Math.Max(Value - SmallChange * ViewportSize, Minimum);
+ }
+
+ private void SmallIncrement()
+ {
+ Value = Math.Min(Value + SmallChange * ViewportSize, Maximum);
+ }
+
+ private void LargeDecrement()
+ {
+ Value = Math.Max(Value - LargeChange * ViewportSize, Minimum);
+ }
+
+ private void LargeIncrement()
+ {
+ Value = Math.Min(Value + LargeChange * ViewportSize, Maximum);
+ }
}
}
diff --git a/src/Avalonia.Controls/Primitives/ToggleButton.cs b/src/Avalonia.Controls/Primitives/ToggleButton.cs
index 6c6887b2f1..4e9e326997 100644
--- a/src/Avalonia.Controls/Primitives/ToggleButton.cs
+++ b/src/Avalonia.Controls/Primitives/ToggleButton.cs
@@ -29,10 +29,10 @@ namespace Avalonia.Controls.Primitives
set { SetAndRaise(IsCheckedProperty, ref _isChecked, value); }
}
- protected override void OnClick(RoutedEventArgs e)
+ protected override void OnClick()
{
Toggle();
- base.OnClick(e);
+ base.OnClick();
}
protected virtual void Toggle()
diff --git a/src/Avalonia.Controls/Primitives/Track.cs b/src/Avalonia.Controls/Primitives/Track.cs
index 00ebe417e2..a9b6afc172 100644
--- a/src/Avalonia.Controls/Primitives/Track.cs
+++ b/src/Avalonia.Controls/Primitives/Track.cs
@@ -10,7 +10,7 @@ namespace Avalonia.Controls.Primitives
public class Track : Control
{
public static readonly DirectProperty MinimumProperty =
- RangeBase.MinimumProperty.AddOwner(o => o.Minimum, (o,v) => o.Minimum = v);
+ RangeBase.MinimumProperty.AddOwner(o => o.Minimum, (o, v) => o.Minimum = v);
public static readonly DirectProperty MaximumProperty =
RangeBase.MaximumProperty.AddOwner(o => o.Maximum, (o, v) => o.Maximum = v);
@@ -25,7 +25,13 @@ namespace Avalonia.Controls.Primitives
ScrollBar.OrientationProperty.AddOwner();
public static readonly StyledProperty ThumbProperty =
- AvaloniaProperty.Register("Thumb");
+ AvaloniaProperty.Register(nameof(Thumb));
+
+ public static readonly StyledProperty IncreaseButtonProperty =
+ AvaloniaProperty.Register(nameof(IncreaseButton));
+
+ public static readonly StyledProperty DecreaseButtonProperty =
+ AvaloniaProperty.Register(nameof(DecreaseButton));
private double _minimum;
private double _maximum = 100.0;
@@ -34,6 +40,8 @@ namespace Avalonia.Controls.Primitives
static Track()
{
ThumbProperty.Changed.AddClassHandler(x => x.ThumbChanged);
+ IncreaseButtonProperty.Changed.AddClassHandler(x => x.ButtonChanged);
+ DecreaseButtonProperty.Changed.AddClassHandler(x => x.ButtonChanged);
AffectsArrange(MinimumProperty, MaximumProperty, ValueProperty, OrientationProperty);
}
@@ -74,6 +82,18 @@ namespace Avalonia.Controls.Primitives
set { SetValue(ThumbProperty, value); }
}
+ public Button IncreaseButton
+ {
+ get { return GetValue(IncreaseButtonProperty); }
+ set { SetValue(IncreaseButtonProperty, value); }
+ }
+
+ public Button DecreaseButton
+ {
+ get { return GetValue(DecreaseButtonProperty); }
+ set { SetValue(DecreaseButtonProperty, value); }
+ }
+
protected override Size MeasureOverride(Size availableSize)
{
var thumb = Thumb;
@@ -98,34 +118,54 @@ namespace Avalonia.Controls.Primitives
protected override Size ArrangeOverride(Size finalSize)
{
var thumb = Thumb;
+ var increaseButton = IncreaseButton;
+ var decreaseButton = DecreaseButton;
- if (thumb != null)
+ var range = Maximum - Minimum;
+ var offset = Math.Min(Value - Minimum, range);
+ var viewportSize = ViewportSize;
+ var extent = range + viewportSize;
+
+ if (Orientation == Orientation.Horizontal)
{
- var range = Maximum - Minimum;
- var thumbFraction = ViewportSize / range;
- var valueFraction = (Value - Minimum) / range;
+ var thumbWidth = double.IsNaN(viewportSize) ? thumb?.DesiredSize.Width ?? 0 : finalSize.Width * viewportSize / extent;
+ var remaining = finalSize.Width - thumbWidth;
+ var firstWidth = range <= 0 ? 0 : remaining * offset / range;
- if (double.IsNaN(valueFraction) || double.IsInfinity(valueFraction))
+ if (decreaseButton != null)
{
- valueFraction = 0;
- thumbFraction = 1;
+ decreaseButton.Arrange(new Rect(0, 0, firstWidth, finalSize.Height));
}
- else if (double.IsNaN(thumbFraction) || double.IsInfinity(thumbFraction))
+
+ if (thumb != null)
{
- thumbFraction = 0;
+ thumb.Arrange(new Rect(firstWidth, 0, thumbWidth, finalSize.Height));
}
- if (Orientation == Orientation.Horizontal)
+ if (increaseButton != null)
{
- var width = Math.Max(finalSize.Width * thumbFraction, thumb.MinWidth);
- var x = (finalSize.Width - width) * valueFraction;
- thumb.Arrange(new Rect(x, 0, width, finalSize.Height));
+ increaseButton.Arrange(new Rect(firstWidth + thumbWidth, 0, remaining - firstWidth, finalSize.Height));
}
- else
+ }
+ else
+ {
+ var thumbHeight = double.IsNaN(viewportSize) ? thumb?.DesiredSize.Height ?? 0 : finalSize.Height * viewportSize / extent;
+ var remaining = finalSize.Height - thumbHeight;
+ var firstHeight = range <= 0 ? 0 : remaining * offset / range;
+
+ if (decreaseButton != null)
{
- var height = Math.Max(finalSize.Height * thumbFraction, thumb.MinHeight);
- var y = (finalSize.Height - height) * valueFraction;
- thumb.Arrange(new Rect(0, y, finalSize.Width, height));
+ decreaseButton.Arrange(new Rect(0, 0, finalSize.Width, firstHeight));
+ }
+
+ if (thumb != null)
+ {
+ thumb.Arrange(new Rect(0, firstHeight, finalSize.Width, thumbHeight));
+ }
+
+ if (increaseButton != null)
+ {
+ increaseButton.Arrange(new Rect(0, firstHeight + thumbHeight, finalSize.Width, remaining - firstHeight));
}
}
@@ -140,10 +180,10 @@ namespace Avalonia.Controls.Primitives
if (oldThumb != null)
{
oldThumb.DragDelta -= ThumbDragged;
- }
- LogicalChildren.Clear();
- VisualChildren.Clear();
+ LogicalChildren.Remove(oldThumb);
+ VisualChildren.Remove(oldThumb);
+ }
if (newThumb != null)
{
@@ -153,6 +193,24 @@ namespace Avalonia.Controls.Primitives
}
}
+ private void ButtonChanged(AvaloniaPropertyChangedEventArgs e)
+ {
+ var oldButton = (Button)e.OldValue;
+ var newButton = (Button)e.NewValue;
+
+ if (oldButton != null)
+ {
+ LogicalChildren.Remove(oldButton);
+ VisualChildren.Remove(oldButton);
+ }
+
+ if (newButton != null)
+ {
+ LogicalChildren.Add(newButton);
+ VisualChildren.Add(newButton);
+ }
+ }
+
private void ThumbDragged(object sender, VectorEventArgs e)
{
double range = Maximum - Minimum;
diff --git a/src/Avalonia.Controls/RepeatButton.cs b/src/Avalonia.Controls/RepeatButton.cs
new file mode 100644
index 0000000000..a9ccb79fe1
--- /dev/null
+++ b/src/Avalonia.Controls/RepeatButton.cs
@@ -0,0 +1,82 @@
+using System;
+using Avalonia.Input;
+using Avalonia.Threading;
+
+namespace Avalonia.Controls
+{
+ public class RepeatButton : Button
+ {
+ ///
+ /// Defines the property.
+ ///
+ public static readonly StyledProperty DelayProperty =
+ AvaloniaProperty.Register(nameof(Delay), 100);
+
+ private DispatcherTimer _repeatTimer;
+
+ ///
+ /// Gets or sets the amount of time, in milliseconds, of repeating clicks.
+ ///
+ public int Delay
+ {
+ get { return GetValue(DelayProperty); }
+ set { SetValue(DelayProperty, value); }
+ }
+
+ private void StartTimer()
+ {
+ if (_repeatTimer == null)
+ {
+ _repeatTimer = new DispatcherTimer();
+ _repeatTimer.Tick += (o, e) => OnClick();
+ }
+
+ if (_repeatTimer.IsEnabled) return;
+
+ _repeatTimer.Interval = TimeSpan.FromMilliseconds(Delay);
+ _repeatTimer.Start();
+ }
+
+ private void StopTimer()
+ {
+ _repeatTimer?.Stop();
+ }
+
+ protected override void OnKeyDown(KeyEventArgs e)
+ {
+ base.OnKeyDown(e);
+
+ if (e.Key == Key.Space)
+ {
+ StartTimer();
+ }
+ }
+
+ protected override void OnKeyUp(KeyEventArgs e)
+ {
+ base.OnKeyUp(e);
+
+ StopTimer();
+ }
+
+ protected override void OnPointerPressed(PointerPressedEventArgs e)
+ {
+ base.OnPointerPressed(e);
+
+ if (e.MouseButton == MouseButton.Left)
+ {
+ StartTimer();
+ }
+ }
+
+ protected override void OnPointerReleased(PointerReleasedEventArgs e)
+ {
+ base.OnPointerReleased(e);
+
+ if (e.MouseButton == MouseButton.Left)
+ {
+ StopTimer();
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Avalonia.Controls/ScrollViewer.cs b/src/Avalonia.Controls/ScrollViewer.cs
index ad771d333e..0442652540 100644
--- a/src/Avalonia.Controls/ScrollViewer.cs
+++ b/src/Avalonia.Controls/ScrollViewer.cs
@@ -275,7 +275,7 @@ namespace Avalonia.Controls
///
protected double HorizontalScrollBarViewportSize
{
- get { return Max((_viewport.Width / _extent.Width) * (_extent.Width - _viewport.Width), 0); }
+ get { return _viewport.Width; }
}
///
@@ -308,7 +308,7 @@ namespace Avalonia.Controls
///
protected double VerticalScrollBarViewportSize
{
- get { return Max((_viewport.Height / _extent.Height) * (_extent.Height - _viewport.Height), 0); }
+ get { return _viewport.Height; }
}
///
diff --git a/src/Avalonia.Controls/Slider.cs b/src/Avalonia.Controls/Slider.cs
index 6bbfb8fd8d..2ef0af2852 100644
--- a/src/Avalonia.Controls/Slider.cs
+++ b/src/Avalonia.Controls/Slider.cs
@@ -33,6 +33,8 @@ namespace Avalonia.Controls
// Slider required parts
private Track _track;
+ private Button _decreaseButton;
+ private Button _increaseButton;
///
/// Initializes static members of the class.
@@ -44,6 +46,8 @@ namespace Avalonia.Controls
Thumb.DragStartedEvent.AddClassHandler(x => x.OnThumbDragStarted, RoutingStrategies.Bubble);
Thumb.DragDeltaEvent.AddClassHandler(x => x.OnThumbDragDelta, RoutingStrategies.Bubble);
Thumb.DragCompletedEvent.AddClassHandler(x => x.OnThumbDragCompleted, RoutingStrategies.Bubble);
+ SmallChangeProperty.OverrideDefaultValue(1);
+ LargeChangeProperty.OverrideDefaultValue(10);
}
///
@@ -83,7 +87,54 @@ namespace Avalonia.Controls
///
protected override void OnTemplateApplied(TemplateAppliedEventArgs e)
{
- _track = e.NameScope.Get("PART_Track");
+ if (_decreaseButton != null)
+ {
+ _decreaseButton.Click -= DecreaseClick;
+ }
+
+ if (_increaseButton != null)
+ {
+ _increaseButton.Click -= IncreaseClick;
+ }
+
+ _decreaseButton = e.NameScope.Find("PART_DecreaseButton");
+ _track = e.NameScope.Find("PART_Track");
+ _increaseButton = e.NameScope.Find("PART_IncreaseButton");
+
+ if (_decreaseButton != null)
+ {
+ _decreaseButton.Click += DecreaseClick;
+ }
+
+ if (_increaseButton != null)
+ {
+ _increaseButton.Click += IncreaseClick;
+ }
+ }
+
+ private void DecreaseClick(object sender, RoutedEventArgs e)
+ {
+ ChangeValueBy(-LargeChange);
+ }
+
+ private void IncreaseClick(object sender, RoutedEventArgs e)
+ {
+ ChangeValueBy(LargeChange);
+ }
+
+ private void ChangeValueBy(double by)
+ {
+ if (IsSnapToTickEnabled)
+ {
+ by = by < 0 ? Math.Min(-TickFrequency, by) : Math.Max(TickFrequency, by);
+ }
+
+ var value = Value;
+ var next = SnapToTick(Math.Max(Math.Min(value + by, Maximum), Minimum));
+ if (next != value)
+ {
+ Value = next;
+ }
}
///
@@ -101,7 +152,7 @@ namespace Avalonia.Controls
protected virtual void OnThumbDragDelta(VectorEventArgs e)
{
Thumb thumb = e.Source as Thumb;
- if (thumb != null && _track.Thumb == thumb)
+ if (thumb != null && _track?.Thumb == thumb)
{
MoveToNextTick(_track.Value);
}
diff --git a/src/Avalonia.Themes.Default/DefaultTheme.xaml b/src/Avalonia.Themes.Default/DefaultTheme.xaml
index 07a3a6f429..48f530cca8 100644
--- a/src/Avalonia.Themes.Default/DefaultTheme.xaml
+++ b/src/Avalonia.Themes.Default/DefaultTheme.xaml
@@ -20,6 +20,7 @@
+
diff --git a/src/Avalonia.Themes.Default/RepeatButton.xaml b/src/Avalonia.Themes.Default/RepeatButton.xaml
new file mode 100644
index 0000000000..557e2d3b03
--- /dev/null
+++ b/src/Avalonia.Themes.Default/RepeatButton.xaml
@@ -0,0 +1,44 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Avalonia.Themes.Default/ScrollBar.xaml b/src/Avalonia.Themes.Default/ScrollBar.xaml
index 89f6f26c08..2a3f6a2e54 100644
--- a/src/Avalonia.Themes.Default/ScrollBar.xaml
+++ b/src/Avalonia.Themes.Default/ScrollBar.xaml
@@ -1,35 +1,127 @@
-
-
-
-
-
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Avalonia.Themes.Default/ScrollViewer.xaml b/src/Avalonia.Themes.Default/ScrollViewer.xaml
index 4adfdaae2d..c7f9ad31db 100644
--- a/src/Avalonia.Themes.Default/ScrollViewer.xaml
+++ b/src/Avalonia.Themes.Default/ScrollViewer.xaml
@@ -1,4 +1,6 @@
+
+
\ No newline at end of file
diff --git a/src/Windows/Avalonia.Win32/WindowImpl.cs b/src/Windows/Avalonia.Win32/WindowImpl.cs
index 72485379a7..a8e1925ee8 100644
--- a/src/Windows/Avalonia.Win32/WindowImpl.cs
+++ b/src/Windows/Avalonia.Win32/WindowImpl.cs
@@ -517,7 +517,7 @@ namespace Avalonia.Win32
WindowsMouseDevice.Instance,
timestamp,
_owner,
- ScreenToClient(DipFromLParam(lParam)),
+ PointToClient(PointFromLParam(lParam)),
new Vector(0, (ToInt32(wParam) >> 16) / wheelDelta), GetMouseModifiers(wParam));
break;
@@ -526,7 +526,7 @@ namespace Avalonia.Win32
WindowsMouseDevice.Instance,
timestamp,
_owner,
- ScreenToClient(DipFromLParam(lParam)),
+ PointToClient(PointFromLParam(lParam)),
new Vector(-(ToInt32(wParam) >> 16) / wheelDelta, 0), GetMouseModifiers(wParam));
break;
diff --git a/tests/Avalonia.Controls.UnitTests/Primitives/ScrollBarTests.cs b/tests/Avalonia.Controls.UnitTests/Primitives/ScrollBarTests.cs
index 01dc9f5076..5b1ade9c47 100644
--- a/tests/Avalonia.Controls.UnitTests/Primitives/ScrollBarTests.cs
+++ b/tests/Avalonia.Controls.UnitTests/Primitives/ScrollBarTests.cs
@@ -65,9 +65,8 @@ namespace Avalonia.Controls.UnitTests.Primitives
var target = new ScrollBar();
target.Visibility = ScrollBarVisibility.Auto;
- target.Minimum = 0;
- target.Maximum = 100;
- target.ViewportSize = 100;
+ target.ViewportSize = 1;
+ target.Maximum = 0;
Assert.False(target.IsVisible);
}
diff --git a/tests/Avalonia.Controls.UnitTests/Primitives/TrackTests.cs b/tests/Avalonia.Controls.UnitTests/Primitives/TrackTests.cs
index 902a7894e9..f07a5f5095 100644
--- a/tests/Avalonia.Controls.UnitTests/Primitives/TrackTests.cs
+++ b/tests/Avalonia.Controls.UnitTests/Primitives/TrackTests.cs
@@ -69,7 +69,7 @@ namespace Avalonia.Controls.UnitTests.Primitives
target.Measure(new Size(100, 100));
target.Arrange(new Rect(0, 0, 100, 100));
- Assert.Equal(new Rect(25, 0, 50, 12), thumb.Bounds);
+ Assert.Equal(new Rect(33, 0, 34, 12), thumb.Bounds);
}
[Fact]
@@ -85,7 +85,7 @@ namespace Avalonia.Controls.UnitTests.Primitives
Thumb = thumb,
Orientation = Orientation.Vertical,
Minimum = 100,
- Maximum = 300,
+ Maximum = 200,
Value = 150,
ViewportSize = 50,
Width = 12,
@@ -94,11 +94,11 @@ namespace Avalonia.Controls.UnitTests.Primitives
target.Measure(new Size(100, 100));
target.Arrange(new Rect(0, 0, 100, 100));
- Assert.Equal(new Rect(0, 18, 12, 25), thumb.Bounds);
+ Assert.Equal(new Rect(0, 33, 12, 34), thumb.Bounds);
}
[Fact]
- public void Thumb_Should_Fill_Track_When_Minimum_Equals_Maximum()
+ public void Thumb_Should_Have_Zero_Width_When_Minimum_Equals_Maximum()
{
var thumb = new Thumb
{
@@ -117,7 +117,7 @@ namespace Avalonia.Controls.UnitTests.Primitives
target.Measure(new Size(100, 100));
target.Arrange(new Rect(0, 0, 100, 100));
- Assert.Equal(new Rect(0, 0, 100, 12), thumb.Bounds);
+ Assert.Equal(new Rect(0, 0, 0, 12), thumb.Bounds);
}
[Fact]
diff --git a/tests/Avalonia.Layout.UnitTests/FullLayoutTests.cs b/tests/Avalonia.Layout.UnitTests/FullLayoutTests.cs
index 3e7ff496a8..00d4af7e4d 100644
--- a/tests/Avalonia.Layout.UnitTests/FullLayoutTests.cs
+++ b/tests/Avalonia.Layout.UnitTests/FullLayoutTests.cs
@@ -177,6 +177,15 @@ namespace Avalonia.Layout.UnitTests
It.IsAny>()))
.Returns(new FormattedTextMock("TEST"));
+ var streamGeometry = new Mock();
+ streamGeometry.Setup(x =>
+ x.Open())
+ .Returns(new Mock().Object);
+
+ renderInterface.Setup(x =>
+ x.CreateStreamGeometry())
+ .Returns(streamGeometry.Object);
+
var windowImpl = new Mock();
Size clientSize = default(Size);