Skip to content

Commit

Permalink
chore: Adjust border clipping
Browse files Browse the repository at this point in the history
  • Loading branch information
Youssef1313 committed Oct 6, 2024
1 parent fd33d22 commit 2f639ce
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 35 deletions.
38 changes: 17 additions & 21 deletions src/Uno.UI/UI/Xaml/Controls/Border/BorderLayerRenderer.iOSmacOS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -289,17 +289,15 @@ GradientBrush gradientBorder when gradientBorder.CanApplyToBorder(cornerRadius)
}
}

parent.Mask = new CAShapeLayer()
foreach (var sublayer in sublayers)
{
Path = outerPath,
Frame = area,
// We only use the fill color to create the mask area
FillColor = _Color.White.CGColor,
};

if (owner != null)
{
owner.ClippingIsSetByCornerRadius = true;
sublayer.Mask = new CAShapeLayer()
{
Path = outerPath,
Frame = area,
// We only use the fill color to create the mask area
FillColor = _Color.White.CGColor,
};
}

updatedBoundsPath = outerPath;
Expand Down Expand Up @@ -427,13 +425,16 @@ GradientBrush gradientBorder when gradientBorder.CanApplyToBorder(cornerRadius)
sublayers.Add(backgroundLayer);
parent.InsertSublayer(backgroundLayer, insertionIndex);

parent.Mask = new CAShapeLayer()
foreach (var sublayer in sublayers)
{
Path = outerPath,
Frame = area,
// We only use the fill color to create the mask area
FillColor = _Color.White.CGColor,
};
sublayer.Mask = new CAShapeLayer()
{
Path = outerPath,
Frame = area,
// We only use the fill color to create the mask area
FillColor = _Color.White.CGColor,
};
}

updatedBoundsPath = outerPath;
}
Expand All @@ -445,11 +446,6 @@ GradientBrush gradientBorder when gradientBorder.CanApplyToBorder(cornerRadius)
sl.RemoveFromSuperLayer();
sl.Dispose();
}

if (owner != null)
{
owner.ClippingIsSetByCornerRadius = false;
}
}
);
return disposables;
Expand Down
7 changes: 1 addition & 6 deletions src/Uno.UI/UI/Xaml/UIElement.iOS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,11 @@ public override void MovedToWindow()
}
}

internal bool ClippingIsSetByCornerRadius { get; set; }

private void SetClipPlatform(Rect? totalLogicalClip)
{
if (totalLogicalClip is null)
{
if (!ClippingIsSetByCornerRadius)
{
this.Layer.Mask = null;
}
this.Layer.Mask = null;
return;
}

Expand Down
11 changes: 3 additions & 8 deletions src/Uno.UI/UI/Xaml/UIElement.macOS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ public UIElement()
UpdateHitTest();
}

internal bool ClippingIsSetByCornerRadius { get; set; }

partial void OnOpacityChanged(DependencyPropertyChangedEventArgs args)
{
// Don't update the internal value if the value is being animated.
Expand Down Expand Up @@ -253,13 +251,10 @@ private void SetClipPlatform(Rect? totalLogicalClip)
{
if (totalLogicalClip is null)
{
if (!ClippingIsSetByCornerRadius)
var emptyClipLayer = Layer;
if (emptyClipLayer != null)
{
var emptyClipLayer = Layer;
if (emptyClipLayer != null)
{
emptyClipLayer.Mask = null;
}
emptyClipLayer.Mask = null;
}
return;
}
Expand Down

0 comments on commit 2f639ce

Please sign in to comment.