fix: close five Θ-W6-T1 review minors — headroom figure, knob-face radius, degenerate band clamp
Aligns inKnobFace's hit radius with computeKnob's draw-side min(w,h) rule and adds a non-square-rect test; clamps halfSpan for degenerate waveform bands with a test; fixes stale docs/comments and annotates an uncommitted perf measurement.
This commit is contained in:
@@ -382,6 +382,27 @@ static void testKnobFaceResolvesInnerRingOuterRingAndMisses() {
|
||||
CHECK(hitTestKnobFace(dl, cx + diag, cy + diag).id == -1);
|
||||
}
|
||||
|
||||
// A non-square knob rect (e.g. a squashed chrome row clamps knob height below its width) must
|
||||
// resolve against min(width, height)/2 — the same radius computeKnob draws — never against
|
||||
// width alone, or the hit disc would claim territory above/below where nothing is drawn.
|
||||
static void testInKnobFaceUsesTheSmallerDimensionOnANonSquareRect() {
|
||||
const Rect wide{0, 0, 40, 20}; // width > height: draws a 10px-radius disc, not 20px
|
||||
const int cx = wide.x + wide.width / 2;
|
||||
const int cy = wide.y + wide.height / 2;
|
||||
CHECK(inKnobFace(wide, cx, cy)); // dead centre always hits
|
||||
CHECK(inKnobFace(wide, cx, cy + 9)); // just inside the drawn (height-limited) radius
|
||||
CHECK(!inKnobFace(wide, cx, cy + 10)); // on the drawn rim: exclusive miss
|
||||
CHECK(!inKnobFace(wide, cx, cy + 15)); // inside the RECT but outside the smaller-radius disc
|
||||
CHECK(!inKnobFace(wide, cx + 15, cy)); // same check along the wider axis
|
||||
|
||||
const Rect tall{0, 0, 20, 40}; // height > width: draws a 10px-radius disc, not 20px
|
||||
const int tcx = tall.x + tall.width / 2;
|
||||
const int tcy = tall.y + tall.height / 2;
|
||||
CHECK(inKnobFace(tall, tcx, tcy));
|
||||
CHECK(!inKnobFace(tall, tcx + 15, tcy));
|
||||
CHECK(!inKnobFace(tall, tcx, tcy + 15));
|
||||
}
|
||||
|
||||
static void testEmptyDeck() {
|
||||
const std::vector<DeckGroupDesc> none;
|
||||
CHECK(deckRowCount(none, 800) == 0);
|
||||
@@ -401,6 +422,7 @@ int main() {
|
||||
testCaptionRadioGeometryAndHit();
|
||||
testInnerDialHit();
|
||||
testKnobFaceResolvesInnerRingOuterRingAndMisses();
|
||||
testInKnobFaceUsesTheSmallerDimensionOnANonSquareRect();
|
||||
testCaptionToggle2();
|
||||
testEmptyDeck();
|
||||
if (g_fail) {
|
||||
|
||||
Reference in New Issue
Block a user