From 627eedec51e12aaf962aae65061ee7e2e414063e Mon Sep 17 00:00:00 2001 From: Miepee Date: Mon, 6 Mar 2023 12:26:33 +0100 Subject: [PATCH] [Mac] use proper text alignment on arm64 TextAlignment Right and Center are switched up on Arm64 Macos. --- src/.idea/.idea.Eto/.idea/workspace.xml | 151 ++++++++++++++++++++++++ src/Eto.Mac/MacConversions.cs | 14 ++- 2 files changed, 161 insertions(+), 4 deletions(-) create mode 100644 src/.idea/.idea.Eto/.idea/workspace.xml diff --git a/src/.idea/.idea.Eto/.idea/workspace.xml b/src/.idea/.idea.Eto/.idea/workspace.xml new file mode 100644 index 0000000000..4a7d788768 --- /dev/null +++ b/src/.idea/.idea.Eto/.idea/workspace.xml @@ -0,0 +1,151 @@ + + + + ../lib/monomac/src/generator.csproj + ../test/Eto.Test.Direct2D/Eto.Test.Direct2D.csproj + ../test/Eto.Test.Gtk/Eto.Test.Gtk.csproj + ../test/Eto.Test.Mac/Eto.Test.Mac64.csproj + ../test/Eto.Test.Mac/Eto.Test.XamMac2.csproj + ../test/Eto.Test.Mac/Eto.Test.macOS.csproj + ../test/Eto.Test.WinForms/Eto.Test.WinForms.csproj + ../test/Eto.Test.Wpf/Eto.Test.Wpf.csproj + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1678010493564 + + + + + + + + + + + + + file://$PROJECT_DIR$/../test/Eto.Test/UnitTests/Forms/CascadingStyleTests.cs + 94 + + + + + + + + + + + \ No newline at end of file diff --git a/src/Eto.Mac/MacConversions.cs b/src/Eto.Mac/MacConversions.cs index 8151c8212b..73cb491a0d 100644 --- a/src/Eto.Mac/MacConversions.cs +++ b/src/Eto.Mac/MacConversions.cs @@ -426,28 +426,34 @@ public static NSDatePickerMode ToNS(this CalendarMode mode) public static TextAlignment ToEto(this NSTextAlignment align) { + // NSTextAlignment Right and Center are interchanged on Arm64 MacOS + // See https://github.com/picoe/Eto/issues/2250 + bool isArm = System.Runtime.InteropServices.RuntimeInformation.ProcessArchitecture == Architecture.Arm64; switch (align) { default: case NSTextAlignment.Left: return TextAlignment.Left; case NSTextAlignment.Right: - return TextAlignment.Right; + return isArm ? TextAlignment.Center : TextAlignment.Right; case NSTextAlignment.Center: - return TextAlignment.Center; + return isArm ? TextAlignment.Right : TextAlignment.Center; } } public static NSTextAlignment ToNS(this TextAlignment align) { + // NSTextAlignment Right and Center are interchanged on Arm64 MacOS + // See https://github.com/picoe/Eto/issues/2250 + bool isArm = System.Runtime.InteropServices.RuntimeInformation.ProcessArchitecture == Architecture.Arm64; switch (align) { case TextAlignment.Left: return NSTextAlignment.Left; case TextAlignment.Center: - return NSTextAlignment.Center; + return isArm ? NSTextAlignment.Right : NSTextAlignment.Center; case TextAlignment.Right: - return NSTextAlignment.Right; + return isArm ? NSTextAlignment.Center : NSTextAlignment.Right; default: throw new NotSupportedException(); }