Skip to main content

egui_pop_views/library/
mod.rs

1//! A photo library's widgets, for importing, culling and sorting
2//! images: the application owns its images, their marks and tags; the
3//! widgets show them and say what the user asked for.
4//!
5//! - [`grid`]: a virtualised thumbnail grid and the filmstrip (one row,
6//!   sharing the grid's selection), thumbnails supplied asynchronously,
7//!   overlays, stacks, the culling keys, a rubber band;
8//! - [`marks`]: ratings, colour labels and pick or reject flags, their
9//!   widgets, and the culling keymap (Lightroom's keys, auto-advance);
10//! - [`compare`]: one to many images, a loupe or side by side, zoom and
11//!   pan synced, a "best" marker, images dragged in and out;
12//! - `mode` (with the `api` feature): the library grid as a file
13//!   browser's view mode, [`LibraryGridMode`];
14//! - `thumbs` (with the `api` feature): the file browser's thumbnail
15//!   provider as a [`ThumbSource`], and a [`Badge`] as its chip;
16//! - [`tags`]: tag chips and a tag input with completion;
17//! - [`filter`]: a search field with filter chips, giving a structured
18//!   filter;
19//! - [`plugin`]: the steps (select, rate, label, flag, tag, stack,
20//!   filter), the commands agents run, and [`LibraryPlugin`].
21//!
22//! Guide: `docs/library.md`.
23
24pub mod compare;
25pub mod filter;
26pub mod grid;
27pub mod marks;
28#[cfg(feature = "api")]
29pub mod mode;
30mod paint;
31pub mod plugin;
32pub mod tags;
33#[cfg(feature = "api")]
34pub mod thumbs;
35
36#[cfg(feature = "api")]
37pub use grid::change;
38pub use grid::{
39    Badge, Change, GridResize, LibraryItems, LibraryOutput, LibraryState, Signal, Stack, Thumb,
40    ThumbGrid, ThumbSource, Tone, Zoom,
41};
42pub use marks::{ColorLabel, CullAction, CullKeymap, Flag, Labels, Marks};
43#[cfg(feature = "api")]
44pub use mode::{LibraryGridMode, LibrarySignals};
45pub use paint::{LabelStyle, LibraryTokens};
46#[cfg(feature = "api")]
47pub use plugin::LibraryPlugin;
48
49use egui::{Rect, vec2};
50
51/// The largest rectangle of aspect `w:h` inside `outer`, centred.
52pub fn fitted(outer: Rect, size: [u32; 2]) -> Rect {
53    if size[0] == 0 || size[1] == 0 {
54        return outer;
55    }
56    let a = size[0] as f32 / size[1] as f32;
57    let (w, h) = if outer.width() / outer.height() > a {
58        (outer.height() * a, outer.height())
59    } else {
60        (outer.width(), outer.width() / a)
61    };
62    Rect::from_center_size(outer.center(), vec2(w, h))
63}