summaryrefslogtreecommitdiff
path: root/src/gui/widgets/button.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-05-23 23:55:26 +0300
committerAndrei Karas <akaras@inbox.ru>2015-05-23 23:57:25 +0300
commitef1767851f3b5509066b0106324c6619102de046 (patch)
tree4cd86ffba145dc686f33b3c195897312158f575b /src/gui/widgets/button.cpp
parent7e64832ec06e48711742329816f23c3429903a7a (diff)
downloadmanaverse-ef1767851f3b5509066b0106324c6619102de046.tar.gz
manaverse-ef1767851f3b5509066b0106324c6619102de046.tar.bz2
manaverse-ef1767851f3b5509066b0106324c6619102de046.tar.xz
manaverse-ef1767851f3b5509066b0106324c6619102de046.zip
If window with button is hidden then release text image and vertexes.
This will reduce memory usage and not affect performance.
Diffstat (limited to 'src/gui/widgets/button.cpp')
-rw-r--r--src/gui/widgets/button.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/gui/widgets/button.cpp b/src/gui/widgets/button.cpp
index 446f4756f..e6f5b501d 100644
--- a/src/gui/widgets/button.cpp
+++ b/src/gui/widgets/button.cpp
@@ -367,6 +367,9 @@ void Button::init()
Button::~Button()
{
+ if (mWindow)
+ mWindow->removeWidgetListener(this);
+
if (gui)
gui->removeDragged(this);
@@ -679,6 +682,15 @@ void Button::widgetMoved(const Event &event A_UNUSED)
mRedraw = true;
}
+void Button::widgetHidden(const Event &event A_UNUSED)
+{
+ if (isBatchDrawRenders(openGLMode))
+ mVertexes2->clear();
+ mTextChunk.deleteImage();
+ mRedraw = true;
+ mTextChanged = true;
+}
+
void Button::adjustSize()
{
const Font *const font = getFont();
@@ -774,3 +786,10 @@ void Button::mouseDragged(MouseEvent& event)
{
event.consume();
}
+
+void Button::setParent(Widget *widget)
+{
+ if (mWindow)
+ mWindow->addWidgetListener(this);
+ Widget::setParent(widget);
+}