Skip to main content

dear_implot3d/
demos.rs

1use crate::Plot3DUi;
2use crate::sys;
3
4impl Plot3DUi<'_> {
5    fn show_native_tool(&self, show: impl FnOnce()) {
6        // Upstream demos can begin plots. The metrics and style tools can clear plot/item caches.
7        let _exclusive = self.context.enter_plot();
8        self.with_bound_context(show);
9    }
10
11    /// Show upstream ImPlot3D demos (from C++ demo).
12    ///
13    /// This displays all available ImPlot3D demos in a single window.
14    /// Useful for learning and testing the library.
15    pub fn show_all_demos(&self) {
16        self.show_native_tool(|| unsafe { sys::ImPlot3D_ShowAllDemos() })
17    }
18
19    /// Show the ImPlot3D demo. Its ImGui tools use the core font-atlas filter.
20    ///
21    /// This displays the main demo window with tabs for different plot types.
22    pub fn show_demo_window(&self) {
23        self.show_native_tool(|| unsafe { sys::ImPlot3D_ShowDemoWindow(std::ptr::null_mut()) })
24    }
25
26    /// Show the main ImPlot3D demo window with a visibility flag.
27    pub fn show_demo_window_with_flag(&self, p_open: &mut bool) {
28        self.show_native_tool(|| unsafe { sys::ImPlot3D_ShowDemoWindow(p_open as *mut bool) })
29    }
30
31    /// Show the style editor with this plot context's saved reference and color preview.
32    ///
33    /// This displays a window for editing ImPlot3D style settings in real time.
34    pub fn show_style_editor(&self) {
35        self.show_native_tool(|| unsafe { sys::ImPlot3D_ShowStyleEditor(std::ptr::null_mut()) })
36    }
37
38    /// Show the ImPlot3D metrics/debugger window.
39    ///
40    /// This displays performance metrics and debugging information.
41    pub fn show_metrics_window(&self) {
42        self.show_native_tool(|| unsafe { sys::ImPlot3D_ShowMetricsWindow(std::ptr::null_mut()) })
43    }
44
45    /// Show the ImPlot3D metrics/debugger window with a visibility flag.
46    pub fn show_metrics_window_with_flag(&self, p_open: &mut bool) {
47        self.show_native_tool(|| unsafe { sys::ImPlot3D_ShowMetricsWindow(p_open as *mut bool) })
48    }
49}