ADD: draw Finder Tags as Decorative Icons in BriefView mode

This commit is contained in:
rich2014 2024-10-13 21:18:43 +08:00
commit 82eb373ee7
6 changed files with 60 additions and 12 deletions

View file

@ -6,8 +6,9 @@ interface
uses
Classes, SysUtils, Controls, LMessages, Grids, Graphics,
uDisplayFile, DCXmlConfig, uTypes, uFileViewWithGrid, uFile,
uFileSource, uFileProperty;
uDisplayFile, DCXmlConfig, uTypes,
uFileView, uFileViewWithMainCtrl, uFileViewWithGrid,
uFile, uFileSource, uFileProperty;
type
@ -18,6 +19,7 @@ type
TBriefDrawGrid = class(TFileViewGrid)
protected
FBriefView: TBriefFileView;
FOnDrawCell: TFileViewOnDrawCell;
protected
procedure UpdateView; override;
procedure CalculateColRowCount; override;
@ -34,11 +36,16 @@ type
function CellToIndex(ACol, ARow: Integer): Integer; override;
procedure IndexToCell(Index: Integer; out ACol, ARow: Integer); override;
procedure DrawCell(aCol, aRow: Integer; aRect: TRect; aState: TGridDrawState); override;
property OnDrawCell: TFileViewOnDrawCell read FOnDrawCell write FOnDrawCell;
end;
{ TBriefFileView }
TBriefFileView = class (TFileViewWithGrid)
protected
function GetOnDrawCell: TFileViewOnDrawCell;
procedure SetOnDrawCell( OnDrawCell: TFileViewOnDrawCell );
protected
procedure CreateDefault(AOwner: TWinControl); override;
function GetFileViewGridClass: TFileViewGridClass; override;
@ -51,7 +58,9 @@ type
procedure DoFileUpdated(AFile: TDisplayFile; UpdatedProperties: TFilePropertiesTypes = []); override;
public
function Clone(NewParent: TWinControl): TBriefFileView; override;
procedure CloneTo(FileView: TFileView); override;
procedure SaveConfiguration(AConfig: TXmlConfig; ANode: TXmlNode; ASaveHistory:boolean); override;
property OnDrawCell: TFileViewOnDrawCell read GetOnDrawCell write SetOnDrawCell;
end;
implementation
@ -507,6 +516,10 @@ begin
iTextTop := aRect.Top + (RowHeights[aRow] - Canvas.TextHeight('Wg')) div 2;
DrawIconCell;
if Assigned(OnDrawCell) and not(CsDesigning in ComponentState) then begin
OnDrawCell(FBriefView,aCol,aRow,aRect,aState,AFile);
end;
end
else
begin
@ -521,6 +534,16 @@ end;
{ TBriefFileView }
function TBriefFileView.GetOnDrawCell: TFileViewOnDrawCell;
begin
Result:= TBriefDrawGrid(dgPanel).OnDrawCell;
end;
procedure TBriefFileView.SetOnDrawCell(OnDrawCell: TFileViewOnDrawCell);
begin
TBriefDrawGrid(dgPanel).OnDrawCell:= OnDrawCell;
end;
procedure TBriefFileView.CreateDefault(AOwner: TWinControl);
begin
inherited CreateDefault(AOwner);
@ -630,6 +653,13 @@ begin
Result := TBriefFileView.Create(NewParent, Self);
end;
procedure TBriefFileView.CloneTo(FileView: TFileView);
begin
inherited CloneTo(FileView);
if FileView is TBriefFileView then
TBriefFileView(FileView).OnDrawCell:= self.OnDrawCell;
end;
procedure TBriefFileView.SaveConfiguration(AConfig: TXmlConfig; ANode: TXmlNode; ASaveHistory:boolean);
begin
inherited SaveConfiguration(AConfig, ANode, ASaveHistory);

View file

@ -26,9 +26,6 @@ type
TColumnsSortDirections = array of TSortDirection;
TColumnsFileView = class;
TFileViewOnDrawCell = procedure(Sender: TFileView; aCol, aRow: Integer;
aRect: TRect; aState: TGridDrawState; aFile: TDisplayFile) of object;
{ TDrawGridEx }
TDrawGridEx = class(TDrawGrid)

View file

