summaryrefslogtreecommitdiff
path: root/src/gui/gui.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-05-11 18:39:15 +0300
committerAndrei Karas <akaras@inbox.ru>2013-06-01 12:52:16 +0300
commitf45b10598c4a128510d7c469a6fe669587c01a3e (patch)
tree6a35598bcf52ee3e380890dbac3c2d013b83a2d2 /src/gui/gui.cpp
parent9f85b059aff7c54043d85c3422f02be3570d5050 (diff)
downloadmanaplus-f45b10598c4a128510d7c469a6fe669587c01a3e.tar.gz
manaplus-f45b10598c4a128510d7c469a6fe669587c01a3e.tar.bz2
manaplus-f45b10598c4a128510d7c469a6fe669587c01a3e.tar.xz
manaplus-f45b10598c4a128510d7c469a6fe669587c01a3e.zip
add dragdrop between inventory and outfits window.
Diffstat (limited to 'src/gui/gui.cpp')
-rw-r--r--src/gui/gui.cpp37
1 files changed, 31 insertions, 6 deletions
diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp
index 9418d3e4c..a12163d60 100644
--- a/src/gui/gui.cpp
+++ b/src/gui/gui.cpp
@@ -33,6 +33,7 @@
#include "gui/widgets/window.h"
#include "configuration.h"
+#include "dragdrop.h"
#include "keydata.h"
#include "keyevent.h"
#include "keyinput.h"
@@ -433,14 +434,24 @@ void Gui::draw()
if ((SDL_GetAppState() & SDL_APPMOUSEFOCUS || button & SDL_BUTTON(1))
&& mMouseCursors && mCustomCursor && mMouseCursorAlpha > 0.0f)
{
+ Graphics *g2 = static_cast<Graphics*>(mGraphics);
+ Item *const item = dragDrop.getItem();
+ if (item)
+ {
+ const Image *const image = item->getImage();
+ if (image)
+ {
+ const int tPosX = mouseX - (image->mBounds.w / 2);
+ const int tPosY = mouseY - (image->mBounds.h / 2);
+ g2->drawImage(image, tPosX, tPosY);
+ }
+ }
+
Image *const mouseCursor = mMouseCursors->get(mCursorType);
if (mouseCursor)
{
mouseCursor->setAlpha(mMouseCursorAlpha);
- static_cast<Graphics*>(mGraphics)->drawImage(
- mouseCursor,
- mouseX - 15,
- mouseY - 17);
+ g2->drawImage(mouseCursor, mouseX - 15, mouseY - 17);
}
}
@@ -598,6 +609,7 @@ void Gui::distributeMouseEvent(gcn::Widget* source, int type, int button,
(*it)->mousePressed(mouseEvent);
break;
case gcn::MouseEvent::RELEASED:
+ case 100: // manual hack for release on target after drag
(*it)->mouseReleased(mouseEvent);
break;
case gcn::MouseEvent::WHEEL_MOVED_UP:
@@ -625,6 +637,9 @@ void Gui::distributeMouseEvent(gcn::Widget* source, int type, int button,
widget = parent;
parent = swap->getParent();
+ if (type == gcn::MouseEvent::RELEASED)
+ dragDrop.clear();
+
// If a non modal focused widget has been reach
// and we have modal focus cancel the distribution.
if (mFocusHandler->getModalFocused()
@@ -734,17 +749,27 @@ void Gui::handleMouseReleased(const gcn::MouseInput &mouseInput)
gcn::Widget *sourceWidget = getMouseEventSource(
mouseInput.getX(), mouseInput.getY());
+ int sourceWidgetX, sourceWidgetY;
if (mFocusHandler->getDraggedWidget())
{
if (sourceWidget != mFocusHandler->getLastWidgetPressed())
mFocusHandler->setLastWidgetPressed(nullptr);
+ gcn::Widget *oldWidget = sourceWidget;
sourceWidget = mFocusHandler->getDraggedWidget();
+ if (oldWidget != sourceWidget)
+ {
+ oldWidget->getAbsolutePosition(sourceWidgetX, sourceWidgetY);
+ distributeMouseEvent(oldWidget,
+ 100,
+ mouseInput.getButton(),
+ mouseInput.getX(),
+ mouseInput.getY());
+
+ }
}
- int sourceWidgetX, sourceWidgetY;
sourceWidget->getAbsolutePosition(sourceWidgetX, sourceWidgetY);
-
distributeMouseEvent(sourceWidget,
MouseEvent::RELEASED,
mouseInput.getButton(),