mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-10-30 04:37:29 -06:00
Merge pull request #3534 from nrq6993-a11y/stream/vc-feat1-3505-type-on-path-fill-hit
Type on a Path hits filled paths without a stroke (#3505)
This commit is contained in:
@@ -419,6 +419,36 @@ fn area_and_path_tools_convert_clicked_paths() {
|
||||
assert!(acts.iter().any(|a| matches!(a, Action::Exec(cmd, p) if cmd == "text.createInPath" && p["mode"] == "onPath")), "{acts:?}");
|
||||
}
|
||||
|
||||
/// Area Type and Type on a Path follow the reference app: click the path outline, not the fill interior
|
||||
/// (helpx: add-text-work-with-type-objects, creating-type-path).
|
||||
#[test]
|
||||
fn area_and_path_tools_hit_path_outline_not_fill_interior() {
|
||||
let (mut d, rect) = crate::testutil::doc_with_rect();
|
||||
if let Some(n) = d.node_mut(rect) {
|
||||
n.appearance.set_stroke(vectorcraft_color::Paint::None);
|
||||
}
|
||||
let (sel, p) = (Selection::default(), paint());
|
||||
let c = cx(&d, &sel, &p);
|
||||
let edge = (100.0, 150.0);
|
||||
let interior = (150.0, 150.0);
|
||||
for tool_id in ["areaType", "typeOnPath"] {
|
||||
let mut tool = TypeTool::new(tool_id);
|
||||
tool.pointer(&c, &PointerEvent::new(PointerKind::Down, edge.0, edge.1));
|
||||
let acts = tool.pointer(&c, &PointerEvent::new(PointerKind::Up, edge.0, edge.1));
|
||||
assert!(
|
||||
acts.iter().any(|a| matches!(a, Action::Exec(cmd, v) if cmd == "text.createInPath" && v["path"] == json!(rect.0))),
|
||||
"{tool_id} on outline: {acts:?}"
|
||||
);
|
||||
let mut tool = TypeTool::new(tool_id);
|
||||
tool.pointer(&c, &PointerEvent::new(PointerKind::Down, interior.0, interior.1));
|
||||
let acts = tool.pointer(&c, &PointerEvent::new(PointerKind::Up, interior.0, interior.1));
|
||||
assert!(
|
||||
!acts.iter().any(|a| matches!(a, Action::Exec(cmd, _) if cmd == "text.createInPath")),
|
||||
"{tool_id} in fill interior should not attach to path: {acts:?}"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn vertical_tools_preserve_their_ids_and_create_vertical_text() {
|
||||
for id in ["verticalType", "verticalAreaType", "verticalTypeOnPath"] {
|
||||
|
||||
Reference in New Issue
Block a user