From 1b416b0f1109bd0b9aeee01d266f3d059cd0feb6 Mon Sep 17 00:00:00 2001 From: bfredl Date: Mon, 23 Oct 2023 17:19:23 +0200 Subject: [PATCH] mod matrix: update display to changed values Also adjust the position if it became invalid after deleting the last patch cable in the list. fixes #428 --- src/deluge/gui/menu_item/patch_cables.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/deluge/gui/menu_item/patch_cables.cpp b/src/deluge/gui/menu_item/patch_cables.cpp index d706935219..acc269baf5 100644 --- a/src/deluge/gui/menu_item/patch_cables.cpp +++ b/src/deluge/gui/menu_item/patch_cables.cpp @@ -18,22 +18,26 @@ void PatchCables::beginSession(MenuItem* navigatedBackwardFrom) { currentValue = 0; if (navigatedBackwardFrom != nullptr) { - PatchCableSet* set = soundEditor.currentParamManager->getPatchCableSet(); currentValue = savedVal; - if (savedVal >= set->numPatchCables) { - currentValue = 0; - } } if (display->haveOLED()) { scrollPos = std::max((int32_t)0, currentValue - 1); } - renderOptions(); readValueAgain(); } void PatchCables::readValueAgain() { + PatchCableSet* set = soundEditor.currentParamManager->getPatchCableSet(); + if (currentValue >= set->numPatchCables) { + // The last patch cable was deleted and it was selected, need to adjust + currentValue = std::max(0, set->numPatchCables - 1); + scrollPos = std::max((int32_t)0, currentValue - 1); + } + + renderOptions(); + if (display->haveOLED()) { renderUIsForOled(); }