1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
use super::*;
impl InspectRenderDefault<bool> for bool {
fn render(data: &[&bool], label: &'static str, ui: &imgui::Ui, _args: &InspectArgsDefault) {
if data.len() == 0 {
let style_token = ui.push_style_color(imgui::StyleColor::Text, [1.0, 0.0, 0.0, 1.0]);
ui.text(&imgui::im_str!("{}: ", label));
style_token.pop(ui);
return;
}
match get_same_or_none(data) {
Some(_v) => {
ui.text(&imgui::im_str!("{}: {}", label, data[0]))
}
None => {
let style_token =
ui.push_style_color(imgui::StyleColor::Text, [1.0, 1.0, 0.0, 1.0]);
ui.text(&imgui::im_str!("{}: ", label));
style_token.pop(ui);
}
}
}
fn render_mut(
data: &mut [&mut bool],
label: &'static str,
ui: &imgui::Ui,
_args: &InspectArgsDefault,
) -> bool {
let same_or_none_value = get_same_or_none_mut(data);
let mut value = match same_or_none_value {
Some(v) => v,
None => false,
};
let style_token = if same_or_none_value.is_none() {
Some(ui.push_style_color(imgui::StyleColor::Text, [1.0, 1.0, 0.0, 1.0]))
} else {
None
};
let mut changed = false;
if ui.checkbox(&imgui::im_str!("{}", label), &mut value) {
for d in data {
**d = value;
changed = true;
}
}
if let Some(style_token) = style_token {
style_token.pop(ui);
}
changed
}
}