zng_app::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

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) -> PxSize

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: PxSize)

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>, ) -> (PxSize, 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), ) -> ((PxSize, PxSize), 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.

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: StateValue + Clone>( &self, id: impl Into<StateId<T>>, ) -> Option<T>

Get the window state id, if it is set.

source

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

Require the window state id.

Panics if the id is not set.

source

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

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: StateValue>( &self, id: impl Into<StateId<T>>, init: impl FnOnce() -> T, )

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

source

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

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

source

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

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.

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
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, 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, 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<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> StateValue for T
where T: Any + Send + Sync,