packagetabs: autosize label and button sizes - use real AutoSize and Anchors

git-svn-id: trunk@63971 -
This commit is contained in:
ondrej 2020-10-08 09:11:34 +00:00
parent 31a695dc02
commit 7505ba38d1

View File

@ -462,8 +462,8 @@ end;
procedure TPackageTabScrollBox.DoAlignControls; procedure TPackageTabScrollBox.DoAlignControls;
var var
xNextY, I, xWidth, xHeight: Integer; I: Integer;
xControl: TControl; xControl, xPrevControl: TControl;
xClientRect: TRect; xClientRect: TRect;
xBS: TControlBorderSpacing; xBS: TControlBorderSpacing;
begin begin
@ -471,22 +471,23 @@ begin
AdjustClientRect(xClientRect); AdjustClientRect(xClientRect);
DisableAlign; DisableAlign;
try try
xNextY := 0; xPrevControl := nil;
for I := 0 to ControlCount-1 do for I := 0 to ControlCount-1 do
begin begin
xControl := Controls[I]; xControl := Controls[I];
xControl.Anchors := [akLeft, akRight, akTop]; xControl.Anchors := [akLeft, akRight, akTop];
xWidth := 0; if Assigned(xPrevControl) then
xHeight := 0; begin
xControl.GetPreferredSize(xWidth, xHeight); xControl.AnchorSide[akTop].Control := xPrevControl;
xControl.Height := xHeight; xControl.AnchorSide[akTop].Side := asrBottom;
end;
xBS := xControl.BorderSpacing; xBS := xControl.BorderSpacing;
xControl.SetBounds( xControl.SetBounds(
xBS.Left+xBS.Around, xNextY+xBS.Top+xBS.Around, xBS.Left+xBS.Around, 0,
xClientRect.Right-xClientRect.Left-xBS.Left-xBS.Right-xBS.Around*2, xClientRect.Right-xClientRect.Left-xBS.Left-xBS.Right-xBS.Around*2,
xBS.ControlHeight); xBS.ControlHeight);
Inc(xNextY, xHeight); xPrevControl := xControl;
end; end;
finally finally
EnableAlign; EnableAlign;
@ -513,6 +514,7 @@ begin
WithThemeSpace); WithThemeSpace);
PreferredHeight := PreferredHeight + 4; PreferredHeight := PreferredHeight + 4;
PreferredWidth := PreferredWidth + 8;
end; end;
{ TGroupTabLabel } { TGroupTabLabel }
@ -535,6 +537,7 @@ begin
WithThemeSpace); WithThemeSpace);
PreferredHeight := PreferredHeight + 8; PreferredHeight := PreferredHeight + 8;
PreferredWidth := PreferredWidth + 8;
end; end;
procedure TGroupTabLabel.MouseDown(Button: TMouseButton; Shift: TShiftState; procedure TGroupTabLabel.MouseDown(Button: TMouseButton; Shift: TShiftState;
@ -918,7 +921,6 @@ begin
xLbl.Caption := xPkgItem.Title; xLbl.Caption := xPkgItem.Title;
xLbl.Parent := FPanel; xLbl.Parent := FPanel;
xLbl.PopupMenu := FTabLabelMenu; xLbl.PopupMenu := FTabLabelMenu;
xLbl.AutoSize := False;
xLbl.OnCloseAllFiles := @CloseAllFiles; xLbl.OnCloseAllFiles := @CloseAllFiles;
if FPanel is TPackageTabScrollBox then if FPanel is TPackageTabScrollBox then
begin begin
@ -941,7 +943,6 @@ begin
xEditor.UpdateProjectFile; // updates FNewEditorInfo.PageIndex xEditor.UpdateProjectFile; // updates FNewEditorInfo.PageIndex
Inc(xNewIndex); Inc(xNewIndex);
xBtn := TPackageTabButton.Create(Self); xBtn := TPackageTabButton.Create(Self);
xBtn.AutoSize := False;
xBtn.Caption := xEditor.PageCaption; xBtn.Caption := xEditor.PageCaption;
xBtn.Hint := xEditor.FileName; xBtn.Hint := xEditor.FileName;
xBtn.ShowHint := True; xBtn.ShowHint := True;