1
0
mirror of git://projects.qi-hardware.com/gmenu2x.git synced 2024-11-23 03:24:38 +02:00

Fixed text area coordinates in TextDialog

Take top and bottom bar height as defined by skin into account.
This commit is contained in:
Maarten ter Huurne 2013-08-14 13:25:07 +02:00
parent 91dd708476
commit 666be4d354
3 changed files with 22 additions and 17 deletions

View File

@ -77,23 +77,23 @@ void TextDialog::preProcess() {
} }
} }
void TextDialog::drawText(vector<string> *text, unsigned firstRow, void TextDialog::drawText(vector<string> *text, unsigned int y,
unsigned rowsPerPage) { unsigned int firstRow, unsigned int rowsPerPage)
gmenu2x->s->setClipRect(0,41,gmenu2x->resX-10,gmenu2x->resY-60); {
const int fontHeight = gmenu2x->font->getHeight();
for (unsigned i = firstRow; i < firstRow + rowsPerPage && i < text->size(); i++) { for (unsigned i = firstRow; i < firstRow + rowsPerPage && i < text->size(); i++) {
int rowY; const string &line = text->at(i);
if (text->at(i)=="----") { //draw a line int rowY = y + (i - firstRow) * fontHeight;
rowY = 42+(int)((i-firstRow+0.5)*gmenu2x->font->getHeight()); if (line == "----") { // horizontal ruler
rowY += fontHeight / 2;
gmenu2x->s->hline(5, rowY, gmenu2x->resX - 16, 255, 255, 255, 130); gmenu2x->s->hline(5, rowY, gmenu2x->resX - 16, 255, 255, 255, 130);
gmenu2x->s->hline(5, rowY+1, gmenu2x->resX - 16, 0, 0, 0, 130); gmenu2x->s->hline(5, rowY+1, gmenu2x->resX - 16, 0, 0, 0, 130);
} else { } else {
rowY = 42+(i-firstRow)*gmenu2x->font->getHeight(); gmenu2x->font->write(gmenu2x->s, line, 5, rowY);
gmenu2x->font->write(gmenu2x->s, text->at(i), 5, rowY);
} }
} }
gmenu2x->s->clearClipRect();
gmenu2x->drawScrollBar(rowsPerPage, text->size(), firstRow); gmenu2x->drawScrollBar(rowsPerPage, text->size(), firstRow);
} }
@ -117,11 +117,16 @@ void TextDialog::exec() {
bg.convertToDisplayFormat(); bg.convertToDisplayFormat();
const int fontHeight = gmenu2x->font->getHeight();
unsigned int contentY, contentHeight;
tie(contentY, contentHeight) = gmenu2x->getContentArea();
const unsigned rowsPerPage = contentHeight / fontHeight;
contentY += (contentHeight % fontHeight) / 2;
unsigned firstRow = 0; unsigned firstRow = 0;
unsigned rowsPerPage = (gmenu2x->resY - 60) / gmenu2x->font->getHeight();
while (!close) { while (!close) {
bg.blit(gmenu2x->s, 0, 0); bg.blit(gmenu2x->s, 0, 0);
drawText(text, firstRow, rowsPerPage); drawText(text, contentY, firstRow, rowsPerPage);
gmenu2x->s->flip(); gmenu2x->s->flip();
switch(gmenu2x->input.waitForPressedButton()) { switch(gmenu2x->input.waitForPressedButton()) {

View File

@ -32,8 +32,8 @@ protected:
std::string title, description, icon; std::string title, description, icon;
void preProcess(); void preProcess();
void drawText(std::vector<std::string> *text, unsigned firstRow, void drawText(std::vector<std::string> *text, unsigned int y,
unsigned rowsPerPage); unsigned int firstRow, unsigned int rowsPerPage);
public: public:
TextDialog(GMenu2X *gmenu2x, const std::string &title, TextDialog(GMenu2X *gmenu2x, const std::string &title,

View File

@ -99,7 +99,7 @@ void TextManualDialog::exec() {
while (!close) { while (!close) {
bg.blit(gmenu2x->s,0,0); bg.blit(gmenu2x->s,0,0);
writeSubTitle(pages[page].title); writeSubTitle(pages[page].title);
drawText(&pages[page].text, firstRow, rowsPerPage); drawText(&pages[page].text, 42 /* TODO */, firstRow, rowsPerPage);
ss.clear(); ss.clear();
ss << page+1; ss << page+1;