From 1c8e222c86d050b01f3ee79c439c15535043aea4 Mon Sep 17 00:00:00 2001 From: Paul Walker Date: Fri, 20 Sep 2024 14:59:33 -0400 Subject: [PATCH] Fix a few places where deleting zones left UI with ghosts You know like we didn't reset hot zones, or didn't reset the structure when re-loading a patch on init and stuff like that. Closes #1256 --- .../components/mapping-pane/MappingDisplay.cpp | 7 +++++++ .../components/mapping-pane/ZoneLayoutDisplay.h | 9 +++++++++ src/engine/engine.cpp | 2 ++ src/messaging/client/interaction_messages.h | 1 + src/selection/selection_manager.cpp | 12 +++++++++++- src/selection/selection_manager.h | 1 + 6 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src-ui/app/edit-screen/components/mapping-pane/MappingDisplay.cpp b/src-ui/app/edit-screen/components/mapping-pane/MappingDisplay.cpp index a3c5e093..0ef7a014 100644 --- a/src-ui/app/edit-screen/components/mapping-pane/MappingDisplay.cpp +++ b/src-ui/app/edit-screen/components/mapping-pane/MappingDisplay.cpp @@ -310,14 +310,21 @@ void MappingDisplay::setGroupZoneMappingSummary(const engine::Part::zoneMappingS void MappingDisplay::setLeadSelection(const selection::SelectionManager::ZoneAddress &za) { // but we need to call setLeadZoneBounds to make the hotspots so rename that too + bool foundZone{false}; for (const auto &s : summary) { if (s.first == za) { + foundZone = true; if (mappingZones) mappingZones->setLeadZoneBounds(s.second); } } + + if (mappingZones && !foundZone) + { + mappingZones->clearLeadZoneBounds(); + } } int MappingDisplay::voiceCountFor(const selection::SelectionManager::ZoneAddress &z) diff --git a/src-ui/app/edit-screen/components/mapping-pane/ZoneLayoutDisplay.h b/src-ui/app/edit-screen/components/mapping-pane/ZoneLayoutDisplay.h index 0174c0a9..842991c7 100644 --- a/src-ui/app/edit-screen/components/mapping-pane/ZoneLayoutDisplay.h +++ b/src-ui/app/edit-screen/components/mapping-pane/ZoneLayoutDisplay.h @@ -116,6 +116,15 @@ struct ZoneLayoutDisplay : juce::Component, HasEditor bothHotZones.push_back(corner.translated(0, r.getHeight() - 8)); } + void clearLeadZoneBounds() + { + cacheLastZone = std::nullopt; + lastSelectedZone.clear(); + keyboardHotZones.clear(); + velocityHotZones.clear(); + bothHotZones.clear(); + } + enum MouseState { NONE, diff --git a/src/engine/engine.cpp b/src/engine/engine.cpp index 3e1bd9d3..77c4d8e4 100644 --- a/src/engine/engine.cpp +++ b/src/engine/engine.cpp @@ -1040,6 +1040,7 @@ std::optional Engine::setupUserStorageDirectory() void Engine::sendFullRefreshToClient() const { + SCLOG("Sending full refresh"); auto &cont = getMessageController(); assert(cont->threadingChecker.isSerialThread()); sendMetadataToClient(); @@ -1068,6 +1069,7 @@ void Engine::sendFullRefreshToClient() const *(getMessageController())); } } + getSelectionManager()->sendGroupZoneMappingForSelectedPart(); getSelectionManager()->sendClientDataForLeadSelectionState(); getSelectionManager()->sendSelectedZonesToClient(); getSelectionManager()->sendSelectedPartMacrosToClient(); diff --git a/src/messaging/client/interaction_messages.h b/src/messaging/client/interaction_messages.h index 06cddf27..0fbceafe 100644 --- a/src/messaging/client/interaction_messages.h +++ b/src/messaging/client/interaction_messages.h @@ -87,6 +87,7 @@ CLIENT_TO_SERIAL(RequestHostCallback, c2s_request_host_callback, uint64_t, inline void doResetEngine(bool pl, engine::Engine &e, MessageController &cont) { scxt::patch_io::initFromResourceBundle(e); + e.sendFullRefreshToClient(); } CLIENT_TO_SERIAL(ResetEngine, c2s_reset_engine, bool, doResetEngine(payload, engine, cont)); diff --git a/src/selection/selection_manager.cpp b/src/selection/selection_manager.cpp index 13558fea..2b7803f4 100644 --- a/src/selection/selection_manager.cpp +++ b/src/selection/selection_manager.cpp @@ -76,7 +76,7 @@ void SelectionManager::sendClientDataForLeadSelectionState() } } - if (p >= 0 && g >= 0) + if (p >= 0) { serializationSendToClient(cms::s2c_send_selected_group_zone_mapping_summary, engine.getPatch()->getPart(p)->getZoneMappingSummary(), @@ -247,6 +247,16 @@ void SelectionManager::adjustInternalStateForAction( } } +void SelectionManager::sendGroupZoneMappingForSelectedPart() +{ + if (selectedPart < 0 || selectedPart >= numParts) + return; + + serializationSendToClient(cms::s2c_send_selected_group_zone_mapping_summary, + engine.getPatch()->getPart(selectedPart)->getZoneMappingSummary(), + *(engine.getMessageController())); +} + void SelectionManager::guaranteeConsistencyAfterDeletes(const engine::Engine &engine, bool zoneDeleted, const ZoneAddress &whatIDeleted) diff --git a/src/selection/selection_manager.h b/src/selection/selection_manager.h index 8a9cc7e4..a962c79a 100644 --- a/src/selection/selection_manager.h +++ b/src/selection/selection_manager.h @@ -184,6 +184,7 @@ struct SelectionManager int currentlySelectedPart(const engine::Engine &e) const { return selectedPart; } void sendSelectedZonesToClient(); + void sendGroupZoneMappingForSelectedPart(); void sendClientDataForLeadSelectionState(); void sendDisplayDataForZonesBasedOnLead(int part, int group, int zone); void sendDisplayDataForNoZoneSelected();