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.
impl WINDOW
Window test helpers.
§Panics
Most of the test methods panic if not called inside with_test_context.
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 UiNode) -> ContextUpdates
pub fn test_init(&self, content: &mut 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 UiNode) -> ContextUpdates
pub fn test_deinit(&self, content: &mut 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 UiNode) -> ContextUpdates
pub fn test_info(&self, content: &mut 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 UiNode,
update: &mut EventUpdate,
) -> ContextUpdates
pub fn test_event( &self, content: &mut 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 UiNode,
updates: Option<&mut WidgetUpdates>,
) -> ContextUpdates
pub fn test_update( &self, content: &mut 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 UiNode,
constraints: Option<PxConstraints2d>,
) -> (PxSize, ContextUpdates)
pub fn test_layout( &self, content: &mut 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 UiNode,
measure_constraints: (PxConstraints2d, InlineConstraintsMeasure),
layout_constraints: (PxConstraints2d, InlineConstraintsLayout),
) -> ((PxSize, PxSize), ContextUpdates)
pub fn test_layout_inline( &self, content: &mut 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 UiNode) -> (BuiltFrame, ContextUpdates)
pub fn test_render(&self, content: &mut 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 UiNode,
) -> (BuiltFrameUpdate, ContextUpdates)
pub fn test_render_update( &self, content: &mut 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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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