summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-05-12 18:39:30 +0300
committerAndrei Karas <akaras@inbox.ru>2013-05-12 18:39:30 +0300
commit3198ea5c33e58c71cdd489c32fcc3c864c2fe6e1 (patch)
tree0a249d5d4a1dc0b2a25af86c7862e5e255bc24d8 /src
parent92ddb0de073b591a3f0833406a02c063cff43002 (diff)
downloadplus-3198ea5c33e58c71cdd489c32fcc3c864c2fe6e1.tar.gz
plus-3198ea5c33e58c71cdd489c32fcc3c864c2fe6e1.tar.bz2
plus-3198ea5c33e58c71cdd489c32fcc3c864c2fe6e1.tar.xz
plus-3198ea5c33e58c71cdd489c32fcc3c864c2fe6e1.zip
In chat selection dialog show popup with character name.
Diffstat (limited to 'src')
-rw-r--r--src/gui/widgets/characterdisplay.cpp32
-rw-r--r--src/gui/widgets/characterdisplay.h24
2 files changed, 49 insertions, 7 deletions
diff --git a/src/gui/widgets/characterdisplay.cpp b/src/gui/widgets/characterdisplay.cpp
index 23a22fbbb..dba6be286 100644
--- a/src/gui/widgets/characterdisplay.cpp
+++ b/src/gui/widgets/characterdisplay.cpp
@@ -23,6 +23,7 @@
#include "gui/widgets/characterdisplay.h"
#include "gui/charselectdialog.h"
+#include "gui/textpopup.h"
#include "gui/widgets/label.h"
#include "gui/widgets/layouthelper.h"
@@ -32,9 +33,12 @@
CharacterDisplay::CharacterDisplay(const Widget2 *const widget,
CharSelectDialog *const charSelectDialog) :
Container(widget),
+ gcn::MouseListener(),
+ gcn::WidgetListener(),
mCharacter(nullptr),
mPlayerBox(new PlayerBox(nullptr)),
- mName(new Label(this, "wwwwwwwwwwwwwwwwwwwwwwww"))
+ mName(new Label(this, "wwwwwwwwwwwwwwwwwwwwwwww")),
+ mPopup(new TextPopup)
{
mPlayerBox->setActionEventId("select");
mPlayerBox->addActionListener(charSelectDialog);
@@ -55,6 +59,14 @@ CharacterDisplay::CharacterDisplay(const Widget2 *const widget,
else
setWidth(80);
setHeight(120);
+ addMouseListener(this);
+ addWidgetListener(this);
+}
+
+CharacterDisplay::~CharacterDisplay()
+{
+ delete mPopup;
+ mPopup = nullptr;
}
void CharacterDisplay::setCharacter(Net::Character *const character)
@@ -84,3 +96,21 @@ void CharacterDisplay::update()
distributeResizedEvent();
}
+
+void CharacterDisplay::widgetHidden(const gcn::Event &event)
+{
+ mPopup->setVisible(false);
+}
+
+void CharacterDisplay::mouseExited(gcn::MouseEvent &event)
+{
+ mPopup->setVisible(false);
+}
+
+void CharacterDisplay::mouseMoved(gcn::MouseEvent &event)
+{
+ int mouseX = 0;
+ int mouseY = 0;
+ SDL_GetMouseState(&mouseX, &mouseY);
+ mPopup->show(mouseX, mouseY, mName->getCaption());
+}
diff --git a/src/gui/widgets/characterdisplay.h b/src/gui/widgets/characterdisplay.h
index 5c602b4f9..c7302ef48 100644
--- a/src/gui/widgets/characterdisplay.h
+++ b/src/gui/widgets/characterdisplay.h
@@ -29,12 +29,17 @@
#include "net/charserverhandler.h"
#include "net/net.h"
+#include <guichan/widgetlistener.hpp>
+
class Button;
class CharSelectDialog;
class Label;
class PlayerBox;
+class TextPopup;
-class CharacterDisplay final : public Container
+class CharacterDisplay final : public Container,
+ public gcn::MouseListener,
+ public gcn::WidgetListener
{
public:
CharacterDisplay(const Widget2 *const widget,
@@ -42,6 +47,8 @@ class CharacterDisplay final : public Container
A_DELETE_COPY(CharacterDisplay)
+ virtual ~CharacterDisplay();
+
void setCharacter(Net::Character *const character);
Net::Character *getCharacter() const
@@ -58,15 +65,19 @@ class CharacterDisplay final : public Container
{ return false; }
void focusSelect()
- { }
+ { }
void focusDelete()
- { }
+ { }
void setSelect(bool b)
- {
- mPlayerBox->setSelected(b);
- }
+ { mPlayerBox->setSelected(b); }
+
+ void widgetHidden(const gcn::Event &event) override;
+
+ void mouseExited(gcn::MouseEvent &event) override;
+
+ void mouseMoved(gcn::MouseEvent &event) override;
private:
void update();
@@ -74,6 +85,7 @@ class CharacterDisplay final : public Container
Net::Character *mCharacter;
PlayerBox *mPlayerBox;
Label *mName;
+ TextPopup *mPopup;
};
#endif