pub struct Window(/* private fields */);Expand description
Runtime control over the OS window — cursor, title, size, fullscreen, and the like.
A self-contained ECS resource — Res<Window>, same as Input — not
WindowResource<WinitWindow>::handle, which is Arc<winit::window::Window>
and every raw winit method that comes with it. Cheap to clone (an
Arc internally); every method forwards straight to the OS window, no
locking needed since none of this is polled state like Input is.
Implementations§
Source§impl Window
impl Window
Sourcepub fn inner_size(&self) -> (u32, u32)
pub fn inner_size(&self) -> (u32, u32)
The window’s current inner size, in physical pixels.
Sourcepub fn set_inner_size(&self, width: u32, height: u32)
pub fn set_inner_size(&self, width: u32, height: u32)
Request a new inner size. The OS may not grant it exactly (or at
all, e.g. a maximized/tiled window) — check Window::inner_size
afterward for whatever size actually resulted.
Sourcepub fn set_min_inner_size(&self, size: Option<(u32, u32)>)
pub fn set_min_inner_size(&self, size: Option<(u32, u32)>)
Lower bound on manual/OS resizing. None clears it.
Sourcepub fn set_max_inner_size(&self, size: Option<(u32, u32)>)
pub fn set_max_inner_size(&self, size: Option<(u32, u32)>)
Upper bound on manual/OS resizing. None clears it.
Sourcepub fn set_resizable(&self, resizable: bool)
pub fn set_resizable(&self, resizable: bool)
Whether the user can resize the window by dragging its edges.
Sourcepub fn set_visible(&self, visible: bool)
pub fn set_visible(&self, visible: bool)
Show or hide the window entirely.
Sourcepub fn set_minimized(&self, minimized: bool)
pub fn set_minimized(&self, minimized: bool)
Minimize or restore the window.
Sourcepub fn set_maximized(&self, maximized: bool)
pub fn set_maximized(&self, maximized: bool)
Maximize or restore the window.
Sourcepub fn set_decorations(&self, decorations: bool)
pub fn set_decorations(&self, decorations: bool)
Show or hide the title bar/border.
Sourcepub fn set_fullscreen(&self, fullscreen: bool)
pub fn set_fullscreen(&self, fullscreen: bool)
Toggle borderless fullscreen on the window’s current monitor, or return to windowed mode.
Sourcepub fn is_fullscreen(&self) -> bool
pub fn is_fullscreen(&self) -> bool
Whether the window is currently fullscreen.
Sourcepub fn set_cursor_icon(&self, icon: CursorIcon)
pub fn set_cursor_icon(&self, icon: CursorIcon)
Change the mouse cursor’s icon.
Sourcepub fn set_cursor_visible(&self, visible: bool)
pub fn set_cursor_visible(&self, visible: bool)
Show or hide the mouse cursor while it’s over the window.
Sourcepub fn set_cursor_grab(&self, mode: CursorGrabMode) -> bool
pub fn set_cursor_grab(&self, mode: CursorGrabMode) -> bool
Confine or lock the cursor (see CursorGrabMode) — the usual pair
with set_cursor_visible(false) for a captured-mouse camera.
Returns false instead of panicking if the platform doesn’t support
the requested mode (see CursorGrabMode’s variant docs).
Sourcepub fn set_cursor_position(&self, x: f64, y: f64) -> bool
pub fn set_cursor_position(&self, x: f64, y: f64) -> bool
Move the cursor to a position within the window, in physical pixels.
Returns false instead of panicking if the platform doesn’t support
it.
Sourcepub fn request_redraw(&self)
pub fn request_redraw(&self)
Request that the window be redrawn on the next frame — rarely needed directly (the render loop already drives this), but available for a backend/window setup that needs to force a redraw out of band.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Window
impl !UnwindSafe 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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> Component for T
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&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
impl<T> DowncastSync for T
impl<S, T> Duplex<S> for Twhere
T: FromSample<S> + ToSample<S>,
Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more