-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Windows] Fixes border content clipping (#17310)
* [Windows] Fixes border content clipping Fixes clip path size to consider the border stroke thickness, so it only uses the inner space. For the space the border takes we consider both sides (top and bottom, or left and right) and not just the thickness. On top of that, the clip should not be sentered with the content, so we need to offset it based on the contents position. * [Windows] Fixes border content clipping Fixes clip path size to consider the border stroke thickness, so it only uses the inner space. For the space the border takes we consider both sides (top and bottom, or left and right) and not just the thickness. On top of that, the clip should not be sentered with the content, so we need to offset it based on the contents position. * Fix BorderResizeContent sample Add stroke thickness to polygon border * Add border gallery for UI tests * Minor fixups to the Border1 Controls.Sample.UITest * Add border gallery ui tests * Update border test * Removed unnecessary .csproj changes * Add WaitForStubControl, waiting for UI to appear * Fix up border appium tests * Make WaitForStubControl have label text - didn't seem to show up otherwise * Disable test for now; will enable in a separate PR --------- Co-authored-by: Bret Johnson <[email protected]> Co-authored-by: Jeffrey Stedfast <[email protected]>
- Loading branch information
1 parent
f09e3d5
commit ca12263
Showing
9 changed files
with
241 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
src/Controls/samples/Controls.Sample.UITests/Elements/BorderGallery.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using Microsoft.Maui.Controls.Internals; | ||
|
||
namespace Maui.Controls.Sample | ||
{ | ||
[Preserve(AllMembers = true)] | ||
public class BorderGallery : ContentViewGalleryPage | ||
{ | ||
public BorderGallery() | ||
{ | ||
Add(new BordersWithVariousShapes()); | ||
} | ||
} | ||
} |
146 changes: 146 additions & 0 deletions
146
src/Controls/samples/Controls.Sample.UITests/Elements/BordersWithVariousShapes.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<ContentView | ||
x:Class="Maui.Controls.Sample.BordersWithVariousShapes" | ||
xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
AutomationId="BordersWithVariousShapes"> | ||
<ContentView.Resources> | ||
<Style x:Key="BorderStyle" TargetType="Border"> | ||
<Style.Setters> | ||
<Setter Property="StrokeShape"> | ||
<Setter.Value> | ||
<Ellipse /> | ||
</Setter.Value> | ||
</Setter> | ||
<Setter Property="WidthRequest" Value="101" /> | ||
<Setter Property="HeightRequest" Value="101" /> | ||
<Setter Property="BackgroundColor" Value="LightBlue" /> | ||
<Setter Property="StrokeThickness" Value="8" /> | ||
<Setter Property="Stroke" Value="LightGreen" /> | ||
</Style.Setters> | ||
</Style> | ||
|
||
<Style x:Key="BorderStyle2" TargetType="Border"> | ||
<Style.Setters> | ||
<Setter Property="StrokeShape"> | ||
<Setter.Value> | ||
<RoundRectangle /> | ||
</Setter.Value> | ||
</Setter> | ||
<Setter Property="WidthRequest" Value="101" /> | ||
<Setter Property="HeightRequest" Value="101" /> | ||
<Setter Property="BackgroundColor" Value="LightBlue" /> | ||
<Setter Property="StrokeThickness" Value="8" /> | ||
<Setter Property="Stroke" Value="LightGreen" /> | ||
</Style.Setters> | ||
</Style> | ||
|
||
<Style x:Key="BorderStyle3" TargetType="Border"> | ||
<Style.Setters> | ||
<Setter Property="StrokeShape"> | ||
<Setter.Value> | ||
<Polygon Points="40,10 70,80 10,50" StrokeThickness="3" /> | ||
</Setter.Value> | ||
</Setter> | ||
<Setter Property="WidthRequest" Value="101" /> | ||
<Setter Property="HeightRequest" Value="101" /> | ||
<Setter Property="BackgroundColor" Value="LightBlue" /> | ||
|
||
<Setter Property="Stroke" Value="LightGreen" /> | ||
</Style.Setters> | ||
</Style> | ||
|
||
<Style x:Key="ButtonIconStyle" TargetType="Label"> | ||
<Style.Setters> | ||
<Setter Property="BackgroundColor" Value="#99FF0000" /> | ||
<Setter Property="HorizontalTextAlignment" Value="Center" /> | ||
<Setter Property="HorizontalTextAlignment" Value="Center" /> | ||
<Setter Property="HorizontalOptions" Value="Center" /> | ||
<Setter Property="VerticalOptions" Value="Center" /> | ||
</Style.Setters> | ||
</Style> | ||
</ContentView.Resources> | ||
|
||
<HorizontalStackLayout Margin="10,10,10,10" Spacing="10"> | ||
<VerticalStackLayout Spacing="10" VerticalOptions="Center"> | ||
<Border Style="{StaticResource BorderStyle}"> | ||
<Label | ||
FontSize="18" | ||
Style="{StaticResource ButtonIconStyle}" | ||
Text="+" | ||
TextColor="#0088ee" /> | ||
</Border> | ||
|
||
<Border Style="{StaticResource BorderStyle2}"> | ||
<Label | ||
FontSize="18" | ||
Style="{StaticResource ButtonIconStyle}" | ||
Text="+" | ||
TextColor="#0088ee" /> | ||
</Border> | ||
|
||
<Border Style="{StaticResource BorderStyle3}"> | ||
<Label | ||
FontSize="18" | ||
Style="{StaticResource ButtonIconStyle}" | ||
Text="+" | ||
TextColor="#0088ee" /> | ||
</Border> | ||
|
||
<Label AutomationId="WaitForStubControl" Text="" /> | ||
</VerticalStackLayout> | ||
|
||
<VerticalStackLayout Spacing="10" VerticalOptions="Center"> | ||
<Border Style="{StaticResource BorderStyle}"> | ||
<Label | ||
FontSize="96" | ||
Style="{StaticResource ButtonIconStyle}" | ||
Text="+" | ||
TextColor="#0088ee" /> | ||
</Border> | ||
|
||
<Border Style="{StaticResource BorderStyle2}"> | ||
<Label | ||
FontSize="96" | ||
Style="{StaticResource ButtonIconStyle}" | ||
Text="+" | ||
TextColor="#0088ee" /> | ||
</Border> | ||
|
||
<Border Style="{StaticResource BorderStyle3}"> | ||
<Label | ||
FontSize="96" | ||
Style="{StaticResource ButtonIconStyle}" | ||
Text="+" | ||
TextColor="#0088ee" /> | ||
</Border> | ||
</VerticalStackLayout> | ||
|
||
<VerticalStackLayout Spacing="10" VerticalOptions="Center"> | ||
<Border Style="{StaticResource BorderStyle}"> | ||
<Label | ||
FontSize="120" | ||
Style="{StaticResource ButtonIconStyle}" | ||
Text="+" | ||
TextColor="#0088ee" /> | ||
</Border> | ||
|
||
<Border Style="{StaticResource BorderStyle2}"> | ||
<Label | ||
FontSize="120" | ||
Style="{StaticResource ButtonIconStyle}" | ||
Text="+" | ||
TextColor="#0088ee" /> | ||
</Border> | ||
|
||
<Border Style="{StaticResource BorderStyle3}"> | ||
<Label | ||
FontSize="120" | ||
Style="{StaticResource ButtonIconStyle}" | ||
Text="+" | ||
TextColor="#0088ee" /> | ||
</Border> | ||
</VerticalStackLayout> | ||
</HorizontalStackLayout> | ||
|
||
</ContentView> |
14 changes: 14 additions & 0 deletions
14
src/Controls/samples/Controls.Sample.UITests/Elements/BordersWithVariousShapes.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using Microsoft.Maui.Controls; | ||
using Microsoft.Maui.Controls.Xaml; | ||
|
||
namespace Maui.Controls.Sample | ||
{ | ||
[XamlCompilation(XamlCompilationOptions.Compile)] | ||
public partial class BordersWithVariousShapes : ContentView | ||
{ | ||
public BordersWithVariousShapes() | ||
{ | ||
InitializeComponent(); | ||
} | ||
} | ||
} |
6 changes: 1 addition & 5 deletions
6
src/Controls/samples/Controls.Sample.UITests/Elements/ButtonCoreGalleryPage.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using Microsoft.Maui.Appium; | ||
using NUnit.Framework; | ||
|
||
namespace Microsoft.Maui.AppiumTests | ||
{ | ||
public class BorderUITests : UITestBase | ||
{ | ||
const string BorderGallery = "* marked:'Border Gallery'"; | ||
|
||
public BorderUITests(TestDevice device) | ||
: base(device) | ||
{ | ||
} | ||
|
||
protected override void FixtureSetup() | ||
{ | ||
base.FixtureSetup(); | ||
App.NavigateToGallery(BorderGallery); | ||
} | ||
|
||
protected override void FixtureTeardown() | ||
{ | ||
base.FixtureTeardown(); | ||
App.NavigateBack(); | ||
} | ||
|
||
// TODO: Enable this as a test once fully working | ||
//[Test] | ||
public void BordersWithVariousShapes() | ||
{ | ||
App.WaitForElement("TargetView"); | ||
App.EnterText("TargetView", "BordersWithVariousShapes"); | ||
App.Tap("GoButton"); | ||
|
||
App.WaitForElement("WaitForStubControl"); | ||
|
||
VerifyScreenshot(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters