Q-W1 pt2: core/shell/app relocation + sub-namespaces; one concrete ui::Rect (LTRB fork retired); slot_map split from bank_book; BankIndex→BankModel; 59/59 green

This commit is contained in:
2026-07-28 20:48:56 -04:00
parent 67a41728f3
commit 847936f813
222 changed files with 2247 additions and 2079 deletions
+33 -32
View File
@@ -1,4 +1,4 @@
// Standalone tests for reasampler::vst::knob_deck — no VST3, no REAPER, no framework. Same fast
// Standalone tests for reasampler::instrument::ui::knob_deck — no VST3, no REAPER, no framework. Same fast
// assert loop as the sibling pure tests. Assert the r11 deck layout HARD:
//
// * group width — caption row vs knob row max + padding; row-toggle and caption-toggle widths.
@@ -10,12 +10,13 @@
// * hit-test — knob cell hit (whole cell), toggle segment 0/1 boundaries, blank (-1) cells
// and fence padding miss, outside-deck miss.
#include "../src/vst/knob_deck.h"
#include "../src/core/instrument/ui/knob_deck.h"
#include <cstdio>
#include <vector>
using namespace reasampler::vst;
using namespace reasampler;
using namespace reasampler::instrument::ui;
static int g_fail = 0;
#define CHECK(cond) do { if(!(cond)) { \
@@ -75,20 +76,20 @@ static void testWrapAtNarrowWidthIsDeterministic() {
CHECK(dl.groups.size() == 5);
// Row membership: groups on row 1 share the first top; the wrapped groups sit one row
// pitch lower and restart at the left margin.
const int row0Top = dl.groups[0].box.top;
const int row0Top = dl.groups[0].box.y;
const int row1Top = row0Top + kDeckGroupH + kDeckRowGap;
CHECK(dl.groups[0].box.top == row0Top);
CHECK(dl.groups[1].box.top == row0Top);
CHECK(dl.groups[0].box.y == row0Top);
CHECK(dl.groups[1].box.y == row0Top);
bool sawWrap = false;
for (std::size_t i = 1; i < dl.groups.size(); ++i) {
if (dl.groups[i].box.top == row1Top && dl.groups[i - 1].box.top == row0Top) {
CHECK(dl.groups[i].box.left == 8); // wrapped row restarts at the left edge
if (dl.groups[i].box.y == row1Top && dl.groups[i - 1].box.y == row0Top) {
CHECK(dl.groups[i].box.x == 8); // wrapped row restarts at the left edge
sawWrap = true;
}
}
CHECK(sawWrap);
// Every box stays within the available width (no group straddles the right edge).
for (const auto& g : dl.groups) CHECK(g.box.right <= 8 + 544);
for (const auto& g : dl.groups) CHECK(g.box.right() <= 8 + 544);
}
static void testFirstGroupAlwaysPlaces() {
@@ -103,33 +104,33 @@ static void testGroupInnerGeometry() {
const DeckLayout dl = layoutDeck(deck, 8, 50, 824);
const DeckGroupLayout& amp = dl.groups[0];
// Caption row at the top padding; caption toggle right-anchored inside the box.
CHECK(amp.caption.top == amp.box.top + kDeckGroupPadY);
CHECK(amp.caption.y == amp.box.y + kDeckGroupPadY);
CHECK(amp.captionToggle.id == 100);
CHECK(amp.captionToggle.seg1.right == amp.box.right - kDeckGroupPadX);
CHECK(amp.captionToggle.seg0.right == amp.captionToggle.seg1.left);
CHECK(amp.captionToggle.seg0.width() == 44 && amp.captionToggle.seg1.width() == 44);
CHECK(amp.captionToggle.seg0.height() == kDeckToggleH);
CHECK(amp.captionToggle.seg1.right() == amp.box.right() - kDeckGroupPadX);
CHECK(amp.captionToggle.seg0.right() == amp.captionToggle.seg1.x);
CHECK(amp.captionToggle.seg0.width == 44 && amp.captionToggle.seg1.width == 44);
CHECK(amp.captionToggle.seg0.height == kDeckToggleH);
// The caption text rect stops before the toggle.
CHECK(amp.caption.right <= amp.captionToggle.seg0.left);
CHECK(amp.caption.right() <= amp.captionToggle.seg0.x);
// Cells: five, fixed size, abutting, inside the box, below the caption row.
CHECK(static_cast<int>(amp.cells.size()) == 5);
for (std::size_t i = 0; i < amp.cells.size(); ++i) {
const DeckCellLayout& c = amp.cells[i];
CHECK(c.cell.width() == kDeckCellW && c.cell.height() == kDeckCellH);
CHECK(c.cell.top == amp.box.top + kDeckGroupPadY + kDeckCaptionH + kDeckCaptionGap);
if (i > 0) CHECK(c.cell.left == amp.cells[i - 1].cell.right);
CHECK(c.cell.width == kDeckCellW && c.cell.height == kDeckCellH);
CHECK(c.cell.y == amp.box.y + kDeckGroupPadY + kDeckCaptionH + kDeckCaptionGap);
if (i > 0) CHECK(c.cell.x == amp.cells[i - 1].cell.right());
// Knob square centered horizontally, label band beneath it, both inside the cell.
CHECK(c.knob.width() == kDeckKnobSize && c.knob.height() == kDeckKnobSize);
CHECK(c.knob.left - c.cell.left == c.cell.right - c.knob.right);
CHECK(c.label.top >= c.knob.bottom);
CHECK(c.label.bottom <= c.cell.bottom);
CHECK(c.knob.width == kDeckKnobSize && c.knob.height == kDeckKnobSize);
CHECK(c.knob.x - c.cell.x == c.cell.right() - c.knob.right());
CHECK(c.label.y >= c.knob.bottom());
CHECK(c.label.bottom() <= c.cell.bottom());
}
// VOICE group's row toggle sits after its cell, vertically centered in the cell row.
const DeckGroupLayout& voice = dl.groups[3];
CHECK(voice.rowToggle.id == 104);
CHECK(voice.rowToggle.seg0.left == voice.cells[0].cell.right + kDeckToggleGap);
CHECK(voice.rowToggle.seg0.height() == kDeckToggleH);
CHECK(voice.rowToggle.seg0.top > voice.cells[0].cell.top);
CHECK(voice.rowToggle.seg0.x == voice.cells[0].cell.right() + kDeckToggleGap);
CHECK(voice.rowToggle.seg0.height == kDeckToggleH);
CHECK(voice.rowToggle.seg0.y > voice.cells[0].cell.y);
// MASTER has no toggles.
CHECK(dl.groups[4].captionToggle.id == -1);
CHECK(dl.groups[4].rowToggle.id == -1);
@@ -142,20 +143,20 @@ static void testHitTest() {
// Knob hit: anywhere in the cell (including the label band) resolves to the cell id.
const DeckCellLayout& c0 = amp.cells[0];
DeckHit h = hitTestDeck(dl, c0.cell.left + 1, c0.cell.top + 1);
DeckHit h = hitTestDeck(dl, c0.cell.x + 1, c0.cell.y + 1);
CHECK(h.kind == DeckHitKind::Knob && h.id == 1 && h.segment == -1);
h = hitTestDeck(dl, c0.label.left + 2, c0.label.top + 2);
h = hitTestDeck(dl, c0.label.x + 2, c0.label.y + 2);
CHECK(h.kind == DeckHitKind::Knob && h.id == 1);
// Caption toggle segments 0/1 at their boundary: last px of seg0, first px of seg1.
h = hitTestDeck(dl, amp.captionToggle.seg0.right - 1, amp.captionToggle.seg0.top + 1);
h = hitTestDeck(dl, amp.captionToggle.seg0.right() - 1, amp.captionToggle.seg0.y + 1);
CHECK(h.kind == DeckHitKind::CaptionToggle && h.id == 100 && h.segment == 0);
h = hitTestDeck(dl, amp.captionToggle.seg1.left, amp.captionToggle.seg1.top + 1);
h = hitTestDeck(dl, amp.captionToggle.seg1.x, amp.captionToggle.seg1.y + 1);
CHECK(h.kind == DeckHitKind::CaptionToggle && h.id == 100 && h.segment == 1);
// Row toggle.
const DeckGroupLayout& voice = dl.groups[3];
h = hitTestDeck(dl, voice.rowToggle.seg1.left + 1, voice.rowToggle.seg1.top + 1);
h = hitTestDeck(dl, voice.rowToggle.seg1.x + 1, voice.rowToggle.seg1.y + 1);
CHECK(h.kind == DeckHitKind::RowToggle && h.id == 104 && h.segment == 1);
// A blank cell (id -1) misses even though its rect exists.
@@ -164,11 +165,11 @@ static void testHitTest() {
const DeckLayout tl = layoutDeck(trig, 0, 0, 824);
const DeckCellLayout& blank = tl.groups[0].cells[4];
CHECK(blank.id == -1);
h = hitTestDeck(tl, blank.cell.left + 5, blank.cell.top + 5);
h = hitTestDeck(tl, blank.cell.x + 5, blank.cell.y + 5);
CHECK(h.kind == DeckHitKind::None);
// The fence padding inside the box misses; outside the deck misses.
h = hitTestDeck(dl, amp.box.left + 1, amp.box.bottom - 1);
h = hitTestDeck(dl, amp.box.x + 1, amp.box.bottom() - 1);
CHECK(h.kind == DeckHitKind::None);
h = hitTestDeck(dl, -50, -50);
CHECK(h.kind == DeckHitKind::None);