From d23982d83e5133b7c6462e5b2438ef69ec6ef1a3 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Tue, 7 Sep 2021 19:55:37 +0200 Subject: [PATCH] Window bounds fix: handle infinite drag_bounds --- egui/src/containers/area.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/egui/src/containers/area.rs b/egui/src/containers/area.rs index f923f538..e55b9124 100644 --- a/egui/src/containers/area.rs +++ b/egui/src/containers/area.rs @@ -274,16 +274,20 @@ impl Prepared { } pub(crate) fn content_ui(&self, ctx: &CtxRef) -> Ui { - let bounds = self.drag_bounds.unwrap_or_else(|| { + let screen_rect = ctx.input().screen_rect(); + + let bounds = if let Some(bounds) = self.drag_bounds { + bounds.intersect(screen_rect) // protect against infinite bounds + } else { let central_area = ctx.available_rect(); let is_within_central_area = central_area.contains_rect(self.state.rect().shrink(1.0)); if is_within_central_area { central_area // let's try to not cover side panels } else { - ctx.input().screen_rect() + screen_rect } - }); + }; let max_rect = Rect::from_min_max( self.state.pos,