From 1e2bc0fee889e0a1682e54ab6c5a2817a234f4c2 Mon Sep 17 00:00:00 2001 From: Terra854 Date: Wed, 2 Dec 2026 05:29:36 +0800 Subject: [PATCH 01/14] Preserve symbol pattern resources and affine stroke scaling in AI exports --- crates/eps/src/ai_editing.rs | 4 +- crates/eps/src/ai_editing/tests.rs | 177 +++++++++++++++++++- crates/eps/src/ai_editing/writer.rs | 40 ++++- crates/eps/src/ai_editing/writer/images.rs | 2 +- crates/eps/src/ai_editing/writer/paints.rs | 37 +++- crates/eps/src/ai_editing/writer/symbols.rs | 6 + crates/eps/src/import/ai/read/directives.rs | 8 +- crates/eps/src/import/ai/read/document.rs | 6 + crates/eps/src/import/ai/read/types.rs | 2 + docs/file-format-parity.md | 8 +- 10 files changed, 265 insertions(+), 25 deletions(-) diff --git a/crates/eps/src/ai_editing.rs b/crates/eps/src/ai_editing.rs index 82ed02f1f8..a952fbac6c 100644 --- a/crates/eps/src/ai_editing.rs +++ b/crates/eps/src/ai_editing.rs @@ -181,7 +181,7 @@ //! (gradients that dither are written without dither's noise, Perceptual gradients and gradients //! mixed around the hue wheel as the stops on their curve in process colors, at most 256, and //! gradient stops linked to global process colors as their colors), pattern fills whose tiles aren't a grid, whose art reaches past -//! the tile or is painted with patterns, and pattern fills in symbols, as their tiles cut +//! the tile or is painted with patterns, and pattern fills in large-canvas symbols, as their tiles cut //! to the shape, clipping groups and clipping layers whose clipping object isn't a path, //! and the clipping groups inside them, as their art cut to that object (its fill cut too, its //! stroke not; an image in a clipping group of the region it is cut to), images that can't be @@ -225,7 +225,7 @@ use vectorcraft_pdf::PrivateData; use crate::ps; mod writer; -pub(crate) use writer::{DYNAMIC_KEY, OVERRIDES_KEY, hex_decode}; +pub(crate) use writer::{DYNAMIC_KEY, OVERRIDES_KEY, PATTERN_SPACE_KEY, hex_decode}; use writer::Writer; diff --git a/crates/eps/src/ai_editing/tests.rs b/crates/eps/src/ai_editing/tests.rs index 8c3b4ad12d..82ea0fc5b0 100644 --- a/crates/eps/src/ai_editing/tests.rs +++ b/crates/eps/src/ai_editing/tests.rs @@ -6521,12 +6521,12 @@ fn instances_the_data_cant_hold_are_written_as_their_art() { } /// Symbols whose art paints with a pattern, directly, through a nested symbol, in an opacity mask -/// and through an inline graphic: their definitions hold the pattern fills as tiles cut to the shape (the reader keeps no -/// symbol whose art paints with a pattern), and their instances are written as their art, whose +/// and through an inline graphic: their definitions retain native pattern resources, and their +/// instances are written as their art, whose /// pattern fills keep the document's placement as the canvas draws them, each with a warning. An /// instance of a symbol without pattern paint stays an instance. #[test] -fn symbols_with_pattern_fills_are_defined_with_tiles_and_placed_as_art() { +fn symbols_with_pattern_fills_keep_resources_and_place_as_art() { let mut doc = Document::new(200.0, 100.0); // Tiles that cover the shape, so its tiles cut to it draw its box. let dot = Arc::new(square(&mut doc, Rect::new(0.0, 0.0, 8.0, 8.0), Color::BLACK)); @@ -6561,12 +6561,17 @@ fn symbols_with_pattern_fills_are_defined_with_tiles_and_placed_as_art() { let filled = Node::path(doc.alloc_id(), shapes::rectangle(Rect::new(150.0, 10.0, 182.0, 42.0)), fill()); doc.insert(Some(layer), usize::MAX, filled).unwrap(); let out = export_ai_editing(&doc, &opts()).unwrap(); - assert!(out.warnings.iter().any(|w| w == writer::SYMBOL_ART) && out.warnings.iter().any(|w| w == writer::PATTERNS), "{:?}", out.warnings); + assert!(out.warnings.iter().any(|w| w == writer::SYMBOL_ART), "{:?}", out.warnings); + assert!(!out.warnings.iter().any(|w| w == writer::PATTERNS), "grid resources must not become tiles: {:?}", out.warnings); let back = read_back(&doc); let names: Vec<&str> = back.symbols.iter().map(|s| s.name.as_str()).collect(); assert_eq!(names, ["Patch", "Outer", "Masked", "Plain", "Typed"]); let patch = &back.symbols[0].art; - assert!(matches!(patch.kind, NodeKind::Group { .. }), "the symbol's art is its tiles: {:?}", patch.kind); + assert!( + matches!(patch.kind, NodeKind::Path { .. }) && vectorcraft_doc::pattern::uses_pattern(patch, Some("Dots")), + "the symbol must retain its original pattern-filled path: {:?}", + patch.kind + ); assert_eq!(instances(&back.symbols[1].art), 0, "the nested instance is its art"); let kids = back.layers[0].children().unwrap(); let kinds: Vec = kids.iter().map(|n| matches!(n.kind, NodeKind::SymbolInstance { .. })).collect(); @@ -6596,8 +6601,164 @@ fn symbols_with_pattern_fills_are_defined_with_tiles_and_placed_as_art() { same_lines(&boxes(&back), &boxes(&doc)); } +/// Original ruled tile shared by symbol art and an ordinary canvas object. The symbol's pattern +/// and geometry are scaled together, as editing its art with Transform Pattern Tiles does. +fn ruled_pattern_symbol(strokes: bool, tile_type: vectorcraft_doc::TileType, extent: f64) -> Document { + let mut doc = Document::new(240.0, 140.0); + let line = + Node::path(doc.alloc_id(), shapes::line((1.0, 5.0).into(), (9.0, 5.0).into()), Appearance::basic(Paint::None, solid(Color::BLACK), 2.0)); + let mut tile = vectorcraft_doc::PatternDef::new("Rules", vec![Arc::new(line)]); + tile.tile = Rect::new(0.0, 0.0, 10.0, 10.0); + tile.tile_type = tile_type; + doc.patterns.push(tile); + let fill = || Appearance::basic(Paint::Pattern { pattern: "Rules".into(), xf: Affine::IDENTITY }, Paint::None, 0.0); + let mut art = Node::path(doc.alloc_id(), shapes::rectangle(Rect::new(0.0, 0.0, extent, extent)), fill()); + art.transform(Affine::scale(0.2), vectorcraft_doc::Scaling { strokes, patterns: true, ..Default::default() }); + doc.symbols.push(Symbol { name: "Scaled".into(), art: Arc::new(art), dynamic: false }); + let layer = doc.layers[0].id; + let one = instance(&mut doc, "Scaled", Affine::translate((20.0, 20.0))); + doc.insert(Some(layer), usize::MAX, one).unwrap(); + let shared = Node::path(doc.alloc_id(), shapes::rectangle(Rect::new(125.0, 5.0, 225.0, 105.0)), fill()); + doc.insert(Some(layer), usize::MAX, shared).unwrap(); + doc +} + +#[test] +fn scaled_pattern_symbol_keeps_native_pattern_resources_in_editing_data() { + let small = ruled_pattern_symbol(true, vectorcraft_doc::TileType::Grid, 100.0); + let large = ruled_pattern_symbol(true, vectorcraft_doc::TileType::Grid, 200.0); + let (a, b) = (program(&small), program(&large)); + eprintln!("pattern symbol editing bytes: {} -> {} for four times the tile area", a.len(), b.len()); + let back = read_back(&small); + let art = &back.symbols.iter().find(|s| s.name == "Scaled").unwrap().art; + assert!(vectorcraft_doc::pattern::uses_pattern(art, Some("Rules")), "the symbol must retain pattern paint rather than one object per tile"); + assert_eq!(a.matches("%AI3_BeginPattern: (Rules)").count(), 1); + assert!(b.len() < a.len() * 2, "editing data must not grow with every covered tile: {} -> {}", a.len(), b.len()); + let tile = back.pattern("Rules").unwrap(); + assert_eq!(tile.tile, small.patterns[0].tile); + assert_eq!(tile.art[0].geometric_bounds().unwrap().width(), 8.0); + let strokes: Vec<_> = + tile.art[0].appearance.items.iter().filter_map(|i| if let AppearanceItem::Stroke(stroke) = i { Some(stroke.width) } else { None }).collect(); + assert_eq!(strokes, [2.0], "the shared tile keeps its original stroke"); +} + +// Four editing-stream round trips and native raster probes cover the flag and fallback cases. +#[test] +fn scaled_pattern_symbol_new_instances_match_native_tile_stroke_weight() { + for strokes in [true, false] { + for tile_type in [vectorcraft_doc::TileType::Grid, vectorcraft_doc::TileType::BrickByRow { offset: 0.5 }] { + let doc = ruled_pattern_symbol(strokes, tile_type, 100.0); + // Native rendering scales a 2pt pattern stroke to 0.4pt with its pattern affine, + // under either flag. The flag controls the selected object's own stroke separately. + let native = vectorcraft_testkit::raster::render_region(&doc, Rect::new(20.0, 20.0, 22.0, 22.0), 20.0); + let native_weight = (0..native.height).filter(|y| native.pixel(20, *y)[0] < 64).count(); + assert!((6..=10).contains(&native_weight), "native weight={native_weight}, strokes={strokes}, {tile_type:?}"); + let mut back = read_back(&doc); + // Place afresh from the editing stream's symbol definition, rather than measuring + // the already-expanded canvas instance or the file's native payload. + back.layers.clear(); + let layer = back.add_layer(Some("New instance")); + let one = instance(&mut back, "Scaled", Affine::translate((20.0, 20.0))); + back.insert(Some(layer), usize::MAX, one).unwrap(); + let placed = vectorcraft_testkit::raster::render_region(&back, Rect::new(20.0, 20.0, 22.0, 22.0), 20.0); + let weight = (0..placed.height).filter(|y| placed.pixel(20, *y)[0] < 64).count(); + assert!((6..=10).contains(&weight), "editing symbol weight={weight}, native={native_weight}, strokes={strokes}, {tile_type:?}"); + } + } +} + +// Each case goes through the real editing stream and renderer: the mask stroke has to be +// transformed as geometry even when writing its dictionary temporarily clears the tile clip. +#[test] +fn pattern_tile_fallback_preserves_affine_mask_stroke_weight() { + for matrix in + [Affine::scale(0.2), Affine::scale_non_uniform(0.2, 0.4), Affine::new([0.2, 0.0, 0.1, 0.2, 0.0, 0.0]), Affine::scale_non_uniform(-0.2, 0.2)] + { + let mut doc = ruled_pattern_symbol(true, vectorcraft_doc::TileType::BrickByRow { offset: 0.5 }, 100.0); + let white_line = + Node::path(doc.alloc_id(), shapes::line((1.0, 5.0).into(), (9.0, 5.0).into()), Appearance::basic(Paint::None, solid(Color::WHITE), 2.0)); + let mut tile = square(&mut doc, Rect::new(0.0, 0.0, 10.0, 10.0), Color::BLACK); + tile.extras_mut().mask = Some(Box::new(OpacityMask { art: Arc::new(white_line), clip: true, invert: false, disabled: false, linked: true })); + doc.patterns[0].art = vec![Arc::new(tile)]; + Arc::make_mut(&mut doc.symbols[0].art) + .transform(matrix * Affine::scale(5.0), vectorcraft_doc::Scaling { patterns: true, ..Default::default() }); + // This fallback bakes the unsupported brick phase. Place on whole super-tile periods + // so the probe isolates stroke geometry, rather than that existing placement limitation. + doc.layers.clear(); + let native_layer = doc.add_layer(Some("Native instance")); + let native_one = instance(&mut doc, "Scaled", Affine::translate((60.0, 40.0))); + doc.insert(Some(native_layer), usize::MAX, native_one).unwrap(); + let bounds = doc.symbols[0].art.geometric_bounds().unwrap() + vectorcraft_geom::Vec2::new(60.0, 40.0); + let period_y = 10.0 * matrix.as_coeffs()[3].abs(); + let region = Rect::new(bounds.x0, bounds.y0, bounds.x0 + 2.0, bounds.y0 + period_y); + let native = vectorcraft_testkit::raster::render_region(&doc, region, 20.0); + // Brick rows shift the line horizontally; select a visible native column and compare + // that same column after the editing-stream round trip. + let (column, native_weight) = (0..native.width) + .map(|x| (x, (0..native.height).filter(|y| native.pixel(x, *y)[0] < 64).count())) + .max_by_key(|(_, weight)| *weight) + .unwrap(); + assert!(native_weight > 0 && native_weight < native.height as usize, "native mask stroke: {matrix:?}, {native_weight}"); + let mut back = read_back(&doc); + back.layers.clear(); + let layer = back.add_layer(Some("New instance")); + let one = instance(&mut back, "Scaled", Affine::translate((60.0, 40.0))); + back.insert(Some(layer), usize::MAX, one).unwrap(); + let placed = vectorcraft_testkit::raster::render_region(&back, region, 20.0); + let weight = (0..placed.height).filter(|y| placed.pixel(column, *y)[0] < 64).count(); + assert!(weight.abs_diff(native_weight) <= 2, "mask stroke {matrix:?}: editing={weight}, native={native_weight}"); + } +} + +#[test] +fn pattern_definition_dictionary_is_scoped_away_from_its_symbol() { + let mut doc = ruled_pattern_symbol(true, vectorcraft_doc::TileType::Grid, 100.0); + // Definitions can hold freshly generated id-less art. Its dictionary must not consume the + // surrounding symbol's root entries just because these independent art scopes share id 0. + Arc::make_mut(&mut doc.patterns[0].art[0]).id = vectorcraft_doc::NodeId(0); + let art = (*doc.symbols[0].art).clone(); + let other = square(&mut doc, Rect::new(25.0, 0.0, 30.0, 5.0), Color::BLACK); + let mut root = group(&mut doc, vec![art, other], false); + root.id = vectorcraft_doc::NodeId(0); + doc.symbols[0].art = Arc::new(root); + let back = read_back(&doc); + let symbol = back.symbols.iter().find(|s| s.name == "Scaled").expect("pattern art must not steal its symbol's declaration"); + let mut uses = false; + vectorcraft_doc::swatches::walk_with_masks(&symbol.art, &mut |n| uses |= vectorcraft_doc::pattern::uses_pattern(n, Some("Rules"))); + assert!(uses); +} + +#[test] +fn symbol_pattern_matrices_stay_readable_or_use_the_bounded_fallback() { + for scale in [0.00001, 0.0, 1e-9] { + let mut doc = ruled_pattern_symbol(true, vectorcraft_doc::TileType::Grid, 100.0); + let art = Arc::make_mut(&mut doc.symbols[0].art); + for item in art.appearance.items.iter_mut() { + if let Paint::Pattern { xf, .. } = item.paint_mut() { + *xf = Affine::scale(scale); + } + } + let out = export_ai_editing(&doc, &opts()).unwrap(); + let back = read_back(&doc); + let symbol = back.symbols.iter().find(|s| s.name == "Scaled").expect("a bad paint matrix must not discard its symbol"); + let mut paints = vec![]; + vectorcraft_doc::swatches::walk_with_masks(&symbol.art, &mut |n| { + for item in &n.appearance.items { + if let Paint::Pattern { xf, .. } = item.paint() { + paints.push(*xf); + } + } + }); + if scale == 0.00001 { + assert_eq!(paints, [Affine::scale(scale)], "a small invertible affine must survive serialization"); + } else { + assert!(paints.is_empty() && out.warnings.iter().any(|w| w == writer::PATTERN_PLACEMENT), "{:?}", out.warnings); + } + } +} + /// A symbol whose art paints with a pattern only through a brushed stroke, whose brush's art is -/// filled with a pattern: the definition holds the tiles, and its instance is written as its art. +/// filled with a pattern: the definition keeps that resource, and its instance is written as art. #[test] fn symbols_painting_patterns_through_brush_art_are_placed_as_art() { let mut doc = Document::new(200.0, 100.0); @@ -6625,9 +6786,13 @@ fn symbols_painting_patterns_through_brush_art_are_placed_as_art() { doc.insert(Some(layer), usize::MAX, one).unwrap(); let out = export_ai_editing(&doc, &opts()).unwrap(); assert!(out.warnings.iter().any(|w| w == writer::SYMBOL_ART), "{:?}", out.warnings); + assert!(!out.warnings.iter().any(|w| w == writer::PATTERNS), "{:?}", out.warnings); let back = read_back(&doc); assert_eq!(back.symbols.iter().map(|s| s.name.as_str()).collect::>(), ["Brushed"]); assert_eq!(instances(&back.layers[0]), 0, "the instance is its art"); + let mut pattern = false; + vectorcraft_doc::swatches::walk_with_masks(&back.symbols[0].art, &mut |n| pattern |= vectorcraft_doc::pattern::uses_pattern(n, Some("Dots"))); + assert!(pattern, "indirect brush paint retains its pattern resource in the definition"); } /// A symbol first defined from the drawn look of a group with a style, through a member's scatter diff --git a/crates/eps/src/ai_editing/writer.rs b/crates/eps/src/ai_editing/writer.rs index b8ea88a1fd..52f5147d9a 100644 --- a/crates/eps/src/ai_editing/writer.rs +++ b/crates/eps/src/ai_editing/writer.rs @@ -48,7 +48,7 @@ pub(super) use paints::{ GRADIENT_COMPARISONS, GRADIENT_DITHER, GRADIENT_HUE, GRADIENT_PERCEPTUAL, GRADIENT_SHAPES, GRADIENTS, SCANNED_DEFINITIONS, STOP_LINKS, SWATCH_PLACEMENT, free_gradient_name, }; -pub(crate) use symbols::{DYNAMIC_KEY, OVERRIDES_KEY, hex_decode}; +pub(crate) use symbols::{DYNAMIC_KEY, OVERRIDES_KEY, PATTERN_SPACE_KEY, hex_decode}; #[cfg(test)] pub(super) use symbols::{MISSING_SYMBOL, SYMBOL_ART, SYMBOL_CHANGES, SYMBOL_COUNT, SYMBOL_OPTIONS}; #[cfg(test)] @@ -62,8 +62,10 @@ pub(super) use variables::{ACTIVE, BINDINGS, LIMITS, VALUES}; pub(super) const MAX_NEST: u32 = 8; pub(super) const TYPE: &str = "type in opacity masks, pattern tiles, symbols and art cut to a clipping object, mirrored type, area type and type on a path that is turned or unevenly scaled or whose frame or path has several parts, area type in an open frame, type on an open path whose ends meet, area type whose text wrap cannot be preserved from the saved objects, type of only white space, threads of type on a path, threads whose frames differ in orientation or hold a frame written as outlines, type of sizes past what the reader reads, stories past what the reader reads (1,048,576 bytes a story, 16,777,216 bytes in all, and the size of text document it reads), and type with inline graphics, ruby, gradient or pattern paint, or fills, strokes, effects or an opacity mask of the object's own, is written as its outlines in the editing data for other apps"; -pub(super) const PATTERNS: &str = "pattern fills whose tiles aren't a grid or whose art reaches past the tile, pattern fills in another pattern's tile or in a symbol, and pattern fills nested more than 8 deep are written as their tiles cut to the shape in the editing data for other apps"; +pub(super) const PATTERNS: &str = "pattern fills whose tiles aren't a grid or whose art reaches past the tile, pattern fills in another pattern's tile or in a large canvas's symbol, and pattern fills nested more than 8 deep are written as their tiles cut to the shape in the editing data for other apps"; pub(super) const PATTERN_TILES: &str = "pattern fills with more tiles than a fill places are written filled gray in the editing data for other apps"; +pub(super) const PATTERN_PLACEMENT: &str = + "pattern fills and strokes whose placement cannot be read are written gray in the editing data for other apps"; pub(super) const CLIPPING: &str = "clipping groups and clipping layers whose clipping object isn't a path, and the clipping groups inside them, are written as their art cut to that object in the editing data for other apps"; pub(super) const CLIP_PAINT: &str = "the fills and strokes of clipping paths that a plain fill and line can't draw are written as paths of their own inside the clipping (fills under the clipped art, strokes over it) in the editing data for other apps"; pub(super) const CLIP_PAINT_MASKS: &str = "the opacity masks of clipping paths whose fills and strokes are written as paths of their own stay on the clipping path, not on those paths, in the editing data for other apps"; @@ -269,10 +271,10 @@ pub(super) struct Writer<'a> { /// Whether each symbol's art paints with a pattern, nested symbols included /// ([`Self::symbol_paints_pattern`]). patterned_symbols: HashMap, - /// Pattern tiles were written in the art being written ([`Self::define_symbol`] starts it over + /// Pattern references or tiles were written in the art ([`Self::define_symbol`] starts it over /// for each symbol's art). wrote_pattern: bool, - /// The symbols whose definitions hold pattern tiles: a brushed stroke's brush art or a live + /// The symbols whose definitions write pattern paint: a brushed stroke's brush art or a live /// object's art can paint with a pattern that the symbol's own objects don't name. pattern_written: HashSet, /// Art that draws as it should only where it is was written in the art being written @@ -1031,6 +1033,7 @@ impl<'a> Writer<'a> { mask = None; mask_written = false; } + let symbol_root = self.root_entries.as_ref().is_some_and(|(id, _)| *id == n.id); let entries = match &self.root_entries { Some((id, _)) if *id == n.id => self.root_entries.take().map(|(_, e)| e), _ => None, @@ -1081,6 +1084,10 @@ impl<'a> Writer<'a> { } mask_written = false; } + // A pattern may first be written by the root's mask, so declare its space afterwards. + if symbol_root && self.in_symbol && self.symbols_live && self.wrote_pattern { + let _ = writeln!(self.body, "%_1 /Int ({PATTERN_SPACE_KEY}) ,"); + } self.body.push_str("%_;\n%_\n"); mask_written } @@ -1480,7 +1487,8 @@ impl<'a> Writer<'a> { let flat = FillLayer { paint: Paint::solid(Color::gray(0.5)), ..f.clone() }; return self.path_object(path, rule, Some(&flat), None, xy); }; - let tiles = def.instances_in(*xf, path.to_bezpath().bounding_box()); + let inverse = xf.inverse(); + let tiles = def.instances_in(Affine::IDENTITY, inverse.transform_rect_bbox(path.to_bezpath().bounding_box())); // More tiles than a fill places come back as none: the shape is filled gray, as a // pattern that isn't found is. if tiles.is_empty() && !def.art.is_empty() { @@ -1494,8 +1502,26 @@ impl<'a> Writer<'a> { } self.wrote_pattern = true; let outer = self.clip.clone(); - let region = self.cut(path, rule); + let mut region = self.cut(path, rule); + region.transform(inverse); self.clip = Some(region); + let shown = std::mem::take(&mut self.shown); + self.shown = shown + .iter() + .map(|p| { + let mut p = p.clone(); + p.apply_affine(inverse); + p + }) + .collect(); + // Outline and clip strokes in pattern space before applying its affine. Moving + // just their centerlines first kept 2pt strokes at 2pt under a 20% pattern scale; + // scaling by one mean factor would still distort nonuniform/sheared patterns. + let spaces = (self.to_art, self.grad_space, self.canvas, self.instance_space); + self.to_art *= *xf; + self.grad_space *= *xf; + self.canvas *= *xf; + self.instance_space *= *xf; self.nest += 1; self.drawn += 1; for t in &tiles { @@ -1508,6 +1534,8 @@ impl<'a> Writer<'a> { self.end_group("U", xy); self.nest -= 1; self.clip = outer; + self.shown = shown; + (self.to_art, self.grad_space, self.canvas, self.instance_space) = spaces; } Paint::None => {} } diff --git a/crates/eps/src/ai_editing/writer/images.rs b/crates/eps/src/ai_editing/writer/images.rs index 408827663f..7731eb0e9e 100644 --- a/crates/eps/src/ai_editing/writer/images.rs +++ b/crates/eps/src/ai_editing/writer/images.rs @@ -430,7 +430,7 @@ impl Writer<'_> { } /// `[a b c d tx ty]`, each number to ten decimals ([`ps::num`] writes four). -fn matrix(m: Affine) -> String { +pub(super) fn matrix(m: Affine) -> String { let n: Vec = m.as_coeffs().iter().map(|v| precise(*v)).collect(); format!("[{}]", n.join(" ")) } diff --git a/crates/eps/src/ai_editing/writer/paints.rs b/crates/eps/src/ai_editing/writer/paints.rs index f1573c39ba..d65224042b 100644 --- a/crates/eps/src/ai_editing/writer/paints.rs +++ b/crates/eps/src/ai_editing/writer/paints.rs @@ -367,7 +367,12 @@ impl Writer<'_> { /// Does a plain line of `s`'s paint draw it ([`Self::direct`], and the line style operators can /// write it)? pub(super) fn direct_stroke(&self, s: &StrokeLayer) -> bool { - self.direct(&s.paint) && stroke::is_plain(s) + let [a, b, c, d, ..] = self.to_art.as_coeffs(); + // Operators receive transformed path coordinates, but their width is in art units. + // A non-isometric map needs the stroke's outline transformed too (including in masks, + // whose dictionary temporarily clears the clipping region of a pattern fallback). + let isometry = (a * a + b * b - 1.0).abs() < 1e-9 && (c * c + d * d - 1.0).abs() < 1e-9 && (a * c + b * d).abs() < 1e-9; + isometry && self.direct(&s.paint) && stroke::is_plain(s) } /// `n`'s paint `items` as one path object paints: no paint, a fill, a plain line, or both, the @@ -576,10 +581,10 @@ impl Writer<'_> { /// Can pattern `name` be written as a definition and painted with from here: the document has /// it, its tiles make a grid, its art is within its tile and holds something, and it isn't used - /// in another pattern's tile or a symbol's art (the reader keeps no symbol whose art paints with - /// a pattern) or nested more than [`MAX_NEST`] deep? + /// in another pattern's tile or nested more than [`MAX_NEST`] deep? A large canvas's symbol + /// art uses the original document, whose same-name tiles can differ from the reduced page's. pub(super) fn pattern_writable(&self, name: &str) -> bool { - if !self.defining.is_empty() || self.nest >= MAX_NEST || self.in_symbol { + if !self.defining.is_empty() || self.nest >= MAX_NEST || (self.in_symbol && !self.symbols_live) { return false; } if self.patterns.find(name).is_some() { @@ -605,7 +610,14 @@ impl Writer<'_> { let doc = self.doc; // The tile's box is an object of the definition ([`Self::take_objects`]). let (before, bound) = (self.charges(), self.bound.len()); - let Some(def) = doc.pattern(name).filter(|_| self.take_objects(1)) else { return false }; + let Some(def) = doc.pattern(name) else { return false }; + // A pattern is a separate global resource, even when first discovered in symbol art. + // Charge its objects outside the symbol-art budget and isolate parent dictionaries. + let in_symbol = std::mem::take(&mut self.in_symbol); + if !self.take_objects(1) { + self.in_symbol = in_symbol; + return false; + } self.defining.push(name.to_string()); // The art is written in the pattern's space, y up, from the state a definition starts in. let saved = ( @@ -617,6 +629,7 @@ impl Writer<'_> { self.block_end, // The tile's masks' objects are written with their art styles, those of no other art. (std::mem::replace(&mut self.styled, self.pattern_styled.get(name).cloned().unwrap_or_default()), self.mask_level.take()), + (in_symbol, self.root_entries.take(), self.instance_entries.take(), self.block_start), ); // `Bg` places a gradient in a pattern's tile as on the canvas, mirrored top to bottom: its // placement is worked out in the tile's space turned y up. @@ -647,6 +660,7 @@ impl Writer<'_> { (self.clip, self.shown), self.block_end, (self.styled, self.mask_level), + (self.in_symbol, self.root_entries, self.instance_entries, self.block_start), ) = saved; let art = std::mem::replace(&mut self.body, art); self.defining.pop(); @@ -679,7 +693,18 @@ impl Writer<'_> { return self.plain_color(Color::gray(0.5), stroke); }; let m = self.to_art * xf * Affine::translate((0.0, h)) * Affine::FLIP_Y; - let _ = writeln!(self.body, "{} 0 0 1 1 0 0 0 0 0 {} {}", ps::bytes(name.as_bytes()), ps::matrix(m), if stroke { 'P' } else { 'p' }); + let written = Affine::new(m.as_coeffs().map(|v| (v * 1e10).round() / 1e10)); + // Keep a definition's reference readable after serialization; a singular or rounded-flat + // paint must not make the reader discard the entire symbol that contains it. + if !written.as_coeffs().iter().all(|v| v.is_finite()) || !written.determinant().is_finite() || written.determinant().abs() < 1e-12 { + self.warn(super::PATTERN_PLACEMENT); + return self.plain_color(Color::gray(0.5), stroke); + } + // Indirect pattern paint (for example in brush art) also prevents a live symbol + // instance: the canvas keeps its pattern phase fixed when placing that instance. + self.wrote_pattern = true; + let _ = + writeln!(self.body, "{} 0 0 1 1 0 0 0 0 0 {} {}", ps::bytes(name.as_bytes()), super::images::matrix(m), if stroke { 'P' } else { 'p' }); } /// The definitions, in the setup before the palette: the gradients the art uses (`n Bn`, then diff --git a/crates/eps/src/ai_editing/writer/symbols.rs b/crates/eps/src/ai_editing/writer/symbols.rs index a616d748d1..815268d39c 100644 --- a/crates/eps/src/ai_editing/writer/symbols.rs +++ b/crates/eps/src/ai_editing/writer/symbols.rs @@ -19,6 +19,9 @@ pub(in crate::ai_editing) const SYMBOL_CHANGES: &str = "the changes of dynamic symbol instances are kept in dictionary entries of their own, which other apps leave out"; pub(crate) const DYNAMIC_KEY: &str = "VectorCraftDynamicSymbol"; pub(crate) const OVERRIDES_KEY: &str = "VectorCraftSymbolOverrides"; +/// Version 1 declares that pattern matrices in this definition use its art coordinates. +/// Foreign definitions without that declaration retain the reader's conservative fallback. +pub(crate) const PATTERN_SPACE_KEY: &str = "VectorCraftSymbolPatternSpace"; const MAX_OVERRIDES_BYTES: usize = 1 << 20; pub(crate) fn hex_decode(s: &str) -> Option> { @@ -311,6 +314,9 @@ impl Writer<'_> { if wrap { self.line("u"); self.node(root); + if self.symbols_live && self.wrote_pattern { + let _ = writeln!(entries, "%_1 /Int ({PATTERN_SPACE_KEY}) ,"); + } let _ = write!(self.body, "U\n%_/ArtDictionary :\n{entries}%_;\n%_\n9 () XW\n"); } else { // A group always writes its dictionary ([`Self::dictionary`]), which takes the entries. diff --git a/crates/eps/src/import/ai/read/directives.rs b/crates/eps/src/import/ai/read/directives.rs index 4c5b48c04d..67c6a47db2 100644 --- a/crates/eps/src/import/ai/read/directives.rs +++ b/crates/eps/src/import/ai/read/directives.rs @@ -631,8 +631,12 @@ impl<'a> Reader<'a> { let measured = read.is_ok() && !open && sub.unsupported.is_empty() && sub.unknown.is_empty() && sub.frames.len() == 1; let Some(frame) = sub.frames.pop().filter(|_| measured) else { return }; let mut kids = frame.children; - // Where a symbol's art puts a pattern's tiles isn't known. - let whole = !head.left_out && sub.unread.is_empty() && sub.hidden_unread.is_empty() && !kids.iter().any(|n| paints_pattern(n, 0)); + // Unmarked foreign symbols do not declare the coordinate convention of their patterns. + // Our writer explicitly declares symbol-art space, so those definitions can retain paint. + let whole = !head.left_out + && sub.unread.is_empty() + && sub.hidden_unread.is_empty() + && (head.pattern_space || !kids.iter().any(|n| paints_pattern(n, 0))); if !whole { let boxes = self.doc.symbol_boxes(); let bounds = kids.iter().fold(None, |acc, n| vectorcraft_geom::union_opt(acc, n.visual_bounds_with(&boxes))); diff --git a/crates/eps/src/import/ai/read/document.rs b/crates/eps/src/import/ai/read/document.rs index 20102b29c4..35dd700e6c 100644 --- a/crates/eps/src/import/ai/read/document.rs +++ b/crates/eps/src/import/ai/read/document.rs @@ -805,6 +805,12 @@ impl<'a> Reader<'a> { { head.dynamic = true; } + if self.frames.len() == 1 + && let Some(head) = self.symbol.as_mut() + && o.nums(crate::ai_editing::PATTERN_SPACE_KEY).first().copied() == Some(1.0) + { + head.pattern_space = true; + } if let Some(text) = o.text(crate::ai_editing::OVERRIDES_KEY) && let Some(bytes) = crate::ai_editing::hex_decode(&text) && let Ok(list) = serde_json::from_slice::>(&bytes) diff --git a/crates/eps/src/import/ai/read/types.rs b/crates/eps/src/import/ai/read/types.rs index 27eb8a8576..2e4d19bff7 100644 --- a/crates/eps/src/import/ai/read/types.rs +++ b/crates/eps/src/import/ai/read/types.rs @@ -245,6 +245,8 @@ pub(super) struct SymbolHead { /// `AI13PatternRegistrationType` in the dictionary after the art. pub(super) registration: Option, pub(super) dynamic: bool, + /// The writer declares its pattern matrices to be in symbol-art coordinates (version 1). + pub(super) pattern_space: bool, /// Art the reader left out (type, a placed file, non-native art, an image it can't read or /// place, a gradient it can't read): the symbol isn't kept, and its instances come in as the /// page draws them, within the box of the rest. diff --git a/docs/file-format-parity.md b/docs/file-format-parity.md index 75f47d7a1c..f5d5642861 100644 --- a/docs/file-format-parity.md +++ b/docs/file-format-parity.md @@ -137,8 +137,12 @@ private editing data. VectorCraft: symbols with 9-slice guides or pattern paint, instances in pattern tiles or in art cut to a clipping object, instances scaled almost flat, instances that turn, mirror or scale symbols holding type, live objects, instances written as their art, shapes with rounded live corners or strokes written as outlines or brush art, - instances that scale their symbol more than 100 times and instances on the layers of a large canvas are written as their art, pattern fills in a - symbol's art are written as their tiles cut to the shape, symbols past 4,096 are written only as their + instances that scale their symbol more than 100 times and instances on the layers of a large canvas are written as their art. Pattern fills in + large-canvas symbol art are written as their tiles cut to the shape. On normal canvases, supported pattern + fills in symbol definitions retain the shared pattern resource and their affine; VectorCraft declares that + coordinate convention in its own dictionary entry, while unmarked foreign symbol patterns keep the reader's + conservative fallback. Tile fallback transforms stroke outlines with the full pattern affine, including + strokes in opacity masks. Symbols past 4,096 are written only as their instances' art, and symbols' 9-slice guides and export types are left out, each with a warning. A dynamic symbol instance whose only changes of its own are its parts' changes is not written as its art when it otherwise qualifies: it stays a live instance. The symbol's dynamic type and the instance's changes From 940b869f2d21f2277e47b15c066c8e3dd5fa483e Mon Sep 17 00:00:00 2001 From: yoriswind Date: Fri, 4 Dec 2026 00:35:05 -0800 Subject: [PATCH 02/14] Gradients: sample a color into a freeform point --- crates/engine/src/lib.rs | 2 + crates/engine/src/session/documents.rs | 1 + crates/engine/src/tooling.rs | 38 +++++++- crates/tools/src/xform/eyedropper.rs | 51 ++++++++-- crates/ui-egui/src/dialogs/gradient_stop.rs | 101 ++++++++++++++++++-- crates/ui-egui/src/panels/gradient.rs | 10 +- docs/control-protocol.md | 4 +- 7 files changed, 188 insertions(+), 19 deletions(-) diff --git a/crates/engine/src/lib.rs b/crates/engine/src/lib.rs index 31cfe000de..eea2fc6238 100644 --- a/crates/engine/src/lib.rs +++ b/crates/engine/src/lib.rs @@ -97,6 +97,8 @@ pub struct Session { /// ([`Session::painting_tool`]); None for a stop of the selection's paint. A pick armed for /// such a stop samples only into a stop selected on that gradient, and otherwise ends. pub(crate) stop_pick: Option, + /// The point and document revision the Eyedropper was armed for. + freeform_point_pick: Option, /// Pointer and key input that came while the tool computed an edit on another thread, each with /// its number and view, made in order once the edit is applied. held_input: std::collections::VecDeque<(u64, tooling::HeldInput, ViewInfo)>, diff --git a/crates/engine/src/session/documents.rs b/crates/engine/src/session/documents.rs index 367334a008..031d4567d3 100644 --- a/crates/engine/src/session/documents.rs +++ b/crates/engine/src/session/documents.rs @@ -63,6 +63,7 @@ impl Session { lender: None, back_to_painter: None, stop_pick: None, + freeform_point_pick: None, held_input: Default::default(), input_count: 0, edit_started_by: None, diff --git a/crates/engine/src/tooling.rs b/crates/engine/src/tooling.rs index 05dde4c156..486564df80 100644 --- a/crates/engine/src/tooling.rs +++ b/crates/engine/src/tooling.rs @@ -10,6 +10,11 @@ use vectorcraft_tools::{Action, Cursor, Mods, Overlay, PointerEvent, PointerKind use crate::{EngineError, Prefs, Result, Session}; +pub(crate) struct FreeformPointPick { + document: (u64, u64, u64), + index: usize, +} + /// What a hover's lend decision holds for ([`Session::hover_tool_at`]). #[derive(Clone, Copy, PartialEq)] pub(crate) struct HoverKey { @@ -228,6 +233,7 @@ impl Session { self.tool = self.make_tool(id); // A pick is armed for a stop after its tool is chosen (`note_stop_pick`). self.stop_pick = None; + self.freeform_point_pick = None; if let Some(selection) = text_selection { self.tool.set_option("textSelection", &selection); } @@ -628,7 +634,7 @@ impl Session { appearance_item: self.appearance_item(), constrain_angle: self.prefs.constrain_angle, keyboard_increment: self.prefs.keyboard_increment, - freeform_point: self.selected_freeform_point(), + freeform_point: if self.tool.id() == "eyedropper" { self.pick_freeform_point() } else { self.selected_freeform_point() }, raster_sample: self.prefs.eyedropper.sample_size, preview_bounds: self.prefs.use_preview_bounds, scale_strokes: self.prefs.scale_strokes, @@ -1543,6 +1549,9 @@ impl Session { let sets_pressed = self.press_taken_by(self.tool.id()); self.tool.set_option(key, v); self.note_stop_pick(key, self.tool.id() == "eyedropper"); + if key == "freeformPoint" && self.tool.id() == "eyedropper" { + self.note_freeform_point_pick(v); + } self.tool_set_since_reset = true; self.keep_tool_settings(); self.keep_press_set(before_press, |k| sets_pressed && k == key, sets_pressed); @@ -1639,9 +1648,14 @@ impl Session { }; self.keep_press_set(before_press, |k| values.contains_key(k) && (sets_pressed || shared.contains(&k)), sets_pressed); // The Eyedropper waiting for a Cmd-drag it lent a selection tool to is armed as the active one. - if (active || lender) && values.contains_key("stop") { + if active || lender { let eyedropper = id.unwrap_or(self.tool.id()) == "eyedropper"; - self.note_stop_pick("stop", eyedropper); + if values.contains_key("stop") { + self.note_stop_pick("stop", eyedropper); + } + if eyedropper && let Some(v) = values.get("freeformPoint") { + self.note_freeform_point_pick(v); + } } out } @@ -1667,6 +1681,24 @@ impl Session { } } + fn note_freeform_point_pick(&mut self, option: &Value) { + self.freeform_point_pick = None; + if option.is_string() + && let Some(doc) = self.active() + && let Some(index) = self.selected_freeform_point() + && self.proxy_freeform(!self.fill_active).is_some_and(|(f, _)| index < f.points.len()) + { + self.freeform_point_pick = Some(FreeformPointPick { document: (doc.uid, doc.revision, doc.reverts), index }); + } + } + + /// An index can outlive its point after a deletion or another paint is applied. + fn pick_freeform_point(&self) -> Option { + let pick = self.freeform_point_pick.as_ref()?; + let doc = self.active()?; + self.selected_freeform_point().filter(|&index| index == pick.index && pick.document == (doc.uid, doc.revision, doc.reverts)) + } + /// The tool that took the press under way: the active tool, or the tool that lent a selection /// tool for it (a Cmd-drag), which the dropped press gives its options back to. fn pressed_tool(&self) -> Option<&dyn Tool> { diff --git a/crates/tools/src/xform/eyedropper.rs b/crates/tools/src/xform/eyedropper.rs index 6ef02bfd11..528578d8b7 100644 --- a/crates/tools/src/xform/eyedropper.rs +++ b/crates/tools/src/xform/eyedropper.rs @@ -56,6 +56,8 @@ use crate::{Action, Cursor, Mods, Overlay, PointerEvent, PointerKind, Tool, Tool pub struct EyedropperTool { /// Sampling for the selected gradient stop: the tool to switch back to afterwards. stop: Option, + /// Sampling for the selected freeform point: the tool to switch back to afterwards. + point: Option, /// The Type tool's highlighted range while sampling, including its selection overlay. text_selection: crate::text::TypeTool, /// Brush Options › Key Color (Hue Shift): sample into the dialog, then [`Self::stop`]. @@ -567,8 +569,14 @@ impl Tool for EyedropperTool { } Click::Back(back) => { self.stop = None; + self.point = None; vec![Action::SwitchTool(back)] } + Click::SamplePoint(color, _, index, back) => { + self.point = None; + let params = json!({ "index": index, "stroke": !cx.fill_active, "color": color_json(&color), "keepModel": true }); + vec![Action::Exec("paint.freeform.setPoint".into(), params), Action::SwitchTool(back)] + } Click::MeshPoints(id, points, color) => { let params = json!({ "id": id.0, "points": points, "color": color_json(&color), "keepModel": true }); vec![Action::Exec("object.mesh.setPointColor".into(), params)] @@ -605,6 +613,9 @@ impl Tool for EyedropperTool { let mut options = if selected.get("editing").is_some_and(|v| !v.is_null()) { selected } else { json!({}) }; if let Some(o) = options.as_object_mut() { o.insert("stop".into(), json!(self.stop)); + if let Some(back) = &self.point { + o.insert("freeformPoint".into(), json!(back)); + } o.insert("brushKeyColor".into(), json!(self.brush_key_color)); if let Some(binding) = &self.image_trace_ignore_color { o.insert("imageTraceIgnoreColor".into(), binding.clone()); @@ -621,7 +632,18 @@ impl Tool for EyedropperTool { /// Type tool or a tool that picks mesh points. fn set_option(&mut self, key: &str, value: &Value) { match key { - "stop" => self.stop = value.as_str().map(str::to_string), + "stop" => { + self.stop = value.as_str().map(str::to_string); + if self.stop.is_some() { + self.point = None; + } + } + "freeformPoint" => { + self.point = value.as_str().map(str::to_string); + if self.point.is_some() { + self.stop = None; + } + } "brushKeyColor" => self.brush_key_color = value.as_bool().unwrap_or(false), "imageTraceIgnoreColor" => self.image_trace_ignore_color = (!value.is_null()).then(|| value.clone()), "meshPoints" => self.mesh_points = crate::meshedit::points_of(value), @@ -633,7 +655,7 @@ impl Tool for EyedropperTool { fn check_option(&self, key: &str, value: &Value) -> Result<(), String> { use crate::option_check as c; match key { - "stop" => c::string_or_null(key, value), + "stop" | "freeformPoint" => c::string_or_null(key, value), "brushKeyColor" => c::boolean(key, value), "textSelection" => self.text_selection.check_option(key, value), _ => Err(c::unknown(key)), @@ -663,6 +685,9 @@ impl Tool for EyedropperTool { if key != ToolKey::Escape || !self.picking() { return vec![]; } + if let Some(back) = self.point.take() { + return vec![Action::SwitchTool(back)]; + } if let Some(binding) = self.image_trace_ignore_color.take() { let back = self.stop.take().unwrap_or_else(|| "selection".to_string()); return vec![Action::Dialog("imageTraceIgnoreColor".into(), json!({ "binding": binding, "cancel": true })), Action::SwitchTool(back)]; @@ -678,7 +703,7 @@ impl Tool for EyedropperTool { } fn returns_to(&self) -> Option<&str> { - self.stop.as_deref().filter(|_| !self.brush_key_color && self.image_trace_ignore_color.is_none()) + self.point.as_deref().or_else(|| self.stop.as_deref().filter(|_| !self.brush_key_color && self.image_trace_ignore_color.is_none())) } /// Escape is the tool's while a pick is armed, so it switches back and ends nothing else. @@ -697,9 +722,10 @@ enum Click { ImageTrace(Value), /// Brush Options › Key Color: this color, sampled from this object. BrushKeyColor(Color, NodeId), - /// A pick for a stop of the gradient a tool paints with (the Live Paint Bucket's, the Shape - /// Builder's fill) that is no longer selected switches back to that tool unsampled. + /// The pick's target is no longer valid. Return to the previous tool without sampling. Back(String), + /// This color, sampled from this object, goes to the armed freeform point. + SamplePoint(Color, NodeId, usize, String), /// The fill color goes to these points of this selected gradient mesh. MeshPoints(NodeId, Vec, Color), /// `appearance.copyFrom` this source, with `reverse` or `append` or neither. @@ -715,19 +741,28 @@ impl Click { fn object(&self) -> Option { match self { Click::ImageTrace(_) | Click::Back(_) => None, - Click::BrushKeyColor(_, id) | Click::MeshPoints(id, ..) | Click::CopyFrom(id, _) | Click::Sample { source: id, .. } => Some(*id), + Click::BrushKeyColor(_, id) + | Click::SamplePoint(_, id, ..) + | Click::MeshPoints(id, ..) + | Click::CopyFrom(id, _) + | Click::Sample { source: id, .. } => Some(*id), } } } impl EyedropperTool { - /// Is a gradient stop, Brush Key Color or Image Trace Ignore Color pick armed? + /// Is a gradient stop, freeform point, Brush Key Color or Image Trace Ignore Color pick armed? fn picking(&self) -> bool { - self.stop.is_some() || self.brush_key_color || self.image_trace_ignore_color.is_some() + self.stop.is_some() || self.point.is_some() || self.brush_key_color || self.image_trace_ignore_color.is_some() } /// What a click at `p` with `mods` does, or None when it does nothing. fn click(&self, cx: &ToolContext, p: Point, mods: Mods) -> Option { + if let Some(back) = &self.point { + let Some(index) = cx.freeform_point else { return Some(Click::Back(back.clone())) }; + let (color, source) = sample_at(cx, p)?; + return Some(Click::SamplePoint(color, source, index, back.clone())); + } if let Some(binding) = &self.image_trace_ignore_color { return Some(Click::ImageTrace(binding.clone())); } diff --git a/crates/ui-egui/src/dialogs/gradient_stop.rs b/crates/ui-egui/src/dialogs/gradient_stop.rs index 2ed369d2da..80476fcd1a 100644 --- a/crates/ui-egui/src/dialogs/gradient_stop.rs +++ b/crates/ui-egui/src/dialogs/gradient_stop.rs @@ -510,11 +510,12 @@ fn body(ui: &mut Ui, feed: &Feed, tab: &mut Tab, panel: &mut ColorPanelState, fi Entry::new(Tab::Swatches, tl!("Swatches").to_owned()).icon(IconId::new("swatch-book")), ]; Segmented::new("View", Bind::bound(&mut *tab), &tabs).show(ui); - // A stop's colour can come from the art, as from the Gradient panel's eyedropper. - if !feed.point { - let tip = tl!("Eyedropper: click the art to sample the stop's colour").to_owned(); - filed.eyedropper |= DropperButton::new(tip, Bind::given(false)).show(ui).edit.value() == Some(&true); - } + let tip = if feed.point { + tl!("Eyedropper: click the art to sample the point's colour") + } else { + tl!("Eyedropper: click the art to sample the stop's colour") + }; + filed.eyedropper |= DropperButton::new(tip.to_owned(), Bind::given(false)).show(ui).edit.value() == Some(&true); if *tab == Tab::Color { let (closed, picked) = mode_menu(ui, &feed.shown, panel.mode); outside |= closed; @@ -834,7 +835,10 @@ pub(crate) fn pump(app: &mut VectorcraftApp, ctx: &egui::Context) { } if filed.eyedropper { dialogs.with(|host| host.cancel_by_id(ctx, id)); - crate::panels::gradient::stop_eyedropper(app); + match target { + Target::Stop(..) => crate::panels::gradient::stop_eyedropper(app), + Target::Point(..) => crate::panels::gradient::point_eyedropper(app), + } return; } let updated = selected(app).filter(|target| owner.key.matches(app, target)).zip(app.session.gradient_edit_paints(!owner.key.fill).ok()); @@ -1722,6 +1726,91 @@ mod tests { assert!(!is_open(&app)); } + fn point_sampling_panel() -> (crate::tests::panel_harness::Panel, NodeId, NodeId, usize) { + let mut app = app(); + let target = app.session.active().unwrap().selection.objects[0]; + app.run("file.documentColorMode", json!({"mode": "cmyk"})).unwrap(); + app.run("paint.editGradient", json!({"kind": "freeform"})).unwrap(); + app.run("paint.freeform.addPoint", json!({"at": [150, 150], "color": "#0000ff"})).unwrap(); + let index = app.session.selected_freeform_point().unwrap(); + let source = app.run("shape.rectangle", json!({"x": 230, "y": 80, "width": 60, "height": 80})).unwrap()["id"].as_u64().unwrap(); + app.run("paint.setFill", json!({"color": "#00aa5a", "keepModel": true})).unwrap(); + app.run("select.set", json!({"ids": [target.0]})).unwrap(); + app.run("paint.freeform.selectPoint", json!({"index": index})).unwrap(); + let panel = crate::tests::panel_harness::Panel::new(app, |app, ui| { + app.dialogs().unwrap().with(|host| host.run(ui)); + host::pump(app, ui.ctx()); + }); + (panel, target, NodeId(source), index) + } + + fn arm_point_sample(panel: &mut crate::tests::panel_harness::Panel, index: usize) { + open_at(&mut panel.app(), index, Anchor::Screen(egui::pos2(200.0, 200.0))); + panel.frame(); + panel.click("Eyedropper: click the art to sample the point's colour"); + assert!(!is_open(&panel.app())); + assert_eq!(panel.app().session.tool_id(), "eyedropper"); + } + + fn click_sample_source(app: &mut VectorcraftApp) { + use vectorcraft_tools::{PointerEvent, PointerKind}; + let view = app.view_info(); + for kind in [PointerKind::Down, PointerKind::Up] { + let requests = app.session.pointer(&PointerEvent::new(kind, 250.0, 115.0), view).unwrap(); + crate::canvas::apply_requests(app, Ok(requests)); + } + } + + fn node_fill(app: &VectorcraftApp, id: NodeId) -> Paint { + app.session.active().unwrap().doc.node(id).unwrap().appearance.fill_paint() + } + + #[test] + fn freeform_point_eyedropper_preserves_the_sample_model_and_undoes_once() { + let (mut panel, target, source, index) = point_sampling_panel(); + let initial = node_fill(&panel.app(), target); + let source_fill = node_fill(&panel.app(), source); + let color = source_fill.color().unwrap(); + assert!(matches!(color, Color::Rgb { .. }), "the source stores RGB in a CMYK document"); + let points = |app: &VectorcraftApp| app.session.proxy_freeform(false).unwrap().0.points; + let mut expected = points(&panel.app()); + assert_ne!(expected[index].color, color); + + arm_point_sample(&mut panel, index); + click_sample_source(&mut panel.app()); + assert_eq!(panel.app().session.tool_id(), "gradient"); + expected[index].color = color; + assert_eq!(points(&panel.app()), expected, "only the point's color changes"); + assert_eq!(node_fill(&panel.app(), source), source_fill); + panel.app().run("edit.undo", json!({})).unwrap(); + assert_eq!(node_fill(&panel.app(), target), initial); + } + + #[test] + fn freeform_point_eyedropper_cancels_and_skips_a_replaced_point() { + let (mut panel, target, source, index) = point_sampling_panel(); + let initial = node_fill(&panel.app(), target); + let source_fill = node_fill(&panel.app(), source); + + arm_point_sample(&mut panel, index); + let escape = egui::Event::Key { key: Key::Escape, physical_key: None, pressed: true, repeat: false, modifiers: Modifiers::NONE }; + let ctx = ctx(&panel.app()); + crate::tests::synthetic::key_frame(&mut panel.app(), &ctx, vec![escape]); + assert_eq!(panel.app().session.tool_id(), "gradient"); + assert_eq!(node_fill(&panel.app(), target), initial); + + arm_point_sample(&mut panel, index); + panel.app().run("paint.freeform.deletePoint", json!({"index": index})).unwrap(); + let replacement = panel.app().run("paint.freeform.addPoint", json!({"at": [155, 150], "color": "#ffa000"})).unwrap(); + assert_eq!(replacement["index"].as_u64(), Some(index as u64), "the replacement uses the old index"); + let before_pick = node_fill(&panel.app(), target); + assert_eq!(panel.app().session.tool_id(), "eyedropper"); + click_sample_source(&mut panel.app()); + assert_eq!(panel.app().session.tool_id(), "gradient"); + assert_eq!(node_fill(&panel.app(), target), before_pick); + assert_eq!(node_fill(&panel.app(), source), source_fill); + } + #[test] fn the_popover_closes_when_its_stop_goes_away() { let mut app = app(); diff --git a/crates/ui-egui/src/panels/gradient.rs b/crates/ui-egui/src/panels/gradient.rs index 9d6088cbd3..08025b0731 100644 --- a/crates/ui-egui/src/panels/gradient.rs +++ b/crates/ui-egui/src/panels/gradient.rs @@ -915,10 +915,18 @@ fn stops_editor(app: &mut VectorcraftApp, ui: &mut Ui, g: &GradientPaint, is_gra /// selected stop, then hands back to the current tool (or, while a pick is already armed, to the /// tool that armed it). pub(crate) fn stop_eyedropper(app: &mut VectorcraftApp) { + gradient_eyedropper(app, "stop"); +} + +pub(crate) fn point_eyedropper(app: &mut VectorcraftApp) { + gradient_eyedropper(app, "freeformPoint"); +} + +fn gradient_eyedropper(app: &mut VectorcraftApp, option: &str) { let tool = app.session.tool_id(); let back = (tool == "eyedropper").then(|| app.session.tool_returns_to()).flatten().unwrap_or_else(|| tool.to_string()); app.select_tool("eyedropper"); - app.session.set_tool_option("stop", &json!(back)); + app.session.set_tool_option(option, &json!(back)); } /// Open the stop popover for stop `i` at screen position `at`, the stop selected first. diff --git a/docs/control-protocol.md b/docs/control-protocol.md index 71e3d0fae9..5fe0d3ab01 100644 --- a/docs/control-protocol.md +++ b/docs/control-protocol.md @@ -187,7 +187,9 @@ or point selected, it paints the inactive Fill or Stroke. Freeform gradients: double-clicking a point with the Gradient tool opens the same `gradientStop` popover on the selected point (`paint.freeform.selectPoint`); its fields are `color` (hex), `opacity` and `spread` (percentages), applied by -`ui.dialog.confirm` through `paint.freeform.setPoint`. `ui.key` Escape ends the line Lines mode is drawing. +`ui.dialog.confirm` through `paint.freeform.setPoint`. Its eyedropper chooses the Eyedropper tool and sets the +`freeformPoint` option to the tool to return to. The next click on art samples its color into the same point if it +is still current. Escape cancels a pick and switches back. When drawing a line, `ui.key` Escape ends that line. Tool options: double-clicking a tool button runs `tool.options {tool}`. For `gradient` it opens the Gradient panel; for `eyedropper` it opens Eyedropper Options, an `eyedropperOptions` dialog (fields `sampleSize` 1/3/5, `pickUp` and From 2d0f5f97260abc9b0450e12f7c46af80854837aa Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Fri, 4 Dec 2026 14:45:10 -0800 Subject: [PATCH 03/14] DXF Import: a failed DWG Replace keeps the user's selection Placing a DWG drawing with Replace selects the object it swaps again at OK. When the drawing was then not placed (an error while it was read, or Cancel), that object stayed selected and the selection the user made since Place started was lost. - The user's selection comes back with select.set, with its anchors and symbol part, when the read fails or is canceled, unless the document changed since OK (a selection made since then is kept). - Cancel restores the selection of the document the drawing was placed in without switching documents, and not after File > Revert. - The current layer stays current. --- crates/engine/src/session/edit.rs | 16 +++++- crates/ui-egui/src/dialogs/dxf_import.rs | 68 +++++++++++++++++++++++- crates/ui-egui/src/placing.rs | 55 +++++++++++++++++++ 3 files changed, 137 insertions(+), 2 deletions(-) diff --git a/crates/engine/src/session/edit.rs b/crates/engine/src/session/edit.rs index 12f8cbe879..1f47de5f91 100644 --- a/crates/engine/src/session/edit.rs +++ b/crates/engine/src/session/edit.rs @@ -240,8 +240,22 @@ impl Session { fn select_unwatched(&mut self, f: impl FnOnce(&Document, &mut Selection)) -> Result<()> { self.active_appearance_item = None; + let uid = self.doc()?.uid; + self.select_document_unwatched(uid, f) + } + + /// Change the selection in an open document without switching the active document. + pub fn select_in_document(&mut self, uid: u64, f: impl FnOnce(&Document, &mut Selection)) -> Result<()> { + if self.active().is_some_and(|st| st.uid == uid) { + return self.select(f); + } + self.select_document_unwatched(uid, f) + } + + /// Apply the selection filters and update the editing state of document `uid`. + fn select_document_unwatched(&mut self, uid: u64, f: impl FnOnce(&Document, &mut Selection)) -> Result<()> { let menu = self.menu.clone(); - let st = self.doc_mut()?; + let st = self.document_mut(uid).ok_or(EngineError::NoDocument)?; let before = st.selection.objects.clone(); let new_art = st.selection.new_art.clone(); let record = if st.selection_record().is_some() { st.selection_record.take() } else { None }; diff --git a/crates/ui-egui/src/dialogs/dxf_import.rs b/crates/ui-egui/src/dialogs/dxf_import.rs index a01076a838..d7e4390bc7 100644 --- a/crates/ui-egui/src/dialogs/dxf_import.rs +++ b/crates/ui-egui/src/dialogs/dxf_import.rs @@ -504,14 +504,19 @@ fn confirm(app: &mut VectorcraftApp, source: &Source, choices: &DxfChoices) -> R // Where new art goes now is taken before Replace selects the object it swaps again. let current = placement.and_then(|_| crate::placing::Insertion::of(app)); // A drawing converted off the UI thread replaces the object selected when Place - // started, selected again, unless it changed meanwhile. + // started, selected again, unless it changed meanwhile. When the drawing is not placed, + // the user's selection comes back. + let mut user_selection = None; if let Some((old, node)) = placement.and_then(|pl| pl.replaced.as_ref()) { let st = app.session.doc().map_err(|e| e.to_string())?; if st.doc.node(*old) != Some(node) { return Err("replace: the object to replace was changed or deleted".into()); } if st.selection.objects != [*old] || st.selection.symbol_part.is_some() { + let user = st.selection.clone(); app.session.execute("select.set", &json!({ "ids": [old.0] })).map_err(|e| e.to_string())?; + let st = app.session.doc().map_err(|e| e.to_string())?; + user_selection = Some(crate::placing::Reselect { doc: st.uid, revision: st.revision, user }); } } // It goes where new art went when Place started, and what the user changed since is @@ -524,11 +529,18 @@ fn confirm(app: &mut VectorcraftApp, source: &Source, choices: &DxfChoices) -> R if let Some(converted) = &source.converted { app.placing.keep_next = Some(Box::new(converted.held.clone())); } + app.placing.select_on_failure = user_selection.clone(); let r = crate::place::run_for_user(app, &p).map(|_| ()); app.placing.keep_next = None; + app.placing.select_on_failure = None; if let (Some(current), Some(insertion)) = (current, restore) { current.restore_changed(&insertion, app); } + if r.is_err() + && let Some(back) = &user_selection + { + crate::placing::reselect(app, back); + } r } None => { @@ -1003,6 +1015,60 @@ mod tests { crate::place::run_for_user(&mut app, &json!({ "path": plan, "replace": true })).unwrap(); assert!(app.opening.converting.is_empty()); assert!(app.ui.status.contains("select the one object to replace"), "{}", app.ui.status); + // A Replace that fails keeps the selection the user made since Place started. + let replaced = rect(&mut app, 90.0); + crate::place::run_for_user(&mut app, &json!({ "path": plan, "replace": true })).unwrap(); + let selected_since = rect(&mut app, 130.0); + finish_conversions(&mut app); + set(&app, "layout", json!("No such layout")); + let undo = undo_steps(&app, first); + let _ = host::confirm(&mut app, KIND); + placed(&mut app); + assert!(app.ui.status.contains("no layout"), "{}", app.ui.status); + let st = app.session.doc().unwrap(); + assert!(st.doc.node(replaced).is_some(), "the object is not replaced"); + assert_eq!(st.selection.objects, vec![selected_since], "the selection made since Place started is kept"); + assert_eq!(undo_steps(&app, first), undo); + host::cancel(&app, KIND); + // A selection made while the drawing is read is kept too. + crate::place::run_for_user(&mut app, &json!({ "path": plan, "replace": true })).unwrap(); + rect(&mut app, 170.0); + finish_conversions(&mut app); + set(&app, "layout", json!("No such layout")); + let _ = host::confirm(&mut app, KIND); + app.run("select.set", json!({ "ids": [replaced.0] })).unwrap(); + placed(&mut app); + assert_eq!(app.session.doc().unwrap().selection.objects, vec![replaced], "the selection made since OK is kept"); + host::cancel(&app, KIND); + // Selecting the replacement target again after OK keeps that selection on failure. + crate::place::run_for_user(&mut app, &json!({ "path": plan, "replace": true })).unwrap(); + rect(&mut app, 210.0); + finish_conversions(&mut app); + set(&app, "layout", json!("No such layout")); + let _ = host::confirm(&mut app, KIND); + app.run("select.set", json!({ "ids": [replaced.0] })).unwrap(); + placed(&mut app); + assert_eq!(app.session.doc().unwrap().selection.objects, vec![replaced], "the target selected again since OK is kept"); + host::cancel(&app, KIND); + // Cancel restores the source document's selection while another document stays active. + crate::place::run_for_user(&mut app, &json!({ "path": plan, "replace": true })).unwrap(); + let selected_since = rect(&mut app, 250.0); + finish_conversions(&mut app); + set(&app, "layout", json!("No such layout")); + let _ = host::confirm(&mut app, KIND); + let other_index = app.session.documents().iter().position(|st| st.uid == other).unwrap(); + let undo = undo_steps(&app, first); + app.session.set_active(other_index); + let other_selection = app.session.doc().unwrap().selection.clone(); + assert_eq!(crate::placing::cancel_all(&mut app)["cancelled"], 1); + assert_eq!(app.session.doc().unwrap().uid, other); + assert_eq!(app.session.doc().unwrap().selection, other_selection); + let st = app.session.documents().iter().find(|st| st.uid == first).unwrap(); + assert_eq!(st.selection.objects, vec![selected_since], "Cancel restores the background document's selection"); + assert_eq!(st.history.undo.len(), undo); + host::cancel(&app, KIND); + let first_index = app.session.documents().iter().position(|st| st.uid == first).unwrap(); + app.session.set_active(first_index); // Closed meanwhile. crate::place::run_for_user(&mut app, &json!({ "path": plan })).unwrap(); app.session.execute("file.close", &json!({})).unwrap(); diff --git a/crates/ui-egui/src/placing.rs b/crates/ui-egui/src/placing.rs index a1eeb20879..a3ee2d62a9 100644 --- a/crates/ui-egui/src/placing.rs +++ b/crates/ui-egui/src/placing.rs @@ -184,6 +184,19 @@ pub struct Pending { pub(crate) started: f64, /// What stays alive until this entry is removed ([`Placing::keep_next`]). _keep: Option>, + /// The selection its document gets back when the file is not placed ([`Placing::select_on_failure`]). + select_on_failure: Option, +} + +/// The user's selection, which a Replace swapped for the object it replaces ([`Placing::select_on_failure`]). +#[derive(Clone)] +pub(crate) struct Reselect { + /// The document whose selection Replace changed. + pub(crate) doc: u64, + /// The document's revision after Replace selected its object. + pub(crate) revision: u64, + /// The user's selection before it. + pub(crate) user: vectorcraft_doc::Selection, } #[cfg(test)] @@ -202,6 +215,10 @@ pub struct Placing { /// dropped: the conversion of a DWG drawing placed through its import options, which the read /// then finds without converting the drawing again. pub(crate) keep_next: Option>, + /// The selection the next read started ([`spawn_labeled`]) gives its document back when its + /// file is not placed: the user's selection before a DWG drawing's Replace selected the object + /// it swaps again. + pub(crate) select_on_failure: Option, /// A deferred paste awaiting its own Swatch Conflict dialog. swatch_paste: Option, /// Set by unit tests whose app reads the files the user places off the UI thread. @@ -432,6 +449,7 @@ fn spawn_labeled( app.placing.lane.push(&*jobs, "vectorcraft-place", job); let started = crate::export_progress::now(app); let keep = app.placing.keep_next.take(); + let select_on_failure = app.placing.select_on_failure.take(); app.placing.pending.push(Pending { name, label: label.clone(), @@ -446,6 +464,7 @@ fn spawn_labeled( hidden: false, started, _keep: keep, + select_on_failure, }); let status = format!("{label}…"); app.status(status.clone()); @@ -559,6 +578,11 @@ fn finish(app: &mut VectorcraftApp, p: &Pending, r: Result) { Ok(Read::Paste(paste)) => return finish_paste(app, *paste), Err(e) => Err(e), }; + if r.is_err() + && let Some(back) = &p.select_on_failure + { + reselect(app, back); + } app.sync_views(); let name = &p.name; match r { @@ -568,6 +592,32 @@ fn finish(app: &mut VectorcraftApp, p: &Pending, r: Result) { } } +/// Restore the user's selection while the document's revision is unchanged and its objects still exist. +/// The selection filters apply, and the current layer and active document stay current. +pub(crate) fn reselect(app: &mut VectorcraftApp, back: &Reselect) { + let Some(st) = app.session.documents().iter().find(|st| st.uid == back.doc) else { return }; + if st.revision != back.revision || !back.user.objects.iter().all(|id| st.doc.node(*id).is_some()) { + return; + } + let layer = st.active_layer; + let r = if app.session.active().is_some_and(|st| st.uid == back.doc) { + let ids: Vec = back.user.objects.iter().map(|id| id.0).collect(); + app.session.execute("select.set", &json!({ "ids": ids })).map(|_| ()) + } else { + app.session.select_in_document(back.doc, |_, sel| sel.set(back.user.objects.iter().copied())) + }; + if let Err(e) = r { + app.status(e.to_string()); + return; + } + if let Some(st) = app.session.document_mut(back.doc) { + if st.selection.objects == back.user.objects { + st.selection = back.user.clone(); + } + st.active_layer = layer; + } +} + /// Run a paste whose bitmap was decoded off the UI thread, in its document, which is the active one: /// the image replaces the internal clipboard, the objects selected when the paste started are /// selected again, and the paste command runs as it runs at once ([`VectorcraftApp::run`]), into @@ -846,6 +896,11 @@ pub fn cancel_all(app: &mut VectorcraftApp) -> Value { if !app.placing.pending[i].paste { let p = app.placing.pending.remove(i); p.token.cancel(); + if let Some(back) = &p.select_on_failure + && app.session.documents().iter().any(|st| st.uid == p.doc && st.reverts == p.reverts) + { + reselect(app, back); + } if app.ui.status == format!("{}…", p.label) { app.ui.status.clear(); } From 308e672673669c94c5ab6b66149999c05f3e672a Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Fri, 4 Dec 2026 15:28:47 -0800 Subject: [PATCH 04/14] DXF Import: a restored selection goes through the selection filters When a DWG Replace fails or is canceled, the user's whole selection now goes back through the selection filters as they are at that moment: ruler guides locked since are left out, hidden or locked slices stay out, and new art on a locked artboard is selected again as new art. Before, only the object ids went through the filters and the guides and slices were copied back, while new art on a locked artboard was dropped. Session::restore_selection gives a document back a saved selection through those filters. The dxf_import test that covers a selection made after OK now selects a different object instead of the Replace target. --- crates/engine/src/session/edit.rs | 10 +++++++ crates/ui-egui/src/dialogs/dxf_import.rs | 4 +-- crates/ui-egui/src/placing.rs | 14 ++------- crates/ui-egui/src/placing/tests.rs | 37 ++++++++++++++++++++++++ 4 files changed, 52 insertions(+), 13 deletions(-) diff --git a/crates/engine/src/session/edit.rs b/crates/engine/src/session/edit.rs index 1f47de5f91..c299347654 100644 --- a/crates/engine/src/session/edit.rs +++ b/crates/engine/src/session/edit.rs @@ -252,6 +252,16 @@ impl Session { self.select_document_unwatched(uid, f) } + /// Give document `uid` back a selection it had, new art included, through the selection + /// filters as they are now: guides locked since, hidden or locked slices and art on a locked + /// artboard that is not new art are left out. + pub fn restore_selection(&mut self, uid: u64, selection: Selection) -> Result<()> { + let st = self.document_mut(uid).ok_or(EngineError::NoDocument)?; + st.selection_record = None; + st.selection = selection; + self.select_in_document(uid, |_, _| {}) + } + /// Apply the selection filters and update the editing state of document `uid`. fn select_document_unwatched(&mut self, uid: u64, f: impl FnOnce(&Document, &mut Selection)) -> Result<()> { let menu = self.menu.clone(); diff --git a/crates/ui-egui/src/dialogs/dxf_import.rs b/crates/ui-egui/src/dialogs/dxf_import.rs index d7e4390bc7..737623f09e 100644 --- a/crates/ui-egui/src/dialogs/dxf_import.rs +++ b/crates/ui-egui/src/dialogs/dxf_import.rs @@ -1036,9 +1036,9 @@ mod tests { finish_conversions(&mut app); set(&app, "layout", json!("No such layout")); let _ = host::confirm(&mut app, KIND); - app.run("select.set", json!({ "ids": [replaced.0] })).unwrap(); + app.run("select.set", json!({ "ids": [selected_since.0] })).unwrap(); placed(&mut app); - assert_eq!(app.session.doc().unwrap().selection.objects, vec![replaced], "the selection made since OK is kept"); + assert_eq!(app.session.doc().unwrap().selection.objects, vec![selected_since], "the selection made since OK is kept"); host::cancel(&app, KIND); // Selecting the replacement target again after OK keeps that selection on failure. crate::place::run_for_user(&mut app, &json!({ "path": plan, "replace": true })).unwrap(); diff --git a/crates/ui-egui/src/placing.rs b/crates/ui-egui/src/placing.rs index a3ee2d62a9..8bb2d58cce 100644 --- a/crates/ui-egui/src/placing.rs +++ b/crates/ui-egui/src/placing.rs @@ -593,27 +593,19 @@ fn finish(app: &mut VectorcraftApp, p: &Pending, r: Result) { } /// Restore the user's selection while the document's revision is unchanged and its objects still exist. -/// The selection filters apply, and the current layer and active document stay current. +/// The whole selection, guides, slices and new art included, goes through the selection filters as +/// they are now, and the current layer and active document stay current. pub(crate) fn reselect(app: &mut VectorcraftApp, back: &Reselect) { let Some(st) = app.session.documents().iter().find(|st| st.uid == back.doc) else { return }; if st.revision != back.revision || !back.user.objects.iter().all(|id| st.doc.node(*id).is_some()) { return; } let layer = st.active_layer; - let r = if app.session.active().is_some_and(|st| st.uid == back.doc) { - let ids: Vec = back.user.objects.iter().map(|id| id.0).collect(); - app.session.execute("select.set", &json!({ "ids": ids })).map(|_| ()) - } else { - app.session.select_in_document(back.doc, |_, sel| sel.set(back.user.objects.iter().copied())) - }; - if let Err(e) = r { + if let Err(e) = app.session.restore_selection(back.doc, back.user.clone()) { app.status(e.to_string()); return; } if let Some(st) = app.session.document_mut(back.doc) { - if st.selection.objects == back.user.objects { - st.selection = back.user.clone(); - } st.active_layer = layer; } } diff --git a/crates/ui-egui/src/placing/tests.rs b/crates/ui-egui/src/placing/tests.rs index dc6a19e0fc..434f47e51e 100644 --- a/crates/ui-egui/src/placing/tests.rs +++ b/crates/ui-egui/src/placing/tests.rs @@ -2060,3 +2060,40 @@ fn cancelling_a_place_places_nothing() { assert_eq!(names(&app), initial_names, "no document nodes mutated or added"); assert_eq!(app.session.doc().unwrap().history.undo.len(), 0, "no undo step added"); } + +/// The selection a failed Replace gives back, after the object it swaps was selected in its place. +fn swapped_out(app: &mut VectorcraftApp, other: NodeId) -> Reselect { + let user = app.session.doc().unwrap().selection.clone(); + app.run("select.set", json!({"ids": [other.0]})).unwrap(); + let st = app.session.doc().unwrap(); + Reselect { doc: st.uid, revision: st.revision, user } +} + +#[test] +fn a_restored_selection_leaves_out_guides_locked_since() { + let mut app = app(false); + let other = NodeId(app.run("shape.rectangle", json!({"x": 60, "y": 10, "width": 20, "height": 20})).unwrap()["id"].as_u64().unwrap()); + app.run("guide.add", json!({"vertical": true, "pos": 40})).unwrap(); + app.run("select.set", json!({"ids": []})).unwrap(); + app.run("guide.select", json!({"indexes": [0]})).unwrap(); + assert_eq!(app.session.doc().unwrap().selection.guides.len(), 1, "the ruler guide is selected"); + let mut back = swapped_out(&mut app, other); + app.run("view.guides.lock", json!({"locked": true})).unwrap(); + back.revision = app.session.doc().unwrap().revision; + reselect(&mut app, &back); + assert!(app.session.doc().unwrap().selection.guides.is_empty(), "the locked guide is not selected again"); +} + +#[test] +fn a_restored_selection_keeps_new_art_on_a_locked_artboard() { + let mut app = app(false); + app.run("artboard.setProps", json!({"index": 0, "locked": true})).unwrap(); + let mut rect = |x| NodeId(app.run("shape.rectangle", json!({"x": x, "y": 10, "width": 20, "height": 20})).unwrap()["id"].as_u64().unwrap()); + let (other, drawn) = (rect(60.0), rect(10.0)); + assert_eq!(app.session.doc().unwrap().selection.objects, vec![drawn], "new art is selected"); + let back = swapped_out(&mut app, other); + reselect(&mut app, &back); + let st = app.session.doc().unwrap(); + assert_eq!(st.selection.objects, vec![drawn], "the new art is selected again"); + assert!(st.selection.new_art.contains(&drawn), "it is still new art"); +} From 9d8ecd1341de0afde2ff1d12dbcd625324d6932e Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Fri, 4 Dec 2026 22:35:37 -0800 Subject: [PATCH 05/14] DXF Import: a failed Replace restores the selection after unrelated edits The user's selection came back only while the document revision was unchanged, so a Replace whose rollback raised the revision, or any edit that left the selection alone, kept the swapped object selected. DocState now counts selection changes (`selections`): every Session::select, Undo and Redo, leaving isolation, and any command or batch step that leaves another selection. A failed command that selected its ids first puts the count back with the selection. The selection comes back when the count, the selection, the isolation and the user's objects are unchanged; a symbol part needs the art unchanged. --- crates/engine/src/cmd/edit.rs | 2 + crates/engine/src/cmd/object/arrange.rs | 2 + crates/engine/src/doc_state.rs | 4 + crates/engine/src/session/edit.rs | 1 + crates/engine/src/session/execute.rs | 29 +++- crates/engine/src/session/undo.rs | 2 + crates/ui-egui/src/dialogs/dxf_import.rs | 9 +- crates/ui-egui/src/placing.rs | 26 +++- crates/ui-egui/src/placing/tests.rs | 164 ++++++++++++++++++++++- 9 files changed, 228 insertions(+), 11 deletions(-) diff --git a/crates/engine/src/cmd/edit.rs b/crates/engine/src/cmd/edit.rs index 55726c31c9..52330c1dde 100644 --- a/crates/engine/src/cmd/edit.rs +++ b/crates/engine/src/cmd/edit.rs @@ -835,6 +835,7 @@ fn undo(s: &mut Session, _: &Value) -> Result { let doc = std::mem::replace(&mut st.doc, e.doc); keep_unrecorded(&doc, &e.unrecorded, &mut st.doc); let selection = std::mem::replace(&mut st.selection, Arc::unwrap_or_clone(e.selection)); + st.selections = st.selections.wrapping_add(1); let selection = shared_selection(selection, st.history.redo.last()); let mut turned = crate::HistoryEntry::turned(e.label, doc, selection, &st.doc, costs); turned.named = e.named; @@ -873,6 +874,7 @@ fn redo(s: &mut Session, _: &Value) -> Result { let doc = std::mem::replace(&mut st.doc, e.doc); keep_unrecorded(&doc, &e.unrecorded, &mut st.doc); let selection = std::mem::replace(&mut st.selection, Arc::unwrap_or_clone(e.selection)); + st.selections = st.selections.wrapping_add(1); let selection = shared_selection(selection, st.history.undo.last()); let mut turned = crate::HistoryEntry::turned(e.label, doc, selection, &st.doc, costs); turned.named = e.named; diff --git a/crates/engine/src/cmd/object/arrange.rs b/crates/engine/src/cmd/object/arrange.rs index 8ed4656295..f234f4f0b9 100644 --- a/crates/engine/src/cmd/object/arrange.rs +++ b/crates/engine/src/cmd/object/arrange.rs @@ -457,6 +457,7 @@ pub(super) fn exit_isolation(s: &mut Session, p: &Value) -> Result { crate::cmd::distortcmds::finish_edit_text(st, inner); st.isolation = Some(layer); st.selection.set([left]); + st.selections = st.selections.wrapping_add(1); st.revision += 1; return ok(); } @@ -494,6 +495,7 @@ pub(super) fn exit_isolation(s: &mut Session, p: &Value) -> Result { crate::cmd::distortcmds::finish_edit_text(st, i); let target = st.doc.parent_of(left).filter(|p| st.doc.node(*p).is_some_and(|n| n.extras().shaper.is_some())).unwrap_or(left); st.selection.set([target]); + st.selections = st.selections.wrapping_add(1); // A guide path isolated while Lock Guides is on isn't selected (#1534). crate::deselect_hidden(&menu, &st.doc, &mut st.selection); // The art on a locked artboard can't be selected. diff --git a/crates/engine/src/doc_state.rs b/crates/engine/src/doc_state.rs index 501cb6cd53..f31b7f8152 100644 --- a/crates/engine/src/doc_state.rs +++ b/crates/engine/src/doc_state.rs @@ -51,6 +51,9 @@ pub struct DocState { /// Increments on every change (also selection and view-only changes); UIs re-render when it /// moves. Not a dirty flag: see [`DocState::is_dirty`]. pub revision: u64, + /// Increments each time the selection is set through [`crate::Session::select`] and the other + /// selection entries, even when it ends as it was. Not saved, not undoable. + pub selections: u64, /// The document as last saved (or opened). Structural sharing makes "unchanged" a pointer /// comparison, and undoing back to the saved state counts as clean. pub(crate) saved_doc: Arc, @@ -535,6 +538,7 @@ impl DocState { history: History { limit: 500, ..Default::default() }, path, revision: 1, + selections: 0, active_layer, layer_rows: vec![], layers_reveal: None, diff --git a/crates/engine/src/session/edit.rs b/crates/engine/src/session/edit.rs index c299347654..bcb09c0b66 100644 --- a/crates/engine/src/session/edit.rs +++ b/crates/engine/src/session/edit.rs @@ -306,6 +306,7 @@ impl Session { st.layer_rows.clear(); } st.revision += 1; + st.selections = st.selections.wrapping_add(1); // Puppet Warp pins belong to the art they were placed on: another selection starts afresh. if st.doc.puppet.as_ref().is_some_and(|p| p.ids != st.selection.objects) { cmd::distortcmds::drop_puppet_pins(st); diff --git a/crates/engine/src/session/execute.rs b/crates/engine/src/session/execute.rs index 25a9b278b1..fde26a790d 100644 --- a/crates/engine/src/session/execute.rs +++ b/crates/engine/src/session/execute.rs @@ -24,6 +24,16 @@ fn with_settled_warnings(mut r: Value, settled: &[String]) -> Value { r } +/// What [`Session::execute`] compares to tell that a command changed the selection: the counts of +/// what is selected and the first and last object, guide and slice, read in constant time. +type SelectionSummary = ([usize; 5], [Option; 6], bool); + +fn selection_summary(s: &Selection) -> SelectionSummary { + let counts = [s.objects.len(), s.anchors.len(), s.segments.len(), s.guides.len(), s.slices.len()]; + let ends = [s.objects.first(), s.objects.last(), s.guides.first(), s.guides.last(), s.slices.first(), s.slices.last()].map(|id| id.copied()); + (counts, ends, s.symbol_part.is_some()) +} + impl Session { /// Run a command callback and keep warnings from every preview it settles or restores. pub(crate) fn command_with_settled_warnings(&mut self, f: impl FnOnce(&mut Self) -> Result) -> Result { @@ -72,7 +82,19 @@ impl Session { if self.plugins_loading() && crate::waits_for_plugin_loads(id) { self.finish_plugin_loads(); } - self.revealing(|s| s.execute_unwatched(id, params)) + // A command, a step of a batch included, that leaves the active document with another + // selection counts as a selection change ([`crate::DocState::selections`]), whichever way + // it wrote the selection. The selections are compared by a summary that takes constant time. + let before = self.active().map(|st| (st.uid, st.selections, selection_summary(&st.selection))); + let r = self.revealing(|s| s.execute_unwatched(id, params)); + if let Some((uid, selections, summary)) = before + && let Some(st) = self.document_mut(uid) + && st.selections == selections + && selection_summary(&st.selection) != summary + { + st.selections = st.selections.wrapping_add(1); + } + r } /// Run `f`, a top-level entry that changes the active document's rows, current layer or @@ -230,7 +252,7 @@ impl Session { params.get("ids").filter(|v| !v.is_null()).cloned().or_else(|| given.map(|ids| ids.iter().map(|i| i.0).collect::>().into())) }) .flatten(); - let selected_before = select_first.as_ref().and(self.active()).map(|d| (d.uid, d.selection.clone(), d.active_layer)); + let selected_before = select_first.as_ref().and(self.active()).map(|d| (d.uid, d.selection.clone(), d.active_layer, d.selections)); // Only a selection command that changes the selection loads its paints for new art: other // commands, and clicking what is already selected, keep a sampled paint in the proxies. let selection_was = (id.starts_with("select.") || id == "layer.target").then(|| self.active().map(|d| d.selection.clone())).flatten(); @@ -240,11 +262,12 @@ impl Session { } let r = cmd::run_spec(s, spec, run_params); if r.is_err() - && let Some((uid, selection, layer)) = selected_before + && let Some((uid, selection, layer, selections)) = selected_before && let Some(st) = s.docs.iter_mut().find(|d| d.uid == uid) { st.selection = selection; st.active_layer = layer; + st.selections = selections; st.revision += 1; } r diff --git a/crates/engine/src/session/undo.rs b/crates/engine/src/session/undo.rs index bf7b0bf6f7..946af081fa 100644 --- a/crates/engine/src/session/undo.rs +++ b/crates/engine/src/session/undo.rs @@ -118,6 +118,7 @@ impl Session { } let undone = std::mem::replace(&mut st.doc, e.doc); st.selection = Arc::unwrap_or_clone(e.selection); + st.selections = st.selections.wrapping_add(1); deselect_hidden(&self.menu, &st.doc, &mut st.selection); st.restore_isolation(g.isolation, &undone); st.sync_new_art(); @@ -275,6 +276,7 @@ impl Session { } let undone = std::mem::replace(&mut st.doc, doc); st.selection = selection; + st.selections = st.selections.wrapping_add(1); st.restore_isolation(scope.isolation, &undone); cmd::globaledit::follow_history(st); st.drop_stale_variables_highlight(); diff --git a/crates/ui-egui/src/dialogs/dxf_import.rs b/crates/ui-egui/src/dialogs/dxf_import.rs index 737623f09e..55f35d97ff 100644 --- a/crates/ui-egui/src/dialogs/dxf_import.rs +++ b/crates/ui-egui/src/dialogs/dxf_import.rs @@ -516,7 +516,14 @@ fn confirm(app: &mut VectorcraftApp, source: &Source, choices: &DxfChoices) -> R let user = st.selection.clone(); app.session.execute("select.set", &json!({ "ids": [old.0] })).map_err(|e| e.to_string())?; let st = app.session.doc().map_err(|e| e.to_string())?; - user_selection = Some(crate::placing::Reselect { doc: st.uid, revision: st.revision, user }); + user_selection = Some(crate::placing::Reselect { + doc: st.uid, + swapped: st.selection.clone(), + selections: st.selections, + art: st.doc.clone(), + isolation: st.isolation, + user, + }); } } // It goes where new art went when Place started, and what the user changed since is diff --git a/crates/ui-egui/src/placing.rs b/crates/ui-egui/src/placing.rs index 8bb2d58cce..e27bc07b23 100644 --- a/crates/ui-egui/src/placing.rs +++ b/crates/ui-egui/src/placing.rs @@ -193,8 +193,16 @@ pub struct Pending { pub(crate) struct Reselect { /// The document whose selection Replace changed. pub(crate) doc: u64, - /// The document's revision after Replace selected its object. - pub(crate) revision: u64, + /// The selection Replace made: the object it swaps. + pub(crate) swapped: vectorcraft_doc::Selection, + /// The document's selection count ([`vectorcraft_engine::DocState::selections`]) after it. + /// The user's selection comes back only while neither changed, whatever else was edited. + pub(crate) selections: u64, + /// The art then: the user's selection comes back only while each object it holds is as it + /// was, so that its selected anchors and segments still name the same points. + pub(crate) art: std::sync::Arc, + /// The group or layer isolated then: the user's selection comes back only in the same isolation. + pub(crate) isolation: Option, /// The user's selection before it. pub(crate) user: vectorcraft_doc::Selection, } @@ -592,12 +600,20 @@ fn finish(app: &mut VectorcraftApp, p: &Pending, r: Result) { } } -/// Restore the user's selection while the document's revision is unchanged and its objects still exist. -/// The whole selection, guides, slices and new art included, goes through the selection filters as +/// Restore the user's selection while the selection Replace made is unchanged and the user's objects +/// are still there as they were. The whole selection, guides, slices and new art included, goes through the selection filters as /// they are now, and the current layer and active document stay current. pub(crate) fn reselect(app: &mut VectorcraftApp, back: &Reselect) { let Some(st) = app.session.documents().iter().find(|st| st.uid == back.doc) else { return }; - if st.revision != back.revision || !back.user.objects.iter().all(|id| st.doc.node(*id).is_some()) { + let kept = |id: &vectorcraft_doc::NodeId| st.doc.node(*id).is_some_and(|n| back.art.node(*id) == Some(n)); + // A symbol part names a child of the symbol's art, which an edit to the symbol can change. + let part_kept = back.user.symbol_part.is_none() || std::sync::Arc::ptr_eq(&st.doc, &back.art); + if st.selections != back.selections + || st.selection != back.swapped + || st.isolation != back.isolation + || !part_kept + || !back.user.objects.iter().all(kept) + { return; } let layer = st.active_layer; diff --git a/crates/ui-egui/src/placing/tests.rs b/crates/ui-egui/src/placing/tests.rs index 434f47e51e..eef7b0e037 100644 --- a/crates/ui-egui/src/placing/tests.rs +++ b/crates/ui-egui/src/placing/tests.rs @@ -2066,7 +2066,166 @@ fn swapped_out(app: &mut VectorcraftApp, other: NodeId) -> Reselect { let user = app.session.doc().unwrap().selection.clone(); app.run("select.set", json!({"ids": [other.0]})).unwrap(); let st = app.session.doc().unwrap(); - Reselect { doc: st.uid, revision: st.revision, user } + Reselect { doc: st.uid, swapped: st.selection.clone(), selections: st.selections, art: st.doc.clone(), isolation: st.isolation, user } +} + +/// The objects selected before the swap, with two rectangles drawn: the user's and the swapped one. +fn two_rectangles(app: &mut VectorcraftApp) -> (NodeId, NodeId) { + let mut rect = |x| NodeId(app.run("shape.rectangle", json!({"x": x, "y": 10, "width": 20, "height": 20})).unwrap()["id"].as_u64().unwrap()); + let (mine, other) = (rect(10.0), rect(60.0)); + app.run("select.set", json!({"ids": [mine.0]})).unwrap(); + (mine, other) +} + +#[test] +fn a_raised_revision_alone_does_not_block_the_restore() { + let mut app = app(false); + let (mine, other) = two_rectangles(&mut app); + let back = swapped_out(&mut app, other); + // The rollback of a failed Replace puts the document back as it was and raises its revision + // (`Session::place_read`), which this does alone. + let uid = app.session.doc().unwrap().uid; + app.session.document_mut(uid).unwrap().revision += 1; + reselect(&mut app, &back); + assert_eq!(app.session.doc().unwrap().selection.objects, vec![mine], "the user's selection comes back"); +} + +#[test] +fn a_selection_undo_and_redo_gave_back_is_kept() { + let mut app = app(false); + let (mine, other) = two_rectangles(&mut app); + app.run("select.set", json!({"ids": [other.0]})).unwrap(); + app.run("artboard.setProps", json!({"index": 0, "name": "Front"})).unwrap(); + app.run("select.set", json!({"ids": [mine.0]})).unwrap(); + let back = swapped_out(&mut app, other); + app.run("edit.undo", json!({})).unwrap(); + app.run("edit.redo", json!({})).unwrap(); + assert_eq!(app.session.doc().unwrap().selection.objects, vec![other], "Redo selects the object again"); + reselect(&mut app, &back); + assert_eq!(app.session.doc().unwrap().selection.objects, vec![other], "the selection Redo gave back is kept"); +} + +#[test] +fn a_selection_isolation_gave_back_is_kept() { + let mut app = app(false); + let (mine, other) = two_rectangles(&mut app); + let group = NodeId(app.run("object.group", json!({ "ids": [other.0] })).unwrap()["id"].as_u64().unwrap()); + app.run("select.set", json!({"ids": [mine.0]})).unwrap(); + let back = swapped_out(&mut app, group); + app.run("object.isolate", json!({"id": group.0})).unwrap(); + app.run("object.exitIsolation", json!({})).unwrap(); + assert_eq!(app.session.doc().unwrap().selection.objects, vec![group], "leaving isolation selects the group again"); + reselect(&mut app, &back); + assert_eq!(app.session.doc().unwrap().selection.objects, vec![group], "the selection leaving isolation made is kept"); +} + +#[test] +fn a_selection_a_batch_step_gave_back_is_kept() { + let mut app = app(false); + let (mine, other) = two_rectangles(&mut app); + let group = NodeId(app.run("object.group", json!({ "ids": [other.0] })).unwrap()["id"].as_u64().unwrap()); + app.run("select.set", json!({"ids": [mine.0]})).unwrap(); + let back = swapped_out(&mut app, group); + let steps = json!([{"command": "object.isolate", "params": {"id": group.0}}, {"command": "object.exitIsolation"}]); + app.run("command.batch", json!({"commands": steps})).unwrap(); + assert_eq!(app.session.doc().unwrap().selection.objects, vec![group], "leaving isolation selects the group again"); + reselect(&mut app, &back); + assert_eq!(app.session.doc().unwrap().selection.objects, vec![group], "the selection the batch made is kept"); +} + +#[test] +fn leaving_isolation_onto_the_swapped_group_keeps_it_selected() { + let mut app = app(false); + let (_, other) = two_rectangles(&mut app); + let group = NodeId(app.run("object.group", json!({ "ids": [other.0] })).unwrap()["id"].as_u64().unwrap()); + app.run("object.isolate", json!({"id": group.0})).unwrap(); + app.run("select.set", json!({"ids": [other.0]})).unwrap(); + let back = swapped_out(&mut app, group); + app.run("object.exitIsolation", json!({})).unwrap(); + assert_eq!(app.session.doc().unwrap().selection.objects, vec![group], "leaving isolation selects the group"); + reselect(&mut app, &back); + assert_eq!(app.session.doc().unwrap().selection.objects, vec![group], "the selection leaving isolation made is kept"); +} + +#[test] +fn a_selection_a_lock_and_unlock_batch_gave_back_is_kept() { + let mut app = app(false); + let (mine, other) = two_rectangles(&mut app); + app.run("select.set", json!({"ids": [mine.0]})).unwrap(); + let back = swapped_out(&mut app, other); + let steps = json!([{"command": "object.lock"}, {"command": "object.unlockAll"}]); + app.run("command.batch", json!({"commands": steps})).unwrap(); + assert_eq!(app.session.doc().unwrap().selection.objects, vec![other], "Unlock All selects what it unlocks"); + reselect(&mut app, &back); + assert_eq!(app.session.doc().unwrap().selection.objects, vec![other], "the selection the batch made is kept"); +} + +#[test] +fn a_selection_is_not_restored_into_another_isolation() { + let mut app = app(false); + let (_, other) = two_rectangles(&mut app); + let group = NodeId(app.run("object.group", json!({ "ids": [other.0] })).unwrap()["id"].as_u64().unwrap()); + app.run("select.set", json!({"ids": []})).unwrap(); + let mut back = swapped_out(&mut app, group); + app.run("object.isolate", json!({"id": group.0})).unwrap(); + app.run("select.set", json!({"ids": [group.0]})).unwrap(); + let st = app.session.doc().unwrap(); + (back.swapped, back.selections) = (st.selection.clone(), st.selections); + let selected = st.selection.objects.clone(); + reselect(&mut app, &back); + assert_eq!(app.session.doc().unwrap().selection.objects, selected, "the selection made in isolation is kept"); +} + +#[test] +fn a_command_that_fails_and_puts_the_selection_back_does_not_block_the_restore() { + let mut app = app(false); + let (mine, other) = two_rectangles(&mut app); + let back = swapped_out(&mut app, other); + let far = NodeId(app.run("shape.rectangle", json!({"x": 300, "y": 300, "width": 20, "height": 20})).unwrap()["id"].as_u64().unwrap()); + app.run("select.set", json!({"ids": [other.0]})).unwrap(); + let mut back = back; + let st = app.session.doc().unwrap(); + (back.swapped, back.selections, back.art) = (st.selection.clone(), st.selections, st.doc.clone()); + assert!(app.run("object.pathfinder.intersect", json!({"ids": [other.0, far.0]})).is_err(), "disjoint shapes have no intersection"); + assert_eq!(app.session.doc().unwrap().selection.objects, vec![other], "the failed command puts the selection back"); + reselect(&mut app, &back); + assert_eq!(app.session.doc().unwrap().selection.objects, vec![mine], "the user's selection comes back"); +} + +#[test] +fn a_symbol_part_is_not_restored_after_an_edit() { + let mut app = app(false); + let (mine, other) = two_rectangles(&mut app); + let mut back = swapped_out(&mut app, other); + back.user.symbol_part = Some(vectorcraft_doc::SymbolPart { instance: mine, path: vec![0] }); + app.run("artboard.setProps", json!({"index": 0, "name": "Front"})).unwrap(); + reselect(&mut app, &back); + assert_eq!(app.session.doc().unwrap().selection.objects, vec![other], "a part of art that may have changed is not restored"); +} + +#[test] +fn selected_anchors_of_a_reversed_path_are_not_restored() { + let mut app = app(false); + let (mine, other) = two_rectangles(&mut app); + app.run("select.anchors", json!({"id": mine.0, "anchors": [[0, 0]], "mode": "set"})).unwrap(); + let back = swapped_out(&mut app, other); + app.run("path.reverse", json!({"ids": [mine.0], "reversed": true})).unwrap(); + assert_eq!(app.session.doc().unwrap().selection.objects, vec![other], "the edit keeps the selection"); + reselect(&mut app, &back); + assert_eq!(app.session.doc().unwrap().selection.objects, vec![other], "anchor numbers of the edited path are not restored"); +} + +#[test] +fn an_edit_that_keeps_the_selection_still_restores_it() { + let mut app = app(false); + let (mine, other) = two_rectangles(&mut app); + let back = swapped_out(&mut app, other); + let revision = app.session.doc().unwrap().revision; + app.run("artboard.setProps", json!({"index": 0, "name": "Front"})).unwrap(); + assert_ne!(app.session.doc().unwrap().revision, revision, "the edit changes the document"); + assert_eq!(app.session.doc().unwrap().selection.objects, vec![other], "the edit keeps the selection"); + reselect(&mut app, &back); + assert_eq!(app.session.doc().unwrap().selection.objects, vec![mine], "the user's selection comes back"); } #[test] @@ -2079,7 +2238,8 @@ fn a_restored_selection_leaves_out_guides_locked_since() { assert_eq!(app.session.doc().unwrap().selection.guides.len(), 1, "the ruler guide is selected"); let mut back = swapped_out(&mut app, other); app.run("view.guides.lock", json!({"locked": true})).unwrap(); - back.revision = app.session.doc().unwrap().revision; + let st = app.session.doc().unwrap(); + (back.swapped, back.selections) = (st.selection.clone(), st.selections); reselect(&mut app, &back); assert!(app.session.doc().unwrap().selection.guides.is_empty(), "the locked guide is not selected again"); } From 8848ba21f3af293148697ca238e01a14dfbd4146 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 5 Dec 2026 10:10:08 -0800 Subject: [PATCH 06/14] DXF Import: a restored selection is journaled and loads its paints When a failed DWG Replace gives the user's selection back in the active document, the journal now records that selection (through the same steps an interaction uses, in open undo groups too), so a recorded action replays later commands on the restored objects. The paints for new art load from the restored selection as they do after select.set, so the next shape does not take the swapped object's paints. --- crates/engine/src/session/edit.rs | 26 ++++++++- crates/ui-egui/src/placing/tests.rs | 83 +++++++++++++++++++++++++++++ 2 files changed, 107 insertions(+), 2 deletions(-) diff --git a/crates/engine/src/session/edit.rs b/crates/engine/src/session/edit.rs index 8417be7815..48c7a8358e 100644 --- a/crates/engine/src/session/edit.rs +++ b/crates/engine/src/session/edit.rs @@ -266,12 +266,34 @@ impl Session { /// Give document `uid` back a selection it had, new art included, through the selection /// filters as they are now: guides locked since, hidden or locked slices and art on a locked - /// artboard that is not new art are left out. + /// artboard that is not new art are left out. In the active document, outside a command and an + /// interaction, the journal records the selection that comes back, with the current layer kept, + /// in the open undo groups too, and the paints for new art load from it as `select.set` loads + /// them, so a recorded action replays as it ran. pub fn restore_selection(&mut self, uid: u64, selection: Selection) -> Result<()> { + let active = self.active().is_some_and(|st| st.uid == uid && st.interaction.is_none()) && self.depth == 0; let st = self.document_mut(uid).ok_or(EngineError::NoDocument)?; + let (made, layer) = (st.selection.clone(), st.active_layer); st.selection_record = None; st.selection = selection; - self.select_in_document(uid, |_, _| {}) + self.select_in_document(uid, |_, _| {})?; + if !active { + return Ok(()); + } + let Some(st) = self.document_mut(uid) else { return Ok(()) }; + if st.selection == made { + return Ok(()); + } + let steps = selection_steps(&st.selection, &made, &st.doc, layer, &st.highlighted_rows()); + let (from, grouped) = (self.journal.len(), self.undo_group_docs()); + for step in steps { + self.journal.push(step); + } + self.journal_in_undo_groups(Some(uid), &grouped, from); + // As `Session::execute` does after a selection command. + self.inherit_new_art(); + self.load_selection_paints(); + Ok(()) } /// Apply the selection filters and update the editing state of document `uid`. diff --git a/crates/ui-egui/src/placing/tests.rs b/crates/ui-egui/src/placing/tests.rs index eef7b0e037..aaa4919874 100644 --- a/crates/ui-egui/src/placing/tests.rs +++ b/crates/ui-egui/src/placing/tests.rs @@ -2069,6 +2069,89 @@ fn swapped_out(app: &mut VectorcraftApp, other: NodeId) -> Reselect { Reselect { doc: st.uid, swapped: st.selection.clone(), selections: st.selections, art: st.doc.clone(), isolation: st.isolation, user } } +/// Restore `back`, then check that the journal entries the restore added select the same again +/// when they are run after the swapped object is selected. +fn reselect_and_replay(app: &mut VectorcraftApp, back: &Reselect, other: NodeId) { + let from = app.session.journal.len(); + reselect(app, back); + let restored = app.session.doc().unwrap().selection.clone(); + let steps: Vec<(String, serde_json::Value)> = app.session.journal.since(from).to_vec(); + assert!(!steps.is_empty(), "the journal records the restored selection"); + app.run("select.set", json!({"ids": [other.0]})).unwrap(); + for (id, p) in steps { + app.run(&id, p).unwrap(); + } + assert_eq!(app.session.doc().unwrap().selection, restored, "the journal replays the restored selection"); +} + +#[test] +fn a_restored_segment_selection_replays_as_segments() { + let mut app = app(false); + let (mine, other) = two_rectangles(&mut app); + app.run("select.segments", json!({"id": mine.0, "segments": [[0, 1]]})).unwrap(); + assert!(!app.session.doc().unwrap().selection.segments.is_empty()); + let back = swapped_out(&mut app, other); + reselect_and_replay(&mut app, &back, other); + assert!(app.session.doc().unwrap().selection.segments.contains_key(&mine), "the segment is selected again"); +} + +#[test] +fn a_restore_inside_a_canceled_undo_group_leaves_the_journal() { + let mut app = app(false); + let (_, other) = two_rectangles(&mut app); + let before = app.session.journal.len(); + app.run("edit.undoGroup.begin", json!({})).unwrap(); + let made = NodeId(app.run("shape.rectangle", json!({"x": 120, "y": 10, "width": 20, "height": 20})).unwrap()["id"].as_u64().unwrap()); + app.run("select.set", json!({"ids": [made.0]})).unwrap(); + let back = swapped_out(&mut app, other); + reselect(&mut app, &back); + assert_eq!(app.session.doc().unwrap().selection.objects, vec![made]); + let last = app.session.journal.last().cloned().unwrap(); + assert_eq!(last, ("select.set".to_string(), json!({"ids": [made.0]})), "the restore is journaled"); + app.run("edit.undoGroup.end", json!({"cancel": true})).unwrap(); + let left: Vec<&str> = app.session.journal.since(before).iter().map(|(id, _)| id.as_str()).collect(); + assert!(!left.iter().any(|id| *id == "select.set" || *id == "shape.rectangle"), "{left:?}"); +} + +#[test] +fn a_restored_selection_is_journaled_and_brings_its_paints_back() { + let mut app = app(false); + let (mine, other) = two_rectangles(&mut app); + app.run("paint.setFill", json!({"ids": [mine.0], "color": "#ff0000"})).unwrap(); + app.run("paint.setFill", json!({"ids": [other.0], "color": "#0000ff"})).unwrap(); + // Selecting the red rectangle loads its paints for new art. + app.run("select.none", json!({})).unwrap(); + app.run("select.set", json!({"ids": [mine.0]})).unwrap(); + let red = app.session.paint.clone(); + let back = swapped_out(&mut app, other); + assert_ne!(app.session.paint, red, "selecting the swapped object loads its paints"); + reselect(&mut app, &back); + assert_eq!(app.session.doc().unwrap().selection.objects, vec![mine]); + assert_eq!(app.session.paint, red, "the restored selection's paints are the paints for new art"); + let last = app.session.journal.last().cloned().unwrap(); + assert_eq!(last, ("select.set".to_string(), json!({"ids": [mine.0]})), "the journal records the restored selection"); + // Replayed, the journal leaves the same paints for new art. + app.run("select.set", json!({"ids": [other.0]})).unwrap(); + app.run(&last.0, last.1).unwrap(); + assert_eq!(app.session.paint, red, "the replay loads the same paints"); +} + +#[test] +fn a_restored_selection_gives_new_art_its_appearance_with_basic_appearance_off() { + let mut app = app(false); + app.session.prefs.new_art_basic = false; + let (mine, other) = two_rectangles(&mut app); + app.run("paint.setFill", json!({"ids": [mine.0], "color": "#ff0000"})).unwrap(); + app.run("paint.setFill", json!({"ids": [other.0], "color": "#0000ff"})).unwrap(); + app.run("select.none", json!({})).unwrap(); + app.run("select.set", json!({"ids": [mine.0]})).unwrap(); + let red = app.session.paint.clone(); + let back = swapped_out(&mut app, other); + assert_ne!(app.session.paint, red, "new art takes the swapped object's appearance"); + reselect(&mut app, &back); + assert_eq!(app.session.paint, red, "new art takes the restored object's appearance again"); +} + /// The objects selected before the swap, with two rectangles drawn: the user's and the swapped one. fn two_rectangles(app: &mut VectorcraftApp) -> (NodeId, NodeId) { let mut rect = |x| NodeId(app.run("shape.rectangle", json!({"x": x, "y": 10, "width": 20, "height": 20})).unwrap()["id"].as_u64().unwrap()); From 15949962fb5730ac6f2a0b3ffcab4c90f6fd713d Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 5 Dec 2026 14:18:05 -0800 Subject: [PATCH 07/14] Swatches: Shift+F10, the Menu key or a screen reader sets the stroke from a Swatch Strip chip A right-click or an Alt-click on a Swatch Strip chip sets the stroke, but keyboard and screen-reader users had no way to do the same. The strip now reads the swatch's context request (SwatchOutput::context), so Shift+F10, or the Menu key off macOS, on the focused chip sets the stroke as a right-click does. Each chip offers AccessKit's ShowContextMenu action, which sets the stroke too. The swatch's request also counts any right-button release over it, wherever the press began. The strip keeps its own press tracking for the pointer, so a right-drag from elsewhere, a press on a layer over the chip or a release in another document still sets nothing, and it takes the context request only in a frame without a right-button release. Each chip's control is now keyed by its document and the paint it sends rather than by its place in the list, so a click whose press lands on one swatch sets that swatch even when the list reorders before the release, and a release after the active document changes sets nothing there. The panel test harness gains offers_context_menu and show_context_menu for a control's AccessKit context menu action. --- crates/ui-egui/src/panels/swatch_strip.rs | 98 ++++++++++++++++++++--- crates/ui-egui/src/tests/panel_harness.rs | 21 +++++ docs/control-protocol.md | 5 +- 3 files changed, 113 insertions(+), 11 deletions(-) diff --git a/crates/ui-egui/src/panels/swatch_strip.rs b/crates/ui-egui/src/panels/swatch_strip.rs index c91b5b3b7a..720b41163e 100644 --- a/crates/ui-egui/src/panels/swatch_strip.rs +++ b/crates/ui-egui/src/panels/swatch_strip.rs @@ -4,11 +4,14 @@ //! across in one line; in a dock column or a narrow floating window they wrap down the column, and scroll when they //! do not fit. //! -//! A click on a chip sets the fill (`paint.setFill`); a right-click or an Alt-click sets the stroke -//! (`paint.setStroke`). Neither changes which of the Fill and Stroke proxies is active. +//! A click on a chip, or Space or Enter on the focused chip, sets the fill (`paint.setFill`); a right-click, an +//! Alt-click, Shift+F10 (or the Menu key off macOS) on the focused chip, or a screen reader's context menu action +//! sets the stroke (`paint.setStroke`). +//! Neither changes which of the Fill and Stroke proxies is active. use craft::theme::Srgba; use craft::ui::choice::Swatch; +use craft::ui::contract::overlay::offer_context_menu; use craft::ui::contract::{Props as _, Scroll, Show as _, ShowContainer as _}; use craft::ui::layout_components::{Row, Stack}; use egui::{Event, PointerButton, Rect, Ui}; @@ -56,33 +59,42 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) { return; } let chips = chips(app); + // Each chip is keyed by its document and the paint it sends, so a swatch that moves in the list between a press + // and its release keeps its control, and a release in another document reaches none of this one's chips. + let uid = app.session.active().map_or(0, |st| st.uid); + let keys: Vec = chips.iter().map(|c| format!("{uid}:{}", c.params)).collect(); let mut picked = None; + // A secondary-button release in this frame: the chips' context requests then come from the pointer, which the + // press tracking below handles, rather than from Shift+F10, the Menu key or a screen reader. + let secondary_release = + ui.input(|i| i.events.iter().any(|e| matches!(e, Event::PointerButton { button: PointerButton::Secondary, pressed: false, .. }))); // Where each chip shows (clipped to the scroll area), for placing the frame's right-button events. // A sizing pass draws the chips first; the drawing pass after it writes over its rects. let mut hits: Vec> = vec![None; chips.len()]; Stack::new().id_salt(ID).fill().scroll(Scroll::vertical()).show(ui, |ui, _| { Row::new().fill_width().wrap(true).show(ui, |ui, _| { - for (at, chip) in chips.iter().enumerate() { + for (at, (chip, key)) in chips.iter().zip(&keys).enumerate() { let swatch = match chip.color { Some(color) => Swatch::new(chip.name.clone(), color), None => Swatch::optional(chip.name.clone(), None::), }; - let out = swatch.id_salt(at).tooltip(chip.name.clone()).show(ui); + let out = swatch.id_salt(key).tooltip(chip.name.clone()).show(ui); + // A screen reader's context menu action on the chip sets the stroke, as a right-click does. + offer_context_menu(ui.ctx(), out.response.id); if let Some(hit) = hits.get_mut(at) { *hit = Some(out.response.rect.intersect(ui.clip_rect())); } if out.clicked { picked = Some((at, out.activation.is_some_and(|a| a.mods.alt))); + } else if out.context && !secondary_release { + picked = Some((at, true)); } } }); }); - // A right-click sets the stroke when its press and its release both land on the same chip. + // A right-click sets the stroke when its press and its release both land on the same chip. The swatch's context + // request counts any secondary release over it, wherever the press began, so the strip tracks the press itself. let press_id = ui.scope_id().with((ID, "secondary-press")); - // The chip is kept by its document and the paint it sends, so a swatch that moves in the list between press and - // release still counts, and a release in another document does not. - let uid = app.session.active().map_or(0, |st| st.uid); - let keys: Vec = chips.iter().map(|c| format!("{uid}:{}", c.params)).collect(); let laid_out: Vec<(Rect, String)> = hits.iter().zip(&keys).filter_map(|(r, k)| r.map(|r| (r, k.clone()))).collect(); // A container's measuring run shows the strip in an invisible sizing pass with the same id and input before the // frame's real run; it leaves the remembered press alone, so the real run's release still finds it. @@ -174,6 +186,32 @@ mod tests { assert_eq!(panel.app().session.fill_active, fill_active, "the active proxy stays as it was"); } + #[test] + fn shift_f10_on_the_focused_chip_sets_the_stroke() { + let mut panel = Panel::new(app(), show); + let before = paints(&panel); + panel.focus("Strip Red"); + assert!(panel.focused("Strip Red"), "the chip takes the focus"); + assert_eq!(paints(&panel), before, "focus alone sets nothing"); + + panel.key(egui::Key::F10, Modifiers::SHIFT); + panel.frame(); + let (fill, stroke) = paints(&panel); + assert_eq!(swatch_of(&stroke).as_deref(), Some("Strip Red"), "Shift+F10 sets the stroke"); + assert_eq!(fill, before.0, "Shift+F10 leaves the fill"); + } + + #[test] + fn a_screen_readers_context_menu_action_sets_the_stroke() { + let mut panel = Panel::new(app(), show); + assert!(panel.offers_context_menu("Strip Green"), "the chip offers the context menu action"); + let before = paints(&panel).0; + panel.show_context_menu("Strip Green"); + let (fill, stroke) = paints(&panel); + assert_eq!(swatch_of(&stroke).as_deref(), Some("Strip Green"), "the action sets the stroke"); + assert_eq!(fill, before, "the action leaves the fill"); + } + #[test] fn a_right_drag_from_outside_onto_a_chip_leaves_the_stroke() { let mut panel = Panel::new(app(), show); @@ -219,6 +257,40 @@ mod tests { assert_eq!(swatch_of(&paints(&panel).1).as_deref(), Some("Strip Red"), "the release on the same swatch sets the stroke"); } + #[test] + fn a_click_counts_for_the_swatch_pressed_when_another_moves_in_under_it() { + let mut panel = Panel::new(app(), show); + let from = panel.rect("Strip Red").center(); + let button = |pressed| egui::Event::PointerButton { pos: from, button: egui::PointerButton::Primary, pressed, modifiers: Modifiers::NONE }; + panel.frame_with(vec![egui::Event::PointerMoved(from)]); + panel.frame_with(vec![button(true)]); + panel.app().run("swatch.move", json!({"names": ["Strip Blue"], "to": 0})).unwrap(); + panel.frame(); + assert!(!panel.rect("Strip Red").contains(from), "the move takes the pressed chip from under the pointer"); + panel.frame_with(vec![button(false)]); + panel.frame(); + assert_eq!(swatch_of(&paints(&panel).0).as_deref(), Some("Strip Red"), "the click sets the pressed swatch, not the one that moved in"); + } + + #[test] + fn a_click_released_in_another_document_leaves_its_fill() { + let mut app = app(); + app.run("file.new", json!({"width": 200, "height": 200})).unwrap(); + app.run("swatch.new", json!({"name": "Strip Green", "color": "#22aa44", "global": true})).unwrap(); + app.run("shape.rectangle", json!({"x": 10, "y": 10, "width": 50, "height": 50})).unwrap(); + let mut panel = Panel::new(app, show); + let at = panel.rect("Strip Green").center(); + let button = |pressed| egui::Event::PointerButton { pos: at, button: egui::PointerButton::Primary, pressed, modifiers: Modifiers::NONE }; + panel.frame_with(vec![egui::Event::PointerMoved(at)]); + panel.frame_with(vec![button(true)]); + assert!(panel.app().session.set_active(0), "the first document becomes active"); + panel.frame(); + let before = paints(&panel).0; + panel.frame_with(vec![button(false)]); + panel.frame(); + assert_eq!(paints(&panel).0, before, "a press in one document and a release in another set nothing"); + } + #[test] fn a_right_click_in_the_frame_the_strip_remeasures_still_sets_the_stroke() { let mut panel = Panel::new(app(), show); @@ -274,6 +346,14 @@ mod tests { panel.frame_with(vec![button(false)]); panel.frame(); assert_eq!(swatch_of(&paints(&panel).1).as_deref(), Some("Strip Green"), "the shown strip's right-click sets the stroke"); + + let steps = |panel: &Panel| panel.app().session.active().map_or(0, |st| st.history.undo.len()); + let before = steps(&panel); + panel.focus("Strip Blue"); + panel.key(egui::Key::F10, Modifiers::SHIFT); + panel.frame(); + assert_eq!(swatch_of(&paints(&panel).1).as_deref(), Some("Strip Blue"), "Shift+F10 on the shown strip sets the stroke"); + assert_eq!(steps(&panel), before + 1, "the sizing pass and the shown strip set it once between them"); } thread_local! { diff --git a/crates/ui-egui/src/tests/panel_harness.rs b/crates/ui-egui/src/tests/panel_harness.rs index e8c2ca4c21..fdd6924d86 100644 --- a/crates/ui-egui/src/tests/panel_harness.rs +++ b/crates/ui-egui/src/tests/panel_harness.rs @@ -307,6 +307,27 @@ impl Panel { self.after(); } + /// Whether the control named `name` offers a screen reader its context menu (AccessKit `ShowContextMenu`). + pub(crate) fn offers_context_menu(&mut self, name: &str) -> bool { + let target = self.find(name); + let id = egui::accesskit::NodeId(target.node.raw()); + let tree = self.fixture.tree(); + tree.update().nodes.iter().any(|(node, n)| *node == id && n.supports_action(egui::accesskit::Action::ShowContextMenu)) + } + + /// A screen reader's `ShowContextMenu` on the control named `name`. + pub(crate) fn show_context_menu(&mut self, name: &str) { + let target = self.find(name); + let request = egui::accesskit::ActionRequest { + action: egui::accesskit::Action::ShowContextMenu, + target_tree: egui::accesskit::TreeId::ROOT, + target_node: egui::accesskit::NodeId(target.node.raw()), + data: None, + }; + self.frame_with(vec![Event::AccessKitActionRequest(request)]); + self.after(); + } + /// Turns the wheel by `dy` points over `at`. pub(crate) fn scroll_at(&mut self, at: Pos2, dy: f32) { self.frame_with(vec![Event::PointerMoved(at)]); diff --git a/docs/control-protocol.md b/docs/control-protocol.md index 2e62cd2de8..e40422e645 100644 --- a/docs/control-protocol.md +++ b/docs/control-protocol.md @@ -293,8 +293,9 @@ Swatch Strip panel (`window.panel {panel: "swatchStrip"}`): a None chip, then th swatches outside any color group, then each group's; gradient and pattern swatches are left out), in a row of chips that wraps to the panel's room and scrolls when they do not fit. `window.panel.dock {panel: "swatchStrip", anchor: "canvas", placement: {"Edge": "Bottom"}}` docks it along the window's bottom edge, where the chips run across in one -line. A click on a chip runs `paint.setFill {swatch}` (`{none: true}` for None) and a right-click or an Alt-click -runs `paint.setStroke`, both with `focus: false`, so the active proxy stays as it was. +line. A click on a chip runs `paint.setFill {swatch}` (`{none: true}` for None) and a right-click, an Alt-click, +Shift+F10 or the Menu key on the focused chip, or a screen reader's context menu action runs `paint.setStroke`, both +with `focus: false`, so the active proxy stays as it was. Color Themes panel (`window.panel {panel: "colorThemes"}`): its Create tab makes a theme on a harmony wheel and its My Themes tab lists the saved themes; every action runs a command (`colorTheme.save`, `colorTheme.delete`, From 374176f3c6359cefe21801647884c2a9f29f375f Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 5 Dec 2026 16:01:45 -0800 Subject: [PATCH 08/14] DXF Import: a restore inherits after a defaults-only paint; a part keeps the paints Restoring a selection now clears the marker a defaults-only paint left, as every top-level command does, so new art takes the restored selection's appearance live as it does when the journaled select.set replays. A restored symbol part no longer loads its paints for new art, as symbol.instance.selectPart, the step the journal records for it, does not. --- crates/engine/src/session/edit.rs | 13 +++++-- crates/ui-egui/src/placing/tests.rs | 53 +++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+), 3 deletions(-) diff --git a/crates/engine/src/session/edit.rs b/crates/engine/src/session/edit.rs index 48c7a8358e..54738772f7 100644 --- a/crates/engine/src/session/edit.rs +++ b/crates/engine/src/session/edit.rs @@ -269,7 +269,8 @@ impl Session { /// artboard that is not new art are left out. In the active document, outside a command and an /// interaction, the journal records the selection that comes back, with the current layer kept, /// in the open undo groups too, and the paints for new art load from it as `select.set` loads - /// them, so a recorded action replays as it ran. + /// them (with New Art Has Basic Appearance on, a symbol part does not load its paints, as + /// `symbol.instance.selectPart` does not), so a recorded action replays as it ran. pub fn restore_selection(&mut self, uid: u64, selection: Selection) -> Result<()> { let active = self.active().is_some_and(|st| st.uid == uid && st.interaction.is_none()) && self.depth == 0; let st = self.document_mut(uid).ok_or(EngineError::NoDocument)?; @@ -285,14 +286,20 @@ impl Session { return Ok(()); } let steps = selection_steps(&st.selection, &made, &st.doc, layer, &st.highlighted_rows()); + // A symbol part comes back through `symbol.instance.selectPart`, which loads no paints. + let part = st.selection.symbol_part.is_some(); let (from, grouped) = (self.journal.len(), self.undo_group_docs()); for step in steps { self.journal.push(step); } self.journal_in_undo_groups(Some(uid), &grouped, from); - // As `Session::execute` does after a selection command. + // As `Session::execute` does after a selection command, which starts without the marker + // of a defaults-only paint that ran before it. + self.defaults_only_ran = None; self.inherit_new_art(); - self.load_selection_paints(); + if !part { + self.load_selection_paints(); + } Ok(()) } diff --git a/crates/ui-egui/src/placing/tests.rs b/crates/ui-egui/src/placing/tests.rs index aaa4919874..a137918e31 100644 --- a/crates/ui-egui/src/placing/tests.rs +++ b/crates/ui-egui/src/placing/tests.rs @@ -2152,6 +2152,59 @@ fn a_restored_selection_gives_new_art_its_appearance_with_basic_appearance_off() assert_eq!(app.session.paint, red, "new art takes the restored object's appearance again"); } +#[test] +fn a_restore_after_a_defaults_only_paint_gives_new_art_the_restored_appearance() { + let mut app = app(false); + app.session.prefs.new_art_basic = false; + let (mine, other) = two_rectangles(&mut app); + app.run("paint.setFill", json!({"ids": [mine.0], "color": "#ff0000"})).unwrap(); + app.run("paint.setFill", json!({"ids": [other.0], "color": "#0000ff"})).unwrap(); + app.run("select.set", json!({"ids": [mine.0, other.0]})).unwrap(); + let back = swapped_out(&mut app, mine); + let red = app.session.paint.clone(); + app.run("paint.setFill", json!({"color": "#00ff00", "defaultsOnly": true})).unwrap(); + assert_ne!(app.session.paint, red, "the defaults-only paint changes the defaults"); + let from = app.session.journal.len(); + reselect(&mut app, &back); + assert_eq!(app.session.paint, red, "new art takes the restored selection's appearance"); + // Replayed after the same defaults-only paint, the journal leaves the same defaults. + let steps: Vec<(String, serde_json::Value)> = app.session.journal.since(from).to_vec(); + app.run("select.set", json!({"ids": [mine.0]})).unwrap(); + app.run("paint.setFill", json!({"color": "#00ff00", "defaultsOnly": true})).unwrap(); + for (id, p) in steps { + app.run(&id, p).unwrap(); + } + assert_eq!(app.session.paint, red, "the replay gives new art the same appearance"); +} + +#[test] +fn a_restored_symbol_part_leaves_the_paints_as_its_replay_does() { + let mut app = app(false); + let rect = |app: &mut VectorcraftApp, x: i32, color: &str| { + let id = app.run("shape.rectangle", json!({"x": x, "y": 10, "width": 20, "height": 20})).unwrap()["id"].as_u64().unwrap(); + app.run("paint.setFill", json!({"ids": [id], "color": color})).unwrap(); + id + }; + let (left, right) = (rect(&mut app, 10, "#ff0000"), rect(&mut app, 40, "#00ff00")); + let other = NodeId(rect(&mut app, 120, "#0000ff")); + let instance = app.run("symbol.new", json!({"type": "dynamic", "ids": [left, right]})).unwrap()["id"].as_u64().unwrap(); + app.run("symbol.instance.selectPart", json!({"id": instance, "path": [0]})).unwrap(); + let back = swapped_out(&mut app, other); + let blue = app.session.paint.clone(); + let from = app.session.journal.len(); + reselect(&mut app, &back); + assert_eq!(app.session.doc().unwrap().selection.symbol_part.as_ref().map(|p| p.path.clone()), Some(vec![0])); + // `symbol.instance.selectPart` keeps the paints for new art, and so does the restore. + assert_eq!(app.session.paint, blue, "the restored part keeps the paints for new art"); + let steps: Vec<(String, serde_json::Value)> = app.session.journal.since(from).to_vec(); + assert!(steps.iter().any(|(id, _)| id == "symbol.instance.selectPart"), "{steps:?}"); + app.run("select.set", json!({"ids": [other.0]})).unwrap(); + for (id, p) in steps { + app.run(&id, p).unwrap(); + } + assert_eq!(app.session.paint, blue, "the replay leaves the same paints"); +} + /// The objects selected before the swap, with two rectangles drawn: the user's and the swapped one. fn two_rectangles(app: &mut VectorcraftApp) -> (NodeId, NodeId) { let mut rect = |x| NodeId(app.run("shape.rectangle", json!({"x": x, "y": 10, "width": 20, "height": 20})).unwrap()["id"].as_u64().unwrap()); From 9f6e817063812d91665e2dc300b94d1a340a64e7 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 5 Dec 2026 16:47:26 -0800 Subject: [PATCH 09/14] Swatches: two swatches with one name keep a Swatch Strip chip each Each chip's control was keyed by its document and the paint it sends, so two swatches with the same name (which an opened file can hold) gave two chips one control, sharing hover, press, focus and one accessibility node. Chips that send the same paint are now numbered in list order, so each keeps a control of its own; distinct swatches keep their keys. docs/control-protocol.md now says the Menu key on a focused chip works off macOS only. --- crates/ui-egui/src/panels/swatch_strip.rs | 26 +++++++++++++++++++++-- crates/ui-egui/src/tests/panel_harness.rs | 5 +++++ docs/control-protocol.md | 2 +- 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/crates/ui-egui/src/panels/swatch_strip.rs b/crates/ui-egui/src/panels/swatch_strip.rs index 720b41163e..8c0fb5cf4a 100644 --- a/crates/ui-egui/src/panels/swatch_strip.rs +++ b/crates/ui-egui/src/panels/swatch_strip.rs @@ -60,9 +60,21 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) { } let chips = chips(app); // Each chip is keyed by its document and the paint it sends, so a swatch that moves in the list between a press - // and its release keeps its control, and a release in another document reaches none of this one's chips. + // and its release keeps its control, and a release in another document reaches none of this one's chips. Chips + // that send the same paint (two swatches with one name, which an opened file can hold) are numbered in list order, + // so each keeps a control of its own. let uid = app.session.active().map_or(0, |st| st.uid); - let keys: Vec = chips.iter().map(|c| format!("{uid}:{}", c.params)).collect(); + let mut seen = std::collections::HashMap::::new(); + let keys: Vec = chips + .iter() + .map(|c| { + let paint = c.params.to_string(); + let n = seen.entry(paint.clone()).or_default(); + let key = format!("{uid}:{paint}:{n}"); + *n += 1; + key + }) + .collect(); let mut picked = None; // A secondary-button release in this frame: the chips' context requests then come from the pointer, which the // press tracking below handles, rather than from Shift+F10, the Menu key or a screen reader. @@ -414,6 +426,16 @@ mod tests { assert!(!panel.shows("Strip Ramp"), "a gradient swatch has none"); } + #[test] + fn two_swatches_with_one_name_keep_a_chip_each() { + let mut app = app(); + let st = app.session.doc_mut().expect("a document"); + let green = std::sync::Arc::make_mut(&mut st.doc).swatch_mut("Strip Green").expect("the green swatch"); + green.name = "Strip Red".to_owned(); + let panel = Panel::new(app, show); + assert_eq!(panel.count_named("Strip Red"), 2, "each of the two swatches named Strip Red has a control of its own"); + } + #[test] fn the_chips_run_along_a_wide_strip_and_wrap_down_a_narrow_one() { let mut panel = Panel::new(app(), show); diff --git a/crates/ui-egui/src/tests/panel_harness.rs b/crates/ui-egui/src/tests/panel_harness.rs index fdd6924d86..c549c50d46 100644 --- a/crates/ui-egui/src/tests/panel_harness.rs +++ b/crates/ui-egui/src/tests/panel_harness.rs @@ -406,6 +406,11 @@ impl Panel { self.fixture.advance(seconds); } + /// How many nodes the latest frame shows named `name`. + pub(crate) fn count_named(&self, name: &str) -> usize { + self.names().iter().filter(|n| *n == name).count() + } + /// Whether the latest frame shows a control named `name`. pub(crate) fn shows(&self, name: &str) -> bool { self.fixture.by_label(name).is_some() diff --git a/docs/control-protocol.md b/docs/control-protocol.md index e40422e645..9e7a300231 100644 --- a/docs/control-protocol.md +++ b/docs/control-protocol.md @@ -294,7 +294,7 @@ swatches outside any color group, then each group's; gradient and pattern swatch that wraps to the panel's room and scrolls when they do not fit. `window.panel.dock {panel: "swatchStrip", anchor: "canvas", placement: {"Edge": "Bottom"}}` docks it along the window's bottom edge, where the chips run across in one line. A click on a chip runs `paint.setFill {swatch}` (`{none: true}` for None) and a right-click, an Alt-click, -Shift+F10 or the Menu key on the focused chip, or a screen reader's context menu action runs `paint.setStroke`, both +Shift+F10 (or the Menu key off macOS) on the focused chip, or a screen reader's context menu action runs `paint.setStroke`, both with `focus: false`, so the active proxy stays as it was. Color Themes panel (`window.panel {panel: "colorThemes"}`): its Create tab makes a theme on a harmony wheel and its From 155a244c60d678a99b0defc33c4ccae2e19930bc Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 5 Dec 2026 16:23:09 -0800 Subject: [PATCH 10/14] Blend: Undo, Redo and other rollbacks drop an unfinished Steps, Distance, Ramp or Shift value The Blend panel's draft key held the document uid, its File > Revert count and the selected objects with their nearest blends. Undo and Redo replace the document's content without changing those, so a value typed into Steps, Distance, Ramp or Shift and not yet finished stayed, and Enter applied it to the restored blend. After a canceled preview or undo group, a new blend can take the removed blend's node id, and the value reached that blend too. The key now also holds the document's history restore and rollback counts, as the other selection fields' target (`selection_target`) does. --- crates/ui-egui/src/panels/blend.rs | 40 ++++---- crates/ui-egui/src/panels/tests_blend.rs | 114 ++++++++++++++++++++++- 2 files changed, 129 insertions(+), 25 deletions(-) diff --git a/crates/ui-egui/src/panels/blend.rs b/crates/ui-egui/src/panels/blend.rs index b9f3526efe..6a69792e79 100644 --- a/crates/ui-egui/src/panels/blend.rs +++ b/crates/ui-egui/src/panels/blend.rs @@ -109,36 +109,38 @@ fn percent_slider(app: &mut VectorcraftApp, ui: &mut Ui, target: &EditTarget, sl }); } -/// The Steps, Distance, Ramp and Shift draft key: the document uid, its File › Revert count, and -/// each selected object id paired with its nearest blend id, or None when it resolves to no blend. -/// Symbol-part selections resolve to no blend, as the Blend commands require. A field drops an -/// unfinished value when this key changes, even when the new target shows the same value. -/// [`settings`] reuses this key until the document or selection changes and shares it with its fields. -pub(super) type EditTarget = Option<(u64, u64, Arc)>>)>; +/// The Steps, Distance, Ramp and Shift draft key: the document uid, how many times File › Revert, +/// Undo or Redo and other rollbacks replaced its content (after which a node id can name another +/// object), as [`crate::panels::SelectionTarget`] counts them, and each selected object id paired +/// with its nearest blend id, or None when it resolves to no blend. Symbol-part selections resolve +/// to no blend, as the Blend commands require. A field drops an unfinished value when this key +/// changes, even when the new target shows the same value. [`settings`] reuses this key until the +/// document or selection changes and shares it with its fields. +pub(super) type EditTarget = Option<((u64, u64, u64, u64), Arc)>>)>; /// The resolved objects also hold the selection's ids, so checking the cache copies no selection. struct TargetCache { - uid: u64, + document: (u64, u64, u64, u64), revision: u64, - reverts: u64, symbol_part: Option, objects: Arc)>>, } -/// The active document's uid and revert count, with each selected id and its resolved blend id. -/// Resolution uses the same nearest-node finder and symbol-part guard as the Blend commands. -/// Unchanged document revisions and selections reuse the resolved objects between passes. +/// The active document's uid with its revert, history restore and rollback counts, and each +/// selected id with its resolved blend id. Resolution uses the same nearest-node finder and +/// symbol-part guard as the Blend commands. Unchanged document revisions and selections reuse the +/// resolved objects between passes. pub(super) fn edit_target(app: &VectorcraftApp, ctx: &egui::Context) -> EditTarget { let st = app.session.active()?; + let document = (st.uid, st.reverts, st.history_restores, st.rollbacks); let key = egui::Id::unique("blend-edit-target"); if let Some(held) = ctx.data(|d| d.get_temp::>(key)) - && held.uid == st.uid + && held.document == document && held.revision == st.revision - && held.reverts == st.reverts && held.symbol_part == st.selection.symbol_part && held.objects.iter().map(|(id, _)| id).eq(st.selection.objects.iter()) { - return Some((st.uid, st.reverts, held.objects.clone())); + return Some((document, held.objects.clone())); } let mut find = st.doc.nearest_finder(); let objects: Vec<(NodeId, Option)> = st @@ -155,16 +157,10 @@ pub(super) fn edit_target(app: &VectorcraftApp, ctx: &egui::Context) -> EditTarg ctx.data_mut(|d| { d.insert_temp( key, - Arc::new(TargetCache { - uid: st.uid, - revision: st.revision, - reverts: st.reverts, - symbol_part: st.selection.symbol_part.clone(), - objects: objects.clone(), - }), + Arc::new(TargetCache { document, revision: st.revision, symbol_part: st.selection.symbol_part.clone(), objects: objects.clone() }), ); }); - Some((st.uid, st.reverts, objects)) + Some((document, objects)) } /// Spacing and Orientation, as `object.blend.info` reports them; a change runs diff --git a/crates/ui-egui/src/panels/tests_blend.rs b/crates/ui-egui/src/panels/tests_blend.rs index b43eb606ad..69270e83c8 100644 --- a/crates/ui-egui/src/panels/tests_blend.rs +++ b/crates/ui-egui/src/panels/tests_blend.rs @@ -92,7 +92,7 @@ fn the_edit_target_is_reused_until_the_document_or_selection_changes() { app.run("select.set", json!({"ids": [ids[0].0, blend.0, ids[1].0]})).unwrap(); (ids, blend) }; - let resolved = |app: &VectorcraftApp| edit_target(app, &ctx).unwrap().2; + let resolved = |app: &VectorcraftApp| edit_target(app, &ctx).unwrap().1; let (ids, blend) = art(&mut app); let first = resolved(&app); assert_eq!(*first, vec![(ids[0], Some(blend)), (blend, Some(blend)), (ids[1], Some(blend))]); @@ -149,14 +149,17 @@ fn the_edit_target_is_reused_until_the_document_or_selection_changes() { assert!(!Arc::ptr_eq(&whole, &reverted), "the key is resolved for the new document state after reverting"); assert!(Arc::ptr_eq(&reverted, &resolved(&app))); - // Another document uses the same ids, revision, revert count and selection. + // Another document uses the same ids, revision, revert, history restore and rollback counts and selection. let st = app.session.active().unwrap(); - let (revision, reverts, selection) = (st.revision, st.reverts, st.selection.objects.clone()); + let (revision, reverts, restores, rollbacks, selection) = + (st.revision, st.reverts, st.history_restores, st.rollbacks, st.selection.objects.clone()); let (other_ids, other_blend) = art(&mut app); assert_eq!((other_ids, other_blend), (ids, blend)); let st = app.session.active_mut().unwrap(); st.revision = revision; st.reverts = reverts; + st.history_restores = restores; + st.rollbacks = rollbacks; st.selection.objects = selection; let other_document = resolved(&app); assert!(!Arc::ptr_eq(&reverted, &other_document), "the key is resolved for the new document state in another document"); @@ -806,3 +809,108 @@ fn an_unfinished_steps_value_is_dropped_by_file_revert() { p.key(Key::Enter, Modifiers::NONE); assert_eq!(spec(&p.app(), id).spacing, BlendSpacing::Steps(1), "Revert drops the unfinished value"); } + +#[test] +fn an_unfinished_steps_value_does_not_reach_a_blend_that_takes_a_canceled_groups_blend_id() { + use craft::ui::contract::Role; + use egui::{Key, Modifiers}; + let blend = |app: &mut VectorcraftApp| { + let ids: Vec = + [0, 200].map(|x| app.run("shape.rectangle", json!({"x": x, "y": 0, "width": 20, "height": 20})).unwrap()["id"].clone()).into(); + app.run("select.set", json!({"ids": ids})).unwrap(); + let id = app.run("object.blend.make", json!({"spacing": "steps", "steps": 5})).unwrap()["id"].clone(); + app.run("select.set", json!({"ids": [id]})).unwrap(); + NodeId(id.as_u64().unwrap()) + }; + let mut app = VectorcraftApp::new(Session::new(), Default::default()); + app.run("file.new", json!({"width": 300, "height": 300})).unwrap(); + app.run("edit.undoGroup.begin", json!({})).unwrap(); + let first = blend(&mut app); + let mut p = Panel::new(app, show); + p.click_role("Steps:", Role::SPIN_BUTTON); + p.key(Key::A, Modifiers::COMMAND); + p.type_text("3+"); + + // Canceling the group removes the blend; the same art made again gives a blend with its id and steps. + p.app().run("edit.undoGroup.end", json!({"cancel": true})).unwrap(); + let second = blend(&mut p.app()); + assert_eq!(second, first, "the new blend takes the canceled group's blend's node ID"); + p.frame(); + p.type_text("1"); + p.key(Key::Enter, Modifiers::NONE); + assert_eq!(spec(&p.app(), second).spacing, BlendSpacing::Steps(1), "the new blend takes 1 step, not 3+1"); +} + +#[test] +fn an_unfinished_steps_value_does_not_reach_a_blend_that_takes_a_canceled_previews_blend_id() { + use craft::ui::contract::Role; + use egui::{Key, Modifiers}; + let mut app = app(); + let params = json!({"spacing": "steps", "steps": 5}); + app.session.begin_interaction("Blend").unwrap(); + let first = NodeId(app.session.preview("object.blend.make", ¶ms).unwrap()["id"].as_u64().unwrap()); + let mut p = Panel::new(app, show); + p.click_role("Steps:", Role::SPIN_BUTTON); + p.key(Key::A, Modifiers::COMMAND); + p.type_text("3+"); + + // Canceling the preview restores the selected rectangles and frees the blend's node ID without a history restore. + { + let mut app = p.app(); + let st = app.session.active().unwrap(); + let (rollbacks, restores) = (st.rollbacks, st.history_restores); + app.session.cancel_interaction().unwrap(); + let st = app.session.active().unwrap(); + assert!(st.rollbacks > rollbacks, "canceling the preview advances the rollback count"); + assert_eq!(st.history_restores, restores, "canceling the preview leaves the history restore count unchanged"); + } + let second = NodeId(p.app().run("object.blend.make", params).unwrap()["id"].as_u64().unwrap()); + assert_eq!(second, first, "the new blend takes the canceled preview's blend's node ID"); + p.app().run("select.set", json!({"ids": [second.0]})).unwrap(); + p.frame(); + p.type_text("1"); + p.key(Key::Enter, Modifiers::NONE); + assert_eq!(spec(&p.app(), second).spacing, BlendSpacing::Steps(1), "the new blend takes 1 step, not 3+1"); +} + +#[test] +fn an_unfinished_steps_ramp_or_shift_value_is_dropped_by_undo_and_redo() { + use craft::ui::contract::Role; + use egui::{Key, Modifiers}; + let (mut app, id) = pathed(); + let reset = json!({"spacing": "steps", "steps": 5, "ramp": 30, "colorShift": 30}); + app.run("object.blend.options", reset.clone()).unwrap(); + let mut p = Panel::new(app, show); + for name in ["Steps:", "Ramp:", "Shift:"] { + let value = |s: &BlendSpec| match name { + "Steps:" => match s.spacing { + BlendSpacing::Steps(n) => f64::from(n), + _ => f64::NAN, + }, + "Ramp:" => s.ease.ramp * 100.0, + _ => s.color_shift, + }; + for cmd in ["edit.undo", "edit.redo"] { + // A change elsewhere for Undo or Redo to replace, leaving the blend as it is. + p.app().run("shape.rectangle", json!({"x": 100, "y": 200, "width": 20, "height": 20})).unwrap(); + if cmd == "edit.redo" { + p.app().run("edit.undo", json!({})).unwrap(); + } + p.app().run("select.set", json!({"ids": [id.0]})).unwrap(); + p.frame(); + p.click_role(name, Role::SPIN_BUTTON); + p.key(Key::A, Modifiers::COMMAND); + p.type_text("3+"); + + // The restored document has the same blend and, selected again, the same selection. + p.app().run(cmd, json!({})).unwrap(); + p.app().run("select.set", json!({"ids": [id.0]})).unwrap(); + p.frame(); + p.type_text("1"); + p.key(Key::Enter, Modifiers::NONE); + let at = value(&spec(&p.app(), id)); + assert!((at - 1.0).abs() < 1e-9, "{name}: {cmd} drops the unfinished value, so the blend takes 1, not 3+1: {at}"); + p.app().run("object.blend.options", reset.clone()).unwrap(); + } + } +} From e6ed3a2a4c65b7d371c242297f6e492e48ebd3f9 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 5 Dec 2026 17:11:28 -0800 Subject: [PATCH 11/14] Effects: Glowing Edges scales its glow by the whole object's strongest edge at every zoom Glowing Edges divides each pixel's edge strength by the strongest edge in its input (crates/effects/src/pixel/edges.rs:45-56), but its reach let the renderer crop the raster to the view once the object passed the pixel budget. A zoomed-in frame then took the peak from the part in view, so the same edge glowed at a different brightness depending on the zoom and on where the view was, and a pan within a kept crop's margin kept the earlier crop's peak. Glowing Edges now has no nearby reach, as Torn Edges and Cutout, whose results also depend on the whole object: past the budget the whole object is filtered at a lower resolution, and whole-pixel pans reuse that raster. --- crates/effects/src/pixel.rs | 6 ++--- crates/render/src/fx/tests.rs | 50 +++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 3 deletions(-) diff --git a/crates/effects/src/pixel.rs b/crates/effects/src/pixel.rs index f6c33079c0..116b1ea20b 100644 --- a/crates/effects/src/pixel.rs +++ b/crates/effects/src/pixel.rs @@ -717,7 +717,6 @@ impl PixelFx { PixelFx::Charcoal { thickness, detail, .. } => Some(sketch_ink::charcoal_reach(thickness, detail)), PixelFx::Photocopy { detail, .. } => Some(sketch_ink::copy_reach(detail)), PixelFx::Stamp { smoothness, .. } => Some(sketch_ink::stamp_reach(smoothness)), - PixelFx::GlowingEdges { width, smoothness, .. } => Some(width.max(smoothness * 3.0)), // The cells around the pixel's, and the cells around theirs. // (Without a usable grid there are no dots: see `pixelate::color_halftone`.) PixelFx::ColorHalftone { max_radius, .. } => { @@ -740,8 +739,9 @@ impl PixelFx { PixelFx::WaterPaper { fiber_length, .. } => { Some(sketch::water_paper_shift(fiber_length) + 3.0 * (0.06 * fiber_length.clamp(3.0, 50.0)).max(0.35)) } - // Cutout's palette and Torn Edges' peak-normalised edges come from the whole object. - PixelFx::Cutout { .. } | PixelFx::TornEdges { .. } => None, + // Cutout's palette and the peak-normalized edges of Torn Edges and Glowing Edges come + // from the whole object. + PixelFx::Cutout { .. } | PixelFx::TornEdges { .. } | PixelFx::GlowingEdges { .. } => None, // The softened tones around the pixel. PixelFx::NeonGlow { size, .. } => Some(3.0 * artistic::glow_spread(size)), PixelFx::PlasticWrap { smoothness, .. } => Some(artistic::plastic_reach(smoothness)), diff --git a/crates/render/src/fx/tests.rs b/crates/render/src/fx/tests.rs index 21e0e9fbd9..c551162d2f 100644 --- a/crates/render/src/fx/tests.rs +++ b/crates/render/src/fx/tests.rs @@ -3016,6 +3016,56 @@ fn photoshop_filters_on_content_larger_than_the_budget() { } } +/// Glowing Edges scales every edge by the strongest one in the object, so a zoomed-in frame draws +/// a point's glow as the whole object draws it. The object is a white 4 × 80 pt bar beside +/// stripes 0.5 pt wide and 1 pt apart, whose edges lie close together and glow strongest, on +/// black. At 400 % the whole object fits the pixel budget; at 6400 % a 200 × 200 view shows only +/// the bar's left edge, and the stripes lie beyond what the effect reads around the view. The pans +/// move the view 10 and 20 pixels, the second within the margin a raster made again at the same +/// zoom keeps, which reaches the stripes. +#[test] +fn glowing_edges_zoomed_in_glow_as_bright_as_in_the_whole_object() { + use vectorcraft_geom::{PathData, SubPath}; + let rect = |x0: f64, y0: f64, x1: f64, y1: f64| { + SubPath::polyline(&[Point::new(x0, y0), Point::new(x1, y0), Point::new(x1, y1), Point::new(x0, y1)], true) + }; + let mut subpaths = vec![rect(10.0, 10.0, 14.0, 90.0)]; + subpaths.extend((0..30).map(|i| rect(16.0 + f64::from(i), 10.0, 16.5 + f64::from(i), 90.0))); + let mut d = Document::new(100.0, 100.0); + let mut ap = Appearance::basic(Paint::solid(Color::rgb(1.0, 1.0, 1.0)), Paint::None, 0.0); + ap.effects = + vec![Effect { id: "stylize.glowingEdges".into(), params: json!({"edgeWidth": 1, "edgeBrightness": 6, "smoothness": 1}), visible: true }]; + let n = Node::path(d.alloc_id(), PathData::new(subpaths), ap); + let l = d.layers[0].id; + d.insert(Some(l), 0, n).unwrap(); + let opts = RenderOptions { background: Some([0, 0, 0, 255]), ..Default::default() }; + // Just inside the bar's left edge. + let at = Point::new(10.125, 50.0); + let glow = |img: &Rendered, view: Affine| { + let p = view * at; + img.pixel(p.x.floor() as u32, p.y.floor() as u32)[0] + }; + let whole_view = Affine::scale(4.0); + let mut whole = Renderer::new(); + let whole_img = whole.render(&d, 400, 400, whole_view, &opts); + assert_eq!(whole.stats.view_sized, 0, "at 400 % the whole object is one raster"); + let whole = glow(&whole_img, whole_view); + let zoomed = |dx: f64| Affine::translate((100.0 - dx, 100.0)) * Affine::scale(64.0) * Affine::translate((-at.x, -at.y)); + let mut r = Renderer::new(); + let mut seen = vec![]; + for dx in [0.0, 10.0, 20.0] { + let view = zoomed(dx); + let panned = glow(&r.render(&d, 200, 200, view, &opts), view); + let fresh = glow(&Renderer::new().render(&d, 200, 200, view, &opts), view); + seen.push((dx, panned, fresh)); + assert!(panned.abs_diff(fresh) <= 2, "panned {dx} px, the frame draws the glow a fresh renderer draws: {seen:?}"); + } + assert!(r.stats.view_sized > 0, "at 6400 % the object is over the pixel budget"); + for (dx, panned, _) in &seen { + assert!(panned.abs_diff(whole) <= 24, "panned {dx} px, the glow is as bright as the whole object's {whole}: {seen:?}"); + } +} + /// #5308: an image's Inner Glow follows its visible pixels, not its frame. A 40 × 40 image whose /// left half is transparent and right half opaque black, on a black page, with a white glow from /// the edges: the transparent half stays black, and the glow lights the opaque half's left edge From 14f92a1fa1c8619c0e8fb65aaa4b65f2ad6cf982 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 5 Dec 2026 17:46:16 -0800 Subject: [PATCH 12/14] DXF Import: a restored Objects on Path member keeps the paints A restored selection loads its paints for new art only when the journal records it with a selection command that loads them on replay. An Objects on Path member, recorded as object.objectsOnPath.selectMember, now keeps the paints as they are, as a symbol part already does. --- crates/engine/src/session/edit.rs | 13 +++++++---- crates/engine/src/tests/objects_on_path.rs | 27 ++++++++++++++++++++++ 2 files changed, 35 insertions(+), 5 deletions(-) diff --git a/crates/engine/src/session/edit.rs b/crates/engine/src/session/edit.rs index 54738772f7..49eb17f799 100644 --- a/crates/engine/src/session/edit.rs +++ b/crates/engine/src/session/edit.rs @@ -269,8 +269,9 @@ impl Session { /// artboard that is not new art are left out. In the active document, outside a command and an /// interaction, the journal records the selection that comes back, with the current layer kept, /// in the open undo groups too, and the paints for new art load from it as `select.set` loads - /// them (with New Art Has Basic Appearance on, a symbol part does not load its paints, as - /// `symbol.instance.selectPart` does not), so a recorded action replays as it ran. + /// them (with New Art Has Basic Appearance on, a symbol part or an Objects on Path member does + /// not load its paints, as `symbol.instance.selectPart` and + /// `object.objectsOnPath.selectMember` do not), so a recorded action replays as it ran. pub fn restore_selection(&mut self, uid: u64, selection: Selection) -> Result<()> { let active = self.active().is_some_and(|st| st.uid == uid && st.interaction.is_none()) && self.depth == 0; let st = self.document_mut(uid).ok_or(EngineError::NoDocument)?; @@ -286,8 +287,10 @@ impl Session { return Ok(()); } let steps = selection_steps(&st.selection, &made, &st.doc, layer, &st.highlighted_rows()); - // A symbol part comes back through `symbol.instance.selectPart`, which loads no paints. - let part = st.selection.symbol_part.is_some(); + // Only the selection commands load paints on replay: a symbol part comes back through + // `symbol.instance.selectPart` and an Objects on Path member through + // `object.objectsOnPath.selectMember`, which load none. + let loads = steps.iter().any(|(id, _)| id.starts_with("select.") || id == "layer.target"); let (from, grouped) = (self.journal.len(), self.undo_group_docs()); for step in steps { self.journal.push(step); @@ -297,7 +300,7 @@ impl Session { // of a defaults-only paint that ran before it. self.defaults_only_ran = None; self.inherit_new_art(); - if !part { + if loads { self.load_selection_paints(); } Ok(()) diff --git a/crates/engine/src/tests/objects_on_path.rs b/crates/engine/src/tests/objects_on_path.rs index d9e76f85bf..fc1066a8e1 100644 --- a/crates/engine/src/tests/objects_on_path.rs +++ b/crates/engine/src/tests/objects_on_path.rs @@ -875,3 +875,30 @@ fn objects_moved_out_together_in_the_layers_panel_all_leave_the_path() { let (layer, at) = place_of(&s, g); assert_eq!((place_of(&s, left), place_of(&s, middle)), ((layer, at + 1), (layer, at + 2)), "above the group, in their order"); } + +/// A restored Objects on Path member keeps the paints for new art as they are, as the journal +/// entry that records it (`object.objectsOnPath.selectMember`) does when it is replayed. +#[test] +fn a_restored_member_leaves_the_same_paints_live_and_on_replay() { + let mut s = session(); + let (g, [a, b, c], _) = three_on_a_line(&mut s); + s.execute("paint.setFill", &json!({"ids": [a.0, b.0, c.0, g.0], "color": "#ff0000"})).unwrap(); + s.execute("object.objectsOnPath.selectMember", &json!({"member": b.0})).unwrap(); + let saved = s.doc().unwrap().selection.clone(); + let blue = rect(&mut s, 400.0, 0.0, 10.0, 10.0); + s.execute("paint.setFill", &json!({"ids": [blue.0], "color": "#0000ff"})).unwrap(); + select(&mut s, &[blue]); + let before = s.paint.clone(); + let (uid, from) = (s.doc().unwrap().uid, s.journal.len()); + s.restore_selection(uid, saved.clone()).unwrap(); + assert_eq!(s.doc().unwrap().selection, saved); + assert_eq!(s.paint, before, "selecting a member keeps the paints for new art"); + let steps = s.journal.since(from).to_vec(); + assert_eq!(steps.iter().map(|(c, _)| c.as_str()).collect::>(), ["object.objectsOnPath.selectMember"]); + select(&mut s, &[blue]); + for (cmd, p) in steps { + s.execute(&cmd, &p).unwrap(); + } + assert_eq!(s.doc().unwrap().selection, saved); + assert_eq!(s.paint, before, "the replay leaves the same paints"); +} From 78b192e5f50c860a075cc579423e2890cfc23efc Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Sat, 5 Dec 2026 21:07:11 -0500 Subject: [PATCH 13/14] Pin craft-libs at 138ce992, which carries the shared vector kernel craft-libs main now holds craft-geom, craft-pathops and craft-trace (storytold/craft-libs#2260, RFC-0030 step 1). The pin moves first, as its own change, so the cutover that deletes VectorCraft's copies only swaps crates. API changes since f9e5cecc, behaviour kept: - craft-dxf's Drawing has block definitions; VectorCraft writes none. - craft-cdr reads text as Object::Text and counts what a CMX read left out; CDR text stays left out under the existing unsupported-objects warning, as it was when the reader dropped it. --- Cargo.lock | 273 ++++++++++++++------- Cargo.toml | 84 +++---- apps/vectorcraft-web/Cargo.toml | 2 +- crates/cad/src/scene.rs | 1 + crates/engine/src/cmd/fileio/cdr.rs | 4 +- crates/engine/src/cmd/fileio/cdr/shapes.rs | 15 +- crates/engine/src/cmd/fileio/cmx.rs | 10 +- 7 files changed, 247 insertions(+), 142 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 049b499aaf..75ec41e2f0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1256,7 +1256,7 @@ dependencies = [ [[package]] name = "craft" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f9e5cecc9cf1b701b22f6f24a88719b14456323e#f9e5cecc9cf1b701b22f6f24a88719b14456323e" +source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97" dependencies = [ "craft-automation", "craft-behavior", @@ -1298,7 +1298,7 @@ dependencies = [ [[package]] name = "craft-affinity" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f9e5cecc9cf1b701b22f6f24a88719b14456323e#f9e5cecc9cf1b701b22f6f24a88719b14456323e" +source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97" dependencies = [ "crc32fast", "flate2", @@ -1319,7 +1319,7 @@ dependencies = [ [[package]] name = "craft-appkit" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f9e5cecc9cf1b701b22f6f24a88719b14456323e#f9e5cecc9cf1b701b22f6f24a88719b14456323e" +source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97" dependencies = [ "block2 0.6.2", "objc2 0.6.5", @@ -1331,7 +1331,7 @@ dependencies = [ [[package]] name = "craft-atomic" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f9e5cecc9cf1b701b22f6f24a88719b14456323e#f9e5cecc9cf1b701b22f6f24a88719b14456323e" +source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97" dependencies = [ "rustix 1.1.6", ] @@ -1339,7 +1339,7 @@ dependencies = [ [[package]] name = "craft-automation" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f9e5cecc9cf1b701b22f6f24a88719b14456323e#f9e5cecc9cf1b701b22f6f24a88719b14456323e" +source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97" dependencies = [ "base64 0.23.1", "craft-behavior", @@ -1364,7 +1364,7 @@ dependencies = [ [[package]] name = "craft-behavior" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f9e5cecc9cf1b701b22f6f24a88719b14456323e#f9e5cecc9cf1b701b22f6f24a88719b14456323e" +source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97" dependencies = [ "accesskit", "bitflags 2.13.2", @@ -1383,7 +1383,7 @@ dependencies = [ [[package]] name = "craft-browse" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f9e5cecc9cf1b701b22f6f24a88719b14456323e#f9e5cecc9cf1b701b22f6f24a88719b14456323e" +source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97" dependencies = [ "craft-behavior", "craft-docpath", @@ -1401,8 +1401,9 @@ dependencies = [ [[package]] name = "craft-cdr" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f9e5cecc9cf1b701b22f6f24a88719b14456323e#f9e5cecc9cf1b701b22f6f24a88719b14456323e" +source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97" dependencies = [ + "craft-codepage", "crc32fast", "flate2", ] @@ -1410,7 +1411,7 @@ dependencies = [ [[package]] name = "craft-cloud-ui" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f9e5cecc9cf1b701b22f6f24a88719b14456323e#f9e5cecc9cf1b701b22f6f24a88719b14456323e" +source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97" dependencies = [ "egui", ] @@ -1418,7 +1419,7 @@ dependencies = [ [[package]] name = "craft-cms" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f9e5cecc9cf1b701b22f6f24a88719b14456323e#f9e5cecc9cf1b701b22f6f24a88719b14456323e" +source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97" dependencies = [ "md-5", "rayon", @@ -1427,12 +1428,12 @@ dependencies = [ [[package]] name = "craft-codepage" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f9e5cecc9cf1b701b22f6f24a88719b14456323e#f9e5cecc9cf1b701b22f6f24a88719b14456323e" +source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97" [[package]] name = "craft-color-ui" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f9e5cecc9cf1b701b22f6f24a88719b14456323e#f9e5cecc9cf1b701b22f6f24a88719b14456323e" +source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97" dependencies = [ "craft-behavior", "craft-cms", @@ -1452,7 +1453,7 @@ dependencies = [ [[package]] name = "craft-control" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f9e5cecc9cf1b701b22f6f24a88719b14456323e#f9e5cecc9cf1b701b22f6f24a88719b14456323e" +source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97" dependencies = [ "craft-ai-agents", "craft-atomic", @@ -1468,7 +1469,7 @@ dependencies = [ [[package]] name = "craft-control-protocol" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f9e5cecc9cf1b701b22f6f24a88719b14456323e#f9e5cecc9cf1b701b22f6f24a88719b14456323e" +source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97" dependencies = [ "getrandom 0.3.4", "serde_json", @@ -1478,7 +1479,7 @@ dependencies = [ [[package]] name = "craft-dds" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f9e5cecc9cf1b701b22f6f24a88719b14456323e#f9e5cecc9cf1b701b22f6f24a88719b14456323e" +source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97" dependencies = [ "rayon", ] @@ -1486,7 +1487,7 @@ dependencies = [ [[package]] name = "craft-dialogs" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f9e5cecc9cf1b701b22f6f24a88719b14456323e#f9e5cecc9cf1b701b22f6f24a88719b14456323e" +source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97" dependencies = [ "block2 0.6.2", "craft-appkit", @@ -1512,7 +1513,7 @@ dependencies = [ [[package]] name = "craft-doc" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f9e5cecc9cf1b701b22f6f24a88719b14456323e#f9e5cecc9cf1b701b22f6f24a88719b14456323e" +source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97" dependencies = [ "blake3", "craft-ecproj-format", @@ -1528,7 +1529,7 @@ dependencies = [ [[package]] name = "craft-docpath" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f9e5cecc9cf1b701b22f6f24a88719b14456323e#f9e5cecc9cf1b701b22f6f24a88719b14456323e" +source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97" dependencies = [ "serde", ] @@ -1536,7 +1537,7 @@ dependencies = [ [[package]] name = "craft-draw" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f9e5cecc9cf1b701b22f6f24a88719b14456323e#f9e5cecc9cf1b701b22f6f24a88719b14456323e" +source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97" dependencies = [ "craft-behavior", "craft-color-ui", @@ -1555,7 +1556,7 @@ dependencies = [ [[package]] name = "craft-dwg" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f9e5cecc9cf1b701b22f6f24a88719b14456323e#f9e5cecc9cf1b701b22f6f24a88719b14456323e" +source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97" dependencies = [ "acadrust", "craft-dxf", @@ -1565,7 +1566,7 @@ dependencies = [ [[package]] name = "craft-dxf" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f9e5cecc9cf1b701b22f6f24a88719b14456323e#f9e5cecc9cf1b701b22f6f24a88719b14456323e" +source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97" dependencies = [ "craft-codepage", "encoding_rs", @@ -1577,7 +1578,7 @@ dependencies = [ [[package]] name = "craft-ecproj-format" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f9e5cecc9cf1b701b22f6f24a88719b14456323e#f9e5cecc9cf1b701b22f6f24a88719b14456323e" +source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97" dependencies = [ "serde", "serde_json", @@ -1587,12 +1588,12 @@ dependencies = [ [[package]] name = "craft-eps" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f9e5cecc9cf1b701b22f6f24a88719b14456323e#f9e5cecc9cf1b701b22f6f24a88719b14456323e" +source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97" [[package]] name = "craft-flags" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f9e5cecc9cf1b701b22f6f24a88719b14456323e#f9e5cecc9cf1b701b22f6f24a88719b14456323e" +source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97" dependencies = [ "craft-atomic", "dirs", @@ -1602,7 +1603,7 @@ dependencies = [ [[package]] name = "craft-font-catalog" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f9e5cecc9cf1b701b22f6f24a88719b14456323e#f9e5cecc9cf1b701b22f6f24a88719b14456323e" +source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97" dependencies = [ "fontique", "harfrust 0.13.3", @@ -1617,7 +1618,7 @@ dependencies = [ [[package]] name = "craft-font-manager" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f9e5cecc9cf1b701b22f6f24a88719b14456323e#f9e5cecc9cf1b701b22f6f24a88719b14456323e" +source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97" dependencies = [ "craft-behavior", "craft-font-catalog", @@ -1636,7 +1637,7 @@ dependencies = [ [[package]] name = "craft-font-os-windows" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f9e5cecc9cf1b701b22f6f24a88719b14456323e#f9e5cecc9cf1b701b22f6f24a88719b14456323e" +source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97" dependencies = [ "windows-registry", "windows-sys 0.61.2", @@ -1645,7 +1646,7 @@ dependencies = [ [[package]] name = "craft-font-store" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f9e5cecc9cf1b701b22f6f24a88719b14456323e#f9e5cecc9cf1b701b22f6f24a88719b14456323e" +source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97" dependencies = [ "cap-primitives", "craft-atomic", @@ -1668,12 +1669,12 @@ dependencies = [ [[package]] name = "craft-fonts-build" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f9e5cecc9cf1b701b22f6f24a88719b14456323e#f9e5cecc9cf1b701b22f6f24a88719b14456323e" +source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97" [[package]] name = "craft-gif" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f9e5cecc9cf1b701b22f6f24a88719b14456323e#f9e5cecc9cf1b701b22f6f24a88719b14456323e" +source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97" dependencies = [ "gif", ] @@ -1681,7 +1682,7 @@ dependencies = [ [[package]] name = "craft-gzip" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f9e5cecc9cf1b701b22f6f24a88719b14456323e#f9e5cecc9cf1b701b22f6f24a88719b14456323e" +source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97" dependencies = [ "flate2", ] @@ -1689,7 +1690,7 @@ dependencies = [ [[package]] name = "craft-host" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f9e5cecc9cf1b701b22f6f24a88719b14456323e#f9e5cecc9cf1b701b22f6f24a88719b14456323e" +source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97" dependencies = [ "bitflags 2.13.2", "craft-i18n", @@ -1702,7 +1703,7 @@ dependencies = [ [[package]] name = "craft-i18n" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f9e5cecc9cf1b701b22f6f24a88719b14456323e#f9e5cecc9cf1b701b22f6f24a88719b14456323e" +source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97" dependencies = [ "brotli 9.1.3", "brotli-decompressor 6.3.2", @@ -1732,7 +1733,7 @@ dependencies = [ [[package]] name = "craft-image-codecs" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f9e5cecc9cf1b701b22f6f24a88719b14456323e#f9e5cecc9cf1b701b22f6f24a88719b14456323e" +source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97" dependencies = [ "craft-dds", "craft-jpeg", @@ -1759,7 +1760,7 @@ dependencies = [ [[package]] name = "craft-imaging" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f9e5cecc9cf1b701b22f6f24a88719b14456323e#f9e5cecc9cf1b701b22f6f24a88719b14456323e" +source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97" dependencies = [ "craft-behavior", "craft-color-ui", @@ -1777,7 +1778,7 @@ dependencies = [ [[package]] name = "craft-jpeg" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f9e5cecc9cf1b701b22f6f24a88719b14456323e#f9e5cecc9cf1b701b22f6f24a88719b14456323e" +source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97" dependencies = [ "thiserror 2.0.21", ] @@ -1785,7 +1786,7 @@ dependencies = [ [[package]] name = "craft-jxl" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f9e5cecc9cf1b701b22f6f24a88719b14456323e#f9e5cecc9cf1b701b22f6f24a88719b14456323e" +source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97" dependencies = [ "brotli-decompressor 5.0.3", "jixel", @@ -1796,7 +1797,7 @@ dependencies = [ [[package]] name = "craft-keymap" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f9e5cecc9cf1b701b22f6f24a88719b14456323e#f9e5cecc9cf1b701b22f6f24a88719b14456323e" +source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97" dependencies = [ "craft-host", "craft-i18n", @@ -1811,7 +1812,7 @@ dependencies = [ [[package]] name = "craft-layers" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f9e5cecc9cf1b701b22f6f24a88719b14456323e#f9e5cecc9cf1b701b22f6f24a88719b14456323e" +source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97" dependencies = [ "craft-behavior", "craft-i18n", @@ -1825,7 +1826,7 @@ dependencies = [ [[package]] name = "craft-menu" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f9e5cecc9cf1b701b22f6f24a88719b14456323e#f9e5cecc9cf1b701b22f6f24a88719b14456323e" +source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97" dependencies = [ "craft-behavior", "craft-host", @@ -1843,7 +1844,7 @@ dependencies = [ [[package]] name = "craft-metadata" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f9e5cecc9cf1b701b22f6f24a88719b14456323e#f9e5cecc9cf1b701b22f6f24a88719b14456323e" +source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97" dependencies = [ "brotli-decompressor 6.3.2", "chrono", @@ -1855,7 +1856,7 @@ dependencies = [ [[package]] name = "craft-metafile" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f9e5cecc9cf1b701b22f6f24a88719b14456323e#f9e5cecc9cf1b701b22f6f24a88719b14456323e" +source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97" dependencies = [ "encoding_rs", "image", @@ -1866,7 +1867,7 @@ dependencies = [ [[package]] name = "craft-mime" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f9e5cecc9cf1b701b22f6f24a88719b14456323e#f9e5cecc9cf1b701b22f6f24a88719b14456323e" +source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97" dependencies = [ "chrono", "craft-codepage", @@ -1876,7 +1877,7 @@ dependencies = [ [[package]] name = "craft-nightly" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f9e5cecc9cf1b701b22f6f24a88719b14456323e#f9e5cecc9cf1b701b22f6f24a88719b14456323e" +source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97" dependencies = [ "uds_windows", "winsafe", @@ -1885,7 +1886,7 @@ dependencies = [ [[package]] name = "craft-pages" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f9e5cecc9cf1b701b22f6f24a88719b14456323e#f9e5cecc9cf1b701b22f6f24a88719b14456323e" +source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97" dependencies = [ "craft-behavior", "craft-keymap", @@ -1901,7 +1902,7 @@ dependencies = [ [[package]] name = "craft-pbr" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f9e5cecc9cf1b701b22f6f24a88719b14456323e#f9e5cecc9cf1b701b22f6f24a88719b14456323e" +source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97" dependencies = [ "craft-texture", "thiserror 2.0.21", @@ -1910,7 +1911,7 @@ dependencies = [ [[package]] name = "craft-pcraft-format" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f9e5cecc9cf1b701b22f6f24a88719b14456323e#f9e5cecc9cf1b701b22f6f24a88719b14456323e" +source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97" dependencies = [ "flate2", "serde", @@ -1921,7 +1922,7 @@ dependencies = [ [[package]] name = "craft-pdf" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f9e5cecc9cf1b701b22f6f24a88719b14456323e#f9e5cecc9cf1b701b22f6f24a88719b14456323e" +source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97" dependencies = [ "hayro-interpret", "hayro-syntax", @@ -1933,7 +1934,7 @@ dependencies = [ [[package]] name = "craft-platform" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f9e5cecc9cf1b701b22f6f24a88719b14456323e#f9e5cecc9cf1b701b22f6f24a88719b14456323e" +source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97" dependencies = [ "async-channel", "async-io", @@ -1947,6 +1948,7 @@ dependencies = [ "futures-lite", "js-sys", "log", + "notify", "objc2-app-kit 0.3.2", "objc2-core-foundation", "objc2-core-graphics", @@ -1966,7 +1968,7 @@ dependencies = [ [[package]] name = "craft-plotter" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f9e5cecc9cf1b701b22f6f24a88719b14456323e#f9e5cecc9cf1b701b22f6f24a88719b14456323e" +source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97" dependencies = [ "kurbo 0.13.1", "thiserror 2.0.21", @@ -1975,7 +1977,7 @@ dependencies = [ [[package]] name = "craft-print" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f9e5cecc9cf1b701b22f6f24a88719b14456323e#f9e5cecc9cf1b701b22f6f24a88719b14456323e" +source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97" dependencies = [ "craft-behavior", "craft-host", @@ -1999,7 +2001,7 @@ dependencies = [ [[package]] name = "craft-proof" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f9e5cecc9cf1b701b22f6f24a88719b14456323e#f9e5cecc9cf1b701b22f6f24a88719b14456323e" +source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97" dependencies = [ "log", "miniz_oxide 0.9.1", @@ -2010,7 +2012,7 @@ dependencies = [ [[package]] name = "craft-ps" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f9e5cecc9cf1b701b22f6f24a88719b14456323e#f9e5cecc9cf1b701b22f6f24a88719b14456323e" +source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97" dependencies = [ "craft-eps", "flate2", @@ -2024,7 +2026,7 @@ dependencies = [ [[package]] name = "craft-psd" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f9e5cecc9cf1b701b22f6f24a88719b14456323e#f9e5cecc9cf1b701b22f6f24a88719b14456323e" +source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97" dependencies = [ "encoding_rs", "flate2", @@ -2035,7 +2037,7 @@ dependencies = [ [[package]] name = "craft-quit" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f9e5cecc9cf1b701b22f6f24a88719b14456323e#f9e5cecc9cf1b701b22f6f24a88719b14456323e" +source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97" dependencies = [ "dispatch2", "egui", @@ -2048,7 +2050,7 @@ dependencies = [ [[package]] name = "craft-raster3d" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f9e5cecc9cf1b701b22f6f24a88719b14456323e#f9e5cecc9cf1b701b22f6f24a88719b14456323e" +source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97" dependencies = [ "rayon", "thiserror 2.0.21", @@ -2057,7 +2059,7 @@ dependencies = [ [[package]] name = "craft-review" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f9e5cecc9cf1b701b22f6f24a88719b14456323e#f9e5cecc9cf1b701b22f6f24a88719b14456323e" +source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97" dependencies = [ "base64 0.23.1", "craft-behavior", @@ -2076,7 +2078,7 @@ dependencies = [ [[package]] name = "craft-settings" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f9e5cecc9cf1b701b22f6f24a88719b14456323e#f9e5cecc9cf1b701b22f6f24a88719b14456323e" +source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97" dependencies = [ "craft-atomic", "craft-host", @@ -2093,7 +2095,7 @@ dependencies = [ [[package]] name = "craft-stream-codecs" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f9e5cecc9cf1b701b22f6f24a88719b14456323e#f9e5cecc9cf1b701b22f6f24a88719b14456323e" +source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97" dependencies = [ "fax", "hayro-ccitt", @@ -2104,7 +2106,7 @@ dependencies = [ [[package]] name = "craft-svg" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f9e5cecc9cf1b701b22f6f24a88719b14456323e#f9e5cecc9cf1b701b22f6f24a88719b14456323e" +source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97" dependencies = [ "craft-image-codecs", "craft-xml", @@ -2125,7 +2127,7 @@ dependencies = [ [[package]] name = "craft-table" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f9e5cecc9cf1b701b22f6f24a88719b14456323e#f9e5cecc9cf1b701b22f6f24a88719b14456323e" +source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97" dependencies = [ "craft-behavior", "craft-keymap", @@ -2137,7 +2139,7 @@ dependencies = [ [[package]] name = "craft-text" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f9e5cecc9cf1b701b22f6f24a88719b14456323e#f9e5cecc9cf1b701b22f6f24a88719b14456323e" +source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97" dependencies = [ "craft-behavior", "craft-font-manager", @@ -2162,7 +2164,7 @@ dependencies = [ [[package]] name = "craft-texture" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f9e5cecc9cf1b701b22f6f24a88719b14456323e#f9e5cecc9cf1b701b22f6f24a88719b14456323e" +source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97" dependencies = [ "thiserror 2.0.21", ] @@ -2170,7 +2172,7 @@ dependencies = [ [[package]] name = "craft-theme" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f9e5cecc9cf1b701b22f6f24a88719b14456323e#f9e5cecc9cf1b701b22f6f24a88719b14456323e" +source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97" dependencies = [ "bitflags 2.13.2", "craft-tracked", @@ -2185,7 +2187,7 @@ dependencies = [ [[package]] name = "craft-theme-store" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f9e5cecc9cf1b701b22f6f24a88719b14456323e#f9e5cecc9cf1b701b22f6f24a88719b14456323e" +source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97" dependencies = [ "craft-atomic", "craft-behavior", @@ -2200,7 +2202,7 @@ dependencies = [ [[package]] name = "craft-tiff" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f9e5cecc9cf1b701b22f6f24a88719b14456323e#f9e5cecc9cf1b701b22f6f24a88719b14456323e" +source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97" dependencies = [ "serde", "thiserror 2.0.21", @@ -2210,7 +2212,7 @@ dependencies = [ [[package]] name = "craft-time" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f9e5cecc9cf1b701b22f6f24a88719b14456323e#f9e5cecc9cf1b701b22f6f24a88719b14456323e" +source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97" dependencies = [ "serde", "thiserror 2.0.21", @@ -2219,7 +2221,7 @@ dependencies = [ [[package]] name = "craft-timeline" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f9e5cecc9cf1b701b22f6f24a88719b14456323e#f9e5cecc9cf1b701b22f6f24a88719b14456323e" +source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97" dependencies = [ "craft-behavior", "craft-keymap", @@ -2234,12 +2236,12 @@ dependencies = [ [[package]] name = "craft-tracked" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f9e5cecc9cf1b701b22f6f24a88719b14456323e#f9e5cecc9cf1b701b22f6f24a88719b14456323e" +source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97" [[package]] name = "craft-ui" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f9e5cecc9cf1b701b22f6f24a88719b14456323e#f9e5cecc9cf1b701b22f6f24a88719b14456323e" +source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97" dependencies = [ "craft-cloud-ui", "craft-ui-canvas", @@ -2253,7 +2255,7 @@ dependencies = [ [[package]] name = "craft-ui-canvas" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f9e5cecc9cf1b701b22f6f24a88719b14456323e#f9e5cecc9cf1b701b22f6f24a88719b14456323e" +source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97" dependencies = [ "craft-behavior", "craft-font-catalog", @@ -2270,7 +2272,7 @@ dependencies = [ [[package]] name = "craft-ui-contract" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f9e5cecc9cf1b701b22f6f24a88719b14456323e#f9e5cecc9cf1b701b22f6f24a88719b14456323e" +source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97" dependencies = [ "accesskit", "craft-behavior", @@ -2308,7 +2310,7 @@ dependencies = [ [[package]] name = "craft-ui-macros" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f9e5cecc9cf1b701b22f6f24a88719b14456323e#f9e5cecc9cf1b701b22f6f24a88719b14456323e" +source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -2319,7 +2321,7 @@ dependencies = [ [[package]] name = "craft-ui-panels" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f9e5cecc9cf1b701b22f6f24a88719b14456323e#f9e5cecc9cf1b701b22f6f24a88719b14456323e" +source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97" dependencies = [ "craft-behavior", "craft-host", @@ -2337,7 +2339,7 @@ dependencies = [ [[package]] name = "craft-ui-patterns" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f9e5cecc9cf1b701b22f6f24a88719b14456323e#f9e5cecc9cf1b701b22f6f24a88719b14456323e" +source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97" dependencies = [ "craft-behavior", "craft-host", @@ -2358,7 +2360,7 @@ dependencies = [ [[package]] name = "craft-ui-shell" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f9e5cecc9cf1b701b22f6f24a88719b14456323e#f9e5cecc9cf1b701b22f6f24a88719b14456323e" +source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97" dependencies = [ "craft-behavior", "craft-host", @@ -2379,7 +2381,7 @@ dependencies = [ [[package]] name = "craft-ui-widgets" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f9e5cecc9cf1b701b22f6f24a88719b14456323e#f9e5cecc9cf1b701b22f6f24a88719b14456323e" +source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97" dependencies = [ "craft-behavior", "craft-host", @@ -2393,12 +2395,13 @@ dependencies = [ "log", "serde", "smallvec", + "unicode-segmentation", ] [[package]] name = "craft-update" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f9e5cecc9cf1b701b22f6f24a88719b14456323e#f9e5cecc9cf1b701b22f6f24a88719b14456323e" +source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97" dependencies = [ "base64 0.22.1", "chrono", @@ -2430,7 +2433,7 @@ dependencies = [ [[package]] name = "craft-vectorcraft-format" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f9e5cecc9cf1b701b22f6f24a88719b14456323e#f9e5cecc9cf1b701b22f6f24a88719b14456323e" +source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97" dependencies = [ "flate2", "serde", @@ -2441,7 +2444,7 @@ dependencies = [ [[package]] name = "craft-wayland" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f9e5cecc9cf1b701b22f6f24a88719b14456323e#f9e5cecc9cf1b701b22f6f24a88719b14456323e" +source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97" dependencies = [ "raw-window-handle", "wayland-backend", @@ -2451,7 +2454,7 @@ dependencies = [ [[package]] name = "craft-web-api" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f9e5cecc9cf1b701b22f6f24a88719b14456323e#f9e5cecc9cf1b701b22f6f24a88719b14456323e" +source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97" dependencies = [ "js-sys", "serde_json", @@ -2462,7 +2465,7 @@ dependencies = [ [[package]] name = "craft-win32" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f9e5cecc9cf1b701b22f6f24a88719b14456323e#f9e5cecc9cf1b701b22f6f24a88719b14456323e" +source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97" dependencies = [ "winsafe", ] @@ -2470,7 +2473,7 @@ dependencies = [ [[package]] name = "craft-window" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f9e5cecc9cf1b701b22f6f24a88719b14456323e#f9e5cecc9cf1b701b22f6f24a88719b14456323e" +source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97" dependencies = [ "craft-appkit", "craft-atomic", @@ -2502,7 +2505,7 @@ dependencies = [ [[package]] name = "craft-xml" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f9e5cecc9cf1b701b22f6f24a88719b14456323e#f9e5cecc9cf1b701b22f6f24a88719b14456323e" +source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97" dependencies = [ "quick-xml 0.41.0", "serde", @@ -3861,7 +3864,7 @@ checksum = "9f4d0e94ddd48749f06bbe4e5389fb9799a0c45bcaf00495042076ef05e3241a" [[package]] name = "hayro-cmap" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f9e5cecc9cf1b701b22f6f24a88719b14456323e#f9e5cecc9cf1b701b22f6f24a88719b14456323e" +source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97" dependencies = [ "brotli 8.0.4", "hayro-postscript", @@ -3870,7 +3873,7 @@ dependencies = [ [[package]] name = "hayro-interpret" version = "0.7.0" -source = "git+https://github.com/storytold/craft-libs?rev=f9e5cecc9cf1b701b22f6f24a88719b14456323e#f9e5cecc9cf1b701b22f6f24a88719b14456323e" +source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97" dependencies = [ "bitflags 2.13.2", "hayro-cmap", @@ -3888,7 +3891,7 @@ dependencies = [ [[package]] name = "hayro-jbig2" version = "0.3.0" -source = "git+https://github.com/storytold/craft-libs?rev=f9e5cecc9cf1b701b22f6f24a88719b14456323e#f9e5cecc9cf1b701b22f6f24a88719b14456323e" +source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97" dependencies = [ "fearless_simd", "hayro-ccitt", @@ -3906,12 +3909,12 @@ dependencies = [ [[package]] name = "hayro-postscript" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f9e5cecc9cf1b701b22f6f24a88719b14456323e#f9e5cecc9cf1b701b22f6f24a88719b14456323e" +source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97" [[package]] name = "hayro-syntax" version = "0.7.2" -source = "git+https://github.com/storytold/craft-libs?rev=f9e5cecc9cf1b701b22f6f24a88719b14456323e#f9e5cecc9cf1b701b22f6f24a88719b14456323e" +source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97" dependencies = [ "flate2", "hayro-ccitt", @@ -4473,6 +4476,26 @@ dependencies = [ "hashbrown 0.17.1", ] +[[package]] +name = "inotify" +version = "0.11.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cc00ea907cab49550b7da656f80ebb97be1b997d931fbcd28d39734e17ce592" +dependencies = [ + "bitflags 2.13.2", + "inotify-sys", + "libc", +] + +[[package]] +name = "inotify-sys" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c033f80b2c113cdf91ab7a33faa9cbc014726dcad99880c8609af2a370edf37d" +dependencies = [ + "libc", +] + [[package]] name = "inout" version = "0.1.4" @@ -4891,10 +4914,30 @@ dependencies = [ "accesskit_consumer", ] +[[package]] +name = "kqueue" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d763e5b24120b4ddf50de6c92308156765aabfbbccebf401da7cff2d70a41ea" +dependencies = [ + "kqueue-sys", + "libc", +] + +[[package]] +name = "kqueue-sys" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07293a4e297ac234359b510362495713f75ea345d5307140414f20c69ffeb087" +dependencies = [ + "bitflags 2.13.2", + "libc", +] + [[package]] name = "krilla" version = "0.8.2" -source = "git+https://github.com/storytold/craft-libs?rev=f9e5cecc9cf1b701b22f6f24a88719b14456323e#f9e5cecc9cf1b701b22f6f24a88719b14456323e" +source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97" dependencies = [ "base64 0.22.1", "bumpalo", @@ -5051,7 +5094,7 @@ checksum = "d4a5ff6bcca6c4867b1c4fd4ef63e4db7436ef363e0ad7531d1558856bae64f4" [[package]] name = "linesweeper" version = "0.5.0" -source = "git+https://github.com/storytold/craft-libs?rev=f9e5cecc9cf1b701b22f6f24a88719b14456323e#f9e5cecc9cf1b701b22f6f24a88719b14456323e" +source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97" dependencies = [ "arrayvec", "kurbo 0.13.1", @@ -5193,6 +5236,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1788edb87fdc09c7e26304471e2f5be8cdefb1b6930d6e3985fc02ff53bf86ee" dependencies = [ "libc", + "log", "wasi", "windows-sys 0.61.2", ] @@ -5358,6 +5402,35 @@ dependencies = [ "memchr", ] +[[package]] +name = "notify" +version = "9.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5482d5bd11b91a337521980e5d52fe115bdccfb4c217099daaf0abd69159dc4e" +dependencies = [ + "bitflags 2.13.2", + "inotify", + "kqueue", + "libc", + "log", + "mio", + "notify-types", + "objc2-core-foundation", + "objc2-core-services", + "walkdir", + "windows-sys 0.61.2", + "xxhash-rust", +] + +[[package]] +name = "notify-types" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cbd044e85df3d939d8e32a1c35a3b737c7d0a4eeb7acd737bd207644e00f4e5f" +dependencies = [ + "bitflags 2.13.2", +] + [[package]] name = "num" version = "0.4.3" @@ -5712,6 +5785,16 @@ dependencies = [ "objc2-core-video", ] +[[package]] +name = "objc2-core-services" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "583300ad934cba24ff5292aee751ecc070f7ca6b39a574cc21b7b5e588e06a0b" +dependencies = [ + "libc", + "objc2-core-foundation", +] + [[package]] name = "objc2-core-text" version = "0.3.2" @@ -7617,7 +7700,7 @@ dependencies = [ [[package]] name = "skrifa" version = "0.44.0" -source = "git+https://github.com/storytold/craft-libs?rev=f9e5cecc9cf1b701b22f6f24a88719b14456323e#f9e5cecc9cf1b701b22f6f24a88719b14456323e" +source = "git+https://github.com/storytold/craft-libs?rev=138ce9929ea48d055c797f61c042a3c407427d97#138ce9929ea48d055c797f61c042a3c407427d97" dependencies = [ "bytemuck", "read-fonts 0.41.0", @@ -10575,6 +10658,12 @@ dependencies = [ "tempfile", ] +[[package]] +name = "xxhash-rust" +version = "0.8.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40de123dbb523ebcc00d61ec01840ad192578afc378d859f3429caa38308fad5" + [[package]] name = "yeslogic-fontconfig-sys" version = "6.0.1" diff --git a/Cargo.toml b/Cargo.toml index cd35931dc4..4f6f278c59 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,60 +10,60 @@ license = "MIT OR Apache-2.0" rust-version = "1.95" [workspace.dependencies] -craft-cms = { git = "https://github.com/storytold/craft-libs", rev = "f9e5cecc9cf1b701b22f6f24a88719b14456323e" } -craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "f9e5cecc9cf1b701b22f6f24a88719b14456323e", default-features = false, features = ["interpret", "write"] } -craft-docpath = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "f9e5cecc9cf1b701b22f6f24a88719b14456323e" } -craft-proof = { git = "https://github.com/storytold/craft-libs", rev = "f9e5cecc9cf1b701b22f6f24a88719b14456323e" } +craft-cms = { git = "https://github.com/storytold/craft-libs", rev = "138ce9929ea48d055c797f61c042a3c407427d97" } +craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "138ce9929ea48d055c797f61c042a3c407427d97", default-features = false, features = ["interpret", "write"] } +craft-docpath = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "138ce9929ea48d055c797f61c042a3c407427d97" } +craft-proof = { git = "https://github.com/storytold/craft-libs", rev = "138ce9929ea48d055c797f61c042a3c407427d97" } # Language packs: the Craft apps' shared font store installs them (#4936). -craft-font-store = { git = "https://github.com/storytold/craft-libs", rev = "f9e5cecc9cf1b701b22f6f24a88719b14456323e" } -craft-font-catalog = { git = "https://github.com/storytold/craft-libs", rev = "f9e5cecc9cf1b701b22f6f24a88719b14456323e" } +craft-font-store = { git = "https://github.com/storytold/craft-libs", rev = "138ce9929ea48d055c797f61c042a3c407427d97" } +craft-font-catalog = { git = "https://github.com/storytold/craft-libs", rev = "138ce9929ea48d055c797f61c042a3c407427d97" } # The `.vectorcraft` envelope: its members, version, embedded images and the data after the JSON. -craft-vectorcraft-format = { git = "https://github.com/storytold/craft-libs", rev = "f9e5cecc9cf1b701b22f6f24a88719b14456323e" } -craft-gzip = { git = "https://github.com/storytold/craft-libs", rev = "f9e5cecc9cf1b701b22f6f24a88719b14456323e" } +craft-vectorcraft-format = { git = "https://github.com/storytold/craft-libs", rev = "138ce9929ea48d055c797f61c042a3c407427d97" } +craft-gzip = { git = "https://github.com/storytold/craft-libs", rev = "138ce9929ea48d055c797f61c042a3c407427d97" } # `.pcraft` documents: their manifest, full-size composite, preview, layer pixels and ICC profile. -craft-doc = { git = "https://github.com/storytold/craft-libs", rev = "f9e5cecc9cf1b701b22f6f24a88719b14456323e", features = ["pcraft-pixels"] } +craft-doc = { git = "https://github.com/storytold/craft-libs", rev = "138ce9929ea48d055c797f61c042a3c407427d97", features = ["pcraft-pixels"] } # Native Affinity documents (craft-libs#914). -craft-affinity = { git = "https://github.com/storytold/craft-libs", rev = "f9e5cecc9cf1b701b22f6f24a88719b14456323e" } +craft-affinity = { git = "https://github.com/storytold/craft-libs", rev = "138ce9929ea48d055c797f61c042a3c407427d97" } # Bounded CDR (v1-v27) and CMX (32-bit) reader (craft-libs#778). -craft-cdr = { git = "https://github.com/storytold/craft-libs", rev = "f9e5cecc9cf1b701b22f6f24a88719b14456323e" } +craft-cdr = { git = "https://github.com/storytold/craft-libs", rev = "138ce9929ea48d055c797f61c042a3c407427d97" } # SVG parsing, limits, SVGZ and writer (craft-libs#778). -craft-svg = { git = "https://github.com/storytold/craft-libs", rev = "f9e5cecc9cf1b701b22f6f24a88719b14456323e", features = ["tree"] } -craft-mime = { git = "https://github.com/storytold/craft-libs", rev = "f9e5cecc9cf1b701b22f6f24a88719b14456323e" } +craft-svg = { git = "https://github.com/storytold/craft-libs", rev = "138ce9929ea48d055c797f61c042a3c407427d97", features = ["tree"] } +craft-mime = { git = "https://github.com/storytold/craft-libs", rev = "138ce9929ea48d055c797f61c042a3c407427d97" } # EPS container, previews, ASCII85 and DSC comments (craft-libs#778). -craft-eps = { git = "https://github.com/storytold/craft-libs", rev = "f9e5cecc9cf1b701b22f6f24a88719b14456323e" } +craft-eps = { git = "https://github.com/storytold/craft-libs", rev = "138ce9929ea48d055c797f61c042a3c407427d97" } # DXF tags, reader and writer (craft-libs#778, #926, #927). -craft-plotter = { git = "https://github.com/storytold/craft-libs", rev = "f9e5cecc9cf1b701b22f6f24a88719b14456323e" } -craft-dxf = { git = "https://github.com/storytold/craft-libs", rev = "f9e5cecc9cf1b701b22f6f24a88719b14456323e" } +craft-plotter = { git = "https://github.com/storytold/craft-libs", rev = "138ce9929ea48d055c797f61c042a3c407427d97" } +craft-dxf = { git = "https://github.com/storytold/craft-libs", rev = "138ce9929ea48d055c797f61c042a3c407427d97" } # DWG to DXF bytes, in a child process on desktop builds (acadrust 0.6.6, MPL-2.0, unmodified). -craft-dwg = { git = "https://github.com/storytold/craft-libs", rev = "f9e5cecc9cf1b701b22f6f24a88719b14456323e" } +craft-dwg = { git = "https://github.com/storytold/craft-libs", rev = "138ce9929ea48d055c797f61c042a3c407427d97" } # The DWG reader and writer craft-dwg uses, at the rev craft-libs pins (its Cargo.toml). Tests only: it writes the # R12, R13 and R14 DWG files that craft-dwg's writer, 2000 and later, does not. acadrust = { git = "https://github.com/storytold/acadrust.git", rev = "468b9d8e317755209020d5d3f2f1c8a76210c47f" } # WMF, EMF and EMF+ reader (craft-libs#778). -craft-metafile = { git = "https://github.com/storytold/craft-libs", rev = "f9e5cecc9cf1b701b22f6f24a88719b14456323e" } -craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "f9e5cecc9cf1b701b22f6f24a88719b14456323e" } -craft-image-codecs = { git = "https://github.com/storytold/craft-libs", rev = "f9e5cecc9cf1b701b22f6f24a88719b14456323e" } -craft-gif = { git = "https://github.com/storytold/craft-libs", rev = "f9e5cecc9cf1b701b22f6f24a88719b14456323e" } -craft-tiff = { git = "https://github.com/storytold/craft-libs", rev = "f9e5cecc9cf1b701b22f6f24a88719b14456323e" } -craft-ps = { git = "https://github.com/storytold/craft-libs", rev = "f9e5cecc9cf1b701b22f6f24a88719b14456323e", default-features = false, features = ["read", "write"] } -craft-psd = { git = "https://github.com/storytold/craft-libs", rev = "f9e5cecc9cf1b701b22f6f24a88719b14456323e" } -craft-stream-codecs = { git = "https://github.com/storytold/craft-libs", rev = "f9e5cecc9cf1b701b22f6f24a88719b14456323e" } -craft-jxl = { git = "https://github.com/storytold/craft-libs", rev = "f9e5cecc9cf1b701b22f6f24a88719b14456323e" } -craft-codepage = { git = "https://github.com/storytold/craft-libs", rev = "f9e5cecc9cf1b701b22f6f24a88719b14456323e" } +craft-metafile = { git = "https://github.com/storytold/craft-libs", rev = "138ce9929ea48d055c797f61c042a3c407427d97" } +craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "138ce9929ea48d055c797f61c042a3c407427d97" } +craft-image-codecs = { git = "https://github.com/storytold/craft-libs", rev = "138ce9929ea48d055c797f61c042a3c407427d97" } +craft-gif = { git = "https://github.com/storytold/craft-libs", rev = "138ce9929ea48d055c797f61c042a3c407427d97" } +craft-tiff = { git = "https://github.com/storytold/craft-libs", rev = "138ce9929ea48d055c797f61c042a3c407427d97" } +craft-ps = { git = "https://github.com/storytold/craft-libs", rev = "138ce9929ea48d055c797f61c042a3c407427d97", default-features = false, features = ["read", "write"] } +craft-psd = { git = "https://github.com/storytold/craft-libs", rev = "138ce9929ea48d055c797f61c042a3c407427d97" } +craft-stream-codecs = { git = "https://github.com/storytold/craft-libs", rev = "138ce9929ea48d055c797f61c042a3c407427d97" } +craft-jxl = { git = "https://github.com/storytold/craft-libs", rev = "138ce9929ea48d055c797f61c042a3c407427d97" } +craft-codepage = { git = "https://github.com/storytold/craft-libs", rev = "138ce9929ea48d055c797f61c042a3c407427d97" } # The metallic-roughness BRDF and environment light the 3D effects' Roughness and Metallic shade with. -craft-pbr = { git = "https://github.com/storytold/craft-libs", rev = "f9e5cecc9cf1b701b22f6f24a88719b14456323e" } +craft-pbr = { git = "https://github.com/storytold/craft-libs", rev = "138ce9929ea48d055c797f61c042a3c407427d97" } # The CPU rasterizer that draws a 3D effect's Render Settings › Rendered image: depth-buffered triangles, shadow maps. -craft-raster3d = { git = "https://github.com/storytold/craft-libs", rev = "f9e5cecc9cf1b701b22f6f24a88719b14456323e" } +craft-raster3d = { git = "https://github.com/storytold/craft-libs", rev = "138ce9929ea48d055c797f61c042a3c407427d97" } # The framework facade (`craft::ui`, `craft::settings`, `craft::platform`, ...). No default features: each crate names # the members it imports. -craft = { git = "https://github.com/storytold/craft-libs", rev = "f9e5cecc9cf1b701b22f6f24a88719b14456323e" } +craft = { git = "https://github.com/storytold/craft-libs", rev = "138ce9929ea48d055c797f61c042a3c407427d97" } # Below the egui layer, so not through the facade: the colour harmony rules and their settings (craft-color-ui # without its `ui` feature), the colour type they work in, and the craft-fonts tables the text crate's build writes. -craft-color-ui = { git = "https://github.com/storytold/craft-libs", rev = "f9e5cecc9cf1b701b22f6f24a88719b14456323e" } -craft-theme = { git = "https://github.com/storytold/craft-libs", rev = "f9e5cecc9cf1b701b22f6f24a88719b14456323e" } -craft-fonts-build = { git = "https://github.com/storytold/craft-libs", rev = "f9e5cecc9cf1b701b22f6f24a88719b14456323e" } +craft-color-ui = { git = "https://github.com/storytold/craft-libs", rev = "138ce9929ea48d055c797f61c042a3c407427d97" } +craft-theme = { git = "https://github.com/storytold/craft-libs", rev = "138ce9929ea48d055c797f61c042a3c407427d97" } +craft-fonts-build = { git = "https://github.com/storytold/craft-libs", rev = "138ce9929ea48d055c797f61c042a3c407427d97" } # Nightly profile isolation, launch protocol, and security fence. -craft-nightly = { git = "https://github.com/storytold/craft-libs", rev = "f9e5cecc9cf1b701b22f6f24a88719b14456323e" } +craft-nightly = { git = "https://github.com/storytold/craft-libs", rev = "138ce9929ea48d055c797f61c042a3c407427d97" } # internal vectorcraft-geom = { path = "crates/geom" } vectorcraft-color = { path = "crates/color" } @@ -203,15 +203,15 @@ lto = "thin" codegen-units = 1 [patch.crates-io] -hayro-syntax = { git = "https://github.com/storytold/craft-libs", rev = "f9e5cecc9cf1b701b22f6f24a88719b14456323e" } -hayro-interpret = { git = "https://github.com/storytold/craft-libs", rev = "f9e5cecc9cf1b701b22f6f24a88719b14456323e" } -hayro-jbig2 = { git = "https://github.com/storytold/craft-libs", rev = "f9e5cecc9cf1b701b22f6f24a88719b14456323e" } -hayro-cmap = { git = "https://github.com/storytold/craft-libs", rev = "f9e5cecc9cf1b701b22f6f24a88719b14456323e" } -hayro-postscript = { git = "https://github.com/storytold/craft-libs", rev = "f9e5cecc9cf1b701b22f6f24a88719b14456323e" } -krilla = { git = "https://github.com/storytold/craft-libs", rev = "f9e5cecc9cf1b701b22f6f24a88719b14456323e" } -linesweeper = { git = "https://github.com/storytold/craft-libs", rev = "f9e5cecc9cf1b701b22f6f24a88719b14456323e" } +hayro-syntax = { git = "https://github.com/storytold/craft-libs", rev = "138ce9929ea48d055c797f61c042a3c407427d97" } +hayro-interpret = { git = "https://github.com/storytold/craft-libs", rev = "138ce9929ea48d055c797f61c042a3c407427d97" } +hayro-jbig2 = { git = "https://github.com/storytold/craft-libs", rev = "138ce9929ea48d055c797f61c042a3c407427d97" } +hayro-cmap = { git = "https://github.com/storytold/craft-libs", rev = "138ce9929ea48d055c797f61c042a3c407427d97" } +hayro-postscript = { git = "https://github.com/storytold/craft-libs", rev = "138ce9929ea48d055c797f61c042a3c407427d97" } +krilla = { git = "https://github.com/storytold/craft-libs", rev = "138ce9929ea48d055c797f61c042a3c407427d97" } +linesweeper = { git = "https://github.com/storytold/craft-libs", rev = "138ce9929ea48d055c797f61c042a3c407427d97" } # skrifa 0.44 (epaint, glifo, usvg) with the automatic hinter's long blue-zone exit (craft-libs vendor/skrifa). -skrifa = { git = "https://github.com/storytold/craft-libs", rev = "f9e5cecc9cf1b701b22f6f24a88719b14456323e" } +skrifa = { git = "https://github.com/storytold/craft-libs", rev = "138ce9929ea48d055c797f61c042a3c407427d97" } ecolor = { git = "https://github.com/storytold/egui.git", rev = "399fc6e0ea65059e37de680f11ebbd177bf7d4ff" } emath = { git = "https://github.com/storytold/egui.git", rev = "399fc6e0ea65059e37de680f11ebbd177bf7d4ff" } epaint = { git = "https://github.com/storytold/egui.git", rev = "399fc6e0ea65059e37de680f11ebbd177bf7d4ff" } diff --git a/apps/vectorcraft-web/Cargo.toml b/apps/vectorcraft-web/Cargo.toml index bac975902d..8b7d0e896c 100644 --- a/apps/vectorcraft-web/Cargo.toml +++ b/apps/vectorcraft-web/Cargo.toml @@ -28,7 +28,7 @@ egui_extras = { workspace = true } # `wgpu` pulls egui-wgpu's defaults: WebGPU plus the WebGL2 fallback. eframe = { workspace = true, features = ["default_fonts", "wgpu", "accesskit"] } # The page command API (storytold/craft-libs#413): the request plumbing behind window.vectorcraft. -craft-web-api = { git = "https://github.com/storytold/craft-libs", rev = "f9e5cecc9cf1b701b22f6f24a88719b14456323e", version = "0.1.0" } +craft-web-api = { git = "https://github.com/storytold/craft-libs", rev = "138ce9929ea48d055c797f61c042a3c407427d97", version = "0.1.0" } wasm-bindgen = "0.2" serde_json = { workspace = true } diff --git a/crates/cad/src/scene.rs b/crates/cad/src/scene.rs index 45d2fcf234..93dc163627 100644 --- a/crates/cad/src/scene.rs +++ b/crates/cad/src/scene.rs @@ -597,6 +597,7 @@ impl<'a> Scene<'a> { linetypes: self.linetypes, styles: self.styles, images: self.images, + blocks: Vec::new(), entities: self.e.into_string(), extents: self.extents.unwrap_or(limits), limits, diff --git a/crates/engine/src/cmd/fileio/cdr.rs b/crates/engine/src/cmd/fileio/cdr.rs index 3633d06553..148942b386 100644 --- a/crates/engine/src/cmd/fileio/cdr.rs +++ b/crates/engine/src/cmd/fileio/cdr.rs @@ -425,8 +425,8 @@ fn copy_cost(objects: &[cd::Object]) -> usize { match o { cd::Object::Group { objects: kids, .. } => stack.extend(kids), cd::Object::Shape(s) => n = n.saturating_add(shape_cost(s)), - // A bitmap is not placed, so it takes nothing past the object itself. - cd::Object::Image(_) => {} + // A bitmap or text is not placed, so it takes nothing past the object itself. + cd::Object::Image(_) | cd::Object::Text(_) => {} cd::Object::Clip { container, objects } => { // A container whose outline is behind its fill is built twice, as that outline // and as the clipping path, inside a group of their own. diff --git a/crates/engine/src/cmd/fileio/cdr/shapes.rs b/crates/engine/src/cmd/fileio/cdr/shapes.rs index 127f97d87c..9d0f9cdc91 100644 --- a/crates/engine/src/cmd/fileio/cdr/shapes.rs +++ b/crates/engine/src/cmd/fileio/cdr/shapes.rs @@ -74,8 +74,8 @@ impl Builder { self.learn_spot(c); } } - // Bitmaps are not placed, so their colors add no swatch. - cd::Object::Image(_) => {} + // Bitmaps and text are not placed, so their colors add no swatch. + cd::Object::Image(_) | cd::Object::Text(_) => {} cd::Object::Group { objects: kids, .. } => stack.extend(kids), cd::Object::Clip { container, objects } => { for c in container.fill.iter().chain(container.outline.iter().map(|o| &o.color)) { @@ -125,8 +125,8 @@ impl Builder { for o in objects.iter().rev() { match o { cd::Object::Shape(s) => out.extend(self.shape(s, to_doc, false).map(|n| with_flags(n, s.flags))), - // Bitmaps are left out, and the warnings name them with the other objects not read. - cd::Object::Image(_) => self.note(Warning::UnsupportedObjects), + // Bitmaps and text are left out, and the warnings name them with the other objects not read. + cd::Object::Image(_) | cd::Object::Text(_) => self.note(Warning::UnsupportedObjects), cd::Object::Group { objects: kids, flags } => { let children = self.objects_at(kids, to_doc, depth + 1); if !children.is_empty() { @@ -456,6 +456,7 @@ mod tests { master: vec![], guides: vec![], warnings: vec![], + left_out: Default::default(), }; let doc = Builder::new().document(&d); let swatch = doc.swatches.iter().find(|s| s.name == "Red ink").unwrap(); @@ -498,6 +499,7 @@ mod tests { master: vec![], guides: vec![], warnings: vec![], + left_out: Default::default(), }; assert!(Document::new(612.0, 792.0).swatches.iter().any(|s| s.name == "Black" && !s.spot)); let doc = Builder::new().document(&d); @@ -539,6 +541,7 @@ mod tests { master: vec![master], guides: vec![], warnings: vec![], + left_out: Default::default(), }; let mut b = Builder::new(); b.copies_left = 1000; @@ -575,6 +578,7 @@ mod tests { master: vec![master], guides: vec![], warnings: vec![], + left_out: Default::default(), }; let mut b = Builder::new(); b.copies_left = 1000; @@ -648,6 +652,7 @@ mod tests { master: vec![], guides: vec![cd::Guideline { at: cd::Pt { x: 0.0, y: 0.0 }, angle: 90.0, hidden }], warnings: vec![], + left_out: Default::default(), }; let doc = Builder::new().document(&d); doc.layers @@ -675,6 +680,7 @@ mod tests { master: vec![], guides: vec![cd::Guideline { at: cd::Pt { x: 0.0, y: 0.0 }, angle: 45.0, hidden: false }], warnings: vec![], + left_out: Default::default(), }; let mut b = Builder::new(); let doc = b.document(&d); @@ -748,6 +754,7 @@ mod tests { master: vec![], guides: vec![], warnings: vec![], + left_out: Default::default(), }; let doc = Builder::new().document(&drawing(vec![vec![layer(cd::Flags::default(), objects)]])); let kids = doc.layers[0].children().unwrap(); diff --git a/crates/engine/src/cmd/fileio/cmx.rs b/crates/engine/src/cmd/fileio/cmx.rs index 29e8a22696..454ceaf168 100644 --- a/crates/engine/src/cmd/fileio/cmx.rs +++ b/crates/engine/src/cmd/fileio/cmx.rs @@ -103,7 +103,15 @@ pub(super) fn encode(doc: &Document, f: &super::Format, p: &Value, use_artboards .collect(); pages.push(cd::Page { size: Some((r.width().abs(), r.height().abs())), layers }); } - let drawing = cd::Drawing { version: 0, page_size: None, pages, master: Vec::new(), guides: Vec::new(), warnings: Vec::new() }; + let drawing = cd::Drawing { + version: 0, + page_size: None, + pages, + master: Vec::new(), + guides: Vec::new(), + warnings: Vec::new(), + left_out: Default::default(), + }; // The limits `document.open` reads `.cmx` files with, so the file opens whole again. let written = craft_cdr::write_cmx(&drawing, Limits::default()).map_err(|e| bad(C, e.to_string()))?; for (set, w) in [ From 7106c9753d86f5d232a3ffaabb0708810ff27de0 Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Sat, 5 Dec 2026 21:36:19 -0500 Subject: [PATCH 14/14] xtask pdf-deps: expect the PDF crates at 138ce992 too --- xtask/src/pdf_deps.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xtask/src/pdf_deps.rs b/xtask/src/pdf_deps.rs index 5044979608..839f55b257 100644 --- a/xtask/src/pdf_deps.rs +++ b/xtask/src/pdf_deps.rs @@ -5,7 +5,7 @@ use std::process::Command; use serde_json::Value; -const REV: &str = "f9e5cecc9cf1b701b22f6f24a88719b14456323e"; +const REV: &str = "138ce9929ea48d055c797f61c042a3c407427d97"; const PACKAGES: &[(&str, &str, &str)] = &[ ("craft-pdf", "0.1.0", REV), ("krilla", "0.8.2", REV),