From 4f6ebd0c62299e3ab2d4b4ef70fd2a27d5b4908c Mon Sep 17 00:00:00 2001 From: Guillaume Melquiond Date: Sun, 21 Oct 2007 10:43:01 +0000 Subject: Converted inventory window to layout handler. --- src/gui/inventorywindow.cpp | 60 +++++++++++++-------------------------------- 1 file changed, 17 insertions(+), 43 deletions(-) (limited to 'src/gui/inventorywindow.cpp') 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(); -- cgit v1.2.3-70-g09d2