diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-05-31 23:59:16 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-05-31 23:59:16 +0300 |
commit | 4e596c5929ff5b773caeda3fcf0de9ca89602b37 (patch) | |
tree | e937dba7b85f2beb2aa9f1d65abedddf6299888e /src | |
parent | 0e37aebef74df6221df8f219572b9abe2ed0f3fd (diff) | |
download | manaplus-4e596c5929ff5b773caeda3fcf0de9ca89602b37.tar.gz manaplus-4e596c5929ff5b773caeda3fcf0de9ca89602b37.tar.bz2 manaplus-4e596c5929ff5b773caeda3fcf0de9ca89602b37.tar.xz manaplus-4e596c5929ff5b773caeda3fcf0de9ca89602b37.zip |
Change mouserelease gui function.
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/gui.cpp | 44 | ||||
-rw-r--r-- | src/gui/gui.h | 2 | ||||
-rw-r--r-- | src/guichan/gui.cpp | 43 | ||||
-rw-r--r-- | src/guichan/include/guichan/gui.hpp | 8 |
4 files changed, 45 insertions, 52 deletions
diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index dcb8d38cf..9418d3e4c 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -437,7 +437,6 @@ void Gui::draw() if (mouseCursor) { mouseCursor->setAlpha(mMouseCursorAlpha); - static_cast<Graphics*>(mGraphics)->drawImage( mouseCursor, mouseX - 15, @@ -730,6 +729,49 @@ void Gui::handleMouseInput() BLOCK_END("Gui::handleMouseInput") } +void Gui::handleMouseReleased(const gcn::MouseInput &mouseInput) +{ + gcn::Widget *sourceWidget = getMouseEventSource( + mouseInput.getX(), mouseInput.getY()); + + if (mFocusHandler->getDraggedWidget()) + { + if (sourceWidget != mFocusHandler->getLastWidgetPressed()) + mFocusHandler->setLastWidgetPressed(nullptr); + + sourceWidget = mFocusHandler->getDraggedWidget(); + } + + int sourceWidgetX, sourceWidgetY; + sourceWidget->getAbsolutePosition(sourceWidgetX, sourceWidgetY); + + distributeMouseEvent(sourceWidget, + MouseEvent::RELEASED, + mouseInput.getButton(), + mouseInput.getX(), + mouseInput.getY()); + + if (mouseInput.getButton() == mLastMousePressButton + && mFocusHandler->getLastWidgetPressed() == sourceWidget) + { + distributeMouseEvent(sourceWidget, + MouseEvent::CLICKED, + mouseInput.getButton(), + mouseInput.getX(), + mouseInput.getY()); + + mFocusHandler->setLastWidgetPressed(nullptr); + } + else + { + mLastMousePressButton = 0; + mClickCount = 0; + } + + if (mFocusHandler->getDraggedWidget()) + mFocusHandler->setDraggedWidget(nullptr); +} + void Gui::addGlobalFocusListener(gcn::FocusListener* focusListener) { mFocusListeners.push_back(focusListener); diff --git a/src/gui/gui.h b/src/gui/gui.h index ed6bf6774..94dbf638f 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -156,6 +156,8 @@ class Gui final : public gcn::Gui protected: void handleMouseMoved(const gcn::MouseInput &mouseInput); + void handleMouseReleased(const gcn::MouseInput &mouseInput); + void handleMouseInput(); void distributeMouseEvent(gcn::Widget* source, int type, int button, diff --git a/src/guichan/gui.cpp b/src/guichan/gui.cpp index d363bdc9b..fcfe58bef 100644 --- a/src/guichan/gui.cpp +++ b/src/guichan/gui.cpp @@ -416,49 +416,6 @@ namespace gcn mouseInput.getY()); } - void Gui::handleMouseReleased(const MouseInput& mouseInput) - { - Widget* sourceWidget = getMouseEventSource( - mouseInput.getX(), mouseInput.getY()); - - if (mFocusHandler->getDraggedWidget()) - { - if (sourceWidget != mFocusHandler->getLastWidgetPressed()) - mFocusHandler->setLastWidgetPressed(nullptr); - - sourceWidget = mFocusHandler->getDraggedWidget(); - } - - int sourceWidgetX, sourceWidgetY; - sourceWidget->getAbsolutePosition(sourceWidgetX, sourceWidgetY); - - distributeMouseEvent(sourceWidget, - MouseEvent::RELEASED, - mouseInput.getButton(), - mouseInput.getX(), - mouseInput.getY()); - - if (mouseInput.getButton() == mLastMousePressButton - && mFocusHandler->getLastWidgetPressed() == sourceWidget) - { - distributeMouseEvent(sourceWidget, - MouseEvent::CLICKED, - mouseInput.getButton(), - mouseInput.getX(), - mouseInput.getY()); - - mFocusHandler->setLastWidgetPressed(nullptr); - } - else - { - mLastMousePressButton = 0; - mClickCount = 0; - } - - if (mFocusHandler->getDraggedWidget()) - mFocusHandler->setDraggedWidget(nullptr); - } - Widget* Gui::getWidgetAt(int x, int y) { // If the widget's parent has no child then we have found the widget.. diff --git a/src/guichan/include/guichan/gui.hpp b/src/guichan/include/guichan/gui.hpp index ea952ec9c..3a30dedd0 100644 --- a/src/guichan/include/guichan/gui.hpp +++ b/src/guichan/include/guichan/gui.hpp @@ -290,14 +290,6 @@ namespace gcn virtual void handleMouseWheelMovedUp(const MouseInput& mouseInput); /** - * Handles mouse released input. - * - * @param mouseInput The mouse input to handle. - * @since 0.6.0 - */ - virtual void handleMouseReleased(const MouseInput& mouseInput); - - /** * Handles modal focus. Modal focus needs to be checked at * each logic iteration as it might be necessary to distribute * mouse entered or mouse exited events. |