Approximate size for MenuComponents that exceed max height so that scrolling still fits within row height multiples.

This commit is contained in:
Aloshi 2014-05-13 13:49:52 -05:00
parent 5d0df7acf8
commit 7e5f161271

View file

@ -46,9 +46,21 @@ float MenuComponent::getButtonGridHeight() const
void MenuComponent::updateSize()
{
const float maxHeight = Renderer::getScreenHeight() * 0.7f;
float height = TITLE_HEIGHT + mList->getTotalRowHeight() + getButtonGridHeight() + 2;
if(height > Renderer::getScreenHeight() * 0.7f)
height = Renderer::getScreenHeight() * 0.7f;
if(height > maxHeight)
{
height = TITLE_HEIGHT + getButtonGridHeight() + 2;
int i = 0;
while(height < maxHeight && i < mList->size())
{
float rowHeight = mList->getRowHeight(i);
if(height + rowHeight < maxHeight)
height += rowHeight;
i++;
}
height += 2;
}
setSize(Renderer::getScreenWidth() * 0.5f, height);
}