refactor(bank_panel): factor resetDragState() helper; fix WM_CAPTURECHANGED missing instrumentDropTrack reset

All eight drag-state fields cleared through one canonical helper.
WM_CAPTURECHANGED now resets instrumentDropTrack (was missing per doc-contract).
WM_DESTROY and closePanel gain dropKind/dropBankId resets (inert on teardown; correct for symmetry).
This commit is contained in:
2026-07-27 04:46:30 -04:00
parent af557fdc25
commit 6a014114c2
+18 -22
View File
@@ -3035,6 +3035,20 @@ void doReplaceDrop(const std::string& newId, const std::string& oldId,
invalidatePanel(); invalidatePanel();
} }
// Clears all drag-state fields to their resting values. Called from every exit path
// (button-up, WM_CAPTURECHANGED, WM_DESTROY, closePanel) so the set of cleared fields
// stays consistent across all four sites.
void resetDragState() {
g_panel.dragArmed = false;
g_panel.dragging = false;
g_panel.dropKind = DropKind::None;
g_panel.dropBankId.clear();
g_panel.cardGesture = CardGesture::None;
g_panel.dragTargetSlot = -1;
g_panel.dragPrimaryId.clear();
g_panel.instrumentDropTrack = nullptr;
}
// Commits (or abandons) a drag on button-up. The resolved pure CardGesture decides: // Commits (or abandons) a drag on button-up. The resolved pure CardGesture decides:
// * Reorder / Replace -> in-grid, within the source bank (L7); one Ctrl-Z each. // * Reorder / Replace -> in-grid, within the source bank (L7); one Ctrl-Z each.
// * Move / Copy -> the EXISTING cross-bank transfer (unchanged; Ctrl = copy). // * Move / Copy -> the EXISTING cross-bank transfer (unchanged; Ctrl = copy).
@@ -3095,14 +3109,7 @@ void onLBtnUp(int x, int y) {
if (focus >= 0) if (focus >= 0)
g_panel.selection = applyClick(g_panel.selection, focus, false, false, count); g_panel.selection = applyClick(g_panel.selection, focus, false, false, count);
} }
g_panel.dragArmed = false; resetDragState();
g_panel.dragging = false;
g_panel.dropKind = DropKind::None;
g_panel.dropBankId.clear();
g_panel.cardGesture = CardGesture::None;
g_panel.dragTargetSlot = -1;
g_panel.dragPrimaryId.clear();
g_panel.instrumentDropTrack = nullptr; // S17: clear the FX hotspot after the release
invalidatePanel(); invalidatePanel();
} }
@@ -3199,13 +3206,7 @@ WDL_DLGRET dlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
// state lingers, mirroring onLBtnUp's reset (peer-path symmetry). Nothing is // state lingers, mirroring onLBtnUp's reset (peer-path symmetry). Nothing is
// mutated on a cancel; the cursor is restored to the arrow. // mutated on a cancel; the cursor is restored to the arrow.
if (g_panel.dragArmed || g_panel.dragging) { if (g_panel.dragArmed || g_panel.dragging) {
g_panel.dragArmed = false; resetDragState();
g_panel.dragging = false;
g_panel.dropKind = DropKind::None;
g_panel.dropBankId.clear();
g_panel.cardGesture = CardGesture::None;
g_panel.dragTargetSlot = -1;
g_panel.dragPrimaryId.clear();
SetCursor(LoadCursor(nullptr, IDC_ARROW)); SetCursor(LoadCursor(nullptr, IDC_ARROW));
invalidatePanel(); invalidatePanel();
} }
@@ -3227,11 +3228,7 @@ WDL_DLGRET dlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
if (GetCapture() == hwnd) ReleaseCapture(); if (GetCapture() == hwnd) ReleaseCapture();
stopAudition(); stopAudition();
g_panel.selection = Selection{}; g_panel.selection = Selection{};
g_panel.dragArmed = g_panel.dragging = false; resetDragState();
g_panel.cardGesture = CardGesture::None;
g_panel.dragTargetSlot = -1;
g_panel.dragPrimaryId.clear();
g_panel.instrumentDropTrack = nullptr; // S17: drop the FX hotspot on teardown
g_panel.hovered = Hover{}; g_panel.hovered = Hover{};
g_panel.tooltipShown = false; g_panel.tooltipShown = false;
g_panel.hwnd = nullptr; g_panel.hwnd = nullptr;
@@ -3288,8 +3285,7 @@ void closePanel() {
if (GetCapture() == g_panel.hwnd) ReleaseCapture(); if (GetCapture() == g_panel.hwnd) ReleaseCapture();
stopAudition(); stopAudition();
g_panel.selection = Selection{}; g_panel.selection = Selection{};
g_panel.dragArmed = g_panel.dragging = false; resetDragState();
g_panel.instrumentDropTrack = nullptr; // S17: drop the FX hotspot on close
unregisterAccel(); unregisterAccel();
if (g_panel.hwnd) { if (g_panel.hwnd) {
DockWindowRemove(g_panel.hwnd); DockWindowRemove(g_panel.hwnd);