mirror of https://github.com/stella-emu/stella.git
allow RomInfoWidget text to fill multiple lines
This commit is contained in:
parent
654c843084
commit
c769d22b54
|
@ -340,13 +340,14 @@ bool FBSurface::isWhiteSpace(const char s) const
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void FBSurface::drawString(const GUI::Font& font, const string& s,
|
||||
int FBSurface::drawString(const GUI::Font& font, const string& s,
|
||||
int x, int y, int w, int h,
|
||||
ColorId color, TextAlign align,
|
||||
int deltax, bool useEllipsis, ColorId shadowColor)
|
||||
{
|
||||
#ifdef GUI_SUPPORT
|
||||
string inStr = s;
|
||||
int lines = 1;
|
||||
|
||||
// draw multiline string
|
||||
while (font.getStringWidth(inStr) > w && h >= font.getFontHeight() * 2)
|
||||
|
@ -371,8 +372,10 @@ void FBSurface::drawString(const GUI::Font& font, const string& s,
|
|||
h -= font.getFontHeight();
|
||||
y += font.getFontHeight();
|
||||
inStr = rightStr;
|
||||
lines++;
|
||||
}
|
||||
drawString(font, inStr, x, y, w, color, align, deltax, useEllipsis, shadowColor);
|
||||
return lines;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -218,7 +218,7 @@ class FBSurface
|
|||
@param useEllipsis Whether to use '...' when the string is too long
|
||||
*/
|
||||
|
||||
virtual void drawString(
|
||||
virtual int drawString(
|
||||
const GUI::Font& font, const string& s, int x, int y, int w, int h,
|
||||
ColorId color, TextAlign align = TextAlign::Left,
|
||||
int deltax = 0, bool useEllipsis = true, ColorId shadowColor = kNone);
|
||||
|
@ -235,6 +235,7 @@ class FBSurface
|
|||
@param align The alignment of the text in the string width area
|
||||
@param deltax FIXME
|
||||
@param useEllipsis Whether to use '...' when the string is too long
|
||||
@return Number of lines drawn
|
||||
*/
|
||||
virtual void drawString(
|
||||
const GUI::Font& font, const string& s, int x, int y, int w,
|
||||
|
|
|
@ -200,7 +200,8 @@ void RomInfoWidget::drawWidget(bool hilite)
|
|||
int xpos = _x + 8, ypos = _y + yoff + 10;
|
||||
for(const auto& info: myRomInfo)
|
||||
{
|
||||
s.drawString(_font, info, xpos, ypos, _w - 16, onTop ? _textcolor : _shadowcolor);
|
||||
ypos += _font.getLineHeight();
|
||||
int lines = s.drawString(_font, info, xpos, ypos, _w - 16, _font.getFontHeight() * 3,
|
||||
onTop ? _textcolor : _shadowcolor);
|
||||
ypos += _font.getLineHeight() + (lines - 1) * _font.getFontHeight();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue