mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-04 06:36:37 +02:00
LCL/Toolbar: Fix incorrect high-dpi scaling of toolbuttons due to hard-coded constant margins.
This commit is contained in:
parent
a376c5ea2f
commit
6d123c6ac8
@ -2121,7 +2121,8 @@ type
|
|||||||
cDefSeparatorWidth = 8;
|
cDefSeparatorWidth = 8;
|
||||||
cDefDividerWidth = 5;
|
cDefDividerWidth = 5;
|
||||||
cDefButtonDropDecArrowWidth = 2;
|
cDefButtonDropDecArrowWidth = 2;
|
||||||
cIconTextDist = 5;
|
cHorIconTextDist = 5;
|
||||||
|
cVertIconTextDist = 2;
|
||||||
protected
|
protected
|
||||||
FToolBar: TToolBar;
|
FToolBar: TToolBar;
|
||||||
class procedure WSRegisterClass; override;
|
class procedure WSRegisterClass; override;
|
||||||
|
@ -295,7 +295,7 @@ var
|
|||||||
DropDownButtonRect: TRect;
|
DropDownButtonRect: TRect;
|
||||||
TextSize: TSize;
|
TextSize: TSize;
|
||||||
TextPos: TPoint;
|
TextPos: TPoint;
|
||||||
dist: Integer;
|
dist, marg: Integer;
|
||||||
IconSize: TSize;
|
IconSize: TSize;
|
||||||
IconPos: TPoint;
|
IconPos: TPoint;
|
||||||
ImgList: TCustomImageList;
|
ImgList: TCustomImageList;
|
||||||
@ -373,18 +373,19 @@ begin
|
|||||||
if FToolBar.List then
|
if FToolBar.List then
|
||||||
begin
|
begin
|
||||||
// icon left of text
|
// icon left of text
|
||||||
dist := FToolbar.Scale96ToFont(cIconTextDist);
|
dist := FToolbar.Scale96ToFont(cHorIconTextDist);
|
||||||
IconPos.X:=(MainBtnRect.Left+MainBtnRect.Right-IconSize.cx-TextSize.cx-2) div 2;
|
IconPos.X:=(MainBtnRect.Left+MainBtnRect.Right-IconSize.cx-TextSize.cx-dist) div 2;
|
||||||
IconPos.Y:=(MainBtnRect.Top+MainBtnRect.Bottom-IconSize.cy) div 2;
|
IconPos.Y:=(MainBtnRect.Top+MainBtnRect.Bottom-IconSize.cy) div 2;
|
||||||
TextPos.X:=IconPos.X+IconSize.cx+dist;
|
TextPos.X:=IconPos.X+IconSize.cx+dist;
|
||||||
TextPos.Y:=(MainBtnRect.Top+MainBtnRect.Bottom-TextSize.cy) div 2;
|
TextPos.Y:=(MainBtnRect.Top+MainBtnRect.Bottom-TextSize.cy) div 2;
|
||||||
end else
|
end else
|
||||||
begin
|
begin
|
||||||
// icon above text
|
// icon above text
|
||||||
|
dist := cVertIconTextDist;
|
||||||
IconPos.X:=(MainBtnRect.Left+MainBtnRect.Right-IconSize.cx) div 2;
|
IconPos.X:=(MainBtnRect.Left+MainBtnRect.Right-IconSize.cx) div 2;
|
||||||
IconPos.Y:=(MainBtnRect.Top+MainBtnRect.Bottom-IconSize.cy-TextSize.cy-2) div 2;
|
IconPos.Y:=(MainBtnRect.Top+MainBtnRect.Bottom-IconSize.cy-TextSize.cy-dist) div 2;
|
||||||
TextPos.X:=(MainBtnRect.Left+MainBtnRect.Right-TextSize.cx) div 2;
|
TextPos.X:=(MainBtnRect.Left+MainBtnRect.Right-TextSize.cx) div 2;
|
||||||
TextPos.Y:=IconPos.Y+IconSize.cy+2;
|
TextPos.Y:=IconPos.Y+IconSize.cy+dist;
|
||||||
end;
|
end;
|
||||||
end else
|
end else
|
||||||
begin
|
begin
|
||||||
@ -1151,8 +1152,9 @@ begin
|
|||||||
TextSize := GetTextSize;
|
TextSize := GetTextSize;
|
||||||
end;
|
end;
|
||||||
// add space around text
|
// add space around text
|
||||||
inc(TextSize.cx, 4);
|
dist := FToolbar.Scale96ToFont(4);
|
||||||
inc(TextSize.cy, 4);
|
inc(TextSize.cx, dist);
|
||||||
|
inc(TextSize.cy, dist);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// calculate icon size
|
// calculate icon size
|
||||||
@ -1176,13 +1178,14 @@ begin
|
|||||||
if FToolBar.List then
|
if FToolBar.List then
|
||||||
begin
|
begin
|
||||||
// icon left of text
|
// icon left of text
|
||||||
dist := FToolbar.Scale96ToFont(cIconTextDist);
|
dist := FToolbar.Scale96ToFont(cHorIconTextDist);
|
||||||
TextPos.X := IconPos.X + IconSize.cx + dist;
|
TextPos.X := IconPos.X + IconSize.cx + dist;
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
// icon above text
|
// icon above text
|
||||||
TextPos.Y := IconPos.Y + IconSize.cy + 2;
|
dist := FToolbar.Scale96ToFont(cVertIconTextDist);
|
||||||
|
TextPos.Y := IconPos.Y + IconSize.cy + dist;
|
||||||
end;
|
end;
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user