mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-10-28 11:47:21 -06:00
#1063: a fill chosen with characters selected colours just them
Choosing a fill or stroke (Color panel, Swatches, the proxies) while the Type tool had a few characters selected painted every run of the type object. As in Illustrator, it now goes to the selected characters only: the runs are split at the selection's ends and the paint is placed on the runs in between, as one undo step; a stroke gets a 1 pt weight where it had none. With only a caret, or with explicit ids or an item, paint.setFill/setStroke behave as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
10f1c56a86
commit
75c587c8a0
@@ -563,3 +563,35 @@ fn automatic_alignment_updates_during_edits_and_can_be_overridden() {
|
||||
legacy["para"]["justify"] = json!("Left");
|
||||
assert_eq!(serde_json::from_value::<TextObject>(legacy).unwrap().para.justify, vectorcraft_doc::Justify::Left);
|
||||
}
|
||||
|
||||
/// #1063: a fill (or stroke) chosen while the Type tool has characters selected colours just
|
||||
/// those characters, as one undo step; the rest of the type keeps its colour.
|
||||
#[test]
|
||||
fn a_fill_chosen_with_characters_selected_colours_only_them() {
|
||||
let mut s = session();
|
||||
let v = ViewInfo::default();
|
||||
s.select_tool("type", v).unwrap();
|
||||
click(&mut s, 50.0, 300.0);
|
||||
let id = s.doc().unwrap().selection.objects[0];
|
||||
s.tool_text("Sample Text", v).unwrap();
|
||||
let before = obj(&s, id).runs[0].style.fill.clone();
|
||||
s.set_tool_option("select", &json!({"start": 0, "end": 6}));
|
||||
s.execute("paint.setFill", &json!({"color": "#00a000"})).unwrap();
|
||||
let t = obj(&s, id);
|
||||
assert_eq!(t.runs.len(), 2);
|
||||
assert_eq!(t.runs[0].text, "Sample");
|
||||
assert_eq!(t.runs[0].style.fill, Paint::solid(vectorcraft_color::Color::rgb8(0, 160, 0)));
|
||||
assert_eq!(t.runs[1].text, " Text");
|
||||
assert_eq!(t.runs[1].style.fill, before);
|
||||
// A stroke goes on the selected characters only, with a weight to show.
|
||||
s.execute("paint.setStroke", &json!({"color": "#ff0000"})).unwrap();
|
||||
let t = obj(&s, id);
|
||||
assert!(t.runs[0].style.stroke_width > 0.0 && !t.runs[0].style.stroke.is_none());
|
||||
assert!(t.runs[1].style.stroke.is_none());
|
||||
// One undo step each.
|
||||
let labels = undo_labels(&s);
|
||||
assert_eq!(&labels[labels.len() - 2..], ["Fill Color", "Stroke Color"]);
|
||||
s.execute("edit.undo", &json!({})).unwrap();
|
||||
s.execute("edit.undo", &json!({})).unwrap();
|
||||
assert!(obj(&s, id).runs.iter().all(|r| r.style.fill == before));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user