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
This commit is contained in:
parent
91ff7f7a31
commit
8e7c4ffa37
3 changed files with 13 additions and 4 deletions
|
@ -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);
|
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)
|
// Draw an 8x8 bitmap at location (x,y)
|
||||||
//
|
//
|
||||||
|
|
|
@ -154,6 +154,7 @@ public:
|
||||||
|
|
||||||
void drawChar(byte c, int x, int y, OverlayColor color, const Graphics::Font *font = 0);
|
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 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 getStringWidth(const String &str) const;
|
||||||
int getCharWidth(byte c) const;
|
int getCharWidth(byte c) const;
|
||||||
|
|
|
@ -150,7 +150,7 @@ void StaticTextWidget::setAlign(TextAlignment align) {
|
||||||
|
|
||||||
void StaticTextWidget::drawWidget(bool hilite) {
|
void StaticTextWidget::drawWidget(bool hilite) {
|
||||||
NewGui *gui = &g_gui;
|
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 -
|
#pragma mark -
|
||||||
|
@ -169,7 +169,11 @@ void ButtonWidget::handleMouseUp(int x, int y, int button, int clickCount) {
|
||||||
|
|
||||||
void ButtonWidget::drawWidget(bool hilite) {
|
void ButtonWidget::drawWidget(bool hilite) {
|
||||||
NewGui *gui = &g_gui;
|
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 :
|
!isEnabled() ? gui->_color :
|
||||||
hilite ? gui->_textcolorhi : gui->_textcolor, _align);
|
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);
|
gui->drawBitmap(checked_img, _x + 4, _y + 3, isEnabled() ? gui->_textcolor : gui->_color);
|
||||||
|
|
||||||
// Finally draw the label
|
// 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 -
|
#pragma mark -
|
||||||
|
@ -269,7 +273,7 @@ void SliderWidget::drawWidget(bool hilite) {
|
||||||
|
|
||||||
// Draw the label, if any
|
// Draw the label, if any
|
||||||
if (_labelWidth > 0)
|
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
|
// Draw the box
|
||||||
gui->box(_x + _labelWidth, _y, _w - _labelWidth, _h, gui->_color, gui->_shadowcolor);
|
gui->box(_x + _labelWidth, _y, _w - _labelWidth, _h, gui->_color, gui->_shadowcolor);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue