Browse Source

Share default small change value across controls.

pull/3725/head
Steven Kirk 6 years ago
parent
commit
b14e1a999b
  1. 2
      src/Avalonia.Controls/Presenters/ItemsPresenter.cs
  2. 8
      src/Avalonia.Controls/ScrollViewer.cs

2
src/Avalonia.Controls/Presenters/ItemsPresenter.cs

@ -103,7 +103,7 @@ namespace Avalonia.Controls.Presenters
} }
/// <inheritdoc/> /// <inheritdoc/>
Size ILogicalScrollable.ScrollSize => new Size(16, 1); Size ILogicalScrollable.ScrollSize => new Size(ScrollViewer.DefaultSmallChange, 1);
/// <inheritdoc/> /// <inheritdoc/>
Size ILogicalScrollable.PageScrollSize => Virtualizer?.Viewport ?? new Size(16, 16); Size ILogicalScrollable.PageScrollSize => Virtualizer?.Viewport ?? new Size(16, 16);

8
src/Avalonia.Controls/ScrollViewer.cs

@ -10,8 +10,6 @@ namespace Avalonia.Controls
/// </summary> /// </summary>
public class ScrollViewer : ContentControl, IScrollable, IScrollAnchorProvider public class ScrollViewer : ContentControl, IScrollable, IScrollAnchorProvider
{ {
private static readonly Size s_defaultSmallChange = new Size(16, 16);
/// <summary> /// <summary>
/// Defines the <see cref="CanHorizontallyScroll"/> property. /// Defines the <see cref="CanHorizontallyScroll"/> property.
/// </summary> /// </summary>
@ -167,13 +165,15 @@ namespace Avalonia.Controls
nameof(VerticalScrollBarVisibility), nameof(VerticalScrollBarVisibility),
ScrollBarVisibility.Auto); ScrollBarVisibility.Auto);
internal const double DefaultSmallChange = 16;
private IDisposable _childSubscription; private IDisposable _childSubscription;
private ILogicalScrollable _logicalScrollable; private ILogicalScrollable _logicalScrollable;
private Size _extent; private Size _extent;
private Vector _offset; private Vector _offset;
private Size _viewport; private Size _viewport;
private Size _largeChange; private Size _largeChange;
private Size _smallChange = s_defaultSmallChange; private Size _smallChange = new Size(DefaultSmallChange, DefaultSmallChange);
/// <summary> /// <summary>
/// Initializes static members of the <see cref="ScrollViewer"/> class. /// Initializes static members of the <see cref="ScrollViewer"/> class.
@ -543,7 +543,7 @@ namespace Avalonia.Controls
} }
else else
{ {
SetAndRaise(SmallChangeProperty, ref _smallChange, s_defaultSmallChange); SetAndRaise(SmallChangeProperty, ref _smallChange, new Size(DefaultSmallChange, DefaultSmallChange));
SetAndRaise(LargeChangeProperty, ref _largeChange, Viewport); SetAndRaise(LargeChangeProperty, ref _largeChange, Viewport);
} }
} }

Loading…
Cancel
Save