From 6e3604ee4bd83bb06a7e49a8c5076f5a54d00fad Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Thu, 24 Jun 2021 15:08:16 +0200 Subject: [PATCH] =?UTF-8?q?Bug=20fix:=20ui.scope(=E2=80=A6)=20is=20now=20e?= =?UTF-8?q?quivalent=20to=20ui.allocate=5Fspace(=E2=80=A6)=20WRT=20IDs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Before a disabled and enabled button would leave the parent ui in different states, which lead to a bug where a slider drag could be aborted if it caused a button before it to switch between enabled and disabled. Repro: dragging slider in "Manual Layout Test" --- egui/src/ui.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/egui/src/ui.rs b/egui/src/ui.rs index ff7e8865..b92539df 100644 --- a/egui/src/ui.rs +++ b/egui/src/ui.rs @@ -1280,7 +1280,9 @@ impl Ui { /// ``` pub fn scope(&mut self, add_contents: impl FnOnce(&mut Ui) -> R) -> InnerResponse { let child_rect = self.available_rect_before_wrap(); + let next_auto_id_source = self.next_auto_id_source; let mut child_ui = self.child_ui(child_rect, *self.layout()); + self.next_auto_id_source = next_auto_id_source; // HACK: we want `scope` to only increment this once, so that `ui.scope` is equivalent to `ui.allocate_space`. let ret = add_contents(&mut child_ui); let response = self.allocate_rect(child_ui.min_rect(), Sense::hover()); InnerResponse::new(ret, response)