Files
vectorcraft/crates/ui-egui/src/tests_widthtool.rs
T
bflatasticandClaude Opus 5.5 13db157d36 M8.7: Width tool edits compound-path strokes, shows every subpath's points, own cursors
- A compound path's stroke lives on the compound: the tool edits it through
  any member, and stroke.widthPoint.* / stroke.widthProfile.set given a member
  edit the compound's profile.
- Width points show on every subpath the stroke runs along (not just the
  first) for the hovered and the selected stroke.
- Cursors: the Width tool's own glyphs off a stroke, over a stroke (a drag
  adds a point) and over a width point or handle (a drag moves or widens it).
- Hint-bar text for the tool.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-06 12:01:10 +07:00

30 lines
1.1 KiB
Rust

//! The Width tool in the UI: its cursors and hint.
use serde_json::json;
use vectorcraft_engine::Session;
use vectorcraft_tools::Cursor;
use crate::{VectorcraftApp, chrome, tests_labels::painted_text};
#[test]
fn the_width_tool_has_its_own_cursors() {
let ctx = egui::Context::default();
let mut out = ctx.run_ui(egui::RawInput::default(), |ui| {
let painter = ui.painter().clone();
for c in [Cursor::Width, Cursor::WidthAdd, Cursor::WidthPoint] {
assert!(crate::cursors::paint(&painter, c, egui::pos2(50.0, 50.0)), "{c:?} is drawn");
}
});
out.textures_delta.clear();
assert!(out.shapes.len() > 3, "{} shapes", out.shapes.len());
}
#[test]
fn the_hint_bar_explains_the_width_tool() {
let mut app = VectorcraftApp::new(Session::new(), Default::default());
app.run("file.new", json!({"width": 300, "height": 300})).unwrap();
app.run("tool.select", json!({"tool": "width"})).unwrap();
let text = painted_text(&mut app, chrome::hint_bar).replace('\n', "");
assert!(text.contains("add a width point") && text.contains("one side") && text.contains("remove points"), "{text}");
}