pub struct WindowHelper<UserEventType = ()>where
UserEventType: 'static,{ /* private fields */ }Expand description
A set of helper methods to perform actions on a crate::Window.
Implementations§
Source§impl<UserEventType> WindowHelper<UserEventType>
impl<UserEventType> WindowHelper<UserEventType>
Sourcepub fn terminate_loop(&mut self)
pub fn terminate_loop(&mut self)
Causes the event loop to stop processing events, and terminate the application.
Note: The event loop will stop only once the current callback has returned, rather than terminating immediately.
Once the event loop has stopped, the entire process will end with error code 0, even if other threads are running.
If your WindowHandler struct implements Drop, it will be safely
destructed before exiting.
No further callbacks will be given once this function has been called.
Sourcepub fn set_icon_from_rgba_pixels<S>(
&self,
data: Vec<u8>,
size: S,
) -> Result<(), BacktraceError<ErrorMessage>>
pub fn set_icon_from_rgba_pixels<S>( &self, data: Vec<u8>, size: S, ) -> Result<(), BacktraceError<ErrorMessage>>
Sets the window icon from the provided RGBA pixels.
On Windows, the base icon size is 16x16, however a multiple of this (e.g. 32x32) should be provided for high-resolution displays.
For WebCanvas, this function has no effect.
Sourcepub fn set_cursor_visible(&self, visible: bool)
pub fn set_cursor_visible(&self, visible: bool)
Sets the visibility of the mouse cursor.
Sourcepub fn set_cursor_grab(
&self,
grabbed: bool,
) -> Result<(), BacktraceError<ErrorMessage>>
pub fn set_cursor_grab( &self, grabbed: bool, ) -> Result<(), BacktraceError<ErrorMessage>>
Grabs the cursor, preventing it from leaving the window.
Sourcepub fn set_cursor(&self, cursor: MouseCursorType)
pub fn set_cursor(&self, cursor: MouseCursorType)
Sets the shape of the mouse cursor shown over the window.
Sourcepub fn set_resizable(&self, resizable: bool)
pub fn set_resizable(&self, resizable: bool)
Set to false to prevent the user from resizing the window.
For WebCanvas, this function has no effect.
Sourcepub fn set_visible(&self, visible: bool)
pub fn set_visible(&self, visible: bool)
Sets whether the window is visible. Hiding the window (passing false)
keeps it and the event loop alive, so it can be shown again later by
passing true. This pairs with
WindowCreationOptions::with_visible (to start hidden) and
WindowCreationOptions::with_hide_on_close (to hide instead of exit),
allowing an application to live in the system tray.
After re-showing a window you may want to call WindowHelper::request_redraw to ensure its contents are drawn.
For WebCanvas, this function has no effect.
Sourcepub fn request_redraw(&self)
pub fn request_redraw(&self)
Request that the window is redrawn.
This will cause the WindowHandler::on_draw callback to be invoked on the next frame.
Sourcepub fn set_fullscreen_mode(&self, mode: WindowFullscreenMode)
pub fn set_fullscreen_mode(&self, mode: WindowFullscreenMode)
Sets the window fullscreen mode.
When using a web canvas, permission for this operation may be denied, depending on where this is called from, and the user’s browser settings. If the operation is successful, the WindowHandler::on_fullscreen_status_changed callback will be invoked.
Sourcepub fn set_size_pixels<S: Into<UVec2>>(&self, size: S)
pub fn set_size_pixels<S: Into<UVec2>>(&self, size: S)
Sets the window size in pixels. This is the window’s inner size, excluding the border.
For WebCanvas, this function has no effect.
Sourcepub fn get_size_pixels(&self) -> UVec2
pub fn get_size_pixels(&self) -> UVec2
Gets the window size in pixels.
Sourcepub fn set_position_pixels<P: Into<IVec2>>(&self, position: P)
pub fn set_position_pixels<P: Into<IVec2>>(&self, position: P)
Sets the position of the window in pixels. If multiple monitors are in use, this will be the distance from the top left of the display area, spanning all the monitors.
For WebCanvas, this function has no effect.
Sourcepub fn set_size_scaled_pixels<S: Into<Vec2>>(&self, size: S)
pub fn set_size_scaled_pixels<S: Into<Vec2>>(&self, size: S)
Sets the window size in scaled device-independent pixels. This is the window’s inner size, excluding the border.
For WebCanvas, this function has no effect.
Sourcepub fn set_position_scaled_pixels<P: Into<Vec2>>(&self, position: P)
pub fn set_position_scaled_pixels<P: Into<Vec2>>(&self, position: P)
Sets the position of the window in scaled device-independent pixels. If multiple monitors are in use, this will be the distance from the top left of the display area, spanning all the monitors.
For WebCanvas, this function has no effect.
Sourcepub fn get_scale_factor(&self) -> f64
pub fn get_scale_factor(&self) -> f64
Gets the window’s scale factor.
Sourcepub fn create_user_event_sender(&self) -> UserEventSender<UserEventType>
pub fn create_user_event_sender(&self) -> UserEventSender<UserEventType>
Creates a UserEventSender, which can be used to post custom events to this event loop from another thread.
Events from a sender created here are delivered to this window’s handler. Senders created via crate::Window::create_user_event_sender (before the loop starts) deliver to the main window.
See UserEventSender::send_event, WindowHandler::on_user_event.
Auto Trait Implementations§
impl<UserEventType> Freeze for WindowHelper<UserEventType>
impl<UserEventType> RefUnwindSafe for WindowHelper<UserEventType>where
UserEventType: RefUnwindSafe,
impl<UserEventType> Send for WindowHelper<UserEventType>where
UserEventType: Send,
impl<UserEventType> Sync for WindowHelper<UserEventType>where
UserEventType: Sync,
impl<UserEventType> Unpin for WindowHelper<UserEventType>where
UserEventType: Unpin,
impl<UserEventType> UnsafeUnpin for WindowHelper<UserEventType>
impl<UserEventType> UnwindSafe for WindowHelper<UserEventType>where
UserEventType: UnwindSafe,
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> 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
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