From 06afc063b8538b90b8dd8eb662a9ae0e11812963 Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Thu, 16 Jun 2005 01:29:37 +0000 Subject: Fixed window resizing to work properly, and on all edges and corners. --- src/gui/inventory.cpp | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'src/gui/inventory.cpp') diff --git a/src/gui/inventory.cpp b/src/gui/inventory.cpp index 66ccff58..59be88b8 100644 --- a/src/gui/inventory.cpp +++ b/src/gui/inventory.cpp @@ -63,7 +63,7 @@ InventoryWindow::InventoryWindow(): add(itemDescriptionLabel); add(weightLabel); - setResizeable(true); + setResizable(true); setMinWidth(240); setMinHeight(150); @@ -215,18 +215,26 @@ void InventoryWindow::mouseMotion(int mx, int my) void InventoryWindow::updateWidgets() { + int width = getContent()->getWidth(); + int height = getContent()->getHeight(); + int columns = width / 24; + + if (columns < 1) + { + columns = 1; + } + // Resize widgets - useButton->setPosition(8, getHeight() - 24); - dropButton->setPosition(48 + 16, getHeight() - 24); - items->setSize(getWidth() - 24 - 12 - 1, - (INVENTORY_SIZE * 24) / (getWidth() / 24) - 1); - invenScroll->setSize(getWidth() - 16, getHeight() - 90); + useButton->setPosition(8, height - 24); + dropButton->setPosition(48 + 16, height - 24); + items->setSize(width - 24 - 12 - 1, + (INVENTORY_SIZE * 24) / columns - 1); + invenScroll->setSize(width - 16, height - 90); - itemNameLabel->setPosition(8, invenScroll->getY() + invenScroll->getHeight() + 4); + itemNameLabel->setPosition(8, + invenScroll->getY() + invenScroll->getHeight() + 4); itemDescriptionLabel->setPosition(8, itemNameLabel->getY() + itemNameLabel->getHeight() + 4); - - setContentSize(getWidth(), getHeight()); } void InventoryWindow::updateButtons() -- cgit v1.2.3-70-g09d2