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();