diff options
Diffstat (limited to 'src/gui/widgets')
-rw-r--r-- | src/gui/widgets/itemcontainer.cpp | 11 | ||||
-rw-r--r-- | src/gui/widgets/itemcontainer.h | 4 |
2 files changed, 15 insertions, 0 deletions
diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp index ad9f868ad..59d5c8976 100644 --- a/src/gui/widgets/itemcontainer.cpp +++ b/src/gui/widgets/itemcontainer.cpp @@ -901,6 +901,11 @@ void ItemContainer::mouseExited(MouseEvent &event A_UNUSED) void ItemContainer::widgetResized(const Event &event A_UNUSED) { + updateSize(); +} + +void ItemContainer::updateSize() +{ mGridColumns = std::min(mMaxColumns, std::max(1, mDimension.width / mBoxWidth)); if (mGridColumns > mMaxColumns) @@ -1088,3 +1093,9 @@ void ItemContainer::setCellBackgroundImage(const std::string &xmlName) mCellBackgroundImg = Theme::getImageFromThemeXml(xmlName, ""); mRedraw = true; } + +void ItemContainer::setMaxColumns(const int maxColumns) +{ + mMaxColumns = maxColumns; + updateSize(); +} diff --git a/src/gui/widgets/itemcontainer.h b/src/gui/widgets/itemcontainer.h index 4e29cf2c5..b411e0136 100644 --- a/src/gui/widgets/itemcontainer.h +++ b/src/gui/widgets/itemcontainer.h @@ -140,6 +140,8 @@ class ItemContainer final : public Widget, void setCellBackgroundImage(const std::string &xmlName); + void setMaxColumns(const int maxColumns); + private: enum Direction { @@ -173,6 +175,8 @@ class ItemContainer final : public Widget, */ void distributeValueChangedEvent(); + void updateSize(); + /** * Gets the inventory slot index based on the cursor position. * |