Skip to content

Commit

Permalink
[Window] Fix transforms being offset by 0.5x0.5 (#20454)
Browse files Browse the repository at this point in the history
* Fix transforms being offset by 0.5x0.5

* Added visual regression test

* Adjust tests

* Fix ref image

* update baseline img again...

---------

Co-authored-by: Mike Corsaro <mikecorsaro@microsoft.com>
  • Loading branch information
Foda and Mike Corsaro committed Feb 22, 2024
1 parent 85adc13 commit 373b060
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,13 @@
<ProjectReference Condition="'$(IncludeCompatibilityProjects)' == 'true'" Include="..\..\..\Compatibility\Core\src\Compatibility.csproj" />
<ProjectReference Include="..\..\..\Controls\Maps\src\Controls.Maps.csproj" />
<ProjectReference Include="..\..\..\Controls\Foldable\src\Controls.Foldable.csproj" />
<ProjectReference Include="..\..\..\Graphics\src\Graphics\Graphics.csproj" />
</ItemGroup>

<ItemGroup Condition=" '$(UseMaui)' == 'true' ">
<PackageReference Include="Microsoft.Maui.Controls.Foldable" Version="$(MauiVersion)" />
<PackageReference Include="Microsoft.Maui.Controls.Maps" Version="$(MauiVersion)" />
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="$(MauiVersion)" />
</ItemGroup>

<ItemGroup>
Expand Down
57 changes: 57 additions & 0 deletions src/Controls/samples/Controls.Sample.UITests/Issues/Issue17694.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
using Microsoft.Maui.Controls;
using Microsoft.Maui.Graphics;

namespace Maui.Controls.Sample.Issues
{
[Issue(IssueTracker.Github, 17694, "Circle view not rotating from center", PlatformAffected.UWP)]
public class Issue17694 : TestContentPage
{
protected override void Init()
{
var circleView = new CircleView
{
HeightRequest = 50,
WidthRequest = 50,
Drawable = new CircleDraw()
};

var button = new Button()
{
AutomationId = "Spin",
Text = "Spin",
};
button.Clicked += (s, e) =>
{
circleView.Rotation = 180;
};

var stack = new VerticalStackLayout
{
circleView,
button
};

Content = stack;
}

public class CircleView : GraphicsView
{
public CircleView()
{

}
}

public class CircleDraw : IDrawable
{
public void Draw(ICanvas canvas, RectF dirtyRect)
{
canvas.FillColor = Colors.Red;
canvas.FillCircle(25, 25, 25);
canvas.StrokeSize = 1f;
canvas.StrokeColor = Colors.Black;
canvas.DrawLine(0, 25, 50, 25);
}
}
}
}
33 changes: 33 additions & 0 deletions src/Controls/tests/UITests/Tests/Issues/Issue17694.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using NUnit.Framework;
using UITest.Appium;
using UITest.Core;

namespace Microsoft.Maui.AppiumTests.Issues
{
public class Issue17694 : _IssuesUITest
{
public Issue17694(TestDevice device) : base(device)
{
}

public override string Issue => "Circle view not rotating from center";

[Test]
public void Issue17694Test()
{
this.IgnoreIfPlatforms(new[]
{
TestDevice.iOS,
TestDevice.Mac,
TestDevice.Android
});

App.WaitForElement("Spin");

// 1. Click button
App.Click("Spin");

VerifyScreenshot();
}
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 0 additions & 2 deletions src/Core/src/Platform/Windows/TransformationExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ public static void UpdateTransformation(this FrameworkElement frameworkElement,
{
frameworkElement.RenderTransform = new CompositeTransform
{
CenterX = anchorX,
CenterY = anchorY,
Rotation = rotation,
ScaleX = scaleX,
ScaleY = scaleY,
Expand Down

0 comments on commit 373b060

Please sign in to comment.