[][src]Struct show_image::Window

pub struct Window { /* fields omitted */ }

A window capable of displaying images.

The handle can be used to set the displayed image, handle key events and to close the window.

If the handle is dropped, the window is closed.

Methods

impl Window[src]

pub fn set_image(
    &self,
    image: impl ImageData,
    name: impl Into<String>
) -> Result<(), String>
[src]

Set the image to de displayed by the window.

The name is used to suggest a defaullt file name when saving images. It is also returned again by Window::get_image.

pub fn get_image(&self) -> Result<Option<Image>, String>[src]

Get the currently displayed image of the window.

pub fn add_event_handler<Handler>(&self, handler: Handler) -> Result<(), String> where
    Handler: FnMut(&mut EventHandlerContext) + Send + 'static, 
[src]

Add a handler for events.

The added handler will be run directly in the context thread. This allows you to handle events asynchronously, but it also means your hander shouldn't block for long.

The handler can use the EventHandlerContext::spawn_task to perform long running operations.

If you want to handle events in your own thread, use Window::wait_key, Window::wait_key_deadline or Window::events.

pub fn close(self) -> Result<(), String>[src]

Close the window.

The window is automatically closed if the handle is dropped, but this function allows you to handle errors that may occur.

pub fn events(&self) -> &Receiver<Event>[src]

Get the receiver for events.

pub fn wait_key(
    &self,
    timeout: Duration
) -> Result<Option<KeyboardEvent>, WaitKeyError>
[src]

Wait for a key-down event with a timeout.

If an error is returned, no further key events will be received. Any loop processing keyboard input should terminate.

If no key press was available within the timeout, Ok(None) is returned.

This function discards all key-up events and blocks until a key is pressed or the timeout occurs.

pub fn wait_key_deadline(
    &self,
    deadline: Instant
) -> Result<Option<KeyboardEvent>, WaitKeyError>
[src]

Wait for a key-down event with a deadline.

If an error is returned, no further key events will be received. Any loop processing keyboard input should terminate.

If no key press was available within the timeout, Ok(None) is returned.

This function discards all key-up events and blocks until a key is pressed or the deadline passes.

Trait Implementations

impl Drop for Window[src]

Close the window when the handle is dropped.

Auto Trait Implementations

impl !RefUnwindSafe for Window

impl Send for Window

impl !Sync for Window

impl Unpin for Window

impl !UnwindSafe for Window

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> SetParameter for T

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.