gearmulator

Emulation of classic VA synths of the late 90s/2000s that are based on Motorola 56300 family DSPs
Log | Files | Refs | Submodules | README | LICENSE

commit bccd05c6bf6af10cf15afa8255fb32989177a756
parent dcd0c7fe4ce9b1814e90b0dd86ba85dbf970083d
Author: dsp56300 <dsp56300@users.noreply.github.com>
Date:   Wed, 28 Aug 2024 20:00:31 +0200

do not allocate more grid items than we have rows

Diffstat:
Mdoc/changelog.txt | 1+
Msource/jucePluginEditorLib/patchmanager/grid.cpp | 14+++++++++++++-
2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/doc/changelog.txt b/doc/changelog.txt @@ -8,6 +8,7 @@ Framework: - [Fix] Crash when dragging a patch from Patch Manager to a part slot - [Fix] Crash when dragging a patch on empty area in grid view +- [Fix] Drag target slot rectangles displayed in grid view for areas without content NodalRed2x: diff --git a/source/jucePluginEditorLib/patchmanager/grid.cpp b/source/jucePluginEditorLib/patchmanager/grid.cpp @@ -68,7 +68,13 @@ namespace jucePluginEditorLib::patchManager void Grid::setVisibleItemRange(const std::pair<uint32_t, uint32_t>& _range) { const auto& start = _range.first; - const auto& end = start + _range.second; + + auto end = start + _range.second; + + if(end > static_cast<uint32_t>(getNumRows())) + { + end = std::max(0, getNumRows()); + } // move items not in range back to pool first for(auto it = m_items.begin(); it != m_items.end();) @@ -77,6 +83,9 @@ namespace jucePluginEditorLib::patchManager if(index < start || index >= end) { + auto* comp = it->second->getItem(); + if(comp) + comp->setVisible(false); m_itemPool.emplace_back(std::move(it->second)); it = m_items.erase(it); } @@ -109,6 +118,8 @@ namespace jucePluginEditorLib::patchManager if(item->getParentComponent() != &m_itemContainer) m_itemContainer.addAndMakeVisible(item.get()); + else + item->getItem()->setVisible(true); m_items.insert({i, std::move(item)}); } @@ -297,6 +308,7 @@ namespace jucePluginEditorLib::patchManager void Grid::onModelChanged() { updateViewportSize(); + setVisibleItemRange(m_viewport.getItemRangeFromArea(m_viewport.getViewArea())); repaint(); }