fix(view): park untagged leaves in non-Arrange modes; refresh TCP/MCP on apply

planToggle now enumerates all leaves in the FolderTree instead of only tagged
membership entries, so untagged (Arrange-member) tracks park in Design and
restore in Arrange. applyMode calls TrackList_AdjustWindows + UpdateArrange so
changes render immediately. Correct the stale "tagged-only" invariant comments.
This commit is contained in:
2026-07-23 04:59:50 -04:00
parent 60add4afc7
commit 4bf394b89c
5 changed files with 130 additions and 22 deletions
+17 -13
View File
@@ -204,15 +204,18 @@ std::set<std::string> ViewModeModel::visibleTracks(const FolderTree& tree,
TogglePlan ViewModeModel::planToggle(const FolderTree& tree, const std::string& targetMode) const {
TogglePlan plan;
// Index the tree so we can classify each tagged GUID (leaf vs parent vs stale).
std::map<std::string, const FolderNode*> byGuid;
for (const auto& node : tree.nodes) byGuid[node.guid] = &node;
for (const auto& [guid, m] : membership_.all()) {
auto it = byGuid.find(guid);
if (it == byGuid.end()) continue; // stale GUID: prune-safe, ignore
if (it->second->isParent) continue; // parents are derived, never parked
if (m.showBoth) continue; // show-both leaves are never parked
// The mode system manages EVERY leaf, not just tagged ones. An untagged leaf is
// an Arrange member (leafBelongsToMode resolves that), so it must park when the
// target mode is not Arrange and restore when it is — the same full park/restore
// a tagged leaf gets. Enumerating the FolderTree (not membership_.all()) is what
// brings untagged leaves — which are absent from the membership index — under
// management. Parents are visibility-only (handled by visibleTracks + the shell's
// parent-visibility pass) and show-both leaves are the always-visible escape;
// neither is ever parked.
for (const auto& node : tree.nodes) {
if (node.isParent) continue; // parents are derived, never parked
const std::string& guid = node.guid;
if (membership_.isShowBoth(guid)) continue; // show-both leaves are never parked
const bool active = leafBelongsToMode(guid, targetMode);
if (active) {
@@ -221,10 +224,11 @@ TogglePlan ViewModeModel::planToggle(const FolderTree& tree, const std::string&
if (const TrackSnapshot* snap = snapshot(guid))
plan.restore.push_back(makeRestorePlan(guid, *snap));
} else {
// Inactive tagged leaf ⇒ park. fxOffline is intentionally empty here:
// the D2 shell expands per-FX offline writes using TrackFX_GetCount.
// The pure model has no access to REAPER FX counts at plan time;
// makeParkPlan(guid, 0) emits only the scalar flags as a result.
// Inactive leaf (tagged into another mode, or untagged in a non-Arrange
// mode) ⇒ park. fxOffline is intentionally empty here: the D2 shell
// expands per-FX offline writes using TrackFX_GetCount. The pure model
// has no access to REAPER FX counts at plan time; makeParkPlan(guid, 0)
// emits only the scalar flags as a result.
plan.park.push_back(makeParkPlan(guid, /*fxCount=*/0));
}
}