pub struct Sticky<W> { /* private fields */ }Expand description
A widget that keeps its contents in view.
When the contents of a Sticky widget would go out of view (for
example, when they are scrolled out of a Scrollable),
they are moved into an overlay inside the intersection of the parent’s
layout.bounds and the viewport, so that they stay
visible at the edge of the viewport.
The contents start floating as soon as any of their edges goes out of the visible bounds, and they are always clamped to the visible bounds, so that they stay inside them.
While they are stuck, the contents keep their original layout: they simply float in a new position.
When the edges of the contents reach the edges of their parent, they stay attached to them: they keep their original bounds, and are clipped to the visible bounds instead.
Once the parent of the contents has gone out of the visible bounds, they stop floating and scroll with it.
§Example
use iced::widget::{column, container, scrollable, sticky, space};
use iced::Fill;
enum Message {
// ...
}
fn view(state: &State) -> impl Widget<Message> {
scrollable(column![
sticky(container("I always stay in view!").width(Fill).padding(10)),
space().height(3000),
])
}Implementations§
Trait Implementations§
Source§impl<W, Message, Theme, Renderer> Widget<Message, Theme, Renderer> for Sticky<W>
impl<W, Message, Theme, Renderer> Widget<Message, Theme, Renderer> for Sticky<W>
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, )
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 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 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, )
Widget using the associated Renderer.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>>
Widget.Auto Trait Implementations§
impl<W> Freeze for Sticky<W>where
W: Freeze,
impl<W> RefUnwindSafe for Sticky<W>where
W: RefUnwindSafe,
impl<W> Send for Sticky<W>where
W: Send,
impl<W> Sync for Sticky<W>where
W: Sync,
impl<W> Unpin for Sticky<W>where
W: Unpin,
impl<W> UnsafeUnpin for Sticky<W>where
W: UnsafeUnpin,
impl<W> UnwindSafe for Sticky<W>where
W: UnwindSafe,
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<State, Message> IntoBoot<State, Message> for State
impl<State, Message> IntoBoot<State, Message> for State
Source§fn into_boot(self) -> (State, Task<Message>)
fn into_boot(self) -> (State, Task<Message>)
Application.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