diff options
author | Guillaume Melquiond <guillaume.melquiond@gmail.com> | 2007-10-21 10:43:01 +0000 |
---|---|---|
committer | Guillaume Melquiond <guillaume.melquiond@gmail.com> | 2007-10-21 10:43:01 +0000 |
commit | 4f6ebd0c62299e3ab2d4b4ef70fd2a27d5b4908c (patch) | |
tree | a70340529f4ca11df908d5e2e3a5517a52f67592 /src/gui | |
parent | 5020ea5c875a1f8d8c6468f40f0e1f9b4c482045 (diff) | |
download | mana-4f6ebd0c62299e3ab2d4b4ef70fd2a27d5b4908c.tar.gz mana-4f6ebd0c62299e3ab2d4b4ef70fd2a27d5b4908c.tar.bz2 mana-4f6ebd0c62299e3ab2d4b4ef70fd2a27d5b4908c.tar.xz mana-4f6ebd0c62299e3ab2d4b4ef70fd2a27d5b4908c.zip |
Converted inventory window to layout handler.
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/inventorywindow.cpp | 60 | ||||
-rw-r--r-- | src/gui/inventorywindow.h | 9 |
2 files changed, 18 insertions, 51 deletions
diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp index ec241800..9aaba37a 100644 --- a/src/gui/inventorywindow.cpp +++ b/src/gui/inventorywindow.cpp @@ -38,6 +38,8 @@ #include "sdlinput.h" #include "viewport.h" +#include "widgets/layout.h" + #include "../item.h" #include "../localplayer.h" #include "../log.h" @@ -78,30 +80,22 @@ InventoryWindow::InventoryWindow(): mItemEffectLabel = new gcn::Label(strprintf(_("Effect: %s"), "")); mWeightLabel = new gcn::Label( strprintf(_("Total Weight: %d - Maximum Weight: %d"), 0, 0)); - mWeightLabel->setPosition(8, 8); - mInvenScroll->setPosition(8, - mWeightLabel->getY() + mWeightLabel->getHeight() + 5); - - add(mUseButton); - add(mDropButton); - add(mSplitButton); - add(mInvenScroll); - add(mItemNameLabel); - add(mItemDescriptionLabel); - add(mItemEffectLabel); - add(mWeightLabel); - - if (mUseButton->getWidth() < 48) { - mUseButton->setWidth(48); - } - if (mDropButton->getWidth() < 48) { - mDropButton->setWidth(48); - } - if (mSplitButton->getWidth() < 48) { - mSplitButton->setWidth(48); - } - addWindowListener(this); + setPadding(8); + place(0, 0, mWeightLabel, 4); + place(0, 1, mInvenScroll, 4).setPadding(3); + place(0, 2, mItemNameLabel, 4); + place(0, 3, mItemDescriptionLabel, 4); + place(0, 4, mItemEffectLabel, 4); + place(0, 5, mUseButton); + place(1, 5, mDropButton); + place(2, 5, mSplitButton); + Layout &layout = getLayout(); + layout.setColWidth(0, 48); + layout.setColWidth(1, 48); + layout.setColWidth(2, 48); + layout.setRowHeight(1, Layout::FILL); + loadWindowState("Inventory"); } @@ -215,26 +209,6 @@ void InventoryWindow::mouseClicked(gcn::MouseEvent &event) } } -void InventoryWindow::windowResized(const WindowEvent &event) -{ - const gcn::Rectangle area = getChildrenArea(); - - // Resize widgets - mUseButton->setPosition(8, area.height - 24); - mDropButton->setPosition(mUseButton->getWidth() + 16, area.height - 24); - mSplitButton->setPosition( - mUseButton->getWidth() + mDropButton->getWidth() + 24, - area.height - 24); - mInvenScroll->setSize(area.width - 16, area.height - 110); - - mItemNameLabel->setPosition(8, - mInvenScroll->getY() + mInvenScroll->getHeight() + 4); - mItemEffectLabel->setPosition(8, - mItemNameLabel->getY() + mItemNameLabel->getHeight() + 4); - mItemDescriptionLabel->setPosition(8, - mItemEffectLabel->getY() + mItemEffectLabel->getHeight() + 4); -} - void InventoryWindow::updateButtons() { Item *item = mItems->getItem(); diff --git a/src/gui/inventorywindow.h b/src/gui/inventorywindow.h index a9fdadf2..de2c1509 100644 --- a/src/gui/inventorywindow.h +++ b/src/gui/inventorywindow.h @@ -31,7 +31,6 @@ #include "selectionlistener.h" #include "window.h" -#include "windowlistener.h" #include "../guichanfwd.h" @@ -46,8 +45,7 @@ class ItemContainer; class InventoryWindow : public Window, public gcn::ActionListener, public gcn::KeyListener, - public SelectionListener, - public WindowListener + public SelectionListener { public: /** @@ -94,11 +92,6 @@ class InventoryWindow : public Window, */ void selectionChanged(const SelectionEvent &event); - /** - * Called whenever the window is resized. - */ - void windowResized(const WindowEvent &event); - private: void updateButtons(); /**< Updates button states. */ |