aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTorbjörn Andersson2005-05-12 15:46:03 +0000
committerTorbjörn Andersson2005-05-12 15:46:03 +0000
commit8e7c4ffa3778a3b0dba8a677b1750261b6b7bd55 (patch)
tree4aa95fa031bdb2584afac3e9c7e1dfced7308eb3
parent91ff7f7a31e18a42438d08aaea515c38bb319755 (diff)
downloadscummvm-rg350-8e7c4ffa3778a3b0dba8a677b1750261b6b7bd55.tar.gz
scummvm-rg350-8e7c4ffa3778a3b0dba8a677b1750261b6b7bd55.tar.bz2
scummvm-rg350-8e7c4ffa3778a3b0dba8a677b1750261b6b7bd55.zip
Quick fix to make button texts etc. draw at the correct position. (They
were being drawn at unscaled coordinates.) I don't know if this is the correct fix, but the change is small and easy to revert, if need be. svn-id: r18072
-rw-r--r--gui/newgui.cpp4
-rw-r--r--gui/newgui.h1
-rw-r--r--gui/widget.cpp12
3 files changed, 13 insertions, 4 deletions
diff --git a/gui/newgui.cpp b/gui/newgui.cpp
index 7267f65e29..a7fa7cd674 100644
--- a/gui/newgui.cpp
+++ b/gui/newgui.cpp
@@ -464,6 +464,10 @@ void NewGui::drawString(const String &s, int x, int y, int w, OverlayColor color
getFont().drawString(&_screen, s, x * _scaleFactor, y * _scaleFactor, w * _scaleFactor, color, align, deltax, useEllipsis);
}
+void NewGui::drawString(const Graphics::Font *font, const String &s, int x, int y, int w, OverlayColor color, TextAlignment valign) {
+ font->drawString(&_screen, s, x * _scaleFactor, y * _scaleFactor, w * _scaleFactor, color, valign);
+}
+
//
// Draw an 8x8 bitmap at location (x,y)
//
diff --git a/gui/newgui.h b/gui/newgui.h
index 5724499ec6..c931b248e8 100644
--- a/gui/newgui.h
+++ b/gui/newgui.h
@@ -154,6 +154,7 @@ 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);
+ void drawString(const Graphics::Font *font, const String &str, int x, int y, int w, OverlayColor color, Graphics::TextAlignment valign = Graphics::kTextAlignLeft);
int getStringWidth(const String &str) const;
int getCharWidth(byte c) const;
diff --git a/gui/widget.cpp b/gui/widget.cpp
index 158fac64dd..0bc70e4a74 100644
--- a/gui/widget.cpp
+++ b/gui/widget.cpp
@@ -150,7 +150,7 @@ void StaticTextWidget::setAlign(TextAlignment align) {
void StaticTextWidget::drawWidget(bool hilite) {
NewGui *gui = &g_gui;
- _font->drawString(&gui->getScreen(), _label, _x, _y, _w, isEnabled() ? gui->_textcolor : gui->_color, _align);
+ gui->drawString(_font, _label, _x, _y, _w, isEnabled() ? gui->_textcolor : gui->_color, _align);
}
#pragma mark -
@@ -169,7 +169,11 @@ void ButtonWidget::handleMouseUp(int x, int y, int button, int clickCount) {
void ButtonWidget::drawWidget(bool hilite) {
NewGui *gui = &g_gui;
- _font->drawString(&gui->getScreen(), _label, _x, _y + (_h - (_font->getFontHeight() + 2))/2 + 1, _w,
+ // HACK: Subtracting 1 from _y isn't very nice when we don't know
+ // anything about the size of the font. But we can't use the size of
+ // the font either, because we don't know how the coordinates will be
+ // scaled.
+ gui->drawString(_font, _label, _x, _y - 1, _w,
!isEnabled() ? gui->_color :
hilite ? gui->_textcolorhi : gui->_textcolor, _align);
}
@@ -221,7 +225,7 @@ void CheckboxWidget::drawWidget(bool hilite) {
gui->drawBitmap(checked_img, _x + 4, _y + 3, isEnabled() ? gui->_textcolor : gui->_color);
// Finally draw the label
- _font->drawString(&g_gui.getScreen(), _label, _x + 20, _y + 3, _w, isEnabled() ? gui->_textcolor : gui->_color);
+ gui->drawString(_font, _label, _x + 20, _y + 3, _w, isEnabled() ? gui->_textcolor : gui->_color);
}
#pragma mark -
@@ -269,7 +273,7 @@ void SliderWidget::drawWidget(bool hilite) {
// Draw the label, if any
if (_labelWidth > 0)
- _font->drawString(&g_gui.getScreen(), _label, _x, _y + 2, _labelWidth, isEnabled() ? gui->_textcolor : gui->_color, kTextAlignRight);
+ gui->drawString(_font, _label, _x, _y + 2, _labelWidth, isEnabled() ? gui->_textcolor : gui->_color, kTextAlignRight);
// Draw the box
gui->box(_x + _labelWidth, _y, _w - _labelWidth, _h, gui->_color, gui->_shadowcolor);