mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-12 09:56:12 +02:00
cocoa: update the proper tab control placement and client dimensions for ShowTabs set to false. #35565
git-svn-id: trunk@61399 -
This commit is contained in:
parent
2d8ade5a97
commit
04d6641daf
@ -440,22 +440,43 @@ end;
|
|||||||
function TCocoaTabControl.lclClientFrame: TRect;
|
function TCocoaTabControl.lclClientFrame: TRect;
|
||||||
var
|
var
|
||||||
r : TRect;
|
r : TRect;
|
||||||
|
f : NSRect;
|
||||||
begin
|
begin
|
||||||
if isFlipped then
|
case tabViewType of
|
||||||
Result:=NSRectToRect( contentRect )
|
NSNoTabsNoBorder:
|
||||||
|
begin
|
||||||
|
f := frame;
|
||||||
|
f.origin.x := 0;
|
||||||
|
f.origin.y := 0;
|
||||||
|
Result := NSRectToRect( f );
|
||||||
|
end;
|
||||||
else
|
else
|
||||||
NSToLCLRect( contentRect, frame.size.height, Result );
|
if isFlipped then
|
||||||
|
Result:=NSRectToRect( contentRect )
|
||||||
|
else
|
||||||
|
NSToLCLRect( contentRect, frame.size.height, Result );
|
||||||
|
end;
|
||||||
|
|
||||||
r:=lclGetFrameToLayoutDelta;
|
//if tabs are hidden, frame layout should not be taken into account
|
||||||
Types.OffsetRect(Result, -r.Left, -r.Top);
|
//r:=lclGetFrameToLayoutDelta;
|
||||||
|
//Types.OffsetRect(Result, -r.Left, -r.Top);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TCocoaTabControl.lclGetFrameToLayoutDelta: TRect;
|
function TCocoaTabControl.lclGetFrameToLayoutDelta: TRect;
|
||||||
begin
|
begin
|
||||||
Result.Bottom := -10;
|
case tabViewType of
|
||||||
Result.Top := 6;
|
NSNoTabsNoBorder: begin
|
||||||
Result.Left := 7;
|
Result.Left := 0;
|
||||||
Result.Right := -7;
|
Result.Top := 0;
|
||||||
|
Result.Bottom := 0;
|
||||||
|
Result.Right := 0;
|
||||||
|
end;
|
||||||
|
else
|
||||||
|
Result.Bottom := -10;
|
||||||
|
Result.Top := 6;
|
||||||
|
Result.Left := 7;
|
||||||
|
Result.Right := -7;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TCocoaTabControl.tabView_shouldSelectTabViewItem(tabView: NSTabView;
|
function TCocoaTabControl.tabView_shouldSelectTabViewItem(tabView: NSTabView;
|
||||||
|
@ -823,13 +823,36 @@ class procedure TCocoaWSCustomTabControl.ShowTabs(const ATabControl: TCustomTabC
|
|||||||
var
|
var
|
||||||
lTabControl: TCocoaTabControl = nil;
|
lTabControl: TCocoaTabControl = nil;
|
||||||
lOldTabStyle, lTabStyle: NSTabViewType;
|
lOldTabStyle, lTabStyle: NSTabViewType;
|
||||||
|
var
|
||||||
|
pr : TRect;
|
||||||
|
ar : TRect;
|
||||||
|
fr : NSRect;
|
||||||
|
dx, dy : double;
|
||||||
|
cb: ICommonCallback;
|
||||||
begin
|
begin
|
||||||
if not Assigned(ATabControl) or not ATabControl.HandleAllocated then Exit;
|
if not Assigned(ATabControl) or not ATabControl.HandleAllocated then Exit;
|
||||||
lTabControl := TCocoaTabControl(ATabControl.Handle);
|
lTabControl := TCocoaTabControl(ATabControl.Handle);
|
||||||
|
|
||||||
lOldTabStyle := lTabControl.tabViewType();
|
lOldTabStyle := lTabControl.tabViewType();
|
||||||
lTabStyle := LCLTabPosToNSTabStyle(AShowTabs, ATabControl.BorderWidth, ATabControl.TabPosition);
|
lTabStyle := LCLTabPosToNSTabStyle(AShowTabs, ATabControl.BorderWidth, ATabControl.TabPosition);
|
||||||
|
pr := lTabControl.lclGetFrameToLayoutDelta;
|
||||||
lTabControl.setTabViewType(lTabStyle);
|
lTabControl.setTabViewType(lTabStyle);
|
||||||
|
ar := lTabControl.lclGetFrameToLayoutDelta;
|
||||||
|
// switching ShowTabs actually changes layout to frame
|
||||||
|
// this needs to be compenstated
|
||||||
|
if (ar.Top<>pr.Top) or (pr.Left<>ar.Top) then
|
||||||
|
begin
|
||||||
|
fr := lTabControl.frame;
|
||||||
|
dx := pr.Left - ar.left;
|
||||||
|
dy := pr.Top - ar.Top;
|
||||||
|
fr.origin.x := fr.origin.x + dx;
|
||||||
|
fr.origin.y := fr.origin.y + dy;
|
||||||
|
fr.size.width := fr.size.width - dx - (ar.Right - pr.Right);
|
||||||
|
fr.size.height := fr.size.height - dy - (ar.Bottom - pr.Bottom);
|
||||||
|
lTabControl.setFrame(fr);
|
||||||
|
cb := lTabControl.lclGetCallback;
|
||||||
|
if Assigned(cb) then cb.frameDidChange(lTabControl);
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TCocoaWSCustomListView }
|
{ TCocoaWSCustomListView }
|
||||||
|
Loading…
Reference in New Issue
Block a user