Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/gl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ mod macos;
#[cfg(target_os = "macos")]
use macos as platform;

#[derive(Clone, Debug)]
#[derive(Clone, Debug, PartialEq)]
pub struct GlConfig {
pub version: (u8, u8),
pub profile: Profile,
Expand Down
35 changes: 33 additions & 2 deletions src/window_open_options.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
use crate::Size;

#[cfg(feature = "opengl")]
use crate::gl::GlConfig;

/// The dpi scaling policy of the window
#[derive(Debug, Clone, Copy, PartialEq)]
#[derive(Default, Debug, Clone, Copy, PartialEq)]
pub enum WindowScalePolicy {
/// Use the system's dpi scale factor
#[default]
SystemScaleFactor,
/// Use the given dpi scale factor (e.g. `1.0` = 96 dpi)
ScaleFactor(f64),
}

/// The options for opening a new window
#[derive(Debug, Clone, PartialEq)]
pub struct WindowOpenOptions {
pub title: String,

Expand All @@ -24,6 +29,32 @@ pub struct WindowOpenOptions {

/// If provided, then an OpenGL context will be created for this window. You'll be able to
/// access this context through [crate::Window::gl_context].
///
/// By default this is set to `Some(GlConfig::default())`.
#[cfg(feature = "opengl")]
pub gl_config: Option<crate::gl::GlConfig>,
pub gl_config: Option<GlConfig>,
}

impl WindowOpenOptions {
pub fn default_no_opengl() -> Self {
Self {
title: String::from("baseview window"),
size: Size { width: 500.0, height: 400.0 },
scale: WindowScalePolicy::default(),
#[cfg(feature = "opengl")]
gl_config: None,
}
}
}

impl Default for WindowOpenOptions {
fn default() -> Self {
Self {
title: String::from("baseview window"),
size: Size { width: 500.0, height: 400.0 },
scale: WindowScalePolicy::default(),
#[cfg(feature = "opengl")]
gl_config: Some(GlConfig::default()),
}
}
}
Loading