Skip to content

Commit

Permalink
Add ability to compile for VS Mac 2022 (17.0)
Browse files Browse the repository at this point in the history
  • Loading branch information
cwensley committed Jun 11, 2022
1 parent 11caf99 commit 35c20f5
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 29 deletions.
4 changes: 4 additions & 0 deletions src/Eto.Mac/Drawing/FormattedTextHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ protected void ShowGlyphs(IntPtr glyphs, IntPtr positions, nuint glyphCount, Int

// what to do with the attributes?? needed?
var m = CTFontGetMatrix(font);
#if !XAMMAC || VSMAC
m.Translate(textMatrix.Tx, textMatrix.Ty);
#else
m.Translate(textMatrix.x0, textMatrix.y0);
#endif
m.Scale(1, -1);
ctx.TextMatrix = m;
CTFontDrawGlyphs(font, glyphs, positions, glyphCount, ctx.Handle);
Expand Down
35 changes: 20 additions & 15 deletions src/Eto.Mac/Drawing/MatrixHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,33 +40,38 @@ public void Create (float xx, float yx, float xy, float yy, float dx, float dy)
{
control = new CGAffineTransform (xx, yx, xy, yy, dx, dy);
}

public float[] Elements
{
get
{
return new float[] {

#if !XAMMAC || VSMAC
public float[] Elements => new float[] {
(float)control.A,
(float)control.B,
(float)control.C,
(float)control.D,
(float)control.Tx,
(float)control.Ty };

public float X0 { get { return (float)control.Tx; } set { control.Tx = value; } }
public float Y0 { get { return (float)control.Ty; } set { control.Ty = value; } }
public float Xx { get { return (float)control.A; } set { control.A = value; } }
public float Xy { get { return (float)control.C; } set { control.C = value; } }
public float Yx { get { return (float)control.B; } set { control.B = value; } }
public float Yy { get { return (float)control.D; } set { control.D = value; } }
#else
public float[] Elements => new float[] {
(float)control.xx,
(float)control.yx,
(float)control.xy,
(float)control.yy,
(float)control.x0,
(float)control.y0
};
}
}
(float)control.y0 };

public float X0 { get { return (float)control.x0; } set { control.x0 = value; } }

public float Y0 { get { return (float)control.y0; } set { control.y0 = value; } }

public float Xx { get { return (float)control.xx; } set { control.xx = value; } }

public float Xy { get { return (float)control.xy; } set { control.xy = value; } }

public float Yx { get { return (float)control.yx; } set { control.yx = value; } }

public float Yy { get { return (float)control.yy; } set { control.yy = value; } }
#endif

public void Rotate (float angle)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Eto.Mac/Drawing/TextureBrushHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public void Draw(GraphicsHandler graphics, bool stroke, FillMode fillMode, bool

context.SaveState();
context.ConcatCTM(transform);
context.ConcatCTM(new CGAffineTransform(1, 0, 0, -1, 0, Image.Height));
context.ConcatCTM(new CGAffineTransform(1, 0, 0, -1, 0, (nfloat)Image.Height));
//transform.ToEto().TransformRectangle(rect);

if (Opacity < 1f)
Expand Down
4 changes: 2 additions & 2 deletions src/Eto.Mac/Eto.XamMac2.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

<PropertyGroup>
<UseXamarinMac Condition="$(UseXamarinMac) == ''">True</UseXamarinMac>
<TargetFrameworks>net462;xamarinmac20</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::VersionGreaterThanOrEquals($(NETCoreSdkVersion), '6.0')) AND $([MSBuild]::VersionLessThan($(NETCoreSdkVersion), '6.0.200'))">net6.0-macos10.15;$(TargetFrameworks)</TargetFrameworks>
<TargetFrameworks Condition="$(OverrideTargetFrameworks) != 'True'">net462;xamarinmac20</TargetFrameworks>
<TargetFrameworks Condition="$(OverrideTargetFrameworks) != 'True' AND $([MSBuild]::VersionGreaterThanOrEquals($(NETCoreSdkVersion), '6.0')) AND $([MSBuild]::VersionLessThan($(NETCoreSdkVersion), '6.0.200'))">net6.0-macos10.15;$(TargetFrameworks)</TargetFrameworks>
<RootNamespace>Eto.Mac</RootNamespace>
<DefineConstants>$(DefineConstants);OSX;DESKTOP;XAMMAC;XAMMAC2;UNIFIED</DefineConstants>
<DefineConstants Condition="$(UseCFString) != 'False'">$(DefineConstants);USE_CFSTRING</DefineConstants>
Expand Down
14 changes: 7 additions & 7 deletions src/Eto.Mac/Forms/Controls/GridViewHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using System.Linq;
using Eto.Mac.Forms.Cells;

#if MACOS_NET
#if MACOS_NET && !VSMAC
using NSDraggingInfo = AppKit.INSDraggingInfo;
#endif

Expand Down Expand Up @@ -110,8 +110,8 @@ public override bool ValidateProposedFirstResponder(NSResponder responder, NSEve
return Handler?.ValidateProposedFirstResponder(responder, forEvent, valid) ?? valid;
}

#if XAMMAC2
public override NSImage DragImageForRowsWithIndexestableColumnseventoffset(NSIndexSet dragRows, NSTableColumn[] tableColumns, NSEvent dragEvent, ref CGPoint dragImageOffset)
#if MACOS_NET
public override NSImage DragImageForRows(NSIndexSet dragRows, NSTableColumn[] tableColumns, NSEvent dragEvent, ref CGPoint dragImageOffset)
{
var dragInfo = Handler?.DragInfo;
var img = dragInfo?.DragImage;
Expand All @@ -120,10 +120,10 @@ public override NSImage DragImageForRowsWithIndexestableColumnseventoffset(NSInd
dragImageOffset = dragInfo.GetDragImageOffset();
return img;
}
return base.DragImageForRowsWithIndexestableColumnseventoffset(dragRows, tableColumns, dragEvent, ref dragImageOffset);
return base.DragImageForRows(dragRows, tableColumns, dragEvent, ref dragImageOffset);
}
#elif MACOS_NET
public override NSImage DragImageForRows(NSIndexSet dragRows, NSTableColumn[] tableColumns, NSEvent dragEvent, ref CGPoint dragImageOffset)
#elif XAMMAC2
public override NSImage DragImageForRowsWithIndexestableColumnseventoffset(NSIndexSet dragRows, NSTableColumn[] tableColumns, NSEvent dragEvent, ref CGPoint dragImageOffset)
{
var dragInfo = Handler?.DragInfo;
var img = dragInfo?.DragImage;
Expand All @@ -132,7 +132,7 @@ public override NSImage DragImageForRows(NSIndexSet dragRows, NSTableColumn[] ta
dragImageOffset = dragInfo.GetDragImageOffset();
return img;
}
return base.DragImageForRows(dragRows, tableColumns, dragEvent, ref dragImageOffset);
return base.DragImageForRowsWithIndexestableColumnseventoffset(dragRows, tableColumns, dragEvent, ref dragImageOffset);
}
#else

Expand Down
2 changes: 1 addition & 1 deletion src/Eto.Mac/Forms/Controls/SliderHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public SliderHandler Handler
set { WeakHandler = new WeakReference(value); }
}

