mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-11-24 01:15:12 +03:00
Make canvas scroll speed configurable, just like GUI panel scroll speed.
This commit is contained in:
parent
d4e2b25689
commit
0f06d4d52f
@ -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 {
|
||||
|
@ -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(
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user