Skip to content

Commit

Permalink
Refactor UnitFmt constructors
Browse files Browse the repository at this point in the history
  • Loading branch information
dabreegster committed Jun 27, 2022
1 parent e47a985 commit 4839861
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 16 deletions.
7 changes: 1 addition & 6 deletions apps/game/src/edit/roads.rs
Expand Up @@ -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),
Expand Down
7 changes: 1 addition & 6 deletions apps/game/src/ungap/predict.rs
Expand Up @@ -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())),
),
]),
])
Expand Down
10 changes: 10 additions & 0 deletions geom/src/lib.rs
Expand Up @@ -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,
Expand Down
5 changes: 1 addition & 4 deletions widgetry_demo/src/lib.rs
Expand Up @@ -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
Expand Down

0 comments on commit 4839861

Please sign in to comment.