From 8ce59e703f491ed48c924cd037045d3965961be1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20R=C3=B6ssler?= Date: Wed, 9 Feb 2022 13:32:53 +0100 Subject: [PATCH] shrink rect --- egui_extras/src/layout.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/egui_extras/src/layout.rs b/egui_extras/src/layout.rs index 101d98e1..abca17b2 100644 --- a/egui_extras/src/layout.rs +++ b/egui_extras/src/layout.rs @@ -39,11 +39,9 @@ pub struct Layout<'l> { impl<'l> Layout<'l> { pub(crate) fn new(ui: &'l mut Ui, padding: Padding, direction: LineDirection) -> Self { - let mut rect = ui.available_rect_before_wrap(); - rect.set_left(rect.left() + padding.outer + padding.inner); - rect.set_top(rect.top() + padding.outer + padding.inner); - rect.set_width(rect.width() - 2.0 * padding.outer); - rect.set_height(rect.height() - 2.0 * padding.outer); + let rect = ui + .available_rect_before_wrap() + .shrink(padding.inner + padding.outer); let pos = rect.left_top(); Self {