Graphic Styles: a style dropped on another with Alt replaces that style

A graphic style dragged onto another style in the Graphic Styles panel
with Alt held gives that style the dragged style's look. The replaced
style keeps its name, place and id, and the art still linked to it
takes the new look in one undo step; the dragged style and its art stay
as they are. Without Alt the style moves, as before.

graphicStyle.redefine takes {name, from} for this. A style dropped on
itself, or on a style with the same look, records nothing. A `from` that
names no style or is not a string, or `from` with `id`, is an error.
This commit is contained in:
dotCooCoo
2026-11-17 11:31:04 -08:00
parent ffae374bac
commit a1e3d6b5bb
6 changed files with 217 additions and 27 deletions
+43 -20
View File
@@ -76,7 +76,7 @@ pub fn specs() -> Vec<CommandSpec> {
"Redefine Graphic Style",
["Window", "Appearance"],
None,
"{name?, id?} replace the style (default: the one the object was last linked to) with the look of object `id` or the first selected object (a graph series group with no fill, stroke, effect, opacity, blend mode, isolation, knockout or style link of its own: the topmost path directly in it; a graph's Axes or Legend group: its topmost line or label); the objects still linked to it update, and that object becomes linked. The art of a graph design in a series keeps its look and is unlinked, as the source or as a linked object. A linked graph series group passes the style to the paths directly in it, a linked Axes group to its lines and labels and a linked Legend group to its labels, other than the source and paths linked to the style whose look was edited, and is left cleared (as appearance.clear) and unlinked. On a linked path directly in a graph series, the graph also stores the paint, weight, opacity and blend mode of the topmost visible fill and stroke and the object's opacity and blend mode (exceptions: docs/mcp.md); on a graph label, or a graph's axis line, tick mark or radar ring (a graph's Axes group stands for the lines and labels directly in it, its Legend group for the labels), the graph stores that object's topmost visible fill and stroke rows and object opacity and blend mode for every label or line of its kind → {name}",
"{name?, id?} | {name, from} replace the style (default: the one the object was last linked to) with the look of object `id` or the first selected object (a graph series group with no fill, stroke, effect, opacity, blend mode, isolation, knockout or style link of its own: the topmost path directly in it; a graph's Axes or Legend group: its topmost line or label); the objects still linked to it update, and that object becomes linked. With `from`, the style takes the look of the style named `from` (its fills, strokes, effects, opacity, blend mode, isolate and knockout) and keeps its own name and place; `from` and the objects linked to it stay as they are, `from` naming the style itself or a style with the same look changes nothing, and `from` with `id` is an error. The art of a graph design in a series keeps its look and is unlinked, as the source or as a linked object. A linked graph series group passes the style to the paths directly in it, a linked Axes group to its lines and labels and a linked Legend group to its labels, other than the source and paths linked to the style whose look was edited, and is left cleared (as appearance.clear) and unlinked. On a linked path directly in a graph series, the graph also stores the paint, weight, opacity and blend mode of the topmost visible fill and stroke and the object's opacity and blend mode (exceptions: docs/mcp.md); on a graph label, or a graph's axis line, tick mark or radar ring (a graph's Axes group stands for the lines and labels directly in it, its Legend group for the labels), the graph stores that object's topmost visible fill and stroke rows and object opacity and blend mode for every label or line of its kind → {name}",
has_doc,
style_redefine
),
@@ -489,22 +489,43 @@ pub(crate) fn style_json(g: &GraphicStyle) -> Value {
fn style_redefine(s: &mut Session, p: &Value) -> Result<Value> {
let cmd = "graphicStyle.redefine";
let (src, n) = source(s, p, cmd)?;
let d = &s.doc()?.doc;
// A series group that holds nothing of its own is redefined from the topmost of its paths, which a style links.
let n = super::appearance::look_holder(d, n);
let src = if n.id == src { src } else { n.id };
let i = match str_param(p, "name") {
Some(name) => style_index(d, name)?,
None => n
.extras()
.graphic_style
.and_then(|id| d.graphic_style_by_id(id))
.and_then(|g| d.graphic_style_index(&g.name))
.ok_or_else(|| bad(cmd, "the object has no graphic style (pass `name`)"))?,
// The style to replace, its new look, and the object that look comes from (none for another style's look).
let (i, look, src) = match p.get("from") {
Some(from) => {
let from = from.as_str().ok_or_else(|| bad(cmd, "`from` must be a graphic style name"))?;
if p.get("id").is_some() {
return Err(bad(cmd, "pass `id` or `from`, not both"));
}
let name = str_param(p, "name").ok_or_else(|| bad(cmd, "missing name (the style `from` replaces)"))?;
let d = &s.doc()?.doc;
let (i, j) = (style_index(d, name)?, style_index(d, from)?);
// A style dropped on itself, or on a style with the same look, stays as it is.
let target = &d.graphic_styles[i];
let look = GraphicStyle { name: target.name.clone(), id: target.id, ..d.graphic_styles[j].clone() };
if i == j || look == *target {
return Ok(json!({ "name": name }));
}
(i, look, None)
}
None => {
let (src, n) = source(s, p, cmd)?;
let d = &s.doc()?.doc;
// A series group that holds nothing of its own is redefined from the topmost of its paths, which a style links.
let n = super::appearance::look_holder(d, n);
let src = if n.id == src { src } else { n.id };
let i = match str_param(p, "name") {
Some(name) => style_index(d, name)?,
None => n
.extras()
.graphic_style
.and_then(|id| d.graphic_style_by_id(id))
.and_then(|g| d.graphic_style_index(&g.name))
.ok_or_else(|| bad(cmd, "the object has no graphic style (pass `name`)"))?,
};
(i, GraphicStyle::of(String::new(), captured(n), n), Some(src))
}
};
let look = GraphicStyle::of(String::new(), captured(n), n);
let name = d.graphic_styles[i].name.clone();
let name = s.doc()?.doc.graphic_styles[i].name.clone();
let chars = s.prefs.override_char_color;
let before = s.doc()?.doc.clone();
s.edit_named("Redefine Graphic Style “{name}”", &name, false, |d, _| {
@@ -513,7 +534,7 @@ fn style_redefine(s: &mut Session, p: &Value) -> Result<Value> {
// Objects still linked follow the new definition; edited ones are unlinked (they keep their look), and the
// source keeps its own. The art of a graph design in a series is unlinked and keeps its look too, as the
// source or as a linked object: the graph draws it again from the design.
let linked = objects_where(d, |n| n.extras().graphic_style == Some(id) && n.id != src);
let linked = objects_where(d, |n| n.extras().graphic_style == Some(id) && Some(n.id) != src);
let (follow, edited): (Vec<NodeId>, Vec<NodeId>) =
linked.into_iter().partition(|nid| !super::graph::is_design_art(d, *nid) && d.node(*nid).is_some_and(|n| in_sync(n, &old)));
set_link(d, &edited, None);
@@ -521,7 +542,7 @@ fn style_redefine(s: &mut Session, p: &Value) -> Result<Value> {
// goes back to the empty appearance the graph draws it with. The source and the edited paths keep their look.
let mut follow_marks = super::graph::series_group_marks(d, &follow);
let edited: HashSet<NodeId> = edited.into_iter().collect();
follow_marks.retain(|nid| *nid != src && !edited.contains(nid));
follow_marks.retain(|nid| Some(*nid) != src && !edited.contains(nid));
super::appearance::clear_stood_for(d, &super::appearance::stood_for(&follow, &follow_marks));
let g = d.graphic_styles[i].clone();
let mut shared = None;
@@ -530,8 +551,10 @@ fn style_redefine(s: &mut Session, p: &Value) -> Result<Value> {
}
super::appearance::capture_series_writes(&before, d, &follow_marks, (true, true), (true, true), false, true);
super::graph::capture_label_rows(d, &follow_marks);
let link = (!super::graph::is_design_art(d, src)).then_some(id);
set_link(d, &[src], link);
if let Some(src) = src {
let link = (!super::graph::is_design_art(d, src)).then_some(id);
set_link(d, &[src], link);
}
Ok(())
})?;
Ok(json!({ "name": name }))
+62
View File
@@ -299,6 +299,68 @@ fn redefine_shares_one_appearance() {
assert!(!Shared::ptr_eq(&node(&s, d).appearance, &nb.appearance));
}
/// Redefine with `from` gives a style another style's look: the style keeps its name, place and id,
/// its objects still linked follow, edited ones are unlinked, and `from` and its objects stay as
/// they are, in one undo step. A style replaced by itself or by a style with the same look records
/// nothing, and bad parameters are errors that change nothing.
#[test]
fn redefine_from_a_style_gives_the_style_that_look() {
let mut s = session();
let (a, b, c) = linked_three(&mut s);
let d = rect(&mut s, 300.0);
set_fill(&mut s, d, "#0000ff");
run(&mut s, "transparency.set", json!({"item": null, "opacity": 50, "blend": "multiply"}));
run(&mut s, "graphicStyle.new", json!({"name": "Blue"}));
set_fill(&mut s, c, "#00ff00");
let names = |s: &Session| s.doc().unwrap().doc.graphic_styles.iter().map(|g| g.name.clone()).collect::<Vec<_>>();
let steps = |s: &Session| s.doc().unwrap().history.undo.len();
let (old, blue, order, before) = (style(&s, "S"), style(&s, "Blue"), names(&s), steps(&s));
assert_eq!(run(&mut s, "graphicStyle.redefine", json!({"name": "S", "from": "Blue"}))["name"], "S");
assert_eq!(style(&s, "S"), GraphicStyle { name: "S".into(), id: old.id, ..blue.clone() });
assert_eq!(names(&s), order);
let blue_paint = Paint::solid(Color::from_hex("#0000ff").unwrap());
for id in [a, b] {
let n = node(&s, id);
assert_eq!((n.appearance.fill_paint(), n.opacity, n.blend), (blue_paint.clone(), 0.5, BlendMode::Multiply));
}
assert_eq!(linked(&mut s, "S"), vec![a.0, b.0]);
// The edited object keeps its look and is unlinked; Blue and its object are as they were.
assert_eq!(fill(&s, c), Paint::solid(Color::from_hex("#00ff00").unwrap()));
assert_eq!(node(&s, c).extras().graphic_style, None);
assert_eq!(style(&s, "Blue"), blue);
assert_eq!(linked(&mut s, "Blue"), vec![d.0]);
let step = s.doc().unwrap().history.undo.last().unwrap().clone();
assert_eq!((step.label.as_str(), steps(&s)), ("Redefine Graphic Style “S”", before + 1));
run(&mut s, "edit.undo", json!({}));
assert_eq!(style(&s, "S"), old);
assert_eq!((fill(&s, a), fill(&s, b)), (Paint::solid(Color::WHITE), Paint::solid(Color::WHITE)));
assert_eq!(node(&s, c).extras().graphic_style, Some(old.id));
run(&mut s, "edit.redo", json!({}));
assert_eq!(style(&s, "S").appearance, blue.appearance);
assert_eq!(linked(&mut s, "S"), vec![a.0, b.0]);
run(&mut s, "edit.undo", json!({}));
// A style replaced by itself, or by a copy with the same look, records nothing.
run(&mut s, "graphicStyle.duplicate", json!({"name": "Blue"}));
let before = steps(&s);
run(&mut s, "graphicStyle.redefine", json!({"name": "S", "from": "S"}));
run(&mut s, "graphicStyle.redefine", json!({"name": "Blue copy", "from": "Blue"}));
assert_eq!(steps(&s), before);
assert_eq!(style(&s, "S"), old);
// A style that does not exist, a `from` that is not a name, `from` with `id` and a missing `name` are errors.
for p in [
json!({"name": "S", "from": "nope"}),
json!({"name": "nope", "from": "Blue"}),
json!({"name": "S", "from": 3}),
json!({"name": "S", "from": "Blue", "id": a.0}),
json!({"from": "Blue"}),
] {
assert!(s.execute("graphicStyle.redefine", &p).is_err(), "{p}");
}
assert_eq!((steps(&s), style(&s, "S")), (before, old));
}
#[test]
fn deleting_a_style_unlinks_and_renaming_keeps_links() {
let mut s = session();
+101 -4
View File
@@ -3,7 +3,8 @@
//! shows the shape outlined in black and filled with white, under a red slash. Clicking a style applies it to the
//! selection (Alt-click adds it on top); Shift-click adds to the panel's selection every style from
//! the last one clicked without Shift through this one; Cmd/Ctrl-click adds or removes one;
//! double-click opens Graphic Style Options. Dragging a style moves it in the list, applies it
//! double-click opens Graphic Style Options. Dragging a style moves it in the list (dropped on
//! another style with Alt held, replaces that style with its look), applies it
//! to the art it is dropped on (`canvas::panel_drop`), or, dropped on New Graphic Style, adds a
//! copy of it and of the styles highlighted with it at the end of the list; art dragged off the
//! canvas or the Appearance panel's thumbnail dropped on the panel becomes a new style, and
@@ -368,6 +369,8 @@ struct Events {
new_from: Option<NodeId>,
/// Art or an appearance dropped on a style with Alt held: the style takes this object's look.
replaced: Option<(String, NodeId)>,
/// A style dropped on another with Alt held: the second (`.0`) takes the first's (`.1`) look.
restyled: Option<(String, String)>,
/// The style the right button is held on.
large: Option<usize>,
/// A style is dragged over a tile or row.
@@ -387,7 +390,8 @@ fn clicked(ui: &Ui, resp: &Response, name: &str) -> Option<Click> {
/// Clicks, drags and the right button on the tile or row `resp` of style `i` of `d` (`list`: rows
/// stack downwards). A drag from it carries the style ([`PanelDrag::GraphicStyle`]); a style
/// dragged over it lands before or after it by the pointer's half. Art (its first object) or the
/// dragged over it lands before or after it by the pointer's half, or with Alt held outlines it
/// and, released there, replaces it with the dragged style's look. Art (its first object) or the
/// Appearance panel's thumbnail held over it with Alt outlines it, and released there replaces the
/// style with that object's look; without Alt it is left to the list ([`zone_input`]).
fn cell_input(ui: &Ui, resp: &Response, d: &Document, i: usize, list: bool, ev: &mut Events) {
@@ -414,6 +418,11 @@ fn cell_input(ui: &Ui, resp: &Response, d: &Document, i: usize, list: bool, ev:
if moving == name {
// Dropped on itself: it stays where it is.
resp.dnd_release_payload::<PanelDrag>();
} else if alt_held(ui) {
widgets::drop_target_outline(ui, resp.rect);
if resp.dnd_release_payload::<PanelDrag>().is_some() {
ev.restyled = Some((name.clone(), moving.clone()));
}
} else {
let r = resp.rect;
let at = ui.input(|i| i.pointer.interact_pos()).unwrap_or(r.center());
@@ -531,6 +540,9 @@ fn act(app: &mut VectorcraftApp, ui: &Ui, s: &Shown, ev: Events, picker: bool) {
{
run(app, "graphicStyle.redefine", json!({ "name": name, "id": id.0 }));
}
if let Some((name, from)) = ev.restyled {
run(app, "graphicStyle.redefine", json!({ "name": name, "from": from }));
}
match ev.click {
Some(Click::Pick(name, _)) if picker => {
app.run("graphicStyle.apply", json!({"name": name, "add": alt_held(ui)})).ok();
@@ -1535,10 +1547,10 @@ mod tests {
assert_eq!(doc(&app).graphic_style("Red").unwrap().appearance, red.appearance, "{view:?}");
app.run("edit.undo", json!({})).unwrap();
// A style dragged onto Red with Alt moves and replaces nothing.
// A style dragged onto Red without Alt moves and replaces nothing.
let last = n.last().unwrap().clone();
egui::DragAndDrop::set_payload(&ctx, PanelDrag::GraphicStyle(last.clone()));
frame_at(&mut app, at, release(at, alt), alt);
frame_at(&mut app, at, release(at, none), none);
assert_eq!(names(&app)[0], last, "{view:?}");
assert_eq!(doc(&app).graphic_style("Red").unwrap().appearance, red.appearance, "{view:?}");
app.run("edit.undo", json!({})).unwrap();
@@ -1557,6 +1569,91 @@ mod tests {
}
}
/// A style dropped on another with Alt held replaces that style's look with its own: the
/// replaced style keeps its name, place and id, and its art follows, in one undo step; the
/// dragged style and its art stay as they are. Without Alt the style moves; dropped on itself
/// it does nothing.
#[test]
fn a_style_dropped_on_another_with_alt_replaces_that_style() {
let mut app = app();
let rect = app.session.active().unwrap().doc.layers[0].children().unwrap()[0].id;
app.run("paint.setFill", json!({"color": "#ff0000", "ids": [rect.0]})).unwrap();
app.run("graphicStyle.new", json!({"name": "Red", "id": rect.0})).unwrap();
app.run("graphicStyle.move", json!({"name": "Red", "to": 0})).unwrap();
app.run("shape.ellipse", json!({"x": 60, "y": 60, "width": 20, "height": 20})).unwrap();
let oval = app.session.active().unwrap().selection.objects[0];
app.run("paint.setFill", json!({"color": "#00ff00", "ids": [oval.0]})).unwrap();
app.run("graphicStyle.new", json!({"name": "Green", "id": oval.0})).unwrap();
let ctx = egui::Context::default();
let screen = Some(Rect::from_min_size(pos2(0.0, 0.0), vec2(260.0, 600.0)));
// One frame of the panel with `events` and `modifiers` held: whether a drop-target outline
// the size of one style's tile or row is drawn around `at`.
let frame_at = |app: &mut VectorcraftApp, at: egui::Pos2, events: Vec<egui::Event>, modifiers: egui::Modifiers| {
let events = std::iter::once(egui::Event::ModifiersChanged(modifiers)).chain(events).collect();
let mut out = ctx.run_ui(egui::RawInput { screen_rect: screen, events, ..Default::default() }, |ui| show(app, ui));
out.textures_delta.clear();
let accent = Tokens::get(&ctx).accent;
out.shapes.iter().any(|c| match &c.shape {
egui::Shape::Rect(r) => r.stroke.width == 1.5 && r.stroke.color == accent && r.rect.contains(at) && r.rect.height() < 45.0,
_ => false,
})
};
let release = |at: egui::Pos2, modifiers: egui::Modifiers| {
let up = egui::Event::PointerButton { pos: at, button: egui::PointerButton::Primary, pressed: false, modifiers };
vec![egui::Event::PointerMoved(at), up]
};
let (none, alt) = (egui::Modifiers::default(), egui::Modifiers::ALT);
let doc = |app: &VectorcraftApp| app.session.active().unwrap().doc.clone();
let steps = |app: &VectorcraftApp| app.session.doc().unwrap().history.undo.len();
let (red, green) = (doc(&app).graphic_style("Red").unwrap().clone(), doc(&app).graphic_style("Green").unwrap().clone());
let (red_fill, green_fill) = (red.appearance.fill_paint(), green.appearance.fill_paint());
assert_ne!(red_fill, green_fill);
// The first style: the top of the list's first row, or its first tile.
for (view, at) in [(View::SmallList, pos2(60.0, 9.0)), (View::Thumbnail, pos2(20.0, 20.0))] {
app.ui.graphic_styles_view = view;
frame_at(&mut app, at, vec![], none);
let n = names(&app);
assert_eq!(n[0], "Red", "{view:?}");
let before = steps(&app);
// Held over Red with Alt it is outlined; without Alt it is not (the insertion marker shows instead).
egui::DragAndDrop::set_payload(&ctx, PanelDrag::GraphicStyle("Green".into()));
assert!(!frame_at(&mut app, at, vec![egui::Event::PointerMoved(at)], none), "{view:?}: no outline without Alt");
assert!(frame_at(&mut app, at, vec![egui::Event::PointerMoved(at)], alt), "{view:?}: outlined with Alt");
assert_eq!((names(&app), steps(&app)), (n.clone(), before), "{view:?}: holding it there changes nothing");
// Released there with Alt: Red takes Green's look and keeps its name, place and id.
frame_at(&mut app, at, release(at, alt), alt);
let d = doc(&app);
assert_eq!(names(&app), n, "{view:?}: no style moves");
let g = d.graphic_style("Red").unwrap();
assert_eq!((g.id, &g.appearance), (red.id, &green.appearance), "{view:?}");
assert_eq!(d.node(rect).unwrap().appearance.fill_paint(), green_fill, "{view:?}: the linked rectangle follows");
assert_eq!(d.node(rect).unwrap().extras().graphic_style, Some(red.id), "{view:?}");
assert_eq!(d.graphic_style("Green").unwrap(), &green, "{view:?}: Green stays as it was");
assert_eq!(d.node(oval).unwrap().extras().graphic_style, Some(green.id), "{view:?}: the oval stays linked to Green");
assert_eq!(steps(&app), before + 1, "{view:?}: one undo step");
app.run("edit.undo", json!({})).unwrap();
let d = doc(&app);
assert_eq!(d.graphic_style("Red").unwrap(), &red, "{view:?}: undo restores the style");
assert_eq!(d.node(rect).unwrap().appearance.fill_paint(), red_fill, "{view:?}");
assert_eq!(d.node(rect).unwrap().extras().graphic_style, Some(red.id), "{view:?}");
// Red dropped on itself with Alt changes nothing and records nothing.
egui::DragAndDrop::set_payload(&ctx, PanelDrag::GraphicStyle("Red".into()));
frame_at(&mut app, at, release(at, alt), alt);
assert_eq!((names(&app), steps(&app)), (n.clone(), before), "{view:?}");
assert_eq!(doc(&app).graphic_style("Red").unwrap(), &red, "{view:?}");
// Without Alt, Green moves before Red and Red keeps its look.
egui::DragAndDrop::set_payload(&ctx, PanelDrag::GraphicStyle("Green".into()));
frame_at(&mut app, at, release(at, none), none);
assert_eq!(names(&app)[0], "Green", "{view:?}");
assert_eq!(doc(&app).graphic_style("Red").unwrap(), &red, "{view:?}");
app.run("edit.undo", json!({})).unwrap();
assert_eq!(names(&app), n, "{view:?}");
}
}
#[test]
fn shift_click_selects_a_range_and_cmd_click_adds_or_removes_one_style() {
let mut app = app();
+2 -1
View File
@@ -17,7 +17,8 @@ pub enum PanelDrag {
/// replaces the style it is dropped on with it (`graphicStyle.redefine`).
Appearance(vectorcraft_doc::NodeId),
/// A Graphic Styles panel style: art it is dropped on takes it (`graphicStyle.apply` with its
/// `ids`); the panel moves it to where it is dropped.
/// `ids`); the panel moves it to where it is dropped, or with Alt held replaces the style it is
/// dropped on with its look (`graphicStyle.redefine` with `from`).
GraphicStyle(String),
/// The selected art, dragged off the canvas with the Selection tool: the Graphic Styles panel
/// makes a style of the first object (`graphicStyle.new`), or with Alt held replaces the style
+8 -2
View File
@@ -4313,8 +4313,14 @@ object's, type its characters'). `graphicStyle.apply {name, ids?}` gives the obj
style's look: editing their appearance or transparency breaks the link, and `graphicStyle.redefine {name?, id?}`
updates only the objects still linked. Art dragged off the canvas, or the Appearance panel's thumbnail, dropped on a
style in the Graphic Styles panel with Alt held runs `graphicStyle.redefine` with that style's `name` and the object's
`id` (the first object of the art); an object already linked to the style with its look changes nothing. The art of a
column or marker design in a graph series is never linked:
`id` (the first object of the art); an object already linked to the style with its look changes nothing.
`graphicStyle.redefine {name, from}` gives the style `name` the look of the style `from` instead (fills, strokes,
effects, opacity, blend mode, isolate and knockout): `name` keeps its name, place and id, its objects still linked
follow in one undo step, and `from` and its objects stay as they are. `from` naming the same style, or a style with
the same look, records nothing; a `from` that names no style or is not a string, or `from` with `id`, is an error. A
style dragged onto another in the Graphic Styles panel with Alt held runs it with the dragged style as `from`;
without Alt the style moves (`graphicStyle.move`). The art of a column or marker design in a graph series is never
linked:
`graphicStyle.new` can make a style from it, and `graphicStyle.redefine` leaves its look as it was and unlinks it,
whether it is the source or a linked object. `graphicStyle.list` returns each style with the ids linked to it and the
style of the first selected object; `select.same.graphicStyle` selects an object's fellow users.
+1
View File
@@ -1845,6 +1845,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur
A graphic style dragged onto the Graphic Styles panel's New Graphic Style button is duplicated, as the panel menu's Duplicate Graphic Style does, and both put the copy at the end of the list, as the help page describes ([the help page](https://help.adobe.com/archive/en_US/illustrator/cs5/illustrator_cs5_help.pdf#page=391)). VectorCraft's own rules: the button takes the drop with no art selected; a dragged style that is highlighted brings the other highlighted styles, copied in panel order in one undo step, and the copies are highlighted; the copy is named `<name> copy`, with a number when that is taken, and no art is linked to it (`a_style_dropped_on_new_graphic_style_is_duplicated_at_the_end` in `crates/ui-egui/src/panels/graphic_styles.rs`, `tests::styles::duplicate_puts_the_copy_at_the_end_of_the_list_in_one_undo_step`).
A graphic style dragged onto the Graphic Styles panel's Delete Graphic Style button is deleted, which the help page gives as another way to delete a style besides the panel menu's Delete Graphic Style; art that used the style keeps its look and is no longer linked to it ([the help page](https://help.adobe.com/archive/en_US/illustrator/cs5/illustrator_cs5_help.pdf#page=392)). VectorCraft's own rules: the drop asks first as the button does, and with Alt held it deletes without asking; the button takes the drop with no style highlighted; a dragged style that is highlighted brings the other highlighted styles, deleted in one undo step (`a_style_dropped_on_delete_graphic_style_is_deleted_as_the_button_deletes` in `crates/ui-egui/src/panels/graphic_styles.rs`).
The Appearance panel's thumbnail dropped on a graphic style with Alt held replaces that style with the look of the object the panel shows; the style keeps its name and the art that uses it takes the new look, as the help page describes ([the help page](https://web.archive.org/web/20210601162814/https://helpx.adobe.com/pdf/illustrator_reference.pdf#page=568)). VectorCraft's own rules: art dragged off the canvas does the same with its first object; the style keeps its place in the list, is outlined while one is held over it with Alt, and the replacement is one undo step; an object already linked to the style with its look changes nothing; without Alt the drop makes a new style (`art_or_an_appearance_dropped_on_a_style_with_alt_replaces_that_style` in `crates/ui-egui/src/panels/graphic_styles.rs`).
A graphic style dragged onto another style in the Graphic Styles panel with Alt held gives that style the dragged style's look; the replaced style keeps its name and the art that uses it takes the new look, as the help page describes ([the help page](https://web.archive.org/web/20210601162814/https://helpx.adobe.com/pdf/illustrator_reference.pdf#page=568)). VectorCraft's own rules: the dragged style and the art linked to it stay as they are; the replaced style keeps its place in the list and is outlined while a style is held over it with Alt; the replacement is one undo step; a style dropped on itself, or on a style with the same look, changes nothing and records no undo step; without Alt the style moves (`graphicStyle.redefine {name, from}`, `a_style_dropped_on_another_with_alt_replaces_that_style` in `crates/ui-egui/src/panels/graphic_styles.rs`, `tests::styles::redefine_from_a_style_gives_the_style_that_look`).
In the Graphic Styles panel's thumbnail and list views, a style with no fill and no stroke, one with only effects or transparency included, shows its preview shape with a black outline, a white fill and a red slash, as the help page describes for the panel's thumbnails ([Graphic styles](https://helpx.adobe.com/illustrator/using/graphic-styles.html)); its effects still draw on that shape. The Control bar's Style picker and chip, graphic style library panels and the large preview on the selected object show the same marker. A fill or stroke row that paints None does not count as a fill or stroke, and a hidden row or one with zero opacity does; these rules, the marker outside the panel's thumbnails and the slash's direction and size are VectorCraft's own (`a_style_with_no_fill_and_no_stroke_shows_an_outlined_shape_and_a_red_slash` in `crates/ui-egui/src/panels/graphic_styles.rs`).
Applying a style to several objects, and Redefine Graphic Style, give the objects one shared copy of the style's appearance instead of a copy each; an object that is edited later gets its own copy, and an object whose placed gradients are fitted to its own bounds gets its own. The undo history's memory estimate counts a shared appearance once. Saved files are unchanged (`crates/engine/src/tests/styles.rs`).
- **Several text styles at once:** in the Character Styles and Paragraph Styles panels, Shift-click highlights a range of styles and Ctrl/Cmd-click adds or removes one, without applying them; the panel menu's Select All Unused (`charStyle.unused`, `paraStyle.unused`) highlights the styles no type uses (in the layers, opacity masks, symbols, graph designs, pattern tiles and the art of brushes), never the Normal style; Delete, the button or the menu item, deletes every highlighted style but Normal in one undo step (`charStyle.delete {names}`, `paraStyle.delete {names}`). The menu's Duplicate copies every highlighted style in one undo step and highlights the copies. A highlighted row dragged onto Create New Style or Delete carries every highlighted style: dropped on Create New Style it copies them all and highlights the copies, and dropped on Delete it deletes them all but Normal and clears the highlight; a row from outside the highlight carries only its own style. Public reference: [Character and paragraph styles](https://web.archive.org/web/20261015081534/https://helpx.adobe.com/illustrator/using/character-paragraph-styles.html).