#pragma once // Design View's park surface: one track's flag park or restore, plus the park // record that makes the restore non-destructive. FLAG DOMAIN ONLY — a park record's // FX half is captured here (a read) but never written here; the reclaimer owns // every TrackFX_SetOffline, off the switch's synchronous path. #include #include #include "core/view/view_mode_model.h" // Flag / TrackFlagOp — what a park writes // Forward-declared to keep this header SDK-free; the .cpp includes the real SDK header. class MediaTrack; namespace reasampler { // The REAPER track parameter each driven flag addresses. One home for the mapping — // the park's pre-park read, the restore's write and the reconcile's repair must // never disagree about which parameter a Flag names. inline const char* trackFlagParm(Flag f) { switch (f) { case Flag::ShowInTcp: return "B_SHOWINTCP"; case Flag::ShowInMixer: return "B_SHOWINMIXER"; case Flag::MainSend: return "B_MAINSEND"; case Flag::FxEnable: return "I_FXEN"; } return "B_SHOWINTCP"; // unreachable; keeps the compiler quiet } // A track parameter written only when it is not already there. A reapply re-plans // every flag it already applied, so most of what it writes is a value the track // already holds. The read is ASSUMED cheaper than the write it elides (unmeasured); // what it certainly does is keep those no-op writes out of the undo record's mask. // Returns whether it wrote. bool writeIfChanged(MediaTrack* tr, const char* parm, double value); // Parks one inactive leaf: capture the pre-park truth when the model does not // already hold it, then drive the flags. Returns whether anything moved — a project // write or the record. // // The record is the tool's own account of an act it performed, and it is the ONLY // account — nothing infers a park from a live value any more. That is what retired // the old refusal: a track that merely LOOKS parked while no record names it is a // track the tool did not park, so its values are the user's own and capturing them // is right. So the capture is owed exactly when the flag half is not held. // // A still-held FX half is the one thing not re-read: it outlives the flag half the // restore spends, the chain stays offline until the reclaimer onlines it, and // re-reading it there would file the park's own state as the user's. bool parkTrack(ViewModeModel& model, const std::string& guid, MediaTrack* tr, const std::vector& flags); // Restores one returning leaf from its record and spends the record's flag half. // Always true: the record is consumed here, so this apply changed state and is not // repeatable, which is exactly what its one reader (the undo-point decision) asks. bool restoreTrack(ViewModeModel& model, const std::string& guid, MediaTrack* tr, const std::vector& flags); } // namespace reasampler