summaryrefslogtreecommitdiff
path: root/src/gui/shortcutwindow.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-01-15 00:25:57 +0300
committerAndrei Karas <akaras@inbox.ru>2012-01-15 00:25:57 +0300
commitf6d283961cfdac6779a6e7ac07de211b44fc7bc7 (patch)
treec133d33c7a63035be65fbc22f681fd4047796043 /src/gui/shortcutwindow.cpp
parentdf9f983d747a430ed9c2fddbbf1496f265dad6a4 (diff)
downloadManaVerse-f6d283961cfdac6779a6e7ac07de211b44fc7bc7.tar.gz
ManaVerse-f6d283961cfdac6779a6e7ac07de211b44fc7bc7.tar.bz2
ManaVerse-f6d283961cfdac6779a6e7ac07de211b44fc7bc7.tar.xz
ManaVerse-f6d283961cfdac6779a6e7ac07de211b44fc7bc7.zip
Add support moving shortcuts like windows by header.
Diffstat (limited to 'src/gui/shortcutwindow.cpp')
-rw-r--r--src/gui/shortcutwindow.cpp38
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);
+ }
+}