MultiColumnList Selection

For help with anything that CEGUI doesn't offer straight out-of-the-box, e.g.:
- Implementation of new features, such as new Core classes, widgets, WindowRenderers, etc. ...
- Modification of any existing features for specific purposes
- Integration of CEGUI in new engines or frameworks and writing of new plugins (Renderer, Parser, ...) or modules

Moderators: CEGUI MVP, CEGUI Team

User avatar
EJohnson
Just popping in
Just popping in
Posts: 11
Joined: Fri Jul 01, 2005 03:45
Location: California
Contact:

MultiColumnList Selection

Postby EJohnson » Wed Aug 10, 2005 02:52

Hi,

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);

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Re: MultiColumnList Selection

Postby CrazyEddie » Wed Aug 10, 2005 08:34

As long as you're using one of the whole row selection modes, the function:

MultiColumnList::setItemSelectState

Should do what you want.

User avatar
EJohnson
Just popping in
Just popping in
Posts: 11
Joined: Fri Jul 01, 2005 03:45
Location: California
Contact:

Re: MultiColumnList Selection

Postby EJohnson » Wed Aug 10, 2005 21:09

..and so it does! :D


One more quick one that's related:

Is there a way to automatically scroll the MultiColumnList to the selected row? It looks like the ListBox does this with

Code: Select all

 ListBox::ensureItemIsVisible()


?

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Re: MultiColumnList Selection

Postby CrazyEddie » Thu Aug 11, 2005 13:33

Hmmmm. Seems we do not have anything like this. It should probably be added though ;)

Rackle
CEGUI Team (Retired)
Posts: 534
Joined: Mon Jan 16, 2006 11:59
Location: Montréal

Postby Rackle » Tue Jun 27, 2006 02:31

I've adapted void Listbox::ensureItemIsVisible(size_t item_index) and void Listbox::ensureItemIsVisible(const ListboxItem* item) to a MultiColumnList object (and replaced the i variable with a row). It should be fairly easy to move this code within the MultiColumnList code.

What I'm unsure of (I have not looked enough at v0.5.0 yet) is whether the height is the same for every ListboxItem of a row, in which case the code below should be final, otherwise we'd have to iterate through each item on that row and find the highest.

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”

Who is online

Users browsing this forum: Bing [Bot] and 2 guests