From 65a3c616ab3b0a7c3ecb0826e3298c831e7d2e58 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Sun, 17 Feb 2013 19:10:49 +0100 Subject: [PATCH] infoviewer_bb: limit text width to available space only use the available space to draw the button texts Signed-off-by: Jacek Jendrzej Origin commit data ------------------ Commit: https://github.com/neutrino-images/ni-neutrino/commit/ab191b1c76eaa5faa6f0ad01c4c692bad23346b3 Author: Stefan Seyfried Date: 2013-02-17 (Sun, 17 Feb 2013) --- src/gui/infoviewer_bb.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/gui/infoviewer_bb.cpp b/src/gui/infoviewer_bb.cpp index 62c3bca74..0ef15bf1c 100644 --- a/src/gui/infoviewer_bb.cpp +++ b/src/gui/infoviewer_bb.cpp @@ -347,12 +347,21 @@ void CInfoViewerBB::showBBButtons(const int modus) } if (paint) { + int last_x = minX; frameBuffer->paintBoxRel(g_InfoViewer->ChanInfoX, BBarY, minX - g_InfoViewer->ChanInfoX, InfoHeightY_Info, COL_INFOBAR_BUTTONS_BACKGROUND, RADIUS_SMALL, CORNER_BOTTOM); //round - for (i = 0; i < CInfoViewerBB::BUTTON_MAX; i++) { + for (i = BUTTON_MAX; i > 0;) { + --i; if ((bbButtonInfo[i].x <= g_InfoViewer->ChanInfoX) || (bbButtonInfo[i].x >= g_InfoViewer->BoxEndX) || (!bbButtonInfo[i].paint)) continue; - if ((bbButtonInfo[i].x > 0) && ((bbButtonInfo[i].x + bbButtonInfo[i].w) <= minX)) { - + if (bbButtonInfo[i].x > 0) { + if (bbButtonInfo[i].x + bbButtonInfo[i].w > last_x) /* text too long */ + bbButtonInfo[i].w = last_x - bbButtonInfo[i].x; + last_x = bbButtonInfo[i].x; + if (bbButtonInfo[i].w - bbButtonInfo[i].cx <= 0) { + printf("[infoviewer_bb:%d cannot paint icon %d (not enough space)\n", + __LINE__, i); + continue; + } frameBuffer->paintIcon(bbButtonInfo[i].icon, bbButtonInfo[i].x, BBarY, InfoHeightY_Info); g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL]->RenderString(bbButtonInfo[i].x + bbButtonInfo[i].cx, BBarFontY,