Because I’m using the FileTreeComponent as a comfortable preset-browser (which reflects the preset-structure on disc), i would like to have the option to hide file-extensions.
All you need is to insert in juce_FileTreeComponent.h
void setShowFileExtension(bool showExtension)
{
if (showFileExtension!=showExtension)
{
showFileExtension=showExtension;
repaint();
}
}
bool getShowFileExtension()
{
return showFileExtension;
}
......
private:
......
bool showFileExtension;
change these three lines in juce_FileTreeComponent.h
//FileListTreeItem::paintItem
void paintItem (Graphics& g, int width, int height)
{
if (file != File::nonexistent)
{
updateIcon (true);
if (icon.isNull())
thread.addTimeSliceClient (this);
}
String filename(owner.getShowFileExtension() ? file.getFileName() : file.getFileNameWithoutExtension()); // New ############
owner.getLookAndFeel().drawFileBrowserRow (g, width, height,
filename, // Changed ###########
&icon, fileSize, modTime,
isDirectory, isSelected(),
indexInContentsList, owner);
}
....
FileTreeComponent::FileTreeComponent (DirectoryContentsList& listToShow)
: DirectoryContentsDisplayComponent (listToShow)
, showFileExtension(true) // New ###############