diff --git a/crates/ui-egui/src/panels/layers.rs b/crates/ui-egui/src/panels/layers.rs index 1b0c664d2f..eed20e12cb 100644 --- a/crates/ui-egui/src/panels/layers.rs +++ b/crates/ui-egui/src/panels/layers.rs @@ -33,7 +33,7 @@ //! - Double-clicking a name renames it; double-clicking elsewhere on a row opens its options. //! - A target circle targets its layer, group or object (`layer.target`); dragging it onto another //! row's circle moves the appearance there (Alt copies it, `appearance.transfer`) and dropping it -//! on the trash clears it. +//! on the trash reduces it to basic appearance (`appearance.reduceToBasic`) without deleting it. //! - Search All and the Filter button at its right (`ui.layersFilter`, lit while a filter is on) //! narrow the rows, and every row that holds others shows open while they do. A row stays when //! its name holds the text typed, it is one of the object kinds ticked under By Object and it is diff --git a/crates/ui-egui/src/panels/layers/controls.rs b/crates/ui-egui/src/panels/layers/controls.rs index 381d0a65b1..4cea41db75 100644 --- a/crates/ui-egui/src/panels/layers/controls.rs +++ b/crates/ui-egui/src/panels/layers/controls.rs @@ -55,13 +55,14 @@ pub(super) fn bottom_bar(app: &mut VectorcraftApp, ui: &mut Ui, view: &View, doc let m = ui.input(|i| i.modifiers); let mut child = ui.new_child(egui::UiBuilder::new().max_rect(bar).layout(egui::Layout::right_to_left(egui::Align::Center))); let trash = widgets::icon_button(&mut child, "trash-2", tl!("Delete Selection"), false, 24.0); - // A target circle dropped on the trash clears that appearance (dragged rows: below). Peek at - // the payload's type before taking it: egui's take drops a payload of another type. + // A target circle dropped on the trash reduces that appearance to one fill and one stroke + // (dragged rows: below). Peek at the payload's type before taking it: egui's take drops a + // payload of another type. if trash.dnd_hover_payload::().is_some() && let Some(d) = trash.dnd_release_payload::() && let PanelDrag::Appearance(id) = *d { - actions.push(("appearance.clear".into(), json!({"ids": [id.0]}))); + actions.push(("appearance.reduceToBasic".into(), json!({"ids": [id.0]}))); } else if trash.clicked() { // With no row highlighted, the selected art and ruler guides go. if view.rows.is_empty() && app.session.active().is_some_and(|d| d.selection.has_objects_or_guides()) { diff --git a/crates/ui-egui/src/panels/layers/tests.rs b/crates/ui-egui/src/panels/layers/tests.rs index 123a9aacd1..a4cd26ac50 100644 --- a/crates/ui-egui/src/panels/layers/tests.rs +++ b/crates/ui-egui/src/panels/layers/tests.rs @@ -409,7 +409,7 @@ fn clicking_a_target_circle_targets_the_layer() { } #[test] -fn dragging_a_target_circle_moves_or_copies_the_appearance_and_the_trash_clears_it() { +fn dragging_a_target_circle_moves_or_copies_the_appearance() { let (mut app, layer, [a, b]) = two_rects(); app.session.execute("transparency.set", &json!({"ids": [a.0], "opacity": 30})).unwrap(); let ctx = egui::Context::default(); @@ -421,14 +421,49 @@ fn dragging_a_target_circle_moves_or_copies_the_appearance_and_the_trash_clears_ // A plain drag onto the layer's circle moves it there. drag(&mut app, &ctx, c[1], c[0], false); assert!((opacity(&app, layer) - 0.3).abs() < 1e-6 && opacity(&app, b) == 1.0); - // Dropped on the trash, the layer's appearance is cleared (and nothing is deleted). - let st = app.session.active().unwrap(); - let count = st.doc.node_count(); +} + +/// A target circle dropped on the trash reduces that item's own appearance to its topmost visible +/// fill and stroke in one undo step, and deletes nothing; dropped again, it changes nothing and +/// adds no undo step. A layer keeps only the rows it had, and its art is left as it is. +#[test] +fn dropping_a_target_circle_on_the_trash_reduces_it_to_basic_appearance() { + let (mut app, layer, [a, _]) = two_rects(); + let run = |app: &mut VectorcraftApp, id: &str, p: serde_json::Value| app.session.execute(id, &p).unwrap(); + // [Fill green, Stroke, Fill red, Stroke 5 pt], with an effect on the object. + run(&mut app, "appearance.addFill", json!({"ids": [a.0]})); + run(&mut app, "appearance.setItem", json!({"ids": [a.0], "index": 0, "color": "#00ff00"})); + run(&mut app, "appearance.setItem", json!({"ids": [a.0], "index": 2, "color": "#ff0000"})); + run(&mut app, "appearance.addStroke", json!({"ids": [a.0]})); + run(&mut app, "appearance.setItem", json!({"ids": [a.0], "index": 3, "weight": 5})); + run(&mut app, "effect.apply", json!({"ids": [a.0], "effect": "stylize.dropShadow", "item": null})); + let ctx = egui::Context::default(); + let (c, _) = frame(&mut app, &ctx, vec![], false); let trash = trash_pos(&mut app, &ctx); + let node = |app: &VectorcraftApp, id: NodeId| app.session.active().unwrap().doc.node(id).unwrap().clone(); + let undo = |app: &VectorcraftApp| app.session.active().unwrap().history.undo.len(); + let (original, count, before) = (node(&app, a), app.session.active().unwrap().doc.node_count(), undo(&app)); + // The bottom rectangle's circle (rows: the layer, the top rectangle, the bottom one). + drag(&mut app, &ctx, c[2], trash, false); + let n = node(&app, a); + assert!(n.appearance.is_basic(), "{:?}", n.appearance); + assert_eq!(n.appearance.items.len(), 2); + assert_eq!(n.appearance.fill().unwrap().paint.color().unwrap().to_hex(), "#ff0000"); + assert_eq!(n.appearance.stroke().unwrap().width, 5.0); + assert_eq!((app.session.active().unwrap().doc.node_count(), undo(&app)), (count, before + 1)); + // Dropped again, nothing changes and no undo step is made. + drag(&mut app, &ctx, c[2], trash, false); + assert_eq!((node(&app, a), undo(&app)), (n, before + 1)); + run(&mut app, "edit.undo", json!({})); + assert_eq!(node(&app, a), original, "one undo step restores the whole stack"); + // The layer's own fill stays and its effect goes; the art on it keeps its appearance. + run(&mut app, "appearance.addFill", json!({"ids": [layer.0]})); + run(&mut app, "effect.apply", json!({"ids": [layer.0], "effect": "stylize.dropShadow", "item": null})); drag(&mut app, &ctx, c[0], trash, false); - let st = app.session.active().unwrap(); - assert_eq!(st.doc.node(layer).unwrap().opacity, 1.0); - assert_eq!(st.doc.node_count(), count); + let l = node(&app, layer); + assert_eq!((l.appearance.items.len(), l.appearance.effects.len()), (1, 0), "{:?}", l.appearance); + assert!(l.appearance.fill().is_some()); + assert_eq!(node(&app, a), original); } /// The trash button: the bottom bar's rightmost button. diff --git a/docs/mcp.md b/docs/mcp.md index c7aa202d3f..53938339b9 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -5407,7 +5407,7 @@ layer (its opacity, its own fills and effects, an opacity mask on the whole laye selected. `document.inspect` reports it as `target`, and any other selection change ends it. `appearance.transfer {source, target, copy?}` is dragging a target circle onto another: the target gets the source's fills, strokes, effects and transparency, and the source is cleared unless `copy` (Alt-drag). Dropping a circle on the -panel's trash is `appearance.clear {ids: [id]}`. Masked objects' names have a dashed underline; while an opacity mask +panel's trash is `appearance.reduceToBasic {ids: [id]}` (Reduce to Basic Appearance; nothing is deleted). Masked objects' names have a dashed underline; while an opacity mask is edited the panel lists only an `` entry and the document tab says `(/Opacity Mask)`. ```json diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 0782bacab9..394d7ff700 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1733,6 +1733,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur - The [About brushes](https://helpx.adobe.com/illustrator/desktop/paint-and-fill/apply-and-edit-strokes/about-brushes.html) page describes up to five Pattern brush tiles: sides, inner corner, outer corner, beginning and end. The archived [Brushes](https://web.archive.org/web/20241230205225/https://helpx.adobe.com/illustrator/using/brushes.html) page says to add pattern tiles to the Swatches panel and select a swatch from the scroll list for each tile. Pattern Brush Options offers document pattern swatches in all five tile menus, including swatches named like built-in choices. The brush copies each swatch's whole art and tile frame. Side requires art; explicit None on a corner prevents fallback to the other corner's art. After a swatch is deleted, the brush keeps drawing its copied art and shows it as Original. The cited pages do not describe copying the whole art, requiring Side, suppressing corner fallback after explicit None, or showing deleted swatch art as Original. `brush.options` accepts swatch names and an object form for names that match built-in choices, and rejects unknown patterns before editing. Evidence: `tests::brushsym::pattern_tile_choices_copy_whole_swatch_art_and_reject_invalid_side` and `tests::brushsym::pattern_tile_object_selects_reserved_swatch_names` (vectorcraft-engine), `tests::pattern_corner_source_none_leaves_that_kind_of_corner_empty` (vectorcraft-brush), and `dialogs::brush_options::tests::pattern_tile_menus_use_document_patterns_and_side_none_keeps_dialog_open`, `dialogs::brush_options::tests::pattern_options_borrowed_swatch_corner_keeps_its_frame`, and `dialogs::brush_options::tests::pattern_options_selects_swatches_with_reserved_names` (vectorcraft-ui-egui). - **Appearance:** the Appearance panel's selected row drives every paint, stroke, gradient and transparency edit (`item` on the commands); effects apply to one fill or stroke; per-item Opacity popups, whose blend-mode list and opacity slider stay open inside them (#430; the Control bar's Stroke popover too); Mixed Appearances, Layers target dots and basic-appearance rules. Effects can be reordered, moved between items and copied by dragging; Show All Hidden Attributes; clicking an effect edits it in place; the object thumbnail drags onto art; effects render on type, images, symbols, blends, envelopes, meshes and repeats, and per-item raster effects export. Groups, layers and type have their own fills, strokes and effects (Contents and Characters rows); the Layers panel's target circles target layers, groups and objects; Expand Appearance turns fills, strokes, effects and brushes into objects. Fill and stroke paint (Fill, Stroke, None, Apply Last Color and Apply Last Gradient, also on characters selected with the Type tool), the Stroke panel's options, gradient and freeform point edits, Swap Fill and Stroke, Default Fill and Stroke, the Eyedropper, and the Appearance panel's item edits, Clear Appearance, Reduce to Basic Appearance, Remove Item, item reordering and Move Appearance record no undo step when they change nothing. + A Layers panel target circle dropped on the panel's Delete Selection button reduces that layer, group or object to basic appearance (`appearance.reduceToBasic`) in one undo step and deletes nothing, as the [Appearance attributes](https://helpx.adobe.com/illustrator/using/appearance-attributes.html) help page describes for that drag. Which fill and stroke stay (the topmost visible ones), that a layer or group keeps only the rows it had, and that the object's opacity and blend mode stay are VectorCraft's own rules (`panels::layers` test `dropping_a_target_circle_on_the_trash_reduces_it_to_basic_appearance`). The Add New Effect popup (Appearance panel, Properties), the Appearance panel's swatch picker, the Gradient panel's gradient swatches menu and the Image Trace button's list of presets stop at the bottom of a short window, and the mouse wheel or the scroll bar reaches their last rows. A list that fits does not scroll (`a_long_swatch_picker_scrolls_inside_a_short_window`). An image's own fills and strokes draw the shape that a Convert to Shape or Outline Object effect on them gives them (the image's box, or the outline of the image's opaque area or its frame, reshaped by the effects after it), under or over the image as its Contents row says, on the canvas, in exports and through Expand Appearance; new fills and strokes on an image go under it. Without one of those effects they draw nothing, and Use Preview Bounds then measures an image by its frame. Outline Object on an image's own fill or stroke follows the outline of the image's opaque area, and the image's frame when the image has no transparency. Path effects apply to a fill or stroke added to a bitmap object ([archived reference manual, page 561](https://web.archive.org/web/20210601162814/https://helpx.adobe.com/pdf/illustrator_reference.pdf#page=561)), and with Outline Object such a stroke follows the boundary of the art when the image has transparent areas and the image's frame when it has none ([CreativePro article on strokes for placed images](https://web.archive.org/web/20250815214529/https://creativepro.com/add-strokes-placed-images-illustrator/)). VectorCraft's own rules: the opaque area is the pixels at least 50% opaque, and its outline is traced as Image Trace's Black and White mode traces at threshold 128 and fitted with curves. Evidence: `tests::imageoutline` (vectorcraft-effects), `opaque::tests` (vectorcraft-trace), `tests::containers::an_images_stroke_with_outline_object_follows_its_opaque_area` and `tests::containers::an_images_outline_object_stroke_exports_selects_and_measures_along_its_opaque_area` (vectorcraft-engine), `tests::objectfx::an_images_outline_object_stroke_follows_new_pixels_under_the_same_key` (vectorcraft-render).