pub struct Sensor<'a, Key, Message, W = Element<'a, Message>> { /* private fields */ }Expand description
A widget that can generate messages when its content pops in and out of view.
It can even notify you with anticipation at a given distance!
Implementations§
Source§impl<'a, Key, Message, W> Sensor<'a, Key, Message, W>where
Key: Key,
impl<'a, Key, Message, W> Sensor<'a, Key, Message, W>where
Key: Key,
Sourcepub fn on_show(self, on_show: impl Fn(Size) -> Message + 'a) -> Self
pub fn on_show(self, on_show: impl Fn(Size) -> Message + 'a) -> Self
Sets the message to be produced when the content pops into view.
The closure will receive the [Size] of the content in that moment.
Sourcepub fn on_resize<T>(self, on_resize: impl Fn(Size) -> T + 'a) -> Self
pub fn on_resize<T>(self, on_resize: impl Fn(Size) -> T + 'a) -> Self
Sets the message to be produced when the content changes [Size] once its in view.
The closure will receive the new [Size] of the content.
Sourcepub fn on_hide(self, on_hide: Message) -> Self
pub fn on_hide(self, on_hide: Message) -> Self
Sets the message to be produced when the content pops out of view.
Sourcepub fn anticipate(self, distance: impl Into<Pixels>) -> Self
pub fn anticipate(self, distance: impl Into<Pixels>) -> Self
Sets the distance in [Pixels] to use in anticipation of the
content popping into view.
This can be quite useful to lazily load items in a long scrollable behind the scenes before the user can notice it!
Trait Implementations§
Source§impl<Key, Message, W, Theme, Renderer> Widget<Message, Theme, Renderer> for Sensor<'_, Key, Message, W>where
Key: Key,
Renderer: Renderer,
W: Widget<Message, Theme, Renderer>,
impl<Key, Message, W, Theme, Renderer> Widget<Message, Theme, Renderer> for Sensor<'_, Key, Message, W>where
Key: Key,
Renderer: Renderer,
W: Widget<Message, Theme, Renderer>,
Source§fn update(
&mut self,
tree: &mut Tree,
event: &Event,
layout: Layout,
cursor: Cursor,
renderer: &Renderer,
shell: &mut Shell<'_, Message>,
viewport: &Rectangle,
)
fn update( &mut self, tree: &mut Tree, event: &Event, layout: Layout, cursor: Cursor, renderer: &Renderer, shell: &mut Shell<'_, Message>, viewport: &Rectangle, )
Source§fn layout(&mut self, tree: &mut Tree, renderer: &Renderer, limits: &Limits)
fn layout(&mut self, tree: &mut Tree, renderer: &Renderer, limits: &Limits)
Lays out the [
Widget]. Read moreSource§fn draw(
&self,
tree: &Tree,
renderer: &mut Renderer,
theme: &Theme,
style: &Style,
layout: Layout,
cursor: Cursor,
viewport: &Rectangle,
)
fn draw( &self, tree: &Tree, renderer: &mut Renderer, theme: &Theme, style: &Style, layout: Layout, cursor: Cursor, viewport: &Rectangle, )
Draws the [
Widget] using the associated Renderer.Source§fn operate(
&mut self,
tree: &mut Tree,
layout: Layout,
viewport: &Rectangle,
renderer: &Renderer,
operation: &mut dyn Operation,
)
fn operate( &mut self, tree: &mut Tree, layout: Layout, viewport: &Rectangle, renderer: &Renderer, operation: &mut dyn Operation, )
Applies an [
Operation] to the [Widget].Source§fn mouse_interaction(
&self,
tree: &Tree,
layout: Layout,
cursor: Cursor,
viewport: &Rectangle,
renderer: &Renderer,
) -> Interaction
fn mouse_interaction( &self, tree: &Tree, layout: Layout, cursor: Cursor, viewport: &Rectangle, renderer: &Renderer, ) -> Interaction
Source§fn overlay<'b>(
&'b mut self,
tree: &'b mut Tree,
layout: Layout,
renderer: &Renderer,
viewport: &Rectangle,
translation: Vector,
window: Size,
) -> Vec<Element<'b, Message, Theme, Renderer>>
fn overlay<'b>( &'b mut self, tree: &'b mut Tree, layout: Layout, renderer: &Renderer, viewport: &Rectangle, translation: Vector, window: Size, ) -> Vec<Element<'b, Message, Theme, Renderer>>
Returns the overlays of the [
Widget].Auto Trait Implementations§
impl<'a, Key, Message, W> Freeze for Sensor<'a, Key, Message, W>
impl<'a, Key, Message, W = Element<'a, Message, Theme, Renderer<Renderer, Renderer>>> !RefUnwindSafe for Sensor<'a, Key, Message, W>
impl<'a, Key, Message, W = Element<'a, Message, Theme, Renderer<Renderer, Renderer>>> !Send for Sensor<'a, Key, Message, W>
impl<'a, Key, Message, W = Element<'a, Message, Theme, Renderer<Renderer, Renderer>>> !Sync for Sensor<'a, Key, Message, W>
impl<'a, Key, Message, W> Unpin for Sensor<'a, Key, Message, W>
impl<'a, Key, Message, W> UnsafeUnpin for Sensor<'a, Key, Message, W>
impl<'a, Key, Message, W = Element<'a, Message, Theme, Renderer<Renderer, Renderer>>> !UnwindSafe for Sensor<'a, Key, Message, W>
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
Mutably borrows from an owned value. Read more
§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>
Convert
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>
Convert
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)
Convert
&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)
Convert
&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>
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 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>
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