Skip to content

Commit

Permalink
TNewTabSet: Scale padding, too.
Browse files Browse the repository at this point in the history
  • Loading branch information
jordanrussell authored Nov 22, 2024
1 parent 67a6624 commit 880b9ee
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions Components/NewTabSet.pas
Original file line number Diff line number Diff line change
Expand Up @@ -295,10 +295,10 @@ function TNewTabSet.GetTabRect(const Index: Integer;
Dec(Result.Right, FTabsOffset);
for I := 0 to FTabs.Count-1 do begin
Size := Canvas.TextExtent(FTabs[I]);
SizeX := Size.cx + (TabPaddingX * 2);
SizeX := Size.cx + (ToCurrentPPI(TabPaddingX) * 2);
if (I < FCloseButtons.Count) and FCloseButtons[I] then
Inc(SizeX, MulDiv(CloseButtonSizeX, CurrentPPI, 96));
SizeY := Size.cy + (TabPaddingY * 2);
Inc(SizeX, ToCurrentPPI(CloseButtonSizeX));
SizeY := Size.cy + (ToCurrentPPI(TabPaddingY) * 2);
if FTabPosition = tpTop then
Result.Top := CR.Bottom - SizeY;
Result := Bounds(Result.Right, Result.Top, SizeX, SizeY);
Expand All @@ -310,8 +310,8 @@ function TNewTabSet.GetTabRect(const Index: Integer;

function TNewTabSet.GetCloseButtonRect(const TabRect: TRect): TRect;
begin
Result := TRect.Create(TabRect.Right - MulDiv(CloseButtonSizeX, CurrentPPI, 96) - TabPaddingX div 2,
TabRect.Top, TabRect.Right - TabPaddingX div 2, TabRect.Bottom);
Result := TRect.Create(TabRect.Right - ToCurrentPPI(CloseButtonSizeX) - ToCurrentPPI(TabPaddingX) div 2,
TabRect.Top, TabRect.Right - ToCurrentPPI(TabPaddingX) div 2, TabRect.Bottom);
end;

procedure TNewTabSet.InvalidateTab(Index: Integer);
Expand Down Expand Up @@ -397,12 +397,12 @@ procedure TNewTabSet.Paint;
if (TabIndex < FCloseButtons.Count) and FCloseButtons[TabIndex] then begin
var R := GetCloseButtonRect(TabRect);
if FMenuThemeData <> 0 then begin
var Offset := MulDiv(1, CurrentPPI, 96);
var Offset := ToCurrentPPI(1);
Inc(R.Left, Offset);
Inc(R.Top, Offset);
DrawThemeBackground(FMenuThemeData, Canvas.Handle, MENU_SYSTEMCLOSE, MSYSC_NORMAL, R, nil);
end else begin
InflateRect(R, -MulDiv(3, CurrentPPI, 96), -MulDiv(6, CurrentPPI, 96));
InflateRect(R, -ToCurrentPPI(3), -ToCurrentPPI(6));
Canvas.Pen.Color := Canvas.Font.Color;
Canvas.MoveTo(R.Left, R.Top);
Canvas.LineTo(R.Right, R.Bottom);
Expand Down Expand Up @@ -430,7 +430,7 @@ procedure TNewTabSet.Paint;
Canvas.Font.Color := FTheme.Colors[tcFore]
else
Canvas.Font.Color := clBtnText;
Canvas.TextOut(R.Left + TabPaddingX, R.Top + TabPaddingY, FTabs[I]);
Canvas.TextOut(R.Left + ToCurrentPPI(TabPaddingX), R.Top + ToCurrentPPI(TabPaddingY), FTabs[I]);
DrawCloseButton(R, I);
ExcludeClipRect(Canvas.Handle, R.Left, R.Top, R.Right, R.Bottom);
Break;
Expand All @@ -450,7 +450,7 @@ procedure TNewTabSet.Paint;
use plain clBtnHighlight as the text color }
Canvas.Font.Color := clBtnHighlight;
end;
Canvas.TextOut(R.Left + TabPaddingX, R.Top + TabPaddingY, FTabs[I]);
Canvas.TextOut(R.Left + ToCurrentPPI(TabPaddingX), R.Top + ToCurrentPPI(TabPaddingY), FTabs[I]);
if FHotIndex = I then
DrawCloseButton(R, I);
end;
Expand Down

0 comments on commit 880b9ee

Please sign in to comment.