fix: restore waveform symmetry about the midline, cut deck_values' link to the bank model, and unit-test the column arithmetic
The waveform column's vertical extents move to pure component_geometry so the shared primitive stops being untested; PlaySeconds hoists into a header-only play_seconds target.
This commit is contained in:
@@ -190,24 +190,19 @@ DeckHit hitTestDeck(const DeckLayout& layout, int x, int y) {
|
||||
return {};
|
||||
}
|
||||
|
||||
namespace {
|
||||
// Squared distance from a rect's centre, in the rect's own pixel units.
|
||||
double distSqFromCentre(const Rect& r, int x, int y) {
|
||||
const double dx = x - (r.x + r.width / 2.0);
|
||||
const double dy = y - (r.y + r.height / 2.0);
|
||||
return dx * dx + dy * dy;
|
||||
bool inKnobFace(const Rect& knob, int x, int y) {
|
||||
const double dx = x - (knob.x + knob.width / 2.0);
|
||||
const double dy = y - (knob.y + knob.height / 2.0);
|
||||
const double r = knob.width / 2.0;
|
||||
return dx * dx + dy * dy < r * r;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
DeckFaceHit hitTestKnobFace(const DeckLayout& layout, int x, int y) {
|
||||
for (const DeckGroupLayout& g : layout.groups) {
|
||||
if (!contains(g.box, x, y)) continue;
|
||||
for (const DeckCellLayout& c : g.cells) {
|
||||
const double rOuter = c.knob.width / 2.0;
|
||||
if (distSqFromCentre(c.knob, x, y) >= rOuter * rOuter) continue;
|
||||
const double rInner = c.inner.width / 2.0;
|
||||
const bool inner = distSqFromCentre(c.inner, x, y) < rInner * rInner;
|
||||
return {c.id, inner};
|
||||
if (!inKnobFace(c.knob, x, y)) continue;
|
||||
return {c.id, inKnobFace(c.inner, x, y)};
|
||||
}
|
||||
return {}; // inside the group but off every dial
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user