Is there an easy way, in code, to select an entire row? For example, I want the 3rd row to be selected by default.
I was hoping to see something like:
Code: Select all
list->setRowSelectState(3, true);
Moderators: CEGUI MVP, CEGUI Team
Code: Select all
list->setRowSelectState(3, true);
Code: Select all
ListBox::ensureItemIsVisible()
Code: Select all
void ensureItemIsVisible(const CEGUI::MultiColumnList* multiColumnList, const CEGUI::ListboxItem* listboxItem)
{
ensureItemIsVisible(multiColumnList, multiColumnList->getItemRowIndex(listboxItem));
}
void ensureItemIsVisible(const CEGUI::MultiColumnList* multiColumnList, const CEGUI::uint& rowID)
{
using namespace CEGUI;
Scrollbar* vertScrollbar = multiColumnList->getVertScrollbar();
// handle simple "scroll to the bottom" case
if (rowID >= multiColumnList->getRowCount())
{
vertScrollbar->setScrollPosition(vertScrollbar->getDocumentSize() - vertScrollbar->getPageSize());
}
else
{
float bottom;
float listHeight = multiColumnList->getListRenderArea().getHeight();
float top = 0;
// get height to top of item
CEGUI::uint row;
for (row = 0; row < rowID; ++row)
{
MCLGridRef grid_ref(row, 0);
top += multiColumnList->getItemAtGridReference(grid_ref)->getPixelSize().d_height;
//top += d_listItems[i]->getPixelSize().d_height;
}
// calculate height to bottom of item
MCLGridRef grid_ref(row, 0);
bottom = top + multiColumnList->getItemAtGridReference(grid_ref)->getPixelSize().d_height;
//bottom = top + d_listItems[i]->getPixelSize().d_height;
// account for current scrollbar value
float currPos = vertScrollbar->getScrollPosition();
top -= currPos;
bottom -= currPos;
// if top is above the view area, or if item is too big to fit
if ((top < 0.0f) || ((bottom - top) > listHeight))
{
// scroll top of item to top of box.
vertScrollbar->setScrollPosition(currPos + top);
}
// if bottom is below the view area
else if (bottom >= listHeight)
{
// position bottom of item at the bottom of the list
vertScrollbar->setScrollPosition(currPos + bottom - listHeight);
}
// Item is already fully visible - nothing more to do.
}
}
Return to “Modifications / Integrations / Customisations”
Users browsing this forum: No registered users and 9 guests