Allow introspection of WindowBuilder attributes

Makes WindowAttributes public and adds window_attributes() getter to
WindowBuilder.

In version 0.27, the WindowAttributes struct was made private, but this
removed the ability to introspect the default WindowBuilder values.
This commit is contained in:
Shane Pearman 2023-01-27 07:38:56 +02:00 committed by GitHub
parent b457329003
commit 422c6b1987
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 18 additions and 10 deletions

View file

@ -120,7 +120,7 @@ impl fmt::Debug for WindowBuilder {
/// Attributes to use when creating a window.
#[derive(Debug, Clone)]
pub(crate) struct WindowAttributes {
pub struct WindowAttributes {
pub inner_size: Option<Size>,
pub min_inner_size: Option<Size>,
pub max_inner_size: Option<Size>,
@ -128,7 +128,7 @@ pub(crate) struct WindowAttributes {
pub resizable: bool,
pub enabled_buttons: WindowButtons,
pub title: String,
pub fullscreen: Option<platform_impl::Fullscreen>,
pub fullscreen: Option<Fullscreen>,
pub maximized: bool,
pub visible: bool,
pub transparent: bool,
@ -176,6 +176,11 @@ impl WindowBuilder {
Default::default()
}
/// Get the current window attributes.
pub fn window_attributes(&self) -> &WindowAttributes {
&self.window
}
/// Requests the window to be of specific dimensions.
///
/// If this is not set, some platform-specific dimensions will be used.
@ -279,7 +284,7 @@ impl WindowBuilder {
/// See [`Window::set_fullscreen`] for details.
#[inline]
pub fn with_fullscreen(mut self, fullscreen: Option<Fullscreen>) -> Self {
self.window.fullscreen = fullscreen.map(|f| f.into());
self.window.fullscreen = fullscreen;
self
}