/************************************************************************* Sets up sizes and positions for attached ItemEntry children. *************************************************************************/ void PopupMenu::layoutItemWidgets() { // get render area Rect render_rect = getItemRenderArea(); // get starting position const float x0 = PixelAligned(render_rect.d_left); float y0 = PixelAligned(render_rect.d_top); URect rect; UVector2 sz(cegui_absdim(PixelAligned(render_rect.getWidth())), cegui_absdim(0)); // set item width // iterate through all items attached to this window ItemEntryList::iterator item = d_listItems.begin(); while ( item != d_listItems.end() ) { // get the "optimal" height of the item and use that! sz.d_y.d_offset = PixelAligned((*item)->getItemPixelSize().d_height); // rounding errors ? // set destination rect rect.setPosition(UVector2(cegui_absdim(x0), cegui_absdim(y0)) ); rect.setSize( sz ); (*item)->setArea(rect); // next position y0 += PixelAligned(sz.d_y.d_offset + d_itemSpacing); item++; // next item } }
/************************************************************************* Sets up sizes and positions for attached ItemEntry children. *************************************************************************/ void Menubar::layoutItemWidgets() { Rect render_rect = getItemRenderArea(); float x0 = PixelAligned(render_rect.d_left); URect rect; ItemEntryList::iterator item = d_listItems.begin(); while ( item != d_listItems.end() ) { const Size optimal = (*item)->getItemPixelSize(); (*item)->setVerticalAlignment(VA_CENTRE); rect.setPosition(UVector2(cegui_absdim(x0), cegui_absdim(0)) ); rect.setSize( UVector2( cegui_absdim(PixelAligned(optimal.d_width)), cegui_absdim(PixelAligned(optimal.d_height)))); (*item)->setArea(rect); x0 += optimal.d_width + d_itemSpacing; ++item; } }