maycoon_core/
config.rs

1use nalgebra::{Point2, Vector2};
2pub use winit::window::{
3    BadIcon, Cursor, CursorIcon, CustomCursor, Icon as WindowIcon, WindowButtons, WindowLevel,
4};
5
6use crate::vgi::VectorGraphicsInterface;
7use maycoon_theme::theme::Theme;
8
9/// Maycoon Application Configuration Structure.
10#[derive(Clone, Debug)]
11pub struct MayConfig<T: Theme, V: VectorGraphicsInterface> {
12    /// Window Configuration
13    pub window: WindowConfig,
14    /// Theme of the Application.
15    pub theme: T,
16    /// The configuration of the vector graphics interface.
17    pub graphics: V::Config,
18}
19
20impl<T: Default + Theme, V: VectorGraphicsInterface> Default for MayConfig<T, V> {
21    fn default() -> Self {
22        Self {
23            window: WindowConfig::default(),
24            theme: T::default(),
25            graphics: V::Config::default(),
26        }
27    }
28}
29
30/// Window configuration.
31#[derive(Clone, Debug)]
32pub struct WindowConfig {
33    /// The title of the window.
34    pub title: String,
35    /// The inner size of the window.
36    pub size: Vector2<f64>,
37    /// The minimum size of the window.
38    pub min_size: Option<Vector2<f64>>,
39    /// The maximum size of the window.
40    pub max_size: Option<Vector2<f64>>,
41    /// If the window should be resizeable.
42    pub resizable: bool,
43    /// If the window should be maximized on startup.
44    pub maximized: bool,
45    /// The window mode.
46    pub mode: WindowMode,
47    /// The window level.
48    pub level: WindowLevel,
49    /// If the window should be visible on startup.
50    pub visible: bool,
51    /// If the window background should be blurred.
52    pub blur: bool,
53    /// If the window background should be transparent. May not be compatible on all system.
54    pub transparent: bool,
55    /// The desired initial position for the window.
56    pub position: Option<Point2<f64>>,
57    /// If the window should be active/focused on startup.
58    pub active: bool,
59    /// The enabled window buttons.
60    pub buttons: WindowButtons,
61    /// If the window should be decorated (have borders).
62    pub decorations: bool,
63    /// The resize increments of the window. Not supported everywhere.
64    pub resize_increments: Option<Vector2<f64>>,
65    /// Prevents window capturing by some apps (not all though).
66    pub content_protected: bool,
67    /// The window icon.
68    pub icon: Option<WindowIcon>,
69    /// The window cursor.
70    pub cursor: Cursor,
71    /// If the window should exit/close on close request (pressing the close window button).
72    pub close_on_request: bool,
73}
74
75impl Default for WindowConfig {
76    fn default() -> Self {
77        Self {
78            title: "New App".to_string(),
79            size: Vector2::new(800.0, 600.0),
80            min_size: None,
81            max_size: None,
82            resizable: true,
83            maximized: false,
84            mode: WindowMode::default(),
85            level: Default::default(),
86            visible: true,
87            blur: false,
88            transparent: false,
89            position: None,
90            active: true,
91            buttons: WindowButtons::all(),
92            decorations: true,
93            resize_increments: None,
94            content_protected: false,
95            icon: None,
96            cursor: Cursor::default(),
97            close_on_request: true,
98        }
99    }
100}
101
102/// The window mode.
103#[derive(Clone, Debug, Default)]
104pub enum WindowMode {
105    /// The default windowed mode.
106    #[default]
107    Windowed,
108    /// Size the window to fill the screen and remove borders. This is more modern, than default Fullscreen.
109    Borderless,
110    /// Legacy Fullscreen mode.
111    Fullscreen,
112}