Skip to content

DesignCraft: An open-source page and layout design editor written by scratch in pure Rust

Separations Preview keeps every visible sheet; a superseded job is no longer pending

aiongga138e1f0109c
diff --git a/ROADMAP.md b/ROADMAP.md
index 003f2b0ff..f9a944468 100644
--- a/ROADMAP.md
+++ b/ROADMAP.md
@@ -382,7 +382,6 @@ Newest first.
- **2026-10-20** · PDF/X-1a:2003 export (craft-libs#194): `file.exportPdf {standard: "x1a"}`, the Export PDF dialog's PDF/X-1a:2003 preset and standard. The PDF/X-4 print file is flattened in its inks by craft-prepress (no transparency; spot, process, overprint and live text kept; complex regions as DeviceN images at the Transparency Flattener preset's resolution), then written as PDF 1.4 with the X-1a identification and checked; `validate-pdf --standard x1a`. Soft drop shadows reach the flattener in their swatch's inks; other soft effects are still RGB images. No readiness percentage change.
- **2026-10-20** · Print color (craft-libs#190): CMYK print PDFs blend in DeviceCMYK through craft-pdf's print settings instead of byte rewrites, with the CMYK working space as the output intent in PDF/X-4 only; overprint (Overprint Fill, Stroke and Gap, overprinting text, 100% [Black]) is written as `/op` `/OP` `/OPM 1`; Knockout Group writes `/K true` instead of becoming an image; File › Print prints the PDF Export PDF writes. No readiness percentage change.
-- **2026-10-20** · Spot gradients print on their plates. A gradient stop keeps the swatch it was given (Gradient panel drop, `swatch.create {gradient}`, `object.gradient`, IDML `StopColor`), following its renames and edits. PDF export shades one spot with its tints or [Paper] as a Separation, and a spot with process inks or a second spot as DeviceN; a process gradient to [Paper] prints in DeviceCMYK. Documents with plain-colour stops export as before. No readiness percentage change.
- **2026-10-20** · Separations Preview shows the plates the exported PDF prints, spot plates included: each visible spread is exported in memory with the Export PDF settings and separated by craft-prepress off the UI thread, then shown as all inks, one plate or an ink limit. The Ink Manager builds craft-prepress's `InkSet` from the document for export and preview. On the sample magazine the first preview of a spread takes about 0.6–1.1 s, most of it the PDF export. No readiness percentage change.
- **2026-10-20** · Spot gradients print on their plates. A gradient stop keeps the swatch it was given (Gradient panel drop, `swatch.create {gradient}`, `object.gradient`, IDML `StopColor`), following its renames and edits. PDF export shades one spot with its tints or [Paper] as a Separation, and a spot with process inks or a second spot as DeviceN; a process gradient to [Paper] prints in DeviceCMYK. Documents with plain-color stops export as before. No readiness percentage change.
- **2026-10-24** · Panels dock through the suite's shared docking (craft-libs), and on desktop a floating panel opens in its own window that can leave the main window: keys pressed there run the main window's shortcuts, clipboard and tool keys, and the canvas paints no tool cursor while another of the app's windows has the pointer. The web build keeps floating panels in the page. No readiness percentage change.
diff --git a/crates/ui-egui/src/separations.rs b/crates/ui-egui/src/separations.rs
index 9e1bac580..1db68664b 100644
--- a/crates/ui-egui/src/separations.rs
+++ b/crates/ui-egui/src/separations.rs
@@ -27,8 +27,10 @@ pub struct Separations {
pub ink_limit: Option<f32>,
}
-/// Sheets kept at most (each holds one plane per ink).
+/// Sheets kept when few spreads are visible (each holds one plane per ink).
const MAX_SHEETS: usize = 6;
+/// Visible spreads separated at most: beyond this many the rest show without plates.
+const MAX_VISIBLE: usize = 4 * MAX_SHEETS;
/// The highest resolution the web build separates at (on the UI thread).
#[cfg(target_arch = "wasm32")]
const WEB_MAX_DPI: f32 = 72.0;
@@ -113,6 +115,9 @@ fn separate(job: Job) -> Done {
pub struct Preview {
entries: Vec<Entry>,
pending: Vec<Key>,
+ /// The spreads the canvas last drew: every one keeps its sheet, so a visible sheet is never
+ /// evicted only to be separated again next frame.
+ visible: usize,
#[cfg(not(target_arch = "wasm32"))]
worker: Option<Worker>,
#[cfg(not(target_arch = "wasm32"))]
@@ -134,12 +139,20 @@ impl Preview {
Some(e) => *e = Entry { key, sheet, texture: None, used: frame },
None => self.entries.push(Entry { key, sheet, texture: None, used: frame }),
}
- if self.entries.len() > MAX_SHEETS {
+ let limit = self.visible.clamp(MAX_SHEETS, MAX_VISIBLE);
+ if self.entries.len() > limit {
self.entries.sort_by_key(|e| std::cmp::Reverse(e.used));
- self.entries.truncate(MAX_SHEETS);
+ self.entries.truncate(limit);
}
}
+ /// Notes `key` as sent to the worker. The worker keeps only the newest waiting job of a
+ /// spread and drops the rest unanswered, so an older key of the spread is no longer pending.
+ fn queued(&mut self, key: Key) {
+ self.pending.retain(|k| k.spread != key.spread);
+ self.pending.push(key);
+ }
+
/// Collects finished separations.
fn poll(&mut self) {
#[cfg(not(target_arch = "wasm32"))]
@@ -169,11 +182,11 @@ impl Preview {
self.worker = Worker::spawn(ctx.clone());
}
if let Some(w) = &self.worker {
- self.pending.push(job.key.clone());
+ let key = job.key.clone();
if w.tx.send(job).is_ok() {
+ self.queued(key);
return;
}
- self.pending.pop();
self.worker = None;
return;
}
@@ -298,12 +311,19 @@ pub fn paint(app: &mut DesignApp, ctx: &egui::Context, painter: &egui::Painter,
app.canvas.separations.pointer = None;
let Some(st) = app.session.active() else { return };
let doc = st.doc.clone();
- for slot in &layout.slots {
- let SpreadRef::Doc(si) = slot.spread else { continue };
+ let visible: Vec<(usize, &designcraft_tools::SpreadSlot)> = layout
+ .slots
+ .iter()
+ .filter_map(|slot| {
+ let SpreadRef::Doc(si) = slot.spread else { return None };
+ let sp = doc.spreads.get(si)?;
+ xf.rect(slot.xf.transform_rect_bbox(sp.bounds())).intersects(screen).then_some((si, slot))
+ })
+ .take(MAX_VISIBLE)
+ .collect();
+ app.canvas.separations.visible = visible.len();
+ for (si, slot) in visible {
let Some(sp) = doc.spreads.get(si) else { continue };
- if !xf.rect(slot.xf.transform_rect_bbox(sp.bounds())).intersects(screen) {
- continue;
- }
if let Some(c) = hover {
let p = slot.xf.inverse() * c;
if sp.bounds().contains(p) {
@@ -354,6 +374,24 @@ mod tests {
use crate::menus::run_ui;
+ #[test]
+ fn every_visible_sheet_stays_and_a_superseded_job_is_not_pending() {
+ let key = |spread, dpi| super::Key { uid: 1, revision: 1, spread, dpi, print: Default::default(), cms: 0 };
+ let mut p = super::Preview { visible: 10, ..Default::default() };
+ for si in 0..10 {
+ p.insert(key(si, 72.0), Err("unseparated".into()));
+ }
+ assert_eq!(p.entries.len(), 10, "ten visible spreads keep ten sheets");
+ p.visible = 1;
+ p.insert(key(10, 72.0), Err("unseparated".into()));
+ assert_eq!(p.entries.len(), super::MAX_SHEETS);
+ // The worker drops a spread's older waiting job, so only the newest stays pending.
+ p.queued(key(3, 72.0));
+ p.queued(key(3, 288.0));
+ p.queued(key(4, 72.0));
+ assert_eq!(p.pending.iter().map(|k| (k.spread, k.dpi)).collect::<Vec<_>>(), [(3, 288.0), (4, 72.0)]);
+ }
+
#[test]
fn view_separations_lists_the_spot_plate_and_shows_it_alone() {
let mut app = crate::DesignApp::new(designcraft_engine::Session::new(), crate::Services::default());