Expand description
A preview dialog: an image viewport in a custom dialog (ADR 0013),
the first use of Dialog::Custom. An export or a crop shows its
effect before it runs: the viewport draws from a tile source of its
own, the interface behind stays as it is (a Clear backdrop) and
keeps drawing, its own viewport included, while the dialog is modal.
Experimental: may change in any release
(docs/stability.md).
The dialog keeps every dialog rule: the primary button says what it does (“Export”), Enter runs it, Escape cancels it, except during a drag of the viewport (Escape then cancels the drag: the viewport claims Escape). It is movable and comes back where it was left. The viewport draws sRGB first (decided 2026-10-14): two overlapping wide-gamut image surfaces have not been tried.
use egui_pop_api::AppHandle;
use egui_pop_imaging::preview::{self, Preview};
use egui_pop_model::ids::CommandId;
use egui_pop_viewport::demo::Procedural;
fn export(app: &AppHandle) {
let preview = Preview::new("Export preview", "Export", CommandId::from_static("doc.export"));
let opened = preview::open(app, preview, |sink| Box::new(Procedural::new(sink, [4096, 3072], 2)));
if let Err(why) = opened {
eprintln!("no preview: {why}");
}
}Structs§
- Preview
- A preview dialog, as declared.
- Preview
State - The preview’s viewport: its view, its state, its source.
Functions§
- open
- Opens a preview:
sourcemakes the tile source from the viewport’s sink. Returns the dialog’s id and the viewport’s state, shared with the dialog’s body; an error when the dialogs plugin is missing or the viewport does not fit a custom dialog.