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,
|
int x, int y, int w, int h,
|
||||||
ColorId color, TextAlign align,
|
ColorId color, TextAlign align,
|
||||||
int deltax, bool useEllipsis, ColorId shadowColor)
|
int deltax, bool useEllipsis, ColorId shadowColor)
|
||||||
{
|
{
|
||||||
#ifdef GUI_SUPPORT
|
#ifdef GUI_SUPPORT
|
||||||
string inStr = s;
|
string inStr = s;
|
||||||
|
int lines = 1;
|
||||||
|
|
||||||
// draw multiline string
|
// draw multiline string
|
||||||
while (font.getStringWidth(inStr) > w && h >= font.getFontHeight() * 2)
|
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();
|
h -= font.getFontHeight();
|
||||||
y += font.getFontHeight();
|
y += font.getFontHeight();
|
||||||
inStr = rightStr;
|
inStr = rightStr;
|
||||||
|
lines++;
|
||||||
}
|
}
|
||||||
drawString(font, inStr, x, y, w, color, align, deltax, useEllipsis, shadowColor);
|
drawString(font, inStr, x, y, w, color, align, deltax, useEllipsis, shadowColor);
|
||||||
|
return lines;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -218,7 +218,7 @@ class FBSurface
|
||||||
@param useEllipsis Whether to use '...' when the string is too long
|
@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,
|
const GUI::Font& font, const string& s, int x, int y, int w, int h,
|
||||||
ColorId color, TextAlign align = TextAlign::Left,
|
ColorId color, TextAlign align = TextAlign::Left,
|
||||||
int deltax = 0, bool useEllipsis = true, ColorId shadowColor = kNone);
|
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 align The alignment of the text in the string width area
|
||||||
@param deltax FIXME
|
@param deltax FIXME
|
||||||
@param useEllipsis Whether to use '...' when the string is too long
|
@param useEllipsis Whether to use '...' when the string is too long
|
||||||
|
@return Number of lines drawn
|
||||||
*/
|
*/
|
||||||
virtual void drawString(
|
virtual void drawString(
|
||||||
const GUI::Font& font, const string& s, int x, int y, int w,
|
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;
|
int xpos = _x + 8, ypos = _y + yoff + 10;
|
||||||
for(const auto& info: myRomInfo)
|
for(const auto& info: myRomInfo)
|
||||||
{
|
{
|
||||||
s.drawString(_font, info, xpos, ypos, _w - 16, onTop ? _textcolor : _shadowcolor);
|
int lines = s.drawString(_font, info, xpos, ypos, _w - 16, _font.getFontHeight() * 3,
|
||||||
ypos += _font.getLineHeight();
|
onTop ? _textcolor : _shadowcolor);
|
||||||
|
ypos += _font.getLineHeight() + (lines - 1) * _font.getFontHeight();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue