From 7e5f161271f3152f76a524ade3ab8ad87dab1139 Mon Sep 17 00:00:00 2001 From: Aloshi Date: Tue, 13 May 2014 13:49:52 -0500 Subject: [PATCH] Approximate size for MenuComponents that exceed max height so that scrolling still fits within row height multiples. --- src/components/MenuComponent.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/components/MenuComponent.cpp b/src/components/MenuComponent.cpp index 9855410d5..6094547c4 100644 --- a/src/components/MenuComponent.cpp +++ b/src/components/MenuComponent.cpp @@ -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); }