Make WindowAttributes private (#2134)
* Make `WindowAttributes` private, and move its documentation * Reorder WindowAttributes title and fullscreen to match method order
This commit is contained in:
parent
eec84ade86
commit
44288f6280
14 changed files with 74 additions and 98 deletions
143
src/window.rs
143
src/window.rs
|
|
@ -88,7 +88,7 @@ impl WindowId {
|
|||
#[must_use]
|
||||
pub struct WindowBuilder {
|
||||
/// The attributes to use to create the window.
|
||||
pub window: WindowAttributes,
|
||||
pub(crate) window: WindowAttributes,
|
||||
|
||||
// Platform-specific configuration.
|
||||
pub(crate) platform_specific: platform_impl::PlatformSpecificWindowBuilderAttributes,
|
||||
|
|
@ -104,92 +104,19 @@ impl fmt::Debug for WindowBuilder {
|
|||
|
||||
/// Attributes to use when creating a window.
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct WindowAttributes {
|
||||
/// The dimensions of the window. If this is `None`, some platform-specific dimensions will be
|
||||
/// used.
|
||||
///
|
||||
/// The default is `None`.
|
||||
pub(crate) struct WindowAttributes {
|
||||
pub inner_size: Option<Size>,
|
||||
|
||||
/// The minimum dimensions a window can be, If this is `None`, the window will have no minimum dimensions (aside from reserved).
|
||||
///
|
||||
/// The default is `None`.
|
||||
pub min_inner_size: Option<Size>,
|
||||
|
||||
/// The maximum dimensions a window can be, If this is `None`, the maximum will have no maximum or will be set to the primary monitor's dimensions by the platform.
|
||||
///
|
||||
/// The default is `None`.
|
||||
pub max_inner_size: Option<Size>,
|
||||
|
||||
/// The desired position of the window. If this is `None`, some platform-specific position
|
||||
/// will be chosen.
|
||||
///
|
||||
/// The default is `None`.
|
||||
///
|
||||
/// ## Platform-specific
|
||||
///
|
||||
/// - **macOS**: The top left corner position of the window content, the window's "inner"
|
||||
/// position. The window title bar will be placed above it.
|
||||
/// The window will be positioned such that it fits on screen, maintaining
|
||||
/// set `inner_size` if any.
|
||||
/// If you need to precisely position the top left corner of the whole window you have to
|
||||
/// use [`Window::set_outer_position`] after creating the window.
|
||||
/// - **Windows**: The top left corner position of the window title bar, the window's "outer"
|
||||
/// position.
|
||||
/// There may be a small gap between this position and the window due to the specifics of the
|
||||
/// Window Manager.
|
||||
/// - **X11**: The top left corner of the window, the window's "outer" position.
|
||||
/// - **Others**: Ignored.
|
||||
///
|
||||
/// See [`Window::set_outer_position`].
|
||||
///
|
||||
/// [`Window::set_outer_position`]: crate::window::Window::set_outer_position
|
||||
pub position: Option<Position>,
|
||||
|
||||
/// Whether the window is resizable or not.
|
||||
///
|
||||
/// The default is `true`.
|
||||
pub resizable: bool,
|
||||
|
||||
/// Whether the window should be set as fullscreen upon creation.
|
||||
///
|
||||
/// The default is `None`.
|
||||
pub fullscreen: Option<Fullscreen>,
|
||||
|
||||
/// The title of the window in the title bar.
|
||||
///
|
||||
/// The default is `"winit window"`.
|
||||
pub title: String,
|
||||
|
||||
/// Whether the window should be maximized upon creation.
|
||||
///
|
||||
/// The default is `false`.
|
||||
pub fullscreen: Option<Fullscreen>,
|
||||
pub maximized: bool,
|
||||
|
||||
/// Whether the window should be immediately visible upon creation.
|
||||
///
|
||||
/// The default is `true`.
|
||||
pub visible: bool,
|
||||
|
||||
/// Whether the the window should be transparent. If this is true, writing colors
|
||||
/// with alpha values different than `1.0` will produce a transparent window.
|
||||
///
|
||||
/// The default is `false`.
|
||||
pub transparent: bool,
|
||||
|
||||
/// Whether the window should have borders and bars.
|
||||
///
|
||||
/// The default is `true`.
|
||||
pub decorations: bool,
|
||||
|
||||
/// Whether the window should always be on top of other windows.
|
||||
///
|
||||
/// The default is `false`.
|
||||
pub always_on_top: bool,
|
||||
|
||||
/// The window icon.
|
||||
///
|
||||
/// The default is `None`.
|
||||
pub window_icon: Option<Icon>,
|
||||
}
|
||||
|
||||
|
|
@ -223,6 +150,8 @@ impl WindowBuilder {
|
|||
|
||||
/// Requests the window to be of specific dimensions.
|
||||
///
|
||||
/// If this is not set, some platform-specific dimensions will be used.
|
||||
///
|
||||
/// See [`Window::set_inner_size`] for details.
|
||||
///
|
||||
/// [`Window::set_inner_size`]: crate::window::Window::set_inner_size
|
||||
|
|
@ -232,7 +161,10 @@ impl WindowBuilder {
|
|||
self
|
||||
}
|
||||
|
||||
/// Sets a minimum dimension size for the window.
|
||||
/// Sets the minimum dimensions a window can have.
|
||||
///
|
||||
/// If this is not set, the window will have no minimum dimensions (aside
|
||||
/// from reserved).
|
||||
///
|
||||
/// See [`Window::set_min_inner_size`] for details.
|
||||
///
|
||||
|
|
@ -243,7 +175,10 @@ impl WindowBuilder {
|
|||
self
|
||||
}
|
||||
|
||||
/// Sets a maximum dimension size for the window.
|
||||
/// Sets the maximum dimensions a window can have.
|
||||
///
|
||||
/// If this is not set, the window will have no maximum or will be set to
|
||||
/// the primary monitor's dimensions by the platform.
|
||||
///
|
||||
/// See [`Window::set_max_inner_size`] for details.
|
||||
///
|
||||
|
|
@ -256,9 +191,28 @@ impl WindowBuilder {
|
|||
|
||||
/// Sets a desired initial position for the window.
|
||||
///
|
||||
/// See [`WindowAttributes::position`] for details.
|
||||
/// If this is not set, some platform-specific position will be chosen.
|
||||
///
|
||||
/// [`WindowAttributes::position`]: crate::window::WindowAttributes::position
|
||||
/// See [`Window::set_outer_position`] for details.
|
||||
///
|
||||
/// ## Platform-specific
|
||||
///
|
||||
/// - **macOS**: The top left corner position of the window content, the
|
||||
/// window's "inner" position. The window title bar will be placed above
|
||||
/// it. The window will be positioned such that it fits on screen,
|
||||
/// maintaining set `inner_size` if any.
|
||||
/// If you need to precisely position the top left corner of the whole
|
||||
/// window you have to use [`Window::set_outer_position`] after creating
|
||||
/// the window.
|
||||
/// - **Windows**: The top left corner position of the window title bar,
|
||||
/// the window's "outer" position.
|
||||
/// There may be a small gap between this position and the window due to
|
||||
/// the specifics of the Window Manager.
|
||||
/// - **X11**: The top left corner of the window, the window's "outer"
|
||||
/// position.
|
||||
/// - **Others**: Ignored.
|
||||
///
|
||||
/// [`Window::set_outer_position`]: crate::window::Window::set_outer_position
|
||||
#[inline]
|
||||
pub fn with_position<P: Into<Position>>(mut self, position: P) -> Self {
|
||||
self.window.position = Some(position.into());
|
||||
|
|
@ -267,6 +221,8 @@ impl WindowBuilder {
|
|||
|
||||
/// Sets whether the window is resizable or not.
|
||||
///
|
||||
/// The default is `true`.
|
||||
///
|
||||
/// See [`Window::set_resizable`] for details.
|
||||
///
|
||||
/// [`Window::set_resizable`]: crate::window::Window::set_resizable
|
||||
|
|
@ -276,7 +232,9 @@ impl WindowBuilder {
|
|||
self
|
||||
}
|
||||
|
||||
/// Requests a specific title for the window.
|
||||
/// Sets the initial title of the window in the title bar.
|
||||
///
|
||||
/// The default is `"winit window"`.
|
||||
///
|
||||
/// See [`Window::set_title`] for details.
|
||||
///
|
||||
|
|
@ -287,7 +245,9 @@ impl WindowBuilder {
|
|||
self
|
||||
}
|
||||
|
||||
/// Sets the window fullscreen state.
|
||||
/// Sets whether the window should be put into fullscreen upon creation.
|
||||
///
|
||||
/// The default is `None`.
|
||||
///
|
||||
/// See [`Window::set_fullscreen`] for details.
|
||||
///
|
||||
|
|
@ -298,7 +258,9 @@ impl WindowBuilder {
|
|||
self
|
||||
}
|
||||
|
||||
/// Requests maximized mode.
|
||||
/// Request that the window is maximized upon creation.
|
||||
///
|
||||
/// The default is `false`.
|
||||
///
|
||||
/// See [`Window::set_maximized`] for details.
|
||||
///
|
||||
|
|
@ -309,7 +271,9 @@ impl WindowBuilder {
|
|||
self
|
||||
}
|
||||
|
||||
/// Sets whether the window will be initially hidden or visible.
|
||||
/// Sets whether the window will be initially visible or hidden.
|
||||
///
|
||||
/// The default is to show the window.
|
||||
///
|
||||
/// See [`Window::set_visible`] for details.
|
||||
///
|
||||
|
|
@ -321,6 +285,11 @@ impl WindowBuilder {
|
|||
}
|
||||
|
||||
/// Sets whether the background of the window should be transparent.
|
||||
///
|
||||
/// If this is `true`, writing colors with alpha values different than
|
||||
/// `1.0` will produce a transparent window.
|
||||
///
|
||||
/// The default is `false`.
|
||||
#[inline]
|
||||
pub fn with_transparent(mut self, transparent: bool) -> Self {
|
||||
self.window.transparent = transparent;
|
||||
|
|
@ -329,6 +298,8 @@ impl WindowBuilder {
|
|||
|
||||
/// Sets whether the window should have a border, a title bar, etc.
|
||||
///
|
||||
/// The default is `true`.
|
||||
///
|
||||
/// See [`Window::set_decorations`] for details.
|
||||
///
|
||||
/// [`Window::set_decorations`]: crate::window::Window::set_decorations
|
||||
|
|
@ -340,6 +311,8 @@ impl WindowBuilder {
|
|||
|
||||
/// Sets whether or not the window will always be on top of other windows.
|
||||
///
|
||||
/// The default is `false`.
|
||||
///
|
||||
/// See [`Window::set_always_on_top`] for details.
|
||||
///
|
||||
/// [`Window::set_always_on_top`]: crate::window::Window::set_always_on_top
|
||||
|
|
@ -351,6 +324,8 @@ impl WindowBuilder {
|
|||
|
||||
/// Sets the window icon.
|
||||
///
|
||||
/// The default is `None`.
|
||||
///
|
||||
/// See [`Window::set_window_icon`] for details.
|
||||
///
|
||||
/// [`Window::set_window_icon`]: crate::window::Window::set_window_icon
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue