Struct jumpy::prelude::egui::containers::scroll_area::ScrollArea
pub struct ScrollArea {
has_bar: [bool; 2],
auto_shrink: [bool; 2],
max_size: Vec2,
min_scrolled_size: Vec2,
scroll_bar_visibility: ScrollBarVisibility,
id_source: Option<Id>,
offset_x: Option<f32>,
offset_y: Option<f32>,
scrolling_enabled: bool,
drag_to_scroll: bool,
stick_to_end: [bool; 2],
}
Expand description
Add vertical and/or horizontal scrolling to a contained Ui
.
egui::ScrollArea::vertical().show(ui, |ui| {
// Add a lot of widgets here.
});
You can scroll to an element using Response::scroll_to_me
, Ui::scroll_to_cursor
and Ui::scroll_to_rect
.
Fields§
§has_bar: [bool; 2]
§auto_shrink: [bool; 2]
§max_size: Vec2
§min_scrolled_size: Vec2
§scroll_bar_visibility: ScrollBarVisibility
§id_source: Option<Id>
§offset_x: Option<f32>
§offset_y: Option<f32>
§scrolling_enabled: bool
§drag_to_scroll: bool
§stick_to_end: [bool; 2]
Implementations§
§impl ScrollArea
impl ScrollArea
pub fn horizontal() -> ScrollArea
pub fn horizontal() -> ScrollArea
Create a horizontal scroll area.
pub fn vertical() -> ScrollArea
pub fn vertical() -> ScrollArea
Create a vertical scroll area.
pub fn both() -> ScrollArea
pub fn both() -> ScrollArea
Create a bi-directional (horizontal and vertical) scroll area.
pub fn neither() -> ScrollArea
pub fn neither() -> ScrollArea
Create a scroll area where both direction of scrolling is disabled. It’s unclear why you would want to do this.
pub fn new(has_bar: [bool; 2]) -> ScrollArea
pub fn new(has_bar: [bool; 2]) -> ScrollArea
Create a scroll area where you decide which axis has scrolling enabled.
For instance, ScrollArea::new([true, false])
enables horizontal scrolling.
pub fn max_width(self, max_width: f32) -> ScrollArea
pub fn max_width(self, max_width: f32) -> ScrollArea
The maximum width of the outer frame of the scroll area.
Use f32::INFINITY
if you want the scroll area to expand to fit the surrounding Ui
(default).
See also Self::auto_shrink
.
pub fn max_height(self, max_height: f32) -> ScrollArea
pub fn max_height(self, max_height: f32) -> ScrollArea
The maximum height of the outer frame of the scroll area.
Use f32::INFINITY
if you want the scroll area to expand to fit the surrounding Ui
(default).
See also Self::auto_shrink
.
pub fn min_scrolled_width(self, min_scrolled_width: f32) -> ScrollArea
pub fn min_scrolled_width(self, min_scrolled_width: f32) -> ScrollArea
The minimum width of a horizontal scroll area which requires scroll bars.
The ScrollArea
will only become smaller than this if the content is smaller than this
(and so we don’t require scroll bars).
Default: 64.0
.
pub fn min_scrolled_height(self, min_scrolled_height: f32) -> ScrollArea
pub fn min_scrolled_height(self, min_scrolled_height: f32) -> ScrollArea
The minimum height of a vertical scroll area which requires scroll bars.
The ScrollArea
will only become smaller than this if the content is smaller than this
(and so we don’t require scroll bars).
Default: 64.0
.
pub fn scroll_bar_visibility(
self,
scroll_bar_visibility: ScrollBarVisibility,
) -> ScrollArea
pub fn scroll_bar_visibility( self, scroll_bar_visibility: ScrollBarVisibility, ) -> ScrollArea
Set the visibility of both horizontal and vertical scroll bars.
With ScrollBarVisibility::VisibleWhenNeeded
(default), the scroll bar will be visible only when needed.
pub fn id_source(self, id_source: impl Hash) -> ScrollArea
pub fn id_source(self, id_source: impl Hash) -> ScrollArea
A source for the unique Id
, e.g. .id_source("second_scroll_area")
or .id_source(loop_index)
.
pub fn scroll_offset(self, offset: Vec2) -> ScrollArea
pub fn scroll_offset(self, offset: Vec2) -> ScrollArea
Set the horizontal and vertical scroll offset position.
Positive offset means scrolling down/right.
See also: Self::vertical_scroll_offset
, Self::horizontal_scroll_offset
,
Ui::scroll_to_cursor
and
Response::scroll_to_me
pub fn vertical_scroll_offset(self, offset: f32) -> ScrollArea
pub fn vertical_scroll_offset(self, offset: f32) -> ScrollArea
Set the vertical scroll offset position.
Positive offset means scrolling down.
See also: Self::scroll_offset
, Ui::scroll_to_cursor
and
Response::scroll_to_me
pub fn horizontal_scroll_offset(self, offset: f32) -> ScrollArea
pub fn horizontal_scroll_offset(self, offset: f32) -> ScrollArea
Set the horizontal scroll offset position.
Positive offset means scrolling right.
See also: Self::scroll_offset
, Ui::scroll_to_cursor
and
Response::scroll_to_me
pub fn hscroll(self, hscroll: bool) -> ScrollArea
pub fn hscroll(self, hscroll: bool) -> ScrollArea
Turn on/off scrolling on the horizontal axis.
pub fn vscroll(self, vscroll: bool) -> ScrollArea
pub fn vscroll(self, vscroll: bool) -> ScrollArea
Turn on/off scrolling on the vertical axis.
pub fn scroll2(self, has_bar: [bool; 2]) -> ScrollArea
pub fn scroll2(self, has_bar: [bool; 2]) -> ScrollArea
Turn on/off scrolling on the horizontal/vertical axes.
pub fn enable_scrolling(self, enable: bool) -> ScrollArea
pub fn enable_scrolling(self, enable: bool) -> ScrollArea
Control the scrolling behavior.
- If
true
(default), the scroll area will respond to user scrolling. - If
false
, the scroll area will not respond to user scrolling.
This can be used, for example, to optionally freeze scrolling while the user
is typing text in a TextEdit
widget contained within the scroll area.
This controls both scrolling directions.
pub fn drag_to_scroll(self, drag_to_scroll: bool) -> ScrollArea
pub fn drag_to_scroll(self, drag_to_scroll: bool) -> ScrollArea
Can the user drag the scroll area to scroll?
This is useful for touch screens.
If true
, the ScrollArea
will sense drags.
Default: true
.
pub fn auto_shrink(self, auto_shrink: [bool; 2]) -> ScrollArea
pub fn auto_shrink(self, auto_shrink: [bool; 2]) -> ScrollArea
For each axis, should the containing area shrink if the content is small?
- If
true
, egui will add blank space outside the scroll area. - If
false
, egui will add blank space inside the scroll area.
Default: [true; 2]
.
pub fn stick_to_right(self, stick: bool) -> ScrollArea
pub fn stick_to_right(self, stick: bool) -> ScrollArea
The scroll handle will stick to the rightmost position even while the content size changes dynamically. This can be useful to simulate text scrollers coming in from right hand side. The scroll handle remains stuck until user manually changes position. Once “unstuck” it will remain focused on whatever content viewport the user left it on. If the scroll handle is dragged all the way to the right it will again become stuck and remain there until manually pulled from the end position.
pub fn stick_to_bottom(self, stick: bool) -> ScrollArea
pub fn stick_to_bottom(self, stick: bool) -> ScrollArea
The scroll handle will stick to the bottom position even while the content size changes dynamically. This can be useful to simulate terminal UIs or log/info scrollers. The scroll handle remains stuck until user manually changes position. Once “unstuck” it will remain focused on whatever content viewport the user left it on. If the scroll handle is dragged to the bottom it will again become stuck and remain there until manually pulled from the end position.
§impl ScrollArea
impl ScrollArea
pub fn show<R>(
self,
ui: &mut Ui,
add_contents: impl FnOnce(&mut Ui) -> R,
) -> ScrollAreaOutput<R>
pub fn show<R>( self, ui: &mut Ui, add_contents: impl FnOnce(&mut Ui) -> R, ) -> ScrollAreaOutput<R>
Show the ScrollArea
, and add the contents to the viewport.
If the inner area can be very long, consider using Self::show_rows
instead.
pub fn show_rows<R>(
self,
ui: &mut Ui,
row_height_sans_spacing: f32,
total_rows: usize,
add_contents: impl FnOnce(&mut Ui, Range<usize>) -> R,
) -> ScrollAreaOutput<R>
pub fn show_rows<R>( self, ui: &mut Ui, row_height_sans_spacing: f32, total_rows: usize, add_contents: impl FnOnce(&mut Ui, Range<usize>) -> R, ) -> ScrollAreaOutput<R>
Efficiently show only the visible part of a large number of rows.
let text_style = egui::TextStyle::Body;
let row_height = ui.text_style_height(&text_style);
// let row_height = ui.spacing().interact_size.y; // if you are adding buttons instead of labels.
let total_rows = 10_000;
egui::ScrollArea::vertical().show_rows(ui, row_height, total_rows, |ui, row_range| {
for row in row_range {
let text = format!("Row {}/{}", row + 1, total_rows);
ui.label(text);
}
});
pub fn show_viewport<R>(
self,
ui: &mut Ui,
add_contents: impl FnOnce(&mut Ui, Rect) -> R,
) -> ScrollAreaOutput<R>
pub fn show_viewport<R>( self, ui: &mut Ui, add_contents: impl FnOnce(&mut Ui, Rect) -> R, ) -> ScrollAreaOutput<R>
This can be used to only paint the visible part of the contents.
add_contents
is given the viewport rectangle, which is the relative view of the content.
So if the passed rect has min = zero, then show the top left content (the user has not scrolled).
Trait Implementations§
§impl Clone for ScrollArea
impl Clone for ScrollArea
§fn clone(&self) -> ScrollArea
fn clone(&self) -> ScrollArea
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreAuto Trait Implementations§
impl Freeze for ScrollArea
impl RefUnwindSafe for ScrollArea
impl Send for ScrollArea
impl Sync for ScrollArea
impl Unpin for ScrollArea
impl UnwindSafe for ScrollArea
Blanket Implementations§
§impl<T, U> AsBindGroupShaderType<U> for T
impl<T, U> AsBindGroupShaderType<U> for T
§fn as_bind_group_shader_type(&self, _images: &RenderAssets<Image>) -> U
fn as_bind_group_shader_type(&self, _images: &RenderAssets<Image>) -> U
T
[ShaderType
] for self
. When used in [AsBindGroup
]
derives, it is safe to assume that all images in self
exist.§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<T> Conv for T
impl<T> Conv for 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> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self
to use its Binary
implementation when Debug
-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self
to use its Display
implementation when
Debug
-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self
to use its LowerExp
implementation when
Debug
-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self
to use its LowerHex
implementation when
Debug
-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self
to use its Octal
implementation when Debug
-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self
to use its Pointer
implementation when
Debug
-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self
to use its UpperExp
implementation when
Debug
-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self
to use its UpperHex
implementation when
Debug
-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> 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 more§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self
, then passes self.as_ref()
into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self
, then passes self.as_mut()
into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self
, then passes self.deref()
into the pipe function.§impl<T> Pointable for T
impl<T> Pointable for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B>
of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B>
of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R>
view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R>
view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target
of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target
of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap()
only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut()
only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow()
only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref()
only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut()
only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref()
only in debug builds, and is erased in release
builds.