Browse Source

Updated overflow algorithm.

pull/545/head
Steven Kirk 10 years ago
parent
commit
7a718ef9c2
  1. 3
      src/Avalonia.Controls/VirtualizingStackPanel.cs
  2. 46
      tests/Avalonia.Controls.UnitTests/VirtualizingStackPanelTests.cs

3
src/Avalonia.Controls/VirtualizingStackPanel.cs

@ -41,7 +41,7 @@ namespace Avalonia.Controls
{
var bounds = Orientation == Orientation.Horizontal ?
Bounds.Width : Bounds.Height;
return Math.Max(0, (_takenSpace - _pixelOffset) - bounds);
return Math.Max(0, _takenSpace - bounds);
}
}
@ -82,6 +82,7 @@ namespace Avalonia.Controls
_averageItemSize = 0;
_averageCount = 0;
var result = base.ArrangeOverride(finalSize);
_takenSpace += _pixelOffset;
Controller?.UpdateControls();
return result;
}

46
tests/Avalonia.Controls.UnitTests/VirtualizingStackPanelTests.cs

@ -80,6 +80,52 @@ namespace Avalonia.Controls.UnitTests
Assert.Equal(2, target.OverflowCount);
}
[Fact]
public void Reports_PixelOverflow_After_Arrange()
{
var target = (IVirtualizingPanel)new VirtualizingStackPanel();
target.Children.Add(new Canvas { Width = 50, Height = 50 });
target.Children.Add(new Canvas { Width = 50, Height = 52 });
target.Measure(new Size(100, 100));
target.Arrange(new Rect(target.DesiredSize));
Assert.Equal(2, target.PixelOverflow);
}
[Fact]
public void Reports_PixelOverflow_With_PixelOffset()
{
var target = (IVirtualizingPanel)new VirtualizingStackPanel();
target.Children.Add(new Canvas { Width = 50, Height = 50 });
target.Children.Add(new Canvas { Width = 50, Height = 52 });
target.PixelOffset = 2;
target.Measure(new Size(100, 100));
target.Arrange(new Rect(target.DesiredSize));
Assert.Equal(2, target.PixelOverflow);
}
[Fact]
public void PixelOffset_Can_Be_More_Than_Child_Without_Affecting_IsFull()
{
var target = (IVirtualizingPanel)new VirtualizingStackPanel();
target.Children.Add(new Canvas { Width = 50, Height = 50 });
target.Children.Add(new Canvas { Width = 50, Height = 52 });
target.PixelOffset = 55;
target.Measure(new Size(100, 100));
target.Arrange(new Rect(target.DesiredSize));
Assert.Equal(55, target.PixelOffset);
Assert.Equal(2, target.PixelOverflow);
Assert.True(target.IsFull);
}
[Fact]
public void Passes_Navigation_Request_To_ILogicalScrollable_Parent()
{

Loading…
Cancel
Save