UPD: simplify OnDrawCell related base on TFileSourceUIParams

This commit is contained in:
rich2014 2025-12-29 20:00:45 +08:00
commit 52a699fbd7
5 changed files with 13 additions and 15 deletions

View file

@ -71,7 +71,7 @@ type
TFileSourceUIHandler = class
procedure draw( var params: TFileSourceUIParams ); virtual; abstract;
function click( var params: TFileSourceUIParams ): Boolean; virtual; abstract;
function click( var params: TFileSourceUIParams ): Boolean; virtual; abstract;
end;
TFileSourceField = record

View file

@ -548,7 +548,7 @@ var
procedure callOnDrawCell;
begin
if Assigned(OnDrawCell) and not(CsDesigning in ComponentState) then
OnDrawCell(FBriefView,aCol,aRow,params.drawingRect,params.focused,AFile);
OnDrawCell( params );
end;
//------------------------------------------------------
@ -606,7 +606,7 @@ begin
quickSearch.LimitedAutoHide := True;
{$IFDEF DARWIN}
TBriefDrawGrid(dgPanel).OnDrawCell:= @darwinFileViewDrawHandler.OnDrawCell;
TBriefDrawGrid(dgPanel).OnDrawCell:= @darwinFileViewDrawHandler.onDrawCell;
{$ENDIF}
end;

View file

@ -932,7 +932,7 @@ begin
dgpanel.OnResize:= @dgPanelResize;
dgPanel.OnHeaderSized:= @dgPanelHeaderSized;
{$IFDEF DARWIN}
dgPanel.OnDrawCell:= @darwinFileViewDrawHandler.OnDrawCell;
dgPanel.OnDrawCell:= @darwinFileViewDrawHandler.onDrawCell;
{$ENDIF}
pmColumnsMenu := TPopupMenu.Create(Self);
@ -1957,7 +1957,7 @@ var
procedure callOnDrawCell;
begin
if Assigned(OnDrawCell) and not(CsDesigning in ComponentState) then
OnDrawCell(Self.ColumnsView,aCol,aRow,params.drawingRect,params.focused,AFile);
OnDrawCell( params );
end;
//------------------------------------------------------

View file

@ -33,6 +33,7 @@ uses
uFile, uDisplayFile,
uFileViewWorker,
uOrderedFileView,
uFileSource,
uFileView,
uDragDropEx,
uFileViewNotebook,
@ -40,8 +41,7 @@ uses
type
TFileViewOnDrawCell = procedure(Sender: TFileView; aCol, aRow: Integer;
aRect: TRect; focused: Boolean; aFile: TDisplayFile) of object;
TFileViewOnDrawCell = procedure( var params: TFileSourceUIParams ) of object;
TRenameFileActionType=(rfatName,rfatExt,rfatFull,rfatToSeparators,rfatNextSeparated);
@ -239,7 +239,7 @@ uses
GTK2Globals, // for DblClickTime
{$ENDIF}
LCLIntf, LCLProc, LazUTF8, Forms, Dialogs, Buttons, DCOSUtils, DCStrUtils,
fMain, uShowMsg, uLng, uFileProperty, uFileSource, uFileSourceOperationTypes,
fMain, uShowMsg, uLng, uFileProperty, uFileSourceOperationTypes,
uGlobs, uInfoToolTip, uFileSystemFileSource, uFileSourceUtil,
uArchiveFileSourceUtil, uFormCommands, uKeyboard, uFileSourceSetFilePropertyOperation,
uFileSystemWatcher;

View file

@ -38,8 +38,7 @@ type
end;
TDarwinFileViewDrawHandler = class
procedure onDrawCell(Sender: TFileView; aCol, aRow: Integer;
aRect: TRect; focused: Boolean; aFile: TDisplayFile);
procedure onDrawCell( var params: TFileSourceUIParams );
procedure drawTagsAsDecoration(
const colors: TFileFinderTagPrimaryColors; const drawRect: TRect; const focused: Boolean );
end;
@ -85,19 +84,18 @@ end;
{ TDarwinFileViewDrawHandler }
procedure TDarwinFileViewDrawHandler.onDrawCell(Sender: TFileView; aCol, aRow: Integer;
aRect: TRect; focused: Boolean; aFile: TDisplayFile);
procedure TDarwinFileViewDrawHandler.onDrawCell( var params: TFileSourceUIParams );
var
macOSProperty: TFileMacOSSpecificProperty;
begin
if (Sender.ClassName = 'TColumnsFileView') and (aCol<>0) then
if params.multiColumns AND (params.col<>0) then
Exit;
macOSProperty:= aFile.FSFile.MacOSSpecificProperty;
macOSProperty:= params.displayFile.FSFile.MacOSSpecificProperty;
if macOSProperty = nil then
Exit;
drawTagsAsDecoration( macOSProperty.FinderTagPrimaryColors, aRect, focused );
drawTagsAsDecoration( macOSProperty.FinderTagPrimaryColors, params.drawingRect, params.focused );
end;
procedure TDarwinFileViewDrawHandler.drawTagsAsDecoration(