mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-22 11:19:26 +02:00
Cocoa: simplify coordinate conversion related to Window
This commit is contained in:
parent
a4863bb0e3
commit
0c99ef9d0d
@ -446,10 +446,7 @@ begin
|
||||
if not isembedded then
|
||||
begin
|
||||
//Window bounds should return "client rect" in screen coordinates
|
||||
if Assigned(window.screen) then
|
||||
NSToLCLRect(window.frame, NSGlobalScreenHeight, wfrm)
|
||||
else
|
||||
wfrm := NSRectToRect(frame);
|
||||
NSToLCLRect(window.frame, NSGlobalScreenHeight, wfrm);
|
||||
Types.OffsetRect(Result, -Result.Left+wfrm.Left, -Result.Top+wfrm.Top);
|
||||
end;
|
||||
end;
|
||||
@ -1239,39 +1236,30 @@ end;
|
||||
|
||||
procedure LCLWindowExtension.lclRelativePos(var Left, Top: Integer);
|
||||
var
|
||||
f: NSRect;
|
||||
f: NSRect;
|
||||
begin
|
||||
if Assigned(screen) then
|
||||
begin
|
||||
f:=frame;
|
||||
Left := Round(f.origin.x);
|
||||
Top := Round(NSGlobalScreenHeight - f.size.height - f.origin.y);
|
||||
//debugln('Top:'+dbgs(Top));
|
||||
end;
|
||||
f:=frame;
|
||||
Left := Round(f.origin.x);
|
||||
Top := Round(NSGlobalScreenHeight - NSMaxY(f));
|
||||
//debugln('Top:'+dbgs(Top));
|
||||
end;
|
||||
|
||||
procedure LCLWindowExtension.lclLocalToScreen(var X, Y:Integer);
|
||||
var
|
||||
f: NSRect;
|
||||
begin
|
||||
if Assigned(screen) then
|
||||
begin
|
||||
f := frame;
|
||||
inc(X, Round(f.origin.x));
|
||||
inc(Y, Round(NSGlobalScreenHeight - f.size.height - f.origin.y));
|
||||
end;
|
||||
f := frame;
|
||||
inc(X, Round(f.origin.x));
|
||||
inc(Y, Round(NSGlobalScreenHeight - NSMaxY(f)));
|
||||
end;
|
||||
|
||||
procedure LCLWindowExtension.lclScreenToLocal(var X, Y: Integer);
|
||||
var
|
||||
f: NSRect;
|
||||
begin
|
||||
if Assigned(screen) then
|
||||
begin
|
||||
f := frame;
|
||||
dec(X, Round(f.origin.x));
|
||||
dec(Y, Round(NSGlobalScreenHeight - f.size.height - f.origin.y));
|
||||
end;
|
||||
f := frame;
|
||||
dec(X, Round(f.origin.x));
|
||||
dec(Y, Round(NSGlobalScreenHeight - NSMaxY(f)));
|
||||
end;
|
||||
|
||||
function LCLWindowExtension.lclFrame: TRect;
|
||||
@ -1279,12 +1267,7 @@ begin
|
||||
if Assigned(contentView) then
|
||||
Result:=contentView.lclFrame
|
||||
else
|
||||
begin
|
||||
if Assigned(screen) then
|
||||
NSToLCLRect(frame, NSGlobalScreenHeight, Result)
|
||||
else
|
||||
Result := NSRectToRect(frame);
|
||||
end;
|
||||
NSToLCLRect(frame, NSGlobalScreenHeight, Result);
|
||||
end;
|
||||
|
||||
function LCLWindowExtension.lclGetTopBarHeight:integer;
|
||||
|
Loading…
Reference in New Issue
Block a user