[examples] test_window_impl: Add "stacked modals" example

This commit is contained in:
Malik Olivier Boussejra 2018-09-26 09:47:53 +09:00
parent 68b1d331b0
commit ae9a79bd50

View File

@ -50,6 +50,8 @@ struct State {
color_edit: ColorEditState,
custom_rendering: CustomRenderingState,
dont_ask_me_next_time: bool,
stacked_modals_item: i32,
stacked_modals_color: [f32; 4],
}
impl Default for State {
@ -103,6 +105,8 @@ impl Default for State {
color_edit: ColorEditState::default(),
custom_rendering: Default::default(),
dont_ask_me_next_time: false,
stacked_modals_item: 0,
stacked_modals_color: [0.4, 0.7, 0.0, 0.5],
}
}
}
@ -669,6 +673,31 @@ CTRL+click on individual component to input value.\n",
}
});
});
if ui.button(im_str!("Stacked modals.."), (0.0, 0.0)) {
ui.open_popup(im_str!("Stacked 1"));
}
ui.popup_modal(im_str!("Stacked 1")).build(|| {
ui.text(
"Hello from Stacked The First\n\
Using style.Colors[ImGuiCol_ModalWindowDarkening] for darkening."
);
let items = &[im_str!("aaaa"), im_str!("bbbb"), im_str!("cccc"), im_str!("dddd"), im_str!("eeee")];
ui.combo(im_str!("Combo"), &mut state.stacked_modals_item, items, -1);
ui.color_edit(im_str!("color"), &mut state.stacked_modals_color).build();
if ui.button(im_str!("Add another modal.."), (0.0, 0.0)) {
ui.open_popup(im_str!("Stacked 2")) ;
}
ui.popup_modal(im_str!("Stacked 2")).build(|| {
ui.text("Hello from Stacked The Second");
if ui.button(im_str!("Close"), (0.0, 0.0)) {
ui.close_current_popup();
}
});
});
});
}
})