fix(plot,render,glfw): a hue-neutral crosshair, an em-dash placeholder, one layout per figure event, and a usable readout switch

This commit is contained in:
Martino Ferrari committed 2026-09-28 19:38:30 +02:00
1 parent 10d5129fbf
commit a14f333dbe
10 files changed
+175 -70

No files matched your search

+35 -6
View File
@@ -2038,12 +2038,41 @@ PLOT_TEST(crosshair_readout_lists_every_visible_trace_including_unnamed_ones) {
PLOT_CHECK(cleared.panel.w == 0.0f && cleared.panel.h == 0.0f);
PLOT_CHECK(cleared.vertical.w == 0.0f && cleared.horizontal.h == 0.0f);
// A crosshair with the readout switched off still draws its lines -- and lists nothing.
scene.plot.set_crosshair(2.0, true);
plot::Crosshair no_readout = scene.plot.crosshair();
PLOT_CHECK(no_readout.active);
PLOT_CHECK(!no_readout.horizontal); // the one-coordinate form draws no row
PLOT_CHECK(no_readout.show_readout);
// A crosshair whose x is outside every trace's window: the row is still listed -- the trace is
// one of the signals under the pointer -- and says so with the documented placeholder rather than
// a blank cell or a fabricated number.
scene.plot.set_crosshair(10.0, true); // past the last sample of the 4-sample series
const plot::CrosshairLayout& past_the_end = scene.plot.layout().crosshair;
PLOT_CHECK(past_the_end.rows.size() == 2u); // the two visible traces, both with no sample here
PLOT_CHECK(!past_the_end.rows[0].valid);
PLOT_CHECK(past_the_end.rows[0].value == plot::kCrosshairNoValue);
PLOT_CHECK(!past_the_end.rows[0].value.empty());
PLOT_CHECK(past_the_end.rows[0].value_box.w > 0.0f); // the dash has a box of its own
PLOT_CHECK(past_the_end.rows[0].listed);
PLOT_CHECK(past_the_end.rows[0].value_box.w <= past_the_end.panel.w);
// The readout switch, and the reason it is a switch rather than a field nobody can reach: with it
// off the crosshair itself is untouched -- the lines are still placed and the trace is still a
// row -- while nothing is listed in a panel, so a host that wants the pointer's column marked and
// not a panel over its data can say so. Switching it back on lists the rows again.
scene.plot.set_crosshair(1.5, true);
scene.plot.set_crosshair_readout(false);
const plot::CrosshairLayout& off = scene.plot.layout().crosshair;
PLOT_CHECK(off.active);
PLOT_CHECK(off.vertical.w > 0.0f); // the switch is the readout's: the lines are untouched
PLOT_CHECK(off.rows.size() == 2u); // both traces are still there, with their markers
for (const plot::CrosshairRow& row : off.rows) {
PLOT_CHECK(!row.listed); // ... and neither is a line in a panel
PLOT_CHECK(row.value_box.w == 0.0f);
PLOT_CHECK(row.marker.x > 0.0f); // the marker is placed either way
}
PLOT_CHECK(off.panel.w == 0.0f && off.panel.h == 0.0f);
scene.plot.set_crosshair_readout(true);
const plot::CrosshairLayout& on = scene.plot.layout().crosshair;
PLOT_CHECK(on.rows[0].listed);
PLOT_CHECK(on.rows[1].listed);
PLOT_CHECK(on.panel.w > 0.0f && on.panel.h > 0.0f);
PLOT_CHECK(on.rows[0].value == "15");
}
/// Spec §15, the panel's placement: near the pointer, flipped over it where it would otherwise