summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/gui/emotepopup.cpp2
-rw-r--r--src/gui/emotepopup.h3
-rw-r--r--src/gui/itempopup.cpp2
-rw-r--r--src/gui/itempopup.h3
-rw-r--r--src/gui/viewport.cpp4
-rw-r--r--src/gui/viewport.h5
-rw-r--r--src/gui/widgets/popup.cpp7
-rw-r--r--src/gui/widgets/popup.h6
-rw-r--r--src/gui/widgets/window.cpp4
9 files changed, 31 insertions, 5 deletions
diff --git a/src/gui/emotepopup.cpp b/src/gui/emotepopup.cpp
index e0c0a409..2161e04c 100644
--- a/src/gui/emotepopup.cpp
+++ b/src/gui/emotepopup.cpp
@@ -119,6 +119,8 @@ void EmotePopup::mousePressed(gcn::MouseEvent &event)
void EmotePopup::mouseMoved(gcn::MouseEvent &event)
{
+ Popup::mouseMoved(event);
+
mHoveredEmoteIndex = getIndexAt(event.getX(), event.getY());
}
diff --git a/src/gui/emotepopup.h b/src/gui/emotepopup.h
index de957925..62a3f24a 100644
--- a/src/gui/emotepopup.h
+++ b/src/gui/emotepopup.h
@@ -42,8 +42,7 @@ namespace gcn {
*
* \ingroup GUI
*/
-class EmotePopup : public Popup,
- public gcn::MouseListener
+class EmotePopup : public Popup
{
public:
/**
diff --git a/src/gui/itempopup.cpp b/src/gui/itempopup.cpp
index c22a9c33..1d41449d 100644
--- a/src/gui/itempopup.cpp
+++ b/src/gui/itempopup.cpp
@@ -168,6 +168,8 @@ gcn::Color ItemPopup::getColor(ItemType type)
void ItemPopup::mouseMoved(gcn::MouseEvent &event)
{
+ Popup::mouseMoved(event);
+
// When the mouse moved on top of the popup, hide it
setVisible(false);
}
diff --git a/src/gui/itempopup.h b/src/gui/itempopup.h
index 79aba523..67d1eb2f 100644
--- a/src/gui/itempopup.h
+++ b/src/gui/itempopup.h
@@ -34,8 +34,7 @@ class TextBox;
/**
* A popup that displays information about an item.
*/
-class ItemPopup : public Popup,
- public gcn::MouseListener
+class ItemPopup : public Popup
{
public:
/**
diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp
index 0ebf0cb9..4622c538 100644
--- a/src/gui/viewport.cpp
+++ b/src/gui/viewport.cpp
@@ -517,3 +517,7 @@ void Viewport::toggleDebugPath()
}
}
+void Viewport::hideBeingPopup()
+{
+ mBeingPopup->setVisible(false);
+}
diff --git a/src/gui/viewport.h b/src/gui/viewport.h
index c4fcece4..3fab607d 100644
--- a/src/gui/viewport.h
+++ b/src/gui/viewport.h
@@ -152,6 +152,11 @@ class Viewport : public WindowContainer, public gcn::MouseListener,
*/
Map *getCurrentMap() const { return mMap; }
+ /**
+ * Hides the BeingPopup.
+ */
+ void hideBeingPopup();
+
private:
/**
* Finds a path from the player to the mouse, and draws it. This is for
diff --git a/src/gui/widgets/popup.cpp b/src/gui/widgets/popup.cpp
index 391b0eed..970b21ec 100644
--- a/src/gui/widgets/popup.cpp
+++ b/src/gui/widgets/popup.cpp
@@ -27,6 +27,7 @@
#include "log.h"
#include "gui/skin.h"
+#include "gui/viewport.h"
#include "gui/widgets/windowcontainer.h"
@@ -186,3 +187,9 @@ void Popup::position(int x, int y)
setVisible(true);
requestMoveToTop();
}
+
+void Popup::mouseMoved(gcn::MouseEvent &event)
+{
+ if (viewport)
+ viewport->hideBeingPopup();
+}
diff --git a/src/gui/widgets/popup.h b/src/gui/widgets/popup.h
index 207a9857..5c9164f6 100644
--- a/src/gui/widgets/popup.h
+++ b/src/gui/widgets/popup.h
@@ -28,6 +28,8 @@
#include "gui/widgets/container.h"
+#include <guichan/mouselistener.hpp>
+
class Skin;
class WindowContainer;
@@ -43,7 +45,7 @@ class WindowContainer;
*
* \ingroup GUI
*/
-class Popup : public Container
+class Popup : public Container, public gcn::MouseListener
{
public:
/**
@@ -94,6 +96,8 @@ class Popup : public Container
*/
void setLocationRelativeTo(gcn::Widget *widget);
+ void mouseMoved(gcn::MouseEvent &event);
+
/**
* Sets the minimum width of the popup.
*/
diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp
index 8505f552..83c918cf 100644
--- a/src/gui/widgets/window.cpp
+++ b/src/gui/widgets/window.cpp
@@ -27,6 +27,7 @@
#include "gui/gui.h"
#include "gui/palette.h"
#include "gui/skin.h"
+#include "gui/viewport.h"
#include "gui/widgets/layout.h"
#include "gui/widgets/resizegrip.h"
@@ -430,6 +431,9 @@ void Window::mouseMoved(gcn::MouseEvent &event)
default:
gui->setCursorType(Gui::CURSOR_POINTER);
}
+
+ if (viewport)
+ viewport->hideBeingPopup();
}
void Window::mouseDragged(gcn::MouseEvent &event)