Accounting for the ScrollView scrollbar

shenjoku

17-10-2011 21:20:14

I'm having some issues trying to fit things inside of a ScrollView widget without them being covered by the vertical scroll bar when it becomes visible. I'm manualy calculating the height of the canvas with the width filling the entire scroll view. The only option I can think of is to recalculate the size AGAIN after setting the new height based on if the scrollbar is visible or not. Is this really how it's meant to be used? This seems like something that should be automatic in the ScrollView class already.

marj

17-11-2011 10:09:52

yeah, i'm also getting that same problem, never got to solve it, tsk tsk :oops: need help pleaseeeeee

shenjoku

19-11-2011 22:59:13

yeah, i'm also getting that same problem, never got to solve it, tsk tsk :oops: need help pleaseeeeee

This is how I solved it. It's pretty dirty but it's the only thing I could get working.:


void mAccountForScrollBar(MyGUI::ScrollViewPtr scrollView)
{
MyGUI::IntSize canvasSize = scrollView->getCanvasSize();

// If the height of the canvas is smaller then the height of the child widgets then the scroll bar must be visible.
if (canvasSize.height > scrollView->getHeight())
{
// Hard coded constant for the width of the scroll bar since, as far as I can tell, there is no possible way to query the widget directly for its width.
static const int32_t kScrollBarOffset = 16;

scrollView->setCanvasSize(canvasSize.width - kScrollBarOffset, canvasSize.height);
}
}