summaryrefslogtreecommitdiff
path: root/src/gui/widgets
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-09-12 20:35:30 +0300
committerAndrei Karas <akaras@inbox.ru>2012-09-12 20:35:30 +0300
commit1031587ed2e4623d622bcc602c262290e14ea4c5 (patch)
tree2d1aaf848192694dac57d46b10fbec5b9df6e69e /src/gui/widgets
parentf7abd3b849d218af2a57e14490a8054d01be0e6f (diff)
downloadmv-1031587ed2e4623d622bcc602c262290e14ea4c5.tar.gz
mv-1031587ed2e4623d622bcc602c262290e14ea4c5.tar.bz2
mv-1031587ed2e4623d622bcc602c262290e14ea4c5.tar.xz
mv-1031587ed2e4623d622bcc602c262290e14ea4c5.zip
Add for windows close button hover image.
New theme parameter "closeImageHighlighted". It have attributes same as "closeImage".
Diffstat (limited to 'src/gui/widgets')
-rw-r--r--src/gui/widgets/window.cpp25
-rw-r--r--src/gui/widgets/window.h6
2 files changed, 19 insertions, 12 deletions
diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp
index 751980d75..e49af5f15 100644
--- a/src/gui/widgets/window.cpp
+++ b/src/gui/widgets/window.cpp
@@ -75,6 +75,7 @@ Window::Window(const std::string &caption, const bool modal,
mCaptionOffsetY(5),
mCaptionAlign(gcn::Graphics::LEFT),
mTitlePadding(4),
+ mResizeHandles(-1),
mRedraw(true),
mCaptionFont(getFont())
{
@@ -195,7 +196,8 @@ void Window::draw(gcn::Graphics *graphics)
// Draw Close Button
if (mCloseButton)
{
- const Image *const button = mSkin->getCloseImage();
+ const Image *const button = mSkin->getCloseImage(
+ mResizeHandles == CLOSE);
if (button)
g->drawImage(button, mCloseRect.x, mCloseRect.y);
}
@@ -388,11 +390,11 @@ void Window::widgetResized(const gcn::Event &event A_UNUSED)
int h = area.height;
mLayout->reflow(w, h);
}
- const bool showClose = mCloseButton && mSkin->getCloseImage();
+ const bool showClose = mCloseButton && mSkin->getCloseImage(false);
const int closePadding = getOption("closePadding");
if (showClose)
{
- const Image *const button = mSkin->getCloseImage();
+ const Image *const button = mSkin->getCloseImage(false);
const int x = getWidth() - button->getWidth() - closePadding;
mCloseRect.x = x;
mCloseRect.y = closePadding;
@@ -406,7 +408,7 @@ void Window::widgetResized(const gcn::Event &event A_UNUSED)
{
int x = getWidth() - button->getWidth() - closePadding;
if (showClose)
- x -= mSkin->getCloseImage()->getWidth() + closePadding;
+ x -= mSkin->getCloseImage(false)->getWidth() + closePadding;
mStickyRect.x = x;
mStickyRect.y = closePadding;
@@ -520,7 +522,7 @@ void Window::mousePressed(gcn::MouseEvent &event)
}
// Handle window resizing
- mouseResize = getResizeHandles(event);
+ mouseResize = getResizeHandles(event) & resizeMask;
if (canMove())
mMoved = !mouseResize;
else
@@ -557,10 +559,10 @@ void Window::mouseMoved(gcn::MouseEvent &event)
if (!gui)
return;
- const int resizeHandles = getResizeHandles(event);
+ mResizeHandles = getResizeHandles(event);
// Changes the custom mouse cursor based on it's current position.
- switch (resizeHandles)
+ switch (mResizeHandles & resizeMask)
{
case BOTTOM | RIGHT:
case TOP | LEFT:
@@ -890,15 +892,16 @@ int Window::getResizeHandles(const gcn::MouseEvent &event)
return 0;
int resizeHandles = 0;
+ const unsigned y = event.getY();
+ const unsigned x = event.getX();
+ if (mCloseRect.isPointInRect(x, y))
+ return CLOSE;
+
if (!mStickyButtonLock || !mSticky)
{
- const unsigned y = event.getY();
-
if (mGrip && (y > mTitleBarHeight || (y < getPadding()
&& mTitleBarHeight > getPadding())))
{
- const unsigned x = event.getX();
-
if (!getWindowArea().isPointInRect(x, y)
&& event.getSource() == this)
{
diff --git a/src/gui/widgets/window.h b/src/gui/widgets/window.h
index 28976f2ca..01519e271 100644
--- a/src/gui/widgets/window.h
+++ b/src/gui/widgets/window.h
@@ -422,9 +422,12 @@ class Window : public gcn::Window, private gcn::WidgetListener
TOP = 0x01,
RIGHT = 0x02,
BOTTOM = 0x04,
- LEFT = 0x08
+ LEFT = 0x08,
+ CLOSE = 0x10
};
+ const int resizeMask = 8 + 4 + 2 + 1;
+
/**
* Ensures the window is on the screen, moving it if necessary. This is
* used by loadWindowState and setVisible(true), and when the screen
@@ -479,6 +482,7 @@ class Window : public gcn::Window, private gcn::WidgetListener
int mCaptionOffsetY;
int mCaptionAlign;
int mTitlePadding;
+ int mResizeHandles;
bool mRedraw;
gcn::Font *mCaptionFont;
};