Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow * decompression during Arrange even when target size is smaller than desired size #10768

Merged
merged 1 commit into from
Oct 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 8 additions & 14 deletions src/Core/src/Layouts/GridLayoutManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -679,26 +679,20 @@ public void DecompressStars(Size targetSize)
{
if (_grid.VerticalLayoutAlignment == LayoutAlignment.Fill || Dimension.IsExplicitSet(_explicitGridHeight))
{
if (_grid.DesiredSize.Height < targetSize.Height)
{
// Reset the size on all star rows
ZeroOutStarSizes(_rows);
// Reset the size on all star rows
ZeroOutStarSizes(_rows);

// And compute them for the actual arrangement height
ResolveStarRows(targetSize.Height);
}
// And compute them for the actual arrangement height
ResolveStarRows(targetSize.Height);
}

if (_grid.HorizontalLayoutAlignment == LayoutAlignment.Fill || Dimension.IsExplicitSet(_explicitGridWidth))
{
if (_grid.DesiredSize.Width < targetSize.Width)
{
// Reset the size on all star rows
ZeroOutStarSizes(_columns);
// Reset the size on all star columns
ZeroOutStarSizes(_columns);

// And compute them for the actual arrangement width
ResolveStarColumns(targetSize.Width);
}
// And compute them for the actual arrangement width
ResolveStarColumns(targetSize.Width);
}
}

Expand Down
23 changes: 23 additions & 0 deletions src/Core/tests/UnitTests/Layouts/GridLayoutManagerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2316,5 +2316,28 @@ public void StarRowHeightLimitedToGridHeight()

AssertArranged(view1, new Rect(20, 0, 20, 500));
}

[Fact]
[Category(GridStarSizing)]
public void StarsExpandToFixedSizes()
{
var grid = CreateGridLayout();
grid.DesiredSize.Returns(new Size(100, 120));
grid.Width.Returns(100);
grid.Height.Returns(120);

var view0 = CreateTestView(new Size(20, 20));
view0.Width.Returns(20);
view0.Height.Returns(20);
view0.HorizontalLayoutAlignment.Returns(LayoutAlignment.End);
view0.VerticalLayoutAlignment.Returns(LayoutAlignment.Start);

SetLocation(grid, view0);
SubstituteChildren(grid, view0);

_ = MeasureAndArrange(grid);

AssertArranged(view0, new Rect(0, 0, 100, 120));
}
}
}