pub struct ScrollArea { /* private fields */ }Expand description
Scrolling with smooth wheel steps, elastic ends and overlay scroll bars.
Vertical by default; Self::horizontal lays the content out in a row
and Self::both scrolls on two axes. fade dissolves content at the
edges, which keeps floating glass legible without a solid bar behind it.
Long lists draw only what is visible with Self::show_rows.
Implementations§
Source§impl ScrollArea
impl ScrollArea
Sourcepub fn horizontal() -> Self
pub fn horizontal() -> Self
Horizontal scrolling. Children are placed side by side and centered on the height of the area. Vertical wheel movement passes to the area around it; shift with the wheel or a sideways swipe scrolls this one.
Sourcepub fn both() -> Self
pub fn both() -> Self
Scrolling on both axes, for content larger than the view both ways.
Children are stacked vertically in a column Self::content_width
wide, or as wide as they need when that is not set.
Sourcepub fn id(self, id: &'static str) -> Self
pub fn id(self, id: &'static str) -> Self
Names the area. Needed when one Ui holds more than one scroll area.
Sourcepub fn height(self, height: f32) -> Self
pub fn height(self, height: f32) -> Self
Sets the height. The default is the height left in the layout.
Sourcepub fn width(self, width: f32) -> Self
pub fn width(self, width: f32) -> Self
Sets the width. The default is the width left in the layout.
Sourcepub fn content_width(self, w: f32) -> Self
pub fn content_width(self, w: f32) -> Self
Width of the column the content is laid out in, for Self::both.
Sourcepub fn fade(self, top: f32, bottom: f32) -> Self
pub fn fade(self, top: f32, bottom: f32) -> Self
Dissolve content over this distance at the top and bottom.
Sourcepub fn fade_sides(self, left: f32, right: f32) -> Self
pub fn fade_sides(self, left: f32, right: f32) -> Self
Dissolve content over this distance at the left and right.
Sourcepub fn insets(self, top: f32, bottom: f32) -> Self
pub fn insets(self, top: f32, bottom: f32) -> Self
Space kept free for floating bars. Content scrolls below them.
Sourcepub fn show<R>(self, ui: &mut Ui<'_>, f: impl FnOnce(&mut Ui<'_>) -> R) -> R
pub fn show<R>(self, ui: &mut Ui<'_>, f: impl FnOnce(&mut Ui<'_>) -> R) -> R
Shows the area with the content drawn by f.
Sourcepub fn show_rows<R>(
self,
ui: &mut Ui<'_>,
row_height: f32,
count: usize,
f: impl FnOnce(&mut Ui<'_>, Range<usize>) -> R,
) -> R
pub fn show_rows<R>( self, ui: &mut Ui<'_>, row_height: f32, count: usize, f: impl FnOnce(&mut Ui<'_>, Range<usize>) -> R, ) -> R
A vertical list of count rows, each row_height tall, of which only
the visible ones are laid out. f gets the range of rows to draw and
must give each row exactly row_height.
ScrollArea::new().height(300.0).show_rows(ui, 28.0, names.len(), |ui, rows| {
for i in rows {
ui.label(&names[i]);
}
});Trait Implementations§
Auto Trait Implementations§
impl Forget for ScrollArea
impl Freeze for ScrollArea
impl Move for ScrollArea
impl RefUnwindSafe for ScrollArea
impl Send for ScrollArea
impl Sync for ScrollArea
impl Unpin for ScrollArea
impl UnsafeUnpin for ScrollArea
impl UnwindSafe for ScrollArea
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§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.Source§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.Source§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.Source§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.