Struct show_image::WindowProxy[][src]

pub struct WindowProxy { /* fields omitted */ }
Expand description

Proxy object to interact with a window from a user thread.

You should not use proxy objects from withing the global context thread. The proxy objects often wait for the global context to perform some action. Doing so from within the global context thread would cause a deadlock.

Implementations

impl WindowProxy[src]

pub fn new(window_id: WindowId, context_proxy: ContextProxy) -> Self[src]

Create a new window proxy from a context proxy and a window ID.

pub fn id(&self) -> WindowId[src]

Get the window ID.

pub fn context_proxy(&self) -> &ContextProxy[src]

Get the context proxy of the window proxy.

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

Set the displayed image of the window.

The real work is done in the context thread. This function blocks until the context thread has performed the action.

Note that you can not change the overlays with this function. To modify those, you can use Self::run_function or Self::run_function_wait to get access to the WindowHandle.

Panics

This function will panic if called from within the context thread.

pub fn add_event_handler<F>(&self, handler: F) -> Result<(), InvalidWindowId> where
    F: FnMut(&mut WindowHandle<'_>, &mut WindowEvent, &mut EventHandlerControlFlow) + Send + 'static, 
[src]

Add an event handler for the window.

Events that are already queued with the event loop will not be passed to the handler.

This function uses ContextProxy::run_function_wait internally, so it blocks until the event handler is added. To avoid blocking, you can use ContextProxy::run_function to post a lambda that adds an event handler instead.

Panics

This function will panic if called from within the context thread.

pub fn event_channel(&self) -> Result<Receiver<WindowEvent>, InvalidWindowId>[src]

Create a channel that receives events from the window.

To close the channel, simply drop de receiver. The channel is closed automatically when the window is destroyed.

Warning: The created channel blocks when you request an event until one is available. You should never use the receiver from within an event handler or a function posted to the global context thread. Doing so would cause a deadlock.

Panics

This function will panic if called from within the context thread.

pub fn wait_until_destroyed(&self) -> Result<(), InvalidWindowId>[src]

Wait for the window to be destroyed.

This can happen if the application code destroys the window or if the user closes the window.

Warning: This function blocks until the window is closed. You should never use this function from within an event handler or a function posted to the global context thread. Doing so would cause a deadlock.

Panics

This function will panic if called from within the context thread.

pub fn run_function<F>(&self, function: F) where
    F: 'static + FnOnce(&mut WindowHandle<'_>) + Send
[src]

Post a function for execution in the context thread without waiting for it to execute.

This function returns immediately, without waiting for the posted function to start or complete. If you want to get a return value back from the function, use Self::run_function_wait instead.

Note: You should not use this to post functions that block for a long time. Doing so will block the event loop and will make the windows unresponsive until the event loop can continue. Consider using self.context_proxy().run_background_task(...) for long blocking tasks instead.

Panics

This function will panic if called from within the context thread.

pub fn run_function_wait<F, T>(&self, function: F) -> T where
    F: FnOnce(&mut WindowHandle<'_>) -> T + Send + 'static,
    T: Send + 'static, 
[src]

Post a function for execution in the context thread and wait for the return value.

If you do not need a return value from the posted function, you can use Self::run_function to avoid blocking the calling thread until it completes.

Note: You should not use this to post functions that block for a long time. Doing so will block the event loop and will make the windows unresponsive until the event loop can continue. Consider using self.context_proxy().run_background_task(...) for long blocking tasks instead.

Panics

This function will panic if called from within the context thread.

Trait Implementations

impl Clone for WindowProxy[src]

fn clone(&self) -> WindowProxy[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

Auto Trait Implementations

Blanket Implementations

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

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

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

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

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

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> Downcast<T> for T

pub fn downcast(&self) -> &T

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

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T> Instrument for T[src]

fn instrument(self, span: Span) -> Instrumented<Self>[src]

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

fn in_current_span(self) -> Instrumented<Self>[src]

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

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

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> Pointable for T

pub const ALIGN: usize

The alignment of pointer.

type Init = T

The type for initializers.

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

Initializes a with the given initializer. Read more

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

Dereferences the given pointer. Read more

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

Mutably dereferences the given pointer. Read more

pub unsafe fn drop(ptr: usize)

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

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

Creates owned data from borrowed data, usually by cloning. Read more

pub fn clone_into(&self, target: &mut T)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

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.

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

Performs the conversion.

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.

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

Performs the conversion.

impl<T> Upcast<T> for T

pub fn upcast(&self) -> Option<&T>

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 

pub fn vzip(self) -> V