mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-11-24 01:15:12 +03:00
Ungap tweaks:
- use nonconflicting keybindings for the 3 tabs - fix the vanishing steep street legend
This commit is contained in:
parent
3a9246e3d0
commit
a5b905992e
@ -70,18 +70,8 @@ impl SteepStreets {
|
||||
|
||||
/// Also returns the steepest street and a row explaining the uphill arrows
|
||||
pub fn make_colorer<'a>(ctx: &mut EventCtx, app: &'a App) -> (ColorDiscrete<'a>, f64, Widget) {
|
||||
let mut colorer = ColorDiscrete::new(
|
||||
app,
|
||||
vec![
|
||||
// Colors and buckets from https://github.com/ITSLeeds/slopes
|
||||
("0-3% (flat)", Color::hex("#296B07")),
|
||||
("3-5%", Color::hex("#689A03")),
|
||||
("5-8%", Color::hex("#EB9A04")),
|
||||
("8-10%", Color::hex("#D30800")),
|
||||
("10-20%", Color::hex("#980104")),
|
||||
(">20% (steep)", Color::hex("#680605")),
|
||||
],
|
||||
);
|
||||
let (categories, uphill_legend) = SteepStreets::make_legend(ctx);
|
||||
let mut colorer = ColorDiscrete::new(app, categories);
|
||||
|
||||
let arrow_len = Distance::meters(5.0);
|
||||
let thickness = Distance::meters(2.0);
|
||||
@ -131,6 +121,23 @@ impl SteepStreets {
|
||||
}
|
||||
colorer.unzoomed.append(arrows);
|
||||
|
||||
(colorer, steepest, uphill_legend)
|
||||
}
|
||||
|
||||
/// Returns the colored categories used and a row explaining the uphill arrows
|
||||
pub fn make_legend(ctx: &mut EventCtx) -> (Vec<(&'static str, Color)>, Widget) {
|
||||
let categories = vec![
|
||||
// Colors and buckets from https://github.com/ITSLeeds/slopes
|
||||
("0-3% (flat)", Color::hex("#296B07")),
|
||||
("3-5%", Color::hex("#689A03")),
|
||||
("5-8%", Color::hex("#EB9A04")),
|
||||
("8-10%", Color::hex("#D30800")),
|
||||
("10-20%", Color::hex("#980104")),
|
||||
(">20% (steep)", Color::hex("#680605")),
|
||||
];
|
||||
|
||||
let arrow_len = Distance::meters(5.0);
|
||||
let thickness = Distance::meters(2.0);
|
||||
let pt = Pt2D::new(0.0, 0.0);
|
||||
let panel_arrow = PolyLine::must_new(vec![
|
||||
pt.project_away(arrow_len, Angle::degrees(-135.0)),
|
||||
@ -146,7 +153,7 @@ impl SteepStreets {
|
||||
"points uphill".text_widget(ctx).centered_vert(),
|
||||
]);
|
||||
|
||||
(colorer, steepest, uphill_legend)
|
||||
(categories, uphill_legend)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -142,32 +142,13 @@ impl Layers {
|
||||
}
|
||||
"steep streets" => {
|
||||
if self.panel.is_checked("steep streets") {
|
||||
let (colorer, _, uphill_legend) =
|
||||
let (colorer, _, _) =
|
||||
crate::layer::elevation::SteepStreets::make_colorer(ctx, app);
|
||||
// Make a horizontal legend for the incline
|
||||
let mut legend: Vec<Widget> = colorer
|
||||
.categories
|
||||
.iter()
|
||||
.map(|(label, color)| {
|
||||
legend_btn(*color, label)
|
||||
.label_color(Color::WHITE, ControlState::Default)
|
||||
.disabled(true)
|
||||
.build_def(ctx)
|
||||
})
|
||||
.collect();
|
||||
legend.push(uphill_legend);
|
||||
let legend = Widget::custom_row(legend);
|
||||
self.panel.replace(ctx, "steep streets legend", legend);
|
||||
|
||||
self.steep_streets = Some(colorer.unzoomed.upload(ctx));
|
||||
} else {
|
||||
self.steep_streets = None;
|
||||
self.panel.replace(
|
||||
ctx,
|
||||
"steep streets legend",
|
||||
Text::new().into_widget(ctx),
|
||||
);
|
||||
}
|
||||
self.update_panel(ctx, app);
|
||||
}
|
||||
_ => unreachable!(),
|
||||
},
|
||||
@ -281,11 +262,30 @@ impl Layers {
|
||||
.named("current elevation")
|
||||
.centered_vert(),
|
||||
]),
|
||||
Widget::row(vec![
|
||||
Toggle::checkbox(ctx, "steep streets", Key::S, self.steep_streets.is_some()),
|
||||
// A placeholder
|
||||
Text::new().into_widget(ctx).named("steep streets legend"),
|
||||
]),
|
||||
Widget::row({
|
||||
let mut row = vec![Toggle::checkbox(
|
||||
ctx,
|
||||
"steep streets",
|
||||
Key::S,
|
||||
self.steep_streets.is_some(),
|
||||
)];
|
||||
if self.steep_streets.is_some() {
|
||||
let (categories, uphill_legend) =
|
||||
crate::layer::elevation::SteepStreets::make_legend(ctx);
|
||||
let mut legend: Vec<Widget> = categories
|
||||
.into_iter()
|
||||
.map(|(label, color)| {
|
||||
legend_btn(color, label)
|
||||
.label_color(Color::WHITE, ControlState::Default)
|
||||
.disabled(true)
|
||||
.build_def(ctx)
|
||||
})
|
||||
.collect();
|
||||
legend.push(uphill_legend);
|
||||
row.push(Widget::custom_row(legend));
|
||||
}
|
||||
row
|
||||
}),
|
||||
// TODO Probably a collisions layer
|
||||
])
|
||||
}
|
||||
|
@ -53,19 +53,19 @@ impl Tab {
|
||||
ctx.style()
|
||||
.btn_tab
|
||||
.icon_text("system/assets/tools/pan.svg", "Explore")
|
||||
.hotkey(Key::E)
|
||||
.hotkey(Key::Num1)
|
||||
.disabled(self == Tab::Explore)
|
||||
.build_def(ctx),
|
||||
ctx.style()
|
||||
.btn_tab
|
||||
.icon_text("system/assets/tools/pencil.svg", "Create new bike lanes")
|
||||
.hotkey(Key::C)
|
||||
.hotkey(Key::Num2)
|
||||
.disabled(self == Tab::Create)
|
||||
.build_def(ctx),
|
||||
ctx.style()
|
||||
.btn_tab
|
||||
.icon_text("system/assets/tools/pin.svg", "Plan a route")
|
||||
.hotkey(Key::R)
|
||||
.hotkey(Key::Num3)
|
||||
.disabled(self == Tab::Route)
|
||||
.build_def(ctx),
|
||||
]),
|
||||
|
Loading…
Reference in New Issue
Block a user