mirror of
https://git.vladimir.cc/vladimir/ewsdr.git
synced 2026-08-25 20:37:33 +00:00
feat(ui): add hover overlay scroll for left panel
This commit is contained in:
+11
-4
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user