summaryrefslogtreecommitdiff
path: root/src/gui/widgets/window.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-09-19 00:21:38 +0300
committerAndrei Karas <akaras@inbox.ru>2012-09-19 00:21:38 +0300
commit9847915fafee7fc3872aafb4395543b12174a1ae (patch)
tree2230ad7e345fdc46bd30c2c49864194ba1180ab6 /src/gui/widgets/window.cpp
parent0ebeb9512515249f33a9334abf1c52cbb0b6b7bb (diff)
downloadmanaverse-9847915fafee7fc3872aafb4395543b12174a1ae.tar.gz
manaverse-9847915fafee7fc3872aafb4395543b12174a1ae.tar.bz2
manaverse-9847915fafee7fc3872aafb4395543b12174a1ae.tar.xz
manaverse-9847915fafee7fc3872aafb4395543b12174a1ae.zip
Add resize grip padding.
Fix resize grip position. New theme option: resizePadding
Diffstat (limited to 'src/gui/widgets/window.cpp')
-rw-r--r--src/gui/widgets/window.cpp46
1 files changed, 21 insertions, 25 deletions
diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp
index ce893c360..0a0951f9e 100644
--- a/src/gui/widgets/window.cpp
+++ b/src/gui/widgets/window.cpp
@@ -33,7 +33,6 @@
#include "gui/viewport.h"
#include "gui/widgets/layout.h"
-#include "gui/widgets/resizegrip.h"
#include "resources/image.h"
@@ -77,6 +76,7 @@ Window::Window(const std::string &caption, const bool modal,
mCaptionOffsetY(5),
mCaptionAlign(gcn::Graphics::LEFT),
mTitlePadding(4),
+ mGripPadding(2),
mResizeHandles(-1),
mRedraw(true),
mCaptionFont(getFont())
@@ -106,6 +106,7 @@ Window::Window(const std::string &caption, const bool modal,
mCaptionFont = reinterpret_cast<gcn::Font*>(boldFont);
setTitlePadding(mSkin->getTitlePadding());
setTitleBarHeight(getOption("titlebarHeight"));
+ mGripPadding = getOption("resizePadding");
mCaptionOffsetX = getOption("captionoffsetx");
if (!mCaptionOffsetX)
mCaptionOffsetX = 7;
@@ -121,6 +122,7 @@ Window::Window(const std::string &caption, const bool modal,
}
}
+
// Add this window to the window container
windowContainer->add(this);
@@ -163,6 +165,11 @@ Window::~Window()
Theme::instance()->unload(mSkin);
mSkin = nullptr;
}
+ if (mGrip)
+ {
+ mGrip->decRef();
+ mGrip = nullptr;
+ }
}
void Window::setWindowContainer(WindowContainer *wc)
@@ -213,6 +220,9 @@ void Window::draw(gcn::Graphics *graphics)
g->drawImage(button, mStickyRect.x, mStickyRect.y);
}
+ if (mGrip)
+ g->drawImage(mGrip, mGripRect.x, mGripRect.y);
+
if (update)
{
g->setRedraw(update);
@@ -358,27 +368,19 @@ void Window::setMaxHeight(const int height)
void Window::setResizable(const bool r)
{
- if (static_cast<bool>(mGrip) == r)
+ if ((mGrip != nullptr) == r)
return;
+ if (mGrip)
+ mGrip->decRef();
if (r)
{
- if (mGrip)
- {
- remove(mGrip);
- delete mGrip;
- }
- mGrip = new ResizeGrip;
- mGrip->setX(mDimension.width - mGrip->getWidth()
- - getChildrenArea().x);
- mGrip->setY(mDimension.height - mGrip->getHeight()
- - getChildrenArea().y);
- add(mGrip);
+ mGrip = Theme::getImageFromThemeXml("resize.xml", "");
+ mGripRect.x = mDimension.width - mGrip->getWidth() - mGripPadding;
+ mGripRect.y = mDimension.height - mGrip->getHeight() - mGripPadding;
}
else
{
- remove(mGrip);
- delete mGrip;
mGrip = nullptr;
}
}
@@ -389,8 +391,8 @@ void Window::widgetResized(const gcn::Event &event A_UNUSED)
if (mGrip)
{
- mGrip->setPosition(mDimension.width - mGrip->getWidth() - area.x,
- mDimension.height - mGrip->getHeight() - area.y);
+ mGripRect.x = mDimension.width - mGrip->getWidth() - mGripPadding;
+ mGripRect.y = mDimension.height - mGrip->getHeight() - mGripPadding;
}
if (mLayout)
@@ -474,7 +476,6 @@ void Window::setStickyButtonLock(const bool lock)
{
mStickyButtonLock = lock;
mStickyButton = lock;
-// mMovable = false;
}
void Window::setVisible(bool visible)
@@ -919,8 +920,7 @@ int Window::getResizeHandles(const gcn::MouseEvent &event)
resizeHandles |= (y > mDimension.height - resizeBorderWidth)
? BOTTOM : (y < resizeBorderWidth) ? TOP : 0;
}
-
- if (event.getSource() == mGrip)
+ if (x >= mGripRect.x && y >= mGripRect.y)
{
mDragOffsetX = x;
mDragOffsetY = y;
@@ -944,7 +944,7 @@ bool Window::isResizeAllowed(const gcn::MouseEvent &event) const
if (!getWindowArea().isPointInRect(x, y) && event.getSource() == this)
return true;
- if (event.getSource() == mGrip)
+ if (x >= mGripRect.x && y >= mGripRect.y)
return true;
}
@@ -969,10 +969,6 @@ void Window::clearLayout()
{
clear();
- // Restore the resize grip
- if (mGrip)
- add(mGrip);
-
// Recreate layout instance when one is present
if (mLayout)
{