summaryrefslogtreecommitdiff
path: root/src/gui/itemcontainer.cpp
diff options
context:
space:
mode:
authorIra Rice <irarice@gmail.com>2009-01-20 12:35:38 -0700
committerIra Rice <irarice@gmail.com>2009-01-20 12:35:38 -0700
commit7db9e03f34bf150dbcfec981cc3b4105bda92ada (patch)
tree906e18e622f6965822ceaaa191bdebc9d236cef3 /src/gui/itemcontainer.cpp
parentf404997629d9a34f5a15261073536903a59a604c (diff)
downloadmana-7db9e03f34bf150dbcfec981cc3b4105bda92ada.tar.gz
mana-7db9e03f34bf150dbcfec981cc3b4105bda92ada.tar.bz2
mana-7db9e03f34bf150dbcfec981cc3b4105bda92ada.tar.xz
mana-7db9e03f34bf150dbcfec981cc3b4105bda92ada.zip
Changed item popup drawing to be based on the mouse position, not window
position. Signed-off-by: Ira Rice <irarice@gmail.com>
Diffstat (limited to 'src/gui/itemcontainer.cpp')
-rw-r--r--src/gui/itemcontainer.cpp15
1 files changed, 9 insertions, 6 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
{