52 lines
2.7 KiB
C++
52 lines
2.7 KiB
C++
#pragma once
|
|
// instrument_drop_win — the REAPER-facing shell half of drop-and-load: (a) resolves
|
|
// a screen point to a track + its FX-surface hotspot via REAPER's hit-test API, and
|
|
// (b) on release adds a ReaSampler 9000 instance and applies the dragged capture as
|
|
// its component state via a temp .vstpreset + TrackFX_SetPreset (the earlier
|
|
// "vst_chunk" named-config-parm write was silently unappliable for VST3 — don't
|
|
// revert to it). The pure gesture decision lives in drag_out; the pure payload
|
|
// construction in instrument_drop.
|
|
//
|
|
// LOAD-BEARING: an EXPLICIT user placement-of-the-player gesture — adds a READER of
|
|
// the bank on a track, pointed at an already-captured sample. NEVER captures, NEVER
|
|
// writes the bank, NEVER inserts a timeline item. The only writes are a new FX
|
|
// instance + its component state, both wrapped in one undo block (one Ctrl-Z), plus
|
|
// a transient .vstpreset deleted before returning.
|
|
|
|
#include <cstdint>
|
|
#include <vector>
|
|
|
|
// Declared as a class (matching reaper_plugin.h) so the mangled name agrees, without
|
|
// pulling in the SDK.
|
|
class MediaTrack;
|
|
|
|
namespace reasampler {
|
|
|
|
struct FxDropTarget {
|
|
MediaTrack* track = nullptr; // the track under the pointer (null if none / not a track)
|
|
bool overReaperUi = false; // the point is over REAPER's own window/UI at all
|
|
bool overFxHotspot = false; // specifically over this track's FX button/chain surface
|
|
|
|
bool valid() const { return track != nullptr && overFxHotspot; }
|
|
};
|
|
|
|
// Wraps GetThingFromPoint, whose info string tells us what was hit ("tcp.fx*"/
|
|
// "mcp.fx*" for the TCP/MCP FX button family; "fx_chain"/"fx_N" for the FX-chain and
|
|
// floating windows). `overReaperUi` is true when the point is over REAPER's own UI
|
|
// at all; `overFxHotspot` is true only for a genuine FX-bearing surface (decided by
|
|
// the pure instrument_drop::infoNamesFxHotspot).
|
|
FxDropTarget resolveFxDropTarget(int screenX, int screenY);
|
|
|
|
// Adds a fresh ReaSampler 9000 instance to `track` and applies `presetBytes` as its
|
|
// component state. Wraps add + apply in one REAPER undo block. All-or-nothing: if
|
|
// the preset apply fails after a successful add, the FX instance is removed via
|
|
// TrackFX_Delete before returning false, leaving the track exactly as it was.
|
|
bool performInstrumentDrop(MediaTrack* track, const std::vector<std::uint8_t>& presetBytes);
|
|
|
|
// Same all-or-nothing add+apply contract as performInstrumentDrop but does NOT open
|
|
// its own undo block — the caller owns the undo grouping so persist + FX-add + apply
|
|
// collapses to one Ctrl-Z. The shared inner half performInstrumentDrop wraps.
|
|
bool loadInstrumentOntoTrack(MediaTrack* track, const std::vector<std::uint8_t>& presetBytes);
|
|
|
|
} // namespace reasampler
|