1use anyrender::CompositeAlphaMode;
2use blitz_dom::FontContext;
3use dioxus_core::LaunchConfig;
4use peniko::Color;
5use winit::window::WindowAttributes;
6
7pub struct Config {
9 pub(crate) window_attributes: WindowAttributes,
10 pub(crate) font_ctx: Option<FontContext>,
11 pub(crate) alpha_mode: Option<CompositeAlphaMode>,
12 pub(crate) base_color: Option<Color>,
13}
14
15impl LaunchConfig for Config {}
16
17impl Default for Config {
18 fn default() -> Self {
19 let window_attributes = WindowAttributes::default()
20 .with_title(dioxus_cli_config::app_title().unwrap_or_else(|| "Dioxus App".to_string()));
21
22 #[cfg(target_arch = "wasm32")]
29 let window_attributes = {
30 use winit::platform::web::WindowAttributesWeb;
31 window_attributes.with_platform_attributes(Box::new(
32 WindowAttributesWeb::default().with_append(true),
33 ))
34 };
35
36 Self {
37 window_attributes,
38 font_ctx: None,
39 alpha_mode: None,
40 base_color: None,
41 }
42 }
43}
44
45impl Config {
46 pub fn new() -> Self {
47 Self::default()
48 }
49
50 pub fn with_window_attributes(mut self, attrs: WindowAttributes) -> Self {
52 self.window_attributes = attrs;
53 self
54 }
55
56 pub fn with_font_ctx(mut self, font_ctx: FontContext) -> Self {
62 self.font_ctx = Some(font_ctx);
63 self
64 }
65
66 pub fn with_alpha_mode(mut self, alpha_mode: CompositeAlphaMode) -> Self {
72 self.alpha_mode = Some(alpha_mode);
73 self
74 }
75
76 pub fn with_base_color(mut self, base_color: Color) -> Self {
78 self.base_color = Some(base_color);
79 self
80 }
81}