ListBox/Viewport glitch, latest tip, Juce Demo

In the Juce Demo, switch to the Table Components demo, shrink the window vertically so that only a few rows are visible, scroll to the bottom using the vertical scroll bar, then expand the window vertically so that all rows are visible.

Result: The scrollbar correctly goes into a state where there is no thumb (since the window is big enough to show all the rows) but the list is not scrolled to the beginning. Some rows lie above the top of the Component, invisible.

Thanks - I saw the same thing go wrong a while ago using a treeview, but couldn’t work out what I’d done to trigger it. I’ll get this sorted out today…

Since its probably the same code, can we get these:

  • Always round the Viewport content component’s height to a multiple of the ListBox row height
  • Set the Viewport Scrollbar’s page size to the number of fully visible rows - 1
  • Change the behavior of the vertical scroll wheel in the Viewport to always move by one Scrollbar page up or down regardless of the magnitude of the wheel movement passed to Viewport::mouseWheelMove().

As optional behavior for a ListBox?


What I might do when I get chance is to create some kind of “ValueSnapper” class that can be used to apply custom snapping algorithms to a scrollbar, slider, or other continuous scale. Then you could apply one of those to the sliders in your viewport to get that authentic “windows 3.1” look that you seem so keen on :wink:

Whatever lets me get the functionality I need, is great. If it comes in the form of a more general feature that can be used for an even larger set of purposes, all the better!