adapters: route pointer events by cell rect

This commit is contained in:
Martino Ferrari committed 2026-11-03 17:04:16 +01:00
1 parent 7d8c453232
commit e5b7faadec
6 files changed
+145 -93

No files matched your search

+15 -11
View File
@@ -33,7 +33,9 @@ struct FigureLayout {
/// cells, the cells' widths summing to the row's less the gaps.
std::vector<Rect> cells;
/// The strip the figure's one shared x axis is drawn in: the bottom row's own
/// `PlotLayout::x_label_area`, at the bottom of the bottom row's rect and so as
/// `PlotLayout::x_label_area` (for a bottom row split into several cells, only the **last
/// cell's** strip -- the others' strips are their own `plot(i).layout().x_label_area`, which
/// is where the controller's axis-zoom hit test reads each cell's gestures from), at the bottom of the bottom row's rect and so as
/// wide as that row's axes rather than the whole figure. Read back from the row
/// rather than derived here, so a host and the frame cannot disagree about where
/// the axis is. It is nonzero whenever the figure has rows and the bottom row
@@ -236,17 +238,18 @@ class Figure {
/// is not a number; such a call therefore leaves every row's crosshair as it was.
void set_crosshair(f64 x, bool active);
/// Places the crosshair with the pointer's **row** and that row's local y (spec §17): the
/// shared x goes to every row -- vertical lines everywhere, as the plain overload does -- and
/// the horizontal line is drawn **only in `hovered_row`**, where its y is a value of *that*
/// row's own scale. It is the fix for the reported defect -- a figure showing no horizontal
/// Places the crosshair with the pointer's **plot** and that plot's local y (spec §17): the
/// shared x goes to every plot -- vertical lines everywhere, as the plain overload does -- and
/// the horizontal line is drawn **only in `hovered_row`** -- the **flattened plot index**, not
/// the figure-row index; they differ when a row holds several cells -- where its y is a value of
/// *that* plot's own scale. It is the fix for the reported defect -- a figure showing no horizontal
/// line at all -- without inventing a figure-wide y, which would mean a different value in
/// every row: the line appears where the pointer is, and no row ever shows another row's y.
///
/// `y_in_row` is a data coordinate on `hovered_row`'s y axis 0, exactly as `Crosshair::y`'s
/// two-coordinate placement is; a host reads it from the row's own y transform at the
/// pointer's pixel row. `hovered_row` outside `[0, row_count())` is treated as "no row under
/// the pointer": every row gets the vertical line and none gets a horizontal one, the same
/// pointer's pixel row. `hovered_row` outside `[0, plot_count())` is treated as "no plot under
/// the pointer": every plot gets the vertical line and none gets a horizontal one, the same
/// state the single-coordinate overload produces.
///
/// Refused, changing nothing, when `x` is not a number -- matching `set_crosshair(x, active)`
@@ -267,9 +270,10 @@ class Figure {
/// How many groups there are, excluding the unlinked group 0.
u32 x_link_count() const noexcept { return static_cast<u32>(links_.size()); }
/// Moves one row into a link group and applies that group's range to it at once,
/// so the row is on the group's window from this call rather than from the next
/// frame. `group` 0 takes the row back out of its group, leaving it with the range
/// Moves one plot into a link group and applies that group's range to it at once; `row`
/// is the **flattened plot index** (see `plot_count()`), which is the row index only for a
/// figure with one cell per row. The plot is on the group's window from this call rather
/// than from the next frame. `group` 0 takes the plot back out of its group, leaving it with the range
/// it holds now.
///
/// A group with no range yet -- one that no row and no `set_x_link_range()` has
@@ -283,7 +287,7 @@ class Figure {
/// per-row window. `XFollow::Off` is the group's to set
/// (`set_x_link_follow()`), not the axis'.
Status link_x(u32 row, u32 group);
/// The group a row is in, or 0 when it is in none.
/// The group the plot with flattened index `row` is in, or 0 when it is in none.
u32 x_link(u32 row) const noexcept;
/// Sets a group's shared range and pushes it to every member.