pub struct Overlay { /* private fields */ }Expand description
A declarative overlay that renders content above all other views.
The overlay content remains in the view tree as a child of this view, maintaining proper parent-child lifetime semantics. Floem reparents overlay nodes in the box tree to the window root so they participate in normal z-index ordering above regular content.
Visibility can be controlled through styles on the content itself.
§Example
use floem::prelude::*;
use floem::views::{Label, Overlay, Decorators};
let show_dialog = RwSignal::new(false);
Stack::vertical((
Button::new("Show Dialog").action(move || show_dialog.set(true)),
Overlay::new_dyn(move || {
let visible = show_dialog.get();
Stack::vertical((
Label::derived(|| "This is a dialog!".to_string()),
Button::new("Close").action(move || show_dialog.set(false)),
))
.style(move |s| {
s.apply_if(!visible, |s| s.hide())
.background(Color::WHITE)
.padding(20)
.border_radius(8)
})
}),
));§Notes
- The overlay is positioned absolutely at the window level
- Overlay uses a default
z-index: 1so it sorts above non-overlay content - You can style the overlay content using the view returned by
Overlay::new(...) - The overlay is automatically removed when this view is cleaned up
Implementations§
Source§impl Overlay
impl Overlay
Sourcepub fn new(child: impl IntoView + 'static) -> Overlay
pub fn new(child: impl IntoView + 'static) -> Overlay
Creates a new overlay.
§Example
use floem::prelude::*;
use floem::views::{Overlay, Label};
Overlay::new("Static overlay content");Sourcepub fn base() -> Overlay
pub fn base() -> Overlay
Creates a new overlay with no child.
§Example
use floem::prelude::*;
use floem::views::Overlay;
Overlay::base();Sourcepub fn new_dyn<CF, V>(child_fn: CF) -> Overlay
pub fn new_dyn<CF, V>(child_fn: CF) -> Overlay
Creates a new overlay whose child will dynamically update in response to signal changes.
§Example
use floem::prelude::*;
use floem::views::{Label, Overlay};
let message = RwSignal::new("Loading...".to_string());
Overlay::new_dyn(move || Label::new(message.get()));Trait Implementations§
Source§impl ParentView for Overlay
impl ParentView for Overlay
Source§fn scope(&self) -> Option<Scope>
fn scope(&self) -> Option<Scope>
Source§fn child(self, child: impl IntoView + 'static) -> Self
fn child(self, child: impl IntoView + 'static) -> Self
Source§fn children(self, children: impl IntoViewIter + 'static) -> Self
fn children(self, children: impl IntoViewIter + 'static) -> Self
Source§fn derived_children<CF, C>(self, children_fn: CF) -> Selfwhere
CF: Fn() -> C + 'static,
C: IntoViewIter + 'static,
fn derived_children<CF, C>(self, children_fn: CF) -> Selfwhere
CF: Fn() -> C + 'static,
C: IntoViewIter + 'static,
Source§fn stateful_child<S, SF, CF, V>(self, state_fn: SF, child_fn: CF) -> Self
fn stateful_child<S, SF, CF, V>(self, state_fn: SF, child_fn: CF) -> Self
Source§fn keyed_children<IF, I, T, K, KF, VF, V>(
self,
items_fn: IF,
key_fn: KF,
view_fn: VF,
) -> Self
fn keyed_children<IF, I, T, K, KF, VF, V>( self, items_fn: IF, key_fn: KF, view_fn: VF, ) -> Self
Source§impl View for Overlay
impl View for Overlay
fn id(&self) -> ViewId
fn view_style(&self) -> Option<Style>
fn debug_name(&self) -> Cow<'static, str>
fn view_class(&self) -> Option<StyleClassRef>
Source§fn update(&mut self, cx: &mut UpdateCx<'_>, state: Box<dyn Any>)
fn update(&mut self, cx: &mut UpdateCx<'_>, state: Box<dyn Any>)
View’s Id handle Read moreSource§fn style_pass(&mut self, cx: &mut StyleCx<'_>)
fn style_pass(&mut self, cx: &mut StyleCx<'_>)
Source§fn event_capture(&mut self, _cx: &mut EventCx<'_>) -> EventPropagation
fn event_capture(&mut self, _cx: &mut EventCx<'_>) -> EventPropagation
Source§fn event(&mut self, _cx: &mut EventCx<'_>) -> EventPropagation
fn event(&mut self, _cx: &mut EventCx<'_>) -> EventPropagation
Source§fn paint(&mut self, cx: &mut PaintCx<'_>)
fn paint(&mut self, cx: &mut PaintCx<'_>)
View-specific implementation. Called during paint traversal for this view.
Children are painted automatically by Floem.
Views should only paint their own content (backgrounds, borders, custom drawing).fn post_paint(&mut self, cx: &mut PaintCx<'_>)
Auto Trait Implementations§
impl Freeze for Overlay
impl RefUnwindSafe for Overlay
impl !Send for Overlay
impl !Sync for Overlay
impl Unpin for Overlay
impl UnsafeUnpin for Overlay
impl UnwindSafe for Overlay
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> ContainerExt for Twhere
T: IntoView + 'static,
impl<T> ContainerExt for Twhere
T: IntoView + 'static,
Source§impl<T> Decorators for Twhere
T: IntoView,
impl<T> Decorators for Twhere
T: IntoView,
Source§fn style(self, style: impl Fn(Style) -> Style + 'static) -> Self::Intermediate
fn style(self, style: impl Fn(Style) -> Style + 'static) -> Self::Intermediate
Source§fn debug_name(self, name: impl Into<String>) -> Self::Intermediate
fn debug_name(self, name: impl Into<String>) -> Self::Intermediate
Source§fn debug_name_if<S>(
self,
apply: impl Fn() -> bool + 'static,
name: impl Fn() -> S + 'static,
) -> Self::Intermediate
fn debug_name_if<S>( self, apply: impl Fn() -> bool + 'static, name: impl Fn() -> S + 'static, ) -> Self::Intermediate
Source§fn dragging_style(
self,
style: impl Fn(Style) -> Style + 'static,
) -> Self::Intermediate
fn dragging_style( self, style: impl Fn(Style) -> Style + 'static, ) -> Self::Intermediate
Source§fn class<C>(self, _class: C) -> Self::Intermediatewhere
C: StyleClass,
fn class<C>(self, _class: C) -> Self::Intermediatewhere
C: StyleClass,
Source§fn class_if<C>(
self,
apply: impl Fn() -> bool + 'static,
_class: C,
) -> Self::Intermediatewhere
C: StyleClass,
fn class_if<C>(
self,
apply: impl Fn() -> bool + 'static,
_class: C,
) -> Self::Intermediatewhere
C: StyleClass,
Source§fn remove_class<C>(self, _class: C) -> Self::Intermediatewhere
C: StyleClass,
fn remove_class<C>(self, _class: C) -> Self::Intermediatewhere
C: StyleClass,
Set this property using Style::keyboard_navigable instead
Source§fn disable_default_event<L>(
self,
disable: impl Fn() -> (L, bool) + 'static,
) -> Self::Intermediatewhere
L: EventListenerTrait,
fn disable_default_event<L>(
self,
disable: impl Fn() -> (L, bool) + 'static,
) -> Self::Intermediatewhere
L: EventListenerTrait,
Source§fn draggable(self) -> <Self::Intermediate as IntoView>::Intermediate
fn draggable(self) -> <Self::Intermediate as IntoView>::Intermediate
Source§fn draggable_with_config(
self,
config: impl Fn() -> DragConfig + 'static,
) -> <Self::Intermediate as IntoView>::Intermediate
fn draggable_with_config( self, config: impl Fn() -> DragConfig + 'static, ) -> <Self::Intermediate as IntoView>::Intermediate
Source§fn disabled(
self,
disabled_fn: impl Fn() -> bool + 'static,
) -> Self::Intermediate
fn disabled( self, disabled_fn: impl Fn() -> bool + 'static, ) -> Self::Intermediate
use Style::set_disabled directly instead
Source§fn on_event_with_config<L>(
self,
listener: L,
config: EventCallbackConfig,
action: impl FnMut(&mut EventCx<'_>, &<L as EventListenerTrait>::EventData) -> EventPropagation + 'static,
) -> Self::Intermediate
fn on_event_with_config<L>( self, listener: L, config: EventCallbackConfig, action: impl FnMut(&mut EventCx<'_>, &<L as EventListenerTrait>::EventData) -> EventPropagation + 'static, ) -> Self::Intermediate
EventListener with custom phase configuration.Source§fn on_event_cont_with_config<L>(
self,
listener: L,
config: EventCallbackConfig,
action: impl FnMut(&mut EventCx<'_>, &<L as EventListenerTrait>::EventData) + 'static,
) -> Self::Intermediate
fn on_event_cont_with_config<L>( self, listener: L, config: EventCallbackConfig, action: impl FnMut(&mut EventCx<'_>, &<L as EventListenerTrait>::EventData) + 'static, ) -> Self::Intermediate
EventListener. This event will be handled with
the given handler and the event will continue propagating.Source§fn on_event_stop_with_config<L>(
self,
listener: L,
config: EventCallbackConfig,
action: impl FnMut(&mut EventCx<'_>, &<L as EventListenerTrait>::EventData) + 'static,
) -> Self::Intermediate
fn on_event_stop_with_config<L>( self, listener: L, config: EventCallbackConfig, action: impl FnMut(&mut EventCx<'_>, &<L as EventListenerTrait>::EventData) + 'static, ) -> Self::Intermediate
EventListener. This event will be handled with
the given handler and the event will stop propagating.Source§fn on_event<L>(
self,
listener: L,
action: impl FnMut(&mut EventCx<'_>, &<L as EventListenerTrait>::EventData) -> EventPropagation + 'static,
) -> Self::Intermediate
fn on_event<L>( self, listener: L, action: impl FnMut(&mut EventCx<'_>, &<L as EventListenerTrait>::EventData) -> EventPropagation + 'static, ) -> Self::Intermediate
EventListener.Source§fn on_event_cont<L>(
self,
listener: L,
action: impl FnMut(&mut EventCx<'_>, &<L as EventListenerTrait>::EventData) + 'static,
) -> Self::Intermediate
fn on_event_cont<L>( self, listener: L, action: impl FnMut(&mut EventCx<'_>, &<L as EventListenerTrait>::EventData) + 'static, ) -> Self::Intermediate
EventListener. This event will be handled with
the given handler and the event will continue propagating.Source§fn on_event_stop<L>(
self,
listener: L,
action: impl FnMut(&mut EventCx<'_>, &<L as EventListenerTrait>::EventData) + 'static,
) -> Self::Intermediate
fn on_event_stop<L>( self, listener: L, action: impl FnMut(&mut EventCx<'_>, &<L as EventListenerTrait>::EventData) + 'static, ) -> Self::Intermediate
EventListener. This event will be handled with
the given handler and the event will stop propagating.Source§fn on_key_down(
self,
key: Key,
cmp: impl Fn(Modifiers) -> bool + 'static,
action: impl FnMut(&mut EventCx<'_>, &KeyboardEvent) + 'static,
) -> Self::Intermediate
fn on_key_down( self, key: Key, cmp: impl Fn(Modifiers) -> bool + 'static, action: impl FnMut(&mut EventCx<'_>, &KeyboardEvent) + 'static, ) -> Self::Intermediate
Use on_event(listener::KeyDown, ...) instead.
Source§fn on_key_up(
self,
key: Key,
cmp: impl Fn(Modifiers) -> bool + 'static,
action: impl FnMut(&mut EventCx<'_>, &KeyboardEvent) + 'static,
) -> Self::Intermediate
fn on_key_up( self, key: Key, cmp: impl Fn(Modifiers) -> bool + 'static, action: impl FnMut(&mut EventCx<'_>, &KeyboardEvent) + 'static, ) -> Self::Intermediate
Use on_event(listener::KeyUp, ...) instead.
Source§fn on_click(
self,
action: impl FnMut(&mut EventCx<'_>) -> EventPropagation + 'static,
) -> Self::Intermediate
fn on_click( self, action: impl FnMut(&mut EventCx<'_>) -> EventPropagation + 'static, ) -> Self::Intermediate
Use on_event(Click, |cx, _event| { ... }) instead. The new API provides direct access to typed event data.
EventListener::Click.Source§fn on_click_cont(
self,
action: impl FnMut(&mut EventCx<'_>) + 'static,
) -> Self::Intermediate
fn on_click_cont( self, action: impl FnMut(&mut EventCx<'_>) + 'static, ) -> Self::Intermediate
Use on_event_cont(Click, |cx, _event| { ... }) instead. The new API provides direct access to typed event data.
EventListener::Click. This event will be handled with
the given handler and the event will continue propagating.Source§fn on_click_stop(
self,
action: impl FnMut(&mut EventCx<'_>) + 'static,
) -> Self::Intermediate
fn on_click_stop( self, action: impl FnMut(&mut EventCx<'_>) + 'static, ) -> Self::Intermediate
Use on_event_stop(Click, |cx, _event| { ... }) instead. The new API provides direct access to typed event data.
EventListener::Click. This event will be handled with
the given handler and the event will stop propagating.Source§fn action(self, action: impl FnMut() + 'static) -> Self::Intermediate
fn action(self, action: impl FnMut() + 'static) -> Self::Intermediate
Source§fn on_double_click(
self,
action: impl FnMut(&mut EventCx<'_>) -> EventPropagation + 'static,
) -> Self::Intermediate
fn on_double_click( self, action: impl FnMut(&mut EventCx<'_>) -> EventPropagation + 'static, ) -> Self::Intermediate
Use on_event(DoubleClick, |cx, _event| { ... }) instead. The new API provides direct access to typed event data.
EventListener::DoubleClickSource§fn on_double_click_cont(
self,
action: impl FnMut(&mut EventCx<'_>) + 'static,
) -> Self::Intermediate
fn on_double_click_cont( self, action: impl FnMut(&mut EventCx<'_>) + 'static, ) -> Self::Intermediate
Use on_event_cont(DoubleClick, |cx, _event| { ... }) instead. The new API provides direct access to typed event data.
EventListener::DoubleClick. This event will be handled with
the given handler and the event will continue propagating.Source§fn on_double_click_stop(
self,
action: impl FnMut(&mut EventCx<'_>) + 'static,
) -> Self::Intermediate
fn on_double_click_stop( self, action: impl FnMut(&mut EventCx<'_>) + 'static, ) -> Self::Intermediate
Use on_event_stop(DoubleClick, |cx, _event| { ... }) instead. The new API provides direct access to typed event data.
EventListener::DoubleClick. This event will be handled with
the given handler and the event will stop propagating.Source§fn on_secondary_click(
self,
action: impl FnMut(&mut EventCx<'_>) -> EventPropagation + 'static,
) -> Self::Intermediate
fn on_secondary_click( self, action: impl FnMut(&mut EventCx<'_>) -> EventPropagation + 'static, ) -> Self::Intermediate
Use on_event(SecondaryClick, |cx, _event| { ... }) instead. The new API provides direct access to typed event data.
EventListener::SecondaryClick. This is most often the “Right” click.Source§fn on_secondary_click_cont(
self,
action: impl FnMut(&mut EventCx<'_>) + 'static,
) -> Self::Intermediate
fn on_secondary_click_cont( self, action: impl FnMut(&mut EventCx<'_>) + 'static, ) -> Self::Intermediate
Use on_event_cont(SecondaryClick, |cx, _event| { ... }) instead. The new API provides direct access to typed event data.
EventListener::SecondaryClick. This is most often the “Right” click.
This event will be handled with the given handler and the event will continue propagating.Source§fn on_secondary_click_stop(
self,
action: impl FnMut(&mut EventCx<'_>) + 'static,
) -> Self::Intermediate
fn on_secondary_click_stop( self, action: impl FnMut(&mut EventCx<'_>) + 'static, ) -> Self::Intermediate
Use on_event_stop(SecondaryClick, |cx, _event| { ... }) instead. The new API provides direct access to typed event data.
EventListener::SecondaryClick. This is most often the “Right” click.
This event will be handled with the given handler and the event will stop propagating.Source§fn on_cleanup(self, action: impl Fn() + 'static) -> Self::Intermediate
fn on_cleanup(self, action: impl Fn() + 'static) -> Self::Intermediate
Source§fn animation(
self,
animation: impl Fn(Animation) -> Animation + 'static,
) -> Self::Intermediate
fn animation( self, animation: impl Fn(Animation) -> Animation + 'static, ) -> Self::Intermediate
Source§fn clear_focus(self, when: impl Fn() + 'static) -> Self::Intermediate
fn clear_focus(self, when: impl Fn() + 'static) -> Self::Intermediate
Source§fn request_focus(self, when: impl Fn() + 'static) -> Self::Intermediate
fn request_focus(self, when: impl Fn() + 'static) -> Self::Intermediate
Source§fn window_scale(
self,
scale_fn: impl Fn() -> f64 + 'static,
) -> Self::Intermediate
fn window_scale( self, scale_fn: impl Fn() -> f64 + 'static, ) -> Self::Intermediate
Source§fn window_title(
self,
title_fn: impl Fn() -> String + 'static,
) -> Self::Intermediate
fn window_title( self, title_fn: impl Fn() -> String + 'static, ) -> Self::Intermediate
§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> 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 moreSource§impl<VW> IntoView for VWwhere
VW: View + 'static,
impl<VW> IntoView for VWwhere
VW: View + 'static,
Source§type Intermediate = VW
type Intermediate = VW
Source§fn into_intermediate(self) -> <VW as IntoView>::Intermediate
fn into_intermediate(self) -> <VW as IntoView>::Intermediate
Source§impl<T> OverlayExt for Twhere
T: IntoView + 'static,
impl<T> OverlayExt for Twhere
T: IntoView + 'static,
§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().