mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-23 20:39:39 +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;
|
||||
var
|
||||
r : TRect;
|
||||
f : NSRect;
|
||||
begin
|
||||
if isFlipped then
|
||||
Result:=NSRectToRect( contentRect )
|
||||
case tabViewType of
|
||||
NSNoTabsNoBorder:
|
||||
begin
|
||||
f := frame;
|
||||
f.origin.x := 0;
|
||||
f.origin.y := 0;
|
||||
Result := NSRectToRect( f );
|
||||
end;
|
||||
else
|
||||
NSToLCLRect( contentRect, frame.size.height, Result );
|
||||
if isFlipped then
|
||||
Result:=NSRectToRect( contentRect )
|
||||
else
|
||||
NSToLCLRect( contentRect, frame.size.height, Result );
|
||||
end;
|
||||
|
||||
r:=lclGetFrameToLayoutDelta;
|
||||
Types.OffsetRect(Result, -r.Left, -r.Top);
|
||||
//if tabs are hidden, frame layout should not be taken into account
|
||||
//r:=lclGetFrameToLayoutDelta;
|
||||
//Types.OffsetRect(Result, -r.Left, -r.Top);
|
||||
end;
|
||||
|
||||
function TCocoaTabControl.lclGetFrameToLayoutDelta: TRect;
|
||||
begin
|
||||
Result.Bottom := -10;
|
||||
Result.Top := 6;
|
||||
Result.Left := 7;
|
||||
Result.Right := -7;
|
||||
case tabViewType of
|
||||
NSNoTabsNoBorder: begin
|
||||
Result.Left := 0;
|
||||
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;
|
||||
|
||||
function TCocoaTabControl.tabView_shouldSelectTabViewItem(tabView: NSTabView;
|
||||
|
@ -823,13 +823,36 @@ class procedure TCocoaWSCustomTabControl.ShowTabs(const ATabControl: TCustomTabC
|
||||
var
|
||||
lTabControl: TCocoaTabControl = nil;
|
||||
lOldTabStyle, lTabStyle: NSTabViewType;
|
||||
var
|
||||
pr : TRect;
|
||||
ar : TRect;
|
||||
fr : NSRect;
|
||||
dx, dy : double;
|
||||
cb: ICommonCallback;
|
||||
begin
|
||||
if not Assigned(ATabControl) or not ATabControl.HandleAllocated then Exit;
|
||||
lTabControl := TCocoaTabControl(ATabControl.Handle);
|
||||
|
||||
lOldTabStyle := lTabControl.tabViewType();
|
||||
lTabStyle := LCLTabPosToNSTabStyle(AShowTabs, ATabControl.BorderWidth, ATabControl.TabPosition);
|
||||
pr := lTabControl.lclGetFrameToLayoutDelta;
|
||||
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;
|
||||
|
||||
{ TCocoaWSCustomListView }
|
||||
|
Loading…
Reference in New Issue
Block a user