diff --git a/ezgui/src/widgets/line_plot.rs b/ezgui/src/widgets/line_plot.rs index 2a8da30791..8caca6a22b 100644 --- a/ezgui/src/widgets/line_plot.rs +++ b/ezgui/src/widgets/line_plot.rs @@ -1,5 +1,5 @@ use crate::{ - Checkbox, Color, Drawable, EventCtx, GeomBatch, GfxCtx, Line, ScreenDims, ScreenPt, + Checkbox, Color, Drawable, EventCtx, GeomBatch, GfxCtx, JustDraw, Line, ScreenDims, ScreenPt, ScreenRectangle, Text, TextExt, Widget, WidgetImpl, WidgetOutput, }; use abstutil::prettyprint_usize; @@ -217,7 +217,8 @@ impl> LinePlot { for (color, poly) in Text::from(Line(t.to_string())).render_ctx(ctx).consume() { batch.fancy_push(color, poly.rotate(Angle::new_degs(-15.0))); } - row.push(Widget::draw_batch(ctx, batch.autocrop())); + // The text is already scaled; don't use Widget::draw_batch and scale it again. + row.push(JustDraw::wrap(ctx, batch.autocrop())); } let x_axis = Widget::row(row).padding(10); diff --git a/game/src/common/mod.rs b/game/src/common/mod.rs index a39ac4e1ff..7dc51e6a76 100644 --- a/game/src/common/mod.rs +++ b/game/src/common/mod.rs @@ -15,7 +15,10 @@ use crate::game::Transition; use crate::helpers::{list_names, ID}; use crate::info::InfoPanel; pub use crate::info::{ContextualActions, Tab}; -use ezgui::{hotkey, lctrl, Color, EventCtx, GeomBatch, GfxCtx, Key, Line, ScreenPt, Text}; +use ezgui::{ + hotkey, lctrl, Color, EventCtx, GeomBatch, GfxCtx, Key, Line, ScreenDims, ScreenPt, + ScreenRectangle, Text, +}; use geom::Polygon; use std::collections::BTreeSet; @@ -256,6 +259,10 @@ impl CommonState { let draw = g.upload(batch); let top_left = ScreenPt::new(0.0, g.canvas.window_height - 1.5 * g.default_line_height()); g.redraw_at(top_left, &draw); + g.canvas.mark_covered_area(ScreenRectangle::top_left( + top_left, + ScreenDims::new(g.canvas.window_width, 1.5 * g.default_line_height()), + )); } // Meant to be used for launching from other states diff --git a/game/src/edit/traffic_signals.rs b/game/src/edit/traffic_signals.rs index c2e5022ebc..9590fe5376 100644 --- a/game/src/edit/traffic_signals.rs +++ b/game/src/edit/traffic_signals.rs @@ -183,7 +183,10 @@ impl State for TrafficSignalEditor { "Export" => { let ts = orig_signal.export(&app.primary.map); abstutil::write_json( - format!("traffic_signal_data/{}.json", ts.intersection_osm_node_id), + format!( + "../traffic_signal_data/{}.json", + ts.intersection_osm_node_id + ), &ts, ); } @@ -288,7 +291,9 @@ impl State for TrafficSignalEditor { pub fn make_top_panel(ctx: &mut EventCtx, app: &App, can_undo: bool, can_redo: bool) -> Composite { let row = vec![ - Btn::text_fg("Finish").build_def(ctx, hotkey(Key::Escape)), + Btn::text_fg("Finish") + .build_def(ctx, hotkey(Key::Escape)) + .margin_right(5), Btn::text_fg("Preview").build_def(ctx, lctrl(Key::P)), (if can_undo { Btn::svg_def("../data/system/assets/tools/undo.svg").build(ctx, "undo", lctrl(Key::Z)) @@ -316,12 +321,21 @@ pub fn make_top_panel(ctx: &mut EventCtx, app: &App, can_undo: bool, can_redo: b }) .margin(15), if app.opts.dev { - Btn::text_fg("Export").build_def(ctx, None) + Btn::text_fg("Export") + .tooltip(Text::from_multiline(vec![ + Line("This will create a JSON file in traffic_signal_data/.").small(), + Line( + "Contribute this to map how this traffic signal is currently timed in \ + real life.", + ) + .small(), + ])) + .build_def(ctx, None) } else { Widget::nothing() }, ]; - Composite::new(Widget::row(row).bg(app.cs.panel_bg)) + Composite::new(Widget::row(row).bg(app.cs.panel_bg).padding(5)) .aligned(HorizontalAlignment::Center, VerticalAlignment::Top) .build(ctx) } diff --git a/game/src/info/intersection.rs b/game/src/info/intersection.rs index 75fe4d3c0f..1dc9c00a93 100644 --- a/game/src/info/intersection.rs +++ b/game/src/info/intersection.rs @@ -131,6 +131,7 @@ pub fn current_demand( let zoom = 300.0 / bounds.width(); batch.push(app.cs.normal_intersection, polygon); + let mut txt_batch = GeomBatch::new(); for (pl, demand) in demand_per_group { let percent = (demand as f64) / (total_demand as f64); batch.push( @@ -138,14 +139,15 @@ pub fn current_demand( pl.make_arrow(percent * Distance::meters(3.0), ArrowCap::Triangle) .unwrap(), ); - batch.add_transformed( + txt_batch.add_transformed( Text::from(Line(prettyprint_usize(demand))).render_ctx(ctx), pl.middle(), - 0.15, + 0.15 / ctx.get_scale_factor(), Angle::ZERO, RewriteColor::NoOp, ); } + batch.append(txt_batch); let mut transformed_batch = GeomBatch::new(); for (color, poly) in batch.consume() { transformed_batch.fancy_push( diff --git a/game/src/info/trip.rs b/game/src/info/trip.rs index 2ce5f2bf55..bc58028918 100644 --- a/game/src/info/trip.rs +++ b/game/src/info/trip.rs @@ -367,7 +367,7 @@ fn make_timeline( let total_duration_so_far = end_time.unwrap_or_else(|| sim.time()) - phases[0].start_time; - let total_width = 0.22 * ctx.canvas.window_width; + let total_width = 0.22 * ctx.canvas.window_width / ctx.get_scale_factor(); let mut timeline = Vec::new(); let num_phases = phases.len(); let mut elevation = Vec::new(); diff --git a/game/src/render/traffic_signal.rs b/game/src/render/traffic_signal.rs index 1ebc4f96db..2ff8f2e959 100644 --- a/game/src/render/traffic_signal.rs +++ b/game/src/render/traffic_signal.rs @@ -328,7 +328,7 @@ pub fn make_signal_diagram( ctx, GeomBatch::from(vec![( Color::WHITE, - Polygon::rectangle(0.2 * ctx.canvas.window_width, 2.0), + Polygon::rectangle(0.2 * ctx.canvas.window_width / ctx.get_scale_factor(), 2.0), )]), ) .margin(15) @@ -411,7 +411,7 @@ pub fn make_signal_diagram( } } - Composite::new(Widget::col(col).bg(app.cs.panel_bg)) + Composite::new(Widget::col(col).bg(app.cs.panel_bg).padding(10)) .aligned(HorizontalAlignment::Left, VerticalAlignment::Top) .max_size_percent(30, 85) .build(ctx) diff --git a/game/src/sandbox/mod.rs b/game/src/sandbox/mod.rs index 5fd2fcf1ac..efa430610a 100644 --- a/game/src/sandbox/mod.rs +++ b/game/src/sandbox/mod.rs @@ -310,7 +310,7 @@ impl AgentMeter { ctx, GeomBatch::from(vec![( Color::WHITE, - Polygon::rectangle(0.2 * ctx.canvas.window_width, 2.0), + Polygon::rectangle(0.2 * ctx.canvas.window_width / ctx.get_scale_factor(), 2.0), )]), ) .margin(15)