diff options
author | Andrei Karas <akaras@inbox.ru> | 2017-08-13 00:12:19 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2017-08-13 00:12:19 +0300 |
commit | 906331c5a512e54424b148a2a89590bc03a704ff (patch) | |
tree | 16ca1feda8dc2f005424746421dd455b8b3c6c55 /src/gui/widgets | |
parent | b2a22c500de97b68f0684313b2e6304bf70b728d (diff) | |
download | manaplus-906331c5a512e54424b148a2a89590bc03a704ff.tar.gz manaplus-906331c5a512e54424b148a2a89590bc03a704ff.tar.bz2 manaplus-906331c5a512e54424b148a2a89590bc03a704ff.tar.xz manaplus-906331c5a512e54424b148a2a89590bc03a704ff.zip |
Change height in item containers if some items hidden by filter.
Diffstat (limited to 'src/gui/widgets')
-rw-r--r-- | src/gui/widgets/itemcontainer.cpp | 25 | ||||
-rw-r--r-- | src/gui/widgets/itemcontainer.h | 3 |
2 files changed, 22 insertions, 6 deletions
diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp index f53af32a6..5f1cd4b05 100644 --- a/src/gui/widgets/itemcontainer.cpp +++ b/src/gui/widgets/itemcontainer.cpp @@ -242,6 +242,7 @@ ItemContainer::ItemContainer(const Widget2 *const widget, mSelectionListeners(), mGridColumns(1), mGridRows(1), + mDrawRows(1), mSelectedIndex(-1), mLastUsedSlot(-1), mTag(0), @@ -1080,14 +1081,26 @@ void ItemContainer::adjustHeight() mGridRows = maxRows; } + const int num = updateMatrix(); + if (mShowEmptyRows == ShowEmptyRows_false) + { + mDrawRows = num / mGridColumns; + if (mDrawRows == 0 || num % mGridColumns > 0) + ++mDrawRows; + + maxRows = mDrawRows; + } + else + { + mDrawRows = mGridRows; + } setHeight(maxRows * mBoxHeight); - updateMatrix(); } -void ItemContainer::updateMatrix() +int ItemContainer::updateMatrix() { if (mInventory == nullptr) - return; + return 0; mRedraw = true; delete []mShowMatrix; @@ -1175,8 +1188,10 @@ void ItemContainer::updateMatrix() for (int idx = j * mGridColumns + i; idx < maxSize; idx ++) mShowMatrix[idx] = -1; - for (size_t idx = 0, sz = sortedItems.size(); idx < sz; idx ++) + const int num = CAST_S32(sortedItems.size()); + for (size_t idx = 0, sz = num; idx < sz; idx ++) delete sortedItems[idx]; + return num; } int ItemContainer::getSlotIndex(int x, int y) const @@ -1219,7 +1234,7 @@ int ItemContainer::getSlotByXY(int x, int y) const void ItemContainer::setFilter(const int tag) { mTag = tag; - updateMatrix(); + adjustHeight(); } void ItemContainer::setSortType(const int sortType) diff --git a/src/gui/widgets/itemcontainer.h b/src/gui/widgets/itemcontainer.h index ba640d374..c992c43f5 100644 --- a/src/gui/widgets/itemcontainer.h +++ b/src/gui/widgets/itemcontainer.h @@ -123,7 +123,7 @@ class ItemContainer final : public Widget, void setName(const std::string &str) { mName = str; } - void updateMatrix(); + int updateMatrix(); bool getClickCount() const noexcept2 A_WARN_UNUSED { return mClicks != 0; } @@ -202,6 +202,7 @@ class ItemContainer final : public Widget, SelectionListenerList mSelectionListeners; int mGridColumns; int mGridRows; + int mDrawRows; int mSelectedIndex; int mLastUsedSlot; int mTag; |