Utility/SimpleTextDrawer: Add Clear method
Former-commit-id: 10f7c36edb7f0d1705709b070e78792708cdbebf
This commit is contained in:
@@ -11,7 +11,8 @@ namespace Nz
|
||||
SimpleTextDrawer::SimpleTextDrawer() :
|
||||
m_color(Color::White),
|
||||
m_style(TextStyle_Regular),
|
||||
m_glyphUpdated(false)
|
||||
m_glyphUpdated(false),
|
||||
m_characterSize(24)
|
||||
{
|
||||
SetFont(Font::GetDefault());
|
||||
}
|
||||
@@ -40,6 +41,12 @@ namespace Nz
|
||||
GenerateGlyphs(str);
|
||||
}
|
||||
|
||||
void SimpleTextDrawer::Clear()
|
||||
{
|
||||
m_text.Clear(true);
|
||||
ClearGlyphs();
|
||||
}
|
||||
|
||||
const Rectui& SimpleTextDrawer::GetBounds() const
|
||||
{
|
||||
if (!m_glyphUpdated)
|
||||
@@ -199,6 +206,16 @@ namespace Nz
|
||||
return drawer;
|
||||
}
|
||||
|
||||
void SimpleTextDrawer::ClearGlyphs() const
|
||||
{
|
||||
m_bounds.MakeZero();
|
||||
m_drawPos.Set(0, m_characterSize); //< Our draw "cursor"
|
||||
m_glyphs.clear();
|
||||
m_glyphUpdated = true;
|
||||
m_previousCharacter = 0;
|
||||
m_workingBounds.MakeZero(); //< Compute bounds as float to speedup bounds computation (as casting between floats and integers is costly)
|
||||
}
|
||||
|
||||
void SimpleTextDrawer::ConnectFontSlots()
|
||||
{
|
||||
m_atlasChangedSlot.Connect(m_font->OnFontAtlasChanged, this, &SimpleTextDrawer::OnFontInvalidated);
|
||||
@@ -374,13 +391,7 @@ namespace Nz
|
||||
{
|
||||
NazaraAssert(m_font && m_font->IsValid(), "Invalid font");
|
||||
|
||||
m_bounds.MakeZero();
|
||||
m_drawPos.Set(0, m_characterSize); //< Our draw "cursor"
|
||||
m_glyphs.clear();
|
||||
m_glyphUpdated = true;
|
||||
m_previousCharacter = 0;
|
||||
m_workingBounds.MakeZero(); //< Compute bounds as float to speedup bounds computation (as casting between floats and integers is costly)
|
||||
|
||||
ClearGlyphs();
|
||||
GenerateGlyphs(m_text);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user