Skip to main content

Module thumbnail

Module thumbnail 

Source
Expand description

Thumbnails and a virtualised grid of them, from images the application supplies (a texture and its size), with a flat placeholder in the image’s average colour until the image is there: no spinner per thumbnail. In this layer so that both the image tools (egui_pop_viewport::thumbnail re-exports it) and the file picker of the application API can draw them.

Experimental: may change in any release (docs/stability.md).
use egui_pop_core::thumbnail::{Thumbnail, thumbnail_grid};

fn ui(ui: &mut egui::Ui, selected: &mut usize) {
    thumbnail_grid(ui, 10_000, egui::vec2(96.0, 72.0), |ui, i| {
        let r = ui.add(
            Thumbnail::new(format!("Image {i}"))
                .placeholder(egui::Color32::from_gray(90))
                .selected(i == *selected),
        );
        if r.clicked() {
            *selected = i;
        }
    });
}

Structs§

Band
A rubber band dragged across a grid (ThumbnailGrid::rubber_band).
GridOutput
What a ThumbnailGrid drawn with ThumbnailGrid::show_with_band tells.
Thumbnail
One thumbnail.
ThumbnailGrid
thumbnail_grid with its options: where it keeps its scrolling, how high it gets, and a cell to bring into view, drawn or not.

Enums§

GridResize
How a thumbnail grid’s zoom answers a resize: what the zoom (its slider, Ctrl and + or -, Ctrl and the wheel) means, and so what a wider grid shows.

Constants§

BAND_MIN
How far the pointer moves before a drag draws a rubber band: a click is not a band.

Functions§

caption_height
The room Thumbnail::caption takes under the image, in points.
cells_in
The cells of a grid per_row wide that rect touches, rect in the grid’s own coordinates (its first cell’s corner at the origin), each cell cell large, gap apart in a row and pitch from one row’s top to the next’s.
fitted
The largest rectangle of aspect w:h inside outer, centred.
thumbnail_grid
A virtualised grid: only the rows in view are built, so ten thousand thumbnails cost what a screenful does. item draws cell i.