Make canvas scroll speed configurable, just like GUI panel scroll speed.

This commit is contained in:
Dustin Carlino 2021-05-17 10:16:44 -07:00
parent d4e2b25689
commit 0f06d4d52f
3 changed files with 20 additions and 2 deletions

View File

@ -173,6 +173,16 @@ impl OptionsPanel {
1,
),
]),
Widget::row(vec![
"Zoom speed for the map".text_widget(ctx).centered_vert(),
Spinner::widget(
ctx,
"canvas_scroll_speed",
(1, 30),
ctx.canvas.canvas_scroll_speed,
1,
),
]),
])
.bg(app.cs().inner_panel_bg)
.padding(8),
@ -305,6 +315,7 @@ impl<A: AppLike> State<A> for OptionsPanel {
.is_checked("Use arrow keys to pan and Q/W to zoom");
ctx.canvas.edge_auto_panning = self.panel.is_checked("autopan");
ctx.canvas.gui_scroll_speed = self.panel.spinner("gui_scroll_speed");
ctx.canvas.canvas_scroll_speed = self.panel.spinner("canvas_scroll_speed");
let style = self.panel.dropdown_value("Traffic signal rendering");
if opts.traffic_signal_style != style {

View File

@ -74,7 +74,10 @@ impl DrawMovement {
} else {
// TODO These turns are often too small to even dash the arrow. So they'll just
// look like solid protected turns...
warn!("{:?} is too short to render as a yield movement", movement.id);
warn!(
"{:?} is too short to render as a yield movement",
movement.id
);
batch.extend(
cs.signal_protected_turn,
pl.dashed_arrow(

View File

@ -38,6 +38,9 @@ pub struct Canvas {
pub edge_auto_panning: bool,
pub keys_to_pan: bool,
pub gui_scroll_speed: usize,
// TODO Ideally this would be an f64, but elsewhere we use it in a Spinner. Until we override
// the Display trait to do some rounding, floating point increments render pretty horribly.
pub canvas_scroll_speed: usize,
// TODO Bit weird and hacky to mutate inside of draw() calls.
pub(crate) covered_areas: RefCell<Vec<ScreenRectangle>>,
@ -68,6 +71,7 @@ impl Canvas {
edge_auto_panning: false,
keys_to_pan: false,
gui_scroll_speed: 5,
canvas_scroll_speed: 10,
covered_areas: RefCell::new(Vec::new()),
@ -178,7 +182,7 @@ impl Canvas {
let old_zoom = self.cam_zoom;
// By popular request, some limits ;)
self.cam_zoom = 1.1_f64
.powf(old_zoom.log(1.1) + delta)
.powf(old_zoom.log(1.1) + delta * (self.canvas_scroll_speed as f64 / 10.0))
.max(self.min_zoom())
.min(150.0);