#pragma once
// The transient DAW track selection a selected-tracks render requires. REAPER's
// &128 source prints whatever tracks are selected, not the tracks the request
// names, so the render owns the selection for its duration and hands it back.
// The .cpp includes reaper_plugin_functions.h WITHOUT REAPERAPI_IMPLEMENT.

#include <vector>

#include "shell/capture/capture.h"  // MediaTrack fwd

namespace reasampler::capture {

// RAII: selects exactly `tracks`, restores the project's original track selection
// on every exit path (non-destructive — selection flags only, no restructuring).
// Two callers need this and neither has the right selection standing: a ranged
// item capture renders through the items' tracks while the user's track selection
// is unrelated, and re-capture-from-source resolves its tracks by GUID and selects
// nothing at all. An empty `tracks` is a deliberate no-op — forcing an empty
// selection would render silence.
class RenderTrackSelection
{
public:
    explicit RenderTrackSelection(const std::vector<MediaTrack*>& tracks);
    ~RenderTrackSelection();

    RenderTrackSelection(const RenderTrackSelection&)            = delete;
    RenderTrackSelection& operator=(const RenderTrackSelection&) = delete;

private:
    std::vector<MediaTrack*> original_;
    bool                     applied_ = false;
};

}  // namespace reasampler::capture
