runmat_plot/gui/
window.rs

1//! Main window management for interactive GUI plotting
2//!
3//! Provides the main application window with integrated plot viewport
4//! and control panels using winit and egui.
5
6/// Configuration for the plot window
7#[derive(Debug, Clone)]
8pub struct WindowConfig {
9    pub title: String,
10    pub width: u32,
11    pub height: u32,
12    pub resizable: bool,
13    pub maximized: bool,
14    pub vsync: bool,
15}
16
17impl Default for WindowConfig {
18    fn default() -> Self {
19        Self {
20            title: "RunMat - Interactive Visualization | Powered by Dystr".to_string(),
21            width: 1200,
22            height: 800,
23            resizable: true,
24            maximized: false,
25            vsync: true,
26        }
27    }
28}
29
30/// Interactive plot window with full WGPU rendering
31#[cfg(feature = "gui")]
32pub struct PlotWindow<'window> {
33    pub window: std::sync::Arc<winit::window::Window>,
34    pub event_loop: Option<winit::event_loop::EventLoop<()>>,
35    pub plot_renderer: crate::core::PlotRenderer,
36    pub plot_overlay: crate::gui::PlotOverlay,
37    pub surface: wgpu::Surface<'window>,
38    pub depth_texture: wgpu::Texture,
39    pub depth_view: wgpu::TextureView,
40    pub egui_ctx: egui::Context,
41    pub egui_state: egui_winit::State,
42    pub egui_renderer: egui_wgpu::Renderer,
43    pub config: WindowConfig,
44    pub mouse_position: glam::Vec2,
45    pub is_mouse_over_plot: bool,
46}
47
48// The implementation is in window_impl.rs in the same directory
49
50// Stub implementation for non-GUI builds
51#[cfg(not(feature = "gui"))]
52pub struct PlotWindow;
53
54#[cfg(not(feature = "gui"))]
55impl PlotWindow {
56    pub async fn new(_config: WindowConfig) -> Result<Self, Box<dyn std::error::Error>> {
57        Err("GUI feature not enabled".into())
58    }
59
60    pub fn add_test_plot(&mut self) {
61        // No-op for non-GUI builds
62    }
63
64    pub fn run(self) -> Result<(), Box<dyn std::error::Error>> {
65        Err("GUI feature not enabled".into())
66    }
67}