TableListBox scrollbars


#1

I have a TableListBox where I tried to use table->getHeader()->setStretchToFitActive (true).

That works fine until the vertical scrollbar is not displayed, but when the vertical scrollbar eats up some place, the listbox automatically displays the horizontal scrollbar too. That’s not necessary (and in fact quite ugly). The column resize code should be called instead, this time with the vertical scrollbar taken into the calculation.

For a single column I tried to write a workaround in the component resize code:

if (table->getVerticalScrollBar()->isVisible())
{
	table->getHeader()->setColumnWidth(col, getWidth() - this->getLookAndFeel().getDefaultScrollbarWidth());
}
else
{
	table->getHeader()->setColumnWidth(col, getWidth());
}

but it flashes like crazy while I drag the window resize handles (and sometimes it even left the colum with the bad width).

Is there a better workaround or it should be written into the Juce code?


#2

No, it shouldn’t do anything that’s ugly like that, but the way to fix it isn’t to try a hack like that one! I’m a bit busy on other stuff right now but if you can spot anything that looks like it might be causing the problem let me know. Otherwise, I’ll check it out sometime in the future.


#3

I just tested, this bug still exists in 1.41.

When I first posted it I spent some time trying to figure out from where it comes, but without success. Jules try to put it on your TODO list for the next version. Thanks.


#4

I thought I’d fixed that one… Oh well, I’ll take another look.


#5

OK, I finally understood what was going on.

Juce handles correctly the resize, but does not check for a possible apparition of the vertical scrollbar when adding new rows.

My original component refresh code contained only

table->updateContent();

now it looks like

table->updateContent();
table->resized();

#6

Ah, that’s interesting. The updateContent method should certainly do a better job, so how about this change in juce_ListBox.cpp, line 415:

viewport->updateVisibleArea (isVisible()); viewport->resized();


#7