Fix Insert-as-FX review findings: id rename, selection-count drift, refusal tooltip, success msg, master-only, reserve test
Renames the permanent action id out of the placement family, makes the button's painted state and pressed outcome share one selection count, surfaces panel-known refusals in the tooltip, reports the target track on success, distinguishes a master-only selection, and pins the overflow-reserve test to the real bar spec.
This commit is contained in:
@@ -16,6 +16,9 @@
|
||||
|
||||
#define REAPERAPI_MINIMAL
|
||||
#define REAPERAPI_WANT_GetSelectedTrack
|
||||
#define REAPERAPI_WANT_GetMasterTrack
|
||||
#define REAPERAPI_WANT_GetMediaTrackInfo_Value
|
||||
#define REAPERAPI_WANT_GetTrackName
|
||||
#define REAPERAPI_WANT_ShowConsoleMsg
|
||||
#include "reaper_plugin_functions.h"
|
||||
|
||||
@@ -27,6 +30,23 @@ void report(const std::string& sentence) {
|
||||
if (ShowConsoleMsg) ShowConsoleMsg(("ReaSampler: " + sentence + "\n").c_str());
|
||||
}
|
||||
|
||||
// GetSelectedTrack ignores the master, so a master-only selection reads back as "no
|
||||
// track" -- distinguish it here for a clearer refusal (core/ui/insert_fx_enable.h).
|
||||
bool isMasterOnlySelected() {
|
||||
if (!GetMasterTrack || !GetMediaTrackInfo_Value) return false;
|
||||
MediaTrack* master = GetMasterTrack(nullptr);
|
||||
return master && GetMediaTrackInfo_Value(master, "I_SELECTED") != 0.0;
|
||||
}
|
||||
|
||||
// "Track N" for an unnamed track, matching REAPER's own convention (GetTrackName,
|
||||
// not P_NAME, for the same reason scope_resolve::trackName picks it).
|
||||
std::string trackDisplayName(MediaTrack* tr) {
|
||||
std::vector<char> buf(256, '\0');
|
||||
if (GetTrackName && GetTrackName(tr, buf.data(), static_cast<int>(buf.size())))
|
||||
return std::string(buf.data());
|
||||
return "the selected track";
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
void doInsertAsFx() {
|
||||
@@ -37,7 +57,8 @@ void doInsertAsFx() {
|
||||
MediaTrack* track = GetSelectedTrack ? GetSelectedTrack(nullptr, 0) : nullptr;
|
||||
|
||||
const ui::InsertFxRefusal refusal =
|
||||
ui::insertFxRefusal(static_cast<int>(selected.size()), track != nullptr);
|
||||
ui::insertFxRefusal(static_cast<int>(selected.size()), track != nullptr,
|
||||
!track && isMasterOnlySelected());
|
||||
if (refusal != ui::InsertFxRefusal::None) {
|
||||
report(ui::insertFxRefusalMessage(refusal));
|
||||
return;
|
||||
@@ -49,6 +70,9 @@ void doInsertAsFx() {
|
||||
if (!performInstrumentDrop(track, wire::buildInstrumentDropPreset(selected.front())))
|
||||
report("could not add ReaSampler 9000 to the selected track -- check the plug-in "
|
||||
"is installed and scanned");
|
||||
else
|
||||
report("added ReaSampler 9000 to \"" + trackDisplayName(track) +
|
||||
"\", loaded with the selected capture");
|
||||
}
|
||||
|
||||
} // namespace reasampler
|
||||
|
||||
Reference in New Issue
Block a user