diff options
author | Andrei Karas <akaras@inbox.ru> | 2012-01-15 00:25:57 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2012-01-15 00:25:57 +0300 |
commit | f6d283961cfdac6779a6e7ac07de211b44fc7bc7 (patch) | |
tree | c133d33c7a63035be65fbc22f681fd4047796043 /src/gui/shortcutwindow.cpp | |
parent | df9f983d747a430ed9c2fddbbf1496f265dad6a4 (diff) | |
download | manaplus-f6d283961cfdac6779a6e7ac07de211b44fc7bc7.tar.gz manaplus-f6d283961cfdac6779a6e7ac07de211b44fc7bc7.tar.bz2 manaplus-f6d283961cfdac6779a6e7ac07de211b44fc7bc7.tar.xz manaplus-f6d283961cfdac6779a6e7ac07de211b44fc7bc7.zip |
Add support moving shortcuts like windows by header.
Diffstat (limited to 'src/gui/shortcutwindow.cpp')
-rw-r--r-- | src/gui/shortcutwindow.cpp | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/gui/shortcutwindow.cpp b/src/gui/shortcutwindow.cpp index 888b97222..0e968efef 100644 --- a/src/gui/shortcutwindow.cpp +++ b/src/gui/shortcutwindow.cpp @@ -23,6 +23,7 @@ #include "gui/shortcutwindow.h" #include "configuration.h" +#include "logger.h" #include "gui/setup.h" @@ -64,6 +65,9 @@ ShortcutWindow::ShortcutWindow(const std::string &title, setDefaultVisible(false); setSaveVisible(true); + mDragOffsetX = 0; + mDragOffsetY = 0; + setupWindow->registerWindowForReset(this); mTabs = nullptr; @@ -110,6 +114,9 @@ ShortcutWindow::ShortcutWindow(const std::string &title, std::string skinFile, setDefaultVisible(false); setSaveVisible(true); + mDragOffsetX = 0; + mDragOffsetY = 0; + setupWindow->registerWindowForReset(this); mTabs = new TabbedArea; @@ -178,3 +185,34 @@ void ShortcutWindow::widgetHidden(const gcn::Event &event) } } } + +void ShortcutWindow::mousePressed(gcn::MouseEvent &event) +{ + Window::mousePressed(event); + + if (event.isConsumed()) + return; + + if (event.getButton() == gcn::MouseEvent::LEFT) + { + mDragOffsetX = event.getX(); + mDragOffsetY = event.getY(); + } +} + +void ShortcutWindow::mouseDragged(gcn::MouseEvent &event) +{ + Window::mouseDragged(event); + + if (event.isConsumed()) + return; + + if (canMove() && isMovable() && mMoved) + { + int newX = std::max(0, getX() + event.getX() - mDragOffsetX); + int newY = std::max(0, getY() + event.getY() - mDragOffsetY); + newX = std::min(mainGraphics->mWidth - getWidth(), newX); + newY = std::min(mainGraphics->mHeight - getHeight(), newY); + setPosition(newX, newY); + } +} |