1
0
mirror of git://projects.qi-hardware.com/gmenu2x.git synced 2024-06-30 21:13:51 +03:00

Show at least one row per page

In theory a font could be so large that no full row would fit on the
allotted space; in that case showing a partial row is better than
nothing and will avoid bugs where -1 wraps around on unsigned exprs.
This commit is contained in:
Maarten ter Huurne 2014-08-10 10:17:01 +02:00
parent 0535f8273b
commit b833f59bb5
2 changed files with 2 additions and 2 deletions

View File

@ -80,7 +80,7 @@ void TextDialog::exec() {
const int fontHeight = gmenu2x->font->getLineSpacing();
unsigned int contentY, contentHeight;
tie(contentY, contentHeight) = gmenu2x->getContentArea();
const unsigned rowsPerPage = contentHeight / fontHeight;
const unsigned rowsPerPage = max(contentHeight / fontHeight, 1u);
const unsigned maxFirstRow =
text.size() < rowsPerPage ? 0 : text.size() - rowsPerPage;
contentY += (contentHeight % fontHeight) / 2;

View File

@ -92,7 +92,7 @@ void TextManualDialog::exec() {
ss >> spagecount;
string pageStatus;
const unsigned rowsPerPage = 180 / gmenu2x->font->getLineSpacing();
const unsigned rowsPerPage = max(180u / gmenu2x->font->getLineSpacing(), 1u);
unsigned page = 0, firstRow = 0;
bool close = false;