Clear shortcut state when swapping neighbourhoods

This commit is contained in:
Dustin Carlino 2022-07-19 10:55:45 +02:00
parent 83600f0e26
commit 8bc25fc136
2 changed files with 17 additions and 1 deletions

View File

@ -10,6 +10,7 @@ use widgetry::{
Text, TextExt, Toggle, Widget,
};
use crate::edit::EditMode;
use crate::filters::auto::Heuristic;
use crate::{colors, App, Neighbourhood, NeighbourhoodID, Transition};
@ -26,6 +27,11 @@ impl BrowseNeighbourhoods {
pub fn new_state(ctx: &mut EventCtx, app: &mut App) -> Box<dyn State<App>> {
map_gui::tools::update_url_map_name(app);
// Make sure we clear this state if we ever switch neighbourhoods
if let EditMode::Shortcuts(ref mut maybe_focus) = app.session.edit_mode {
*maybe_focus = None;
}
let (world, draw_over_roads) =
ctx.loading_screen("calculate neighbourhoods", |ctx, timer| {
if &app.session.partitioning.map != app.map.get_name() {

View File

@ -12,6 +12,7 @@ use widgetry::{
};
use crate::browse::draw_boundary_roads;
use crate::edit::EditMode;
use crate::partition::BlockID;
use crate::{colors, App, NeighbourhoodID, Partitioning, Transition};
@ -35,7 +36,16 @@ pub struct SelectBoundary {
}
impl SelectBoundary {
pub fn new_state(ctx: &mut EventCtx, app: &App, id: NeighbourhoodID) -> Box<dyn State<App>> {
pub fn new_state(
ctx: &mut EventCtx,
app: &mut App,
id: NeighbourhoodID,
) -> Box<dyn State<App>> {
// Make sure we clear this state if we ever modify neighbourhood boundaries
if let EditMode::Shortcuts(ref mut maybe_focus) = app.session.edit_mode {
*maybe_focus = None;
}
let top_panel = crate::components::TopPanel::panel(ctx, app);
let left_panel = make_panel(ctx, app, id, &top_panel);
let mut state = SelectBoundary {