Added ResourceListenerWrapper
This class wraps the call to Resource::AddResourceListener/RemoveResourceListener using RAII and help a lot with some of the dependencies. Thanks to this, the render queues now handle their resources listening properly. Former-commit-id: 7f215ffa4ccadcc4f44f777656970e92ce01087a
This commit is contained in:
@@ -8,17 +8,12 @@
|
||||
|
||||
NzSimpleTextDrawer::NzSimpleTextDrawer() :
|
||||
m_color(NzColor::White),
|
||||
m_fontListener(this),
|
||||
m_style(nzTextStyle_Regular)
|
||||
{
|
||||
SetFont(NzFont::GetDefault());
|
||||
}
|
||||
|
||||
NzSimpleTextDrawer::~NzSimpleTextDrawer()
|
||||
{
|
||||
if (m_font)
|
||||
m_font->RemoveResourceListener(this);
|
||||
}
|
||||
|
||||
const NzRectui& NzSimpleTextDrawer::GetBounds() const
|
||||
{
|
||||
if (!m_glyphUpdated)
|
||||
@@ -63,12 +58,8 @@ void NzSimpleTextDrawer::SetColor(const NzColor& color)
|
||||
|
||||
void NzSimpleTextDrawer::SetFont(NzFont* font)
|
||||
{
|
||||
if (m_font)
|
||||
m_font->RemoveResourceListener(this);
|
||||
|
||||
m_font = font;
|
||||
if (m_font)
|
||||
m_font->AddResourceListener(this);
|
||||
m_fontListener = font;
|
||||
|
||||
m_glyphUpdated = false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user