Work around the initial window size being wrong by reseting the minimap

when the window is resized. This is a bit unexpected if done
interactively in-game, but not unreasonable.

This mostly fixes the issue that sometimes happens starting with --dev.
When the resize happens late on X11, the minimap looks initially better,
but still cut off horizontally. Zooming in and out fixes it. (Before,
even zooming in/out would keep it tiny, because base_zoom was never
reset.)
This commit is contained in:
Dustin Carlino 2020-08-13 08:15:21 -07:00
parent 58849d3d15
commit d9da24b3d1

View File

@ -118,6 +118,17 @@ impl Minimap {
self.recenter(ctx, app);
}
}
if ctx.input.is_window_resized() {
// When the window is resized, just reset completely. This is important when the window
// size at startup is incorrect and immediately corrected by the window manager after
// Minimap::new happens.
let bounds = app.primary.map.get_bounds();
self.base_zoom = 0.15 * ctx.canvas.window_width / bounds.width().min(bounds.height());
self.zoom = self.base_zoom;
if self.zoomed {
self.recenter(ctx, app);
}
}
let pan_speed = 100.0;
match self.composite.event(ctx) {