ViewPort question


#1

I’m trying to scroll a component using a ViewPort, but I’m having trouble with the horizontal scroll bar. Instead of appearing and disappearing as the viewport’s bounds change, it’s never being drawn.

mScrollingPane->setBounds(0,0,100,340)

mViewPort = new Viewport(T("Scroller"));
mViewPort->setViewedComponent(mScrollingPane);
mViewPort->setScrollBarsShown(false,true);
mViewPort->setBounds(0,0,100,360);
addAndMakeVisible(mViewPort);

In debugging, I can see that my scrolling pane gets wider than the Viewport, at which point the horizontal scroll bar should appear. The horizontal scroll bar’s visible flag is set to true. The scroll bar paint() routine is never called, but the UpdateThumbPosition() is called when the ViewPort is resized.

Is there something here I missed? Some assumption about the connection between the Viewport and the ViewedComponent that I’m not setting properly?


#2

…no, it sounds like you’re doing the right thing. Does it work if you enable both scrollbars?


#3

I found the issue. I had mistakenly resized the component that the Viewport was in after creation, thus the Viewport was taller than the parent, and the scroll bars along the bottom were clipped off. Duh!

On the bright side, I’ve learned a lot more about how components are drawn…


#4