feat(input): Ctrl restricts keyboard zoom to x, Alt to y
This commit is contained in:
1 parent
0ee6e10c81
commit
26a7c82a80
2 files changed
+41
-10
No files matched your search
@@ -263,6 +263,27 @@ PLOT_TEST(key_minus_zooms_out) {
|
||||
PLOT_CHECK(f.plot.x_range(f.ax).span() > 100.0);
|
||||
}
|
||||
|
||||
PLOT_TEST(ctrl_plus_zooms_only_x) {
|
||||
Fixture f;
|
||||
f.ay = f.plot.add_y_axis({"v", {-1.0, 1.0}, false, plot::AxisPlace::Left, false});
|
||||
const f64 x_before = f.plot.x_range(f.ax).span();
|
||||
const f64 y_before = f.plot.y_range(f.ay).span();
|
||||
f.controller.on_key({plot::input::kKeyZoomIn, kCtrl, true});
|
||||
PLOT_CHECK(f.plot.x_range(f.ax).span() < x_before);
|
||||
PLOT_CHECK_NEAR(f.plot.y_range(f.ay).span(), y_before, 1e-12);
|
||||
}
|
||||
|
||||
PLOT_TEST(alt_plus_zooms_only_y) {
|
||||
Fixture f;
|
||||
f.ay = f.plot.add_y_axis({"v", {-1.0, 1.0}, false, plot::AxisPlace::Left, false});
|
||||
constexpr plot::u32 kAlt = static_cast<plot::u32>(plot::input::Mod::Alt);
|
||||
const f64 x_before = f.plot.x_range(f.ax).span();
|
||||
const f64 y_before = f.plot.y_range(f.ay).span();
|
||||
f.controller.on_key({plot::input::kKeyZoomIn, kAlt, true});
|
||||
PLOT_CHECK_NEAR(f.plot.x_range(f.ax).span(), x_before, 1e-12);
|
||||
PLOT_CHECK(f.plot.y_range(f.ay).span() < y_before);
|
||||
}
|
||||
|
||||
/// A host can hand the controller a coordinate that is not a number: ImGui reports
|
||||
/// (-FLT_MAX, -FLT_MAX) for "no mouse position", and any host can produce a NaN out
|
||||
/// of a degenerate mapping of its own. The pan arithmetic runs through the axis
|
||||
|
||||
Reference in new issue
Block a user