zng::window

Struct WINDOW

source
pub struct WINDOW;
Expand description

Current context window.

This represents the minimum features required for a window context, see WINDOW_Ext for more features provided by the default window implementation.

§Panics

Most of the methods on this service panic if not called inside a window context.

Implementations§

source§

impl WINDOW

source

pub fn is_in_window(&self) -> bool

Returns true if called inside a window.

source

pub fn try_id(&self) -> Option<WindowId>

Gets the window ID, if called inside a window.

source

pub fn id(&self) -> WindowId

Gets the window ID.

source

pub fn mode(&self) -> WindowMode

Gets the window mode.

source

pub fn info(&self) -> WidgetInfoTree

Gets the window info tree.

Panics if called before the window future yields the window.

source

pub fn with_state<R>(&self, f: impl FnOnce(StateMapRef<'_, WINDOW>) -> R) -> R

Calls f with a read lock on the current window state map.

source

pub fn with_state_mut<R>( &self, f: impl FnOnce(StateMapMut<'_, WINDOW>) -> R, ) -> R

Calls f with a write lock on the current window state map.

source

pub fn get_state<T>(&self, id: impl Into<StateId<T>>) -> Option<T>
where T: StateValue + Clone,

Get the window state id, if it is set.

source

pub fn req_state<T>(&self, id: impl Into<StateId<T>>) -> T
where T: StateValue + Clone,

Require the window state id.

Panics if the id is not set.

source

pub fn set_state<T>( &self, id: impl Into<StateId<T>>, value: impl Into<T>, ) -> Option<T>
where T: StateValue,

Set the window state id to value.

Returns the previous set value.

source

pub fn flag_state(&self, id: impl Into<StateId<()>>) -> bool

Sets the window state id without value.

Returns if the state id was already flagged.

source

pub fn init_state<T>(&self, id: impl Into<StateId<T>>, init: impl FnOnce() -> T)
where T: StateValue,

Calls init and sets id if the id is not already set in the widget.

source

pub fn init_state_default<T>(&self, id: impl Into<StateId<T>>)
where T: StateValue + Default,

Sets the id to the default value if it is not already set.

source

pub fn contains_state<T>(&self, id: impl Into<StateId<T>>) -> bool
where T: StateValue,

Returns true if the id is set or flagged in the window.

source

pub fn with_context<R>(&self, ctx: &mut WindowCtx, f: impl FnOnce() -> R) -> R

Calls f while the window is set to ctx.

source

pub fn with_no_context<R>(&self, f: impl FnOnce() -> R) -> R

Calls f while no window is available in the context.

source§

impl WINDOW

Window test helpers.

§Panics

Most of the test methods panic if not called inside with_test_context.

source

pub fn with_test_context<R>( &self, update_mode: WidgetUpdateMode, f: impl FnOnce() -> R, ) -> R

Calls f inside a new headless window and root widget.

source

pub fn test_window_size(&self) -> Size2D<Px, Px>

Get the test window size.

This size is used by the test_* methods that need a window size.

source

pub fn set_test_window_size(&self, size: Size2D<Px, Px>)

Set test window size.

source

pub fn test_init(&self, content: &mut impl UiNode) -> ContextUpdates

Call inside with_test_context to init the content as a child of the test window root.

source

pub fn test_deinit(&self, content: &mut impl UiNode) -> ContextUpdates

Call inside with_test_context to deinit the content as a child of the test window root.

source

pub fn test_info(&self, content: &mut impl UiNode) -> ContextUpdates

Call inside with_test_context to rebuild info the content as a child of the test window root.

source

pub fn test_event( &self, content: &mut impl UiNode, update: &mut EventUpdate, ) -> ContextUpdates

Call inside with_test_context to delivery an event to the content as a child of the test window root.

source

pub fn test_update( &self, content: &mut impl UiNode, updates: Option<&mut WidgetUpdates>, ) -> ContextUpdates

Call inside with_test_context to update the content as a child of the test window root.

The updates can be set to a custom delivery list, otherwise window root and content widget are flagged for update.

source

pub fn test_layout( &self, content: &mut impl UiNode, constraints: Option<PxConstraints2d>, ) -> (Size2D<Px, Px>, ContextUpdates)

Call inside with_test_context to layout the content as a child of the test window root.

source

pub fn test_layout_inline( &self, content: &mut impl UiNode, measure_constraints: (PxConstraints2d, InlineConstraintsMeasure), layout_constraints: (PxConstraints2d, InlineConstraintsLayout), ) -> ((Size2D<Px, Px>, Size2D<Px, Px>), ContextUpdates)

Call inside with_test_context to layout the content as a child of the test window root.

Returns the measure and layout size, and the requested updates.

source

pub fn test_render( &self, content: &mut impl UiNode, ) -> (BuiltFrame, ContextUpdates)

Call inside with_test_context to render the content as a child of the test window root.

source

pub fn test_render_update( &self, content: &mut impl UiNode, ) -> (BuiltFrameUpdate, ContextUpdates)

Call inside with_test_context to render_update the content as a child of the test window root.

Trait Implementations§

source§

impl WINDOW_Ext for WINDOW

source§

fn vars(&self) -> WindowVars

Clone a reference to the variables that get and set window properties.
source§

fn is_open(&self) -> bool

Returns true if the window is open.
source§

fn is_loaded(&self) -> bool

Returns true if the window is open and loaded.
source§

fn enable_access(&self)

Enable accessibility info. Read more
source§

fn loading_handle( &self, deadline: impl Into<Deadline>, ) -> Option<WindowLoadingHandle>

Gets a handle that stops the window from loading while the handle is alive. Read more
source§

fn frame_image( &self, mask: Option<ImageMaskMode>, ) -> ReadOnlyVar<Img, ArcVar<Img>>

Generate an image from the current rendered frame of the window. Read more
source§

fn frame_image_rect( &self, rect: Rect<Px, Px>, mask: Option<ImageMaskMode>, ) -> ReadOnlyVar<Img, ArcVar<Img>>

Generate an image from a selection of the current rendered frame of the window. Read more
source§

fn bring_to_top(&self)

Move the window to the front of the operating system Z stack. Read more
source§

fn close( &self, ) -> ReadOnlyVar<Response<CloseWindowResult>, ArcVar<Response<CloseWindowResult>>>

Starts closing the window, the operation can be canceled by listeners of WINDOW_CLOSE_REQUESTED_EVENT. If the window has children they are closed together. Read more

Auto Trait Implementations§

§

impl Freeze for WINDOW

§

impl RefUnwindSafe for WINDOW

§

impl Send for WINDOW

§

impl Sync for WINDOW

§

impl Unpin for WINDOW

§

impl UnwindSafe for WINDOW

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

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

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

fn in_current_span(self) -> Instrumented<Self>

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

impl<T> Instrument for T

source§

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

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

fn in_current_span(self) -> Instrumented<Self>

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

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

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.

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize = _

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> Same for T

source§

type Output = T

Should always be Self
source§

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

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

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

Performs the conversion.
source§

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

source§

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

The type returned in the event of a conversion error.
source§

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

Performs the conversion.
§

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

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> MaybeSendSync for T

source§

impl<T> StateValue for T
where T: Any + Send + Sync,