figure: shared-y rows draw one y axis, on the first cell

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Martino FerrariandClaude Opus 4.6 committed 2026-11-04 00:43:41 +01:00
1 parent 25c3381551
commit 2b4b316ad8
6 files changed
+172 -5

No files matched your search

+46
View File
@@ -5059,6 +5059,52 @@ PLOT_TEST(figure_x_title_is_drawn_on_the_bottom_row_only) {
ctx.destroy();
}
/// A split row that shares one y axis draws it once, on its first cell: every later cell is
/// `YStrip::None`, reserves no y strip, and the renderer must stage no y tick labels for it.
/// Staged text is not observable through `FrameStats`, so this reads the pixels. The column gap
/// is wide and empty chrome, and a label staged for the second cell would be right-aligned
/// against that cell's (zero-width) label area, i.e. land in the gap: the gap holds no ink.
PLOT_TEST(figure_shared_y_second_cell_stages_no_y_labels) {
plottest::HeadlessContext ctx(kW, kH);
plot::Status st;
PLOT_CHECK(ctx.create(&st));
PLOT_CHECK(plot::gl::load(nullptr));
plot::Renderer r;
PLOT_CHECK(r.init(&st));
const std::vector<plot::u32> cells{2u};
plot::Figure figure{std::span<const plot::u32>(cells)};
figure.set_viewport({0, 0, static_cast<plot::f32>(kW), static_cast<plot::f32>(kH)});
for (plot::u32 i = 0; i < 2u; ++i) {
plot::Plot& p = figure.plot(i);
p.add_x_axis({"t", {0.0, 100.0}, false, plot::AxisPlace::Bottom, false});
p.add_y_axis({"", {-1.0, 1.0}, false, plot::AxisPlace::Left, false});
}
figure.set_col_gap(80.0f);
figure.set_share_row_y(true);
r.begin_frame(kW, kH, {0, 0, static_cast<plot::f32>(kW), static_cast<plot::f32>(kH)});
r.draw(figure);
r.end_frame();
PLOT_CHECK(!r.last_frame_had_gl_error());
const plot::FigureLayout layout = figure.layout();
const plot::Color ink = r.style().axis_text;
const plot::PlotLayout& first = figure.plot(0u).layout();
const plot::PlotLayout& second = figure.plot(1u).layout();
PLOT_CHECK(second.y_label_area.w == 0.0f);
PLOT_CHECK(layout.cells[1].x - layout.cells[0].right() > 70.0f);
// The first cell still draws the row's one axis ...
PLOT_CHECK(scan_rect_ink(ctx, first.y_label_area, ink).pixels > 0u);
// ... and nothing is staged in the gap on the second cell's left.
// Inset a few pixels each side: the cells' own frame lines sit on the gap's two edges.
const plot::Rect gap{layout.cells[0].right() + 4.0f, first.axes.y,
layout.cells[1].x - layout.cells[0].right() - 8.0f, first.axes.h};
PLOT_CHECK(scan_rect_ink(ctx, gap, ink).pixels == 0u);
ctx.destroy();
}
// ---------------------------------------------------- the axes clip (spec §13)
// The reported defect this section is about: a trace is staged in *data* space and