Add a `getTextHeight` to the GuiText class

This commit is contained in:
Maschell 2020-08-13 14:08:23 +02:00
parent 85abf9a572
commit 545046971a
2 changed files with 13 additions and 0 deletions

View File

@ -104,6 +104,7 @@ public:
return maxWidth;
}
float getTextHeight();
void setSSAA(int32_t ssaa) {
this->internalSSAA = ssaa;

View File

@ -292,6 +292,18 @@ int32_t GuiText::getTextWidth() {
res = res > maxWidth && maxWidth > 0 ? maxWidth : res;
textMutex.unlock();
return res;
}
float GuiText::getTextHeight() {
textMutex.lock();
if (wrapMode == GuiText::WRAP && textDyn.empty()) {
if (maxWidth > 0 && font->getWidth(text, currentSize)) {
wrapText();
}
}
auto res = textDyn.empty() ? getLineHeight() : getLineHeight() * textDyn.size();
textMutex.unlock();
return res;
}