2020-10-30 13:35:50 +00:00
|
|
|
use examples_shared;
|
|
|
|
use imgui::{im_str, Condition, Window};
|
|
|
|
use implot::Context;
|
2020-10-12 22:36:31 +00:00
|
|
|
|
2020-10-30 11:51:57 +00:00
|
|
|
// the actual implot samples are in there TODO(4bb4) move to using examples-shared instead
|
2020-10-30 13:35:50 +00:00
|
|
|
mod support;
|
2020-10-12 22:36:31 +00:00
|
|
|
|
2020-10-13 17:59:59 +00:00
|
|
|
fn main() {
|
2020-10-30 13:35:50 +00:00
|
|
|
let system = support::init(file!());
|
2020-10-12 22:36:31 +00:00
|
|
|
let mut showing_demo = false;
|
2020-10-30 13:35:50 +00:00
|
|
|
let mut showing_rust_demo = true;
|
|
|
|
let plotcontext = Context::create();
|
|
|
|
system.main_loop(move |_, ui| {
|
|
|
|
// The context is moved into the closure after creation so plot_ui is valid.
|
|
|
|
let plot_ui = plotcontext.get_plot_ui();
|
|
|
|
|
|
|
|
if showing_demo {
|
|
|
|
implot::show_demo_window(&mut showing_demo);
|
|
|
|
}
|
2020-10-12 22:36:31 +00:00
|
|
|
|
2020-10-30 13:35:50 +00:00
|
|
|
if showing_rust_demo {
|
|
|
|
examples_shared::show_demos(ui, &plot_ui);
|
2020-10-12 22:36:31 +00:00
|
|
|
}
|
|
|
|
|
2020-10-30 13:35:50 +00:00
|
|
|
Window::new(im_str!("Welcome to the ImPlot-rs demo!"))
|
|
|
|
.size([430.0, 450.0], Condition::FirstUseEver)
|
|
|
|
.build(ui, || {
|
|
|
|
ui.checkbox(im_str!("Show C++ ImPlot demo window"), &mut showing_demo);
|
|
|
|
ui.checkbox(
|
|
|
|
im_str!("Show Rust ImPlot demo windows"),
|
|
|
|
&mut showing_rust_demo,
|
|
|
|
);
|
|
|
|
// TODO(4bb4) ... move windows by default so this is less confusing
|
|
|
|
ui.text_wrapped(im_str!(
|
|
|
|
"Note that the windows are stacked, so move this one out of the way to see\
|
|
|
|
the ones beneath it."
|
|
|
|
));
|
|
|
|
});
|
2020-10-12 22:36:31 +00:00
|
|
|
});
|
|
|
|
}
|