Browse Source
Merge pull request #1298 from AvaloniaUI/fixes/1297-track-arrange-bug
Fix Track Arrange Problem
pull/1315/head
danwalmsley
9 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
36 additions and
2 deletions
-
src/Avalonia.Controls/Primitives/Track.cs
-
tests/Avalonia.Controls.UnitTests/Primitives/TrackTests.cs
|
|
|
@ -154,7 +154,11 @@ namespace Avalonia.Controls.Primitives |
|
|
|
|
|
|
|
if (increaseButton != null) |
|
|
|
{ |
|
|
|
increaseButton.Arrange(new Rect(firstWidth + thumbWidth, 0, remaining - firstWidth, finalSize.Height)); |
|
|
|
increaseButton.Arrange(new Rect( |
|
|
|
firstWidth + thumbWidth, |
|
|
|
0, |
|
|
|
Math.Max(0, remaining - firstWidth), |
|
|
|
finalSize.Height)); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
@ -185,7 +189,11 @@ namespace Avalonia.Controls.Primitives |
|
|
|
|
|
|
|
if (increaseButton != null) |
|
|
|
{ |
|
|
|
increaseButton.Arrange(new Rect(0, firstHeight + thumbHeight, finalSize.Width, Math.Max(remaining - firstHeight, 0))); |
|
|
|
increaseButton.Arrange(new Rect( |
|
|
|
0, |
|
|
|
firstHeight + thumbHeight, |
|
|
|
finalSize.Width, |
|
|
|
Math.Max(remaining - firstHeight, 0))); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -140,5 +140,31 @@ namespace Avalonia.Controls.UnitTests.Primitives |
|
|
|
Assert.Same(thumb.Parent, target); |
|
|
|
Assert.Equal(new[] { thumb }, ((ILogical)target).LogicalChildren); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void Should_Not_Pass_Invalid_Arrange_Rect() |
|
|
|
{ |
|
|
|
var thumb = new Thumb { Width = 100.873106060606 }; |
|
|
|
var increaseButton = new Button { Width = 10 }; |
|
|
|
var decreaseButton = new Button { Width = 10 }; |
|
|
|
|
|
|
|
var target = new Track |
|
|
|
{ |
|
|
|
Height = 12, |
|
|
|
Thumb = thumb, |
|
|
|
IncreaseButton = increaseButton, |
|
|
|
DecreaseButton = decreaseButton, |
|
|
|
Orientation = Orientation.Horizontal, |
|
|
|
Minimum = 0, |
|
|
|
Maximum = 287, |
|
|
|
Value = 287, |
|
|
|
ViewportSize = 241, |
|
|
|
}; |
|
|
|
|
|
|
|
target.Measure(Size.Infinity); |
|
|
|
|
|
|
|
// #1297 was occuring here.
|
|
|
|
target.Arrange(new Rect(0, 0, 221, 12)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|