fix(render): drop y title columns the chrome clamp cut short
This commit is contained in:
1 parent
daeb31b1ea
commit
e211701d05
2 files changed
+179
-3
No files matched your search
+19
-3
@@ -622,11 +622,27 @@ void Renderer::draw_titles(const Plot& plot, const PlotLayout& layout) {
|
||||
const Axis& axis = plot.y_axis(i);
|
||||
if (axis.label.empty()) continue;
|
||||
const Rect& strip = layout.y_title_area;
|
||||
// A column must *fit* before it is staged, and its own cell is what has to fit:
|
||||
// with this basis the cell occupies [pen.x, pen.x + line_h], so the strip's
|
||||
// width -- the one dimension the run never advances along -- is the whole of a
|
||||
// column's cross extent, and nothing else in this path can see it. `walk_text_clipped()`
|
||||
// cuts along the run and would happily stage a column that is wider than the
|
||||
// strip it belongs to, drawing its cells over whatever is beside them.
|
||||
//
|
||||
// The layout clamps the strip against the viewport's chrome allowance (see
|
||||
// `Plot::layout()`), so a viewport narrow enough to spend that allowance on the
|
||||
// tick labels leaves room for fewer columns than there are titled axes, or for
|
||||
// none at all. Columns are laid out left to right, so the ones the clamp cut
|
||||
// short are the trailing ones: keep the leading columns that fit and stage no
|
||||
// more. A dropped title is chrome that had no room, which is the same bargain
|
||||
// the label strip already makes -- never drawn outside its strip, and never
|
||||
// inside `axes`.
|
||||
const f32 x = strip.x + pad + static_cast<f32>(column) * line_h;
|
||||
if (x + line_h > strip.right()) break;
|
||||
const f32 budget = strip.h - 2.0f * pad;
|
||||
const f32 length = clipped_text_width(axis.label.c_str(), budget, kTextUp);
|
||||
stage_text_clipped({strip.x + pad + static_cast<f32>(column) * line_h,
|
||||
strip.bottom() - 0.5f * (strip.h - length)},
|
||||
axis.label.c_str(), budget, kTextUp);
|
||||
stage_text_clipped({x, strip.bottom() - 0.5f * (strip.h - length)}, axis.label.c_str(), budget,
|
||||
kTextUp);
|
||||
++column;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user