UPD: hint in TFileViewHeader improved

This commit is contained in:
rich2014 2023-08-05 21:47:59 +08:00
commit 421417a09b

View file

@ -32,6 +32,8 @@ type
procedure PathLabelMouseWheelUp(Sender: TObject;Shift: TShiftState; MousePos: TPoint;var Handled:Boolean);
procedure PathLabelMouseWheelDown(Sender: TObject;Shift: TShiftState; MousePos: TPoint;var Handled:Boolean);
procedure HeaderShowHint(Sender: TObject; HintInfo: PHintInfo);
procedure EachViewUpdateHeader(AFileView: TFileView; {%H-}UserData: Pointer);
protected
@ -286,22 +288,24 @@ begin
FPathEdit.ObjectTypes:= [otFolders, otHidden];
OnResize:= @HeaderResize;
OnShowHint:=@HeaderShowHint;
FPathEdit.OnExit:= @PathEditExit;
FPathEdit.onKeyESCAPE:=@onKeyESCAPE;
FPathEdit.onKeyRETURN:=@onKeyRETURN;
FPathEdit.OnShowHint:=@HeaderShowHint;
FPathLabel.OnClick := @PathLabelClick;
FPathLabel.OnDblClick := @PathLabelDblClick;
FPathLabel.OnMouseUp := @PathLabelMouseUp;
FPathLabel.OnMouseWheelDown := @PathLabelMouseWheelDown;
FPathLabel.OnMouseWheelUp := @PathLabelMouseWheelUp;
FPathLabel.OnShowHint:=@HeaderShowHint;
FAddressLabel.OnClick := @AddressLabelClick;
FAddressLabel.OnMouseEnter:= @AddressLabelMouseEnter;
FAddressLabel.OnShowHint:=@HeaderShowHint;
tmViewHistoryMenu := TTimer.Create(Self); //Timer used to show history after a while in case it was not a double click to show Hot dir
tmViewHistoryMenu.Enabled := False;
tmViewHistoryMenu.Interval := 250;
@ -316,6 +320,20 @@ begin
UpdatePathLabel;
end;
// 1. in most cases, as not to bother users,
// the Header does not need to show hint,
// 2. so set hint to the full path, only when the path in PathLabel is shortened
// due to insufficient width
procedure TFileViewHeader.HeaderShowHint(Sender: TObject; HintInfo: PHintInfo);
begin
HintInfo^.HintStr := '';
if FFileView.CurrentAddress<>'' then
exit;
if IncludeTrailingPathDelimiter(FPathLabel.Caption) <> FFileView.CurrentPath then
HintInfo^.HintStr := FFileView.CurrentPath;
end;
procedure TFileViewHeader.UpdateAddressLabel;
begin
if FFileView.CurrentAddress = '' then
@ -333,7 +351,6 @@ end;
procedure TFileViewHeader.UpdatePathLabel;
begin
FPathLabel.Caption := MinimizeFilePath(FFileView.CurrentPath, FPathLabel.Canvas, FPathLabel.Width);
FPathLabel.Hint := FFileView.CurrentPath;
end;
procedure TFileViewHeader.UpdateFont;