Skip to content

Commit

Permalink
fix: Fix Stretch.None behavior and closing path on Skia
Browse files Browse the repository at this point in the history
  • Loading branch information
Youssef1313 authored and ahmed605 committed Sep 13, 2023
1 parent 38bcbe4 commit 53baca9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 2 additions & 0 deletions src/Uno.UI/Media/PathStreamGeometryContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,8 @@ public override void SetClosedState(bool closed)
bezierPath.ClosePath();
#elif __ANDROID__
bezierPath.Close();
#elif __SKIA__
bezierPath.Geometry.Close();
#endif
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/Uno.UI/UI/Xaml/FrameworkElement.Layout.crossruntime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ private void InnerMeasureCore(Size availableSize)

var desiredSize = MeasureOverride(frameworkAvailableSize);

// TODO: This is needed in Android, iOS, macOS.
desiredSize = new Size(Math.Round(desiredSize.Width, MidpointRounding.AwayFromZero), Math.Round(desiredSize.Height, MidpointRounding.AwayFromZero));

_logDebug?.Trace($"{DepthIndentation}{FormatDebugName()}.MeasureOverride(availableSize={frameworkAvailableSize}): desiredSize={desiredSize} minSize={minSize} maxSize={maxSize} marginSize={marginSize}");

if (
Expand Down
11 changes: 3 additions & 8 deletions src/Uno.UI/UI/Xaml/Shapes/Shape.layout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -277,10 +277,8 @@ private protected Size MeasureAbsoluteShape(Size availableSize, NativePath? path
// Also, as the path does not have any notion of stroke thickness, we have to include it for the measure phase.
// Note: The logic would say to include the full StrokeThickness as it will "overflow" half on booth side of the path,
// but WinUI does include only the half of it.
var pathNaturalSize = new Size(
pathBounds.X == 0 ? pathBounds.Width + strokeThickness : pathBounds.Right + alignedHalfStrokeThickness,
pathBounds.Y == 0 ? pathBounds.Height + strokeThickness : pathBounds.Bottom + alignedHalfStrokeThickness);
size = pathNaturalSize.AtMost(userMaxSize).AtLeast(userMinSize); // The size defined on the Shape has priority over the size of the geometry itself!
var halfStrokeThickness = strokeThickness / 2;
size = new Size(pathBounds.Right + halfStrokeThickness, pathBounds.Bottom + halfStrokeThickness);
break;

case Stretch.Fill:
Expand Down Expand Up @@ -368,10 +366,7 @@ private protected Size ArrangeAbsoluteShape(Size finalSize, NativePath? path, Fi
{
default:
case Stretch.None:
var alignedHalfStrokeThickness = GetAlignedHalfStrokeThickness();
var pathNaturalSize = new Size(
pathBounds.X == 0 ? pathBounds.Width + strokeThickness : pathBounds.Right + alignedHalfStrokeThickness,
pathBounds.Y == 0 ? pathBounds.Height + strokeThickness : pathBounds.Bottom + alignedHalfStrokeThickness);
var pathNaturalSize = new Size(pathBounds.Right + halfStrokeThickness, pathBounds.Bottom + halfStrokeThickness);
var (userMinSize, userMaxSize) = GetMinMax(userSize);

var clampedSize = pathNaturalSize.AtMost(userMaxSize).AtLeast(userMinSize); // The size defined on the Shape has priority over the size of the geometry itself!
Expand Down

0 comments on commit 53baca9

Please sign in to comment.