Added support for linked axes. See comments.
This commit adds support for linked axes between plots. One can specify such linked limits using the new `linked_x_axis()` function (and the variants for the Y axes) by specifying an `Rc<RefCell<ImPlotRange>>` value, and passing clones of the same `Rc` to other plots. The values within those `Rc` need to be kept persistent between frames, hence the way to use this functionality is to keep a clone of the `Rc` outside the frame-drawing function as part of the application state. The regular limit setting API is unaffected.
This commit is contained in:
parent
ad80781f4d
commit
06cc3061c1
5 changed files with 570 additions and 391 deletions
|
@ -8,6 +8,7 @@ fn main() {
|
|||
let system = support::init(file!());
|
||||
let mut showing_demo = false;
|
||||
let mut showing_rust_demo = true;
|
||||
let mut demo_state = examples_shared::DemoState::new();
|
||||
let plotcontext = Context::create();
|
||||
system.main_loop(move |_, ui| {
|
||||
// The context is moved into the closure after creation so plot_ui is valid.
|
||||
|
@ -18,7 +19,7 @@ fn main() {
|
|||
}
|
||||
|
||||
if showing_rust_demo {
|
||||
examples_shared::show_demos(ui, &plot_ui);
|
||||
demo_state.show_demos(ui, &plot_ui);
|
||||
}
|
||||
|
||||
Window::new(im_str!("Welcome to the ImPlot-rs demo!"))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue