Revert "Remove superfluous 'deltax' parameter in drawString; I have no idea what it was doing there."

This reverts commit 6a180aeda0.

And as soon as I committed it, I suspected it would cause problems :(
This commit is contained in:
Stephen Anthony 2020-06-19 20:25:00 -02:30
parent 44c180f189
commit 186ead46fb
4 changed files with 13 additions and 10 deletions

View File

@ -329,7 +329,7 @@ bool FBSurface::isWhiteSpace(const char s) const
int 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,
bool useEllipsis, ColorId shadowColor) int deltax, bool useEllipsis, ColorId shadowColor)
{ {
int lines = 1; int lines = 1;
@ -355,13 +355,13 @@ int FBSurface::drawString(const GUI::Font& font, const string& s,
//str += inStr[i]; //str += inStr[i];
} }
wrapString(inStr, i, leftStr, rightStr); wrapString(inStr, i, leftStr, rightStr);
drawString(font, leftStr, x, y, w, color, align, false, shadowColor); drawString(font, leftStr, x, y, w, color, align, deltax, false, shadowColor);
h -= font.getFontHeight(); h -= font.getFontHeight();
y += font.getFontHeight(); y += font.getFontHeight();
inStr = rightStr; inStr = rightStr;
lines++; lines++;
} }
drawString(font, inStr, x, y, w, color, align, useEllipsis, shadowColor); drawString(font, inStr, x, y, w, color, align, deltax, useEllipsis, shadowColor);
#endif #endif
return lines; return lines;
} }
@ -370,7 +370,7 @@ int FBSurface::drawString(const GUI::Font& font, const string& s,
void FBSurface::drawString(const GUI::Font& font, const string& s, void FBSurface::drawString(const GUI::Font& font, const string& s,
int x, int y, int w, int x, int y, int w,
ColorId color, TextAlign align, ColorId color, TextAlign align,
bool useEllipsis, ColorId shadowColor) int deltax, bool useEllipsis, ColorId shadowColor)
{ {
#ifdef GUI_SUPPORT #ifdef GUI_SUPPORT
const string ELLIPSIS = "\x1d"; // "..." const string ELLIPSIS = "\x1d"; // "..."
@ -410,6 +410,7 @@ void FBSurface::drawString(const GUI::Font& font, const string& s,
else if(align == TextAlign::Right) else if(align == TextAlign::Right)
x = x + w - width; x = x + w - width;
x += deltax;
for(i = 0; i < str.size(); ++i) for(i = 0; i < str.size(); ++i)
{ {
w = font.getCharWidth(str[i]); w = font.getCharWidth(str[i]);

View File

@ -218,6 +218,7 @@ class FBSurface
@param h The height of the string area (for multi line strings) @param h The height of the string area (for multi line strings)
@param color The color of the text @param color The color of the text
@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 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 @return Number of lines drawn
*/ */
@ -225,7 +226,7 @@ class FBSurface
virtual int 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,
bool useEllipsis = true, ColorId shadowColor = kNone); int deltax = 0, bool useEllipsis = true, ColorId shadowColor = kNone);
/** /**
This method should be called to draw the specified string. This method should be called to draw the specified string.
@ -237,12 +238,13 @@ class FBSurface
@param w The width of the string area @param w The width of the string area
@param color The color of the text @param color The color of the text
@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 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 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,
ColorId color, TextAlign align = TextAlign::Left, ColorId color, TextAlign align = TextAlign::Left,
bool useEllipsis = true, ColorId shadowColor = kNone); int deltax = 0, bool useEllipsis = true, ColorId shadowColor = kNone);
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
// Note: The following methods are FBSurface-specific, and must be // Note: The following methods are FBSurface-specific, and must be

View File

@ -600,7 +600,7 @@ void FrameBuffer::drawFrameStats(float framesPerSecond)
<< info.DisplayFormat; << info.DisplayFormat;
myStatsMsg.surface->drawString(f, ss.str(), xPos, yPos, myStatsMsg.surface->drawString(f, ss.str(), xPos, yPos,
myStatsMsg.w, color, TextAlign::Left, true, kBGColor); myStatsMsg.w, color, TextAlign::Left, 0, true, kBGColor);
yPos += dy; yPos += dy;
ss.str(""); ss.str("");
@ -615,7 +615,7 @@ void FrameBuffer::drawFrameStats(float framesPerSecond)
<< "% speed"; << "% speed";
myStatsMsg.surface->drawString(f, ss.str(), xPos, yPos, myStatsMsg.surface->drawString(f, ss.str(), xPos, yPos,
myStatsMsg.w, myStatsMsg.color, TextAlign::Left, true, kBGColor); myStatsMsg.w, myStatsMsg.color, TextAlign::Left, 0, true, kBGColor);
yPos += dy; yPos += dy;
ss.str(""); ss.str("");
@ -624,7 +624,7 @@ void FrameBuffer::drawFrameStats(float framesPerSecond)
if (myOSystem.settings().getBool("dev.settings")) ss << "| Developer"; if (myOSystem.settings().getBool("dev.settings")) ss << "| Developer";
myStatsMsg.surface->drawString(f, ss.str(), xPos, yPos, myStatsMsg.surface->drawString(f, ss.str(), xPos, yPos,
myStatsMsg.w, myStatsMsg.color, TextAlign::Left, true, kBGColor); myStatsMsg.w, myStatsMsg.color, TextAlign::Left, 0, true, kBGColor);
myStatsMsg.surface->setDstPos(myImageRect.x() + 10, myImageRect.y() + 8); myStatsMsg.surface->setDstPos(myImageRect.x() + 10, myImageRect.y() + 8);
myStatsMsg.surface->setDstSize(myStatsMsg.w * hidpiScaleFactor(), myStatsMsg.surface->setDstSize(myStatsMsg.w * hidpiScaleFactor(),

View File

@ -344,7 +344,7 @@ void StaticTextWidget::drawWidget(bool hilite)
FBSurface& s = _boss->dialog().surface(); FBSurface& s = _boss->dialog().surface();
bool onTop = _boss->dialog().isOnTop(); bool onTop = _boss->dialog().isOnTop();
s.drawString(_font, _label, _x, _y, _w, s.drawString(_font, _label, _x, _y, _w,
isEnabled() && onTop ? _textcolor : kColor, _align, true, _shadowcolor); isEnabled() && onTop ? _textcolor : kColor, _align, 0, true, _shadowcolor);
setDirty(); setDirty();
} }