Window bounds fix: handle infinite drag_bounds

This commit is contained in:
Emil Ernerfeldt 2021-09-07 19:55:37 +02:00
parent 249876523d
commit d23982d83e

View file

@ -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,