pub struct WindowWrapper<UserEventType> { /* private fields */ }
Expand description

Wraps an egui context with features that are useful for integrating egui with Speedy2d.

Implementations§

source§

impl<UserEventType> WindowWrapper<UserEventType>

source

pub fn new(handler: impl WindowHandler<UserEventType> + 'static) -> Self

Creates a new WindowWrapper and underlying egui context.

source

pub fn draw( &mut self, full_output: FullOutput, gfx: &mut Graphics2D ) -> Result<(), BacktraceError<ErrorMessage>>

Draws the latest finished GUI frame to the screen.

Trait Implementations§

source§

impl<UserEventType> WindowHandler<UserEventType> for WindowWrapper<UserEventType>

source§

fn on_start( &mut self, helper: &mut WindowHelper<UserEventType>, info: WindowStartupInfo )

Invoked once when the window first starts.

source§

fn on_user_event( &mut self, helper: &mut WindowHelper<UserEventType>, user_event: UserEventType )

Invoked when a user-defined event is received, allowing you to wake up the event loop to handle events from other threads.

See WindowHelper::create_user_event_sender.

source§

fn on_resize( &mut self, helper: &mut WindowHelper<UserEventType>, size_pixels: UVec2 )

Invoked when the window is resized.

source§

fn on_mouse_grab_status_changed( &mut self, helper: &mut WindowHelper<UserEventType>, mouse_grabbed: bool )

Invoked if the mouse cursor becomes grabbed or un-grabbed. See WindowHelper::set_cursor_grab.

Note: mouse movement events will behave differently depending on the current cursor grabbing status.

source§

fn on_fullscreen_status_changed( &mut self, helper: &mut WindowHelper<UserEventType>, fullscreen: bool )

Invoked if the window enters or exits fullscreen mode. See WindowHelper::set_fullscreen_mode.

source§

fn on_scale_factor_changed( &mut self, helper: &mut WindowHelper<UserEventType>, scale_factor: f64 )

Invoked when the window scale factor changes.

source§

fn on_draw( &mut self, helper: &mut WindowHelper<UserEventType>, graphics: &mut Graphics2D )

Invoked when the contents of the window needs to be redrawn.

It is possible to request a redraw from any callback using WindowHelper::request_redraw.

source§

fn on_mouse_move( &mut self, helper: &mut WindowHelper<UserEventType>, position: Vec2 )

Invoked when the mouse changes position.

Normally, this provides the absolute position of the mouse in the window/canvas. However, if the mouse cursor is grabbed, this will instead provide the amount of relative movement since the last move event.

See WindowHandler::on_mouse_grab_status_changed.

source§

fn on_mouse_button_down( &mut self, helper: &mut WindowHelper<UserEventType>, button: MouseButton )

Invoked when a mouse button is pressed.

source§

fn on_mouse_button_up( &mut self, helper: &mut WindowHelper<UserEventType>, button: MouseButton )

Invoked when a mouse button is released.

source§

fn on_mouse_wheel_scroll( &mut self, helper: &mut WindowHelper<UserEventType>, distance: MouseScrollDistance )

Invoked when the mouse wheel moves.

source§

fn on_key_down( &mut self, helper: &mut WindowHelper<UserEventType>, virtual_key_code: Option<VirtualKeyCode>, scancode: KeyScancode )

Invoked when a keyboard key is pressed.

To detect when a character is typed, see the WindowHandler::on_keyboard_char callback.

source§

fn on_key_up( &mut self, helper: &mut WindowHelper<UserEventType>, virtual_key_code: Option<VirtualKeyCode>, scancode: KeyScancode )

Invoked when a keyboard key is released.

source§

fn on_keyboard_char( &mut self, helper: &mut WindowHelper<UserEventType>, unicode_codepoint: char )

Invoked when a character is typed on the keyboard.

This is invoked in addition to the WindowHandler::on_key_up and WindowHandler::on_key_down callbacks.

source§

fn on_keyboard_modifiers_changed( &mut self, helper: &mut WindowHelper<UserEventType>, state: ModifiersState )

Invoked when the state of the modifier keys has changed.

Auto Trait Implementations§

§

impl<UserEventType> !RefUnwindSafe for WindowWrapper<UserEventType>

§

impl<UserEventType> !Send for WindowWrapper<UserEventType>

§

impl<UserEventType> !Sync for WindowWrapper<UserEventType>

§

impl<UserEventType> Unpin for WindowWrapper<UserEventType>

§

impl<UserEventType> !UnwindSafe for WindowWrapper<UserEventType>

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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.

§

impl<T> Pointable for T

§

const ALIGN: usize = mem::align_of::<T>()

The alignment of pointer.
§

type Init = T

The type for initializers.
§

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

Initializes a with the given initializer. Read more
§

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

Dereferences the given pointer. Read more
§

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

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

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

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

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.