feat(render): independent major and minor grid classes tied to the tick set
This commit is contained in:
1 parent
69495a3799
commit
eaae07d8e0
7 files changed
+635
-16
No files matched your search
+6
-2
@@ -26,16 +26,20 @@ void Grid::build(const std::vector<Tick>& x_ticks, Range x_range,
|
||||
|
||||
// Segments stay in data space: the renderer applies the transform, so a pan or
|
||||
// zoom needs no grid rebuild other than for a changed tick set.
|
||||
//
|
||||
// Both classes are built: the tick set is the only source of positions, and
|
||||
// `Style::grid_*_visible` decides what the renderer stages from here, so a class
|
||||
// is never filtered out of the tick set (that would be a second, geometry-side
|
||||
// switch for the same behaviour, and the grid would then disagree with the tick
|
||||
// list a caller can read).
|
||||
if (vertical) {
|
||||
for (const Tick& tick : x_ticks) {
|
||||
if (!tick.major && !show_minor) continue;
|
||||
if (!std::isfinite(tick.value) || !inside(tick.value, x_range)) continue;
|
||||
lines_.push_back(GridLine{tick.value, y_range.min, tick.value, y_range.max, tick.major});
|
||||
}
|
||||
}
|
||||
if (horizontal) {
|
||||
for (const Tick& tick : y_ticks) {
|
||||
if (!tick.major && !show_minor) continue;
|
||||
if (!std::isfinite(tick.value) || !inside(tick.value, y_range)) continue;
|
||||
lines_.push_back(GridLine{x_range.min, tick.value, x_range.max, tick.value, tick.major});
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user