feat(cursor): a cursor's stroke is its own -- width and dash
Cursors took `Style::line_width_px` and were always solid, so a host had no way to place a *readout mark* on the data (a measured level, a peak, a pulse's edge) without it reading as another instrument framing the plot. `set_cursor_stroke(id, width, dash)` gives it its own, the same shape as `set_cursor_color()`: per cursor, because one plot holds both kinds. `width <= 0` means the style's default for that cursor (`handle_width_px` while hovered or grabbed, `line_width_px` otherwise), and a hover can only make the stroke *thicker* -- the cue that the pointer has hold of something must not be the thing that hides it. `dash.off <= 0` is solid, the convention a trace's, the crosshair's and the grid's dash already share. Test: a_cursor_stroke_can_be_thinner_and_dashed -- a default cursor and a thin dashed one in the same frame. The dashed column alternates ink and gap (153/151 at the 4/4 the test asks for) while the solid one has no gaps; the ink laid down over each stroke's whole run of columns is less for the thin one. That last assertion is deliberately *not* a single-column peak: a cursor is a data position and is not snapped, so the solid stroke's ink split across two columns and read *lighter* than the thin one -- which is how this test first failed.
This commit is contained in:
1 parent
c4c0a49466
commit
fba8d985cf
6 files changed
+154
-5
No files matched your search
@@ -484,6 +484,10 @@ class Plot {
|
||||
/// be told apart from its neighbours, and its colour is how it says which readout it
|
||||
/// belongs to. An id that names no cursor is ignored, like every other setter here.
|
||||
void set_cursor_color(u32 id, Color color);
|
||||
|
||||
/// A cursor's stroke: its logical width (`<= 0` for the style's default) and its dash
|
||||
/// (`dash.off <= 0` for solid). The instrument's own, like its colour -- see `Cursor::width`.
|
||||
void set_cursor_stroke(u32 id, f32 width, Vec2 dash);
|
||||
/// Makes a cursor unselectable (see `Cursor::selectable`): the pointer cannot hover or
|
||||
/// grab it, which is what a host wants for a marker it draws as a *readout*. An id that
|
||||
/// names no cursor is ignored, like every other setter here.
|
||||
|
||||
Reference in new issue
Block a user