diff --git a/ezgui/src/widgets/scatter_plot.rs b/ezgui/src/widgets/scatter_plot.rs index c4d7d2c420..1c38299b1e 100644 --- a/ezgui/src/widgets/scatter_plot.rs +++ b/ezgui/src/widgets/scatter_plot.rs @@ -1,6 +1,6 @@ use crate::{ - Color, Drawable, EventCtx, GeomBatch, GfxCtx, Line, ScreenDims, ScreenPt, ScreenRectangle, - Text, TextExt, Widget, WidgetImpl, WidgetOutput, + Color, Drawable, EventCtx, GeomBatch, GfxCtx, JustDraw, Line, ScreenDims, ScreenPt, + ScreenRectangle, Text, TextExt, Widget, WidgetImpl, WidgetOutput, }; use geom::{Angle, Circle, Distance, Duration, Pt2D}; @@ -101,7 +101,8 @@ impl ScatterPlot { { label.fancy_push(color, poly.rotate(Angle::new_degs(90.0))); } - Widget::draw_batch(ctx, label.autocrop()).centered_vert() + // The text is already scaled; don't use Widget::draw_batch and scale it again. + JustDraw::wrap(ctx, label.autocrop()).centered_vert() }; let x_axis = Widget::row( diff --git a/game/src/sandbox/dashboards/misc.rs b/game/src/sandbox/dashboards/misc.rs index de8671bfcc..81967bd60d 100644 --- a/game/src/sandbox/dashboards/misc.rs +++ b/game/src/sandbox/dashboards/misc.rs @@ -35,7 +35,7 @@ impl ActiveTraffic { Box::new(ActiveTraffic { composite: Composite::new( Widget::col(vec![ - DashTab::ActiveTraffic.picker(ctx), + DashTab::ActiveTraffic.picker(ctx, app), LinePlot::new(ctx, "active agents", active_agents, PlotOptions::new()), ]) .bg(app.cs.panel_bg) @@ -82,7 +82,7 @@ impl BusRoutes { routes.sort(); let mut col = vec![ - DashTab::BusRoutes.picker(ctx), + DashTab::BusRoutes.picker(ctx, app), Line("Bus routes").small_heading().draw(ctx), ]; for r in routes { diff --git a/game/src/sandbox/dashboards/mod.rs b/game/src/sandbox/dashboards/mod.rs index 36e426d112..826cbb6245 100644 --- a/game/src/sandbox/dashboards/mod.rs +++ b/game/src/sandbox/dashboards/mod.rs @@ -19,7 +19,7 @@ pub enum DashTab { } impl DashTab { - pub fn picker(self, ctx: &EventCtx) -> Widget { + pub fn picker(self, ctx: &EventCtx, app: &App) -> Widget { let mut row = Vec::new(); for (name, tab) in vec![ ("trip table", DashTab::TripTable), @@ -28,6 +28,9 @@ impl DashTab { ("active traffic", DashTab::ActiveTraffic), ("bus routes", DashTab::BusRoutes), ] { + if tab == DashTab::TripSummaries && app.has_prebaked().is_none() { + continue; + } if self == tab { row.push(Btn::text_bg2(name).inactive(ctx)); } else { diff --git a/game/src/sandbox/dashboards/parking_overhead.rs b/game/src/sandbox/dashboards/parking_overhead.rs index e16ddaf20b..9684a58177 100644 --- a/game/src/sandbox/dashboards/parking_overhead.rs +++ b/game/src/sandbox/dashboards/parking_overhead.rs @@ -268,7 +268,7 @@ fn make(ctx: &mut EventCtx, app: &App, opts: &Options) -> Composite { btn(SortBy::PercentOverhead, "Percent overhead"), ]; - let mut col = vec![DashTab::ParkingOverhead.picker(ctx)]; + let mut col = vec![DashTab::ParkingOverhead.picker(ctx, app)]; col.push( Widget::row(vec![ Text::from_multiline(vec![ diff --git a/game/src/sandbox/dashboards/summaries.rs b/game/src/sandbox/dashboards/summaries.rs index ec22256414..ded178194a 100644 --- a/game/src/sandbox/dashboards/summaries.rs +++ b/game/src/sandbox/dashboards/summaries.rs @@ -46,7 +46,7 @@ impl TripSummaries { Box::new(TripSummaries { composite: Composite::new( Widget::col(vec![ - DashTab::TripSummaries.picker(ctx), + DashTab::TripSummaries.picker(ctx, app), Widget::row(filters).centered_horiz().margin_below(10), summary(ctx, app, &filter).margin_below(10), Widget::row(vec![ diff --git a/game/src/sandbox/dashboards/trip_table.rs b/game/src/sandbox/dashboards/trip_table.rs index 30e323819e..f27d461bbe 100644 --- a/game/src/sandbox/dashboards/trip_table.rs +++ b/game/src/sandbox/dashboards/trip_table.rs @@ -314,7 +314,7 @@ fn make(ctx: &mut EventCtx, app: &App, opts: &Options) -> Composite { headers.push(btn(SortBy::Waiting, "Time spent waiting")); headers.push(btn(SortBy::PercentWaiting, "Percent waiting")); - let mut col = vec![DashTab::TripTable.picker(ctx)]; + let mut col = vec![DashTab::TripTable.picker(ctx, app)]; let mut filters = Vec::new(); for m in TripMode::all() { filters.push( @@ -402,10 +402,14 @@ pub fn make_table( rows: Vec<(String, Vec)>, total_width: f64, ) -> Vec { - let mut width_per_col: Vec = headers.iter().map(|w| w.get_width_for_forcing()).collect(); + let total_width = total_width / ctx.get_scale_factor(); + let mut width_per_col: Vec = headers + .iter() + .map(|w| w.get_width_for_forcing() / ctx.get_scale_factor()) + .collect(); for (_, row) in &rows { for (col, width) in row.iter().zip(width_per_col.iter_mut()) { - *width = width.max(col.get_dims().width); + *width = width.max(col.get_dims().width / ctx.get_scale_factor()); } } let extra_margin = ((total_width - width_per_col.clone().into_iter().sum::()) @@ -417,7 +421,8 @@ pub fn make_table( .into_iter() .enumerate() .map(|(idx, w)| { - let margin = extra_margin + width_per_col[idx] - w.get_width_for_forcing(); + let margin = extra_margin + width_per_col[idx] + - (w.get_width_for_forcing() / ctx.get_scale_factor()); if idx == width_per_col.len() - 1 { w.margin_right((margin - extra_margin) as usize) } else { @@ -433,7 +438,7 @@ pub fn make_table( batch.autocrop_dims = false; let mut x1 = 0.0; for (col, width) in row.into_iter().zip(width_per_col.iter()) { - batch.add_translated(col, x1, 0.0); + batch.add_translated(col.scale(1.0 / ctx.get_scale_factor()), x1, 0.0); x1 += *width + extra_margin; }