summaryrefslogtreecommitdiff
path: root/src/gui/gui.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-09-23 03:33:47 +0300
committerAndrei Karas <akaras@inbox.ru>2012-09-23 03:33:47 +0300
commit48f2996ccc789d740edc4b425a3e00f378a9095a (patch)
tree8117023506896ffbe204eeb61b8cdafaa0463f8e /src/gui/gui.cpp
parent8040656ae1d1dea330754d4595b2737b7eb7959a (diff)
downloadmv-48f2996ccc789d740edc4b425a3e00f378a9095a.tar.gz
mv-48f2996ccc789d740edc4b425a3e00f378a9095a.tar.bz2
mv-48f2996ccc789d740edc4b425a3e00f378a9095a.tar.xz
mv-48f2996ccc789d740edc4b425a3e00f378a9095a.zip
Restore mouse cursor if window set visible and have mouse over.
Diffstat (limited to 'src/gui/gui.cpp')
-rw-r--r--src/gui/gui.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp
index c502ce04a..ce2fcef98 100644
--- a/src/gui/gui.cpp
+++ b/src/gui/gui.cpp
@@ -27,6 +27,7 @@
#include "gui/sdlfont.h"
#include "gui/sdlinput.h"
#include "gui/theme.h"
+#include "gui/viewport.h"
#include "gui/widgets/mouseevent.h"
#include "gui/widgets/window.h"
@@ -605,3 +606,34 @@ void Gui::resetClickCount()
mClickCount = 1;
mLastMousePressTimeStamp = 0;
}
+
+MouseEvent *Gui::createMouseEvent(Window *widget)
+{
+ if (!viewport || !widget)
+ return nullptr;
+
+ int x = 0;
+ int y = 0;
+ int mouseX = 0;
+ int mouseY = 0;
+
+ getAbsolutePosition(widget, x, y);
+ SDL_GetMouseState(&mouseX, &mouseY);
+
+ MouseEvent *mouseEvent = new MouseEvent(widget, mShiftPressed,
+ mControlPressed, mAltPressed, mMetaPressed, 0, 0,
+ mouseX - x, mouseY - y, mClickCount);
+ return mouseEvent;
+}
+
+void Gui::getAbsolutePosition(gcn::Widget *widget, int &x, int &y)
+{
+ x = 0;
+ y = 0;
+ while (widget->getParent())
+ {
+ x += widget->getX();
+ y += widget->getY();
+ widget = widget->getParent();
+ }
+}