mirror of
git://projects.qi-hardware.com/gmenu2x.git
synced 2024-11-29 09:09:43 +02:00
Revert "Removed support for multi-line text drawing"
This reverts commit 0908aa7bb7
.
It turns out there are multi-line text messages in use: Nebuleon found
one in the confirmation message when deleting a section.
This commit is contained in:
parent
826d4bbac4
commit
d4344c7960
25
src/font.cpp
25
src/font.cpp
@ -59,7 +59,30 @@ int Font::getTextWidth(const char *text)
|
|||||||
else return 1;
|
else return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Font::write(Surface *surface, std::string const& text,
|
void Font::write(Surface *surface, const string &text,
|
||||||
|
int x, int y, HAlign halign, VAlign valign)
|
||||||
|
{
|
||||||
|
if (!font) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t pos = text.find('\n', 0);
|
||||||
|
if (pos == string::npos) {
|
||||||
|
writeLine(surface, text, x, y, halign, valign);
|
||||||
|
} else {
|
||||||
|
size_t prev = 0;
|
||||||
|
do {
|
||||||
|
writeLine(surface, text.substr(prev, pos - prev),
|
||||||
|
x, y, halign, valign);
|
||||||
|
y += lineSpacing;
|
||||||
|
prev = pos + 1;
|
||||||
|
pos = text.find('\n', prev);
|
||||||
|
} while (pos != string::npos);
|
||||||
|
writeLine(surface, text.substr(prev), x, y, halign, valign);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Font::writeLine(Surface *surface, std::string const& text,
|
||||||
int x, int y, HAlign halign, VAlign valign)
|
int x, int y, HAlign halign, VAlign valign)
|
||||||
{
|
{
|
||||||
if (!font) {
|
if (!font) {
|
||||||
|
@ -41,6 +41,9 @@ public:
|
|||||||
private:
|
private:
|
||||||
Font(TTF_Font *font);
|
Font(TTF_Font *font);
|
||||||
|
|
||||||
|
void writeLine(Surface *surface, std::string const& text,
|
||||||
|
int x, int y, HAlign halign, VAlign valign);
|
||||||
|
|
||||||
TTF_Font *font;
|
TTF_Font *font;
|
||||||
int lineSpacing;
|
int lineSpacing;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user