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>

source

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.

source

pub fn set_icon_from_rgba_pixels<S>( &self, data: Vec<u8>, size: S ) -> Result<(), BacktraceError<ErrorMessage>>
where S: Into<UVec2>,

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.

source

pub fn set_cursor_visible(&self, visible: bool)

Sets the visibility of the mouse cursor.

source

pub fn set_cursor_grab( &self, grabbed: bool ) -> Result<(), BacktraceError<ErrorMessage>>

Grabs the cursor, preventing it from leaving the window.

source

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.

source

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.

source

pub fn set_title<S: AsRef<str>>(&self, title: S)

Sets the window title.

source

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.

source

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.

source

pub fn get_size_pixels(&self) -> UVec2

Gets the window size in pixels.

source

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.

source

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.

source

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.

source

pub fn get_scale_factor(&self) -> f64

Gets the window’s scale factor.

source

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.

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> UnwindSafe for WindowHelper<UserEventType>
where UserEventType: UnwindSafe,

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> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

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> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

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

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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.