use super::*;
impl InspectRenderDefault<bool> for bool {
fn render(
data: &[&bool],
label: &'static str,
ui: &imgui::Ui,
_args: &InspectArgsDefault,
) {
if data.is_empty() {
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 = same_or_none_value.unwrap_or(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
}
}