summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gui/itemcontainer.cpp15
-rw-r--r--src/gui/itemlinkhandler.cpp13
-rw-r--r--src/gui/itempopup.cpp14
-rw-r--r--src/gui/itempopup.h1
-rw-r--r--src/gui/itemshortcutcontainer.cpp18
5 files changed, 36 insertions, 25 deletions
diff --git a/src/gui/itemcontainer.cpp b/src/gui/itemcontainer.cpp
index 78745158..681bf0ce 100644
--- a/src/gui/itemcontainer.cpp
+++ b/src/gui/itemcontainer.cpp
@@ -19,11 +19,13 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include "itemcontainer.h"
+#include <SDL_mouse.h>
#include <guichan/mouseinput.hpp>
#include <guichan/selectionlistener.hpp>
+#include "itemcontainer.h"
+
#include "../graphics.h"
#include "../inventory.h"
#include "../item.h"
@@ -143,6 +145,7 @@ void ItemContainer::recalculateHeight()
const int rows = (mMaxItems / cols) + (mMaxItems % cols > 0 ? 1 : 0);
const int height = rows * gridHeight + 8;
+
if (height != getHeight())
setHeight(height);
}
@@ -248,16 +251,16 @@ void ItemContainer::mousePressed(gcn::MouseEvent &event)
// Show ItemTooltip
void ItemContainer::mouseMoved(gcn::MouseEvent &event)
{
- Item *item = mInventory->getItem( getSlotIndex(event.getX(), event.getY() ) );
+ Item *item = mInventory->getItem(getSlotIndex(event.getX(), event.getY()));
if (item)
{
- mItemPopup->setPosition(getParent()->getParent()->getX() +
- getParent()->getParent()->getWidth(),
- getParent()->getParent()->getY());
+ int mouseX, mouseY;
+ SDL_GetMouseState(&mouseX, &mouseY);
+
mItemPopup->setItem(item->getInfo());
mItemPopup->setOpaque(false);
- mItemPopup->setVisible(true);
+ mItemPopup->view(mouseX, mouseY);
}
else
{
diff --git a/src/gui/itemlinkhandler.cpp b/src/gui/itemlinkhandler.cpp
index bdfa2ca6..34c12a0c 100644
--- a/src/gui/itemlinkhandler.cpp
+++ b/src/gui/itemlinkhandler.cpp
@@ -19,6 +19,8 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include <SDL_mouse.h>
+
#include "itemlinkhandler.h"
#include "itempopup.h"
@@ -47,14 +49,15 @@ void ItemLinkHandler::handleLink(const std::string &link)
if (id > 0)
{
const ItemInfo &iteminfo = ItemDB::get(id);
+ int mouseX, mouseY;
+
+ SDL_GetMouseState(&mouseX, &mouseY);
+
mItemPopup->setItem(iteminfo);
+
if (mItemPopup->isVisible())
- {
mItemPopup->setVisible(false);
- }
else
- {
- mItemPopup->setVisible(true);
- }
+ mItemPopup->view(mouseX, mouseY);
}
}
diff --git a/src/gui/itempopup.cpp b/src/gui/itempopup.cpp
index c0a75193..81e4607b 100644
--- a/src/gui/itempopup.cpp
+++ b/src/gui/itempopup.cpp
@@ -24,6 +24,7 @@
#include "gui.h"
#include "itempopup.h"
+#include "windowcontainer.h"
#include "widgets/layout.h"
@@ -116,3 +117,16 @@ unsigned int ItemPopup::getNumRows()
{
return mItemDesc->getNumberOfRows(), mItemEffect->getNumberOfRows();
}
+
+void ItemPopup::view(int x, int y)
+{
+ if (windowContainer->getWidth() < (x + getWidth() + 5))
+ x = windowContainer->getWidth() - getWidth();
+ if (windowContainer->getHeight() < (y + getHeight() + 5))
+ y = windowContainer->getHeight() - getHeight();
+ else
+ y = y - getHeight() - 5;
+ setPosition(x, y);
+ setVisible(true);
+ requestMoveToTop();
+}
diff --git a/src/gui/itempopup.h b/src/gui/itempopup.h
index 5b7a911a..4206671e 100644
--- a/src/gui/itempopup.h
+++ b/src/gui/itempopup.h
@@ -36,6 +36,7 @@ class ItemPopup : public Window
void setItem(const ItemInfo &item);
unsigned int getNumRows();
+ void view(int x, int y);
private:
gcn::Label *mItemName;
diff --git a/src/gui/itemshortcutcontainer.cpp b/src/gui/itemshortcutcontainer.cpp
index 950c042a..40b435cc 100644
--- a/src/gui/itemshortcutcontainer.cpp
+++ b/src/gui/itemshortcutcontainer.cpp
@@ -18,6 +18,7 @@
* along with The Mana World; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include <SDL_mouse.h>
#include "itemshortcutcontainer.h"
@@ -223,23 +224,12 @@ void ItemShortcutContainer::mouseMoved(gcn::MouseEvent &event)
if (item)
{
- if (getParent()->getParent()->getWidth() <
- getParent()->getParent()->getHeight())
- {
- mItemPopup->setPosition(getParent()->getParent()->getX() -
- mItemPopup->getWidth(),
- getParent()->getParent()->getY());
- }
- else
- {
- mItemPopup->setPosition(getParent()->getParent()->getX(),
- getParent()->getParent()->getY() +
- getParent()->getParent()->getHeight());
- }
+ int mouseX, mouseY;
+ SDL_GetMouseState(&mouseX, &mouseY);
mItemPopup->setItem(item->getInfo());
mItemPopup->setOpaque(false);
- mItemPopup->setVisible(true);
+ mItemPopup->view(mouseX, mouseY);
}
else
{