Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a few places where deleting zones left UI with ghosts #1359

Merged
merged 1 commit into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading