[−][src]Struct show_image::Window
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]
&self,
image: impl ImageData,
name: impl Into<String>
) -> Result<(), String>
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]
Handler: FnMut(&mut EventHandlerContext) + Send + 'static,
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]
&self,
timeout: Duration
) -> Result<Option<KeyboardEvent>, WaitKeyError>
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]
&self,
deadline: Instant
) -> Result<Option<KeyboardEvent>, WaitKeyError>
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
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> SetParameter for T
fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Result where
T: Parameter<Self>,
T: Parameter<Self>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,