Navigation Menu

Skip to content

Commit

Permalink
feat(macos): [MacOS] Add clipping support
Browse files Browse the repository at this point in the history
  • Loading branch information
David committed Jul 24, 2020
1 parent ccaf546 commit 1c8a0ad
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/Uno.UI/UI/Xaml/UIElement.macOS.cs
Expand Up @@ -6,6 +6,8 @@
using System.Linq;
using Uno.UI.Extensions;
using AppKit;
using CoreAnimation;
using CoreGraphics;

namespace Windows.UI.Xaml
{
Expand Down Expand Up @@ -122,5 +124,34 @@ private protected override void OnNativeKeyUp(NSEvent evt)

base.OnNativeKeyUp(evt);
}

partial void ApplyNativeClip(Rect rect)
{
if (rect.IsEmpty
|| double.IsPositiveInfinity(rect.X)
|| double.IsPositiveInfinity(rect.Y)
|| double.IsPositiveInfinity(rect.Width)
|| double.IsPositiveInfinity(rect.Height)
)
{
if (!ClippingIsSetByCornerRadius)
{
if (Layer != null)
{
this.Layer.Mask = null;
}
}
return;
}

WantsLayer = true;
if (Layer != null)
{
this.Layer.Mask = new CAShapeLayer
{
Path = CGPath.FromRect(rect.ToCGRect())
};
}
}
}
}

0 comments on commit 1c8a0ad

Please sign in to comment.