From 7b641be7b06be8b81b66d63968f081718acc7c89 Mon Sep 17 00:00:00 2001 From: Lampsitter <96946613+lampsitter@users.noreply.github.com> Date: Sat, 8 Jan 2022 10:07:02 +0100 Subject: [PATCH] Don't constrain immovable egui windows to native window (#1049) --- CHANGELOG.md | 1 + egui/src/containers/window.rs | 14 ++++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index be641726..0093f20a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ NOTE: [`epaint`](epaint/CHANGELOG.md), [`eframe`](eframe/CHANGELOG.md), [`egui_w ### Fixed 🐛 * Context menu now respects the theme ([#1043](https://github.com/emilk/egui/pull/1043)) +* Immovable windows can no longer incorrectly move ([#1049](https://github.com/emilk/egui/pull/1049)) ## 0.16.1 - 2021-12-31 - Add back `CtxRef::begin_frame,end_frame` diff --git a/egui/src/containers/window.rs b/egui/src/containers/window.rs index 4eceac70..3c80a5d0 100644 --- a/egui/src/containers/window.rs +++ b/egui/src/containers/window.rs @@ -399,9 +399,11 @@ impl<'open> Window<'open> { content_inner }; - area.state_mut().pos = ctx - .constrain_window_rect_to_area(area.state().rect(), area.drag_bounds()) - .min; + if area.movable { + area.state_mut().pos = ctx + .constrain_window_rect_to_area(area.state().rect(), area.drag_bounds()) + .min; + } let full_response = area.end(ctx, area_content_ui); @@ -508,7 +510,11 @@ fn interact( let new_rect = move_and_resize_window(ctx, &window_interaction)?; let new_rect = ctx.round_rect_to_pixels(new_rect); - let new_rect = ctx.constrain_window_rect_to_area(new_rect, area.drag_bounds()); + let new_rect = if area.movable { + ctx.constrain_window_rect_to_area(new_rect, area.drag_bounds()) + } else { + new_rect + }; // TODO: add this to a Window state instead as a command "move here next frame" area.state_mut().pos = new_rect.min;