From 1fadc7396a1871ca9e73894f72cc478d79cd402e Mon Sep 17 00:00:00 2001 From: "Lily M. Lyons" Date: Mon, 24 Oct 2022 08:10:13 -0700 Subject: [PATCH] Add CollapsingHeader::show_unindented (#2154) --- .../egui/src/containers/collapsing_header.rs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/crates/egui/src/containers/collapsing_header.rs b/crates/egui/src/containers/collapsing_header.rs index b1a4eca6..febf0d1b 100644 --- a/crates/egui/src/containers/collapsing_header.rs +++ b/crates/egui/src/containers/collapsing_header.rs @@ -599,13 +599,23 @@ impl CollapsingHeader { ui: &mut Ui, add_body: impl FnOnce(&mut Ui) -> R, ) -> CollapsingResponse { - self.show_dyn(ui, Box::new(add_body)) + self.show_dyn(ui, Box::new(add_body), true) + } + + #[inline] + pub fn show_unindented( + self, + ui: &mut Ui, + add_body: impl FnOnce(&mut Ui) -> R, + ) -> CollapsingResponse { + self.show_dyn(ui, Box::new(add_body), false) } fn show_dyn<'c, R>( self, ui: &mut Ui, add_body: Box R + 'c>, + indented: bool, ) -> CollapsingResponse { // Make sure body is bellow header, // and make sure it is one unit (necessary for putting a [`CollapsingHeader`] in a grid). @@ -618,7 +628,11 @@ impl CollapsingHeader { openness, } = self.begin(ui); // show the header - let ret_response = state.show_body_indented(&header_response, ui, add_body); + let ret_response = if indented { + state.show_body_indented(&header_response, ui, add_body) + } else { + state.show_body_unindented(ui, add_body) + }; if let Some(ret_response) = ret_response { CollapsingResponse {