diff options
Diffstat (limited to 'gui')
-rw-r--r-- | gui/about.cpp | 2 | ||||
-rw-r--r-- | gui/newgui.cpp | 23 | ||||
-rw-r--r-- | gui/newgui.h | 11 | ||||
-rw-r--r-- | gui/widget.cpp | 5 |
4 files changed, 24 insertions, 17 deletions
diff --git a/gui/about.cpp b/gui/about.cpp index 1fbaaaeb3e..e2bb3ac3fd 100644 --- a/gui/about.cpp +++ b/gui/about.cpp @@ -86,7 +86,7 @@ AboutDialog::AboutDialog() int i; - _lineHeight = g_gui.getFont().getFontHeight() + 3; + _lineHeight = g_gui.getFontHeight() + 3; for (i = 0; i < 1; i++) _lines.push_back(""); diff --git a/gui/newgui.cpp b/gui/newgui.cpp index 99f43c18a8..98014faf24 100644 --- a/gui/newgui.cpp +++ b/gui/newgui.cpp @@ -86,8 +86,11 @@ void NewGui::updateScaleFactor() { _scaleFactor = MIN(_system->getWidth() / kDefaultGUIWidth, _system->getHeight() / kDefaultGUIHeight); - // TODO: Pick a bigger font depending on the 'scale' factor. - _font = FontMan.getFontByUsage(Graphics::FontManager::kGUIFont); + // Pick the font depending on the scale factor. + if (_scaleFactor == 1) + _font = FontMan.getFontByUsage(Graphics::FontManager::kGUIFont); + else + _font = FontMan.getFontByUsage(Graphics::FontManager::kBigGUIFont); } void NewGui::runLoop() { @@ -349,19 +352,23 @@ void NewGui::addDirtyRect(int x, int y, int w, int h) { void NewGui::drawChar(byte chr, int xx, int yy, OverlayColor color, const Graphics::Font *font) { if (font == 0) font = &getFont(); - font->drawChar(&_screen, chr, xx, yy, color, _scaleFactor); + font->drawChar(&_screen, chr, xx * _scaleFactor, yy * _scaleFactor, color); } -int NewGui::getStringWidth(const String &str) { - return getFont().getStringWidth(str); +int NewGui::getStringWidth(const String &str) const { + return getFont().getStringWidth(str) / _scaleFactor; } -int NewGui::getCharWidth(byte c) { - return getFont().getCharWidth(c); +int NewGui::getCharWidth(byte c) const { + return getFont().getCharWidth(c) / _scaleFactor; +} + +int NewGui::getFontHeight() const { + return getFont().getFontHeight() / _scaleFactor; } void NewGui::drawString(const String &s, int x, int y, int w, OverlayColor color, TextAlignment align, int deltax, bool useEllipsis) { - getFont().drawString(&_screen, s, x, y, w, color, align, deltax, useEllipsis, _scaleFactor); + getFont().drawString(&_screen, s, x * _scaleFactor, y * _scaleFactor, w * _scaleFactor, color, align, deltax, useEllipsis); } // diff --git a/gui/newgui.h b/gui/newgui.h index f8ee91a78e..ed4f69dd96 100644 --- a/gui/newgui.h +++ b/gui/newgui.h @@ -36,7 +36,7 @@ class Dialog; // Height of a single text line -#define kLineHeight (g_gui.getFont().getFontHeight() + 2) +#define kLineHeight (g_gui.getFontHeight() + 2) using Graphics::TextAlignment; @@ -64,9 +64,9 @@ public: // until no dialogs are active anymore. void runLoop(); - bool isActive() { return ! _dialogStack.empty(); } + bool isActive() const { return ! _dialogStack.empty(); } - int getScaleFactor() { return _scaleFactor; } + int getScaleFactor() const { return _scaleFactor; } void enableScaling(bool enable) { _scaleEnable = enable; updateScaleFactor(); } protected: @@ -140,8 +140,9 @@ public: void drawChar(byte c, int x, int y, OverlayColor color, const Graphics::Font *font = 0); void drawString(const String &str, int x, int y, int w, OverlayColor color, Graphics::TextAlignment align = Graphics::kTextAlignLeft, int deltax = 0, bool useEllipsis = true); - int getStringWidth(const String &str); - int getCharWidth(byte c); + int getStringWidth(const String &str) const; + int getCharWidth(byte c) const; + int getFontHeight() const; void drawBitmap(uint32 *bitmap, int x, int y, OverlayColor color, int h = 8); diff --git a/gui/widget.cpp b/gui/widget.cpp index e36be7b23a..865b011a77 100644 --- a/gui/widget.cpp +++ b/gui/widget.cpp @@ -186,12 +186,11 @@ void CheckboxWidget::drawWidget(bool hilite) { // Draw the box gui->box(_x, _y, 14, 14, gui->_color, gui->_shadowcolor); + gui->fillRect(_x + 2, _y + 2, 10, 10, gui->_bgcolor); // If checked, draw cross inside the box if (_state) - gui->drawBitmap(checked_img, _x + 3, _y + 3, isEnabled() ? gui->_textcolor : gui->_color); - else - gui->fillRect(_x + 2, _y + 2, 10, 10, gui->_bgcolor); + gui->drawBitmap(checked_img, _x + 4, _y + 3, isEnabled() ? gui->_textcolor : gui->_color); // Finally draw the label gui->drawString(_label, _x + 20, _y + 3, _w, isEnabled() ? gui->_textcolor : gui->_color); |