From 2dca01ecd5222fc30db59ce206ca99a8e1a2fdd6 Mon Sep 17 00:00:00 2001 From: Paul Rouget Date: Sat, 1 Oct 2022 20:18:15 +0800 Subject: [PATCH] Bug Fix: Allocate Frame outer margins (#2089) --- crates/egui/src/containers/frame.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/crates/egui/src/containers/frame.rs b/crates/egui/src/containers/frame.rs index 0a317d4c..6a5b760d 100644 --- a/crates/egui/src/containers/frame.rs +++ b/crates/egui/src/containers/frame.rs @@ -244,6 +244,13 @@ impl Prepared { rect } + fn content_with_margin(&self) -> Rect { + let mut rect = self.content_ui.min_rect(); + rect.min -= self.frame.inner_margin.left_top() + self.frame.outer_margin.left_top(); + rect.max += self.frame.inner_margin.right_bottom() + self.frame.outer_margin.right_bottom(); + rect + } + pub fn end(self, ui: &mut Ui) -> Response { let paint_rect = self.paint_rect(); @@ -258,6 +265,6 @@ impl Prepared { ui.painter().set(where_to_put_background, shape); } - ui.allocate_rect(paint_rect, Sense::hover()) + ui.allocate_rect(self.content_with_margin(), Sense::hover()) } }