Struct Stack
pub struct Stack<'a> { /* private fields */ }Expand description
The sections a stack is given, in order ([Sections::show]).
Implementations§
§impl<'a> Stack<'a>
impl<'a> Stack<'a>
pub fn section(
&mut self,
section: Section,
body: impl FnOnce(&mut Ui) + 'a,
) -> &mut Stack<'a>
pub fn section( &mut self, section: Section, body: impl FnOnce(&mut Ui) + 'a, ) -> &mut Stack<'a>
Adds a section, body its content (called only while it is open, in a scroll area of
its own).
pub fn rows(
&mut self,
section: Section,
count: usize,
draw: impl FnOnce(&mut Ui, Range<usize>) + 'a,
) -> &mut Stack<'a>
pub fn rows( &mut self, section: Section, count: usize, draw: impl FnOnce(&mut Ui, Range<usize>) + 'a, ) -> &mut Stack<'a>
Adds a section of count rows of one height (Section::row_height) in a scroll area
of its own, windowed: draw is called only while it is open, with the rows in view and
the one past them, on every pass, so the window follows the section’s size and scroll.
It draws them from the top of its ui, which has no spacing between items, each exactly
that tall (with [Ui::add_sized], say), or they drift from their place in the scroll.
Its least height is two rows, or all of them when it has fewer.
use egui_stack::sections::{Section, Sections, laid_out, row_height};
let ctx = egui::Context::default();
let mut out = ctx.run_ui(Default::default(), |ui| {
let height = row_height(ui);
Sections::new("log").show(ui, |stack| {
stack.rows(Section::new("lines", "Lines"), 100_000, move |ui, range| {
for i in range {
let width = ui.available_width();
ui.add_sized([width, height], egui::Label::new(format!("Line {i}")));
}
});
});
});
out.textures_delta.clear();
let window = laid_out(&ctx, "log")[0].window.clone().unwrap();
assert!(window.len() < 1_000, "{window:?}");pub fn bare(
&mut self,
section: Section,
body: impl FnOnce(&mut Ui) + 'a,
) -> &mut Stack<'a>
pub fn bare( &mut self, section: Section, body: impl FnOnce(&mut Ui) + 'a, ) -> &mut Stack<'a>
Adds a section whose body has no scroll area around it (called only while it is
open): for an application’s own view that scrolls itself, such as a virtualised list,
which would otherwise nest two scrolls. It fills the body, clipped to it.
The stack cannot see into that view, so the wheel over a bare body always stops there, whether or not the view has anywhere to go.
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for Stack<'a>
impl<'a> !RefUnwindSafe for Stack<'a>
impl<'a> !Send for Stack<'a>
impl<'a> !Sync for Stack<'a>
impl<'a> Unpin for Stack<'a>
impl<'a> UnsafeUnpin for Stack<'a>
impl<'a> !UnwindSafe for Stack<'a>
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> 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