#if MACOS_NET
#if MACOS_NET && !VSMAC
public override bool IsVertical => Handler?.Orientation == Orientation.Vertical;
#else
public override nint IsVertical => Handler?.Orientation == Orientation.Vertical ? 1 : 0;
Expand Down
2 changes: 1 addition & 1 deletion src/Eto.Mac/Forms/Controls/TextAreaHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public object Handler
set { WeakHandler = new WeakReference(value); }
}

#if MACOS_NET
#if MACOS_NET && !VSMAC
public override void ChangeColor(NSColorPanel sender)
{
// ignore color changes
Expand Down
2 changes: 1 addition & 1 deletion src/Eto.Mac/Forms/Controls/TreeGridViewHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using Eto.Mac.Forms.Cells;
using Eto.Drawing;

#if MACOS_NET
#if MACOS_NET && !VSMAC
using NSDraggingInfo = AppKit.INSDraggingInfo;
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/Eto.Mac/Forms/MacWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ public override void AttachEvent(string id)
if (handler != null)
{
var args = new NSWindowBackingPropertiesEventArgs(e.Notification);
if (args.OldScaleFactor != handler.Control.BackingScaleFactor)
if ((nfloat)args.OldScaleFactor != handler.Control.BackingScaleFactor)
handler.Callback.OnLogicalPixelSizeChanged(handler.Widget, EventArgs.Empty);
}
});
Expand Down

0 comments on commit 35c20f5

Please sign in to comment.