fix(input): clamp a dragged ruler on an ordered y range and share the orientation test
This commit is contained in:
1 parent
93ad774281
commit
a153b73ead
5 files changed
+62
-14
No files matched your search
@@ -66,6 +66,17 @@ struct Cursor {
|
||||
u32 axis_x = 0; ///< the x axis `x` is in. Dead for `Horizontal`.
|
||||
u32 axis_y = 0; ///< the y axis `y` is in. Dead for `Vertical`.
|
||||
bool visible = true;
|
||||
|
||||
/// True when this is a horizontal ruler (spans the axes' width, reads its `y`). The one
|
||||
/// place the orientation becomes a branch, so every consumer takes the same decision and
|
||||
/// the two orientations cannot drift apart as new ones are added.
|
||||
bool is_horizontal() const noexcept { return orientation == CursorOrientation::Horizontal; }
|
||||
|
||||
/// The live data coordinate: `y` for a horizontal ruler, `x` for a vertical marker.
|
||||
f64 coordinate() const noexcept { return is_horizontal() ? y : x; }
|
||||
|
||||
/// The axis `coordinate()` is in: `axis_y` for a horizontal ruler, `axis_x` for a vertical.
|
||||
u32 coordinate_axis() const noexcept { return is_horizontal() ? axis_y : axis_x; }
|
||||
};
|
||||
|
||||
} // namespace plot
|
||||
Reference in new issue
Block a user