mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-11-28 03:35:51 +03:00
Small UI adjustments to the route tool, to make info hierarchy slightly more clear.
And make the "explore" mode point to layers more clearly
This commit is contained in:
parent
d365213948
commit
fbc10f2c71
@ -1,8 +1,8 @@
|
||||
use geom::Distance;
|
||||
use geom::{ArrowCap, Distance, PolyLine};
|
||||
use map_gui::tools::URLManager;
|
||||
use map_gui::ID;
|
||||
use map_model::{EditCmd, LaneType};
|
||||
use widgetry::{lctrl, EventCtx, GfxCtx, Key, Line, Outcome, Panel, State, TextExt, Widget};
|
||||
use widgetry::{lctrl, Color, EventCtx, GfxCtx, Key, Line, Outcome, Panel, State, TextExt, Widget};
|
||||
|
||||
use crate::app::{App, Transition};
|
||||
use crate::edit::{LoadEdits, RoadEditor, SaveEdits};
|
||||
@ -115,6 +115,9 @@ impl State<App> for ExploreMap {
|
||||
"Share proposal" => {
|
||||
return Transition::Push(share::upload_proposal(ctx, app));
|
||||
}
|
||||
"Show more layers" => {
|
||||
self.layers.show_panel(ctx, app);
|
||||
}
|
||||
x => {
|
||||
return Tab::Explore
|
||||
.handle_action::<ExploreMap>(ctx, app, x)
|
||||
@ -133,6 +136,20 @@ impl State<App> for ExploreMap {
|
||||
fn draw(&self, g: &mut GfxCtx, app: &App) {
|
||||
self.top_panel.draw(g);
|
||||
self.layers.draw(g, app);
|
||||
|
||||
if self.top_panel.currently_hovering() == Some(&"Show more layers".to_string()) {
|
||||
g.fork_screenspace();
|
||||
if let Ok(pl) = PolyLine::new(vec![
|
||||
self.top_panel.center_of("Show more layers").to_pt(),
|
||||
self.layers.layer_icon_pos().to_pt(),
|
||||
]) {
|
||||
g.draw_polygon(
|
||||
Color::RED,
|
||||
pl.make_arrow(Distance::meters(20.0), ArrowCap::Triangle),
|
||||
);
|
||||
}
|
||||
g.unfork();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -185,7 +202,7 @@ fn make_top_panel(ctx: &mut EventCtx, app: &App) -> Panel {
|
||||
.build_def(ctx),
|
||||
ctx.style()
|
||||
.btn_outline
|
||||
.text("Save this proposal")
|
||||
.icon_text("system/assets/tools/save.svg", "Save this proposal")
|
||||
.hotkey(lctrl(Key::S))
|
||||
.disabled(edits.commands.is_empty())
|
||||
.build_def(ctx),
|
||||
@ -202,5 +219,12 @@ fn make_top_panel(ctx: &mut EventCtx, app: &App) -> Panel {
|
||||
}
|
||||
// TODO Should undo/redo, save, share functionality also live here?
|
||||
|
||||
col.push(
|
||||
ctx.style()
|
||||
.btn_plain
|
||||
.icon_text("system/assets/tools/layers.svg", "Show more layers")
|
||||
.build_def(ctx),
|
||||
);
|
||||
|
||||
Tab::Explore.make_left_panel(ctx, app, Widget::col(col))
|
||||
}
|
||||
|
@ -6,7 +6,8 @@ use map_model::osm::RoadRank;
|
||||
use map_model::LaneType;
|
||||
use widgetry::{
|
||||
ButtonBuilder, Color, ControlState, Drawable, EdgeInsets, EventCtx, GeomBatch, GfxCtx,
|
||||
HorizontalAlignment, Image, Key, Line, Outcome, Panel, Text, Toggle, VerticalAlignment, Widget,
|
||||
HorizontalAlignment, Image, Key, Line, Outcome, Panel, ScreenPt, Text, Toggle,
|
||||
VerticalAlignment, Widget,
|
||||
};
|
||||
|
||||
use crate::app::{App, Transition};
|
||||
@ -230,6 +231,19 @@ impl Layers {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn layer_icon_pos(&self) -> ScreenPt {
|
||||
if self.minimized {
|
||||
self.panel.center_of("show panel")
|
||||
} else {
|
||||
self.panel.center_of("layer icon")
|
||||
}
|
||||
}
|
||||
|
||||
pub fn show_panel(&mut self, ctx: &mut EventCtx, app: &App) {
|
||||
self.minimized = false;
|
||||
self.update_panel(ctx, app);
|
||||
}
|
||||
|
||||
fn update_panel(&mut self, ctx: &mut EventCtx, app: &App) {
|
||||
self.panel = Panel::new_builder(Widget::col(vec![
|
||||
make_zoom_controls(ctx).align_right().padding_right(16),
|
||||
@ -256,7 +270,8 @@ impl Layers {
|
||||
Image::from_path("system/assets/tools/layers.svg")
|
||||
.dims(30.0)
|
||||
.into_widget(ctx)
|
||||
.centered_vert(),
|
||||
.centered_vert()
|
||||
.named("layer icon"),
|
||||
Widget::custom_row(vec![
|
||||
// TODO Looks too close to access restrictions
|
||||
legend_btn(app.cs.unzoomed_highway, "highway").build_def(ctx),
|
||||
|
@ -56,7 +56,6 @@ impl RoutePlanner {
|
||||
let params = &app.session.routing_params;
|
||||
let col = Widget::col(vec![
|
||||
self.files.get_panel_widget(ctx),
|
||||
self.waypoints.get_panel_widget(ctx),
|
||||
Widget::col(vec![
|
||||
Widget::row(vec![
|
||||
"Avoid steep hills (> 8% incline)".text_widget(ctx),
|
||||
@ -78,7 +77,8 @@ impl RoutePlanner {
|
||||
]),
|
||||
])
|
||||
.section(ctx),
|
||||
results_widget,
|
||||
self.waypoints.get_panel_widget(ctx).section(ctx),
|
||||
results_widget.section(ctx),
|
||||
]);
|
||||
|
||||
let mut new_panel = Tab::Route.make_left_panel(ctx, app, col);
|
||||
@ -278,7 +278,7 @@ impl RouteResults {
|
||||
};
|
||||
|
||||
let widget = Widget::col(vec![
|
||||
Line("Your route").small_heading().into_widget(ctx),
|
||||
Line("Route details").small_heading().into_widget(ctx),
|
||||
Text::from_all(vec![
|
||||
Line("Distance: ").secondary(),
|
||||
Line(total_distance.to_string(&app.opts.units)),
|
||||
@ -593,10 +593,6 @@ impl RouteManagement {
|
||||
.btn()
|
||||
.label_underlined_text(current_name)
|
||||
.build_widget(ctx, "rename route"),
|
||||
ctx.style()
|
||||
.btn_outline
|
||||
.text("Start new route")
|
||||
.build_def(ctx),
|
||||
ctx.style()
|
||||
.btn_plain
|
||||
.icon_text("system/assets/tools/save.svg", "Save")
|
||||
@ -608,6 +604,7 @@ impl RouteManagement {
|
||||
.build_def(ctx),
|
||||
]),
|
||||
Widget::row(vec![
|
||||
ctx.style().btn_plain.text("Start new route").build_def(ctx),
|
||||
ctx.style()
|
||||
.btn_prev()
|
||||
.hotkey(Key::LeftArrow)
|
||||
@ -615,7 +612,7 @@ impl RouteManagement {
|
||||
.build_widget(ctx, "previous route"),
|
||||
// TODO Autosave first?
|
||||
ctx.style()
|
||||
.btn_outline
|
||||
.btn_plain
|
||||
.text("Load another route")
|
||||
.build_def(ctx),
|
||||
ctx.style()
|
||||
|
Loading…
Reference in New Issue
Block a user