pub struct ThumbnailGrid { /* private fields */ }Expand description
thumbnail_grid with its options: where it keeps its scrolling, how
high it gets, and a cell to bring into view, drawn or not.
use egui_pop_core::thumbnail::{Thumbnail, ThumbnailGrid};
fn ui(ui: &mut egui::Ui, cursor: usize) {
let columns = ThumbnailGrid::new(10_000, egui::vec2(96.0, 72.0))
.id_salt("photos")
.max_height(300.0)
.reveal(Some(cursor))
.show(ui, |ui, i| {
ui.add(Thumbnail::new(format!("Image {i}")).selected(i == cursor));
});
// Up and Down move the cursor by `columns`.
let _ = columns;
}Need (image): a grid of thumbnails.
Implementations§
Source§impl ThumbnailGrid
impl ThumbnailGrid
Sourcepub fn new(count: usize, cell: Vec2) -> ThumbnailGrid
pub fn new(count: usize, cell: Vec2) -> ThumbnailGrid
A grid of count cells of size cell.
Sourcepub fn rubber_band(self, on: bool) -> ThumbnailGrid
pub fn rubber_band(self, on: bool) -> ThumbnailGrid
A drag from the room around the cells draws a rubber band
(Finder’s, Explorer’s), which ThumbnailGrid::show_with_band
tells: the cells it touches, scrolled away or not.
Sourcepub fn id_salt(self, salt: impl AsIdSalt) -> ThumbnailGrid
pub fn id_salt(self, salt: impl AsIdSalt) -> ThumbnailGrid
What tells its scrolling from another grid’s in the same Ui.
Sourcepub fn max_height(self, height: f32) -> ThumbnailGrid
pub fn max_height(self, height: f32) -> ThumbnailGrid
The most it takes in height.
Sourcepub fn reveal(self, cell: Option<usize>) -> ThumbnailGrid
pub fn reveal(self, cell: Option<usize>) -> ThumbnailGrid
Scrolls by the least that shows this cell, which may not be drawn yet: for a keyboard moving through a long grid.
Sourcepub fn room(ui: &Ui) -> (f32, f32)
pub fn room(ui: &Ui) -> (f32, f32)
The room a grid drawn in ui lays its cells out in: its width
(the scroll bar aside) and the gap between cells. n cells of
(width + gap) / n - gap points fill a row.
Sourcepub fn show(self, ui: &mut Ui, item: impl FnMut(&mut Ui, usize)) -> usize
pub fn show(self, ui: &mut Ui, item: impl FnMut(&mut Ui, usize)) -> usize
Draws the rows in view, item drawing cell i. Gives the number of
cells in a row, what a move up or down skips.
Sourcepub fn show_with_band(
self,
ui: &mut Ui,
item: impl FnMut(&mut Ui, usize),
) -> GridOutput
pub fn show_with_band( self, ui: &mut Ui, item: impl FnMut(&mut Ui, usize), ) -> GridOutput
ThumbnailGrid::show, telling the rubber band too.
Trait Implementations§
Source§impl Clone for ThumbnailGrid
impl Clone for ThumbnailGrid
Source§fn clone(&self) -> ThumbnailGrid
fn clone(&self) -> ThumbnailGrid
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 ThumbnailGrid
impl RefUnwindSafe for ThumbnailGrid
impl Send for ThumbnailGrid
impl Sync for ThumbnailGrid
impl Unpin for ThumbnailGrid
impl UnsafeUnpin for ThumbnailGrid
impl UnwindSafe for ThumbnailGrid
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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