[][src]Trait druid_shell::window::WinHandler

pub trait WinHandler<THandler> {
    fn paint(&mut self, piet: &mut Piet, ctx: &mut dyn WinCtx) -> bool;
fn get_window_id(&self) -> WindowIdType;
fn add_handler(&self, window_id: WindowIdType, handler: THandler); fn size(&mut self, width: u32, height: u32, ctx: &mut dyn WinCtx) { ... }
fn mouse_move(&mut self, event: &MouseEvent, ctx: &mut dyn WinCtx) { ... }
fn mouse_down(&mut self, event: &MouseEvent, ctx: &mut dyn WinCtx) { ... }
fn mouse_up(&mut self, event: &MouseEvent, ctx: &mut dyn WinCtx) { ... }
fn timer(&mut self, token: TimerToken, ctx: &mut dyn WinCtx) { ... }
fn got_focus(&mut self, ctx: &mut dyn WinCtx) { ... }
fn destroy(&mut self, ctx: &mut dyn WinCtx) { ... } }

App behavior, supplied by the app.

Many of the "window procedure" messages map to calls to this trait. The methods are non-mut because the window procedure can be called recursively; implementers are expected to use RefCell or the like, but should be careful to keep the lifetime of the borrow short.

Required methods

fn paint(&mut self, piet: &mut Piet, ctx: &mut dyn WinCtx) -> bool

Request the handler to paint the window contents. Return value indicates whether window is animating, i.e. whether another paint should be scheduled for the next animation frame.

fn get_window_id(&self) -> WindowIdType

Return the Window ID for this WinHandler

fn add_handler(&self, window_id: WindowIdType, handler: THandler)

Add a Window Handler for the Data type

Loading content...

Provided methods

fn size(&mut self, width: u32, height: u32, ctx: &mut dyn WinCtx)

Provide the handler with a handle to the window so that it can invalidate or make other requests. Called when the size of the window is changed. Note that size is in physical pixels.

fn mouse_move(&mut self, event: &MouseEvent, ctx: &mut dyn WinCtx)

Called when the mouse moves.

fn mouse_down(&mut self, event: &MouseEvent, ctx: &mut dyn WinCtx)

Called on mouse button down.

fn mouse_up(&mut self, event: &MouseEvent, ctx: &mut dyn WinCtx)

Called on mouse button up.

fn timer(&mut self, token: TimerToken, ctx: &mut dyn WinCtx)

Called on timer event.

This is called at (approximately) the requested deadline by a WinCtx::request_timer() call. The token argument here is the same as the return value of that call.

fn got_focus(&mut self, ctx: &mut dyn WinCtx)

Called when this window becomes the focused window.

fn destroy(&mut self, ctx: &mut dyn WinCtx)

Called when the window is being destroyed. Note that this happens earlier in the sequence than drop (at WM_DESTROY, while the latter is WM_NCDESTROY).

Loading content...

Implementors

Loading content...