Skip to content

Commit

Permalink
TNewTabSet: Scale top/bottom line.
Browse files Browse the repository at this point in the history
  • Loading branch information
jordanrussell authored Dec 2, 2024
1 parent 37ddb8b commit 3774bc9
Showing 1 changed file with 21 additions and 13 deletions.
34 changes: 21 additions & 13 deletions Components/NewTabSet.pas
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,17 @@ TNewTabSet = class(TCustomControl)
procedure SetHints(const Value: TStrings);
function ToCurrentPPI(const XY: Integer): Integer;
procedure UpdateThemeData(const Open: Boolean);
protected
procedure CMFontChanged(var Message: TMessage); message CM_FONTCHANGED;
procedure CMHintShow(var Message: TCMHintShow); message CM_HINTSHOW;
procedure CMMouseLeave(var Message: TMessage); message CM_MOUSELEAVE;
procedure WMMouseMove(var Message: TWMMouseMove); message WM_MOUSEMOVE;
procedure WMThemeChanged(var Message: TMessage); message WM_THEMECHANGED;
protected
function CanAutoSize(var NewWidth, NewHeight: Integer): Boolean; override;
procedure CreateParams(var Params: TCreateParams); override;
procedure CreateWnd; override;
procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
procedure UpdateHotIndex(NewHotIndex: Integer);
procedure CMMouseLeave(var Message: TMessage); message CM_MOUSELEAVE;
procedure Paint; override;
procedure Resize; override;
public
Expand Down Expand Up @@ -209,6 +210,13 @@ destructor TNewTabSet.Destroy;
inherited;
end;

procedure TNewTabSet.CMFontChanged(var Message: TMessage);
begin
inherited;
if AutoSize then
AdjustSize;
end;

procedure TNewTabSet.CMHintShow(var Message: TCMHintShow);
var
I: Integer;
Expand Down Expand Up @@ -491,16 +499,16 @@ procedure TNewTabSet.Paint;

{ Top or bottom line }
if FTheme <> nil then
Canvas.Pen.Color := FTheme.Colors[tcBack]
Canvas.Brush.Color := FTheme.Colors[tcBack]
else
Canvas.Pen.Color := clBtnFace;
if FTabPosition = tpBottom then begin
Canvas.MoveTo(0, 0);
Canvas.LineTo(CR.Right, 0);
end else begin
Canvas.MoveTo(0, CR.Bottom-1);
Canvas.LineTo(CR.Right, CR.Bottom-1);
end;
Canvas.Brush.Color := clBtnFace;
const LineRectHeight = ToCurrentPPI(1);
var LineRect := CR;
if FTabPosition = tpBottom then
LineRect.Bottom := LineRect.Top + LineRectHeight
else
LineRect.Top := LineRect.Bottom - LineRectHeight;
Canvas.FillRect(LineRect);

{ Background fill }
if FTheme <> nil then
Expand All @@ -510,9 +518,9 @@ procedure TNewTabSet.Paint;
else
Canvas.Brush.Color := clBtnShadow;
if FTabPosition = tpBottom then
Inc(CR.Top)
Inc(CR.Top, LineRectHeight)
else
Dec(CR.Bottom);
Dec(CR.Bottom, LineRectHeight);
Canvas.FillRect(CR);

{ Non-selected tabs }
Expand Down

0 comments on commit 3774bc9

Please sign in to comment.