Prevent the multiline update for labels from going out of bounds
This commit is contained in:
parent
332fbfe590
commit
22990b680c
@ -48,11 +48,13 @@ void Label::SetText(std::string text)
|
||||
|
||||
void Label::updateMultiline()
|
||||
{
|
||||
int lines = 1;
|
||||
if(text.length()>0)
|
||||
{
|
||||
char * rawText = new char[text.length()+1];
|
||||
std::copy(text.begin(), text.end(), rawText);
|
||||
rawText[text.length()] = 0;
|
||||
|
||||
int lines = 1;
|
||||
int currentWidth = 0;
|
||||
char * lastSpace = NULL;
|
||||
char * currentWord = rawText;
|
||||
@ -73,7 +75,7 @@ void Label::updateMultiline()
|
||||
currentWidth += width;
|
||||
if(nextSpace)
|
||||
nextSpace[0] = ' ';
|
||||
if(!(currentWord = strchr(currentWord+1, ' ')))
|
||||
if(!currentWord[0] || !currentWord[1] || !(currentWord = strchr(currentWord+1, ' ')))
|
||||
break;
|
||||
}
|
||||
if(autoHeight)
|
||||
@ -82,6 +84,15 @@ void Label::updateMultiline()
|
||||
}
|
||||
textLines = std::string(rawText);
|
||||
delete[] rawText;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(autoHeight)
|
||||
{
|
||||
Size.Y = 12;
|
||||
}
|
||||
textLines = std::string("");
|
||||
}
|
||||
}
|
||||
|
||||
std::string Label::GetText()
|
||||
|
Reference in New Issue
Block a user