I fixed this by allowing you to set always on, always off, or as needed for setShowHorzScrollbar and setShowVertScrollbar, which also better matches the function name:
Code: Select all
String ForceVertScrollbar::get(const PropertyReceiver* receiver) const
{
switch (static_cast<const MultiColumnList*>(receiver)->isVertScrollbarAlwaysShown())
{
case MultiColumnList::AlwaysOn:
return String("AlwaysOn");
break;
case MultiColumnList::AlwaysOff:
return String("AlwaysOff");
break;
}
return String("AsRequired");
}
void ForceVertScrollbar::set(PropertyReceiver* receiver, const String& value)
{
MultiColumnList::ScrollbarVisibility mode;
if (value == "AlwaysOn")
{
mode = MultiColumnList::AlwaysOn;
}
else if (value == "AlwaysOff")
{
mode = MultiColumnList::AlwaysOff;
}
else
{
mode = MultiColumnList::AsRequired;
}
static_cast<MultiColumnList*>(receiver)->setShowVertScrollbar(mode);
}
String ForceHorzScrollbar::get(const PropertyReceiver* receiver) const
{
switch (static_cast<const MultiColumnList*>(receiver)->isHorzScrollbarAlwaysShown())
{
case MultiColumnList::AlwaysOn:
return String("AlwaysOn");
break;
case MultiColumnList::AlwaysOff:
return String("AlwaysOff");
break;
}
return String("AsRequired");
}
void ForceHorzScrollbar::set(PropertyReceiver* receiver, const String& value)
{
MultiColumnList::ScrollbarVisibility mode;
if (value == "AlwaysOn")
{
mode = MultiColumnList::AlwaysOn;
}
else if (value == "AlwaysOff")
{
mode = MultiColumnList::AlwaysOff;
}
else
{
mode = MultiColumnList::AsRequired;
}
static_cast<MultiColumnList*>(receiver)->setShowHorzScrollbar(mode);
}
Code: Select all
// KevinJ - fixes a bug with scrollbars showing up even though you set them off
enum ScrollbarVisibility
{
AlwaysOn,
AlwaysOff,
AsRequired,
};
Code: Select all
/*!
\brief
Return whether the vertical scroll bar is always shown.
- AlwaysOn if the scroll bar will always be shown even if it is not required.
- AlwaysOff if the scroll bar will never show up
- AsRequired if the scroll bar will only be shown when it is required.
*/
ScrollbarVisibility isVertScrollbarAlwaysShown(void) const;
/*!
\brief
Return whether the horizontal scroll bar is always shown.
\return
- AlwaysOn if the scroll bar will always be shown even if it is not required.
- AlwaysOff if the scroll bar will never show up
- AsRequired if the scroll bar will only be shown when it is required.
*/
ScrollbarVisibility isHorzScrollbarAlwaysShown(void) const;
Code: Select all
/*!
\brief
Set whether the vertical scroll bar should always be shown, never be shown, or only when needed
\param setting
- AlwaysOn to have the vertical scroll bar shown at all times.
- AlwaysOff to have the vertical scroll bar never show
- AsRequired to have the vertical scroll bar appear only when needed.
\return
Nothing.
*/
void setShowVertScrollbar(ScrollbarVisibility setting);
/*!
\brief
Set whether the horizontal scroll bar should always be shown, never be shown, or only when needed
\param setting
- AlwaysOn to have the horizontal scroll bar shown at all times.
- AlwaysOff to have the horizontal scroll bar never show
- AsRequired to have the horizontal scroll bar appear only when needed.
\return
Nothing.
*/
void setShowHorzScrollbar(ScrollbarVisibility setting);
Code: Select all
// scrollbar settings.
ScrollbarVisibility d_forceVertScroll; //!< Sets scrollbar visibility - always on, always off, or AsRequired
ScrollbarVisibility d_forceHorzScroll; //!< Sets scrollbar visibility - always on, always off, or AsRequired
Code: Select all
d_forceVertScroll(AsRequired),
d_forceHorzScroll(AsRequired),
Code: Select all
/*************************************************************************
Enable / Disable forced display of the vertical scroll bar
*************************************************************************/
void MultiColumnList::setShowVertScrollbar(ScrollbarVisibility setting)
{
if (d_forceVertScroll != setting)
{
d_forceVertScroll = setting;
configureScrollbars();
// Event firing.
WindowEventArgs args(this);
onVertScrollbarModeChanged(args);
}
}
/*************************************************************************
Enable / Disable forced display of the horizontal scroll bar
*************************************************************************/
void MultiColumnList::setShowHorzScrollbar(ScrollbarVisibility setting)
{
if (d_forceHorzScroll != setting)
{
d_forceHorzScroll = setting;
configureScrollbars();
// Event firing.
WindowEventArgs args(this);
onHorzScrollbarModeChanged(args);
}
}
Code: Select all
/*************************************************************************
display required integrated scroll bars according to current state
of the list box and update their values.
*************************************************************************/
void MultiColumnList::configureScrollbars(void)
{
Scrollbar* vertScrollbar = getVertScrollbar();
Scrollbar* horzScrollbar = getHorzScrollbar();
float totalHeight = getTotalRowsHeight();
float fullWidth = getListHeader()->getTotalSegmentsPixelExtent();
//
// First show or hide the scroll bars as needed (or requested)
//
// show or hide vertical scroll bar as required (or as specified by option)
if (((totalHeight > getListRenderArea().getHeight()) && d_forceVertScroll==AsRequired) || d_forceVertScroll==AlwaysOn)
{
vertScrollbar->show();
// show or hide horizontal scroll bar as required (or as specified by option)
if (((fullWidth > getListRenderArea().getWidth()) && d_forceHorzScroll==AsRequired) || d_forceHorzScroll==AlwaysOn)
{
horzScrollbar->show();
}
else
{
horzScrollbar->hide();
}
}
else
{
// show or hide horizontal scroll bar as required (or as specified by option)
if (((fullWidth > getListRenderArea().getWidth()) && d_forceHorzScroll==AsRequired) || d_forceHorzScroll==AlwaysOn)
{
horzScrollbar->show();
// show or hide vertical scroll bar as required (or as specified by option)
if (((totalHeight > getListRenderArea().getHeight()) && d_forceVertScroll==AsRequired) || d_forceVertScroll==AlwaysOn)
{
vertScrollbar->show();
}
else
{
vertScrollbar->hide();
}
}
else
{
vertScrollbar->hide();
horzScrollbar->hide();
}
}
//
// Set up scroll bar values
//
Rect renderArea(getListRenderArea());
vertScrollbar->setDocumentSize(totalHeight);
vertScrollbar->setPageSize(renderArea.getHeight());
vertScrollbar->setStepSize(ceguimax(1.0f, renderArea.getHeight() / 10.0f));
vertScrollbar->setScrollPosition(vertScrollbar->getScrollPosition());
horzScrollbar->setDocumentSize(fullWidth);
horzScrollbar->setPageSize(renderArea.getWidth());
horzScrollbar->setStepSize(ceguimax(1.0f, renderArea.getWidth() / 10.0f));
horzScrollbar->setScrollPosition(horzScrollbar->getScrollPosition());
}
Code: Select all
/*************************************************************************
Return whether the vertical scroll bar is always shown.
*************************************************************************/
MultiColumnList::ScrollbarVisibility MultiColumnList::isVertScrollbarAlwaysShown(void) const
{
return d_forceVertScroll;
}
/*************************************************************************
Return whether the horizontal scroll bar is always shown.
*************************************************************************/
MultiColumnList::ScrollbarVisibility MultiColumnList::isHorzScrollbarAlwaysShown(void) const
{
return d_forceHorzScroll;
}