summaryrefslogtreecommitdiff
path: root/src/gui/inventory.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/inventory.cpp')
-rw-r--r--src/gui/inventory.cpp26
1 files changed, 17 insertions, 9 deletions
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()