Add CollapsingHeader::show_unindented (#2154)
This commit is contained in:
parent
aebec6329a
commit
1fadc7396a
1 changed files with 16 additions and 2 deletions
|
@ -599,13 +599,23 @@ impl CollapsingHeader {
|
||||||
ui: &mut Ui,
|
ui: &mut Ui,
|
||||||
add_body: impl FnOnce(&mut Ui) -> R,
|
add_body: impl FnOnce(&mut Ui) -> R,
|
||||||
) -> CollapsingResponse<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>(
|
fn show_dyn<'c, R>(
|
||||||
self,
|
self,
|
||||||
ui: &mut Ui,
|
ui: &mut Ui,
|
||||||
add_body: Box<dyn FnOnce(&mut Ui) -> R + 'c>,
|
add_body: Box<dyn FnOnce(&mut Ui) -> R + 'c>,
|
||||||
|
indented: bool,
|
||||||
) -> CollapsingResponse<R> {
|
) -> CollapsingResponse<R> {
|
||||||
// Make sure body is bellow header,
|
// Make sure body is bellow header,
|
||||||
// and make sure it is one unit (necessary for putting a [`CollapsingHeader`] in a grid).
|
// and make sure it is one unit (necessary for putting a [`CollapsingHeader`] in a grid).
|
||||||
|
@ -618,7 +628,11 @@ impl CollapsingHeader {
|
||||||
openness,
|
openness,
|
||||||
} = self.begin(ui); // show the header
|
} = 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 {
|
if let Some(ret_response) = ret_response {
|
||||||
CollapsingResponse {
|
CollapsingResponse {
|
||||||
|
|
Loading…
Reference in a new issue