Skip to content

Commit

Permalink
[Mac] use proper text alignment on arm64
Browse files Browse the repository at this point in the history
TextAlignment Right and Center are switched up on Arm64 Macos.
  • Loading branch information
Miepee committed Mar 6, 2023
1 parent 7bc5c5b commit fff00e3
Show file tree
Hide file tree
Showing 2 changed files with 161 additions and 4 deletions.
151 changes: 151 additions & 0 deletions src/.idea/.idea.Eto/.idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 10 additions & 4 deletions src/Eto.Mac/MacConversions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 == System.Runtime.InteropServices.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 == System.Runtime.InteropServices.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();
}
Expand Down

0 comments on commit fff00e3

Please sign in to comment.