use crate::Plot3DUi;
use crate::layout::NextItemStyle;
use dear_imgui_rs::{DrawListMut, NativeWindowScope};
pub struct Plot3DSetup<'plot> {
pub(crate) plot: &'plot Plot3DScope<'plot>,
}
impl Plot3DSetup<'_> {
pub(crate) fn with_bound_context<R>(&self, f: impl FnOnce() -> R) -> R {
self.plot.with_bound_context(f)
}
}
pub struct Plot3DScope<'plot> {
pub(crate) ui: Plot3DUi<'plot>,
pub(crate) host: &'plot NativeWindowScope<'plot>,
pub(crate) next_item: NextItemStyle,
}
impl Plot3DScope<'_> {
pub(crate) fn with_bound_context<R>(&self, f: impl FnOnce() -> R) -> R {
assert!(
self.host.is_current(),
"ImPlot3D requires the plot's host window and table cell"
);
self.ui.with_bound_context(f)
}
pub fn plot_draw_list(&self) -> DrawListMut<'_> {
self.with_bound_context(|| self.ui.imgui.get_window_draw_list())
}
}