diff --git a/ezgui/src/drawing.rs b/ezgui/src/drawing.rs index 3e44875e39..2b55e9ef26 100644 --- a/ezgui/src/drawing.rs +++ b/ezgui/src/drawing.rs @@ -204,15 +204,25 @@ impl<'a> GfxCtx<'a> { } pub fn draw_mouse_tooltip(&mut self, txt: Text) { + // Add some padding + let pad = 5.0; + let txt_batch = txt.render_g(self); - let dims = txt_batch.get_dims(); + let raw_dims = txt_batch.get_dims(); + let dims = ScreenDims::new(raw_dims.width + 2.0 * pad, raw_dims.height + 2.0 * pad); + // TODO Maybe also consider the cursor as a valid center let pt = dims.top_left_for_corner( ScreenPt::new(self.canvas.cursor_x, self.canvas.cursor_y + 20.0), &self.canvas, ); let mut batch = GeomBatch::new(); - batch.add_translated(txt_batch, pt.x, pt.y); + // TODO Outline? + batch.push( + Color::BLACK, + Polygon::rectangle(dims.width, dims.height).translate(pt.x, pt.y), + ); + batch.add_translated(txt_batch, pt.x + pad, pt.y + pad); // fork_screenspace, but with an even more prominent Z self.uniforms.transform = [0.0, 0.0, 1.0]; diff --git a/ezgui/src/widgets/button.rs b/ezgui/src/widgets/button.rs index a05c85f029..ae48a26125 100644 --- a/ezgui/src/widgets/button.rs +++ b/ezgui/src/widgets/button.rs @@ -45,12 +45,11 @@ impl Button { draw_normal: ctx.upload(normal), draw_hovered: ctx.upload(hovered), tooltip: if let Some(ref key) = hotkey { - let mut txt = - Text::from(Line(key.describe()).fg(text::HOTKEY_COLOR).size(20)).with_bg(); + let mut txt = Text::from(Line(key.describe()).fg(text::HOTKEY_COLOR).size(20)); txt.append(Line(format!(" - {}", tooltip))); txt } else { - Text::from(Line(tooltip).size(20)).with_bg() + Text::from(Line(tooltip).size(20)) }, hotkey, hitbox, diff --git a/ezgui/src/widgets/histogram.rs b/ezgui/src/widgets/histogram.rs index e959c73040..75afd9a653 100644 --- a/ezgui/src/widgets/histogram.rs +++ b/ezgui/src/widgets/histogram.rs @@ -60,8 +60,7 @@ impl Histogram { min, max, prettyprint_usize(cnt) - ))) - .bg(Color::BLACK), + ))), )); } } diff --git a/ezgui/src/widgets/plot.rs b/ezgui/src/widgets/plot.rs index 5193843538..c499be3693 100644 --- a/ezgui/src/widgets/plot.rs +++ b/ezgui/src/widgets/plot.rs @@ -196,7 +196,7 @@ impl> Plot if let Some(cursor) = g.canvas.get_cursor_in_screen_space() { if ScreenRectangle::top_left(self.top_left, self.dims).contains(cursor) { let radius = Distance::meters(15.0); - let mut txt = Text::new().bg(Color::BLACK); + let mut txt = Text::new(); for (label, pt, _) in self.closest.all_close_pts( Pt2D::new(cursor.x - self.top_left.x, cursor.y - self.top_left.y), radius, diff --git a/ezgui/src/widgets/popup_menu.rs b/ezgui/src/widgets/popup_menu.rs index 0511633367..d4aec8863a 100644 --- a/ezgui/src/widgets/popup_menu.rs +++ b/ezgui/src/widgets/popup_menu.rs @@ -132,7 +132,7 @@ impl PopupMenu { }; if let Some(pt) = g.canvas.get_cursor_in_screen_space() { if rect.contains(pt) { - let mut txt = Text::new().with_bg(); + let mut txt = Text::new(); txt.add_wrapped(info.to_string(), 0.5 * g.canvas.window_width); g.draw_mouse_tooltip(txt); } diff --git a/game/src/debug/objects.rs b/game/src/debug/objects.rs index e0a5f9f79c..859fe85702 100644 --- a/game/src/debug/objects.rs +++ b/game/src/debug/objects.rs @@ -41,7 +41,7 @@ impl ObjectDebugger { if self.debug_tooltip_key_held { if let Some(pt) = g.canvas.get_cursor_in_map_space() { if let Some(gps) = pt.to_gps(ui.primary.map.get_gps_bounds()) { - let mut txt = Text::new().with_bg(); + let mut txt = Text::new(); txt.add(Line(pt.to_string())); txt.add(Line(gps.to_string())); txt.add(Line(format!("{:?}", g.canvas.get_cursor()))); diff --git a/game/src/sandbox/gameplay/freeform.rs b/game/src/sandbox/gameplay/freeform.rs index 90c3c10702..52ed3ba349 100644 --- a/game/src/sandbox/gameplay/freeform.rs +++ b/game/src/sandbox/gameplay/freeform.rs @@ -64,7 +64,7 @@ impl GameplayState for Freeform { if let Some(ID::Intersection(i)) = ui.primary.current_selection { if self.spawn_pts.contains(&i) { - let mut txt = Text::new().with_bg(); + let mut txt = Text::new(); for line in ui.primary.sim.count_trips_involving_border(i).describe() { txt.add(Line(line)); } diff --git a/game/src/sandbox/speed.rs b/game/src/sandbox/speed.rs index 8be1217fa6..c5a67fb0d0 100644 --- a/game/src/sandbox/speed.rs +++ b/game/src/sandbox/speed.rs @@ -66,7 +66,7 @@ impl SpeedControls { ] .into_iter() .map(|(s, label)| { - let mut tooltip = Text::from(Line(label).size(20)).with_bg(); + let mut tooltip = Text::from(Line(label).size(20)); tooltip.add(Line(Key::LeftArrow.describe()).fg(Color::GREEN).size(20)); tooltip.append(Line(" - slow down")); tooltip.add(Line(Key::RightArrow.describe()).fg(Color::GREEN).size(20)); diff --git a/map_editor/src/main.rs b/map_editor/src/main.rs index 7ec77debaf..219542478f 100644 --- a/map_editor/src/main.rs +++ b/map_editor/src/main.rs @@ -650,7 +650,7 @@ impl GUI for UI { if show_tooltip { // TODO Argh, covers up mouseover tooltip. if let Some(cursor) = g.canvas.get_cursor_in_map_space() { - g.draw_mouse_tooltip(Text::from(Line(cursor.to_string())).with_bg()); + g.draw_mouse_tooltip(Text::from(Line(cursor.to_string()))); } } }