Refactor UnitFmt constructors

This commit is contained in:
Dustin Carlino 2022-06-27 12:11:48 -05:00
parent e47a985e54
commit 48398612de
4 changed files with 13 additions and 16 deletions

View File

@ -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),

View File

@ -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())),
),
]),
])

View File

@ -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,

View File

@ -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