Skip to content

Commit

Permalink
Fix a few places where deleting zones left UI with ghosts
Browse files Browse the repository at this point in the history
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
  • Loading branch information
baconpaul committed Sep 20, 2024
1 parent 5b39119 commit 1c8e222
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions src/engine/engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1040,6 +1040,7 @@ std::optional<fs::path> Engine::setupUserStorageDirectory()

void Engine::sendFullRefreshToClient() const
{
SCLOG("Sending full refresh");
auto &cont = getMessageController();
assert(cont->threadingChecker.isSerialThread());
sendMetadataToClient();
Expand Down Expand Up @@ -1068,6 +1069,7 @@ void Engine::sendFullRefreshToClient() const
*(getMessageController()));
}
}
getSelectionManager()->sendGroupZoneMappingForSelectedPart();
getSelectionManager()->sendClientDataForLeadSelectionState();
getSelectionManager()->sendSelectedZonesToClient();
getSelectionManager()->sendSelectedPartMacrosToClient();
Expand Down
1 change: 1 addition & 0 deletions src/messaging/client/interaction_messages.h
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down
12 changes: 11 additions & 1 deletion src/selection/selection_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions src/selection/selection_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 1c8e222

Please sign in to comment.