From 7e64832ec06e48711742329816f23c3429903a7a Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 23 May 2015 23:42:32 +0300 Subject: If window with label is hidden then release text image. This will reduce memore usage and not affect performance. --- src/gui/widgets/label.cpp | 18 ++++++++++++++++++ src/gui/widgets/label.h | 6 ++++++ 2 files changed, 24 insertions(+) (limited to 'src/gui') 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(); +} diff --git a/src/gui/widgets/label.h b/src/gui/widgets/label.h index 9e82f0a5d..813248da8 100644 --- a/src/gui/widgets/label.h +++ b/src/gui/widgets/label.h @@ -70,6 +70,7 @@ #include "gui/widgets/widget.h" #include "listeners/tooltiplistener.h" +#include "listeners/widgetlistener.h" #include "localconsts.h" @@ -82,6 +83,7 @@ class Skin; * \ingroup GUI */ class Label final : public Widget, + public WidgetListener, public ToolTipListener { public: @@ -156,6 +158,10 @@ class Label final : public Widget, Graphics::Alignment getAlignment() const { return mAlignment; } + void setParent(Widget *widget) override final; + + void widgetHidden(const Event &event) override final; + static Skin *mSkin; static int mInstances; -- cgit v1.2.3-70-g09d2