1use alloc::collections::BTreeMap;
8
9use azul_core::{
10 callbacks::LayoutCallback,
11 dom::DomId,
12 window::{
13 DebugState, ImePosition, KeyboardState, Monitor, MouseState, PlatformSpecificOptions,
14 RendererOptions, TouchState, WindowFlags, WindowPosition, WindowSize, WindowTheme,
15 },
16};
17use azul_css::{
18 corety::OptionU32, impl_option, impl_option_inner, impl_vec, impl_vec_clone, impl_vec_debug,
19 impl_vec_mut, impl_vec_partialeq, props::basic::color::ColorU, AzString,
20};
21
22use crate::callbacks::OptionCallback;
23
24#[derive(Debug, Clone, PartialEq)]
26#[repr(C)]
27pub struct WindowCreateOptions {
28 pub window_state: FullWindowState,
29 pub size_to_content: bool,
30 pub renderer: azul_core::window::OptionRendererOptions,
31 pub theme: azul_core::window::OptionWindowTheme,
32 pub create_callback: OptionCallback,
33 pub hot_reload: bool,
34}
35
36impl Default for WindowCreateOptions {
37 fn default() -> Self {
38 Self {
39 window_state: FullWindowState::default(),
40 size_to_content: false,
41 renderer: azul_core::window::OptionRendererOptions::None,
42 theme: azul_core::window::OptionWindowTheme::None,
43 create_callback: OptionCallback::None,
44 hot_reload: false,
45 }
46 }
47}
48
49impl WindowCreateOptions {
50 pub fn create(layout_callback: impl Into<azul_core::callbacks::LayoutCallback>) -> Self {
52 let mut options = Self::default();
53 options.window_state.layout_callback = layout_callback.into();
54 options
55 }
56}
57
58impl_vec!(
59 WindowCreateOptions,
60 WindowCreateOptionsVec,
61 WindowCreateOptionsVecDestructor,
62 WindowCreateOptionsVecDestructorType
63);
64impl_vec_clone!(
65 WindowCreateOptions,
66 WindowCreateOptionsVec,
67 WindowCreateOptionsVecDestructor
68);
69impl_vec_partialeq!(WindowCreateOptions, WindowCreateOptionsVec);
70impl_vec_debug!(WindowCreateOptions, WindowCreateOptionsVec);
71impl_vec_mut!(WindowCreateOptions, WindowCreateOptionsVec);
72
73#[derive(Debug, Clone, PartialEq)]
75#[repr(C)]
76pub struct FullWindowState {
77 pub window_id: AzString,
80 pub theme: WindowTheme,
81 pub title: AzString,
82 pub size: WindowSize,
83 pub position: WindowPosition,
84 pub flags: WindowFlags,
85 pub debug_state: DebugState,
86 pub keyboard_state: KeyboardState,
87 pub mouse_state: MouseState,
88 pub touch_state: TouchState,
89 pub ime_position: ImePosition,
90 pub platform_specific_options: PlatformSpecificOptions,
91 pub renderer_options: RendererOptions,
92 pub background_color: ColorU,
93 pub layout_callback: LayoutCallback,
94 pub close_callback: OptionCallback,
95 pub monitor_id: OptionU32,
97 pub window_focused: bool,
98}
99
100impl_option!(
101 FullWindowState,
102 OptionFullWindowState,
103 copy = false,
104 [Debug, Clone, PartialEq]
105);
106
107impl Default for FullWindowState {
108 fn default() -> Self {
109 Self {
110 window_id: AzString::from_const_str("azul-window"),
111 theme: WindowTheme::default(),
112 title: AzString::from_const_str("Azul Window"),
113 size: WindowSize::default(),
114 position: WindowPosition::default(),
115 flags: WindowFlags::default(),
116 debug_state: DebugState::default(),
117 keyboard_state: KeyboardState::default(),
118 mouse_state: MouseState::default(),
119 touch_state: TouchState::default(),
120 ime_position: ImePosition::default(),
121 platform_specific_options: PlatformSpecificOptions::default(),
122 background_color: ColorU::WHITE,
123 layout_callback: LayoutCallback::default(),
124 close_callback: OptionCallback::None,
125 renderer_options: RendererOptions::default(),
126 monitor_id: OptionU32::None,
127 window_focused: true,
128 }
129 }
130}