DesignCraft: An open-source page and layout design editor written by scratch in pure Rust
Merge origin/main into codex/swatch-popup-tint
moppeeera14acea3a404
diff --cc ROADMAP.mdindex 5b1b561d8,d60a6bf49..ee35a3081--- a/ROADMAP.md+++ b/ROADMAP.md@@@ -153,10 -438,16 +438,17 @@@ Newest first- **2026-10-12** · The Effects panel shows the level its settings apply to ("Group: Color Dodge 100%") and, as in InDesign, Isolate Blending and Knockout Group for a selected group. No readiness percentage change.- **2026-10-11** · Properties gains InDesign's Pathfinder section (Add, Subtract, Intersect, Exclude Overlap, Minus Back) with several objects selected; section titles and icon buttons have accessible names. No readiness percentage change.- **2026-10-12** · The Eyedropper samples a placed image: clicking the photo with text (or objects) selected fills them with the image's colour under the pointer, as an unnamed colour (`color.sample`), as in InDesign. Images on locked layers can be sampled. No readiness percentage change.+- **2026-10-11** · Properties › Appearance's Fill and Stroke menus gain InDesign's Tint field and, for a text frame, Apply To: Frame / Text. No readiness percentage change.+ - **2026-10-12** · The section marker character shows its section's marker text on document pages (nothing when the section has none) instead of the word "Section", which stays on parent pages; editing the marker recomposes (#556). No readiness percentage change.+ - **2026-10-12** · On screen, blend modes blend with the objects below and not with the paper, as in InDesign and in PDF export: a Color Dodge or Screen object over blank paper shows as it is. No readiness percentage change.+ - **2026-10-12** · A gradient feather on a group fades the group as one, on screen and in PDF. Before, the screen ignored it, and PDF masked the group with a box of zero size because a group has no path of its own. No readiness percentage change.+ - **2026-10-12** · In a CMYK transparency blend space (print documents), blend modes blend in CMYK on screen as in InDesign. Color Dodge with 100% K text turns coloured areas under it white and leaves the paper alone, where RGB blending changed almost nothing. PDF export already did this. No readiness percentage change.+ - **2026-10-11** · Moving a sheared and rotated text frame no longer leaves trails of text behind: canvas repaints cover the frame's whole text box, not just its outline. No readiness percentage change.- **2026-10-12** · Words in capitals hyphenate like capitalized words (FERRUM COM-MODI), as in InDesign; Hyphenate Capitalized Words off keeps them whole. No readiness percentage change.+ - **2026-10-12** · Load Swatches refuses an `.ase` file with more than 100,000 colors, and `swatch.load` merges a file of 100,000 colors in under 0.1 s (it took 9.6 s of CPU in a test build). No readiness percentage change.- **2026-10-11** · `transform.move {copy}`, Edit › Duplicate and Step and Repeat return the copies' ids, so a script can go on with them. No readiness percentage change.- **2026-10-11** · `object.fill` and `object.stroke` refuse a swatch name the document doesn't have (it painted nothing) and suggest the name meant (`Paper` → `[Paper]`). No readiness percentage change.+ - **2026-10-13** · Dropping an `.ase` file on the window loads its swatches, as Load Swatches does (the drop failed with "Can't Place the File"). No readiness percentage change.- **2026-10-11 (printing):** `file.printers` and `file.print` use craft-libs/craft-print for CUPS and Windows. DesignCraft retains PDF export, page selection, spreads, marks and bleed; dry runs create no temporary PDF or print job. Windows selects matching or default driver paper and shrinks oversized sheets without enlarging smaller ones; queue duplex defaults are preserved. Headless tests exercise exported bytes, job settings, dry runs and refusals; shared native Windows CI passes, including paused-queue submission and cleanup. PostScript, production print controls and physical output validation remain open. No readiness percentage change.- **2026-10-10 (UI.4–UI.5):** Panel tabs can move into other groups, split the dock, float, resize and return to their saved locations through shared docking transactions. Layouts persist in custom workspaces; UI and control commands share the same validated action path. Shared pane geometry and widget-state theme application retain all five palettes and local fonts. Split panes send keyboard input only to the focused canvas and scope contextual toolbar IDs per pane. No readiness percentage change.diff --cc crates/engine/src/cmd/object.rsindex b822993f2,bbc0a36a1..b701f1ffb--- a/crates/engine/src/cmd/object.rs+++ b/crates/engine/src/cmd/object.rs@@@ -3355,30 -3461,35 +3461,63 @@@ mod spread_target_tests}}+#[cfg(test)]+mod tint_alone_tests {+ use serde_json::json;++ #[test]+ fn a_tint_alone_keeps_each_swatch_and_leaves_no_stroke_alone() {+ let mut s = crate::Session::new();+ s.execute("file.new", &json!({})).unwrap();+ let a = s.execute("frame.create", &json!({"rect": [0, 0, 50, 50]})).unwrap()["id"].as_u64().unwrap();+ let b = s.execute("frame.create", &json!({"rect": [60, 0, 110, 50]})).unwrap()["id"].as_u64().unwrap();+ s.execute("object.fill", &json!({"swatch": "[Black]", "ids": [a]})).unwrap();+ s.execute("object.fill", &json!({"swatch": "C=100 M=0 Y=0 K=0", "ids": [b]})).unwrap();+ s.execute("object.stroke", &json!({"swatch": "[None]", "ids": [a, b]})).unwrap();+ // Fill tint on both: each keeps its swatch.+ s.execute("object.fill", &json!({"tint": 0.25, "ids": [a, b]})).unwrap();+ let item = |s: &crate::Session, id: u64| s.doc().unwrap().doc.item(designcraft_doc::ItemId(id)).unwrap().clone();+ assert_eq!((item(&s, a).fill.swatch.as_str(), item(&s, a).fill.tint), ("[Black]", 0.25));+ assert_eq!((item(&s, b).fill.swatch.as_str(), item(&s, b).fill.tint), ("C=100 M=0 Y=0 K=0", 0.25));+ // A swatch alone is 100%.+ s.execute("object.fill", &json!({"swatch": "[Paper]", "ids": [a]})).unwrap();+ assert_eq!(item(&s, a).fill.tint, 1.0);+ // A stroke tint on no stroke: still no stroke.+ s.execute("object.stroke", &json!({"tint": 0.5, "ids": [a]})).unwrap();+ assert!(item(&s, a).stroke.is_none(), "{:?}", item(&s, a).stroke);+ assert!(s.execute("object.fill", &json!({"ids": [a]})).is_err(), "neither swatch nor tint");+ }+}+++ #[cfg(test)]+ mod fill_tint_tests {+ use super::*;++ #[test]+ fn a_tint_alone_keeps_each_objects_own_swatch() {+ let mut s = Session::new();+ s.execute("file.new", &json!({})).unwrap();+ let a = s.execute("frame.create", &json!({"rect": [36, 36, 100, 100]})).unwrap()["id"].as_u64().unwrap();+ let b = s.execute("frame.create", &json!({"rect": [136, 36, 200, 100]})).unwrap()["id"].as_u64().unwrap();+ s.execute("object.fill", &json!({"ids": [a], "swatch": "C=100 M=0 Y=0 K=0"})).unwrap();+ s.execute("object.fill", &json!({"ids": [b], "swatch": "C=0 M=100 Y=0 K=0"})).unwrap();+ s.execute("object.fill", &json!({"ids": [a, b], "tint": 0.4})).unwrap();+ let fill_of = |s: &Session, id: u64| s.doc().unwrap().doc.item(ItemId(id)).unwrap().fill.clone();+ assert_eq!((fill_of(&s, a).swatch.as_str(), fill_of(&s, a).tint), ("C=100 M=0 Y=0 K=0", 0.4));+ assert_eq!((fill_of(&s, b).swatch.as_str(), fill_of(&s, b).tint), ("C=0 M=100 Y=0 K=0", 0.4));+ // A swatch without a tint is at 100 %, as before.+ s.execute("object.fill", &json!({"ids": [a], "swatch": "[Black]"})).unwrap();+ assert_eq!(fill_of(&s, a).tint, 1.0);+ // Neither, or a tint out of range: refused.+ assert!(s.execute("object.fill", &json!({"ids": [a]})).is_err());+ assert!(s.execute("object.fill", &json!({"ids": [a], "tint": 2})).is_err());+ assert!(s.execute("object.fill", &json!({"ids": [a], "tint": "x"})).is_err());+ // A stroke tint alone: stroked objects take it, an object without a stroke keeps none.+ s.execute("object.stroke", &json!({"ids": [a], "swatch": "C=100 M=0 Y=0 K=0", "weight": 2})).unwrap();+ s.execute("object.stroke", &json!({"ids": [b], "swatch": "[None]"})).unwrap();+ s.execute("object.stroke", &json!({"ids": [a, b], "tint": 0.5})).unwrap();+ let stroke_of = |s: &Session, id: u64| s.doc().unwrap().doc.item(ItemId(id)).unwrap().stroke.clone();+ assert_eq!((stroke_of(&s, a).swatch.as_str(), stroke_of(&s, a).tint, stroke_of(&s, a).weight), ("C=100 M=0 Y=0 K=0", 0.5, 2.0));+ assert!(stroke_of(&s, b).is_none());+ }+ }diff --cc crates/ui-egui/src/panels/properties.rsindex 1be82b880,52ce7e688..f7b5c4060--- a/crates/ui-egui/src/panels/properties.rs+++ b/crates/ui-egui/src/panels/properties.rs@@@ -648,9 -677,11 +675,9 @@@ fn appearance_section(app: &mut DesignAui.painter().rect_stroke(chip, 0.0, Stroke::new(1.0, t.field_border), StrokeKind::Inside);let resp = ui.interact(chip, ui.id().with("strokechip"), Sense::click()).on_hover_text(format!("Stroke: {}", i.stroke));resp.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, true, "Stroke swatch"));- swatch_menu(app, &resp, &doc, &i.stroke, |app, n| {- let _ = app.run("object.stroke", json!({"swatch": n}));- });+ swatch_menu(app, &resp, &doc, &i.stroke, true, i.is_text && i.count == 1, false);if place(ui, sub(b, 34.0, 0.0, 56.0, FIELD_H), |ui| link_label(ui, crate::i18n::tr(&app.ui.language, "Stroke"), 56.0)).clicked() {- app.ui.open_panel = Some("stroke".into());+ show_panel(app, "stroke");}const WEIGHTS: &[f64] = &[0.0, 0.25, 0.5, 0.75, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 20.0, 30.0, 40.0, 50.0, 100.0];if let Some(v) = place(ui, sub(b, 96.0, 0.0, 69.0, FIELD_H), |ui| {@@@ -717,88 -748,14 +744,81 @@@});}-/// Swatch list popup attached to `resp`.-fn swatch_menu(app: &mut DesignApp, resp: &egui::Response, doc: &designcraft_doc::Document, cur: &str, on_pick: impl FnOnce(&mut DesignApp, String)) {+/// The Fill (or Stroke) popup of Properties › Appearance, as InDesign's: Apply To (a text frame's+/// frame or its text), the tint, then the swatches. `cur` is the frame's swatch. With `text_only`+/// (text selected) it colours the selected text.+fn swatch_menu(+ app: &mut DesignApp,+ resp: &egui::Response,+ doc: &designcraft_doc::Document,+ cur: &str,+ stroke: bool,+ text_frame: bool,+ text_only: bool,+) {+ let lang = app.ui.language.clone();+ let tr = |s: &'static str| crate::i18n::tr(&lang, s);+ let to_text_id = egui::Id::new(("swatch_apply_to_text", stroke));+ let to_text = text_only || text_frame && resp.ctx.data(|d| d.get_temp::<bool>(to_text_id)).unwrap_or(false);+ // What the popup shows and changes: the frame's fill or stroke, or its text's.+ let (key, tint_key) = if stroke { ("stroke", "strokeTint") } else { ("fill", "fillTint") };+ let (cur, tint) = if to_text {+ let chars = super::text_attrs(app).map(|a| a["chars"].clone()).unwrap_or_default();+ (chars[key].as_str().unwrap_or("").to_string(), chars[tint_key].as_f64().unwrap_or(1.0))+ } else {+ (cur.to_string(), f64::from(super::sel_tint(app, stroke)))+ };let mut picked = None;- egui::Popup::menu(resp).show(|ui| {- picked = super::swatch_list(ui, doc, cur);+ let mut new_tint = None;+ let mut switch = None;+ egui::Popup::menu(resp).close_behavior(egui::PopupCloseBehavior::CloseOnClickOutside).show(|ui| {+ ui.set_min_width(220.0);+ ui.set_max_width(280.0);+ if text_frame {+ ui.horizontal(|ui| {+ crate::rtl::label(ui, tr("Apply To:"));+ for (label, text) in [("Frame", false), ("Text", true)] {+ if ui.selectable_label(to_text == text, crate::rtl::widget(ui, tr(label))).clicked() {+ switch = Some(text);+ }+ }+ });+ }+ ui.horizontal(|ui| {+ crate::rtl::label(ui, tr("Tint:"));+ if let Some(v) = NumField::number(if stroke { "stroke_tint" } else { "fill_tint" }, Some((tint * 100.0).round()), "%", 0)+ .width(60.0)+ .range(0.0, 100.0)+ .show(ui)+ {+ new_tint = Some(v / 100.0);+ }+ });+ ui.separator();- egui::ScrollArea::vertical().max_height(320.0).show(ui, |ui| {- for sw in &doc.swatches {- if super::swatch_menu_row(ui, doc, &sw.name, &cur) {- picked = Some(sw.name.clone());- ui.close();- }- }- });++ picked = super::swatch_list(ui, doc, &cur);});- if let Some(p) = picked {- on_pick(app, p);+ if let Some(t) = switch {+ resp.ctx.data_mut(|d| d.insert_temp(to_text_id, t));+ }+ let cmd = |app: &mut DesignApp, attrs: Value| {+ if to_text {+ let _ = app.run("type.char", json!({ "attrs": attrs }));+ } else {+ let mut p = attrs.as_object().cloned().unwrap_or_default();+ // object.fill / object.stroke name the swatch `swatch` and the tint `tint`.+ if let Some(v) = p.remove(key) {+ p.insert("swatch".into(), v);+ }+ if let Some(v) = p.remove(tint_key) {+ p.insert("tint".into(), v);+ }+ let _ = app.run(if stroke { "object.stroke" } else { "object.fill" }, Value::Object(p));+ }+ };+ if let Some(n) = picked {+ cmd(app, json!({ key: n }));+ } else if let Some(t) = new_tint {+ cmd(app, json!({ tint_key: t }));}}