Browse Source

Add CollapsingHeader::show_unindented (#2154)

pull/2232/head
Lily M. Lyons 2 years ago
committed by GitHub
parent
commit
1fadc7396a
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 18
      crates/egui/src/containers/collapsing_header.rs

18
crates/egui/src/containers/collapsing_header.rs

@ -599,13 +599,23 @@ impl CollapsingHeader {
ui: &mut Ui,
add_body: impl FnOnce(&mut Ui) -> R,
) -> CollapsingResponse<R> {
self.show_dyn(ui, Box::new(add_body))
self.show_dyn(ui, Box::new(add_body), true)
}
#[inline]
pub fn show_unindented<R>(
self,
ui: &mut Ui,
add_body: impl FnOnce(&mut Ui) -> R,
) -> CollapsingResponse<R> {
self.show_dyn(ui, Box::new(add_body), false)
}
fn show_dyn<'c, R>(
self,
ui: &mut Ui,
add_body: Box<dyn FnOnce(&mut Ui) -> R + 'c>,
indented: bool,
) -> CollapsingResponse<R> {
// 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 {

Loading…
Cancel
Save