@ -29,8 +29,8 @@ interface
uses
Classes, SysUtils, Controls, ExtCtrls, StdCtrls, LCLType, LMessages, EditBtn,
Graphics, LCLVersion,
uFile,
Grids, Graphics, LCLVersion,
uFile, uDisplayFile,
uFileViewWorker,
uOrderedFileView,
uFileView,
@ -40,6 +40,9 @@ uses
type
TFileViewOnDrawCell = procedure(Sender: TFileView; aCol, aRow: Integer;
aRect: TRect; aState: TGridDrawState; aFile: TDisplayFile) of object;
TRenameFileActionType=(rfatName,rfatExt,rfatFull,rfatToSeparators,rfatNextSeparated);
TRenameFileEditInfo=record
@ -237,7 +240,7 @@ uses
{$ENDIF}
LCLIntf, LCLProc, LazUTF8, Forms, Dialogs, Buttons, DCOSUtils, DCStrUtils,
fMain, uShowMsg, uLng, uFileProperty, uFileSource, uFileSourceOperationTypes,
uGlobs, uInfoToolTip, uDisplayFile, uFileSystemFileSource, uFileSourceUtil,
uGlobs, uInfoToolTip, uFileSystemFileSource, uFileSourceUtil,
uArchiveFileSourceUtil, uFormCommands, uKeyboard, uFileSourceSetFilePropertyOperation,
uFileSystemWatcher;

View file

@ -5113,9 +5113,12 @@ begin
{$IFDEF DARWIN}
TColumnsFileView(Result).OnDrawCell:= @DarwinFileViewDrawHelper.OnDrawCell;
{$ENDIF}
end else if sType = 'brief' then
Result := TBriefFileView.Create(Page, AConfig, ANode, FileViewFlags)
else if sType = 'thumbnails' then
end else if sType = 'brief' then begin
Result := TBriefFileView.Create(Page, AConfig, ANode, FileViewFlags);
{$IFDEF DARWIN}
TBriefFileView(Result).OnDrawCell:= @DarwinFileViewDrawHelper.OnDrawCell;
{$ENDIF}
end else if sType = 'thumbnails' then
Result := TThumbFileView.Create(Page, AConfig, ANode, FileViewFlags)
else begin
DCDebug(rsMsgLogError + 'Invalid file view type "%s"', [sType]);

View file

@ -314,7 +314,7 @@ var
url: NSURL;
tagNames: NSArray;
begin
if aCol <> 0 then
if (Sender is TColumnsFileView) and (aCol<>0) then
Exit;
if NOT (fspDirectAccess in Sender.FileSource.Properties) then

View file

@ -2222,6 +2222,9 @@ begin
with frmMain do
begin
aFileView:= TBriefFileView.Create(ActiveNotebook.ActivePage, ActiveFrame);
{$IFDEF DARWIN}
TBriefFileView(aFileView).OnDrawCell:= @DarwinFileViewDrawHelper.OnDrawCell;
{$ENDIF}
ActiveNotebook.ActivePage.FileView:= aFileView;
ActiveFrame.SetFocus;
end;
@ -2234,6 +2237,9 @@ begin
with frmMain do
begin
aFileView:= TBriefFileView.Create(LeftTabs.ActivePage, FrameLeft);
{$IFDEF DARWIN}
TBriefFileView(aFileView).OnDrawCell:= @DarwinFileViewDrawHelper.OnDrawCell;
{$ENDIF}
LeftTabs.ActivePage.FileView:= aFileView;
end;
end;
@ -2245,6 +2251,9 @@ begin
with frmMain do
begin
aFileView:= TBriefFileView.Create(RightTabs.ActivePage, FrameRight);
{$IFDEF DARWIN}
TBriefFileView(aFileView).OnDrawCell:= @DarwinFileViewDrawHelper.OnDrawCell;
{$ENDIF}
RightTabs.ActivePage.FileView:= aFileView;
end;
end;
@ -2282,6 +2291,9 @@ begin
TColumnsFileView(FrameLeft).SetColumnSet(AParam)
else begin
aFileView:= TColumnsFileView.Create(LeftTabs.ActivePage, FrameLeft, AParam);
{$IFDEF DARWIN}
TColumnsFileView(aFileView).OnDrawCell:= @DarwinFileViewDrawHelper.OnDrawCell;
{$ENDIF}
LeftTabs.ActivePage.FileView:= aFileView;
end;
end;
@ -2299,6 +2311,9 @@ begin
TColumnsFileView(FrameRight).SetColumnSet(AParam)
else begin
aFileView:= TColumnsFileView.Create(RightTabs.ActivePage, FrameRight, AParam);
{$IFDEF DARWIN}
TColumnsFileView(aFileView).OnDrawCell:= @DarwinFileViewDrawHelper.OnDrawCell;
{$ENDIF}
RightTabs.ActivePage.FileView:= aFileView;
end;
end;