Retire the zone system: one capture = one parameter set, and re-seam the engine and Sample face into bands

This commit is contained in:
2026-07-30 07:15:54 -04:00
parent a689fb75eb
commit 8d4ccbf841
61 changed files with 5416 additions and 8008 deletions
+120
View File
@@ -0,0 +1,120 @@
// Standalone tests for reasampler::instrument::ui::sample_chrome — no VST3, no REAPER, no
// test framework.
//
// Covers: the chrome band's two rows (toolbar over control row, tiling the band exactly);
// the Browse button right-anchored inside the toolbar; the control row's fixed
// right-anchored run in order (preview, velocity cell, curve button, Mono|Stereo) with the
// root strip taking the remainder; the velocity knob centred in its cell above its label;
// and degenerate bands yielding no inverted rects.
#include "../src/core/instrument/ui/sample_bands.h"
#include "../src/core/instrument/ui/sample_chrome.h"
#include <cstdio>
using namespace reasampler;
using namespace reasampler::instrument::ui;
static int g_fail = 0;
#define CHECK(cond) do { if(!(cond)) { \
std::printf("FAIL line %d: %s\n", __LINE__, #cond); ++g_fail; } } while(0)
static constexpr int kKnob = 26; // stands in for knob_deck's kDeckKnobSize
static Rect chromeBand(int w = 840, int h = 620) {
return computeSampleBands(w, h, 120).chrome;
}
static void testRowsTileTheBandExactly() {
const Rect band = chromeBand();
const ChromeRects r = chromeRects(band, kKnob);
CHECK(r.toolbar.y == band.y);
CHECK(r.toolbar.height == kTitleHeight);
CHECK(r.controls.y == r.toolbar.bottom());
CHECK(r.controls.bottom() == band.bottom());
CHECK(r.toolbar.x == band.x && r.toolbar.right() == band.right());
CHECK(r.controls.x == band.x && r.controls.right() == band.right());
}
static void testBrowseIsRightAnchoredInsideTheToolbar() {
const Rect band = chromeBand();
const ChromeRects r = chromeRects(band, kKnob);
CHECK(r.navBrowse.right() == band.right() - kPad);
CHECK(r.navBrowse.width == kNavButtonWidth);
CHECK(r.navBrowse.y >= r.toolbar.y);
CHECK(r.navBrowse.bottom() <= r.toolbar.bottom());
}
static void testControlRunIsOrderedRightToLeftWithoutOverlap() {
const Rect band = chromeBand();
const ChromeRects r = chromeRects(band, kKnob);
// Rightmost first: stereo, mono, curve button, velocity cell, preview, then the strip.
CHECK(r.chanStereo.right() == band.right() - kPad);
CHECK(r.chanMono.right() == r.chanStereo.x);
CHECK(r.curveBtn.right() <= r.chanMono.x);
CHECK(r.velCell.right() <= r.curveBtn.x);
CHECK(r.preview.right() <= r.velCell.x);
CHECK(r.rootStrip.right() <= r.preview.x);
CHECK(r.rootStrip.x == band.x + kPad);
CHECK(r.rootStrip.width > 0);
}
static void testRootStripTakesTheRemainderWidth() {
const ChromeRects narrow = chromeRects(chromeBand(600, 620), kKnob);
const ChromeRects wide = chromeRects(chromeBand(1000, 620), kKnob);
// The fixed run keeps its size; every extra pixel goes to the strip.
CHECK(wide.preview.width == narrow.preview.width);
CHECK(wide.velCell.width == narrow.velCell.width);
CHECK(wide.rootStrip.width == narrow.rootStrip.width + 400);
}
static void testVelocityKnobIsCentredInItsCellAboveTheLabel() {
const ChromeRects r = chromeRects(chromeBand(), kKnob);
CHECK(r.velKnob.width == kKnob && r.velKnob.height == kKnob);
CHECK(r.velKnob.y == r.velCell.y);
const int leftGap = r.velKnob.x - r.velCell.x;
const int rightGap = r.velCell.right() - r.velKnob.right();
CHECK(leftGap == rightGap); // horizontally centred in the cell
CHECK(r.velLabel.y == r.velKnob.bottom());
CHECK(r.velLabel.bottom() == r.velCell.bottom());
CHECK(r.velLabel.x == r.velCell.x && r.velLabel.right() == r.velCell.right());
}
static void testDegenerateBandYieldsNoInvertedRects() {
const ChromeRects empty = chromeRects(Rect{}, kKnob);
CHECK(empty.toolbar.empty() && empty.controls.empty());
CHECK(empty.rootStrip.empty() && empty.preview.empty());
// A band far too narrow for the fixed run: the strip collapses, nothing inverts.
const ChromeRects tiny = chromeRects(Rect::ltrb(0, 0, 40, kTitleHeight + kChromeRowHeight),
kKnob);
CHECK(tiny.rootStrip.right() >= tiny.rootStrip.x);
CHECK(tiny.navBrowse.right() >= tiny.navBrowse.x);
CHECK(tiny.preview.right() >= tiny.preview.x || tiny.preview.width < 0);
}
static void testToolbarOnlyBandStillPlacesTheNav() {
// A band clipped to just the toolbar row: the control row is empty but Browse still
// resolves, so the empty state's call-to-action is never unreachable.
const ChromeRects r = chromeRects(Rect::ltrb(0, 0, 400, kTitleHeight), kKnob);
CHECK(r.toolbar.height == kTitleHeight);
CHECK(r.controls.empty());
CHECK(r.navBrowse.width == kNavButtonWidth);
}
int main() {
testRowsTileTheBandExactly();
testBrowseIsRightAnchoredInsideTheToolbar();
testControlRunIsOrderedRightToLeftWithoutOverlap();
testRootStripTakesTheRemainderWidth();
testVelocityKnobIsCentredInItsCellAboveTheLabel();
testDegenerateBandYieldsNoInvertedRects();
testToolbarOnlyBandStillPlacesTheNav();
if (g_fail == 0) {
std::printf("sample_chrome: all tests passed\n");
return 0;
}
std::printf("sample_chrome: %d failure(s)\n", g_fail);
return 1;
}