Skip to content

Commit

Permalink
Merge pull request #1000 from unoplatform/dev/rlm/CounterAxisAlignement
Browse files Browse the repository at this point in the history
fix: autolayout counterAlignment stretch had a wrong padding
  • Loading branch information
Robert-Louis committed Jan 16, 2024
2 parents 466de8a + fc0bc42 commit 61b99c4
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
32 changes: 32 additions & 0 deletions src/Uno.Toolkit.RuntimeTests/Tests/AutoLayoutTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -729,4 +729,36 @@ public async Task When_Hug_With_Padding_CounterAxis()

Assert.AreEqual(Math.Ceiling(autoLayoutAcutalWidth - textBlockCenter), Math.Ceiling(textBlockTransform!.X));
}

[TestMethod]
[RequiresFullWindow]
public async Task When_CounterAlignment_stretch()
{
var SUT = new AutoLayout()
{
Background = new SolidColorBrush(Color.FromArgb(255, 0, 0, 255)),
Width = 300,
Height = 300,
Padding = new Thickness(50)
};

var rectangle = new Border()
{
Background = new SolidColorBrush(Color.FromArgb(255, 0, 255, 255)),
};

AutoLayout.SetPrimaryAlignment(rectangle, AutoLayoutPrimaryAlignment.Stretch);
AutoLayout.SetCounterAlignment(rectangle, AutoLayoutAlignment.Stretch);

SUT.Children.Add(rectangle);

await UnitTestUIContentHelperEx.SetContentAndWait(SUT);

var borderBlockTransform = rectangle.TransformToVisual(SUT).TransformPoint(new Windows.Foundation.Point(0, 0));

var autoLayoutAcutalWidth = SUT.ActualWidth / 2;
var borderBlockCenter = rectangle.ActualWidth / 2;

Assert.AreEqual(Math.Ceiling(autoLayoutAcutalWidth - borderBlockCenter), Math.Ceiling(borderBlockTransform!.X));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ protected override Size ArrangeOverride(Size finalSize)
var haveCounterStartPadding = isStretch || counterAlignment is AutoLayoutAlignment.Start;
var counterStartPadding = haveCounterStartPadding ? (isHorizontal ? padding.Top : padding.Left) : 0;

var haveCounterEndPadding = counterAlignment is AutoLayoutAlignment.Stretch or AutoLayoutAlignment.End;
var haveCounterEndPadding = isStretch || counterAlignment is AutoLayoutAlignment.End;
var counterEndPadding = haveCounterEndPadding ? (isHorizontal ? padding.Bottom : padding.Right) : 0;

var counterBorderLength = borderThickness.GetCounterLength(orientation);
Expand Down

0 comments on commit 61b99c4

Please sign in to comment.