mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-11-24 09:24:26 +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
|
/// 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) {
|
pub fn make_colorer<'a>(ctx: &mut EventCtx, app: &'a App) -> (ColorDiscrete<'a>, f64, Widget) {
|
||||||
let mut colorer = ColorDiscrete::new(
|
let (categories, uphill_legend) = SteepStreets::make_legend(ctx);
|
||||||
app,
|
let mut colorer = ColorDiscrete::new(app, 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 arrow_len = Distance::meters(5.0);
|
||||||
let thickness = Distance::meters(2.0);
|
let thickness = Distance::meters(2.0);
|
||||||
@ -131,6 +121,23 @@ impl SteepStreets {
|
|||||||
}
|
}
|
||||||
colorer.unzoomed.append(arrows);
|
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 pt = Pt2D::new(0.0, 0.0);
|
||||||
let panel_arrow = PolyLine::must_new(vec![
|
let panel_arrow = PolyLine::must_new(vec![
|
||||||
pt.project_away(arrow_len, Angle::degrees(-135.0)),
|
pt.project_away(arrow_len, Angle::degrees(-135.0)),
|
||||||
@ -146,7 +153,7 @@ impl SteepStreets {
|
|||||||
"points uphill".text_widget(ctx).centered_vert(),
|
"points uphill".text_widget(ctx).centered_vert(),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
(colorer, steepest, uphill_legend)
|
(categories, uphill_legend)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,32 +142,13 @@ impl Layers {
|
|||||||
}
|
}
|
||||||
"steep streets" => {
|
"steep streets" => {
|
||||||
if self.panel.is_checked("steep streets") {
|
if self.panel.is_checked("steep streets") {
|
||||||
let (colorer, _, uphill_legend) =
|
let (colorer, _, _) =
|
||||||
crate::layer::elevation::SteepStreets::make_colorer(ctx, app);
|
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));
|
self.steep_streets = Some(colorer.unzoomed.upload(ctx));
|
||||||
} else {
|
} else {
|
||||||
self.steep_streets = None;
|
self.steep_streets = None;
|
||||||
self.panel.replace(
|
|
||||||
ctx,
|
|
||||||
"steep streets legend",
|
|
||||||
Text::new().into_widget(ctx),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
self.update_panel(ctx, app);
|
||||||
}
|
}
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
},
|
},
|
||||||
@ -281,11 +262,30 @@ impl Layers {
|
|||||||
.named("current elevation")
|
.named("current elevation")
|
||||||
.centered_vert(),
|
.centered_vert(),
|
||||||
]),
|
]),
|
||||||
Widget::row(vec![
|
Widget::row({
|
||||||
Toggle::checkbox(ctx, "steep streets", Key::S, self.steep_streets.is_some()),
|
let mut row = vec![Toggle::checkbox(
|
||||||
// A placeholder
|
ctx,
|
||||||
Text::new().into_widget(ctx).named("steep streets legend"),
|
"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
|
// TODO Probably a collisions layer
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
|
@ -53,19 +53,19 @@ impl Tab {
|
|||||||
ctx.style()
|
ctx.style()
|
||||||
.btn_tab
|
.btn_tab
|
||||||
.icon_text("system/assets/tools/pan.svg", "Explore")
|
.icon_text("system/assets/tools/pan.svg", "Explore")
|
||||||
.hotkey(Key::E)
|
.hotkey(Key::Num1)
|
||||||
.disabled(self == Tab::Explore)
|
.disabled(self == Tab::Explore)
|
||||||
.build_def(ctx),
|
.build_def(ctx),
|
||||||
ctx.style()
|
ctx.style()
|
||||||
.btn_tab
|
.btn_tab
|
||||||
.icon_text("system/assets/tools/pencil.svg", "Create new bike lanes")
|
.icon_text("system/assets/tools/pencil.svg", "Create new bike lanes")
|
||||||
.hotkey(Key::C)
|
.hotkey(Key::Num2)
|
||||||
.disabled(self == Tab::Create)
|
.disabled(self == Tab::Create)
|
||||||
.build_def(ctx),
|
.build_def(ctx),
|
||||||
ctx.style()
|
ctx.style()
|
||||||
.btn_tab
|
.btn_tab
|
||||||
.icon_text("system/assets/tools/pin.svg", "Plan a route")
|
.icon_text("system/assets/tools/pin.svg", "Plan a route")
|
||||||
.hotkey(Key::R)
|
.hotkey(Key::Num3)
|
||||||
.disabled(self == Tab::Route)
|
.disabled(self == Tab::Route)
|
||||||
.build_def(ctx),
|
.build_def(ctx),
|
||||||
]),
|
]),
|
||||||
|
Loading…
Reference in New Issue
Block a user