Cocoa: fix the setting of Custom Control with Flipped coordinates

Note that on Cocoa:
1. Not Flipped: opposite to win32
2. Flipped: like win32
This commit is contained in:
rich2014 2024-06-09 18:43:17 +08:00
parent ef1838e6d2
commit d6afcd1953

View File

@ -505,9 +505,15 @@ begin
end;
procedure SetViewDefaults(AView: NSView);
var
mask: NSUInteger;
begin
if not Assigned(AView) then Exit;
AView.setAutoresizingMask(NSViewMinYMargin or NSViewMaxXMargin);
if Assigned(AView.superview) and AView.superview.isFlipped then
mask:= NSViewMaxYMargin or NSViewMaxXMargin
else
mask:= NSViewMinYMargin or NSViewMaxXMargin;
AView.setAutoresizingMask(mask);
end;
function CheckMainThread: Boolean;
@ -627,6 +633,8 @@ begin
end;
procedure TCocoaCustomControl.addSubView(aview: NSView);
var
mask: NSUInteger;
begin
inherited addSubView(aview);
@ -639,7 +647,11 @@ begin
{$else}
setAutoresizesSubviews(true);
{$endif}
aview.setAutoresizingMask(NSViewMaxXMargin or NSViewMinYMargin);
if self.isFlipped then
mask:= NSViewMaxYMargin or NSViewMaxXMargin
else
mask:= NSViewMinYMargin or NSViewMaxXMargin;
aview.setAutoresizingMask(mask);
end;
end;
@ -1360,7 +1372,7 @@ begin
if (AParams.WndParent <> 0) then
p := NSView(AParams.WndParent).lclContentView;
if Assigned(p) then
if Assigned(p) and p.isFlipped then
LCLToNSRect(Types.Bounds(AParams.X, AParams.Y, AParams.Width, AParams.Height),
p.frame.size.height, ns)
else