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:
2026-08-03 16:43:10 -04:00
parent fcd1ed022c
commit 51c7505dc0
8 changed files with 126 additions and 10 deletions
+43
View File
@@ -229,6 +229,48 @@ static void testOverflowReserveHonouredAcrossWidths() {
CHECK(sawReserveCostAButton);
}
// --- Reserve against the REAL panel spec: names the button and the exact width -----
// roundSpec() above uses clusterGap=16 for hand-checkable pixel math; the panel's actual
// bar (shell/panel/panel_state.h's kBarSpec) uses clusterGap=24. Reproduced literally here
// because this test target is REAPER-free and cannot include that shell header -- keep
// the two in sync by hand if either spec ever changes.
static ActionBarSpec realBarSpec() {
ActionBarSpec s;
s.buttonWidth = 108;
s.buttonGap = 4;
s.clusterGap = 24;
s.sidePad = 8;
s.verticalInset = 3;
return s;
}
// At the real spec plus the real 40 px reserve (28 + 2*6, panel_state.h's kMenuBtnSpec --
// all default-constructed here since its defaults already match), 764 is the narrowest
// band that still shows all six buttons; one pixel narrower drops Insert as FX (flat index
// 5, the trailing Placement button) alone into overflow, leaving its five neighbours intact.
static void testReserveDropsInsertAsFxAtRealWidth() {
const auto clusters = inventory();
const ActionBarSpec spec = realBarSpec();
const MenuButtonSpec menuSpec;
const int reserve = menuButtonReserve(MenuBarRect{0, 0, 900, 34}, menuSpec);
CHECK(reserve == 40);
const int allSixWidth = 764;
{
ActionBarRect action{0, 0, allSixWidth - reserve, 34};
const auto slots = computeBarSlots(action, clusters, spec);
CHECK(slots.size() == 6);
CHECK(slots.back().index == 5); // Insert as FX still visible
}
{
ActionBarRect action{0, 0, allSixWidth - 1 - reserve, 34};
const auto slots = computeBarSlots(action, clusters, spec);
CHECK(slots.size() == 5); // Insert as FX alone dropped
CHECK(slots.back().index == 4); // Insert Conform is now the trailing visible button
}
}
// --- Degenerate --------------------------------------------------------------
static void testDegenerate() {
@@ -356,6 +398,7 @@ int main() {
testOverflowDropsTrailingWhole();
testTooNarrowForAny();
testOverflowReserveHonouredAcrossWidths();
testReserveDropsInsertAsFxAtRealWidth();
testDegenerate();
testHitTestHitsButtons();
testHitTestGapsAreMisses();
+18
View File
@@ -27,6 +27,18 @@ static void testEveryCombination() {
CHECK(insertFxRefusal(3, true) == InsertFxRefusal::MultiCapture);
}
// GetSelectedTrack ignores the master track, so "only the master is selected" is a
// distinct refusal from a plain empty selection -- both are !trackSelected, but the
// message differs so a master-only user isn't told "select a track" when they did.
static void testMasterOnlySelectedIsDistinctFromNoTrack() {
CHECK(insertFxRefusal(1, false, /*masterOnlySelected=*/true) ==
InsertFxRefusal::MasterOnlySelected);
CHECK(insertFxRefusal(1, false, /*masterOnlySelected=*/false) == InsertFxRefusal::NoTrack);
// The payload axis still runs first -- a bad capture count refuses on ITS reason
// even with the master selected.
CHECK(insertFxRefusal(0, false, /*masterOnlySelected=*/true) == InsertFxRefusal::NoCapture);
}
// Exactly one capture is the only count that can run; two is already too many.
static void testOnlyASingleCaptureRuns() {
CHECK(insertFxRefusal(2, true) == InsertFxRefusal::MultiCapture);
@@ -68,18 +80,24 @@ static void testEveryRefusalHasItsOwnSentence() {
const std::string noCap = insertFxRefusalMessage(InsertFxRefusal::NoCapture);
const std::string multi = insertFxRefusalMessage(InsertFxRefusal::MultiCapture);
const std::string noTrk = insertFxRefusalMessage(InsertFxRefusal::NoTrack);
const std::string masterOnly = insertFxRefusalMessage(InsertFxRefusal::MasterOnlySelected);
CHECK(none.empty());
CHECK(!noCap.empty());
CHECK(!multi.empty());
CHECK(!noTrk.empty());
CHECK(!masterOnly.empty());
CHECK(noCap != multi);
CHECK(noCap != noTrk);
CHECK(multi != noTrk);
CHECK(masterOnly != noTrk);
CHECK(masterOnly != noCap);
CHECK(masterOnly != multi);
}
int main() {
testEveryCombination();
testMasterOnlySelectedIsDistinctFromNoTrack();
testOnlyASingleCaptureRuns();
testNegativeCountRefuses();
testButtonBitIsThePayloadAxisOfTheFold();