mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-11-23 08:54:30 +03:00
Refactor UnitFmt constructors
This commit is contained in:
parent
e47a985e54
commit
48398612de
@ -830,12 +830,7 @@ fn make_main_panel(
|
||||
Distance::meters(0.1),
|
||||
// Even if the user's settings are set to feet, our step size is in meters, so
|
||||
// just render in meters.
|
||||
Box::new(|x| {
|
||||
x.to_string(&UnitFmt {
|
||||
round_durations: false,
|
||||
metric: true,
|
||||
})
|
||||
}),
|
||||
Box::new(|x| x.to_string(&UnitFmt::metric())),
|
||||
),
|
||||
])
|
||||
.section(ctx),
|
||||
|
@ -282,12 +282,7 @@ impl Filters {
|
||||
Distance::meters(1.0),
|
||||
// Even if the user's settings are set to feet, our step size is in meters, so
|
||||
// just render in meters.
|
||||
Box::new(|x| {
|
||||
x.to_string(&UnitFmt {
|
||||
round_durations: false,
|
||||
metric: true,
|
||||
})
|
||||
}),
|
||||
Box::new(|x| x.to_string(&UnitFmt::metric())),
|
||||
),
|
||||
]),
|
||||
])
|
||||
|
@ -73,6 +73,16 @@ pub struct UnitFmt {
|
||||
pub metric: bool,
|
||||
}
|
||||
|
||||
impl UnitFmt {
|
||||
/// Default settings using metric.
|
||||
pub fn metric() -> Self {
|
||||
Self {
|
||||
round_durations: true,
|
||||
metric: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub struct CornerRadii {
|
||||
pub top_left: f64,
|
||||
|
@ -113,10 +113,7 @@ impl Demo {
|
||||
max_x: Some(Time::START_OF_DAY + self.elapsed),
|
||||
..Default::default()
|
||||
},
|
||||
UnitFmt {
|
||||
round_durations: true,
|
||||
metric: true,
|
||||
},
|
||||
UnitFmt::metric(),
|
||||
),
|
||||
]))
|
||||
// Don't let the panel exceed this percentage of the window. Scrollbars appear
|
||||
|
Loading…
Reference in New Issue
Block a user