#pragma once // view_tree — the ONE genuinely pure piece of the D2 view shell: turning REAPER's // linear I_FOLDERDEPTH stream into the parent<->child FolderTree the pure model // consumes. The REAPER reads (GetTrack / GetTrackGUID / I_FOLDERDEPTH) stay in // view.cpp; this tree arithmetic is REAPER-free so the fiddly folder-depth walk is // unit-tested outside the DAW (mirrors capture_paths splitting the path math out). // // PURE MODULE (CLAUDE.md §load-bearing split): NO REAPER types, NO SWELL, NO // vendor/ includes. Standard library + view_mode_model.h (for FolderTree) only. #include #include #include "view_mode_model.h" namespace reasampler { // One track's contribution to the folder walk, read from REAPER in arrange order. // folderDepth is I_FOLDERDEPTH verbatim: 0 = normal, 1 = folder parent (opens a // folder after this track), <0 = closes |folderDepth| folder levels after this // track (-1 last in innermost, -2 last in innermost + next-innermost, ...). struct TrackFolderEntry { std::string guid; int folderDepth = 0; }; // Walks the ordered entries, tracking the open-folder stack, and assigns each // node its immediate parentGuid (empty = top level) and isParent (opens a folder). // Pure and total: tolerates malformed depth streams (a close deeper than the stack // is clamped to empty) so a corrupt/stale project can never fault the shell. FolderTree buildFolderTree(const std::vector& entries); } // namespace reasampler