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