diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/shortcutwindow.cpp | 38 | ||||
-rw-r--r-- | src/gui/shortcutwindow.h | 4 |
2 files changed, 42 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); + } +} diff --git a/src/gui/shortcutwindow.h b/src/gui/shortcutwindow.h index ceb82ef7b..bdff5ab0d 100644 --- a/src/gui/shortcutwindow.h +++ b/src/gui/shortcutwindow.h @@ -58,6 +58,10 @@ class ShortcutWindow : public Window void widgetHidden(const gcn::Event &event); + void mousePressed(gcn::MouseEvent &event); + + void mouseDragged(gcn::MouseEvent &event); + private: ShortcutWindow(); ShortcutContainer *mItems; |