From 8c62978f845432f8cac046a0d6fd4587c087f22f Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Sat, 12 Apr 2008 18:36:15 +0000 Subject: Fixed display of item shortcut container. gcn::Widget::setWidth is no longer virtual. --- ChangeLog | 7 +++++++ src/gui/itemshortcutcontainer.cpp | 6 ++---- src/gui/itemshortcutcontainer.h | 12 +++++++----- src/gui/itemshortcutwindow.cpp | 18 +++++++----------- src/gui/itemshortcutwindow.h | 12 +++--------- src/gui/scrollarea.cpp | 32 +------------------------------- src/gui/scrollarea.h | 3 ++- 7 files changed, 29 insertions(+), 61 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6f2fe4e7..3017f5eb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2008-04-12 Bjørn Lindeijer + + * src/gui/itemshortcutcontainer.h, src/gui/itemshortcutcontainer.cpp, + src/gui/itemshortcutwindow.cpp, src/gui/scrollarea.h, + src/gui/scrollarea.cpp, src/gui/itemshortcutwindow.h: Fixed display of + item shortcut container. gcn::Widget::setWidth is no longer virtual. + 2008-04-11 David Athay * src/localplayer.cpp, src/beingmanager.h, src/gui/viewport.cpp, diff --git a/src/gui/itemshortcutcontainer.cpp b/src/gui/itemshortcutcontainer.cpp index 0f7d1332..3c03d85a 100644 --- a/src/gui/itemshortcutcontainer.cpp +++ b/src/gui/itemshortcutcontainer.cpp @@ -40,6 +40,7 @@ ItemShortcutContainer::ItemShortcutContainer(): mItemMoved(NULL) { addMouseListener(this); + addWidgetListener(this); ResourceManager *resman = ResourceManager::getInstance(); @@ -119,11 +120,8 @@ ItemShortcutContainer::draw(gcn::Graphics *graphics) } } -void -ItemShortcutContainer::setWidth(int width) +void ItemShortcutContainer::widgetResized(const gcn::Event &event) { - gcn::Widget::setWidth(width); - mGridWidth = getWidth() / mBoxWidth; if (mGridWidth < 1) { mGridWidth = 1; diff --git a/src/gui/itemshortcutcontainer.h b/src/gui/itemshortcutcontainer.h index c69525e0..58f0aea7 100644 --- a/src/gui/itemshortcutcontainer.h +++ b/src/gui/itemshortcutcontainer.h @@ -26,6 +26,7 @@ #include #include +#include class Image; class Item; @@ -35,7 +36,9 @@ class Item; * * \ingroup GUI */ -class ItemShortcutContainer : public gcn::Widget, public gcn::MouseListener +class ItemShortcutContainer : public gcn::Widget, + public gcn::WidgetListener, + public gcn::MouseListener { public: /** @@ -59,10 +62,10 @@ class ItemShortcutContainer : public gcn::Widget, public gcn::MouseListener void draw(gcn::Graphics *graphics); /** - * Sets the width of the container. This is used to determine the new - * height of the container. + * Invoked when a widget changes its size. This is used to determine + * the new height of the container. */ - void setWidth(int width); + void widgetResized(const gcn::Event &event); /** * Handles mouse when dragged. @@ -79,7 +82,6 @@ class ItemShortcutContainer : public gcn::Widget, public gcn::MouseListener */ void mouseReleased(gcn::MouseEvent &event); - int getMaxItems() { return mMaxItems; } diff --git a/src/gui/itemshortcutwindow.cpp b/src/gui/itemshortcutwindow.cpp index efbbe266..3724516a 100644 --- a/src/gui/itemshortcutwindow.cpp +++ b/src/gui/itemshortcutwindow.cpp @@ -45,11 +45,12 @@ ItemShortcutWindow::ItemShortcutWindow() setMaxWidth(mItems->getBoxWidth() * mItems->getMaxItems() + border); setMaxHeight(mItems->getBoxHeight() * mItems->getMaxItems() + border); - mInvenScroll = new ScrollArea(mItems); - mInvenScroll->setPosition(SCROLL_PADDING, SCROLL_PADDING); - mInvenScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); + mScrollArea = new ScrollArea(mItems); + mScrollArea->setPosition(SCROLL_PADDING, SCROLL_PADDING); + mScrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER); + mScrollArea->setOpaque(false); - add(mInvenScroll); + add(mScrollArea); loadWindowState(); } @@ -57,12 +58,7 @@ ItemShortcutWindow::ItemShortcutWindow() ItemShortcutWindow::~ItemShortcutWindow() { delete mItems; - delete mInvenScroll; -} - -void ItemShortcutWindow::logic() -{ - Window::logic(); + delete mScrollArea; } void ItemShortcutWindow::widgetResized(const gcn::Event &event) @@ -71,7 +67,7 @@ void ItemShortcutWindow::widgetResized(const gcn::Event &event) const gcn::Rectangle &area = getChildrenArea(); - mInvenScroll->setSize( + mScrollArea->setSize( area.width - SCROLL_PADDING, area.height - SCROLL_PADDING); } diff --git a/src/gui/itemshortcutwindow.h b/src/gui/itemshortcutwindow.h index 51685e49..9742abdc 100644 --- a/src/gui/itemshortcutwindow.h +++ b/src/gui/itemshortcutwindow.h @@ -26,12 +26,11 @@ #include "window.h" -#include "../guichanfwd.h" - class ItemShortcutContainer; +class ScrollArea; /** - * Inventory dialog. + * A window around the ItemShortcutContainer. * * \ingroup Interface */ @@ -48,11 +47,6 @@ class ItemShortcutWindow : public Window */ ~ItemShortcutWindow(); - /** - * Logic (updates buttons and weight information). - */ - void logic(); - /** * Called whenever the widget changes size. */ @@ -61,7 +55,7 @@ class ItemShortcutWindow : public Window private: ItemShortcutContainer *mItems; - gcn::ScrollArea *mInvenScroll; + ScrollArea *mScrollArea; }; extern ItemShortcutWindow *itemShortcutWindow; diff --git a/src/gui/scrollarea.cpp b/src/gui/scrollarea.cpp index 9c88f8e3..255aa2d8 100644 --- a/src/gui/scrollarea.cpp +++ b/src/gui/scrollarea.cpp @@ -165,14 +165,6 @@ void ScrollArea::logic() void ScrollArea::draw(gcn::Graphics *graphics) { - checkPolicies(); - - int alpha = getBaseColor().a; - gcn::Color highlightColor = getBaseColor() + 0x303030; - highlightColor.a = alpha; - gcn::Color shadowColor = getBaseColor() - 0x303030; - shadowColor.a = alpha; - if (mVBarVisible) { drawUpButton(graphics); @@ -198,29 +190,7 @@ void ScrollArea::draw(gcn::Graphics *graphics) mScrollbarWidth)); } - gcn::Widget *content = getContent(); - - if (content != NULL) - { - graphics->pushClipArea(getChildrenArea()); - - if (content->getFrameSize() > 0) - { - gcn::Rectangle rec = content->getDimension(); - rec.x -= content->getFrameSize(); - rec.y -= content->getFrameSize(); - rec.width += 2 * content->getFrameSize(); - rec.height += 2 * content->getFrameSize(); - graphics->pushClipArea(rec); - content->drawFrame(graphics); - graphics->popClipArea(); - } - - graphics->pushClipArea(content->getDimension()); - content->draw(graphics); - graphics->popClipArea(); - graphics->popClipArea(); - } + drawChildren(graphics); } void ScrollArea::drawFrame(gcn::Graphics *graphics) diff --git a/src/gui/scrollarea.h b/src/gui/scrollarea.h index 9fb7093d..dd1f946d 100644 --- a/src/gui/scrollarea.h +++ b/src/gui/scrollarea.h @@ -34,7 +34,8 @@ class ImageRect; * * \ingroup GUI */ -class ScrollArea : public gcn::ScrollArea { +class ScrollArea : public gcn::ScrollArea +{ public: /** * Constructor. -- cgit v1.2.3-70-g09d2