diff --git a/game/src/info/transit.rs b/game/src/info/transit.rs index f5af79c687..f81b5f28f0 100644 --- a/game/src/info/transit.rs +++ b/game/src/info/transit.rs @@ -328,8 +328,7 @@ fn route_body(ctx: &mut EventCtx, app: &App, details: &mut Details, id: TransitR } } } - details.draw_extra.unzoomed.append(colorer.draw.unzoomed); - details.draw_extra.zoomed.append(colorer.draw.zoomed); + details.draw_extra.append(colorer.draw); for pt in bus_locations { details.draw_extra.unzoomed.push( diff --git a/game/src/layer/elevation.rs b/game/src/layer/elevation.rs index a6ebcc4722..ef8f19ad4e 100644 --- a/game/src/layer/elevation.rs +++ b/game/src/layer/elevation.rs @@ -117,7 +117,7 @@ impl SteepStreets { ); } } - colorer.unzoomed.append(arrows); + colorer.draw.unzoomed.append(arrows); (colorer, steepest, uphill_legend) } diff --git a/game/src/ungap/layers.rs b/game/src/ungap/layers.rs index 674c50b1ae..ee670f40f7 100644 --- a/game/src/ungap/layers.rs +++ b/game/src/ungap/layers.rs @@ -166,8 +166,8 @@ impl Layers { // The Colorer fades the map as the very first thing in the batch, but we // don't want to do that twice. // TODO Can't use no_fading without complicating make_colorer... - colorer.unzoomed.shift(); - self.steep_streets = Some(colorer.unzoomed.upload(ctx)); + colorer.draw.unzoomed.shift(); + self.steep_streets = Some(colorer.draw.unzoomed.upload(ctx)); } else { self.steep_streets = None; } diff --git a/map_gui/src/tools/colors.rs b/map_gui/src/tools/colors.rs index 0037b5d16f..d119ce12a0 100644 --- a/map_gui/src/tools/colors.rs +++ b/map_gui/src/tools/colors.rs @@ -11,8 +11,7 @@ use crate::AppLike; pub struct ColorDiscrete<'a> { map: &'a Map, // pub so callers can add stuff in before building - pub unzoomed: GeomBatch, - pub zoomed: GeomBatch, + pub draw: ToggleZoomedBuilder, // Store both, so we can build the legend in the original order later pub categories: Vec<(String, Color)>, colors: HashMap, @@ -23,8 +22,8 @@ impl<'a> ColorDiscrete<'a> { app: &'a dyn AppLike, categories: Vec<(I, Color)>, ) -> ColorDiscrete<'a> { - let mut unzoomed = GeomBatch::new(); - unzoomed.push( + let mut draw = ToggleZoomed::builder(); + draw.unzoomed.push( app.cs().fade_map_dark, app.map().get_boundary_polygon().clone(), ); @@ -32,8 +31,7 @@ impl<'a> ColorDiscrete<'a> { categories.into_iter().map(|(k, v)| (k.into(), v)).collect(); ColorDiscrete { map: app.map(), - unzoomed, - zoomed: GeomBatch::new(), + draw, colors: categories.iter().cloned().collect(), categories, } @@ -44,48 +42,60 @@ impl<'a> ColorDiscrete<'a> { categories: Vec<(I, Color)>, ) -> ColorDiscrete<'a> { let mut c = ColorDiscrete::new(app, categories); - c.unzoomed = GeomBatch::new(); + c.draw.unzoomed = GeomBatch::new(); c } pub fn add_l>(&mut self, l: LaneID, category: I) { let color = self.colors[category.as_ref()]; - self.unzoomed + self.draw + .unzoomed .push(color, self.map.get_parent(l).get_thick_polygon()); let lane = self.map.get_l(l); - self.zoomed.push(color.alpha(0.4), lane.get_thick_polygon()); + self.draw + .zoomed + .push(color.alpha(0.4), lane.get_thick_polygon()); } pub fn add_r>(&mut self, r: RoadID, category: I) { let color = self.colors[category.as_ref()]; - self.unzoomed + self.draw + .unzoomed .push(color, self.map.get_r(r).get_thick_polygon()); - self.zoomed + self.draw + .zoomed .push(color.alpha(0.4), self.map.get_r(r).get_thick_polygon()); } pub fn add_i>(&mut self, i: IntersectionID, category: I) { let color = self.colors[category.as_ref()]; - self.unzoomed.push(color, self.map.get_i(i).polygon.clone()); - self.zoomed + self.draw + .unzoomed + .push(color, self.map.get_i(i).polygon.clone()); + self.draw + .zoomed .push(color.alpha(0.4), self.map.get_i(i).polygon.clone()); } pub fn add_b>(&mut self, b: BuildingID, category: I) { let color = self.colors[category.as_ref()]; - self.unzoomed.push(color, self.map.get_b(b).polygon.clone()); - self.zoomed + self.draw + .unzoomed + .push(color, self.map.get_b(b).polygon.clone()); + self.draw + .zoomed .push(color.alpha(0.4), self.map.get_b(b).polygon.clone()); } pub fn add_ts>(&mut self, ts: TransitStopID, category: I) { let color = self.colors[category.as_ref()]; let pt = self.map.get_ts(ts).sidewalk_pos.pt(self.map); - self.zoomed.push( + self.draw.zoomed.push( color.alpha(0.4), Circle::new(pt, Distance::meters(5.0)).to_polygon(), ); - self.unzoomed + self.draw + .unzoomed .push(color, Circle::new(pt, Distance::meters(15.0)).to_polygon()); } @@ -95,10 +105,7 @@ impl<'a> ColorDiscrete<'a> { .into_iter() .map(|(name, color)| ColorLegend::row(ctx, color, name)) .collect(); - ( - ToggleZoomed::new(ctx, self.unzoomed, self.zoomed), - Widget::col(legend), - ) + (self.draw.build(ctx), Widget::col(legend)) } }