gui/menue: simplify height calculation

This commit is contained in:
martii
2014-07-14 20:35:59 +02:00
committed by [CST] Focus
parent 6f1fd88ea8
commit c1db7b2852

View File

@@ -1029,23 +1029,24 @@ void CMenuWidget::calcSize()
} }
hheight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getHeight(); hheight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getHeight();
int itemHeightTotal=0;
int heightCurrPage=0; int heightCurrPage=0;
page_start.clear(); page_start.clear();
page_start.push_back(0); page_start.push_back(0);
total_pages=1; total_pages=1;
int maxItemHeight = 0;
for (unsigned int i= 0; i< items.size(); i++) { for (unsigned int i= 0; i< items.size(); i++) {
int item_height=items[i]->getHeight(); int item_height=items[i]->getHeight();
heightCurrPage+=item_height; heightCurrPage+=item_height;
if(heightCurrPage > (height-hheight)) { if(heightCurrPage > (height-hheight)) {
page_start.push_back(i); page_start.push_back(i);
total_pages++; total_pages++;
maxItemHeight = std::max(heightCurrPage - item_height, maxItemHeight);
heightCurrPage=item_height; heightCurrPage=item_height;
} }
if(total_pages == 1)
itemHeightTotal+=item_height;
} }
maxItemHeight = std::max(heightCurrPage, maxItemHeight);
page_start.push_back(items.size()); page_start.push_back(items.size());
iconOffset= 0; iconOffset= 0;
@@ -1061,12 +1062,6 @@ void CMenuWidget::calcSize()
iconOffset += 10; iconOffset += 10;
width += iconOffset; width += iconOffset;
int maxItemHeight = 0;
if (total_pages > 1) {
for (unsigned int i= 0; i< items.size(); i++)
maxItemHeight = std::max(maxItemHeight, items[i]->getHeight());
itemHeightTotal = items.size() * maxItemHeight;
}
if (fbutton_count) if (fbutton_count)
width = std::max(width, fbutton_width); width = std::max(width, fbutton_width);
@@ -1074,8 +1069,7 @@ void CMenuWidget::calcSize()
width = frameBuffer->getScreenWidth(); width = frameBuffer->getScreenWidth();
// shrink menu if less items // shrink menu if less items
if(hheight+itemHeightTotal < height) height = std::min(height, hheight + maxItemHeight);
height=hheight+itemHeightTotal;
//scrollbar width //scrollbar width
sb_width=0; sb_width=0;