summaryrefslogtreecommitdiff
path: root/src/gui/widgets/itemcontainer.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2017-08-13 00:12:19 +0300
committerAndrei Karas <akaras@inbox.ru>2017-08-13 00:12:19 +0300
commit906331c5a512e54424b148a2a89590bc03a704ff (patch)
tree16ca1feda8dc2f005424746421dd455b8b3c6c55 /src/gui/widgets/itemcontainer.cpp
parentb2a22c500de97b68f0684313b2e6304bf70b728d (diff)
downloadmv-906331c5a512e54424b148a2a89590bc03a704ff.tar.gz
mv-906331c5a512e54424b148a2a89590bc03a704ff.tar.bz2
mv-906331c5a512e54424b148a2a89590bc03a704ff.tar.xz
mv-906331c5a512e54424b148a2a89590bc03a704ff.zip
Change height in item containers if some items hidden by filter.
Diffstat (limited to 'src/gui/widgets/itemcontainer.cpp')
-rw-r--r--src/gui/widgets/itemcontainer.cpp25
1 files changed, 20 insertions, 5 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)