From 469c11e5329bf872101133ed84bd33b1c9a7e78a Mon Sep 17 00:00:00 2001 From: Dustin Carlino Date: Fri, 20 Mar 2020 12:31:08 -0700 Subject: [PATCH] fix up overlays, part 2: - say what layer is active when zoomed in - zoom out after opening an overlay, if needed - sadly, scrap the heatmap icons for now [rebuild] --- data/MANIFEST.txt | 5 - data/system/assets/layers/bike_network.svg | 29 ---- data/system/assets/layers/bus_network.svg | 19 --- .../assets/layers/intersection_delay.svg | 32 ----- data/system/assets/layers/parking_avail.svg | 22 --- data/system/assets/layers/throughput.svg | 21 --- game/src/common/minimap.rs | 22 ++- game/src/common/overlays.rs | 130 +++++++++--------- 8 files changed, 83 insertions(+), 197 deletions(-) delete mode 100644 data/system/assets/layers/bike_network.svg delete mode 100644 data/system/assets/layers/bus_network.svg delete mode 100644 data/system/assets/layers/intersection_delay.svg delete mode 100644 data/system/assets/layers/parking_avail.svg delete mode 100644 data/system/assets/layers/throughput.svg diff --git a/data/MANIFEST.txt b/data/MANIFEST.txt index c22fe252f6..e1358a0ef2 100644 --- a/data/MANIFEST.txt +++ b/data/MANIFEST.txt @@ -137,11 +137,6 @@ b0a3a08cac236734be96330179c40be2 data/input/google_transit_2018_18_08/trips.txt 6ee699d3fdc218e5be3906ee90160a1d data/input/google_transit_2018_18_08/fare_attributes.txt d7587f76ed2d514d9f925c8b60b30153 data/input/google_transit_2018_18_08/stops.txt 3d8b080487e096ef417038739acecea5 data/input/google_transit_2018_18_08/agency.txt -bbd7d9c86c3360807a7326c3d07d864c data/system/assets/layers/parking_avail.svg -676e4f938ef8ebe1395c3ee34ac0dd4b data/system/assets/layers/throughput.svg -8e0184126ba8a70da58a1f57dd2661b6 data/system/assets/layers/bike_network.svg -e9a1bcaa265cfb89d276099f491ad4a6 data/system/assets/layers/intersection_delay.svg -92b1f47816f3f8e4a14c630ada8e1141 data/system/assets/layers/bus_network.svg e4d10fa4a66453b7097d906e4616e26b data/system/assets/meters/car.svg 9d747979fdc362ac6df0af3c3bbffd15 data/system/assets/meters/bus.svg f7facfb678770c416e5529b2b2d066e5 data/system/assets/meters/pedestrian.svg diff --git a/data/system/assets/layers/bike_network.svg b/data/system/assets/layers/bike_network.svg deleted file mode 100644 index 3c561ed174..0000000000 --- a/data/system/assets/layers/bike_network.svg +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/data/system/assets/layers/bus_network.svg b/data/system/assets/layers/bus_network.svg deleted file mode 100644 index f6d2f1b4e6..0000000000 --- a/data/system/assets/layers/bus_network.svg +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - - - - - - diff --git a/data/system/assets/layers/intersection_delay.svg b/data/system/assets/layers/intersection_delay.svg deleted file mode 100644 index db444fcffb..0000000000 --- a/data/system/assets/layers/intersection_delay.svg +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/data/system/assets/layers/parking_avail.svg b/data/system/assets/layers/parking_avail.svg deleted file mode 100644 index 6b44e46f11..0000000000 --- a/data/system/assets/layers/parking_avail.svg +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - diff --git a/data/system/assets/layers/throughput.svg b/data/system/assets/layers/throughput.svg deleted file mode 100644 index f2a7ae99ee..0000000000 --- a/data/system/assets/layers/throughput.svg +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - diff --git a/game/src/common/minimap.rs b/game/src/common/minimap.rs index 4aa5cf4673..763f1e2b3e 100644 --- a/game/src/common/minimap.rs +++ b/game/src/common/minimap.rs @@ -7,7 +7,8 @@ use crate::render::MIN_ZOOM_FOR_DETAIL; use abstutil::clamp; use ezgui::{ hotkey, Btn, Color, Composite, EventCtx, Filler, GeomBatch, GfxCtx, HorizontalAlignment, Key, - Line, ManagedWidget, Outcome, RewriteColor, ScreenDims, ScreenPt, Text, VerticalAlignment, + Line, ManagedWidget, Outcome, RewriteColor, ScreenDims, ScreenPt, Text, TextExt, + VerticalAlignment, }; use geom::{Circle, Distance, Polygon, Pt2D, Ring}; @@ -415,5 +416,24 @@ fn make_viz_panel(ctx: &mut EventCtx, app: &App) -> ManagedWidget { .centered_cross(), ); } + + if ctx.canvas.cam_zoom >= MIN_ZOOM_FOR_DETAIL { + if let Some(name) = app.overlay.zoomed_name() { + // TODO Should the full legend have this icon too? + col.insert( + 0, + ManagedWidget::row(vec![ + ManagedWidget::draw_svg_transform( + ctx, + "../data/system/assets/tools/layers.svg", + RewriteColor::ChangeAll(Color::BLUE), + ) + .margin(5), + name.draw_text(ctx), + ]), + ); + } + } + ManagedWidget::col(col).bg(colors::PANEL_BG).padding(5) } diff --git a/game/src/common/overlays.rs b/game/src/common/overlays.rs index 834e078a12..3c75e2e845 100644 --- a/game/src/common/overlays.rs +++ b/game/src/common/overlays.rs @@ -248,74 +248,34 @@ impl Overlays { } pub fn change_overlays(ctx: &mut EventCtx, app: &App) -> Option { + // TODO Icons again, after some work let mut choices = vec![ Btn::text_fg("None").build_def(ctx, hotkey(Key::N)), Btn::text_fg("map edits").build_def(ctx, hotkey(Key::E)), Btn::text_fg("worst traffic jams").build_def(ctx, hotkey(Key::G)), Btn::text_fg("elevation").build_def(ctx, hotkey(Key::S)), - Btn::svg( - "../data/system/assets/layers/parking_avail.svg", - RewriteColor::Change(Color::hex("#F2F2F2"), colors::HOVERING), - ) - .build(ctx, "parking availability", hotkey(Key::P)), - // TODO old button - Btn::svg( - "../data/system/assets/layers/intersection_delay.svg", - RewriteColor::Change(Color::hex("#F2F2F2"), colors::HOVERING), - ) - .build(ctx, "delay", hotkey(Key::I)), - Btn::svg( - "../data/system/assets/layers/throughput.svg", - RewriteColor::Change(Color::hex("#F2F2F2"), colors::HOVERING), - ) - .build(ctx, "throughput", hotkey(Key::T)), - Btn::svg( - "../data/system/assets/layers/bike_network.svg", - RewriteColor::Change(Color::hex("#F2F2F2"), colors::HOVERING), - ) - .build(ctx, "bike network", hotkey(Key::B)), - Btn::svg( - "../data/system/assets/layers/bus_network.svg", - RewriteColor::Change(Color::hex("#F2F2F2"), colors::HOVERING), - ) - .build(ctx, "bus network", hotkey(Key::U)), + Btn::text_fg("parking availability").build_def(ctx, hotkey(Key::P)), + Btn::text_fg("delay").build_def(ctx, hotkey(Key::I)), + Btn::text_fg("throughput").build_def(ctx, hotkey(Key::T)), + Btn::text_fg("bike network").build_def(ctx, hotkey(Key::B)), + Btn::text_fg("bus network").build_def(ctx, hotkey(Key::U)), ]; // TODO Grey out the inactive SVGs, and add the green checkmark - if let Some((find, replace)) = match app.overlay { - Overlays::Inactive => Some(("None", Button::inactive_button(ctx, "None"))), - Overlays::ParkingAvailability(_, _) => Some(( - "parking availability", - ManagedWidget::draw_svg(ctx, "../data/system/assets/layers/parking_avail.svg"), - )), - Overlays::WorstDelay(_, _) => Some(( - "delay", - ManagedWidget::draw_svg(ctx, "../data/system/assets/layers/intersection_delay.svg"), - )), - Overlays::TrafficJams(_, _) => Some(( - "worst traffic jams", - Button::inactive_button(ctx, "worst traffic jams"), - )), - Overlays::CumulativeThroughput(_, _) => Some(( - "throughput", - ManagedWidget::draw_svg(ctx, "../data/system/assets/layers/throughput.svg"), - )), - Overlays::BikeNetwork(_) => Some(( - "bike network", - ManagedWidget::draw_svg(ctx, "../data/system/assets/layers/bike_network.svg"), - )), - Overlays::BusNetwork(_) => Some(( - "bus network", - ManagedWidget::draw_svg(ctx, "../data/system/assets/layers/bus_network.svg"), - )), - Overlays::Elevation(_, _) => { - Some(("elevation", Button::inactive_button(ctx, "elevation"))) - } - Overlays::Edits(_) => Some(("map edits", Button::inactive_button(ctx, "map edits"))), + if let Some(name) = match app.overlay { + Overlays::Inactive => Some("None"), + Overlays::ParkingAvailability(_, _) => Some("parking availability"), + Overlays::WorstDelay(_, _) => Some("delay"), + Overlays::TrafficJams(_, _) => Some("worst traffic jams"), + Overlays::CumulativeThroughput(_, _) => Some("throughput"), + Overlays::BikeNetwork(_) => Some("bike network"), + Overlays::BusNetwork(_) => Some("bus network"), + Overlays::Elevation(_, _) => Some("elevation"), + Overlays::Edits(_) => Some("map edits"), _ => None, } { for btn in &mut choices { - if btn.is_btn(&find) { - *btn = replace.outline(2.0, Color::GREEN); + if btn.is_btn(name) { + *btn = Button::inactive_button(ctx, name).outline(2.0, Color::GREEN); break; } } @@ -330,13 +290,14 @@ impl Overlays { .build(ctx, "close", hotkey(Key::Escape)) .align_right(), ]), - ManagedWidget::row(choices).flex_wrap(ctx, 20), + ManagedWidget::row(choices.into_iter().map(|x| x.margin(5)).collect()) + .flex_wrap(ctx, 30), ]) .bg(colors::PANEL_BG) .outline(10.0, Color::WHITE) .padding(10), ) - .max_size_percent(30, 50) + .max_size_percent(35, 50) .build(ctx), ) .cb("close", Box::new(|_, _| Some(Transition::Pop))) @@ -351,60 +312,80 @@ impl Overlays { "parking availability", Box::new(|ctx, app| { app.overlay = Overlays::parking_availability(ctx, app); - Some(Transition::Pop) + Some(maybe_unzoom(ctx, app)) }), ) .maybe_cb( "delay", Box::new(|ctx, app| { app.overlay = Overlays::worst_delay(ctx, app); - Some(Transition::Pop) + Some(maybe_unzoom(ctx, app)) }), ) .maybe_cb( "worst traffic jams", Box::new(|ctx, app| { app.overlay = Overlays::traffic_jams(ctx, app); - Some(Transition::Pop) + Some(maybe_unzoom(ctx, app)) }), ) .maybe_cb( "throughput", Box::new(|ctx, app| { app.overlay = Overlays::cumulative_throughput(ctx, app); - Some(Transition::Pop) + Some(maybe_unzoom(ctx, app)) }), ) .maybe_cb( "bike network", Box::new(|ctx, app| { app.overlay = Overlays::bike_network(ctx, app); - Some(Transition::Pop) + Some(maybe_unzoom(ctx, app)) }), ) .maybe_cb( "bus network", Box::new(|ctx, app| { app.overlay = Overlays::bus_network(ctx, app); - Some(Transition::Pop) + Some(maybe_unzoom(ctx, app)) }), ) .maybe_cb( "elevation", Box::new(|ctx, app| { app.overlay = Overlays::elevation(ctx, app); - Some(Transition::Pop) + Some(maybe_unzoom(ctx, app)) }), ) .maybe_cb( "map edits", Box::new(|ctx, app| { app.overlay = Overlays::map_edits(ctx, app); - Some(Transition::Pop) + Some(maybe_unzoom(ctx, app)) }), ); Some(Transition::Push(ManagedGUIState::over_map(c))) } + + // Only for those hidden when zoomed in + pub fn zoomed_name(&self) -> Option<&'static str> { + match self { + Overlays::Inactive => None, + Overlays::ParkingAvailability(_, _) => Some("parking availability"), + Overlays::WorstDelay(_, _) => Some("delay"), + Overlays::TrafficJams(_, _) => Some("traffic jams"), + Overlays::CumulativeThroughput(_, _) => Some("throughput"), + Overlays::BikeNetwork(_) => Some("bike network"), + Overlays::BusNetwork(_) => Some("bus network"), + Overlays::Elevation(_, _) => Some("elevation"), + Overlays::Edits(_) => Some("map edits"), + Overlays::TripsHistogram(_, _) => None, + Overlays::IntersectionDemand(_, _, _, _) => None, + Overlays::BusRoute(_, _, _) => None, + Overlays::BusDelaysOverTime(_, _, _) => None, + Overlays::BusPassengers(_, _, _) => None, + } + } } impl Overlays { @@ -971,3 +952,16 @@ impl Overlays { Overlays::Edits(colorer.build(ctx, app)) } } + +fn maybe_unzoom(ctx: &EventCtx, app: &mut App) -> Transition { + if ctx.canvas.cam_zoom < MIN_ZOOM_FOR_DETAIL { + return Transition::Pop; + } + Transition::Replace(Warping::new( + ctx, + ctx.canvas.center_to_map_pt(), + Some(0.99 * MIN_ZOOM_FOR_DETAIL), + None, + &mut app.primary, + )) +}