c068279aac
Reads I_FOLDERDEPTH into a FolderTree (pure view_tree helper, unit-tested), snapshots to-be-parked tracks before parking, runs the D1 planner, and applies park/restore flag + per-FX-offline writes under an undo block. Master and mute/solo untouched; acts only on tagged tracks.
42 lines
1.4 KiB
C++
42 lines
1.4 KiB
C++
// view_tree — pure folder-depth walk. See view_tree.h.
|
|
|
|
#include "view_tree.h"
|
|
|
|
namespace reasampler {
|
|
|
|
FolderTree buildFolderTree(const std::vector<TrackFolderEntry>& entries) {
|
|
FolderTree tree;
|
|
tree.nodes.reserve(entries.size());
|
|
|
|
// Stack of currently-open folder-parent GUIDs. The top is the immediate parent
|
|
// of the next track. A folder-parent track opens its folder AFTER contributing
|
|
// its own node (its own parent is the enclosing folder), so the push trails the
|
|
// assignment. A closing track belongs to the folder it closes, so the pop also
|
|
// trails the assignment.
|
|
std::vector<std::string> open;
|
|
|
|
for (const TrackFolderEntry& e : entries) {
|
|
FolderNode node;
|
|
node.guid = e.guid;
|
|
node.parentGuid = open.empty() ? std::string{} : open.back();
|
|
node.isParent = e.folderDepth == 1;
|
|
tree.nodes.push_back(node);
|
|
|
|
if (e.folderDepth == 1) {
|
|
open.push_back(e.guid); // this track's folder opens for what follows
|
|
} else if (e.folderDepth < 0) {
|
|
// Closes |folderDepth| levels after this (already-assigned) track.
|
|
// Clamp to the stack size so a malformed/stale depth stream can't
|
|
// underflow — the walk stays total.
|
|
int levels = -e.folderDepth;
|
|
while (levels-- > 0 && !open.empty()) {
|
|
open.pop_back();
|
|
}
|
|
}
|
|
}
|
|
|
|
return tree;
|
|
}
|
|
|
|
} // namespace reasampler
|