mirror of
https://github.com/storytold/designcraft.git
synced 2026-11-28 14:18:40 -08:00
Merge pull request #2795 from AlPaka1234/fix/2370-pdf-png-resolution
PDF export: keep live transparency in non-X-1a presets (#2370)
This commit is contained in:
10 files changed
+481
-35
No files matched your search
@@ -413,6 +413,7 @@ list) · [roadmap.md](docs/roadmap.md) (milestones, plan) · [parity-checklist.m
|
||||
- **2026-11-15** · Removed the obsolete gap saying pull requests have no test workflow: [CI](.github/workflows/ci.yml) runs the shared quality gate on every pull request and push to main (#1352). No readiness percentage change.
|
||||
- **2026-11-15** · Accepting tracked deletions or rejecting insertions follows body-text selections through the removed text, including resolving all changes, and preserves independent cell and footnote insertion points. No readiness percentage change.
|
||||
- **2026-11-15** · Format follow-ups to the craft-libs cutover (craft-libs#778; ported from #2734 by Dylan M. Taylor): IDML export keeps CDATA image contents and table spans such as `inf` reach the table edge; DOCX plain-text import leaves out deleted tracked changes and expands inline objects; an XLSX number cell that isn't a number shows as written; unmarked CMYK JPEGs keep the shared decoder's ink polarity; PPTX export writes exact opacity; PDF export repins craft-pdf and craft-prepress to craft-libs main. No readiness percentage change.
|
||||
- **2026-11-14** · PDF export presets other than PDF/X-1a:2003 keep transparency live instead of applying a 72 ppi Low Resolution flattener, and confirming or loading a named preset persists its flattener choice (`flattenChosen`) so the global flattener fallback does not override it on reopen or in Separations Preview (#2370). No readiness percentage change.
|
||||
- **2026-11-14** · `object.stroke` refuses a tint or gap tint outside 0 to 1, a weight outside 0 to 1000 pt, a miter limit outside 1 to 500, a gap overprint that isn't true or false, and an alignment, cap, join or arrowhead name it doesn't have, instead of clamping the numbers and skipping the names. The Stroke panel's Weight and Miter Limit fields keep their values in those ranges. No readiness percentage change.
|
||||
- **2026-11-14** · Photo books no longer freeze the canvas (#1411; based on #2051 by texjer). The image cache keeps only the mip level each image is drawn at, for every format and display quality: a TIFF, PNG, PSD or CMYK JPEG used to keep its full decode too (48 MB for a 12 MP photo), so after about a dozen photos each edit evicted and decoded them again on the render thread. The canvas no longer waits for decodes: an image not cached at its size shows a light box or another cached level and decodes on one of three background threads (within the same in-flight memory limit as the decodes ahead of a render), and finished decodes are drawn in batches, at most one canvas render every 250 ms. Zooming into an image decodes it at most twice. Thumbnails and exports still wait for every image. No readiness percentage change.
|
||||
- **2026-11-14** · IDML export keeps each endnote reference as its number in superscript text, as the endnote frame lists it, instead of dropping it; the endnotes are still written as plain text, without IDML's endnote elements (#2753). No readiness percentage change.
|
||||
|
||||
@@ -788,16 +788,16 @@ pub fn open_print(app: &mut DesignApp) {
|
||||
|
||||
/// File › Export PDF…: the "Export PDF" options dialog, seeded from the persisted settings
|
||||
/// (`UiState.pdf_export`). `pages` is per-job (not persisted); `flatten` falls back to the global
|
||||
/// flattener preset when the persisted value is empty. `title` starts empty: a title given to the
|
||||
/// flattener preset until the user has chosen a flattener in the dialog (`flatten_chosen`).
|
||||
/// `title` starts empty: a title given to the
|
||||
/// dialog is the PDF's title and names the file, and without one the file is named after the
|
||||
/// document and the PDF takes its title from File Info.
|
||||
pub fn open_pdf_export(app: &mut DesignApp) {
|
||||
let mut fields = serde_json::to_value(&app.ui.pdf_export).unwrap_or_else(|_| json!({}));
|
||||
if let Value::Object(m) = &mut fields {
|
||||
m.insert("pages".into(), json!("all"));
|
||||
if app.ui.pdf_export.flatten.is_empty() {
|
||||
m.insert("flatten".into(), json!(app.ui.flattener));
|
||||
}
|
||||
let flatten = app.ui.pdf_export.resolved_flatten(&app.ui.flattener);
|
||||
m.insert("flatten".into(), json!(flatten));
|
||||
}
|
||||
app.ui.dialog = Some(Dialog::new("pdfExport", fields));
|
||||
}
|
||||
@@ -980,9 +980,7 @@ fn pdf_export_params(d: &Dialog) -> Value {
|
||||
},
|
||||
});
|
||||
let flatten = d.s("flatten");
|
||||
if !flatten.is_empty() {
|
||||
params["flatten"] = json!(flatten);
|
||||
}
|
||||
params["flatten"] = if flatten.is_empty() { json!(false) } else { json!(flatten) };
|
||||
params
|
||||
}
|
||||
|
||||
@@ -998,16 +996,16 @@ pub(crate) fn pdf_preset_params(preset: &str) -> Value {
|
||||
pdf_export_params(&d)
|
||||
}
|
||||
|
||||
/// Apply a preset's dependent fields. Flatten is only touched by "Screen and Email" and
|
||||
/// "PDF/X-1a:2003" (High Resolution); "Custom" (and any unknown value) changes nothing.
|
||||
/// Apply a preset's dependent fields. Every preset keeps live transparency (`flatten = ""`)
|
||||
/// except `"PDF/X-1a:2003"` (High Resolution); `"Custom"` (and any unknown value) changes nothing.
|
||||
fn apply_pdf_preset(d: &mut Dialog, preset: &str) {
|
||||
let (standard, compress, crop, bleed, page_info, flatten) = match preset {
|
||||
"Desktop Printing" => ("none", false, false, false, false, None),
|
||||
"Commercial Printing" => ("none", true, true, true, false, None),
|
||||
"Screen and Email" => ("none", true, false, false, false, Some("low")),
|
||||
"PDF/X-1a:2003" => ("x1a", false, true, true, false, Some("high")),
|
||||
"PDF/X-4" => ("x4", false, true, true, false, None),
|
||||
"PDF/A-2b" => ("a2b", false, false, false, false, None),
|
||||
"Desktop Printing" => ("none", false, false, false, false, ""),
|
||||
"Commercial Printing" => ("none", true, true, true, false, ""),
|
||||
"Screen and Email" => ("none", true, false, false, false, ""),
|
||||
"PDF/X-1a:2003" => ("x1a", false, true, true, false, "high"),
|
||||
"PDF/X-4" => ("x4", false, true, true, false, ""),
|
||||
"PDF/A-2b" => ("a2b", false, false, false, false, ""),
|
||||
_ => return,
|
||||
};
|
||||
d.fields.insert("standard".into(), json!(standard));
|
||||
@@ -1015,9 +1013,7 @@ fn apply_pdf_preset(d: &mut Dialog, preset: &str) {
|
||||
d.fields.insert("marksCrop".into(), json!(crop));
|
||||
d.fields.insert("marksBleed".into(), json!(bleed));
|
||||
d.fields.insert("marksPageInfo".into(), json!(page_info));
|
||||
if let Some(f) = flatten {
|
||||
d.fields.insert("flatten".into(), json!(f));
|
||||
}
|
||||
d.fields.insert("flatten".into(), json!(flatten));
|
||||
}
|
||||
|
||||
/// File › Export PDF: the "Export PDF" options (General / Compression / Marks and Bleeds /
|
||||
@@ -5446,6 +5442,7 @@ fn confirm_part3(app: &mut DesignApp, d: Dialog) -> Result<Value, String> {
|
||||
app.ui.pdf_export.standard = d.s("standard");
|
||||
app.ui.pdf_export.compress_images = d.b("compressImages");
|
||||
app.ui.pdf_export.flatten = d.s("flatten");
|
||||
app.ui.pdf_export.flatten_chosen = true;
|
||||
app.ui.pdf_export.spreads = d.b("spreads");
|
||||
app.ui.pdf_export.bleed = d.b("bleed");
|
||||
app.ui.pdf_export.marks_crop = d.b("marksCrop");
|
||||
|
||||
@@ -3967,7 +3967,7 @@ fn pdf_export_override_keeps_override() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pdf_export_preset_high_quality_print_keeps_flatten() {
|
||||
fn pdf_export_preset_desktop_printing_clears_flatten() {
|
||||
let mut d = Dialog::new("pdfExport", json!({}));
|
||||
d.fields.insert("flatten".into(), json!("medium"));
|
||||
apply_pdf_preset(&mut d, "Desktop Printing");
|
||||
@@ -3976,11 +3976,11 @@ fn pdf_export_preset_high_quality_print_keeps_flatten() {
|
||||
assert!(!d.b("marksCrop"));
|
||||
assert!(!d.b("marksBleed"));
|
||||
assert!(!d.b("marksPageInfo"));
|
||||
assert_eq!(d.s("flatten"), "medium", "a leave-unchanged preset must not touch flatten");
|
||||
assert_eq!(d.s("flatten"), "", "non-X-1a presets keep transparency live");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pdf_export_preset_press_quality_keeps_flatten() {
|
||||
fn pdf_export_preset_commercial_printing_clears_flatten() {
|
||||
let mut d = Dialog::new("pdfExport", json!({}));
|
||||
d.fields.insert("flatten".into(), json!("high"));
|
||||
apply_pdf_preset(&mut d, "Commercial Printing");
|
||||
@@ -3989,19 +3989,20 @@ fn pdf_export_preset_press_quality_keeps_flatten() {
|
||||
assert!(d.b("marksCrop"));
|
||||
assert!(d.b("marksBleed"));
|
||||
assert!(!d.b("marksPageInfo"));
|
||||
assert_eq!(d.s("flatten"), "high");
|
||||
assert_eq!(d.s("flatten"), "");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pdf_export_preset_smallest_file_size_sets_flatten_low() {
|
||||
fn pdf_export_preset_screen_and_email_keeps_transparency_live() {
|
||||
let mut d = Dialog::new("pdfExport", json!({}));
|
||||
d.fields.insert("flatten".into(), json!("low"));
|
||||
apply_pdf_preset(&mut d, "Screen and Email");
|
||||
assert_eq!(d.s("standard"), "none");
|
||||
assert!(d.b("compressImages"));
|
||||
assert!(!d.b("marksCrop"));
|
||||
assert!(!d.b("marksBleed"));
|
||||
assert!(!d.b("marksPageInfo"));
|
||||
assert_eq!(d.s("flatten"), "low");
|
||||
assert_eq!(d.s("flatten"), "");
|
||||
}
|
||||
|
||||
/// The PDF/X-1a preset exports X-1a with the High Resolution flattener and printer's marks.
|
||||
@@ -4016,7 +4017,7 @@ fn pdf_export_preset_pdf_x1a_flattens_at_high_resolution() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pdf_export_preset_pdf_x4_keeps_flatten() {
|
||||
fn pdf_export_preset_pdf_x4_clears_flatten() {
|
||||
let mut d = Dialog::new("pdfExport", json!({}));
|
||||
d.fields.insert("flatten".into(), json!("medium"));
|
||||
apply_pdf_preset(&mut d, "PDF/X-4");
|
||||
@@ -4025,11 +4026,11 @@ fn pdf_export_preset_pdf_x4_keeps_flatten() {
|
||||
assert!(d.b("marksCrop"));
|
||||
assert!(d.b("marksBleed"));
|
||||
assert!(!d.b("marksPageInfo"));
|
||||
assert_eq!(d.s("flatten"), "medium");
|
||||
assert_eq!(d.s("flatten"), "");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pdf_export_preset_pdf_a2b_keeps_flatten() {
|
||||
fn pdf_export_preset_pdf_a2b_clears_flatten() {
|
||||
let mut d = Dialog::new("pdfExport", json!({}));
|
||||
d.fields.insert("flatten".into(), json!("low"));
|
||||
apply_pdf_preset(&mut d, "PDF/A-2b");
|
||||
@@ -4038,7 +4039,7 @@ fn pdf_export_preset_pdf_a2b_keeps_flatten() {
|
||||
assert!(!d.b("marksCrop"));
|
||||
assert!(!d.b("marksBleed"));
|
||||
assert!(!d.b("marksPageInfo"));
|
||||
assert_eq!(d.s("flatten"), "low");
|
||||
assert_eq!(d.s("flatten"), "");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -4065,6 +4066,27 @@ fn open_pdf_export_seeds_fields_from_settings() {
|
||||
open_pdf_export(&mut app);
|
||||
let d = app.ui.dialog.as_ref().unwrap();
|
||||
assert_eq!(d.s("flatten"), "low");
|
||||
|
||||
// An explicit No Flattening choice (flatten = "", flatten_chosen = true) keeps "" without falling back to the global flattener.
|
||||
app.ui.pdf_export.flatten = String::new();
|
||||
app.ui.pdf_export.flatten_chosen = true;
|
||||
app.ui.flattener = "medium".into();
|
||||
open_pdf_export(&mut app);
|
||||
let d = app.ui.dialog.as_ref().unwrap();
|
||||
assert_eq!(d.s("flatten"), "");
|
||||
|
||||
// Choosing a flattener via Edit › Transparency Flattener Presets updates app.ui.flattener,
|
||||
// switches pdf_export to follow it (marking preset Custom), and updates the menu checkmark.
|
||||
app.run("app.flattener", json!({"preset": "high"})).unwrap();
|
||||
assert_eq!(app.ui.flattener, "high");
|
||||
assert!(app.ui.pdf_export.uses_global_flatten());
|
||||
assert_eq!(app.ui.pdf_export.resolved_flatten(&app.ui.flattener), "high");
|
||||
assert_eq!(app.ui.pdf_export.preset, "Custom");
|
||||
assert_eq!(crate::menus::checked(&app, "app.flattener", &json!({"preset": "high"})), Some(true));
|
||||
assert_eq!(crate::menus::checked(&app, "app.flattener", &json!({"preset": ""})), Some(false));
|
||||
open_pdf_export(&mut app);
|
||||
let d = app.ui.dialog.as_ref().unwrap();
|
||||
assert_eq!(d.s("flatten"), "high");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -4118,6 +4140,277 @@ fn confirm_pdf_export_writes_file_and_persists_settings() {
|
||||
assert!(!app.ui.pdf_export.tagged);
|
||||
}
|
||||
|
||||
fn make_checker_png_b64(side: u32) -> String {
|
||||
let mut pixels = Vec::with_capacity((side * side * 4) as usize);
|
||||
for y in 0..side {
|
||||
for x in 0..side {
|
||||
let v = if ((x + y) / 4).is_multiple_of(2) { 20u8 } else { 235u8 };
|
||||
pixels.extend_from_slice(&[v, v, v, 255]);
|
||||
}
|
||||
}
|
||||
let png = designcraft_render::Rendered { width: side, height: side, pixels }.to_png();
|
||||
designcraft_engine::cmd::base64_encode(&png)
|
||||
}
|
||||
|
||||
fn select_pdf_preset(d: &mut Dialog, preset: &str) {
|
||||
d.fields.insert("preset".into(), json!(preset));
|
||||
apply_pdf_preset(d, preset);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pdf_export_presets_keep_full_png_resolution_with_effects_and_blending() {
|
||||
use std::sync::{Arc, Mutex};
|
||||
let b64_blend = make_checker_png_b64(400);
|
||||
let b64_feather = make_checker_png_b64(440);
|
||||
|
||||
let mut app = crate::DesignApp::new(designcraft_engine::Session::new(), crate::Services::default());
|
||||
app.run("file.new", json!({})).unwrap();
|
||||
let blended = app.run("file.place", json!({"base64": &b64_blend, "name": "blend.png", "x": 36, "y": 36, "width": 200})).unwrap()["id"].clone();
|
||||
app.run("object.effects", json!({"ids": [blended], "blend": "Multiply"})).unwrap();
|
||||
let feathered =
|
||||
app.run("file.place", json!({"base64": &b64_feather, "name": "grad.png", "x": 260, "y": 36, "width": 200})).unwrap()["id"].clone();
|
||||
app.run("object.gradientFeather", json!({"ids": [feathered], "from": [260, 136], "to": [460, 136]})).unwrap();
|
||||
|
||||
let writes: Arc<Mutex<Vec<Vec<u8>>>> = Arc::new(Mutex::new(Vec::new()));
|
||||
let sink = writes.clone();
|
||||
app.services.write = Some(Box::new(move |_path: &str, bytes: &[u8]| {
|
||||
sink.lock().unwrap().push(bytes.to_vec());
|
||||
Ok(())
|
||||
}));
|
||||
app.answer_dialogs(crate::app::file_dialogs::testing::answer_with(Some("/tmp/preset-resolution-test.pdf".into())));
|
||||
|
||||
// 1. "Screen and Email" must keep transparency live instead of flattening effects/blends to 72 ppi.
|
||||
open_pdf_export(&mut app);
|
||||
{
|
||||
let d = app.ui.dialog.as_mut().unwrap();
|
||||
select_pdf_preset(d, "Screen and Email");
|
||||
assert_eq!(d.s("flatten"), "");
|
||||
}
|
||||
confirm(&mut app).unwrap();
|
||||
app.settle_dialogs();
|
||||
assert_eq!(app.ui.pdf_export.preset, "Screen and Email");
|
||||
assert_eq!(app.ui.pdf_export.flatten, "");
|
||||
assert!(app.ui.pdf_export.flatten_chosen);
|
||||
assert_eq!(crate::menus::checked(&app, "app.flattener", &json!({"preset": ""})), Some(true));
|
||||
|
||||
// 2. Switching away from a prior "low" choice (via Edit › Transparency Flattener Presets) must not re-flatten at 72 ppi.
|
||||
app.run("app.flattener", json!({"preset": "low"})).unwrap();
|
||||
assert_eq!(app.ui.pdf_export.preset, "Custom");
|
||||
assert_eq!(crate::menus::checked(&app, "app.flattener", &json!({"preset": "low"})), Some(true));
|
||||
open_pdf_export(&mut app);
|
||||
{
|
||||
let d = app.ui.dialog.as_mut().unwrap();
|
||||
assert_eq!(d.s("flatten"), "low");
|
||||
select_pdf_preset(d, "Desktop Printing");
|
||||
assert_eq!(d.s("flatten"), "");
|
||||
}
|
||||
confirm(&mut app).unwrap();
|
||||
app.settle_dialogs();
|
||||
assert_eq!(app.ui.pdf_export.preset, "Desktop Printing");
|
||||
assert_eq!(app.ui.pdf_export.flatten, "");
|
||||
assert!(app.ui.pdf_export.flatten_chosen);
|
||||
assert_eq!(crate::menus::checked(&app, "app.flattener", &json!({"preset": ""})), Some(true));
|
||||
assert_eq!(crate::menus::checked(&app, "app.flattener", &json!({"preset": "low"})), Some(false));
|
||||
|
||||
// 3. Reopening the dialog without re-selecting the preset must keep flatten = "" (not fall back to "low").
|
||||
open_pdf_export(&mut app);
|
||||
{
|
||||
let d = app.ui.dialog.as_ref().unwrap();
|
||||
assert_eq!(d.s("flatten"), "");
|
||||
}
|
||||
confirm(&mut app).unwrap();
|
||||
app.settle_dialogs();
|
||||
assert_eq!(app.ui.pdf_export.preset, "Desktop Printing");
|
||||
assert_eq!(app.ui.pdf_export.flatten, "");
|
||||
assert!(app.ui.pdf_export.flatten_chosen);
|
||||
|
||||
let pdfs = writes.lock().unwrap();
|
||||
assert_eq!(pdfs.len(), 3);
|
||||
for (i, pdf) in pdfs.iter().enumerate() {
|
||||
let text = String::from_utf8_lossy(pdf);
|
||||
assert!(text.contains("/Width 400"), "export #{i} should keep 400px blended PNG unflattened");
|
||||
assert!(text.contains("/Width 440"), "export #{i} should keep 440px feathered PNG unflattened");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pdf_export_interactive_keeps_transparency_after_print_export() {
|
||||
use std::sync::{Arc, Mutex};
|
||||
let b64_blend = make_checker_png_b64(400);
|
||||
|
||||
let mut app = crate::DesignApp::new(designcraft_engine::Session::new(), crate::Services::default());
|
||||
app.run("file.new", json!({})).unwrap();
|
||||
let blended = app.run("file.place", json!({"base64": &b64_blend, "name": "blend.png", "x": 36, "y": 36, "width": 200})).unwrap()["id"].clone();
|
||||
app.run("object.effects", json!({"ids": [blended], "blend": "Multiply"})).unwrap();
|
||||
|
||||
let writes: Arc<Mutex<Vec<Vec<u8>>>> = Arc::new(Mutex::new(Vec::new()));
|
||||
let sink = writes.clone();
|
||||
app.services.write = Some(Box::new(move |_path: &str, bytes: &[u8]| {
|
||||
sink.lock().unwrap().push(bytes.to_vec());
|
||||
Ok(())
|
||||
}));
|
||||
app.answer_dialogs(crate::app::file_dialogs::testing::answer_with(Some("/tmp/interactive-transparency-test.pdf".into())));
|
||||
|
||||
// 1. Confirm Print PDF with PDF/X-1a:2003 -> flattens print export without mutating app.ui.flattener.
|
||||
open_pdf_export(&mut app);
|
||||
{
|
||||
let d = app.ui.dialog.as_mut().unwrap();
|
||||
select_pdf_preset(d, "PDF/X-1a:2003");
|
||||
assert_eq!(d.s("flatten"), "high");
|
||||
}
|
||||
confirm(&mut app).unwrap();
|
||||
app.settle_dialogs();
|
||||
assert_eq!(app.ui.pdf_export.preset, "PDF/X-1a:2003");
|
||||
assert_eq!(app.ui.flattener, "");
|
||||
assert_eq!(crate::menus::checked(&app, "app.flattener", &json!({"preset": "high"})), Some(true));
|
||||
|
||||
// 2. Interactive PDF export must keep live transparency instead of inheriting "high".
|
||||
app.run("app.exportInteractivePdf", json!({})).unwrap();
|
||||
app.settle_dialogs();
|
||||
assert_eq!(crate::menus::checked(&app, "app.flattener", &json!({"preset": "high"})), Some(true));
|
||||
|
||||
// 3. Confirm Print PDF with Custom + Low (non-X-1a) -> flattens print export without mutating app.ui.flattener.
|
||||
open_pdf_export(&mut app);
|
||||
{
|
||||
let d = app.ui.dialog.as_mut().unwrap();
|
||||
select_pdf_preset(d, "Custom");
|
||||
d.fields.insert("standard".into(), json!("none"));
|
||||
d.fields.insert("flatten".into(), json!("low"));
|
||||
}
|
||||
confirm(&mut app).unwrap();
|
||||
app.settle_dialogs();
|
||||
assert_eq!(app.ui.flattener, "");
|
||||
assert_eq!(app.ui.pdf_export.standard, "none");
|
||||
assert_eq!(app.ui.pdf_export.preset, "Custom");
|
||||
assert_eq!(crate::menus::checked(&app, "app.flattener", &json!({"preset": "low"})), Some(true));
|
||||
|
||||
// 4. Subsequent Interactive PDF export must still keep live transparency instead of inheriting "low".
|
||||
app.run("app.exportInteractivePdf", json!({})).unwrap();
|
||||
app.settle_dialogs();
|
||||
|
||||
// 5. Explicit global flattener via Edit › Transparency Flattener Presets must also not flatten Interactive PDF.
|
||||
app.run("app.flattener", json!({"preset": "low"})).unwrap();
|
||||
app.run("app.exportInteractivePdf", json!({})).unwrap();
|
||||
app.settle_dialogs();
|
||||
assert_eq!(app.ui.flattener, "low", "interactive export should not clobber the global flattener");
|
||||
|
||||
// 6. Explicit flattener override passed directly by a caller still works.
|
||||
app.run("app.exportInteractivePdf", json!({"path": "/tmp/interactive-explicit-low.pdf", "flatten": "low"})).unwrap();
|
||||
|
||||
let pdfs = writes.lock().unwrap();
|
||||
assert_eq!(pdfs.len(), 6);
|
||||
let as_text: Vec<_> = pdfs.iter().map(|b| String::from_utf8_lossy(b)).collect();
|
||||
assert!(!as_text[0].contains("/Width 400"), "PDF/X-1a print export should flatten blended image");
|
||||
assert!(as_text[1].contains("/Width 400"), "Interactive PDF after PDF/X-1a must keep 400px blended PNG unflattened");
|
||||
assert!(!as_text[2].contains("/Width 400"), "Custom+Low print export should flatten blended image");
|
||||
assert!(as_text[3].contains("/Width 400"), "Interactive PDF after Custom+Low must keep 400px blended PNG unflattened");
|
||||
assert!(as_text[4].contains("/Width 400"), "Interactive PDF after app.flattener low must keep 400px blended PNG unflattened");
|
||||
assert!(!as_text[5].contains("/Width 400"), "Explicit flatten override on Interactive PDF should still flatten");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pdf_export_scripted_does_not_inherit_dialog_flattener() {
|
||||
use std::sync::{Arc, Mutex};
|
||||
let b64_blend = make_checker_png_b64(400);
|
||||
|
||||
let mut app = crate::DesignApp::new(designcraft_engine::Session::new(), crate::Services::default());
|
||||
app.run("file.new", json!({})).unwrap();
|
||||
let blended = app.run("file.place", json!({"base64": &b64_blend, "name": "blend.png", "x": 36, "y": 36, "width": 200})).unwrap()["id"].clone();
|
||||
app.run("object.effects", json!({"ids": [blended], "blend": "Multiply"})).unwrap();
|
||||
|
||||
let writes: Arc<Mutex<Vec<Vec<u8>>>> = Arc::new(Mutex::new(Vec::new()));
|
||||
let sink = writes.clone();
|
||||
app.services.write = Some(Box::new(move |_path: &str, bytes: &[u8]| {
|
||||
sink.lock().unwrap().push(bytes.to_vec());
|
||||
Ok(())
|
||||
}));
|
||||
app.answer_dialogs(crate::app::file_dialogs::testing::answer_with(Some("/tmp/scripted-transparency-test.pdf".into())));
|
||||
|
||||
// 1. Scripted app.exportPdf keeps live transparency by default.
|
||||
app.run("app.exportPdf", json!({"path": "/tmp/a.pdf"})).unwrap();
|
||||
|
||||
// 2. Confirming File › Export PDF with PDF/X-1a:2003 flattens that export, not subsequent scripted exports.
|
||||
open_pdf_export(&mut app);
|
||||
select_pdf_preset(app.ui.dialog.as_mut().unwrap(), "PDF/X-1a:2003");
|
||||
confirm(&mut app).unwrap();
|
||||
app.settle_dialogs();
|
||||
assert_eq!(app.ui.flattener, "");
|
||||
assert_eq!(crate::menus::checked(&app, "app.flattener", &json!({"preset": "high"})), Some(true));
|
||||
|
||||
app.run("app.exportPdf", json!({"path": "/tmp/b.pdf"})).unwrap();
|
||||
|
||||
// 3. Confirming File › Export PDF with Custom + Low flattens that export, not subsequent scripted exports.
|
||||
open_pdf_export(&mut app);
|
||||
{
|
||||
let d = app.ui.dialog.as_mut().unwrap();
|
||||
select_pdf_preset(d, "Custom");
|
||||
d.fields.insert("standard".into(), json!("none"));
|
||||
d.fields.insert("flatten".into(), json!("low"));
|
||||
}
|
||||
confirm(&mut app).unwrap();
|
||||
app.settle_dialogs();
|
||||
assert_eq!(app.ui.flattener, "");
|
||||
assert_eq!(crate::menus::checked(&app, "app.flattener", &json!({"preset": "low"})), Some(true));
|
||||
|
||||
app.run("app.exportPdf", json!({"path": "/tmp/c.pdf"})).unwrap();
|
||||
|
||||
// 4. Choosing Edit › Transparency Flattener Presets explicitly applies to scripted app.exportPdf.
|
||||
app.run("app.flattener", json!({"preset": "low"})).unwrap();
|
||||
app.run("app.exportPdf", json!({"path": "/tmp/d.pdf"})).unwrap();
|
||||
|
||||
// 5. Confirming Desktop Printing in the dialog clears flattening for menu, dialog, and scripted export.
|
||||
open_pdf_export(&mut app);
|
||||
select_pdf_preset(app.ui.dialog.as_mut().unwrap(), "Desktop Printing");
|
||||
confirm(&mut app).unwrap();
|
||||
app.settle_dialogs();
|
||||
assert_eq!(crate::menus::checked(&app, "app.flattener", &json!({"preset": ""})), Some(true));
|
||||
app.run("app.exportPdf", json!({"path": "/tmp/e.pdf"})).unwrap();
|
||||
|
||||
// 6. Explicit flatten parameter on scripted app.exportPdf still flattens.
|
||||
app.run("app.exportPdf", json!({"path": "/tmp/f.pdf", "flatten": "low"})).unwrap();
|
||||
|
||||
// 7. PDF/X-1a:2003 + explicit app.flattener "high" keeps flattening scripted exports across a
|
||||
// preferences save/reload, whereas dialog-only PDF/X-1a:2003 keeps scripted exports live.
|
||||
open_pdf_export(&mut app);
|
||||
select_pdf_preset(app.ui.dialog.as_mut().unwrap(), "PDF/X-1a:2003");
|
||||
confirm(&mut app).unwrap();
|
||||
app.settle_dialogs();
|
||||
let dialog_only_bytes = serde_json::to_vec(&app.ui).unwrap();
|
||||
|
||||
app.run("app.flattener", json!({"preset": "high"})).unwrap();
|
||||
assert_eq!(app.ui.pdf_export.preset, "PDF/X-1a:2003");
|
||||
assert!(app.ui.pdf_export.uses_global_flatten());
|
||||
let global_high_bytes = serde_json::to_vec(&app.ui).unwrap();
|
||||
|
||||
app.ui = crate::UiState::read_preferences(&global_high_bytes).unwrap().ui;
|
||||
assert_eq!(app.ui.pdf_export.preset, "PDF/X-1a:2003");
|
||||
assert!(app.ui.pdf_export.uses_global_flatten());
|
||||
assert_eq!(crate::menus::checked(&app, "app.flattener", &json!({"preset": "high"})), Some(true));
|
||||
app.run("app.exportPdf", json!({"path": "/tmp/g.pdf"})).unwrap();
|
||||
|
||||
app.ui = crate::UiState::read_preferences(&dialog_only_bytes).unwrap().ui;
|
||||
assert_eq!(app.ui.pdf_export.preset, "PDF/X-1a:2003");
|
||||
assert!(!app.ui.pdf_export.uses_global_flatten());
|
||||
assert_eq!(crate::menus::checked(&app, "app.flattener", &json!({"preset": "high"})), Some(true));
|
||||
app.run("app.exportPdf", json!({"path": "/tmp/h.pdf"})).unwrap();
|
||||
|
||||
let pdfs = writes.lock().unwrap();
|
||||
assert_eq!(pdfs.len(), 12);
|
||||
let as_text: Vec<_> = pdfs.iter().map(|b| String::from_utf8_lossy(b)).collect();
|
||||
assert!(as_text[0].contains("/Width 400"), "initial scripted export keeps 400px PNG unflattened");
|
||||
assert!(!as_text[1].contains("/Width 400"), "PDF/X-1a dialog export flattens");
|
||||
assert!(as_text[2].contains("/Width 400"), "scripted export after PDF/X-1a keeps 400px PNG unflattened");
|
||||
assert!(!as_text[3].contains("/Width 400"), "Custom+Low dialog export flattens");
|
||||
assert!(as_text[4].contains("/Width 400"), "scripted export after Custom+Low keeps 400px PNG unflattened");
|
||||
assert!(!as_text[5].contains("/Width 400"), "scripted export after explicit app.flattener low flattens");
|
||||
assert!(as_text[6].contains("/Width 400"), "Desktop Printing dialog export keeps 400px PNG unflattened");
|
||||
assert!(as_text[7].contains("/Width 400"), "scripted export after Desktop Printing keeps 400px PNG unflattened");
|
||||
assert!(!as_text[8].contains("/Width 400"), "scripted export with explicit flatten=low flattens");
|
||||
assert!(!as_text[9].contains("/Width 400"), "PDF/X-1a dialog export before reload flattens");
|
||||
assert!(!as_text[10].contains("/Width 400"), "reloaded PDF/X-1a + explicit global high keeps flattening scripted export");
|
||||
assert!(as_text[11].contains("/Width 400"), "reloaded dialog-only PDF/X-1a keeps scripted export unflattened");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn update_link_asks_before_replacing_edits_made_in_the_layout() {
|
||||
let dir = std::env::temp_dir().join(format!("dc-update-link-dialog-{}", std::process::id()));
|
||||
|
||||
@@ -198,7 +198,7 @@ pub(crate) fn export_pdf(app: &mut DesignApp, p: &Value) -> Result<Value, String
|
||||
o.remove("path");
|
||||
o.entry("bleed").or_insert(json!(true));
|
||||
o.entry("tagged").or_insert(json!(true));
|
||||
if !app.ui.flattener.is_empty() {
|
||||
if app.ui.pdf_export.uses_global_flatten() && !app.ui.flattener.is_empty() {
|
||||
o.entry("flatten").or_insert(json!(app.ui.flattener));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -328,8 +328,17 @@ fn run_ui_part1(app: &mut DesignApp, id: &str, p: &Value) -> Option<Result<Value
|
||||
}
|
||||
"app.exportInteractivePdf" => {
|
||||
let mut q = if p.is_object() { p.clone() } else { json!({}) };
|
||||
for (k, v) in [("pageLayout", json!("single")), ("view", json!("fitPage")), ("bookmarksPanel", json!(true)), ("media", json!(true))] {
|
||||
q.as_object_mut().map(|o| o.entry(k).or_insert(v));
|
||||
// Interactive PDF keeps transparency live unless a caller explicitly requests flattening.
|
||||
if let Some(o) = q.as_object_mut() {
|
||||
for (k, v) in [
|
||||
("pageLayout", json!("single")),
|
||||
("view", json!("fitPage")),
|
||||
("bookmarksPanel", json!(true)),
|
||||
("media", json!(true)),
|
||||
("flatten", json!(false)),
|
||||
] {
|
||||
o.entry(k).or_insert(v);
|
||||
}
|
||||
}
|
||||
export_pdf(app, &q)
|
||||
}
|
||||
@@ -419,7 +428,12 @@ fn run_ui_part1(app: &mut DesignApp, id: &str, p: &Value) -> Option<Result<Value
|
||||
if !["", "high", "medium", "low"].contains(&v) {
|
||||
return Some(Err(format!("unknown preset `{v}`")));
|
||||
}
|
||||
if app.ui.pdf_export.resolved_flatten(&app.ui.flattener) != v {
|
||||
app.ui.pdf_export.preset = "Custom".into();
|
||||
}
|
||||
app.ui.flattener = v.to_string();
|
||||
app.ui.pdf_export.flatten.clear();
|
||||
app.ui.pdf_export.flatten_chosen = false;
|
||||
Ok(json!(v))
|
||||
}
|
||||
"app.graphicCell" => match p.get("path").and_then(Value::as_str) {
|
||||
|
||||
@@ -156,7 +156,7 @@ pub fn checked(app: &DesignApp, id: &str, params: &Value) -> Option<bool> {
|
||||
},
|
||||
"edit.dynamicSpelling" => app.ui.dynamic_spelling,
|
||||
"app.language" => app.ui.language == params.get("lang").and_then(Value::as_str).unwrap_or(""),
|
||||
"app.flattener" => app.ui.flattener == params.get("preset").and_then(Value::as_str).unwrap_or(""),
|
||||
"app.flattener" => app.ui.pdf_export.resolved_flatten(&app.ui.flattener) == params.get("preset").and_then(Value::as_str).unwrap_or(""),
|
||||
"window.taskBar" => app.ui.task_bar,
|
||||
"window.taskBarPin" => app.ui.task_bar_pin.is_some(),
|
||||
"window.toolsDoubleColumn" => app.ui.tools_double_column,
|
||||
|
||||
@@ -36,6 +36,7 @@ impl UiState {
|
||||
let mut ui: UiState = serde_json::from_value(saved)?;
|
||||
ui.story_editor_style_width = crate::story_editor::style_column_width(ui.story_editor_style_width);
|
||||
clear_stale_open_panels(&mut ui);
|
||||
migrate_pdf_export(&mut ui.pdf_export, &ui.flattener);
|
||||
intact &= migrate(&mut ui.docking, &mut ui.floating, &ui.docking_hidden, ui.dock_expanded, ui.icon_groups.as_deref());
|
||||
for workspace in &mut ui.custom_workspaces {
|
||||
let SavedWorkspace { docking, floating, docking_hidden, dock_expanded, icon_groups, .. } = workspace;
|
||||
@@ -127,6 +128,25 @@ fn clear_stale_open_panels(ui: &mut UiState) {
|
||||
}
|
||||
}
|
||||
|
||||
/// Earlier versions seeded `"Screen and Email"` with `"low"` and left `flatten` untouched when
|
||||
/// switching to `"Desktop Printing"`, `"Commercial Printing"`, `"PDF/X-4"`, or `"PDF/A-2b"`, so
|
||||
/// a flattener active at the time was saved alongside those preset names. Align saved named
|
||||
/// presets with their preset flattener on load and mark it chosen while leaving `"Custom"`
|
||||
/// untouched (and keeping an explicit matching non-empty global flattener, such as `"high"` with
|
||||
/// `"PDF/X-1a:2003"`, active for scripted `app.exportPdf`).
|
||||
fn migrate_pdf_export(pdf: &mut crate::PdfExportSettings, global_flattener: &str) {
|
||||
let flatten = match pdf.preset.as_str() {
|
||||
"Desktop Printing" | "Commercial Printing" | "Screen and Email" | "PDF/X-4" | "PDF/A-2b" => "",
|
||||
"PDF/X-1a:2003" => "high",
|
||||
_ => return,
|
||||
};
|
||||
if pdf.uses_global_flatten() && !global_flattener.is_empty() && global_flattener == flatten {
|
||||
return;
|
||||
}
|
||||
pdf.flatten = flatten.into();
|
||||
pdf.flatten_chosen = true;
|
||||
}
|
||||
|
||||
/// Drop docking data this version cannot read. True when nothing was dropped.
|
||||
fn recover_docking(saved: &mut Value) -> bool {
|
||||
let Some(fields) = saved.as_object_mut() else { return true };
|
||||
|
||||
@@ -18,9 +18,10 @@ fn populated() -> UiState {
|
||||
|
||||
#[test]
|
||||
fn saved_preferences_preserve_valid_layouts_and_hidden_origins() {
|
||||
let original = serde_json::to_value(populated()).unwrap();
|
||||
let mut original = serde_json::to_value(populated()).unwrap();
|
||||
let loaded = UiState::from_preferences_json(&serde_json::to_vec(&original).unwrap()).unwrap();
|
||||
assert_eq!(serde_json::to_value(loaded).unwrap(), original);
|
||||
original["pdfExport"]["flattenChosen"] = json!(true);
|
||||
assert_eq!(serde_json::to_value(&loaded).unwrap(), original);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -321,3 +322,80 @@ fn hidden_panels_is_not_persisted_across_restarts() {
|
||||
let saved = serde_json::to_value(&ui).unwrap();
|
||||
assert!(saved.get("hiddenPanels").is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn read_preferences_migrates_named_pdf_preset_flatten_and_keeps_custom() {
|
||||
for preset in ["Desktop Printing", "Commercial Printing", "Screen and Email", "PDF/X-4", "PDF/A-2b"] {
|
||||
for saved_flatten in ["high", ""] {
|
||||
let saved = json!({
|
||||
"flattener": "low",
|
||||
"pdfExport": { "preset": preset, "flatten": saved_flatten }
|
||||
});
|
||||
let ui = UiState::read_preferences(&serde_json::to_vec(&saved).unwrap()).unwrap().ui;
|
||||
assert_eq!(ui.pdf_export.flatten, "", "{preset} ({saved_flatten:?}) should use live transparency");
|
||||
assert!(ui.pdf_export.flatten_chosen, "{preset} ({saved_flatten:?}) should mark flatten as chosen");
|
||||
assert_eq!(ui.pdf_export.resolved_flatten(&ui.flattener), "");
|
||||
}
|
||||
}
|
||||
|
||||
let saved_default = json!({ "flattener": "low" });
|
||||
let ui_default = UiState::read_preferences(&serde_json::to_vec(&saved_default).unwrap()).unwrap().ui;
|
||||
assert_eq!(ui_default.pdf_export.flatten, "");
|
||||
assert!(ui_default.pdf_export.flatten_chosen);
|
||||
assert_eq!(ui_default.pdf_export.resolved_flatten(&ui_default.flattener), "");
|
||||
|
||||
for saved_flatten in ["", "high"] {
|
||||
let saved_x1a = json!({
|
||||
"pdfExport": { "preset": "PDF/X-1a:2003", "flatten": saved_flatten }
|
||||
});
|
||||
let ui_x1a = UiState::read_preferences(&serde_json::to_vec(&saved_x1a).unwrap()).unwrap().ui;
|
||||
assert_eq!(ui_x1a.pdf_export.flatten, "high");
|
||||
assert!(ui_x1a.pdf_export.flatten_chosen);
|
||||
}
|
||||
|
||||
let saved_x1a_global_high = json!({
|
||||
"flattener": "high",
|
||||
"pdfExport": { "preset": "PDF/X-1a:2003", "flatten": "", "flattenChosen": false }
|
||||
});
|
||||
let ui_x1a_global = UiState::read_preferences(&serde_json::to_vec(&saved_x1a_global_high).unwrap()).unwrap().ui;
|
||||
assert!(ui_x1a_global.pdf_export.uses_global_flatten());
|
||||
assert_eq!(ui_x1a_global.pdf_export.resolved_flatten(&ui_x1a_global.flattener), "high");
|
||||
|
||||
let saved_custom = json!({
|
||||
"flattener": "low",
|
||||
"pdfExport": { "preset": "Custom", "flatten": "" }
|
||||
});
|
||||
let ui_custom_global = UiState::read_preferences(&serde_json::to_vec(&saved_custom).unwrap()).unwrap().ui;
|
||||
assert_eq!(ui_custom_global.pdf_export.flatten, "");
|
||||
assert!(!ui_custom_global.pdf_export.flatten_chosen);
|
||||
assert_eq!(ui_custom_global.pdf_export.resolved_flatten(&ui_custom_global.flattener), "low");
|
||||
|
||||
let saved_custom_medium = json!({
|
||||
"pdfExport": { "preset": "Custom", "flatten": "medium" }
|
||||
});
|
||||
let ui_custom = UiState::read_preferences(&serde_json::to_vec(&saved_custom_medium).unwrap()).unwrap().ui;
|
||||
assert_eq!(ui_custom.pdf_export.flatten, "medium");
|
||||
assert!(!ui_custom.pdf_export.flatten_chosen);
|
||||
|
||||
// Loading preferences syncs the Edit › Transparency Flattener Presets menu checkmark immediately.
|
||||
let mut app = DesignApp::new(designcraft_engine::Session::new(), Default::default());
|
||||
let old_desktop = json!({
|
||||
"flattener": "low",
|
||||
"pdfExport": { "preset": "Desktop Printing", "flatten": "" }
|
||||
});
|
||||
app.ui = UiState::read_preferences(&serde_json::to_vec(&old_desktop).unwrap()).unwrap().ui;
|
||||
assert_eq!(crate::menus::checked(&app, "app.flattener", &json!({"preset": ""})), Some(true));
|
||||
assert_eq!(crate::menus::checked(&app, "app.flattener", &json!({"preset": "low"})), Some(false));
|
||||
|
||||
let old_x1a = json!({
|
||||
"flattener": "low",
|
||||
"pdfExport": { "preset": "PDF/X-1a:2003", "flatten": "" }
|
||||
});
|
||||
app.ui = UiState::read_preferences(&serde_json::to_vec(&old_x1a).unwrap()).unwrap().ui;
|
||||
assert_eq!(crate::menus::checked(&app, "app.flattener", &json!({"preset": "high"})), Some(true));
|
||||
assert_eq!(crate::menus::checked(&app, "app.flattener", &json!({"preset": "low"})), Some(false));
|
||||
|
||||
app.ui = ui_custom_global;
|
||||
assert_eq!(crate::menus::checked(&app, "app.flattener", &json!({"preset": "low"})), Some(true));
|
||||
assert_eq!(crate::menus::checked(&app, "app.flattener", &json!({"preset": ""})), Some(false));
|
||||
}
|
||||
@@ -215,7 +215,7 @@ impl Preview {
|
||||
/// The Export PDF settings the preview separates with.
|
||||
pub fn print_settings(app: &DesignApp) -> Print {
|
||||
let s = &app.ui.pdf_export;
|
||||
let flatten = if s.flatten.is_empty() { app.ui.flattener.as_str() } else { s.flatten.as_str() };
|
||||
let flatten = s.resolved_flatten(&app.ui.flattener);
|
||||
Print {
|
||||
standard: designcraft_engine::separations::Standard::parse(&s.standard).unwrap_or_default(),
|
||||
compress_images: s.compress_images,
|
||||
@@ -461,4 +461,25 @@ mod tests {
|
||||
assert!(!std::sync::Arc::ptr_eq(&first, &again), "a sheet of other color settings is separated again");
|
||||
assert!(app.canvas.separations.entries.iter().all(|e| e.key.cms == designcraft_color::cms::generation()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn print_settings_respects_saved_no_flatten_and_screen_and_email_migration() {
|
||||
let mut app = crate::DesignApp::new(designcraft_engine::Session::new(), crate::Services::default());
|
||||
app.ui.flattener = "low".into();
|
||||
// Unset flatten before any dialog choice falls back to global flattener.
|
||||
app.ui.pdf_export.flatten = String::new();
|
||||
app.ui.pdf_export.flatten_chosen = false;
|
||||
assert_eq!(super::print_settings(&app).flatten, Some(72.0));
|
||||
// Explicit No Flattening choice keeps live transparency despite global flattener = "low".
|
||||
app.ui.pdf_export.flatten = String::new();
|
||||
app.ui.pdf_export.flatten_chosen = true;
|
||||
assert_eq!(super::print_settings(&app).flatten, None);
|
||||
// Earlier "Screen and Email" settings with "low" migrate on load to keep live transparency.
|
||||
let saved = serde_json::json!({
|
||||
"flattener": "low",
|
||||
"pdfExport": { "preset": "Screen and Email", "flatten": "low" }
|
||||
});
|
||||
app.ui = crate::UiState::read_preferences(&serde_json::to_vec(&saved).unwrap()).unwrap().ui;
|
||||
assert_eq!(super::print_settings(&app).flatten, None);
|
||||
}
|
||||
}
|
||||
@@ -135,6 +135,10 @@ pub struct PdfExportSettings {
|
||||
pub compress_images: bool,
|
||||
/// Transparency flattener preset (`""` = none, `high`, `medium`, `low`).
|
||||
pub flatten: String,
|
||||
/// Whether `flatten` was explicitly chosen (so `""` keeps live transparency rather than
|
||||
/// falling back to `UiState.flattener`, while older builds still read `flatten = ""` cleanly).
|
||||
#[serde(default)]
|
||||
pub flatten_chosen: bool,
|
||||
pub spreads: bool,
|
||||
pub bleed: bool,
|
||||
pub marks_crop: bool,
|
||||
@@ -153,6 +157,7 @@ impl Default for PdfExportSettings {
|
||||
standard: "none".into(),
|
||||
compress_images: false,
|
||||
flatten: "".into(),
|
||||
flatten_chosen: false,
|
||||
spreads: false,
|
||||
bleed: true,
|
||||
marks_crop: false,
|
||||
@@ -165,6 +170,23 @@ impl Default for PdfExportSettings {
|
||||
}
|
||||
}
|
||||
|
||||
impl PdfExportSettings {
|
||||
/// Whether the Export PDF dialog has not overridden the global flattener preset
|
||||
/// (`UiState.flattener`).
|
||||
pub fn uses_global_flatten(&self) -> bool {
|
||||
!self.flatten_chosen && self.flatten.is_empty()
|
||||
}
|
||||
|
||||
/// The flattener preset to seed the Export PDF dialog, Separations Preview, and the
|
||||
/// `Edit › Transparency Flattener Presets` menu checkmark with (`""` = live transparency,
|
||||
/// `"high"`, `"medium"`, or `"low"`). An unchosen empty value (`""` with
|
||||
/// `flatten_chosen == false`) falls back to `global` (`UiState.flattener`); once explicitly
|
||||
/// chosen (or non-empty), the saved `flatten` value is kept.
|
||||
pub fn resolved_flatten<'a>(&'a self, global: &'a str) -> &'a str {
|
||||
if self.uses_global_flatten() { global } else { &self.flatten }
|
||||
}
|
||||
}
|
||||
|
||||
/// The viewport of New Window's OS window, which shows pane 1.
|
||||
pub(crate) fn second_window_viewport() -> egui::ViewportId {
|
||||
egui::ViewportId::from_hash_of("designcraft_second_window")
|
||||
|
||||
Reference in new issue
Block a user