Skip to main content

blockworx_egui/
lib.rs

1//! The egui backend: the only crate that knows both vocabularies.
2//!
3//! Everything a drawing is made *of* — the [`Renderer`](blockworx_paint::Renderer)
4//! and [`Canvas`](blockworx_paint::Canvas) traits, the palette, the theme and its
5//! [`Style`](blockworx_paint::theme::Style) adapter, the interaction types, the
6//! recorder that turns a frame into [`DrawOp`](blockworx_paint::DrawOp)s — lives
7//! in [`blockworx_paint`] over the coordinates in [`blockworx_geom`]. Here those
8//! become egui calls: [`replay()`] turns a display list into shapes, [`View`] is the widget it
9//! is drawn in and the reader of the pointer and the wheel over it,
10//! [`ContextLayout`] is the text engine a frame is recorded through, [`convert`]
11//! is the dictionary between the two type families, [`ImageRegistry`] and
12//! [`build_fonts`] feed egui's loaders, and [`EpaintLayout`] hands epaint's
13//! own text layout to a consumer that has no backend of its own.
14//!
15//! The dependency goes one way. This crate names the document (for an
16//! [`Asset`](blockworx_doc::block_model::Asset)), the geometry and the paint
17//! vocabulary, and nothing above them: a backend knows how to paint, not what a
18//! block is. The next backend is this crate rewritten, with everything below it
19//! untouched.
20
21pub mod convert;
22pub mod image;
23/// Real text metrics for the suites above this crate, which measure through
24/// the same layout engine the canvas draws with.
25///
26/// A frame that does not run *is* the assertion here, as it would be inside a
27/// `#[cfg(test)]` module.
28#[cfg(any(test, feature = "test-support"))]
29#[expect(clippy::expect_used, clippy::missing_panics_doc)]
30pub mod measure;
31pub mod replay;
32#[cfg(any(test, feature = "test-support"))]
33pub mod settle;
34pub mod text;
35pub mod view;
36
37mod font;
38
39pub use font::build_fonts;
40pub use image::ImageRegistry;
41pub use replay::replay;
42pub use text::{ContextLayout, EpaintLayout};
43pub use view::{Camera, Canvas, CanvasChrome, Diagram, View, tick};
44// Where the camera stands is paint's, since the undo stack — which is not the
45// backend's — restores one. Re-exported so `canvas::Vantage` still reads as the
46// canvas's own word for it.
47pub use blockworx_paint::Vantage;