mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-27 22:49:25 +02:00
CLabel: add methods getWidth, setColor, setAutoRedraw
For somethign like map list we need to change CLabel data without redrawing it.
This commit is contained in:
@@ -63,6 +63,11 @@ std::string CLabel::getText()
|
||||
return text;
|
||||
}
|
||||
|
||||
void CLabel::setAutoRedraw(bool value)
|
||||
{
|
||||
autoRedraw = value;
|
||||
}
|
||||
|
||||
void CLabel::setText(const std::string &Txt)
|
||||
{
|
||||
text = Txt;
|
||||
@@ -75,6 +80,23 @@ void CLabel::setText(const std::string &Txt)
|
||||
}
|
||||
}
|
||||
|
||||
void CLabel::setColor(const SDL_Color & Color)
|
||||
{
|
||||
color = Color;
|
||||
if(autoRedraw)
|
||||
{
|
||||
if(bg || !parent)
|
||||
redraw();
|
||||
else
|
||||
parent->redraw();
|
||||
}
|
||||
}
|
||||
|
||||
size_t CLabel::getWidth()
|
||||
{
|
||||
return graphics->fonts[font]->getStringWidth(visibleText());;
|
||||
}
|
||||
|
||||
CMultiLineLabel::CMultiLineLabel(Rect position, EFonts Font, EAlignment Align, const SDL_Color &Color, const std::string &Text):
|
||||
CLabel(position.x, position.y, Font, Align, Color, Text),
|
||||
visibleSize(0, 0, position.w, position.h)
|
||||
|
||||
Reference in New Issue
Block a user