UPD: abstract decoration related to ConvertToDecorationRect()

This commit is contained in:
rich2014 2025-12-30 21:38:17 +08:00
commit cfb5e4862c
4 changed files with 23 additions and 13 deletions

View file

@ -382,7 +382,7 @@ procedure TBriefDrawGrid.MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y:
ColRowToOffset(True, True, params.col, params.drawingRect.Left, params.drawingRect.Right );
ColRowToOffset(False, True, params.row, params.drawingRect.Top, params.drawingRect.Bottom );
params.decorationRect:= params.drawingRect;
params.decorationRect:= self.ConvertToDecorationRect( params.drawingRect );
params.displayFile:= FBriefView.FFiles[index];
Result:= handler.click( params );
@ -578,7 +578,7 @@ begin
DrawIconCell;
params.drawingRect:= aRect;
params.decorationRect:= aRect;
params.decorationRect:= self.ConvertToDecorationRect( params.drawingRect );
params.focused:= (gdSelected in aState) and FBriefView.Active;
callFileSourceDrawCell;
callOnDrawCell;

View file

@ -2002,7 +2002,7 @@ begin
end;
params.drawingRect:= aRect;
params.decorationRect:= aRect;
params.decorationRect:= self.ConvertToDecorationRect( params.drawingRect );
params.focused:= (gdSelected in aState) and ColumnsView.Active;
callFileSourceDrawCell;
callOnDrawCell;
@ -2066,7 +2066,7 @@ var
ColRowToOffset(True, True, params.col, params.drawingRect.Left, params.drawingRect.Right );
ColRowToOffset(False, True, params.row, params.drawingRect.Top, params.drawingRect.Bottom );
params.decorationRect:= params.drawingRect;
params.decorationRect:= self.ConvertToDecorationRect( params.drawingRect );
params.displayFile:= ColumnsView.FFiles[index];
handler.click( params );

View file

@ -16,6 +16,7 @@ type
public
function MouseOnGrid(X, Y: LongInt): Boolean;
procedure MouseToCellWithoutOutbound(X, Y: Integer; out ACol, ARow: Longint);
function ConvertToDecorationRect(const drawingRect: TRect): TRect; virtual;
function CellToIndex(ACol, ARow: Integer): Integer; virtual; abstract;
end;
@ -46,5 +47,10 @@ begin
AllowOutboundEvents:= bTemp;
end;
function TFileViewBaseGrid.ConvertToDecorationRect(const drawingRect: TRect ): TRect;
begin
Result:= drawingRect;
end;
end.

View file

@ -79,6 +79,7 @@ type
procedure IndexToCell(Index: Integer; out ACol, ARow: Integer); override;
procedure DrawCell(aCol, aRow: Integer; aRect: TRect; aState: TGridDrawState); override;
function ConvertToDecorationRect(const drawingRect: TRect): TRect; override;
property OnDrawCell: TFileViewOnDrawCell read FOnDrawCell write FOnDrawCell;
end;
@ -271,7 +272,6 @@ procedure TThumbDrawGrid.MouseUp(Button: TMouseButton; Shift: TShiftState; X,
handler: TFileSourceUIHandler;
params: TFileSourceUIParams;
index: Integer;
iTextTop: Integer;
begin
Result:= False;
@ -294,11 +294,7 @@ procedure TThumbDrawGrid.MouseUp(Button: TMouseButton; Shift: TShiftState; X,
ColRowToOffset(True, True, params.col, params.drawingRect.Left, params.drawingRect.Right );
ColRowToOffset(False, True, params.row, params.drawingRect.Top, params.drawingRect.Bottom );
params.decorationRect:= params.drawingRect;
iTextTop:= params.decorationRect.Bottom - self.calcTextHeight;
params.decorationRect.Bottom:= iTextTop - 1;
params.decorationRect.Top:= iTextTop - 24;
params.decorationRect:= self.ConvertToDecorationRect( params.drawingRect );
params.displayFile:= FThumbView.FFiles[index];
Result:= handler.click( params );
@ -545,8 +541,6 @@ var
factor:= self.GetCanvasScaleFactor;
aRect:= params.drawingRect;
iTextTop:= aRect.Bottom - self.calcTextHeight;
params.decorationRect.Bottom:= iTextTop - 1;
params.decorationRect.Top:= iTextTop - 24;
IconID := AFile.Tag;
@ -640,7 +634,7 @@ begin
end else begin
params.drawingRect:= aRect;
end;
params.decorationRect:= params.drawingRect;
params.decorationRect:= self.ConvertToDecorationRect( params.drawingRect );
DrawIconCell;
@ -659,6 +653,16 @@ begin
DrawLines(Idx, aCol, aRow, aRect, aState);
end;
function TThumbDrawGrid.ConvertToDecorationRect(const drawingRect: TRect): TRect;
var
iTextTop: Integer;
begin
iTextTop:= drawingRect.Bottom - self.calcTextHeight;
Result:= drawingRect;
Result.Bottom:= iTextTop - 1;
Result.Top:= iTextTop - 24;
end;
{ TThumbFileView }
procedure TThumbFileView.ThumbnailsRetrieverOnAbort(AStart: Integer;