mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-27 15:32:59 +02:00
gui/menue: simplify height calculation
This commit is contained in:
@@ -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;
|
||||||
|
Reference in New Issue
Block a user