Skip to main content

Window

Struct Window 

Source
pub struct Window(/* private fields */);
Expand description

Handle to the window.

This handle can be cloned and passed around freely to give objects access to the window.

Obtained from Context.

Implementations§

Source§

impl Window

Source

pub fn title(&self) -> String

The window title.

Source

pub fn set_title(&self, title: &str)

Set the window title.

Source

pub fn scale_factor(&self) -> f32

The window scale factor.

Source

pub fn inv_scale_factor(&self) -> f32

The inverse window scale factor.

Source

pub fn monitor(&self) -> Option<Monitor>

The monitor the window is on.

Source

pub fn primary_monitor(&self) -> Option<Monitor>

The primary monitor.

Source

pub fn monitors(&self) -> impl Iterator<Item = Monitor>

All monitors.

Source

pub fn center_on(&self, monitor: &Monitor)

Center the window on the selected monitor.

Source

pub fn display_mode(&self) -> DisplayMode

The window display mode.

Source

pub fn set_display_mode(&self, display_mode: DisplayMode)

Set the window display mode.

Source

pub fn is_fullscreen(&self) -> bool

If the window is in a fullscreen mode.

Source

pub fn set_fullscreen_borderless(&self, monitor: Option<Monitor>)

Set the window to borderless fullscreen mode.

Source

pub fn set_fullscreen_exclusive(&self, video_mode: VideoMode)

Set the window to exclusive fullscreen mode.

Source

pub fn set_windowed(&self, monitor: Option<Monitor>)

Set the window to windowed mode.

Source

pub fn has_focus(&self) -> bool

If the window has focus.

Source

pub fn pixel_pos(&self) -> Option<Vec2I>

The window position in pixels.

Source

pub fn pos(&self) -> Option<Vec2I>

The DPI-independent window position.

Source

pub fn outer_pixel_pos(&self) -> Option<Vec2I>

The window outer position in pixels.

Source

pub fn outer_pos(&self) -> Option<Vec2I>

The DPI-independent window outer position.

Source

pub fn set_outer_pos(&self, pos: impl Into<Vec2I>)

Set the window outer DPI-independent position.

Source

pub fn set_outer_pixel_pos(&self, pos: impl Into<Vec2I>)

Set the window outer pixel position.

Source

pub fn pixel_size(&self) -> Vec2U

The window pixel size.

Source

pub fn size(&self) -> Vec2U

The window DPI-independent size.

Source

pub fn request_size(&self, size: impl Into<Vec2U>) -> bool

Request a DPI-independent size for the window.

Source

pub fn request_pixel_size(&self, size: impl Into<Vec2U>) -> bool

Request a pixel size for the window.

Source

pub fn outer_pixel_size(&self) -> Vec2U

Outer pixel size of the window.

Source

pub fn outer_size(&self) -> Vec2U

Outer DPI-independent size of the window.

Source

pub fn center(&self) -> Vec2U

DPI-independent center of the window.

Source

pub fn pixel_center(&self) -> Vec2U

Pixel center of the window.

Source

pub fn resizable(&self) -> bool

If the window can be resized by the user.

Source

pub fn set_resizable(&self, resizable: bool)

Set if the window can be resized by the user.

Source

pub fn maximized(&self) -> bool

If the window is maximized.

Source

pub fn set_maximized(&self, maximized: bool)

Set if the window is maximized.

Source

pub fn minimized(&self) -> Option<bool>

If the window is minimized.

Source

pub fn set_minimized(&self, minimized: bool)

Set if the window is minimized.

Source

pub fn set_min_inner_size(&self, size: impl Into<Option<Vec2U>>)

Set the window’s minimum inner DPI-independent size.

Source

pub fn set_min_inner_pixel_size(&self, size: impl Into<Option<Vec2U>>)

Set the window’s minimum inner pixel size.

Source

pub fn set_max_inner_size(&self, size: impl Into<Option<Vec2U>>)

Set the window’s maximum inner DPI-independent size.

Source

pub fn set_max_inner_pixel_size(&self, size: impl Into<Option<Vec2U>>)

Set the window’s maximum inner pixel size.

Source

pub fn set_cursor(&self, icon: CursorIcon)

Set the cursor to display when the mouse is over the window.

Trait Implementations§

Source§

impl Clone for Window

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Window

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Window

§

impl !UnwindSafe for Window

§

impl Forget for Window

§

impl Freeze for Window

§

impl Send for Window

§

impl Sync for Window

§

impl Unpin for Window

§

impl UnsafeUnpin for Window

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync> ⓘ

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more