Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
bda11df
Fix Border corners clipping mistake on Windows
jsuarezruiz Apr 4, 2023
fccccd2
Merge branch 'main' into housekeeping-border-corners
jsuarezruiz Apr 10, 2023
0726a3d
Merge branch 'main' into housekeeping-border-corners
jsuarezruiz Apr 12, 2023
341b69b
Merge branch 'main' into fix-10407
jsuarezruiz Apr 13, 2023
f531dac
Merge branch 'main' into housekeeping-border-corners
jsuarezruiz Apr 20, 2023
7934531
Merge branch 'main' into housekeeping-border-corners
jsuarezruiz Apr 28, 2023
ca2180e
Merge branch 'main' into housekeeping-border-corners
jsuarezruiz May 3, 2023
521ad3b
Merge branch 'main' into housekeeping-border-corners
jsuarezruiz May 8, 2023
9a975ea
Merge branch 'main' into housekeeping-border-corners
jsuarezruiz May 31, 2023
d61d149
Updated impl
jsuarezruiz May 31, 2023
62013e5
Merge branch 'main' into housekeeping-border-corners
jsuarezruiz Jun 6, 2023
5c3fc09
Merge branch 'main' into housekeeping-border-corners
jsuarezruiz Jun 19, 2023
cc1e9ee
Merge branch 'main' into housekeeping-border-corners
jsuarezruiz Jun 22, 2023
7110f6a
Created method to avoid duplicated code
jsuarezruiz Jun 22, 2023
1a93828
Revert uneccesary changes
jsuarezruiz Jun 22, 2023
9c73f9f
Merge branch 'main' into housekeeping-border-corners
jsuarezruiz Jun 30, 2023
30d99e7
Changes in clipping sizing
jsuarezruiz Jul 13, 2023
7b5ba62
Fix Rui issue
jsuarezruiz Jul 13, 2023
6af3205
Added device tests
jsuarezruiz Jul 13, 2023
b0b5c1c
Remove unnecessary changes
jsuarezruiz Jul 13, 2023
10cfdeb
Merge branch 'main' into housekeeping-border-corners
jsuarezruiz Jul 14, 2023
08e88ae
Merge branch 'main' into housekeeping-border-corners
jsuarezruiz Jul 18, 2023
a49adcd
Merge branch 'main' into housekeeping-border-corners
jsuarezruiz Jul 25, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@
<Grid
Padding="12">
<Grid.RowDefinitions>
<RowDefinition Height="80" />
<RowDefinition Height="110" />
<RowDefinition Height="*"/>
</Grid.RowDefinitions>

<Border x:Name="BorderView" Margin="5"
Stroke="Red" Padding="0"
HorizontalOptions="Center" HeightRequest="100" WidthRequest="100">
<Border
x:Name="BorderView" Margin="5"
Stroke="Red" Padding="0"
HorizontalOptions="Center" HeightRequest="100" WidthRequest="100">
<Image x:Name="BorderContent" Aspect="AspectFill" Source="oasis.jpg" />
</Border>

Expand Down
31 changes: 22 additions & 9 deletions src/Core/src/Platform/Windows/ContentPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace Microsoft.Maui.Platform
public class ContentPanel : Panel
{
readonly Path? _borderPath;
IShape? _borderShape;
IBorderStroke? _borderStroke;
FrameworkElement? _content;

internal Path? BorderPath => _borderPath;
Expand Down Expand Up @@ -76,9 +76,9 @@ void ContentPanelSizeChanged(object sender, UI.Xaml.SizeChangedEventArgs e)
if (_borderPath == null)
return;

_borderPath.UpdatePath(_borderShape, ActualWidth, ActualHeight);
_borderPath.UpdatePath(_borderStroke?.Shape, ActualWidth, ActualHeight);
UpdateContent();
UpdateClip(_borderShape);
UpdateClip(_borderStroke?.Shape);
}

internal void EnsureBorderPath()
Expand All @@ -97,18 +97,21 @@ public void UpdateBackground(Paint? background)
_borderPath.UpdateBackground(background);
}

public void UpdateBorderShape(IShape borderShape)
public void UpdateBorderStroke(IBorderStroke borderStroke)
{
_borderShape = borderShape;
if (borderStroke is null)
return;

_borderStroke = borderStroke;

if (_borderPath == null)
return;

_borderPath.UpdateBorderShape(_borderShape, ActualWidth, ActualHeight);
_borderPath.UpdateBorderShape(_borderStroke.Shape, ActualWidth, ActualHeight);
UpdateContent();
UpdateClip(_borderShape);
UpdateClip(_borderStroke.Shape);
}

void AddContent(FrameworkElement? content)
{
if (content == null)
Expand Down Expand Up @@ -147,8 +150,18 @@ void UpdateClip(IShape? borderShape)
var visual = ElementCompositionPreview.GetElementVisual(Content);
var compositor = visual.Compositor;


var pathSize = new Graphics.Rect(0, 0, width, height);
var clipPath = clipGeometry.PathForBounds(pathSize);
PathF? clipPath;

if (clipGeometry is IRoundRectangle roundRectangle)
{
var strokeThickness = (float)(_borderStroke?.StrokeThickness ?? 0);
clipPath = roundRectangle.InnerPathForBounds(pathSize, strokeThickness);
}
else
clipPath = clipGeometry?.PathForBounds(pathSize);

var device = CanvasDevice.GetSharedDevice();
var geometry = clipPath.AsPath(device);

Expand Down
6 changes: 2 additions & 4 deletions src/Core/src/Platform/Windows/StrokeExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@ public static class StrokeExtensions
{
public static void UpdateStrokeShape(this ContentPanel platformView, IBorderStroke border)
{
var shape = border.Shape;

if (shape == null)
if (border is null)
return;

platformView.UpdateBorderShape(shape);
platformView.UpdateBorderStroke(border);
}

public static void UpdateStroke(this ContentPanel platformView, IBorderStroke border)
Expand Down
1 change: 0 additions & 1 deletion src/Core/src/PublicAPI/net-windows/PublicAPI.Shipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1551,7 +1551,6 @@ Microsoft.Maui.Platform.ColorExtensions
Microsoft.Maui.Platform.ContentPanel
Microsoft.Maui.Platform.ContentPanel.ContentPanel() -> void
Microsoft.Maui.Platform.ContentPanel.UpdateBackground(Microsoft.Maui.Graphics.Paint? background) -> void
Microsoft.Maui.Platform.ContentPanel.UpdateBorderShape(Microsoft.Maui.Graphics.IShape! borderShape) -> void
Microsoft.Maui.Platform.ControlExtensions
Microsoft.Maui.Platform.DatePickerExtensions
Microsoft.Maui.Platform.ElementExtensions
Expand Down
1 change: 1 addition & 0 deletions src/Core/src/PublicAPI/net-windows/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Microsoft.Maui.ICommandMapper<TVirtualView, TViewHandler>
Microsoft.Maui.ICommandMapper<TVirtualView, TViewHandler>.Add(string! key, System.Action<TViewHandler, TVirtualView, object?>! action) -> void
Microsoft.Maui.ICommandMapper<TVirtualView, TViewHandler>.Add(string! key, System.Action<TViewHandler, TVirtualView>! action) -> void
Microsoft.Maui.Layouts.FlexBasis.Equals(Microsoft.Maui.Layouts.FlexBasis other) -> bool
Microsoft.Maui.Platform.ContentPanel.UpdateBorderStroke(Microsoft.Maui.IBorderStroke! borderStroke) -> void
Microsoft.Maui.Platform.MauiWebView.MauiWebView(Microsoft.Maui.Handlers.WebViewHandler! handler) -> void
Microsoft.Maui.SizeRequest.Equals(Microsoft.Maui.SizeRequest other) -> bool
override Microsoft.Maui.Handlers.ContentViewHandler.DisconnectHandler(Microsoft.Maui.Platform.ContentPanel! platformView) -> void
Expand Down