Files
figcraft/crates/engine/src/cmd/view.rs
T
BFlat cc30a261e7 M1: layers panel keyboard (box selection, F2 rename, context menu) and stroke styles (#135)
## What

**Layers panel from the keyboard** (two of the three open items of area 3, plus long-list QA)
- **F2 renames** the selected layer (a second key for `object.rename`, next to Cmd/Ctrl+R) from the canvas, after a click on a row, or from a layer row that has the keyboard (F6 mode, where the canvas shortcuts are off, so the layers branch of `a11y::keys` runs it). When the rename ends the row gets the keyboard back (`a11y::refocus_row`); Escape in the field cancels and stays in the panel instead of jumping to the canvas.
- **Shift+F10 opens the context menu** (`view.contextMenu`, a new command that only asks the UI): at the focused layer row when the layers panel has the keyboard (F6 or a clicked row), else on the canvas just below the selection (the middle of the canvas with nothing selected). The menu takes the keyboard like the other menus opened from the keyboard (`a11y::popup`), and Escape gives it back to the row or the canvas. The Menu key can't be supported: egui 0.36 has no key for it.
- **Keyboard box selection** (`select.area`, F8): for keyboard-only users, a selection box appears around the selection (or in the middle of the view); the arrows move it, Shift+arrows move its far corner (10 screen pixels a press), Enter selects what it covers exactly like a marquee (Shift+Enter toggles, Cmd/Ctrl+Enter takes nested layers), Escape or a click drops it. A toast and the canvas's screen-reader description say the box's size and the keys. With a box (`{x, y, width, height, add?, deep?}`) the command selects directly, for agents. The marquee's rules (top-level layers, frames only when covered, the children of the frame the box starts in, the focus view, Shift toggling) moved into `Session::marquee_within` / `marquee_selection`, shared by the pointer marquee and the command.
- **Long lists (10k layers)**: a test that a layer near the bottom of a 10k-layer list is revealed (parents expanded, list scrolled) and that F6 lands the keyboard on its row and the arrows walk on from it; the UI bench (`perf_ui_frames`) gained rows for expanding every layer, arrow keys down the expanded list, revealing a layer at the bottom and collapsing everything. Release, 10k layers: first frame with every layer expanded 1.22 ms, an arrow key 1.04 ms, reveal 0.30 ms, collapse all 0.37 ms, idle 0.17 ms.

**Stroke styles** (area 6)
- What the public documentation describes for strokes was mostly already in: colour styles apply to strokes from the stroke section's style picker (`style.apply {target: "stroke"}`, linked, following `style.update`, one undo step, `style.detach {which: "stroke"}` keeping the colour), and the stroke weight binds to number variables. A test now covers that path.
- Missing piece, added: **each side's stroke weight binds to a number variable on its own** (`strokeTopWeight`, `strokeRightWeight`, `strokeBottomWeight`, `strokeLeftWeight`): `node.set` keys (setting or binding one side turns on individual strokes with the other sides at the weight), the stroke-weight variable scope, the stroke override group for instances, and REST `boundVariables` import. The Design panel's per-side fields are bindable, two to a row like the corner radii so a variable's name fits.

New strings go through `tr(...)` with `en.toml` / `es.toml` entries, and the two new commands have Spanish labels. Shortcuts are only in `keymap.rs`. Nothing redraws while idle (the box draws only when a key moves it). Selecting from the box leaves no undo step; each stroke edit is one.

## Verified
- **Desktop app** over the control channel (`target/debug/figcraft.exe` from this worktree's target dir, `--control <free port>`, separate `APPDATA`, keys sent as real `ui.input` key events, stopped by PID): F2 on a selected layer opens its name field in the layers panel (screenshot), typing and Enter rename it; F6 to the layers panel, Shift+F10 opens the menu at the Avatar row with Copy focused (screenshot), Escape gives the keyboard back to the row, F2 + typing + Enter renames it and the row keeps the keyboard ("Profile"); Shift+F10 on the canvas opens the menu for the selected frame with Copy focused (screenshot); F8 shows a box around the selected frame, Shift+arrows stretch it over a second layer (screenshot with the hint toast), Enter selects both; a rectangle with the colour style "Brand/Accent" on its stroke and its top weight bound to a number variable (screenshot: the style chip in the stroke section, the red stroke thicker at the top, the per-side field showing the variable).
- **MCP**: `figcraft-cli mcp` (headless): created a paint style, `style.apply {target: "stroke"}`, `object.rename`, bound `strokeLeftWeight` to a variable and ran `select.area` over the layer; `inspect_document` shows the name "Outlined card", `styles.stroke: "S:1"` with the style's colour on the strokes, `strokeSides [2, 2, 2, 6]`, `boundVariables {strokeLeftWeight}`, and one undo step per command.
- **Web**: `cargo xtask wasm` passes (part of the gate).
- **Performance**: release UI bench at 10k layers (numbers above).
- `cargo +1.99.0 xtask ci` passes (fmt, clippy, tests, layers, assets, wasm), after merging #131 and #132.

## Tests
- `ui-egui` `layers_keyboard_tests` (3): F2 from the canvas and from a focused row (the row gets the keyboard back, Escape cancels without leaving the panel); Shift+F10 at a focused row, on the canvas below the selection and after a clicked row, the menu taking and giving back the keyboard; F8: the box around the selection, the screen-reader description, Shift+arrows sizing, Enter selecting, arrows moving it without nudging layers, Escape, the middle of the view with nothing selected, a click dropping it.
- `ui-egui` `perf_tests::a_layer_revealed_at_the_bottom_of_10k_layers_gets_the_keyboard_on_its_row`, plus the new bench rows.
- `engine` `select_area_tests` (2): marquee rules through the command (negative sizes, frames, starting inside a frame, deep, add toggling, empty spots), the UI request with no box, bad boxes refused (the junk sweep covers both new commands too).
- `engine` `stroke_style_tests` (2): a colour style on strokes (link, undo, style edits, detach); stroke weight and per-side weights bound to variables following the frame's mode, `node.set` per-side keys, scopes and override groups.

## Not in this PR
- The Menu (application) key: egui 0.36 doesn't deliver it.
- Enter doesn't rename: on the canvas and a focused row it already selects children / activates the row.
- The keyboard box doesn't pan the view when it is moved off screen (zoom and pan keys still work while it shows).
- Shift+F10 does nothing while a toolbar or properties control has the keyboard.
- Progress docs: area 3 95%/78% → 98%/82%, 2–4 h → 1–2 h; area 6 90%/72% → 95%/75%, 1–3 h → 1–2 h; mainstream depth 67.8% → 68.1%; percentages unchanged at this rounding; full parity ~323–621 h → ~322–618 h (target-app-parity, ROADMAP); ui-parity rows (context menus, keyboard box selection, layers from the keyboard); `docs/mcp.md` documents `object.rename` without a name, `view.contextMenu`, `select.area` and stroke styles and variables.
2026-10-11 23:10:41 +07:00

356 lines
18 KiB
Rust

//! View menu, preferences and tools. View state is per document and drivable like everything else.
use figcraft_doc::*;
use serde_json::{Value, json};
use super::{CommandSpec, ok};
use crate::params::*;
use crate::tools::ToolId;
use crate::{EngineError, Result, Session, ViewState, bad, spec};
fn view(s: &mut Session) -> Result<&mut ViewState> {
Ok(&mut s.ds_mut()?.view)
}
fn flag(s: &mut Session, p: &Value, f: fn(&mut ViewState) -> &mut bool) -> Result<Value> {
let v = view(s)?;
let slot = f(v);
*slot = boolean(p, "on").unwrap_or(!*slot);
Ok(json!({"on": *slot}))
}
/// Pixel preview: toggles, or turns on at a resolution of 1x or 2x.
fn pixel_preview(s: &mut Session, p: &Value) -> Result<Value> {
let scale = match p.get("scale") {
None | Some(Value::Null) => None,
Some(v) => match v.as_u64() {
Some(k @ (1 | 2)) => Some(k as u8),
_ => return Err(bad("view.pixelPreview", "`scale` must be 1 or 2")),
},
};
let v = view(s)?;
if let Some(k) = scale {
v.pixel_scale = k;
}
v.pixel_preview = boolean(p, "on").unwrap_or(scale.is_some() || !v.pixel_preview);
Ok(json!({"on": v.pixel_preview, "scale": v.pixel_scale}))
}
fn zoom_to(s: &mut Session, z: f64) -> Result<Value> {
let v = view(s)?;
let c = (v.cx, v.cy);
v.set_zoom_at(z, c);
Ok(json!({"zoom": v.zoom}))
}
/// Figma's zoom steps.
const STEPS: &[f64] = &[0.02, 0.03, 0.06, 0.13, 0.25, 0.5, 1.0, 2.0, 4.0, 8.0, 16.0, 32.0, 64.0, 128.0, 256.0];
fn step(z: f64, up: bool) -> f64 {
if up {
STEPS.iter().copied().find(|s| *s > z * 1.001).unwrap_or(256.0)
} else {
STEPS.iter().rev().copied().find(|s| *s < z * 0.999).unwrap_or(0.02)
}
}
/// The zoom tool: a click zooms a step in (or out) about the clicked point, a dragged area fills
/// the view.
fn zoom_at(s: &mut Session, p: &Value) -> Result<Value> {
let (Some(x), Some(y)) = (num(p, "x").filter(|v| v.is_finite()), num(p, "y").filter(|v| v.is_finite())) else {
return Err(bad("view.zoomAt", "`x` and `y` (page coordinates) are required"));
};
let v = view(s)?;
match (num(p, "width"), num(p, "height")) {
(Some(w), Some(h)) if w.is_finite() && h.is_finite() && w > 0.0 && h > 0.0 => {
v.fit(figcraft_geom::Rect::new(x, y, x + w, y + h), ViewState::MAX_ZOOM);
}
_ => {
let z = step(v.zoom, !boolean(p, "out").unwrap_or(false));
v.set_zoom_at(z, (x, y));
}
}
Ok(json!({"zoom": v.zoom, "cx": v.cx, "cy": v.cy}))
}
fn zoom_frame(s: &mut Session, dir: i64) -> Result<Value> {
let ds = s.ds()?;
let frames = ds.doc.top_frames(ds.page);
if frames.is_empty() {
return ok();
}
let cur = ds.selection.first().and_then(|i| ds.doc.top_level_frame(*i)).and_then(|f| frames.iter().position(|x| *x == f));
let n = frames.len() as i64;
let next = match cur {
Some(c) => (c as i64 + dir).rem_euclid(n) as usize,
None => 0,
};
let Some(f) = frames.get(next).copied() else { return ok() };
let b = ds.doc.world_bounds(f).unwrap_or_default();
let ds = s.ds_mut()?;
ds.selection = vec![f];
ds.view.fit(b, 256.0);
Ok(json!({"frame": f}))
}
fn page_step(s: &mut Session, dir: i64) -> Result<Value> {
let ds = s.ds()?;
let pages = &ds.doc.pages;
let i = pages.iter().position(|p| *p == ds.page).unwrap_or(0) as i64;
let n = pages.len() as i64;
let next = (i + dir).clamp(0, n - 1) as usize;
let Some(pg) = pages.get(next).copied() else { return ok() };
let ds = s.ds_mut()?;
ds.page = pg;
ds.selection.clear();
ds.zoom_to_fit();
Ok(json!({"page": pg}))
}
fn ui(s: &mut Session, kind: &str) -> Result<Value> {
s.request_ui(kind, json!({}));
ok()
}
/// Move the keyboard `step` regions on (toolbar, layers, canvas, properties): the UI does it.
fn region(s: &mut Session, step: i64) -> Result<Value> {
s.request_ui("focus.region", json!({"step": step}));
ok()
}
fn pref(s: &mut Session, p: &Value, f: fn(&mut crate::Prefs) -> &mut bool) -> Result<Value> {
let slot = f(&mut s.prefs);
*slot = boolean(p, "on").unwrap_or(!*slot);
Ok(json!({"on": *slot}))
}
fn tool(s: &mut Session, t: ToolId) -> Result<Value> {
// A file you can't edit now (view only, or on its way to a server): moving around only.
if let Some(why) = s.active_read_only().filter(|_| !matches!(t, ToolId::Move | ToolId::Hand)) {
return Err(EngineError::Disabled(format!("tool.{}", t.id()), why.into()));
}
s.set_tool(t);
Ok(json!({"tool": t.id()}))
}
pub fn specs() -> Vec<CommandSpec> {
vec![
spec!("view.zoomIn", "Zoom in", "{}", false, |s, _| {
let z = view(s)?.zoom;
zoom_to(s, step(z, true))
}),
spec!("view.zoomOut", "Zoom out", "{}", false, |s, _| {
let z = view(s)?.zoom;
zoom_to(s, step(z, false))
}),
spec!("view.zoom100", "Zoom to 100%", "{}", false, |s, _| zoom_to(s, 1.0)),
spec!("view.zoom50", "Zoom to 50%", "{}", false, |s, _| zoom_to(s, 0.5)),
spec!("view.zoom200", "Zoom to 200%", "{}", false, |s, _| zoom_to(s, 2.0)),
spec!("view.zoomFit", "Zoom to fit", "{}", false, |s, _| {
let ds = s.ds_mut()?;
if let Some(b) = ds.doc.page_content_bounds(ds.page) {
ds.view.fit(b, 256.0);
}
Ok(json!({"zoom": ds.view.zoom}))
}),
spec!("view.zoomSelection", "Zoom to selection", "{}", false, |s, _| {
let ds = s.ds_mut()?;
if let Some(b) = ds.doc.bounds_of(&ds.selection) {
ds.view.fit(b, 256.0);
}
Ok(json!({"zoom": ds.view.zoom}))
}),
spec!("view.set", "Set view", "{zoom?, cx?, cy? (page coordinate at the centre), vw?, vh? (viewport size)}", false, |s, p| {
let v = view(s)?;
if let Some(z) = num(p, "zoom") {
v.zoom = z.clamp(ViewState::MIN_ZOOM, ViewState::MAX_ZOOM);
}
v.cx = num_or(p, "cx", v.cx);
v.cy = num_or(p, "cy", v.cy);
if let Some(w) = num(p, "vw") {
v.vw = w.clamp(10.0, 20000.0);
}
if let Some(h) = num(p, "vh") {
v.vh = h.clamp(10.0, 20000.0);
}
Ok(serde_json::to_value(&*v).unwrap_or(Value::Null))
}),
spec!(
"view.zoomAt",
"Zoom tool",
"{x, y (page point kept in place), out? (zoom out a step), width?, height? (an area to fit instead)}",
false,
zoom_at
),
spec!("view.get", "Get view", "{}", false, |s, _| Ok(serde_json::to_value(&s.ds()?.view).unwrap_or(Value::Null))),
spec!("view.prevFrame", "Zoom to previous frame", "{}", false, |s, _| zoom_frame(s, -1)),
spec!("view.nextFrame", "Zoom to next frame", "{}", false, |s, _| zoom_frame(s, 1)),
spec!("view.prevPage", "Previous page", "{}", false, |s, _| page_step(s, -1)),
spec!("view.nextPage", "Next page", "{}", false, |s, _| page_step(s, 1)),
spec!("view.pixelGrid", "Pixel grid", "{on?}", false, |s, p| flag(s, p, |v| &mut v.pixel_grid)),
spec!("view.layoutGrids", "Layout grids", "{on?}", false, |s, p| flag(s, p, |v| &mut v.layout_grids)),
spec!("view.rulers", "Rulers", "{on?}", false, |s, p| flag(s, p, |v| &mut v.rulers)),
spec!("view.slices", "Slices", "{on?}", false, |s, p| flag(s, p, |v| &mut v.show_slices)),
spec!("view.comments", "Comments", "{on?}", false, |s, p| flag(s, p, |v| &mut v.comments)),
spec!("view.outlines", "Outlines", "{on?}", false, |s, p| flag(s, p, |v| &mut v.outlines)),
spec!("view.outlinesSelection", "Outlines for selection", "{on?} outline mode for the selected layers only", false, |s, p| {
flag(s, p, |v| &mut v.outlines_selection)
}),
spec!("view.maskOutlines", "Mask outlines", "{on?}", false, |s, p| flag(s, p, |v| &mut v.mask_outlines)),
spec!("view.pixelPreview", "Pixel preview", "{on?, scale? (1|2: rendered pixels per page pixel; turns it on)}", false, pixel_preview),
spec!("view.frameOutlines", "Frame outlines", "{on?}", false, |s, p| flag(s, p, |v| &mut v.frame_outlines)),
spec!(
"view.proofSrgb",
"Soft-proof sRGB",
"{on?} mark the colours of a Display P3 file that sRGB screens and files can't show",
false,
|s, p| { flag(s, p, |v| &mut v.proof_srgb) }
),
spec!("view.snapGeometry", "Snap to geometry", "{on?}", false, |s, p| flag(s, p, |v| &mut v.snap_geometry)),
spec!("view.snapObjects", "Snap to objects", "{on?}", false, |s, p| flag(s, p, |v| &mut v.snap_objects)),
spec!("view.snapPixel", "Snap to pixel grid", "{on?}", false, |s, p| flag(s, p, |v| &mut v.snap_pixel)),
spec!("view.toggleUi", "Show/Hide UI", "{on?}", false, |s, p| flag(s, p, |v| &mut v.ui_hidden)),
spec!("view.layers", "Layers panel", "{}", false, |s, _| ui(s, "panel.layers")),
spec!("view.assets", "Assets panel", "{}", false, |s, _| ui(s, "panel.assets")),
spec!("view.design", "Design panel", "{}", false, |s, _| ui(s, "panel.design")),
spec!("view.prototype", "Prototype panel", "{}", false, |s, _| ui(s, "panel.prototype")),
spec!("view.designPrototype", "Switch between Design and Prototype", "{}", false, |s, _| ui(s, "panel.designPrototype")),
spec!("view.devMode", "Dev Mode", "{}", false, |s, _| ui(s, "panel.devMode")),
spec!("view.leftSidebar", "Show/Hide left sidebar", "{}", false, |s, _| ui(s, "panel.leftSidebar")),
// Several windows: the desktop app opens and focuses them (no-ops headless and in the browser).
spec!(
"window.new",
"New window",
"{path?, index?} a new window with a new file, the file at `path`, or open file `index` moved into it",
false,
|s, p| {
let index = if num(p, "index").is_some() { Some(req_index("window.new", p, "index")?) } else { None };
s.request_ui("window.new", json!({"path": string(p, "path"), "index": index}));
ok()
}
),
spec!("window.focus", "Bring window to front", "{id} a window id (control channel `window.list`)", false, |s, p| {
let id = req_index("window.focus", p, "id")?;
s.request_ui("window.focus", json!({"id": id}));
ok()
}),
spec!("view.nextRegion", "Focus next region", "{}", false, |s, _| region(s, 1)),
spec!("view.previousRegion", "Focus previous region", "{}", false, |s, _| region(s, -1)),
spec!(
"view.contextMenu",
"Show context menu",
"{} the selection's context menu at its layer row (when the layers panel has the keyboard) or on the canvas; the menu takes the keyboard",
false,
|s, _| ui(s, "contextMenu")
),
spec!("view.themeLight", "Light theme", "{}", false, |s, _| {
s.prefs.theme = "light".into();
ok()
}),
spec!("view.themeDark", "Dark theme", "{}", false, |s, _| {
s.prefs.theme = "dark".into();
ok()
}),
spec!("view.themeSystem", "Follow system theme", "{}", false, |s, _| {
s.prefs.theme = "system".into();
ok()
}),
spec!("pref.keepTool", "Keep tool selected after use", "{on?}", false, |s, p| pref(s, p, |x| &mut x.keep_tool)),
spec!("pref.highlightHover", "Highlight layers on hover", "{on?}", false, |s, p| pref(s, p, |x| &mut x.highlight_on_hover)),
spec!("pref.renameDuplicates", "Rename duplicated layers", "{on?}", false, |s, p| pref(s, p, |x| &mut x.rename_duplicates)),
spec!("pref.showDimensions", "Show dimensions on objects", "{on?}", false, |s, p| pref(s, p, |x| &mut x.show_dimensions)),
spec!("pref.numberKeysOpacity", "Use number keys for opacity", "{on?}", false, |s, p| pref(s, p, |x| &mut x.number_keys_opacity)),
spec!("pref.reduceMotion", "Reduce motion", "{on?}", false, |s, p| pref(s, p, |x| &mut x.reduce_motion)),
spec!("pref.nudge", "Nudge amount", "{small?, big?}", false, |s, p| {
s.prefs.nudge_small = num(p, "small").unwrap_or(s.prefs.nudge_small).clamp(0.01, 1000.0);
s.prefs.nudge_big = num(p, "big").unwrap_or(s.prefs.nudge_big).clamp(0.01, 10000.0);
Ok(json!({"small": s.prefs.nudge_small, "big": s.prefs.nudge_big}))
}),
spec!("pref.userName", "Your name in comments", "{name (blank: the default, \"You\")}", false, |s, p| {
let name = req_string("pref.userName", p, "name")?;
let name: String = name.trim().chars().filter(|c| !c.is_control()).take(64).collect();
s.prefs.user_name = if name.is_empty() { super::comment::DEFAULT_AUTHOR.into() } else { name };
Ok(json!({"name": s.prefs.user_name}))
}),
spec!("pref.language", "Interface language", "{language: system|en|es|… (a language code; no catalog: English)}", false, |s, p| {
let lang = req_string("pref.language", p, "language")?;
let lang = lang.trim();
// A BCP 47-style tag ("es", "pt-BR", "zh_Hans") or "system".
let tag = lang.len() <= 35
&& lang.split(['-', '_']).all(|part| !part.is_empty() && part.len() <= 8 && part.chars().all(|c| c.is_ascii_alphanumeric()));
if !tag {
return Err(bad("pref.language", format!("`{lang}` is not a language code")));
}
s.prefs.language = lang.to_string();
Ok(json!({"language": s.prefs.language}))
}),
spec!("app.preferences", "Preferences", "{}", false, |s, _| ui(s, "dialog.preferences")),
spec!("app.actions", "Actions", "{}", false, |s, _| ui(s, "palette.actions")),
spec!("help.shortcuts", "Keyboard shortcuts", "{}", false, |s, _| ui(s, "panel.shortcuts")),
spec!("help.about", "About FigCraft", "{}", false, |s, _| ui(s, "dialog.about")),
spec!("help.page", "Help page", "{}", false, |s, _| ui(s, "open.help")),
spec!("libraries.open", "Libraries", "{}", false, |s, _| ui(s, "panel.libraries")),
spec!(
"tool.set",
"Choose tool",
"{tool: move|scale|hand|frame|section|slice|rectangle|line|arrow|ellipse|polygon|star|pen|pencil|text|comment|shapeBuilder}",
false,
|s, p| {
let t = req_string("tool.set", p, "tool")?;
let t = ToolId::from_id(&t).ok_or_else(|| bad("tool.set", format!("unknown tool `{t}`")))?;
tool(s, t)
}
),
spec!(
"tool.pencilBrush",
"Pencil brush",
"{preset? (taper|ink|ribbon|bristle|dots|stars|confetti|leaves | null: plain), spacing?, sizeJitter?, rotationJitter?, scatter?, seed?} (the brush new Pencil strokes get; omit `preset` to read it)",
false,
|s, p| {
// `null` (unlike a missing preset) clears the brush.
if let Some(v) = p.get("preset") {
let v = if v.is_null() { Value::Null } else { p.clone() };
s.tool.pencil_brush = super::props::brush_of(&v).ok_or_else(|| bad("tool.pencilBrush", super::props::BRUSH_HELP))?;
}
Ok(json!({"brush": s.tool.pencil_brush}))
}
),
spec!(
"tool.scaleAnchor",
"Scale anchor",
"{anchor?: tl|t|tr|l|c|r|bl|b|br} (the point of the selection that stays put when the Scale tool scales; omit to read it)",
false,
|s, p| {
if let Some(a) = string(p, "anchor") {
s.tool.scale_anchor = crate::tools::anchor_of(&a).ok_or_else(|| bad("tool.scaleAnchor", format!("unknown anchor `{a}`")))?;
if let Ok(ds) = s.ds_mut() {
ds.revision += 1;
}
}
Ok(json!({"anchor": crate::tools::anchor_name(s.tool.scale_anchor)}))
}
),
spec!("tool.move", "Move", "{}", false, |s, _| tool(s, ToolId::Move)),
spec!("tool.scale", "Scale", "{}", false, |s, _| tool(s, ToolId::Scale)),
spec!("tool.hand", "Hand", "{}", false, |s, _| tool(s, ToolId::Hand)),
spec!("tool.frame", "Frame", "{}", false, |s, _| tool(s, ToolId::Frame)),
spec!("tool.section", "Section", "{}", false, |s, _| tool(s, ToolId::Section)),
spec!("tool.slice", "Slice", "{}", false, |s, _| tool(s, ToolId::Slice)),
spec!("tool.rectangle", "Rectangle", "{}", false, |s, _| tool(s, ToolId::Rectangle)),
spec!("tool.line", "Line", "{}", false, |s, _| tool(s, ToolId::Line)),
spec!("tool.arrow", "Arrow", "{}", false, |s, _| tool(s, ToolId::Arrow)),
spec!("tool.ellipse", "Ellipse", "{}", false, |s, _| tool(s, ToolId::Ellipse)),
spec!("tool.polygon", "Polygon", "{}", false, |s, _| tool(s, ToolId::Polygon)),
spec!("tool.star", "Star", "{}", false, |s, _| tool(s, ToolId::Star)),
spec!("tool.pen", "Pen", "{}", false, |s, _| tool(s, ToolId::Pen)),
spec!("tool.pencil", "Pencil", "{}", false, |s, _| tool(s, ToolId::Pencil)),
spec!("tool.text", "Text", "{}", false, |s, _| tool(s, ToolId::Text)),
spec!("tool.comment", "Comment", "{}", false, |s, _| tool(s, ToolId::Comment)),
spec!("tool.shapeBuilder", "Shape builder", "{}", false, |s, _| tool(s, ToolId::ShapeBuilder)),
spec!("edit.pickColor", "Pick color", "{}", false, |s, _| tool(s, ToolId::Eyedropper)),
]
}
#[allow(dead_code)]
fn unused(_: NodeId) {}