FileTreeComponent / TreeView and horizontal scrollbars?

Is it possible to have an horizontal scrollbar for the FileTreeComponent/TreeView?

If not, I guess I will need to use a viewport and a fixed extra size just for that.

Anyway, thanks for any advice.

Cheers, WilliamK

1 Like

Ok, I found a way that works, just hope it is correct. :wink:

I added to my component.

void componentMovedOrResized(Component& component, bool wasMoved, bool wasResized);
Viewport* extraViewPort;

And also added public ComponentListener

Now I create it and add the TreeView to the ViewPort.

extraViewPort = new Viewport("ExtraViewPort");
addAndMakeVisible(extraViewPort);
extraViewPort->setViewedComponent(treeView, true);
treeView->getViewport()->getViewedComponent()->addComponentListener(this);
treeView->getViewport()->setScrollBarsShown(false, false);

treeView is the actual FileTreeComponent / TreeView

Now I add

void componentMovedOrResized(Component& component, bool wasMoved, bool wasResized)
{
	Point<int> xPos = extraViewPort->getViewPosition();
	treeView->setBounds(0, 0, 800, treeView->getViewport()->getViewedComponent()->getHeight());
	extraViewPort->setViewPosition(xPos);
}

Works correctly so far. :wink: The Width is fixed, so I just add around 400 extra pixels for it, which should be enough.

Cheers, WilliamK

The viewport should indeed allow to horizontally display the file texts properly, however the viewport is enlarged just enough to display the icons. You can see the issue clearly in the screenshot. After going few depths into directories the component is unusable.

viewport%20file

int FileListTreeItem::getItemWidth() const override
Is not implemented, that’s the problem.

cf. ticket: