mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-15 21:19:07 +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
|
if not isembedded then
|
||||||
begin
|
begin
|
||||||
//Window bounds should return "client rect" in screen coordinates
|
//Window bounds should return "client rect" in screen coordinates
|
||||||
if Assigned(window.screen) then
|
NSToLCLRect(window.frame, NSGlobalScreenHeight, wfrm);
|
||||||
NSToLCLRect(window.frame, NSGlobalScreenHeight, wfrm)
|
|
||||||
else
|
|
||||||
wfrm := NSRectToRect(frame);
|
|
||||||
Types.OffsetRect(Result, -Result.Left+wfrm.Left, -Result.Top+wfrm.Top);
|
Types.OffsetRect(Result, -Result.Left+wfrm.Left, -Result.Top+wfrm.Top);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -1239,39 +1236,30 @@ end;
|
|||||||
|
|
||||||
procedure LCLWindowExtension.lclRelativePos(var Left, Top: Integer);
|
procedure LCLWindowExtension.lclRelativePos(var Left, Top: Integer);
|
||||||
var
|
var
|
||||||
f: NSRect;
|
f: NSRect;
|
||||||
begin
|
begin
|
||||||
if Assigned(screen) then
|
f:=frame;
|
||||||
begin
|
Left := Round(f.origin.x);
|
||||||
f:=frame;
|
Top := Round(NSGlobalScreenHeight - NSMaxY(f));
|
||||||
Left := Round(f.origin.x);
|
//debugln('Top:'+dbgs(Top));
|
||||||
Top := Round(NSGlobalScreenHeight - f.size.height - f.origin.y);
|
|
||||||
//debugln('Top:'+dbgs(Top));
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure LCLWindowExtension.lclLocalToScreen(var X, Y:Integer);
|
procedure LCLWindowExtension.lclLocalToScreen(var X, Y:Integer);
|
||||||
var
|
var
|
||||||
f: NSRect;
|
f: NSRect;
|
||||||
begin
|
begin
|
||||||
if Assigned(screen) then
|
f := frame;
|
||||||
begin
|
inc(X, Round(f.origin.x));
|
||||||
f := frame;
|
inc(Y, Round(NSGlobalScreenHeight - NSMaxY(f)));
|
||||||
inc(X, Round(f.origin.x));
|
|
||||||
inc(Y, Round(NSGlobalScreenHeight - f.size.height - f.origin.y));
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure LCLWindowExtension.lclScreenToLocal(var X, Y: Integer);
|
procedure LCLWindowExtension.lclScreenToLocal(var X, Y: Integer);
|
||||||
var
|
var
|
||||||
f: NSRect;
|
f: NSRect;
|
||||||
begin
|
begin
|
||||||
if Assigned(screen) then
|
f := frame;
|
||||||
begin
|
dec(X, Round(f.origin.x));
|
||||||
f := frame;
|
dec(Y, Round(NSGlobalScreenHeight - NSMaxY(f)));
|
||||||
dec(X, Round(f.origin.x));
|
|
||||||
dec(Y, Round(NSGlobalScreenHeight - f.size.height - f.origin.y));
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function LCLWindowExtension.lclFrame: TRect;
|
function LCLWindowExtension.lclFrame: TRect;
|
||||||
@ -1279,12 +1267,7 @@ begin
|
|||||||
if Assigned(contentView) then
|
if Assigned(contentView) then
|
||||||
Result:=contentView.lclFrame
|
Result:=contentView.lclFrame
|
||||||
else
|
else
|
||||||
begin
|
NSToLCLRect(frame, NSGlobalScreenHeight, Result);
|
||||||
if Assigned(screen) then
|
|
||||||
NSToLCLRect(frame, NSGlobalScreenHeight, Result)
|
|
||||||
else
|
|
||||||
Result := NSRectToRect(frame);
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function LCLWindowExtension.lclGetTopBarHeight:integer;
|
function LCLWindowExtension.lclGetTopBarHeight:integer;
|
||||||
|
Loading…
Reference in New Issue
Block a user