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 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>(&self, id: impl Into<StateId<T>>) -> Option<T>where
T: StateValue + Clone,
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.
sourcepub fn req_state<T>(&self, id: impl Into<StateId<T>>) -> Twhere
T: StateValue + Clone,
pub fn req_state<T>(&self, id: impl Into<StateId<T>>) -> Twhere
T: StateValue + Clone,
Require the window state id
.
Panics if the id
is not set.
sourcepub fn set_state<T>(
&self,
id: impl Into<StateId<T>>,
value: impl Into<T>,
) -> Option<T>where
T: StateValue,
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.
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>(&self, id: impl Into<StateId<T>>, init: impl FnOnce() -> T)where
T: StateValue,
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.
sourcepub fn init_state_default<T>(&self, id: impl Into<StateId<T>>)where
T: StateValue + Default,
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.
sourcepub fn contains_state<T>(&self, id: impl Into<StateId<T>>) -> boolwhere
T: StateValue,
pub fn contains_state<T>(&self, id: impl Into<StateId<T>>) -> boolwhere
T: StateValue,
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.
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) -> Size2D<Px, Px>
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.
sourcepub fn set_test_window_size(&self, size: Size2D<Px, Px>)
pub fn set_test_window_size(&self, size: Size2D<Px, Px>)
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>,
) -> (Size2D<Px, Px>, ContextUpdates)
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.
sourcepub fn test_layout_inline(
&self,
content: &mut impl UiNode,
measure_constraints: (PxConstraints2d, InlineConstraintsMeasure),
layout_constraints: (PxConstraints2d, InlineConstraintsLayout),
) -> ((Size2D<Px, Px>, Size2D<Px, Px>), ContextUpdates)
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.
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.
Trait Implementations§
source§impl WINDOW_Ext for WINDOW
impl WINDOW_Ext for WINDOW
source§fn vars(&self) -> WindowVars
fn vars(&self) -> WindowVars
source§fn enable_access(&self)
fn enable_access(&self)
source§fn loading_handle(
&self,
deadline: impl Into<Deadline>,
) -> Option<WindowLoadingHandle>
fn loading_handle( &self, deadline: impl Into<Deadline>, ) -> Option<WindowLoadingHandle>
source§fn frame_image(
&self,
mask: Option<ImageMaskMode>,
) -> ReadOnlyVar<Img, ArcVar<Img>>
fn frame_image( &self, mask: Option<ImageMaskMode>, ) -> ReadOnlyVar<Img, ArcVar<Img>>
source§fn frame_image_rect(
&self,
rect: Rect<Px, Px>,
mask: Option<ImageMaskMode>,
) -> ReadOnlyVar<Img, ArcVar<Img>>
fn frame_image_rect( &self, rect: Rect<Px, Px>, mask: Option<ImageMaskMode>, ) -> ReadOnlyVar<Img, ArcVar<Img>>
source§fn bring_to_top(&self)
fn bring_to_top(&self)
source§fn close(
&self,
) -> ReadOnlyVar<Response<CloseWindowResult>, ArcVar<Response<CloseWindowResult>>>
fn close( &self, ) -> ReadOnlyVar<Response<CloseWindowResult>, ArcVar<Response<CloseWindowResult>>>
WINDOW_CLOSE_REQUESTED_EVENT
. If the window has children they are closed together. Read moreAuto 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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&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
impl<T> DowncastSync for 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> 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