1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-26 03:52:01 +02:00

Fix slider remain enabled when not needed for changed label text

This one fix issue with map description label #1977
This commit is contained in:
ArseniyShestakov 2014-11-24 16:18:10 +03:00
parent 0e346a4f0d
commit f2aedabcb3

View File

@ -280,15 +280,20 @@ void CTextBox::resize(Point newSize)
void CTextBox::setText(const std::string &text)
{
label->pos.w = pos.w; // reset to default before textSize.y check
label->setText(text);
if (label->textSize.y <= label->pos.h && slider)
if(label->textSize.y <= label->pos.h && slider)
{
// slider is no longer needed
vstd::clear_pointer(slider);
label->pos.w = pos.w;
}
else if(slider)
{
// decrease width again if slider still used
label->pos.w = pos.w - 32;
label->setText(text);
}
else if (label->textSize.y > label->pos.h && !slider)
else if(label->textSize.y > label->pos.h)
{
// create slider and update widget
label->pos.w = pos.w - 32;