Skip to content

Commit

Permalink
ContentPanel changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tamilarasan-Paranthaman committed Nov 26, 2024
1 parent 943c085 commit 82eaee9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
16 changes: 5 additions & 11 deletions src/Core/src/Platform/Windows/ContentPanel.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Numerics;
using System.Threading.Tasks;
using Microsoft.Graphics.Canvas;
using Microsoft.Maui.Graphics;
#if MAUI_GRAPHICS_WIN2D
Expand All @@ -22,7 +21,7 @@ public class ContentPanel : MauiPanel
FrameworkElement? _content;

internal Path? BorderPath => _borderPath;

internal IBorderStroke? BorderStroke => _borderStroke;
internal FrameworkElement? Content
{
get => _content;
Expand Down Expand Up @@ -61,7 +60,7 @@ internal FrameworkElement? Content
var size = new global::Windows.Foundation.Size(Math.Max(0, actual.Width), Math.Max(0, actual.Height));

// We need to update the clip since the content's position might have changed
_ = UpdateClipAsync(_borderStroke?.Shape, size.Width, size.Height);
UpdateClip(_borderStroke?.Shape, size.Width, size.Height);

return size;
}
Expand Down Expand Up @@ -90,7 +89,7 @@ void ContentPanelSizeChanged(object sender, SizeChangedEventArgs e)
}

_borderPath.UpdatePath(_borderStroke?.Shape, width, height);
_ = UpdateClipAsync(_borderStroke?.Shape, width, height);
UpdateClip(_borderStroke?.Shape, width, height);
}

internal void EnsureBorderPath(bool containsCheck = true)
Expand Down Expand Up @@ -160,10 +159,10 @@ void UpdateBorder(IShape? strokeShape)
return;
}

_ = UpdateClipAsync(strokeShape, width, height);
UpdateClip(strokeShape, width, height);
}

async Task UpdateClipAsync(IShape? borderShape, double width, double height)
void UpdateClip(IShape? borderShape, double width, double height)
{
if (Content is null)
{
Expand All @@ -184,11 +183,6 @@ async Task UpdateClipAsync(IShape? borderShape, double width, double height)

var visual = ElementCompositionPreview.GetElementVisual(Content);

visual.Clip = null;

//Adding Task.Yield ensures that all layouts are properly updated before applying the clip.
await Task.Yield();

var compositor = visual.Compositor;

PathF? clipPath;
Expand Down
5 changes: 4 additions & 1 deletion src/Core/src/Platform/Windows/LayoutPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ protected override WSize ArrangeOverride(WSize finalSize)
{
var actual = base.ArrangeOverride(finalSize);

Clip = ClipsToBounds ? new RectangleGeometry { Rect = new WRect(0, 0, finalSize.Width, finalSize.Height) } : null;
if (!(Parent is ContentPanel contentPanel && contentPanel.BorderStroke?.Shape is not null))
{
Clip = ClipsToBounds ? new RectangleGeometry { Rect = new WRect(0, 0, finalSize.Width, finalSize.Height) } : null;
}

return actual;
}
Expand Down

0 comments on commit 82eaee9

Please sign in to comment.