feat(ui): add hover overlay scroll for left panel

This commit is contained in:
2026-08-05 13:44:12 +03:00
parent 94bb15bbaf
commit b7b9119339
3 changed files with 391 additions and 19 deletions
+11 -4
View File
@@ -18,7 +18,7 @@ unit FlatDropDown;
interface
uses
Classes, SysUtils, Controls, Graphics, ExtCtrls, FlatButton;
Classes, SysUtils, Controls, Graphics, ExtCtrls, Math, FlatButton;
type
TButtonStyleProc = procedure(B: TFlatButton; Active: Boolean) of object;
@@ -33,13 +33,14 @@ type
FItemIndex: Integer;
FColumns: Integer;
FItemBtnH: Integer;
FRightInset96: Integer;
FIsOpen: Boolean;
FOnSelect: TDropDownSelectEvent;
procedure ItemClick(Sender: TObject);
procedure PositionPopup;
public
constructor Create(AAnchor: TFlatButton; APopupParent: TWinControl;
ACols, ABtnH: Integer);
ACols, ABtnH: Integer; ARightInset96: Integer = 0);
destructor Destroy; override;
procedure SetItems(const ANames: array of string);
procedure SetItemIndex(Idx: Integer);
@@ -54,13 +55,15 @@ type
implementation
constructor TFlatDropDown.Create(AAnchor: TFlatButton; APopupParent: TWinControl;
ACols, ABtnH: Integer);
ACols, ABtnH: Integer;
ARightInset96: Integer = 0);
begin
inherited Create;
FAnchor := AAnchor;
FPopupParent := APopupParent;
FColumns := ACols;
FItemBtnH := ABtnH;
FRightInset96 := Max(0, ARightInset96);
FItemIndex := 0;
FIsOpen := False;
FPopup := TPanel.Create(nil);
@@ -85,7 +88,11 @@ begin
FPopup.Controls[0].Free;
Count := Length(ANames);
SetLength(FItemBtns, Count);
PopW := FPopupParent.ClientWidth;
// Popup может жить в контейнере с постоянно зарезервированным overlay-
// scrollbar gutter. Inset задаётся в 96-DPI координатах и пересчитывается
// при каждом наполнении: SetItems бывает и до, и после DPI-scale формы.
PopW := Max(1, FPopupParent.ClientWidth -
FPopupParent.Scale96ToForm(FRightInset96));
BtnW := (PopW - 4) div FColumns;
FPopup.SetBounds(0, 0, PopW,
((Count + FColumns - 1) div FColumns) * FItemBtnH);