From ea0ee924acc4736b56e760ff9f830d8a1990ebc0 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 Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/b5e0a7e064ec6140163ef47678cb0681d4dbcb3a Author: Stefan Seyfried Date: 2013-02-17 (Sun, 17 Feb 2013) ------------------ This commit was generated by Migit --- 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 795f2b8e1..17454d9d0 100644 --- a/src/gui/infoviewer_bb.cpp +++ b/src/gui/infoviewer_bb.cpp @@ -365,12 +365,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,