refactor: simplify CollapsingHeader enable/disable code
This commit is contained in:
parent
7ac91970bd
commit
0c9b4858f0
1 changed files with 31 additions and 34 deletions
|
@ -281,18 +281,17 @@ impl CollapsingHeader {
|
||||||
ui: &mut Ui,
|
ui: &mut Ui,
|
||||||
add_contents: impl FnOnce(&mut Ui) -> R,
|
add_contents: impl FnOnce(&mut Ui) -> R,
|
||||||
) -> CollapsingResponse<R> {
|
) -> CollapsingResponse<R> {
|
||||||
let header_enabled = self.enabled;
|
|
||||||
ui.wrap(|ui| {
|
|
||||||
ui.set_enabled(header_enabled);
|
|
||||||
|
|
||||||
// Make sure contents are bellow header,
|
// Make sure contents are 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).
|
||||||
ui.vertical(|ui| {
|
ui.vertical(|ui| {
|
||||||
|
ui.set_enabled(self.enabled);
|
||||||
|
|
||||||
let Prepared {
|
let Prepared {
|
||||||
id,
|
id,
|
||||||
header_response,
|
header_response,
|
||||||
mut state,
|
mut state,
|
||||||
} = self.begin(ui);
|
} = self.begin(ui);
|
||||||
|
|
||||||
let ret_response = state.add_contents(ui, id, |ui| {
|
let ret_response = state.add_contents(ui, id, |ui| {
|
||||||
ui.indent(id, |ui| {
|
ui.indent(id, |ui| {
|
||||||
// make as wide as the header:
|
// make as wide as the header:
|
||||||
|
@ -318,8 +317,6 @@ impl CollapsingHeader {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.inner
|
.inner
|
||||||
})
|
|
||||||
.inner
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue