Hi,
I am implementing a small file browser in my plugin for ease of use, instead of using the native one, so I can implement some slick file-previewing.
So I started trying to implement my own FileBrowserComponent.
However I’m finding it quite hard to have full control over the look and feel of it.
If I understand correctly, inside FileBrowserComponent, there is a ViewPort which scrolls through all the files in the current directory, I set the size of this viewport in layoutFileBrowserComponent, with the pointer to juce::DirectoryContentsDisplayComponent*
However I cannot find the interface for changing the background colour of the Viewport?
Not sure why all the interfaces are not exposed in LookAndFeel_V4. Are there any other LookAndFeel methods I need to look out for?
I think what you might be looking for is ListBox::ColourIds::backgroundColourId. However, the only obvious way I could see to set this is by calling setColour() on your LookAndFeel, so this colour might have to apply to all ListBox backgrounds. The actual filling of the background doesn’t appear to be done in the LookAndFeel in this instance so I don’t think there’s anything you can override.
ahh there you go, thank you.
I was searching for a long time in various other classes.
Namely, FileBrowserComponent, FileListComponent, DirectoryContentListComponent and all of those
.
Cheers
Yeah I’m not going to lie it took me a moment too. I would love to make some improvements to it but I don’t think that would make it to the top of the pile of things to do right now. Hopefully that’s enough to keep you going for now though.
I’m also having a hard time finding the interface for setting the scroll bar width.
Any ideas on this?
Cheers
The easiest method might be overriding getDefaultScrollbarWidth() in the LookAndFeel. Does that help?
Thats good thanks :), and I’ll experiment,
but it seems strange that this function is isolated like this.
Presumably one would want to scale the scroll bar in proportion to the plugin, to enable resizing. But I don’t seem to have access to any greater context.
I don’t see a solution around this, other than a convoluted system to store the current size of the plugin in my LookAndFeel class.
Edit: I have found the interface, in layoutFileBrowserComponent():
if (auto* list = dynamic_cast<juce::FileListComponent*> (dc)) {
list->setBounds (b);
list->setRowHeight(rowheight);
list->getViewport()->setScrollBarThickness(<#int thickness#>)
}
Hope this helps someone.
1 Like