Browse Source
Merge branch 'master' into fixes/1436-border-layout-issues
pull/1488/head
danwalmsley
9 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with
50 additions and
3 deletions
-
src/Avalonia.Controls/Border.cs
-
src/Avalonia.Controls/Presenters/ContentPresenter.cs
-
tests/Avalonia.Controls.UnitTests/BorderTests.cs
-
tests/Avalonia.Controls.UnitTests/Presenters/ContentPresenterTests_Layout.cs
|
|
|
@ -115,7 +115,7 @@ namespace Avalonia.Controls |
|
|
|
Child.Arrange(new Rect(finalSize).Deflate(padding)); |
|
|
|
} |
|
|
|
|
|
|
|
_borderRenderHelper.Update(finalSize, BorderThickness, CornerRadius); |
|
|
|
_borderRenderHelper.Update(finalSize, BorderThickness, CornerRadius); |
|
|
|
|
|
|
|
return finalSize; |
|
|
|
} |
|
|
|
|
|
|
|
@ -385,7 +385,7 @@ namespace Avalonia.Controls.Presenters |
|
|
|
{ |
|
|
|
size = size.WithWidth(Math.Min(size.Width, DesiredSize.Width - padding.Left - padding.Right)); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (verticalContentAlignment != VerticalAlignment.Stretch) |
|
|
|
{ |
|
|
|
size = size.WithHeight(Math.Min(size.Height, DesiredSize.Height - padding.Top - padding.Bottom)); |
|
|
|
@ -427,7 +427,7 @@ namespace Avalonia.Controls.Presenters |
|
|
|
originY = Math.Floor(originY * scale) / scale; |
|
|
|
} |
|
|
|
|
|
|
|
Child.Arrange(new Rect(originX, originY, size.Width, size.Height)); |
|
|
|
Child.Arrange(new Rect(originX, originY, Math.Max(0, size.Width), Math.Max(0, size.Height))); |
|
|
|
|
|
|
|
return finalSize; |
|
|
|
} |
|
|
|
|
|
|
|
@ -20,5 +20,27 @@ namespace Avalonia.Controls.UnitTests |
|
|
|
|
|
|
|
Assert.Equal(new Size(20, 20), target.DesiredSize); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void Child_Should_Arrange_With_Zero_Height_Width_If_Padding_Greater_Than_Child_Size() |
|
|
|
{ |
|
|
|
Border content; |
|
|
|
|
|
|
|
var target = new Border |
|
|
|
{ |
|
|
|
Padding = new Thickness(6), |
|
|
|
MaxHeight = 12, |
|
|
|
MaxWidth = 12, |
|
|
|
Child = content = new Border |
|
|
|
{ |
|
|
|
Height = 0, |
|
|
|
Width = 0 |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
target.Arrange(new Rect(0, 0, 100, 100)); |
|
|
|
|
|
|
|
Assert.Equal(new Rect(6, 6, 0, 0), content.Bounds); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -210,5 +210,30 @@ namespace Avalonia.Controls.UnitTests.Presenters |
|
|
|
|
|
|
|
Assert.Equal(new Rect(84, 0, 16, 16), content.Bounds); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void Child_Arrange_With_Zero_Height_When_Padding_Height_Greater_Than_Child_Height() |
|
|
|
{ |
|
|
|
Border content; |
|
|
|
var target = new ContentPresenter |
|
|
|
{ |
|
|
|
Padding = new Thickness(32), |
|
|
|
MaxHeight = 32, |
|
|
|
MaxWidth = 32, |
|
|
|
HorizontalContentAlignment = HorizontalAlignment.Center, |
|
|
|
VerticalContentAlignment = VerticalAlignment.Center, |
|
|
|
Content = content = new Border |
|
|
|
{ |
|
|
|
Height = 0, |
|
|
|
Width = 0, |
|
|
|
}, |
|
|
|
}; |
|
|
|
|
|
|
|
target.UpdateChild(); |
|
|
|
|
|
|
|
target.Arrange(new Rect(0, 0, 100, 100)); |
|
|
|
|
|
|
|
Assert.Equal(new Rect(48, 48, 0, 0), content.Bounds); |
|
|
|
} |
|
|
|
} |
|
|
|
} |