I need the file when drawing the file-browser row, to provide some extra information.
(Actually its some kind of selection state, but not that one which is done via the mouse)
Any i idea how to get it? If not i would request an extra parameter, just a reference or pointer to the file-object in drawFileBrowserRow().
The file-object already exists when the routine is called, so there is no overhead.
Alternatively it would be okay, if there is some virtual method in FileTreeComponent which could be overridden to draw the file browser row (which has access to the file object)
no, the index, is relative to the parent folder and always begins with 0. The DirectoryContentsDisplayComponent only provides a function to get the current selected file, but i need the File() which is currently repainted, regardless if its selected.
Basically instead the filename-parameter, pass the File reference, this would be also future proof, for whatever file-property somebody needs.
BTW:
I see the LookAndFeel_V4::drawFileBrowserRow uses some tricks (dynamic_cast) to access other values as well, but i can’t think if there is a way to get the current File(), but this maybe a good opportunity to change the implementation so that dynamic_cast isn’t required anymore.
Thank you very much for your effort, but i still have a problem.
The index which is provided is the index of the parents-content-list, and the DirectoryContentList provided by the LookFeelClass is the FileTreeComponent, so i can’t get the nested files from this information.
I need access to that one File() Object which will drawn with this method
void drawFileBrowserRow(Graphics& g, int width, int height,
const String& filename, Image* icon,
const String& fileSizeDescription,
const String& fileTimeDescription,
const bool isDirectory, const bool isItemSelected,
const int itemIndex, DirectoryContentsDisplayComponent& dcc) override
The itemIndex refers to the parent Directory, the DirectoryContentsDisplayComponent refers to the root FileTreeComponent.
So with this information it is impossible to get the current File() Object which will be redrawn.
This is the routine in FileListTreeItem, which calls the method
void paintItem (Graphics& g, int width, int height) override
{
if (file != File())
{
updateIcon (true);
if (icon.isNull())
thread.addTimeSliceClient (this);
}
owner.getLookAndFeel().drawFileBrowserRow (g, width, height,
file.getFileName(),
&icon, fileSize, modTime,
isDirectory, isSelected(),
indexInContentsList, owner);
}
The problem is that the directoryContentsList only refers to the root directory, but in a FileTreeComponent there are sub-contents lists too. (see screenshots above)
The straightforward solution is just add the File() parameter to the LookAndFeel method.
Or alternative the sub-contents list as a parameter.
I’m still hoping that access to the File() Object will be implemented in the LookAndFeel Method.
I think there a lot of use-cases for it, for example somebody wants to show special file-attributes etc.