mirror of
https://github.com/eliasstepanik/imgui-rs.git
synced 2026-01-11 13:38:35 +00:00
😍
This commit is contained in:
parent
79aaf9f62c
commit
e6cb406570
@ -11,28 +11,28 @@ fn main() {
|
||||
let mut click_count = 0;
|
||||
|
||||
system.main_loop(move |_, ui| {
|
||||
Window::new(im_str!("Disabling widgets"))
|
||||
Window::new("Disabling widgets")
|
||||
.size([300.0, 200.0], Condition::FirstUseEver)
|
||||
.build(ui, || {
|
||||
ui.checkbox(im_str!("Edit mode"), &mut edit_mode);
|
||||
ui.checkbox(im_str!("Safe mode"), &mut safe_mode);
|
||||
ui.checkbox("Edit mode", &mut edit_mode);
|
||||
ui.checkbox("Safe mode", &mut safe_mode);
|
||||
|
||||
ui.separator();
|
||||
|
||||
// Disable entire rest of widget unless in edit mode
|
||||
let _d = ui.begin_enabled(edit_mode);
|
||||
|
||||
if ui.button(im_str!("Button 1")) {
|
||||
if ui.button("Button 1") {
|
||||
click_count += 1;
|
||||
}
|
||||
if ui.button(im_str!("Button 2")) {
|
||||
if ui.button("Button 2") {
|
||||
click_count += 1;
|
||||
}
|
||||
|
||||
// Disable dangerous buttons when in safe mode
|
||||
ui.disabled(safe_mode, || {
|
||||
let _red = ui.push_style_color(StyleColor::Button, [1.0, 0.0, 0.0, 1.0]);
|
||||
if ui.button(im_str!("Dangerous button!")) {
|
||||
if ui.button("Dangerous button!") {
|
||||
click_count -= 1;
|
||||
}
|
||||
});
|
||||
@ -40,7 +40,7 @@ fn main() {
|
||||
// Can also create a token in a specific scope
|
||||
{
|
||||
let _danger_token = ui.begin_disabled(safe_mode);
|
||||
if ui.button(im_str!("Button 3")) {
|
||||
if ui.button("Button 3") {
|
||||
click_count += 1;
|
||||
}
|
||||
// _danger_token implicitly dropped here
|
||||
@ -48,7 +48,7 @@ fn main() {
|
||||
|
||||
// Or manually drop the token
|
||||
let danger_token2 = ui.begin_disabled(safe_mode);
|
||||
if ui.button(im_str!("Button 4")) {
|
||||
if ui.button("Button 4") {
|
||||
click_count += 1;
|
||||
}
|
||||
danger_token2.end();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user