baseview/
window_open_options.rs1use crate::Size;
2
3#[cfg(feature = "opengl")]
4use crate::gl::GlConfig;
5
6#[derive(Default, Debug, Clone, Copy, PartialEq)]
8pub enum WindowScalePolicy {
9 #[default]
11 SystemScaleFactor,
12 ScaleFactor(f64),
14}
15
16#[derive(Debug, Clone, PartialEq)]
18pub struct WindowOpenOptions {
19 pub title: String,
20
21 pub size: Size,
26
27 pub scale: WindowScalePolicy,
29
30 #[cfg(feature = "opengl")]
35 pub gl_config: Option<GlConfig>,
36}
37
38impl WindowOpenOptions {
39 #[inline]
40 pub fn new() -> Self {
41 Self::default()
42 }
43
44 #[inline]
45 pub fn with_title(mut self, title: impl Into<String>) -> Self {
46 self.title = title.into();
47 self
48 }
49
50 #[inline]
51 pub fn with_size(mut self, width: f64, height: f64) -> Self {
52 self.size = Size::new(width, height);
53 self
54 }
55
56 #[inline]
57 pub fn with_scale_policy(mut self, scale: WindowScalePolicy) -> Self {
58 self.scale = scale;
59 self
60 }
61
62 #[cfg(feature = "opengl")]
63 #[inline]
64 pub fn with_gl_config(mut self, gl_config: impl Into<Option<GlConfig>>) -> Self {
65 self.gl_config = gl_config.into();
66 self
67 }
68}
69
70impl Default for WindowOpenOptions {
71 fn default() -> Self {
72 Self {
73 title: String::from("baseview window"),
74 size: Size { width: 500.0, height: 400.0 },
75 scale: WindowScalePolicy::default(),
76 #[cfg(feature = "opengl")]
77 gl_config: None,
78 }
79 }
80}