Add a location button to the road / multi road editor. #718

This commit is contained in:
Dustin Carlino 2021-07-26 12:50:20 -07:00
parent 07cce162c1
commit 9366116c9b
2 changed files with 47 additions and 9 deletions

View File

@ -14,6 +14,7 @@ use widgetry::{
use crate::app::App;
use crate::app::Transition;
use crate::common::Warping;
use crate::edit::apply_map_edits;
pub struct SelectSegments {
@ -31,12 +32,14 @@ pub struct SelectSegments {
impl SelectSegments {
pub fn new_state(
ctx: &mut EventCtx,
app: &App,
app: &mut App,
base_road: RoadID,
orig_state: EditRoad,
new_state: EditRoad,
base_edits: MapEdits,
) -> Box<dyn State<App>> {
app.primary.current_selection = None;
// Find all road segments matching the original state and name. base_road has already
// changed to new_state, so no need to exclude it.
let map = &app.primary.map;
@ -101,13 +104,23 @@ impl SelectSegments {
Line("Apply changes to similar roads")
.small_heading()
.into_widget(ctx),
format!(
"{} / {} roads similar to #{} are selected",
self.current.len(),
self.candidates.len(),
self.base_road.0
)
.text_widget(ctx),
Widget::row(vec![
format!(
"{} / {} roads similar to",
self.current.len(),
self.candidates.len(),
)
.text_widget(ctx)
.centered_vert(),
ctx.style()
.btn_plain
.icon_text(
"system/assets/tools/location.svg",
format!("#{}", self.base_road.0),
)
.build_widget(ctx, "jump to changed road"),
"are selected".text_widget(ctx).centered_vert(),
]),
// TODO Explain that this is only for lane configuration, NOT speed limit
Widget::row(vec![
"Click to select/unselect".text_widget(ctx).centered_vert(),
@ -178,6 +191,17 @@ impl State<App> for SelectSegments {
"Cancel" => {
return Transition::Pop;
}
"jump to changed road" => {
return Transition::Push(Warping::new_state(
ctx,
app.primary
.canonical_point(ID::Road(self.base_road))
.unwrap(),
Some(10.0),
Some(ID::Road(self.base_road)),
&mut app.primary,
));
}
_ => unreachable!(),
}
}

View File

@ -13,6 +13,7 @@ use widgetry::{
};
use crate::app::{App, Transition};
use crate::common::Warping;
use crate::edit::zones::ZoneEditor;
use crate::edit::{apply_map_edits, can_edit_lane, speed_limit_choices};
@ -189,6 +190,15 @@ impl State<App> for RoadEditor {
self.current_lane = None;
self.recalc_all_panels(ctx, app);
}
"jump to road" => {
return Transition::Push(Warping::new_state(
ctx,
app.primary.canonical_point(ID::Road(self.r)).unwrap(),
Some(10.0),
Some(ID::Road(self.r)),
&mut app.primary,
));
}
"Apply to multiple road segments" => {
return Transition::Push(
crate::edit::multiple_roads::SelectSegments::new_state(
@ -375,7 +385,11 @@ fn make_top_panel(
Panel::new_builder(Widget::col(vec![
Widget::row(vec![
Line("Editing road").small_heading().into_widget(ctx),
Line(format!("Edit {}", r)).small_heading().into_widget(ctx),
ctx.style()
.btn_plain
.icon("system/assets/tools/location.svg")
.build_widget(ctx, "jump to road"),
ctx.style()
.btn_plain
.text("+ Apply to multiple")