summaryrefslogtreecommitdiff
path: root/src/gui/widgets/label.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-05-23 23:42:32 +0300
committerAndrei Karas <akaras@inbox.ru>2015-05-23 23:42:32 +0300
commit7e64832ec06e48711742329816f23c3429903a7a (patch)
treed06ffbb85a71174661c7f9c7944d05ecca30c0e7 /src/gui/widgets/label.cpp
parent89694323abffb1c73c85d49460991b3e6f20f098 (diff)
downloadManaVerse-7e64832ec06e48711742329816f23c3429903a7a.tar.gz
ManaVerse-7e64832ec06e48711742329816f23c3429903a7a.tar.bz2
ManaVerse-7e64832ec06e48711742329816f23c3429903a7a.tar.xz
ManaVerse-7e64832ec06e48711742329816f23c3429903a7a.zip
If window with label is hidden then release text image.
This will reduce memore usage and not affect performance.
Diffstat (limited to 'src/gui/widgets/label.cpp')
-rw-r--r--src/gui/widgets/label.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/gui/widgets/label.cpp b/src/gui/widgets/label.cpp
index 65e7f86d0..e05a76c5d 100644
--- a/src/gui/widgets/label.cpp
+++ b/src/gui/widgets/label.cpp
@@ -76,6 +76,7 @@ int Label::mInstances = 0;
Label::Label(const Widget2 *const widget) :
Widget(widget),
+ WidgetListener(),
ToolTipListener(),
mCaption(),
mTextChunk(),
@@ -89,6 +90,7 @@ Label::Label(const Widget2 *const widget) :
Label::Label(const Widget2 *const widget,
const std::string &caption) :
Widget(widget),
+ WidgetListener(),
ToolTipListener(),
mCaption(caption),
mTextChunk(),
@@ -107,6 +109,9 @@ Label::Label(const Widget2 *const widget,
Label::~Label()
{
+ if (mWindow)
+ mWindow->removeWidgetListener(this);
+
if (gui)
gui->removeDragged(this);
@@ -253,3 +258,16 @@ void Label::setCaption(const std::string& caption)
mTextChanged = true;
mCaption = caption;
}
+
+void Label::setParent(Widget *widget)
+{
+ if (mWindow)
+ mWindow->addWidgetListener(this);
+ Widget::setParent(widget);
+}
+
+void Label::widgetHidden(const Event &event)
+{
+ mTextChanged = true;
+ mTextChunk.deleteImage();
+}