Type-enforce the waveform overlay contract, narrow waveformLanes to LaneSplit, fix laneCount/cache/path-fallback bugs
This commit is contained in:
@@ -44,6 +44,10 @@ static bool findNode(const std::vector<EnvVertex>& poly, EnvNode node, EnvVertex
|
||||
// draw at A x@28, H x@47, D x@85, RS x@235, RE x@284.
|
||||
static Rect wideArea() { return Rect::ltrb(20, 10, 1020, 110); }
|
||||
static constexpr double kTotal = 2.0;
|
||||
|
||||
// nodeAtPoint/resolveNodeDrag take the overlay type, not a bare Rect (the distinct-type
|
||||
// enforcement in editor_geometry.h) — this wraps a plain test Rect for them.
|
||||
static OverlayArea overlayOf(const Rect& r) { return OverlayArea{r}; }
|
||||
static const double kGateSecPerPx = 1.0 / gatePxPerSecond(wideArea());
|
||||
|
||||
static AmpEnvelope gateEnv() {
|
||||
@@ -72,10 +76,10 @@ static void testHitGrabsDrawnHandle() {
|
||||
const AmpEnvelope e = gateEnv();
|
||||
const Rect a = wideArea();
|
||||
// AttackEnd draws at x = left+28 (8px base + 0.2s * 102.125 px/s), y = top (level 1).
|
||||
NodeHit h = nodeAtPoint(e, a, kTotal, a.x + 28, a.y);
|
||||
NodeHit h = nodeAtPoint(e, overlayOf(a), kTotal, a.x + 28, a.y);
|
||||
CHECK(h.hit && h.node == EnvNode::AttackEnd);
|
||||
// The sustain node (DecayEnd) at left+85, level 0.5 -> ~top+50.
|
||||
NodeHit s = nodeAtPoint(e, a, kTotal, a.x + 85, a.y + 50);
|
||||
NodeHit s = nodeAtPoint(e, overlayOf(a), kTotal, a.x + 85, a.y + 50);
|
||||
CHECK(s.hit && s.node == EnvNode::DecayEnd);
|
||||
}
|
||||
|
||||
@@ -83,7 +87,7 @@ static void testHitMissesOffEveryNode() {
|
||||
const AmpEnvelope e = gateEnv();
|
||||
const Rect a = wideArea();
|
||||
// A point far from any drawn handle (right of the release ramp, well away from a node).
|
||||
NodeHit h = nodeAtPoint(e, a, kTotal, a.x + 700, a.y + 5);
|
||||
NodeHit h = nodeAtPoint(e, overlayOf(a), kTotal, a.x + 700, a.y + 5);
|
||||
CHECK(!h.hit);
|
||||
}
|
||||
|
||||
@@ -91,11 +95,11 @@ static void testHitSkipsNonDraggableAnchors() {
|
||||
const AmpEnvelope e = gateEnv();
|
||||
const Rect a = wideArea();
|
||||
// Origin draws at (left, bottom-1). Even a pixel-perfect grab there is NOT a draggable node.
|
||||
NodeHit o = nodeAtPoint(e, a, kTotal, a.x, a.bottom() - 1);
|
||||
NodeHit o = nodeAtPoint(e, overlayOf(a), kTotal, a.x, a.bottom() - 1);
|
||||
CHECK(!o.hit);
|
||||
// ReleaseStart draws at (left+235, sustain level ~top+50) — the fixed plateau end. It is
|
||||
// drawing-only -> not grabbable; no other node is within the radius, so this grab misses.
|
||||
NodeHit rs = nodeAtPoint(e, a, kTotal, a.x + 235, a.y + 50);
|
||||
NodeHit rs = nodeAtPoint(e, overlayOf(a), kTotal, a.x + 235, a.y + 50);
|
||||
CHECK(!rs.hit);
|
||||
}
|
||||
|
||||
@@ -107,7 +111,7 @@ static void testHitNearestNodeWinsOverDrawOrder() {
|
||||
AmpEnvelope e = gateEnv();
|
||||
e.holdSeconds = 0.01;
|
||||
const Rect a = wideArea();
|
||||
NodeHit h = nodeAtPoint(e, a, kTotal, a.x + 33, a.y);
|
||||
NodeHit h = nodeAtPoint(e, overlayOf(a), kTotal, a.x + 33, a.y);
|
||||
CHECK(h.hit && h.node == EnvNode::HoldEnd);
|
||||
}
|
||||
|
||||
@@ -119,11 +123,11 @@ static void testGateDefaultsEveryNodeGrabbable() {
|
||||
// ungrabbable in the default state).
|
||||
const AmpEnvelope e; // struct defaults ARE the tier-0 Gate defaults
|
||||
const Rect a = wideArea();
|
||||
const std::vector<EnvVertex> poly = buildEnvelopePolyline(e, a, kTotal);
|
||||
const std::vector<EnvVertex> poly = buildEnvelopePolyline(e, overlayOf(a), kTotal);
|
||||
CHECK(poly.size() == 6);
|
||||
for (const EnvVertex& v : poly) {
|
||||
if (v.node == EnvNode::Origin || v.node == EnvNode::ReleaseStart) continue;
|
||||
const NodeHit h = nodeAtPoint(e, a, kTotal, v.x, v.y);
|
||||
const NodeHit h = nodeAtPoint(e, overlayOf(a), kTotal, v.x, v.y);
|
||||
CHECK(h.hit && h.node == v.node);
|
||||
}
|
||||
}
|
||||
@@ -135,7 +139,7 @@ static void testGateAttackDragMovesOnlyAttack() {
|
||||
const Rect a = wideArea();
|
||||
EnvClampBounds b; // default maxima 4.0s
|
||||
// +50px at the GATE param-domain scale (~0.0098 s/px) on attack. Nothing else moves.
|
||||
AmpEnvelope out = resolveNodeDrag(e, EnvNode::AttackEnd, a, kTotal, b, 50, 0);
|
||||
AmpEnvelope out = resolveNodeDrag(e, EnvNode::AttackEnd, overlayOf(a), kTotal, b, 50, 0);
|
||||
CHECK(near(out.attackSeconds, 0.2 + 50.0 * kGateSecPerPx));
|
||||
CHECK(near(out.holdSeconds, e.holdSeconds));
|
||||
CHECK(near(out.decaySeconds, e.decaySeconds));
|
||||
@@ -149,7 +153,7 @@ static void testGateTimeLowerClampAtZero() {
|
||||
EnvClampBounds b;
|
||||
// Drag attack far LEFT (-500px ~= -4.9s at the gate scale) from 0.2s: clamps to 0, never
|
||||
// negative (monotonic: the segment cannot go below zero).
|
||||
AmpEnvelope out = resolveNodeDrag(e, EnvNode::AttackEnd, a, kTotal, b, -500, 0);
|
||||
AmpEnvelope out = resolveNodeDrag(e, EnvNode::AttackEnd, overlayOf(a), kTotal, b, -500, 0);
|
||||
CHECK(near(out.attackSeconds, 0.0));
|
||||
}
|
||||
|
||||
@@ -160,7 +164,7 @@ static void testGateTimeUpperClampAtSliderMax() {
|
||||
b.maxDecaySeconds = 1.0; // the shell's decay slider tops out at 1.0s
|
||||
// Drag decay far RIGHT (+2000px ~= +19.6s at the gate scale) from 0.3s: clamps to the slider
|
||||
// max 1.0, NOT beyond (the drag can't produce a param the slider couldn't).
|
||||
AmpEnvelope out = resolveNodeDrag(e, EnvNode::DecayEnd, a, kTotal, b, 2000, 0);
|
||||
AmpEnvelope out = resolveNodeDrag(e, EnvNode::DecayEnd, overlayOf(a), kTotal, b, 2000, 0);
|
||||
CHECK(near(out.decaySeconds, 1.0));
|
||||
}
|
||||
|
||||
@@ -170,7 +174,7 @@ static void testGateSustainNodeBothAxes() {
|
||||
EnvClampBounds b;
|
||||
// DecayEnd: +100px X at the gate timed scale on decay; +bottom-ward Y LOWERS the level. Level
|
||||
// span is 99 px for [0,1]; drag DOWN by ~10px (positive dy) lowers sustain by ~10/99 ~= 0.101.
|
||||
AmpEnvelope out = resolveNodeDrag(e, EnvNode::DecayEnd, a, kTotal, b, 100, 10);
|
||||
AmpEnvelope out = resolveNodeDrag(e, EnvNode::DecayEnd, overlayOf(a), kTotal, b, 100, 10);
|
||||
CHECK(near(out.decaySeconds, 0.3 + 100.0 * kGateSecPerPx));
|
||||
CHECK(out.sustainLevel < e.sustainLevel); // dragged DOWN -> lower sustain
|
||||
CHECK(near(out.sustainLevel, 0.5 - 10.0 / 99.0, 1e-6));
|
||||
@@ -181,10 +185,10 @@ static void testGateSustainLevelClamps01() {
|
||||
const Rect a = wideArea();
|
||||
EnvClampBounds b;
|
||||
// Drag sustain UP hard (dy very negative): clamps to 1.0.
|
||||
AmpEnvelope up = resolveNodeDrag(e, EnvNode::DecayEnd, a, kTotal, b, 0, -10000);
|
||||
AmpEnvelope up = resolveNodeDrag(e, EnvNode::DecayEnd, overlayOf(a), kTotal, b, 0, -10000);
|
||||
CHECK(near(up.sustainLevel, 1.0));
|
||||
// Drag sustain DOWN hard (dy very positive): clamps to 0.0.
|
||||
AmpEnvelope dn = resolveNodeDrag(e, EnvNode::DecayEnd, a, kTotal, b, 0, 10000);
|
||||
AmpEnvelope dn = resolveNodeDrag(e, EnvNode::DecayEnd, overlayOf(a), kTotal, b, 0, 10000);
|
||||
CHECK(near(dn.sustainLevel, 0.0));
|
||||
}
|
||||
|
||||
@@ -193,7 +197,7 @@ static void testGateTimeOnlyNodeIgnoresY() {
|
||||
const Rect a = wideArea();
|
||||
EnvClampBounds b;
|
||||
// HoldEnd is time-only: a big Y delta must NOT change any level (there is no level to change).
|
||||
AmpEnvelope out = resolveNodeDrag(e, EnvNode::HoldEnd, a, kTotal, b, 0, 500);
|
||||
AmpEnvelope out = resolveNodeDrag(e, EnvNode::HoldEnd, overlayOf(a), kTotal, b, 0, 500);
|
||||
CHECK(near(out.holdSeconds, e.holdSeconds)); // dx 0 -> no time change either
|
||||
CHECK(near(out.sustainLevel, e.sustainLevel)); // Y ignored for a time-only node
|
||||
}
|
||||
@@ -204,17 +208,17 @@ static void testGateReleaseEndGrabAndDrag() {
|
||||
const AmpEnvelope e = gateEnv();
|
||||
const Rect a = wideArea();
|
||||
EnvClampBounds b;
|
||||
NodeHit h = nodeAtPoint(e, a, kTotal, a.x + 284, a.bottom() - 1);
|
||||
NodeHit h = nodeAtPoint(e, overlayOf(a), kTotal, a.x + 284, a.bottom() - 1);
|
||||
CHECK(h.hit && h.node == EnvNode::ReleaseEnd);
|
||||
// Dragging it RIGHT lengthens the release at the gate timed scale; only release changes.
|
||||
AmpEnvelope out = resolveNodeDrag(e, EnvNode::ReleaseEnd, a, kTotal, b, 85, 0);
|
||||
AmpEnvelope out = resolveNodeDrag(e, EnvNode::ReleaseEnd, overlayOf(a), kTotal, b, 85, 0);
|
||||
CHECK(near(out.releaseSeconds, 0.4 + 85.0 * kGateSecPerPx));
|
||||
CHECK(near(out.sustainLevel, e.sustainLevel));
|
||||
CHECK(near(out.decaySeconds, e.decaySeconds));
|
||||
// Far LEFT clamps to 0; far RIGHT clamps to the slider max.
|
||||
AmpEnvelope lo = resolveNodeDrag(e, EnvNode::ReleaseEnd, a, kTotal, b, -2000, 0);
|
||||
AmpEnvelope lo = resolveNodeDrag(e, EnvNode::ReleaseEnd, overlayOf(a), kTotal, b, -2000, 0);
|
||||
CHECK(near(lo.releaseSeconds, 0.0));
|
||||
AmpEnvelope hi = resolveNodeDrag(e, EnvNode::ReleaseEnd, a, kTotal, b, 5000, 0);
|
||||
AmpEnvelope hi = resolveNodeDrag(e, EnvNode::ReleaseEnd, overlayOf(a), kTotal, b, 5000, 0);
|
||||
CHECK(near(hi.releaseSeconds, b.maxReleaseSeconds));
|
||||
}
|
||||
|
||||
@@ -230,16 +234,16 @@ static void testGateDragRoundTripTracksPixels() {
|
||||
for (EnvNode n : {EnvNode::AttackEnd, EnvNode::HoldEnd, EnvNode::DecayEnd,
|
||||
EnvNode::ReleaseEnd}) {
|
||||
EnvVertex before, after;
|
||||
CHECK(findNode(buildEnvelopePolyline(e, a, kTotal), n, before));
|
||||
const AmpEnvelope edited = resolveNodeDrag(e, n, a, kTotal, b, dx, 0);
|
||||
CHECK(findNode(buildEnvelopePolyline(edited, a, kTotal), n, after));
|
||||
CHECK(findNode(buildEnvelopePolyline(e, overlayOf(a), kTotal), n, before));
|
||||
const AmpEnvelope edited = resolveNodeDrag(e, n, overlayOf(a), kTotal, b, dx, 0);
|
||||
CHECK(findNode(buildEnvelopePolyline(edited, overlayOf(a), kTotal), n, after));
|
||||
CHECK(std::abs((after.x - before.x) - dx) <= 1);
|
||||
}
|
||||
// The sustain node's Y axis tracks too: +10px down moves the drawn vertex ~10px down.
|
||||
EnvVertex before, after;
|
||||
CHECK(findNode(buildEnvelopePolyline(e, a, kTotal), EnvNode::DecayEnd, before));
|
||||
const AmpEnvelope edited = resolveNodeDrag(e, EnvNode::DecayEnd, a, kTotal, b, 0, 10);
|
||||
CHECK(findNode(buildEnvelopePolyline(edited, a, kTotal), EnvNode::DecayEnd, after));
|
||||
CHECK(findNode(buildEnvelopePolyline(e, overlayOf(a), kTotal), EnvNode::DecayEnd, before));
|
||||
const AmpEnvelope edited = resolveNodeDrag(e, EnvNode::DecayEnd, overlayOf(a), kTotal, b, 0, 10);
|
||||
CHECK(findNode(buildEnvelopePolyline(edited, overlayOf(a), kTotal), EnvNode::DecayEnd, after));
|
||||
CHECK(std::abs((after.y - before.y) - 10) <= 1);
|
||||
}
|
||||
|
||||
@@ -250,7 +254,7 @@ static void testTriggerFadeInIsFractionOfPlaySpan() {
|
||||
const Rect a = wideArea();
|
||||
EnvClampBounds b;
|
||||
// +50px = +0.1s on the play timeline = +0.1/1.0 = +0.1 fraction. fadeIn 0.2 -> 0.3.
|
||||
AmpEnvelope out = resolveNodeDrag(e, EnvNode::FadeInEnd, a, kTotal, b, 50, 0);
|
||||
AmpEnvelope out = resolveNodeDrag(e, EnvNode::FadeInEnd, overlayOf(a), kTotal, b, 50, 0);
|
||||
CHECK(near(out.fadeInFraction, 0.3));
|
||||
CHECK(near(out.fadeOutFraction, e.fadeOutFraction)); // unchanged
|
||||
}
|
||||
@@ -263,7 +267,7 @@ static void testTriggerFadesCannotCross() {
|
||||
EnvClampBounds b;
|
||||
// Drag fade-in far RIGHT (+2000px): would push fadeIn well past 1-fadeOut=0.7, but the mutual
|
||||
// clamp caps it at 0.7 so the fade nodes never cross (monotonic on the play timeline).
|
||||
AmpEnvelope out = resolveNodeDrag(e, EnvNode::FadeInEnd, a, kTotal, b, 2000, 0);
|
||||
AmpEnvelope out = resolveNodeDrag(e, EnvNode::FadeInEnd, overlayOf(a), kTotal, b, 2000, 0);
|
||||
CHECK(near(out.fadeInFraction, 0.7));
|
||||
CHECK(near(out.fadeOutFraction, 0.3));
|
||||
}
|
||||
@@ -274,7 +278,7 @@ static void testTriggerFadeOutMovesOppositePixelDelta() {
|
||||
EnvClampBounds b;
|
||||
// FadeOutStart sits at (1-fadeOut) of the span; dragging it LEFT (-50px) LENGTHENS the fade-out.
|
||||
// -50px = -0.1s = -0.1 fraction on the span, applied OPPOSITE -> fadeOut 0.2 -> 0.3.
|
||||
AmpEnvelope out = resolveNodeDrag(e, EnvNode::FadeOutStart, a, kTotal, b, -50, 0);
|
||||
AmpEnvelope out = resolveNodeDrag(e, EnvNode::FadeOutStart, overlayOf(a), kTotal, b, -50, 0);
|
||||
CHECK(near(out.fadeOutFraction, 0.3));
|
||||
CHECK(near(out.fadeInFraction, e.fadeInFraction));
|
||||
}
|
||||
@@ -290,14 +294,14 @@ static void testTriggerZeroFadeOutGrabbableAtRightEdge() {
|
||||
e.fadeOutFraction = 0.0;
|
||||
const Rect a = wideArea();
|
||||
EnvClampBounds b;
|
||||
NodeHit h = nodeAtPoint(e, a, kTotal, a.right() - 1, a.y);
|
||||
NodeHit h = nodeAtPoint(e, overlayOf(a), kTotal, a.right() - 1, a.y);
|
||||
CHECK(h.hit && h.node == EnvNode::FadeOutStart);
|
||||
// -100px = -0.2s on the 2.0s played span, applied OPPOSITE -> fadeOut 0.0 -> 0.1.
|
||||
AmpEnvelope out = resolveNodeDrag(e, EnvNode::FadeOutStart, a, kTotal, b, -100, 0);
|
||||
AmpEnvelope out = resolveNodeDrag(e, EnvNode::FadeOutStart, overlayOf(a), kTotal, b, -100, 0);
|
||||
CHECK(near(out.fadeOutFraction, 0.1));
|
||||
CHECK(near(out.lengthFraction, e.lengthFraction)); // length untouched
|
||||
// LengthEnd sits at the same x but level 0 (bottom row) — grabbable at ITS drawn point.
|
||||
NodeHit le = nodeAtPoint(e, a, kTotal, a.right() - 1, a.bottom() - 1);
|
||||
NodeHit le = nodeAtPoint(e, overlayOf(a), kTotal, a.right() - 1, a.bottom() - 1);
|
||||
CHECK(le.hit && le.node == EnvNode::LengthEnd);
|
||||
}
|
||||
|
||||
@@ -306,10 +310,10 @@ static void testTriggerLengthClampsAtMax() {
|
||||
const Rect a = wideArea();
|
||||
EnvClampBounds b; // maxLengthFraction 1.0
|
||||
// LengthEnd maps to a fraction of the WHOLE sample: +2000px = +4.0s = +2.0 fraction, clamps 1.0.
|
||||
AmpEnvelope out = resolveNodeDrag(e, EnvNode::LengthEnd, a, kTotal, b, 2000, 0);
|
||||
AmpEnvelope out = resolveNodeDrag(e, EnvNode::LengthEnd, overlayOf(a), kTotal, b, 2000, 0);
|
||||
CHECK(near(out.lengthFraction, 1.0));
|
||||
// Drag far LEFT clamps to 0.
|
||||
AmpEnvelope lo = resolveNodeDrag(e, EnvNode::LengthEnd, a, kTotal, b, -2000, 0);
|
||||
AmpEnvelope lo = resolveNodeDrag(e, EnvNode::LengthEnd, overlayOf(a), kTotal, b, -2000, 0);
|
||||
CHECK(near(lo.lengthFraction, 0.0));
|
||||
}
|
||||
|
||||
@@ -319,9 +323,9 @@ static void testNonDraggableNodeNoMotion() {
|
||||
const AmpEnvelope e = gateEnv();
|
||||
const Rect a = wideArea();
|
||||
EnvClampBounds b;
|
||||
AmpEnvelope o = resolveNodeDrag(e, EnvNode::Origin, a, kTotal, b, 500, 500);
|
||||
AmpEnvelope o = resolveNodeDrag(e, EnvNode::Origin, overlayOf(a), kTotal, b, 500, 500);
|
||||
CHECK(near(o.attackSeconds, e.attackSeconds) && near(o.sustainLevel, e.sustainLevel));
|
||||
AmpEnvelope rs = resolveNodeDrag(e, EnvNode::ReleaseStart, a, kTotal, b, 500, 500);
|
||||
AmpEnvelope rs = resolveNodeDrag(e, EnvNode::ReleaseStart, overlayOf(a), kTotal, b, 500, 500);
|
||||
CHECK(near(rs.releaseSeconds, e.releaseSeconds));
|
||||
}
|
||||
|
||||
@@ -329,9 +333,9 @@ static void testDegenerateAreaNoMotion() {
|
||||
const AmpEnvelope e = gateEnv();
|
||||
EnvClampBounds b;
|
||||
const Rect zeroW = Rect::ltrb(0, 0, 0, 100);
|
||||
AmpEnvelope o1 = resolveNodeDrag(e, EnvNode::AttackEnd, zeroW, kTotal, b, 500, 0);
|
||||
AmpEnvelope o1 = resolveNodeDrag(e, EnvNode::AttackEnd, overlayOf(zeroW), kTotal, b, 500, 0);
|
||||
CHECK(near(o1.attackSeconds, e.attackSeconds));
|
||||
AmpEnvelope o2 = resolveNodeDrag(e, EnvNode::AttackEnd, wideArea(), 0.0, b, 500, 0); // no time
|
||||
AmpEnvelope o2 = resolveNodeDrag(e, EnvNode::AttackEnd, overlayOf(wideArea()), 0.0, b, 500, 0); // no time
|
||||
CHECK(near(o2.attackSeconds, e.attackSeconds));
|
||||
}
|
||||
|
||||
@@ -342,14 +346,14 @@ static void testCrossModeNodeNoMotion() {
|
||||
// inert on a Gate envelope.
|
||||
EnvClampBounds b;
|
||||
const AmpEnvelope t = triggerEnv();
|
||||
AmpEnvelope out = resolveNodeDrag(t, EnvNode::ReleaseEnd, wideArea(), kTotal, b, 50, 0);
|
||||
AmpEnvelope out = resolveNodeDrag(t, EnvNode::ReleaseEnd, overlayOf(wideArea()), kTotal, b, 50, 0);
|
||||
CHECK(near(out.releaseSeconds, t.releaseSeconds));
|
||||
const AmpEnvelope g = gateEnv();
|
||||
out = resolveNodeDrag(g, EnvNode::FadeInEnd, wideArea(), kTotal, b, 50, 0);
|
||||
out = resolveNodeDrag(g, EnvNode::FadeInEnd, overlayOf(wideArea()), kTotal, b, 50, 0);
|
||||
CHECK(near(out.fadeInFraction, g.fadeInFraction));
|
||||
// And the zero-height baseline's ReleaseEnd is not even reported grabbable in Trigger mode.
|
||||
const Rect flat = Rect::ltrb(0, 0, 100, 0);
|
||||
const NodeHit h = nodeAtPoint(t, flat, kTotal, 99, 0);
|
||||
const NodeHit h = nodeAtPoint(t, overlayOf(flat), kTotal, 99, 0);
|
||||
CHECK(!h.hit);
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,10 @@ static int g_fail = 0;
|
||||
#define CHECK(cond) do { if(!(cond)) { \
|
||||
std::printf("FAIL line %d: %s\n", __LINE__, #cond); ++g_fail; } } while(0)
|
||||
|
||||
// buildEnvelopePolyline takes the overlay type, not a bare Rect (the distinct-type
|
||||
// enforcement in editor_geometry.h) — this wraps a plain test Rect for it.
|
||||
static OverlayArea overlayOf(const Rect& r) { return OverlayArea{r}; }
|
||||
|
||||
// A comfortable overlay area: 1000px wide, 100px tall, offset so left/top != 0 (catches origin
|
||||
// bugs). Under levelToY the level span is height-1 = 99 rows.
|
||||
static Rect wideArea() { return Rect::ltrb(20, 10, 1020, 110); } // width 1000, height 100
|
||||
@@ -112,7 +116,7 @@ static void testGateNodeOrderAndLevels() {
|
||||
env.sustainLevel = 0.5;
|
||||
env.releaseSeconds = 0.4;
|
||||
const Rect a = wideArea();
|
||||
const std::vector<EnvVertex> poly = buildEnvelopePolyline(env, a, 2.0);
|
||||
const std::vector<EnvVertex> poly = buildEnvelopePolyline(env, overlayOf(a), 2.0);
|
||||
|
||||
// Six vertices, in draw order.
|
||||
CHECK(poly.size() == 6);
|
||||
@@ -147,7 +151,7 @@ static void testGateSchematicPlacement() {
|
||||
env.sustainLevel = 0.5;
|
||||
env.releaseSeconds = 0.4;
|
||||
const Rect a = wideArea();
|
||||
const std::vector<EnvVertex> poly = buildEnvelopePolyline(env, a, 2.0);
|
||||
const std::vector<EnvVertex> poly = buildEnvelopePolyline(env, overlayOf(a), 2.0);
|
||||
|
||||
EnvVertex v;
|
||||
CHECK(findNode(poly, EnvNode::AttackEnd, v) && v.x == a.x + 28);
|
||||
@@ -169,7 +173,7 @@ static void testGateLayoutIndependentOfSampleDuration() {
|
||||
env.sustainLevel = 0.5;
|
||||
env.releaseSeconds = 0.06;
|
||||
const Rect a = wideArea();
|
||||
CHECK(buildEnvelopePolyline(env, a, 0.3) == buildEnvelopePolyline(env, a, 10.0));
|
||||
CHECK(buildEnvelopePolyline(env, overlayOf(a), 0.3) == buildEnvelopePolyline(env, overlayOf(a), 10.0));
|
||||
}
|
||||
|
||||
static void testGateMinSeparationAtDefaults() {
|
||||
@@ -178,7 +182,7 @@ static void testGateMinSeparationAtDefaults() {
|
||||
// renders on top of its neighbour, so each is individually grabbable.
|
||||
const AmpEnvelope env; // struct defaults ARE the tier-0 Gate defaults
|
||||
const Rect a = wideArea();
|
||||
const std::vector<EnvVertex> poly = buildEnvelopePolyline(env, a, 2.0);
|
||||
const std::vector<EnvVertex> poly = buildEnvelopePolyline(env, overlayOf(a), 2.0);
|
||||
CHECK(poly.size() == 6);
|
||||
for (size_t i = 1; i < poly.size(); ++i) {
|
||||
CHECK(poly[i].x - poly[i - 1].x >= kGateNodeSepPx);
|
||||
@@ -197,7 +201,7 @@ static void testGateSustainPlateauFixedWidth() {
|
||||
env.releaseSeconds = 0.3;
|
||||
const Rect a = wideArea();
|
||||
const int plateauPx = a.width - gateTimedWidth(a); // 150
|
||||
const std::vector<EnvVertex> poly = buildEnvelopePolyline(env, a, 2.0);
|
||||
const std::vector<EnvVertex> poly = buildEnvelopePolyline(env, overlayOf(a), 2.0);
|
||||
|
||||
EnvVertex decay, plateauEnd;
|
||||
CHECK(findNode(poly, EnvNode::DecayEnd, decay));
|
||||
@@ -218,7 +222,7 @@ static void testGateReleaseVisibleInBounds() {
|
||||
env.sustainLevel = 0.5;
|
||||
env.releaseSeconds = 0.4;
|
||||
const Rect a = wideArea();
|
||||
const std::vector<EnvVertex> poly = buildEnvelopePolyline(env, a, 2.0);
|
||||
const std::vector<EnvVertex> poly = buildEnvelopePolyline(env, overlayOf(a), 2.0);
|
||||
|
||||
EnvVertex plateauEnd, rel;
|
||||
CHECK(findNode(poly, EnvNode::ReleaseStart, plateauEnd));
|
||||
@@ -241,7 +245,7 @@ static void testGateOverrunCompressesFromRight() {
|
||||
env.sustainLevel = 0.7;
|
||||
env.releaseSeconds = 4.0;
|
||||
const Rect a = wideArea();
|
||||
const std::vector<EnvVertex> poly = buildEnvelopePolyline(env, a, 2.0);
|
||||
const std::vector<EnvVertex> poly = buildEnvelopePolyline(env, overlayOf(a), 2.0);
|
||||
CHECK(poly.size() == 6);
|
||||
|
||||
EnvVertex plateauEnd, rel;
|
||||
@@ -279,7 +283,7 @@ static void testGateAllVerticesInBounds() {
|
||||
huge.releaseSeconds = 1e12;
|
||||
|
||||
for (const AmpEnvelope& env : {base, big, zero, trig, huge}) {
|
||||
for (const EnvVertex& v : buildEnvelopePolyline(env, a, 2.0)) {
|
||||
for (const EnvVertex& v : buildEnvelopePolyline(env, overlayOf(a), 2.0)) {
|
||||
CHECK(v.x >= a.x && v.x < a.right());
|
||||
CHECK(v.y >= a.y && v.y < a.bottom());
|
||||
}
|
||||
@@ -297,7 +301,7 @@ static void testTriggerShape() {
|
||||
env.fadeInFraction = 0.2;
|
||||
env.fadeOutFraction = 0.3;
|
||||
const Rect a = wideArea();
|
||||
const std::vector<EnvVertex> poly = buildEnvelopePolyline(env, a, 2.0);
|
||||
const std::vector<EnvVertex> poly = buildEnvelopePolyline(env, overlayOf(a), 2.0);
|
||||
|
||||
CHECK(poly.size() == 4);
|
||||
CHECK(poly[0].node == EnvNode::Origin);
|
||||
@@ -319,7 +323,7 @@ static void testTriggerFadeOverlapClamp() {
|
||||
env.fadeInFraction = 0.8; // fade-in end at 0.8*2.0 = 1.6s -> x@800
|
||||
env.fadeOutFraction = 0.6; // would be 1.4s -> clamped to 1-0.8=0.2 -> begins at 0.8*2.0 too
|
||||
const Rect a = wideArea();
|
||||
const std::vector<EnvVertex> poly = buildEnvelopePolyline(env, a, 2.0);
|
||||
const std::vector<EnvVertex> poly = buildEnvelopePolyline(env, overlayOf(a), 2.0);
|
||||
|
||||
EnvVertex fin, fout;
|
||||
CHECK(findNode(poly, EnvNode::FadeInEnd, fin));
|
||||
@@ -338,7 +342,7 @@ static void testTriggerFullLengthZeroFadeOutInBounds() {
|
||||
env.fadeInFraction = 0.1;
|
||||
env.fadeOutFraction = 0.0;
|
||||
const Rect a = wideArea();
|
||||
const std::vector<EnvVertex> poly = buildEnvelopePolyline(env, a, 2.0);
|
||||
const std::vector<EnvVertex> poly = buildEnvelopePolyline(env, overlayOf(a), 2.0);
|
||||
|
||||
EnvVertex fout, lend;
|
||||
CHECK(findNode(poly, EnvNode::FadeOutStart, fout));
|
||||
@@ -353,12 +357,12 @@ static void testTriggerFullLengthZeroFadeOutInBounds() {
|
||||
static void testDegenerateFlatBaseline() {
|
||||
AmpEnvelope env; // any params
|
||||
const Rect zeroW = Rect::ltrb(0, 0, 0, 100);
|
||||
const std::vector<EnvVertex> p1 = buildEnvelopePolyline(env, zeroW, 2.0);
|
||||
const std::vector<EnvVertex> p1 = buildEnvelopePolyline(env, overlayOf(zeroW), 2.0);
|
||||
CHECK(p1.size() == 2); // always a drawable line
|
||||
CHECK(p1.front().level == 0.0 && p1.back().level == 0.0);
|
||||
|
||||
const Rect ok = wideArea();
|
||||
const std::vector<EnvVertex> p2 = buildEnvelopePolyline(env, ok, 0.0); // no duration
|
||||
const std::vector<EnvVertex> p2 = buildEnvelopePolyline(env, overlayOf(ok), 0.0); // no duration
|
||||
CHECK(p2.size() == 2);
|
||||
CHECK(p2.front().level == 0.0 && p2.back().level == 0.0);
|
||||
CHECK(p2.front().x == ok.x && p2.back().x == ok.right() - 1); // spans the area, in-bounds
|
||||
|
||||
@@ -88,7 +88,7 @@ static void testTwoLaneFloorHoldsTwoUsableLanes() {
|
||||
// number, so a lane can never be allocated below its own minimum.
|
||||
CHECK(kWaveformMinHeight == 2 * kLaneMinHeight + kLaneGap);
|
||||
const SampleBands b = computeSampleBands(840, 160, 120);
|
||||
const WaveformLanes lanes = waveformLanes(b.waveform, /*stereo=*/true);
|
||||
const WaveformLanes lanes = waveformLanes(b.waveform, LaneSplit::Stereo);
|
||||
CHECK(lanes.upper.height >= kLaneMinHeight);
|
||||
CHECK(lanes.lower.height >= kLaneMinHeight);
|
||||
}
|
||||
@@ -108,14 +108,14 @@ static void testDegenerateWindowYieldsNoInvertedRects() {
|
||||
|
||||
static void testMonoUsesOneFullBandLane() {
|
||||
const Rect band = Rect::ltrb(8, 100, 832, 300);
|
||||
const WaveformLanes lanes = waveformLanes(band, /*stereo=*/false);
|
||||
const WaveformLanes lanes = waveformLanes(band, LaneSplit::Single);
|
||||
CHECK(lanes.upper == band);
|
||||
CHECK(lanes.lower.empty()); // no redundant duplicate lane in mono
|
||||
}
|
||||
|
||||
static void testStereoSplitsIntoTwoLanesWithTheSeamGap() {
|
||||
const Rect band = Rect::ltrb(8, 100, 832, 300); // height 200
|
||||
const WaveformLanes lanes = waveformLanes(band, /*stereo=*/true);
|
||||
const WaveformLanes lanes = waveformLanes(band, LaneSplit::Stereo);
|
||||
CHECK(lanes.upper.y == band.y);
|
||||
CHECK(lanes.lower.bottom() == band.bottom());
|
||||
// Full width each, seam exactly kLaneGap, no overlap.
|
||||
@@ -127,14 +127,14 @@ static void testStereoSplitsIntoTwoLanesWithTheSeamGap() {
|
||||
|
||||
static void testStereoOddRemainderGoesToTheUpperLane() {
|
||||
const Rect band = Rect::ltrb(0, 0, 100, 201); // usable 199 -> 100 / 99
|
||||
const WaveformLanes lanes = waveformLanes(band, /*stereo=*/true);
|
||||
const WaveformLanes lanes = waveformLanes(band, LaneSplit::Stereo);
|
||||
CHECK(lanes.upper.height == 100);
|
||||
CHECK(lanes.lower.height == 99);
|
||||
CHECK(lanes.lower.bottom() == band.bottom());
|
||||
}
|
||||
|
||||
static void testEmptyBandYieldsEmptyLanes() {
|
||||
const WaveformLanes lanes = waveformLanes(Rect{}, /*stereo=*/true);
|
||||
const WaveformLanes lanes = waveformLanes(Rect{}, LaneSplit::Stereo);
|
||||
CHECK(lanes.upper.empty());
|
||||
CHECK(lanes.lower.empty());
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
// stacked height, grabs reaching the lower lane); laneEnvelope (per-lane channel split).
|
||||
|
||||
#include "../src/core/instrument/ui/waveform_view.h"
|
||||
#include "../src/core/instrument/ui/sample_bands.h" // kWaveformMinHeight, kLaneGap
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdio>
|
||||
@@ -25,6 +26,10 @@ static int g_fail = 0;
|
||||
#define CHECK(cond) do { if(!(cond)) { \
|
||||
std::printf("FAIL line %d: %s\n", __LINE__, #cond); ++g_fail; } } while(0)
|
||||
|
||||
// frameToX/markerAtPoint/resolveDragFrame take the overlay type, not a bare Rect (the
|
||||
// distinct-type enforcement in editor_geometry.h) — this wraps a plain test Rect for them.
|
||||
static OverlayArea overlayOf(const Rect& r) { return OverlayArea{r}; }
|
||||
|
||||
// A comfortable waveform area: 1000px wide, offset so left != 0 (catches origin bugs).
|
||||
static Rect wideArea() { return Rect::ltrb(20, 10, 1020, 90); } // width 1000
|
||||
|
||||
@@ -32,22 +37,22 @@ static Rect wideArea() { return Rect::ltrb(20, 10, 1020, 90); } // width 1000
|
||||
|
||||
static void testFrameToXEndpoints() {
|
||||
const Rect a = wideArea();
|
||||
CHECK(frameToX(a, 1000, 0) == a.x); // frame 0 -> left edge
|
||||
CHECK(frameToX(a, 1000, 1000) == a.right()); // frameCount -> right edge
|
||||
CHECK(frameToX(a, 1000, 500) == a.x + 500); // midpoint (1:1 here)
|
||||
CHECK(frameToX(overlayOf(a), 1000, 0) == a.x); // frame 0 -> left edge
|
||||
CHECK(frameToX(overlayOf(a), 1000, 1000) == a.right()); // frameCount -> right edge
|
||||
CHECK(frameToX(overlayOf(a), 1000, 500) == a.x + 500); // midpoint (1:1 here)
|
||||
}
|
||||
|
||||
static void testFrameToXClampsOutOfRange() {
|
||||
const Rect a = wideArea();
|
||||
CHECK(frameToX(a, 1000, -50) == a.x); // below 0 pins left
|
||||
CHECK(frameToX(a, 1000, 5000) == a.right()); // above count pins right
|
||||
CHECK(frameToX(overlayOf(a), 1000, -50) == a.x); // below 0 pins left
|
||||
CHECK(frameToX(overlayOf(a), 1000, 5000) == a.right()); // above count pins right
|
||||
}
|
||||
|
||||
static void testFrameToXDegenerate() {
|
||||
const Rect a = wideArea();
|
||||
CHECK(frameToX(a, 0, 100) == a.x); // no frames -> left
|
||||
CHECK(frameToX(overlayOf(a), 0, 100) == a.x); // no frames -> left
|
||||
const Rect z = Rect::ltrb(5, 5, 5, 45); // zero width
|
||||
CHECK(frameToX(z, 1000, 500) == z.x);
|
||||
CHECK(frameToX(overlayOf(z), 1000, 500) == z.x);
|
||||
}
|
||||
|
||||
static void testXToFrameInverse() {
|
||||
@@ -69,7 +74,7 @@ static void testFrameToXRoundTrip() {
|
||||
// xToFrame should land within a couple frames (rounding both directions).
|
||||
const Rect a = Rect::ltrb(0, 0, 800, 60);
|
||||
for (std::int64_t f = 0; f <= 2000; f += 137) {
|
||||
const int x = frameToX(a, 2000, f);
|
||||
const int x = frameToX(overlayOf(a), 2000, f);
|
||||
const std::int64_t back = xToFrame(a, 2000, x);
|
||||
CHECK(back >= f - 3 && back <= f + 3);
|
||||
}
|
||||
@@ -79,75 +84,82 @@ static void testFrameToXRoundTrip() {
|
||||
|
||||
static void testMarkerAtPointGrabsWithinBand() {
|
||||
const Rect a = wideArea();
|
||||
const OverlayArea ov = overlayOf(a);
|
||||
// Markers at frames 100, 500, 900 -> x = left+100, left+500, left+900.
|
||||
const std::int64_t frames[3] = {100, 500, 900};
|
||||
const int midY = a.y + a.height / 2;
|
||||
CHECK(markerAtPoint(a, 1000, frames, 3, a.x + 100, midY) == 0);
|
||||
CHECK(markerAtPoint(a, 1000, frames, 3, a.x + 500, midY) == 1);
|
||||
CHECK(markerAtPoint(a, 1000, frames, 3, a.x + 900, midY) == 2);
|
||||
CHECK(markerAtPoint(ov, 1000, frames, 3, a.x + 100, midY) == 0);
|
||||
CHECK(markerAtPoint(ov, 1000, frames, 3, a.x + 500, midY) == 1);
|
||||
CHECK(markerAtPoint(ov, 1000, frames, 3, a.x + 900, midY) == 2);
|
||||
// Within the grab band on either side of the line.
|
||||
CHECK(markerAtPoint(a, 1000, frames, 3, a.x + 500 + kMarkerGrabWidth, midY) == 1);
|
||||
CHECK(markerAtPoint(a, 1000, frames, 3, a.x + 500 - kMarkerGrabWidth, midY) == 1);
|
||||
CHECK(markerAtPoint(ov, 1000, frames, 3, a.x + 500 + kMarkerGrabWidth, midY) == 1);
|
||||
CHECK(markerAtPoint(ov, 1000, frames, 3, a.x + 500 - kMarkerGrabWidth, midY) == 1);
|
||||
}
|
||||
|
||||
static void testMarkerAtPointMissesBetween() {
|
||||
const Rect a = wideArea();
|
||||
const OverlayArea ov = overlayOf(a);
|
||||
const std::int64_t frames[3] = {100, 500, 900};
|
||||
const int midY = a.y + a.height / 2;
|
||||
// Well away from any marker line.
|
||||
CHECK(markerAtPoint(a, 1000, frames, 3, a.x + 300, midY) == -1);
|
||||
CHECK(markerAtPoint(ov, 1000, frames, 3, a.x + 300, midY) == -1);
|
||||
// Off the area vertically.
|
||||
CHECK(markerAtPoint(a, 1000, frames, 3, a.x + 500, a.y - 5) == -1);
|
||||
CHECK(markerAtPoint(ov, 1000, frames, 3, a.x + 500, a.y - 5) == -1);
|
||||
}
|
||||
|
||||
static void testMarkerAtPointFirstMatchOnOverlap() {
|
||||
const Rect a = wideArea();
|
||||
const OverlayArea ov = overlayOf(a);
|
||||
// Two markers at the same frame -> first in order wins.
|
||||
const std::int64_t frames[2] = {400, 400};
|
||||
const int midY = a.y + a.height / 2;
|
||||
CHECK(markerAtPoint(a, 1000, frames, 2, a.x + 400, midY) == 0);
|
||||
CHECK(markerAtPoint(ov, 1000, frames, 2, a.x + 400, midY) == 0);
|
||||
}
|
||||
|
||||
static void testMarkerAtPointRejectsNullEmpty() {
|
||||
const Rect a = wideArea();
|
||||
const OverlayArea ov = overlayOf(a);
|
||||
const int midY = a.y + a.height / 2;
|
||||
CHECK(markerAtPoint(a, 1000, nullptr, 3, a.x + 100, midY) == -1);
|
||||
CHECK(markerAtPoint(ov, 1000, nullptr, 3, a.x + 100, midY) == -1);
|
||||
const std::int64_t frames[1] = {100};
|
||||
CHECK(markerAtPoint(a, 1000, frames, 0, a.x + 100, midY) == -1);
|
||||
CHECK(markerAtPoint(ov, 1000, frames, 0, a.x + 100, midY) == -1);
|
||||
}
|
||||
|
||||
// --- resolveDragFrame ---------------------------------------------------------
|
||||
|
||||
static void testResolveDragFrameShift() {
|
||||
const Rect a = wideArea(); // 1:1 (1000px / 1000 frames)
|
||||
CHECK(resolveDragFrame(a, 1000, 300, 0) == 300); // zero delta -> unchanged
|
||||
CHECK(resolveDragFrame(a, 1000, 300, 100) == 400); // +100px -> +100 frames
|
||||
CHECK(resolveDragFrame(a, 1000, 300, -50) == 250); // -50px -> -50 frames
|
||||
const OverlayArea ov = overlayOf(a);
|
||||
CHECK(resolveDragFrame(ov, 1000, 300, 0) == 300); // zero delta -> unchanged
|
||||
CHECK(resolveDragFrame(ov, 1000, 300, 100) == 400); // +100px -> +100 frames
|
||||
CHECK(resolveDragFrame(ov, 1000, 300, -50) == 250); // -50px -> -50 frames
|
||||
}
|
||||
|
||||
static void testResolveDragFrameClamps() {
|
||||
const Rect a = wideArea();
|
||||
CHECK(resolveDragFrame(a, 1000, 50, -500) == 0); // clamp low
|
||||
CHECK(resolveDragFrame(a, 1000, 950, 500) == 1000); // clamp high (== frameCount)
|
||||
const OverlayArea ov = overlayOf(a);
|
||||
CHECK(resolveDragFrame(ov, 1000, 50, -500) == 0); // clamp low
|
||||
CHECK(resolveDragFrame(ov, 1000, 950, 500) == 1000); // clamp high (== frameCount)
|
||||
}
|
||||
|
||||
static void testResolveDragFrameRounds() {
|
||||
// 500px area over 1000 frames -> 2 frames/px. A +3px drag -> round(6.0)=6; the rounding is
|
||||
// at the frame centre. Use a scale where a fractional result appears.
|
||||
const Rect a = Rect::ltrb(0, 0, 300, 60); // 1000 frames / 300px = 3.33 frames/px
|
||||
const OverlayArea ov = overlayOf(Rect::ltrb(0, 0, 300, 60)); // 1000 frames / 300px = 3.33 frames/px
|
||||
// +3px -> 3*1000/300 = 10.0 -> 10 frames.
|
||||
CHECK(resolveDragFrame(a, 1000, 100, 3) == 110);
|
||||
CHECK(resolveDragFrame(ov, 1000, 100, 3) == 110);
|
||||
// +1px -> 1000/300 = 3.33 -> rounds to 3.
|
||||
CHECK(resolveDragFrame(a, 1000, 100, 1) == 103);
|
||||
CHECK(resolveDragFrame(ov, 1000, 100, 1) == 103);
|
||||
}
|
||||
|
||||
static void testResolveDragFrameDegenerate() {
|
||||
const Rect z = Rect::ltrb(0, 0, 0, 60); // zero width
|
||||
CHECK(resolveDragFrame(z, 1000, 300, 100) == 300); // pinned to start
|
||||
CHECK(resolveDragFrame(overlayOf(z), 1000, 300, 100) == 300); // pinned to start
|
||||
const Rect a = wideArea();
|
||||
CHECK(resolveDragFrame(a, 0, 300, 100) == 0); // no frames -> clamp(start)=0
|
||||
const OverlayArea ov = overlayOf(a);
|
||||
CHECK(resolveDragFrame(ov, 0, 300, 100) == 0); // no frames -> clamp(start)=0
|
||||
// startFrame out of range is clamped first.
|
||||
CHECK(resolveDragFrame(a, 1000, 5000, 0) == 1000);
|
||||
CHECK(resolveDragFrame(ov, 1000, 5000, 0) == 1000);
|
||||
}
|
||||
|
||||
// --- nearestZeroCrossing ------------------------------------------------------
|
||||
@@ -239,12 +251,12 @@ static void testSurfaceOverlayIsFullStackedHeightInBothModes() {
|
||||
const WaveformSurface st = waveformSurface(b, /*stereoMode=*/true, 2);
|
||||
const WaveformSurface mo = waveformSurface(b, /*stereoMode=*/false, 2);
|
||||
// Stereo: ONE overlay rect spanning both lanes, not either lane.
|
||||
CHECK(st.overlay == b);
|
||||
CHECK(st.overlay.height == st.upper.height + kLaneGap + st.lower.height);
|
||||
CHECK(st.overlay != st.upper && st.overlay != st.lower);
|
||||
CHECK(st.overlay.rect == b);
|
||||
CHECK(st.overlay.rect.height == st.upper.height + kLaneGap + st.lower.height);
|
||||
CHECK(st.overlay.rect != st.upper && st.overlay.rect != st.lower);
|
||||
// Mono: the same rect, which is also the single lane.
|
||||
CHECK(mo.overlay == b);
|
||||
CHECK(mo.overlay == mo.upper);
|
||||
CHECK(mo.overlay.rect == b);
|
||||
CHECK(mo.overlay.rect == mo.upper);
|
||||
// The standalone accessor the hit-test paths use agrees with the resolved surface.
|
||||
CHECK(waveformOverlayArea(b) == st.overlay);
|
||||
CHECK(waveformOverlayArea(b) == mo.overlay);
|
||||
@@ -253,8 +265,8 @@ static void testSurfaceOverlayIsFullStackedHeightInBothModes() {
|
||||
static void testSurfaceDegenerateBandDrawsNothing() {
|
||||
const WaveformSurface s = waveformSurface(Rect{10, 10, 0, 0}, true, 2);
|
||||
CHECK(s.laneCount == 0);
|
||||
CHECK(s.upper.empty() && s.lower.empty() && s.overlay.empty());
|
||||
CHECK(waveformOverlayArea(Rect{10, 10, 0, 0}).empty());
|
||||
CHECK(s.upper.empty() && s.lower.empty() && s.overlay.rect.empty());
|
||||
CHECK(waveformOverlayArea(Rect{10, 10, 0, 0}).rect.empty());
|
||||
}
|
||||
|
||||
// --- Hit-testing across the stacked lanes -------------------------------------
|
||||
@@ -271,8 +283,10 @@ static void testMarkerGrabReachesTheLowerStereoLane() {
|
||||
CHECK(markerAtPoint(s.overlay, frames, markers, 1, mx, upperY) == 0);
|
||||
CHECK(markerAtPoint(s.overlay, frames, markers, 1, mx, lowerY) == 0);
|
||||
// A lower-lane grab hit-tested against the UPPER LANE would be lost — the miss this
|
||||
// contract exists to prevent.
|
||||
CHECK(markerAtPoint(s.upper, frames, markers, 1, mx, lowerY) == -1);
|
||||
// contract exists to prevent. (Explicit OverlayArea{} wrap: production code can't do
|
||||
// this by accident — markerAtPoint won't accept a bare lane Rect — but the geometry
|
||||
// claim still needs proving.)
|
||||
CHECK(markerAtPoint(overlayOf(s.upper), frames, markers, 1, mx, lowerY) == -1);
|
||||
// Off the marker's x is still a miss at either height.
|
||||
CHECK(markerAtPoint(s.overlay, frames, markers, 1, mx + 40, lowerY) == -1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user