Commit 7e5f1612 authored by Aloshi's avatar Aloshi

Approximate size for MenuComponents that exceed max height so that scrolling...

Approximate size for MenuComponents that exceed max height so that scrolling still fits within row height multiples.
parent 5d0df7ac
......@@ -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);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment