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
impl WINDOW
sourcepub fn with_test_context<R>(
&self,
update_mode: WidgetUpdateMode,
f: impl FnOnce() -> R,
) -> R
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.
sourcepub fn test_window_size(&self) -> PxSize
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.
sourcepub fn set_test_window_size(&self, size: PxSize)
pub fn set_test_window_size(&self, size: PxSize)
Set test window size
.
sourcepub fn test_init(&self, content: &mut impl UiNode) -> ContextUpdates
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.
sourcepub fn test_deinit(&self, content: &mut impl UiNode) -> ContextUpdates
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.
sourcepub fn test_info(&self, content: &mut impl UiNode) -> ContextUpdates
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.
sourcepub fn test_event(
&self,
content: &mut impl UiNode,
update: &mut EventUpdate,
) -> ContextUpdates
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.
sourcepub fn test_update(
&self,
content: &mut impl UiNode,
updates: Option<&mut WidgetUpdates>,
) -> ContextUpdates
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.
sourcepub fn test_layout(
&self,
content: &mut impl UiNode,
constraints: Option<PxConstraints2d>,
) -> (PxSize, ContextUpdates)
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.
sourcepub fn test_layout_inline(
&self,
content: &mut impl UiNode,
measure_constraints: (PxConstraints2d, InlineConstraintsMeasure),
layout_constraints: (PxConstraints2d, InlineConstraintsLayout),
) -> ((PxSize, PxSize), ContextUpdates)
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.
sourcepub fn test_render(
&self,
content: &mut impl UiNode,
) -> (BuiltFrame, ContextUpdates)
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.
sourcepub fn test_render_update(
&self,
content: &mut impl UiNode,
) -> (BuiltFrameUpdate, ContextUpdates)
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
impl WINDOW
sourcepub fn is_in_window(&self) -> bool
pub fn is_in_window(&self) -> bool
Returns true
if called inside a window.
sourcepub fn mode(&self) -> WindowMode
pub fn mode(&self) -> WindowMode
Gets the window mode.
sourcepub fn info(&self) -> WidgetInfoTree
pub fn info(&self) -> WidgetInfoTree
Gets the window info tree.
Panics if called before the window future yields the window.
sourcepub fn with_state<R>(&self, f: impl FnOnce(StateMapRef<'_, WINDOW>) -> R) -> R
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.
sourcepub fn with_state_mut<R>(
&self,
f: impl FnOnce(StateMapMut<'_, WINDOW>) -> R,
) -> R
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.
sourcepub fn get_state<T: StateValue + Clone>(
&self,
id: impl Into<StateId<T>>,
) -> Option<T>
pub fn get_state<T: StateValue + Clone>( &self, id: impl Into<StateId<T>>, ) -> Option<T>
Get the window state id
, if it is set.
sourcepub fn req_state<T: StateValue + Clone>(&self, id: impl Into<StateId<T>>) -> T
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.
sourcepub fn set_state<T: StateValue>(
&self,
id: impl Into<StateId<T>>,
value: impl Into<T>,
) -> Option<T>
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.
sourcepub fn flag_state(&self, id: impl Into<StateId<()>>) -> bool
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.
sourcepub fn init_state<T: StateValue>(
&self,
id: impl Into<StateId<T>>,
init: impl FnOnce() -> T,
)
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.
sourcepub fn init_state_default<T: StateValue + Default>(
&self,
id: impl Into<StateId<T>>,
)
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.
sourcepub fn contains_state<T: StateValue>(&self, id: impl Into<StateId<T>>) -> bool
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.
sourcepub fn with_context<R>(&self, ctx: &mut WindowCtx, f: impl FnOnce() -> R) -> R
pub fn with_context<R>(&self, ctx: &mut WindowCtx, f: impl FnOnce() -> R) -> R
Calls f
while the window is set to ctx
.
sourcepub fn with_no_context<R>(&self, f: impl FnOnce() -> R) -> R
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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