LCL: Fix Toolbar size when inside a Controlbar. Merge request !77 by Alexander Litjagin.

This commit is contained in:
Juha 2022-02-25 11:58:48 +02:00
parent 3e37e19bbe
commit 78f789c59b
3 changed files with 24 additions and 7 deletions

View File

@ -133,8 +133,13 @@ begin
end;
function TCustomControlBar.CalcBandHeightSnapped(AControl: TControl): Integer;
var
rowsz : integer;
rows : integer;
begin
Result := (1 + trunc((AControl.Height + 2 * cBandBorderV) div RowSize)) * RowSize;
rowsz := RowSize;
rows := (AControl.Height - (2 * cBandBorderV) + (rowsz-1)) div rowsz;
Result := rows * rowsz;
end;
function TCustomControlBar.CalcInnerBevelWidth: Integer;
@ -485,7 +490,7 @@ begin
for i := 0 to ControlCount - 1 do begin
aBand := TCtrlBand.Create;
aBand.Control := Controls[i];
aBand.Height := CalcBandHeight(Controls[i]);
aBand.Height := CalcBandHeight(aBand.Control);
aBand.Width := cFullGrabber + Controls[i].Width + cBandBorderH;
aBand.Top := Controls[i].Top - (aBand.Height - Controls[i].Height) div 2;
aBand.Left := Controls[i].Left - aIndent;

View File

@ -599,6 +599,7 @@ end;
procedure TToolBar.DoAutoSize;
begin
// children are moved in ControlsAligned independent of AutoSize=true
inherited DoAutoSize; // needed for autosizing toolbar in controlbar bands
end;
function TToolBar.DropDownWidthIsStored: Boolean;

View File

@ -874,14 +874,25 @@ begin
inherited GetPreferredSize(PreferredWidth, PreferredHeight, Raw, WithThemeSpace);
if FToolbar = nil then Exit;
RealButtonWidth := FToolbar.ButtonWidth;
RealButtonHeight := FToolbar.ButtonHeight;
if RealButtonHeight <= 0 then Exit;
// buttonheight overrules in hor toolbar
if FToolBar.IsVertical then
PreferredWidth := RealButtonWidth
else
PreferredHeight := RealButtonHeight;
if (AutoSize) then begin
// why FToolbar overrides prefered size?
if FToolBar.IsVertical then
PreferredWidth := max( PreferredWidth, RealButtonWidth )
else
PreferredHeight := max( PreferredHeight, RealButtonHeight );
end
else begin
if FToolBar.IsVertical then
PreferredWidth := RealButtonWidth
else
PreferredHeight:= RealButtonHeight;
end;
end;
function TToolButton.IsWidthStored: Boolean;