diff --git a/crates/engine/src/canvas/tools/click.rs b/crates/engine/src/canvas/tools/click.rs index 35a97a77a..a7c10d574 100644 --- a/crates/engine/src/canvas/tools/click.rs +++ b/crates/engine/src/canvas/tools/click.rs @@ -360,8 +360,13 @@ impl Session { pub(super) fn eyedrop(&mut self, ev: &PointerEvent) -> Result<()> { let ds = self.ds()?; let doc = ds.doc.clone(); - let view = figcraft_render::View { origin: (ev.x, ev.y), scale: ev.zoom.max(0.01), width: 1, height: 1 }; - let Some(pix) = figcraft_render::render_view(&doc, ds.page, &view, &Default::default()) else { return Ok(()) }; + // One screen pixel centred on the pointer (its top left half a pixel up and to the left). + let scale = ev.zoom.max(0.01); + let view = figcraft_render::View { origin: (ev.x - 0.5 / scale, ev.y - 0.5 / scale), scale, width: 1, height: 1 }; + // As the canvas draws it: an image magnified past 2x shows its pixels, so the colour picked + // is the pixel under the pointer, not a blend with its neighbours (#2189). + let opts = figcraft_render::Options { magnified_image_pixels: true, ..Default::default() }; + let Some(pix) = figcraft_render::render_view(&doc, ds.page, &view, &opts) else { return Ok(()) }; let rgba = figcraft_render::to_rgba8(&pix); let c = figcraft_color::Color::from_rgba8( rgba.first().copied().unwrap_or(0), diff --git a/crates/engine/src/cmd/edit/props.rs b/crates/engine/src/cmd/edit/props.rs index e7f04d7a1..c39f8abe2 100644 --- a/crates/engine/src/cmd/edit/props.rs +++ b/crates/engine/src/cmd/edit/props.rs @@ -113,8 +113,12 @@ pub(super) fn set(s: &mut Session, p: &Value) -> Result { // A new rotation for the selection turns it about its moved rotation origin: each layer's // point under the origin stays put. let ds = s.ds()?; - let pivot = - ds.moved_origin().filter(|_| props.contains_key("rotation") && !props.contains_key("x") && !props.contains_key("y") && ds.selection == ids); + let pivot = ds.moved_origin().filter(|_| { + (props.contains_key("rotation") || props.contains_key("absoluteRotation")) + && !props.contains_key("x") + && !props.contains_key("y") + && ds.selection == ids + }); let pinned: Vec<(NodeId, figcraft_geom::Point)> = match pivot { Some(o) => roots(&ds.doc, &ids) .into_iter() @@ -161,6 +165,11 @@ pub(super) fn set(s: &mut Session, p: &Value) -> Result { } let doc = s.doc_mut()?; let before = crate::cmd::styles::bound_before(doc, &ids); + let mut ids = ids; + if props.contains_key("absoluteRotation") { + // A page angle depends on the parents': turn a selected parent before the layers in it. + ids.sort_by_key(|i| doc.ancestors(*i).len()); + } for i in ids { crate::cmd::props::apply("node.set", doc, i, skipped.get(&i).unwrap_or(&props))?; } diff --git a/crates/engine/src/cmd/props.rs b/crates/engine/src/cmd/props.rs index a43ae67cc..0e928793e 100644 --- a/crates/engine/src/cmd/props.rs +++ b/crates/engine/src/cmd/props.rs @@ -16,7 +16,7 @@ use crate::{Result, bad}; pub const STROKE_SIDES: [&str; 4] = ["strokeTopWeight", "strokeRightWeight", "strokeBottomWeight", "strokeLeftWeight"]; /// Keys `node.set` understands (documented for agents). -pub const KEYS: &str = "name, visible, locked, opacity (0-1 or \"50%\"), blend, x, y (relative to the parent frame; groups don't count), width, height, rotation (degrees), \ +pub const KEYS: &str = "name, visible, locked, opacity (0-1 or \"50%\"), blend, x, y (relative to the parent frame; groups don't count), width, height, rotation (degrees), absoluteRotation (degrees on the page: the layer's angle plus its parents', what the Design panel's field shows; one of the two per call), \ fills (paints or colours; gradients as {type: linearGradient|radialGradient|angularGradient|diamondGradient, stops: [\"#hex\", ...], from?, to?} too), fill (colour, {$var: variable id or name}, or \"none\"/null: no fill), strokes, stroke (colour, {$var: variable id or name}, or \"none\"/null: no stroke), strokeWeight, strokeAlign (inside|center|outside), strokeSides [t,r,b,l], strokeTopWeight / strokeRightWeight / strokeBottomWeight / strokeLeftWeight (one side; turns on individual strokes), \ strokeCap / startCap / endCap, strokeJoin, miterAngle (degrees: sharper joins bevel; or miterLimit as a ratio), dashes [..], dashCap (none|round|square; null: dashes take startCap and endCap), widthProfile (preset uniform|wedge|taper|eye|rounded|pinch, [[t, scale], ...] or null), brush (preset id, {preset, spacing, sizeJitter, rotationJitter, scatter, seed} or null), cornerRadius (n or [tl,tr,br,bl]), cornerSmoothing (0-1), effects, \ clip, isMask, layout (null|horizontal|vertical|grid|{...}), gap, crossGap, padding (n or [t,r,b,l]), paddingTop/Right/Bottom/Left, \ @@ -456,7 +456,7 @@ fn apply_order(k: &str, v: &Value) -> u8 { match k { "path" | "width" | "height" | "w" | "h" => 0, "layout" | "layoutMode" => 1, - "rotation" => 3, + "rotation" | "absoluteRotation" => 3, "x" | "y" => 4, "fillStyle" | "strokeStyle" | "effectStyle" | "textStyle" | "gridStyle" => 5, "boundVariables" => 6, @@ -595,6 +595,27 @@ fn apply_geometry( let n = doc.get_mut(id)?; n.transform = figcraft_geom::set_rotation_about_center(n.transform, n.width, n.height, deg); } + "absoluteRotation" => { + let deg = f64_of(v).ok_or_else(|| bad(cmd, "`absoluteRotation` must be degrees"))?; + if props.contains_key("rotation") { + return Err(bad(cmd, "give one of `rotation` and `absoluteRotation`")); + } + let (w, h) = { + let n = doc.get(id)?; + (n.width, n.height) + }; + let world = figcraft_geom::set_rotation_about_center(doc.world_transform(id), w, h, deg); + let parent = doc.get(id)?.parent; + let pw = parent.map(|p| doc.world_transform(p)).unwrap_or(figcraft_geom::Affine::IDENTITY); + let local = pw.inverse() * world; + if local.as_coeffs().iter().all(|c| c.is_finite()) { + doc.get_mut(id)?.transform = local; + } else { + // A degenerate parent can't be inverted: turn the local angle instead. + let n = doc.get_mut(id)?; + n.transform = figcraft_geom::set_rotation_about_center(n.transform, n.width, n.height, deg); + } + } _ => return Ok(false), } Ok(true) diff --git a/crates/engine/src/eyedropper_image_tests.rs b/crates/engine/src/eyedropper_image_tests.rs new file mode 100644 index 000000000..b5e55cd23 --- /dev/null +++ b/crates/engine/src/eyedropper_image_tests.rs @@ -0,0 +1,42 @@ +//! #2189: the eyedropper picks the colour the canvas shows under the pointer. A magnified image +//! draws its pixels on the canvas (`magnified_image_pixels`), so the picked colour is that pixel's, +//! not a blend with its neighbours. + +use base64::Engine as _; +use serde_json::json; + +use crate::Session; +use crate::tools::{PointerEvent, PointerKind}; + +/// A 9 x 9 image of `back` with a 1 px vertical line of `line` in column 4 (a thin border in a +/// screenshot, as in the report). +fn line_png(back: [u8; 3], line: [u8; 3]) -> Vec { + let mut p = figcraft_render::Pixmap::new(9, 9).unwrap(); + for (i, px) in p.data_mut().chunks_exact_mut(4).enumerate() { + let c = if i % 9 == 4 { line } else { back }; + px.copy_from_slice(&[c[0], c[1], c[2], 255]); + } + figcraft_render::encode_png(&p).unwrap() +} + +/// The colour the eyedropper picks at page point (x, y) at `zoom`. +fn picked(png: &[u8], x: f64, y: f64, zoom: f64) -> String { + let mut s = Session::new(); + let data = base64::engine::general_purpose::STANDARD.encode(png); + s.execute("image.place", &json!({"data": data, "x": 0, "y": 0})).unwrap(); + s.execute("edit.pickColor", &json!({"apply": false})).unwrap(); + s.pointer(&PointerEvent::at(PointerKind::Down, x, y, zoom)).unwrap(); + s.tool.picked.map(|c| c.to_hex()).unwrap_or_default() +} + +#[test] +fn the_eyedropper_picks_a_magnified_images_pixel_not_a_blend_with_its_neighbours() { + // The reporter's colours: a #3D444D border, 1 px wide, beside a darker background. + let png = line_png([0x15, 0x1B, 0x23], [0x3D, 0x44, 0x4D]); + for zoom in [2.0, 8.0, 20.0] { + assert_eq!(picked(&png, 4.5, 4.5, zoom), "3D444D", "on the line at {zoom}x"); + assert_eq!(picked(&png, 2.5, 4.5, zoom), "151B23", "beside it at {zoom}x"); + } + // At 1:1 the canvas pixel is the image's pixel too. + assert_eq!(picked(&png, 4.5, 4.5, 1.0), "3D444D", "on the line at 1x"); +} diff --git a/crates/engine/src/lib.rs b/crates/engine/src/lib.rs index ebe88332f..39ead2e82 100644 --- a/crates/engine/src/lib.rs +++ b/crates/engine/src/lib.rs @@ -327,6 +327,8 @@ mod extended_chain_tests; #[cfg(test)] mod eyedropper_create_tests; #[cfg(test)] +mod eyedropper_image_tests; +#[cfg(test)] mod facilitate_tests; #[cfg(test)] mod fig_export_assets_tests; diff --git a/crates/engine/src/rotation_origin_tests.rs b/crates/engine/src/rotation_origin_tests.rs index 38878a0f0..181559a05 100644 --- a/crates/engine/src/rotation_origin_tests.rs +++ b/crates/engine/src/rotation_origin_tests.rs @@ -90,6 +90,17 @@ fn rotation_field_and_rotate_commands_turn_about_a_moved_origin() { assert!(s.execute("transform.setRotationOrigin", &json!({"x": 1})).is_err(), "x without y"); } +#[test] +fn the_absolute_rotation_key_turns_about_a_moved_origin_too() { + let mut s = Session::new(); + let r = rect(&mut s); + s.execute("transform.setRotationOrigin", &json!({"x": 100, "y": 100})).unwrap(); + s.execute("node.set", &json!({"ids": [r], "props": {"absoluteRotation": 30}})).unwrap(); + let doc = s.doc().unwrap(); + assert!(near(doc.world_transform(r) * Point::new(100.0, 100.0), Point::new(100.0, 100.0))); + assert!((figcraft_geom::rotation_degrees(doc.world_transform(r)) - 30.0).abs() < 1e-6); +} + #[test] fn origin_lasts_as_long_as_its_selection() { let mut s = Session::new(); diff --git a/crates/engine/src/transform_behaviour_tests.rs b/crates/engine/src/transform_behaviour_tests.rs index fe6709ee4..7b0354b2e 100644 --- a/crates/engine/src/transform_behaviour_tests.rs +++ b/crates/engine/src/transform_behaviour_tests.rs @@ -533,6 +533,61 @@ fn design_panel_edits_reach_every_selected_layer() { assert!(near(rotation(&s, a), 30.0) && flipped(&s, a), "{}", rotation(&s, a)); } +#[test] +fn absolute_rotation_sets_the_rotation_on_the_page_keeping_the_centre() { + let mut s = session(); + let page = |s: &Session, i: NodeId| rotation_degrees(s.doc().unwrap().world_transform(i)); + let f = id(&ex(&mut s, "frame.create", json!({"x": 0, "y": 100, "width": 400, "height": 400}))); + set(&mut s, &[f], json!({"rotation": 10})); + let r = rect(&mut s, 100.0, 100.0, 120.0, 80.0, Some(f)); + assert!(near(page(&s, r), 10.0) && near(rotation(&s, r), 0.0)); + let centre = s.doc().unwrap().world_transform(r) * Point::new(60.0, 40.0); + set(&mut s, &[r], json!({"absoluteRotation": 7})); + assert!(near(page(&s, r), 7.0), "{}", page(&s, r)); + assert!(near(rotation(&s, r), -3.0), "{}", rotation(&s, r)); + let c = s.doc().unwrap().world_transform(r) * Point::new(60.0, 40.0); + assert!((c - centre).hypot() < 1e-6, "the centre stays put"); + set(&mut s, &[r], json!({"absoluteRotation": 0})); + assert!(near(page(&s, r), 0.0) && near(rotation(&s, r), -10.0)); + // `node.get` still reports the local angle. + let got = ex(&mut s, "node.get", json!({"id": r})); + let rot = got["rotation"].as_f64().unwrap_or(f64::NAN); + assert!(near(rot, -10.0), "{got}"); + // Groups: a child reads and sets the page angle, its sibling keeps its own. + let a = rect(&mut s, 0.0, 600.0, 50.0, 50.0, None); + let b = rect(&mut s, 100.0, 600.0, 50.0, 50.0, None); + let g = id(&ex(&mut s, "object.group", json!({"ids": [a, b]}))); + set(&mut s, &[g], json!({"rotation": 10})); + assert!(near(page(&s, a), 10.0)); + set(&mut s, &[a], json!({"absoluteRotation": 7})); + assert!(near(page(&s, a), 7.0) && near(page(&s, b), 10.0)); + // Several layers: one value on the page for all, one undo step. + let top = rect(&mut s, 800.0, 0.0, 50.0, 50.0, None); + let steps = undo_steps(&s); + set(&mut s, &[r, top], json!({"absoluteRotation": 45})); + assert!(near(page(&s, r), 45.0) && near(page(&s, top), 45.0)); + assert_eq!(undo_steps(&s), steps + 1); + // A flip is kept. + ex(&mut s, "object.flipH", json!({"ids": [r]})); + set(&mut s, &[r], json!({"absoluteRotation": 30})); + assert!(near(page(&s, r), 30.0) && flipped(&s, r), "{}", page(&s, r)); + // One of the two keys per call. + assert!(s.execute("node.set", &json!({"ids": [r], "props": {"rotation": 1, "absoluteRotation": 2}})).is_err()); +} + +#[test] +fn absolute_rotation_on_a_frame_and_a_layer_inside_it_lands_both_on_the_page_angle() { + let mut s = session(); + let page = |s: &Session, i: NodeId| rotation_degrees(s.doc().unwrap().world_transform(i)); + let f = id(&ex(&mut s, "frame.create", json!({"x": 0, "y": 100, "width": 400, "height": 400}))); + set(&mut s, &[f], json!({"rotation": 10})); + let r = rect(&mut s, 100.0, 100.0, 120.0, 80.0, Some(f)); + // The layer inside comes first in the ids: the frame's turn must not carry it past 45. + set(&mut s, &[r, f], json!({"absoluteRotation": 45})); + assert!(near(page(&s, f), 45.0), "{}", page(&s, f)); + assert!(near(page(&s, r), 45.0), "{}", page(&s, r)); +} + #[test] fn constrain_proportions_keeps_the_other_side_in_ratio() { let mut s = session(); diff --git a/crates/mcp/src/tools.rs b/crates/mcp/src/tools.rs index be714f70c..9a546dc2a 100644 --- a/crates/mcp/src/tools.rs +++ b/crates/mcp/src/tools.rs @@ -208,7 +208,7 @@ fn tools() -> Vec { tool( "set_properties", "Set properties", - "Set properties on one or more layers as one undo step (engine `node.set`). Keys: name, visible, locked, opacity (0-1), blend, x, y (relative to the parent frame; groups don't count), width, height, rotation (degrees), fill (colour) / fills (array of paints: \"#hex\" or {\"type\":\"solid\",\"color\":\"#hex\"} or {\"type\":\"linearGradient\",\"stops\":[\"#hex\",\"#hex\"]} or stops [{\"position\":0..1,\"color\":\"#hex\"}], optional from/to handles in the unit box; radialGradient too), stroke / strokes, strokeWeight, strokeAlign (inside|center|outside), cornerRadius (n or [tl,tr,br,bl]), effects (array, e.g. {\"type\":\"dropShadow\",\"color\":\"#00000040\",\"offset\":[0,4],\"radius\":8}), clip, layout (null|horizontal|vertical|grid), gap, padding (n or [t,r,b,l]), mainAlign (min|center|max|spaceBetween|spaceAround|spaceEvenly), crossAlign, wrap, contentAlign (auto|spaceBetween: wrapped lines), sizingH / sizingV (fixed|hug|fill), constraints {horizontal, vertical}, characters, fontFamily, fontStyle, fontSize, lineHeight, letterSpacing, textAlign, textAutoResize. Auto layout keys (gap, padding, mainAlign, crossAlign, wrap, …) apply to frames, components and instances only: other layers among the ids are skipped and named in `warnings`, and with none that can take them the call is an error. A fontStyle draws in the family's nearest face; `warnings` says when that face has another weight or slant than the name asks for. Run list_commands with filter \"node.set\" for the full list. Unknown keys are an error. Returns the updated layers.", + "Set properties on one or more layers as one undo step (engine `node.set`). Keys: name, visible, locked, opacity (0-1), blend, x, y (relative to the parent frame; groups don't count), width, height, rotation (degrees), absoluteRotation (degrees on the page), fill (colour) / fills (array of paints: \"#hex\" or {\"type\":\"solid\",\"color\":\"#hex\"} or {\"type\":\"linearGradient\",\"stops\":[\"#hex\",\"#hex\"]} or stops [{\"position\":0..1,\"color\":\"#hex\"}], optional from/to handles in the unit box; radialGradient too), stroke / strokes, strokeWeight, strokeAlign (inside|center|outside), cornerRadius (n or [tl,tr,br,bl]), effects (array, e.g. {\"type\":\"dropShadow\",\"color\":\"#00000040\",\"offset\":[0,4],\"radius\":8}), clip, layout (null|horizontal|vertical|grid), gap, padding (n or [t,r,b,l]), mainAlign (min|center|max|spaceBetween|spaceAround|spaceEvenly), crossAlign, wrap, contentAlign (auto|spaceBetween: wrapped lines), sizingH / sizingV (fixed|hug|fill), constraints {horizontal, vertical}, characters, fontFamily, fontStyle, fontSize, lineHeight, letterSpacing, textAlign, textAutoResize. Auto layout keys (gap, padding, mainAlign, crossAlign, wrap, …) apply to frames, components and instances only: other layers among the ids are skipped and named in `warnings`, and with none that can take them the call is an error. A fontStyle draws in the family's nearest face; `warnings` says when that face has another weight or slant than the name asks for. Run list_commands with filter \"node.set\" for the full list. Unknown keys are an error. Returns the updated layers.", obj( json!({"ids": ids_schema("Layer ids (default: the selection)"), "props": {"type": "object", "description": "Property values to set"}}), &["props"], diff --git a/crates/ui-egui/src/canvas/overlays.rs b/crates/ui-egui/src/canvas/overlays.rs index f4ce8cce0..3e15693f9 100644 --- a/crates/ui-egui/src/canvas/overlays.rs +++ b/crates/ui-egui/src/canvas/overlays.rs @@ -209,6 +209,61 @@ fn layout_grids(app: &FigApp, painter: &egui::Painter, doc: &Document, c: NodeId } } +/// The solid colour of the fill the next typed character gets (the character before the caret, +/// the first one's at 0, the base style for an empty text): the style's own fills when it has +/// them, else the layer's. `None` when the topmost visible paint isn't a solid (gradient, image, +/// no visible fill), so the caller uses [`caret_fallback`]. Opaque on purpose: Figma's caret +/// is one colour, and the fill's and paint's opacity weren't measured, so it must stay visible. +fn caret_fill(n: &figcraft_doc::Node, caret: usize) -> Option { + let t = n.kind.text()?; + let style = t.style_at(caret.saturating_sub(1)); + let paints = style.fills.as_ref().unwrap_or(&n.fills); + paints.iter().rev().find(|p| p.visible).and_then(|p| match &p.kind { + figcraft_color::PaintKind::Solid { color } => Some(color.with_alpha(1.0)), + _ => None, + }) +} + +/// [`caret_fill`] as a screen colour. +fn caret_color(ctx: &egui::Context, n: &figcraft_doc::Node, caret: usize) -> Option { + caret_fill(n, caret).map(|c| doc_c32(ctx, c)) +} + +/// The caret of a text without a solid fill (a gradient, an image, no visible fill): black on a +/// light surface, white on a dark one. The surface is the nearest layer around the text whose +/// topmost visible fill is a solid at least half opaque as drawn (its colour's alpha times its paint's +/// opacity times its own and its containers' layer opacity), else the page; a layer whose top fill is a gradient or an +/// image is passed over. Not the interface's text colour, which is white in the dark theme and +/// vanishes on the default light page (#2190). +fn caret_fallback(doc: &Document, id: NodeId) -> Color32 { + let chain = doc.ancestors(id); + // Each layer's opacity as drawn: its own times every container's above it. + let drawn: Vec = { + let mut acc = 1.0f32; + let mut out: Vec = chain + .iter() + .rev() + .map(|a| { + acc *= doc.node(*a).map_or(1.0, |n| if n.opacity.is_finite() { n.opacity.clamp(0.0, 1.0) } else { 1.0 }); + acc + }) + .collect(); + out.reverse(); + out + }; + let under = chain.iter().zip(drawn).find_map(|(a, alpha)| { + let n = doc.node(*a)?; + match &n.kind { + NodeKind::Page { background, .. } => Some(*background), + _ => n.fills.iter().rev().find(|p| p.visible).and_then(|p| match &p.kind { + figcraft_color::PaintKind::Solid { color } if color.a * p.opacity * alpha >= 0.5 => Some(*color), + _ => None, + }), + } + }); + if under.is_some_and(|c| c.is_dark()) { Color32::WHITE } else { Color32::BLACK } +} + fn text_edit_overlay(app: &FigApp, painter: &egui::Painter, t: &Tokens, doc: &Document, te: &figcraft_engine::TextEdit, zoom: f64) { let preedit = app.preedit_view(); let edoc: &Document = preedit.map(|p| &*p.doc).unwrap_or(doc); @@ -242,7 +297,8 @@ fn text_edit_overlay(app: &FigApp, painter: &egui::Painter, t: &Tokens, doc: &Do let caret = preedit.map(|p| p.cursor).unwrap_or(te.caret); let blink = (painter.ctx().input(|i| i.time) * 2.0) as i64 % 2 == 0; if blink || a != b { - painter.line_segment(text.caret(app, caret, zoom), stroke(t.text, 1.0)); + let col = edoc.node(te.id).and_then(|n| caret_color(painter.ctx(), n, caret)).unwrap_or_else(|| caret_fallback(edoc, te.id)); + painter.line_segment(text.caret(app, caret, zoom), stroke(col, 1.0)); } painter.ctx().request_repaint_after(std::time::Duration::from_millis(500)); } @@ -782,3 +838,99 @@ fn pick_outline(app: &FigApp, painter: &egui::Painter, doc: &Document) { draw_outline(app, painter, doc, p, stroke(crate::handles::PINK, 2.0)); } } + +#[cfg(test)] +mod caret_tests { + use super::*; + use figcraft_color::{Color, Paint}; + use figcraft_doc::{Node, NodeId, NodeKind, StyleRun, TextData}; + + fn text(chars: &str, fills: Vec) -> Node { + let mut n = Node::new(NodeId(1), NodeKind::Text(TextData { characters: chars.into(), ..TextData::default() }), "Text", 100.0, 20.0); + n.fills = fills; + n + } + + fn hex(s: &str) -> Color { + Color::from_hex(s).unwrap() + } + + #[test] + fn red_text_has_a_red_caret() { + let n = text("Caret", vec![Paint::solid(hex("#FF0000"))]); + assert_eq!(caret_fill(&n, 2), Some(hex("#FF0000"))); + assert_eq!(caret_color(&egui::Context::default(), &n, 2), Some(Color32::from_rgb(255, 0, 0))); + } + + #[test] + fn light_grey_text_keeps_its_own_colour_whatever_is_behind_it() { + // Inside a #222222 frame: the frame's fill plays no part. + let n = text("Caret", vec![Paint::solid(hex("#DDDDDD"))]); + assert_eq!(caret_fill(&n, 5), Some(hex("#DDDDDD"))); + assert_eq!(caret_color(&egui::Context::default(), &n, 0), Some(Color32::from_rgb(0xDD, 0xDD, 0xDD))); + } + + #[test] + fn the_caret_follows_the_run_of_the_character_before_it() { + let mut n = text("ab cd", vec![Paint::solid(hex("#000000"))]); + if let Some(t) = n.kind.text_mut() { + let mut style = t.style.clone(); + style.fills = Some(vec![Paint::solid(hex("#FF0000"))]); + t.runs.push(StyleRun { start: 3, end: 5, style }); + } + assert_eq!(caret_fill(&n, 2), Some(hex("#000000")), "after a black character"); + assert_eq!(caret_fill(&n, 4), Some(hex("#FF0000")), "after a red character"); + assert_eq!(caret_fill(&n, 0), Some(hex("#000000")), "at the start: the first character's"); + } + + #[test] + fn the_caret_is_opaque_whatever_the_fill_opacity() { + let mut p = Paint::solid(hex("#336699")); + p.opacity = 0.2; + assert_eq!(caret_fill(&text("x", vec![p]), 1).map(|c| c.a), Some(1.0)); + } + + /// #2190: a caret without a solid fill reads on the page: black on the default light page, + /// white on a dark one (the interface's text colour was white in the dark theme). + #[test] + fn without_a_solid_fill_the_caret_contrasts_with_the_page() { + let mut s = figcraft_engine::Session::new(); + let r = s.execute("text.create", &serde_json::json!({"text": "Caret", "x": 0, "y": 0})).unwrap(); + let id = figcraft_engine::params::id_of(&r["id"]).unwrap(); + assert_eq!(caret_fallback(s.doc().unwrap(), id), Color32::BLACK, "the default light page"); + s.execute("page.setBackground", &serde_json::json!({"color": "#1E1E1E"})).unwrap(); + assert_eq!(caret_fallback(s.doc().unwrap(), id), Color32::WHITE, "a dark page"); + } + + /// CodeRabbit on #2163: a dark frame on a light page is the surface under its text. + #[test] + fn without_a_solid_fill_the_caret_contrasts_with_the_frame_around_it() { + let mut s = figcraft_engine::Session::new(); + let ex = |s: &mut figcraft_engine::Session, c: &str, p: serde_json::Value| s.execute(c, &p).unwrap(); + let f = ex(&mut s, "frame.create", serde_json::json!({"x": 0, "y": 0, "width": 300, "height": 200})); + let f = figcraft_engine::params::id_of(&f["id"]).unwrap(); + ex(&mut s, "node.set", serde_json::json!({"id": f, "props": {"fill": "#222222"}})); + let r = ex(&mut s, "text.create", serde_json::json!({"text": "Caret", "x": 20, "y": 20, "parent": f})); + let id = figcraft_engine::params::id_of(&r["id"]).unwrap(); + assert_eq!(caret_fallback(s.doc().unwrap(), id), Color32::WHITE, "inside a dark frame on the light page"); + ex(&mut s, "node.set", serde_json::json!({"id": f, "props": {"fill": "#F0F0F0"}})); + assert_eq!(caret_fallback(s.doc().unwrap(), id), Color32::BLACK, "inside a light frame"); + // A dark frame drawn at 20% opacity shows the light page through it. + ex(&mut s, "node.set", serde_json::json!({"id": f, "props": {"fill": "#222222", "opacity": 0.2}})); + assert_eq!(caret_fallback(s.doc().unwrap(), id), Color32::BLACK, "a faint dark frame on the light page"); + // The same through the colour's own alpha. + ex(&mut s, "node.set", serde_json::json!({"id": f, "props": {"fill": "#22222233", "opacity": 1.0}})); + assert_eq!(caret_fallback(s.doc().unwrap(), id), Color32::BLACK, "a dark fill at 20% alpha"); + } + + #[test] + fn gradient_or_missing_fills_have_no_fill_colour() { + let mut g = Paint::solid(hex("#FF0000")); + g.kind = figcraft_color::PaintKind::Gradient(figcraft_color::Gradient::default_for(figcraft_color::GradientKind::Linear, hex("#FF0000"))); + assert_eq!(caret_fill(&text("Caret", vec![g]), 2), None); + assert_eq!(caret_fill(&text("Caret", vec![]), 2), None); + let mut hidden = Paint::solid(hex("#FF0000")); + hidden.visible = false; + assert_eq!(caret_fill(&text("Caret", vec![hidden]), 2), None); + } +} diff --git a/crates/ui-egui/src/field_tests.rs b/crates/ui-egui/src/field_tests.rs index cf37a65da..b9620f177 100644 --- a/crates/ui-egui/src/field_tests.rs +++ b/crates/ui-egui/src/field_tests.rs @@ -441,6 +441,68 @@ fn the_arrow_keys_step_by_the_nudge_amounts_and_fractional_fields_by_their_own() assert!((rot.abs() - 11.0).abs() < 1e-6, "rotation {rot}: the steps stay after Escape"); } +#[test] +fn the_rotation_field_shows_and_sets_the_rotation_on_the_page() { + let mut s = Session::new(); + let f = id(s.execute("frame.create", &json!({"x": 0, "y": 100, "width": 400, "height": 400})).unwrap()); + s.execute("node.set", &json!({"ids": [f], "props": {"rotation": 10}})).unwrap(); + let r = id(s.execute("shape.rectangle", &json!({"x": 100, "y": 100, "width": 120, "height": 80, "parent": f})).unwrap()); + s.execute("node.set", &json!({"ids": [r], "props": {"rotation": -10}})).unwrap(); + let b = id(s.execute("shape.rectangle", &json!({"x": 600, "y": 0, "width": 50, "height": 50})).unwrap()); + s.execute("select.set", &json!({"ids": [r]})).unwrap(); + let mut u = Ui::new(s); + u.ctx.enable_accesskit(); + u.frame(vec![]); + let page = |u: &Ui, n: NodeId| figcraft_geom::rotation_degrees(u.app.session.doc().unwrap().world_transform(n)); + let local = |u: &Ui, n: NodeId| figcraft_geom::rotation_degrees(u.app.session.doc().unwrap().node(n).unwrap().transform); + assert_eq!(field(&mut u, "Rotation").1, "0°"); + type_into(&mut u, "Rotation", "7", Key::Enter); + assert!((page(&u, r) - 7.0).abs() < 1e-6 && (local(&u, r) + 3.0).abs() < 1e-6, "{} {}", page(&u, r), local(&u, r)); + assert_eq!(field(&mut u, "Rotation").1, "7°"); + // Arrows step the shown value. + let shift = Modifiers { shift: true, ..Modifiers::NONE }; + let (p, _) = field(&mut u, "Rotation"); + click(&mut u, p); + key(&mut u, Key::ArrowUp, Modifiers::NONE); + key(&mut u, Key::ArrowUp, shift); + key(&mut u, Key::Escape, Modifiers::NONE); + assert!((page(&u, r) - 18.0).abs() < 1e-6, "{}", page(&u, r)); + assert_eq!(field(&mut u, "Rotation").1, "18°"); + // Scrubbing is one undo step. + let steps = undo_steps(&u); + scrub(&mut u, "Rotation", 15.0, Modifiers::NONE); + assert!((page(&u, r) - 33.0).abs() < 1e-6, "{}", page(&u, r)); + assert_eq!(undo_steps(&u), steps + 1); + // Mixed: layers in differently turned parents agree when their page angles do. + u.app.session.execute("node.set", &json!({"ids": [b], "props": {"rotation": 33}})).unwrap(); + u.app.session.execute("select.set", &json!({"ids": [r, b]})).unwrap(); + assert_eq!(field(&mut u, "Rotation").1, "33°"); + u.app.session.execute("node.set", &json!({"ids": [b], "props": {"rotation": 20}})).unwrap(); + assert_eq!(field(&mut u, "Rotation").1, "Mixed"); + let steps = undo_steps(&u); + type_into(&mut u, "Rotation", "+10", Key::Enter); + assert!((page(&u, r) - 43.0).abs() < 1e-6 && (page(&u, b) - 30.0).abs() < 1e-6, "{} {}", page(&u, r), page(&u, b)); + assert_eq!(undo_steps(&u), steps + 1); +} + +#[test] +fn a_relative_rotation_edit_turns_a_selected_parent_before_its_child_whatever_the_selection_order() { + let mut s = Session::new(); + let f = id(s.execute("frame.create", &json!({"x": 0, "y": 0, "width": 400, "height": 400})).unwrap()); + let c = id(s.execute("shape.rectangle", &json!({"x": 100, "y": 100, "width": 120, "height": 80, "parent": f})).unwrap()); + s.execute("node.set", &json!({"ids": [f], "props": {"rotation": 10}})).unwrap(); + s.execute("node.set", &json!({"ids": [c], "props": {"absoluteRotation": 30}})).unwrap(); + // The child first, then its parent. + s.execute("select.set", &json!({"ids": [c, f]})).unwrap(); + let mut u = Ui::new(s); + u.ctx.enable_accesskit(); + u.frame(vec![]); + let page = |u: &Ui, n: NodeId| figcraft_geom::rotation_degrees(u.app.session.doc().unwrap().world_transform(n)); + assert_eq!(field(&mut u, "Rotation").1, "Mixed"); + type_into(&mut u, "Rotation", "+10", Key::Enter); + assert!((page(&u, f) - 20.0).abs() < 1e-6 && (page(&u, c) - 40.0).abs() < 1e-6, "{} {}", page(&u, f), page(&u, c)); +} + #[test] fn arithmetic_commits_tab_moves_on_and_escape_restores() { let (mut u, a, _) = setup(); diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs index 2daa3f406..01cfe8e88 100644 --- a/crates/ui-egui/src/lib.rs +++ b/crates/ui-egui/src/lib.rs @@ -254,6 +254,8 @@ mod save_as_tests; #[cfg(test)] mod select_all_tests; #[cfg(test)] +mod selection_colors_tests; +#[cfg(test)] mod shortcut_keys_tests; #[cfg(test)] mod shortcuts_tests; diff --git a/crates/ui-egui/src/panels/right.rs b/crates/ui-egui/src/panels/right.rs index 56dde1a47..3c64f665c 100644 --- a/crates/ui-egui/src/panels/right.rs +++ b/crates/ui-egui/src/panels/right.rs @@ -75,7 +75,12 @@ impl FigApp { None => return, }; let Ok(doc) = self.session.doc() else { return }; - let values: Vec<(NodeId, f64)> = ids.iter().filter_map(|i| Some((*i, rel.apply(shown(doc.node(*i)?))?))).collect(); + let mut values: Vec<(NodeId, f64)> = ids.iter().filter_map(|i| Some((*i, rel.apply(shown(doc.node(*i)?))?))).collect(); + if key == "absoluteRotation" { + // A page angle depends on the parents': turn a selected parent before the layers in it + // (as `node.set` orders a multi-id call), whatever order the selection is in. + values.sort_by_key(|(i, _)| doc.ancestors(*i).len()); + } if values.is_empty() || self.session.begin_interaction("Edit").is_err() { return; } @@ -627,8 +632,9 @@ fn y_of(doc: &Document, n: &Node) -> f64 { (doc.frame_relative(n.id).as_coeffs()[5] * 100.0).round() / 100.0 } -fn rot_of(n: &Node) -> f64 { - (figcraft_geom::rotation_degrees(n.transform) * 100.0).round() / 100.0 +/// The layer's rotation on the page (its own angle plus its parents'), what the field shows. +fn rot_of(doc: &Document, n: &Node) -> f64 { + (figcraft_geom::rotation_degrees(doc.world_transform(n.id)) * 100.0).round() / 100.0 } pub(crate) fn position_values(ctx: &egui::Context, doc: &Arc, sel: &[NodeId]) -> PositionValues { @@ -637,7 +643,7 @@ pub(crate) fn position_values(ctx: &egui::Context, doc: &Arc, sel: &[N can_align: figcraft_engine::cmd::arrange::can_align(doc, sel), x: common(doc, sel, |n| x_of(doc, n)), y: common(doc, sel, |n| y_of(doc, n)), - rot: common(doc, sel, rot_of), + rot: common(doc, sel, |n| rot_of(doc, n)), parent_al: sel.iter().all(|i| doc.node(*i).and_then(parent).is_some_and(|p| p.layout.is_some())), absolute: common(doc, sel, |n| n.child_layout.absolute), // Constraints: children of frames without auto layout, or ignoring it. @@ -655,7 +661,7 @@ fn position_fields(app: &mut FigApp, ui: &mut Ui, doc: &Arc, sel: &[No let col = widgets::col_width(ui.available_width()); align_row(app, ui, sel, pv.can_align, col); position_row(app, ui, doc, sel, &pv, col); - rotation_row(app, ui, sel, pv.rot, col); + rotation_row(app, ui, doc, sel, pv.rot, col); if pv.in_frame { constraints_row(app, ui, sel, pv.constraints, col); } @@ -732,12 +738,12 @@ fn position_row(app: &mut FigApp, ui: &mut Ui, doc: &Document, sel: &[NodeId], p } /// Rotation, with the rotate and flip buttons. -fn rotation_row(app: &mut FigApp, ui: &mut Ui, sel: &[NodeId], rot: Option, col: f32) { +fn rotation_row(app: &mut FigApp, ui: &mut Ui, doc: &Document, sel: &[NodeId], rot: Option, col: f32) { let ids = sel.to_vec(); widgets::sublabels(ui, tr("Rotation"), None); row(ui, 32.0, |ui| { let e = widgets::number_field_mixed(ui, Id::unique("pos_rot"), Lead::Icon(Icon::Angle, tr("Rotation")), rot, "°", col, 1.0); - app.field_of(&ids, "rotation", e, rot_of, |v| json!(v)); + app.field_of(&ids, "absoluteRotation", e, |n| rot_of(doc, n), |v| json!(v)); let items = [ (Icon::Rotate, tr("Rotate 90° right")), (Icon::FlipH, crate::shortcuts::tip(tr("Flip horizontal"), "object.flipH")), diff --git a/crates/ui-egui/src/panels/selection_colors.rs b/crates/ui-egui/src/panels/selection_colors.rs index dbb6f16e4..09c831400 100644 --- a/crates/ui-egui/src/panels/selection_colors.rs +++ b/crates/ui-egui/src/panels/selection_colors.rs @@ -65,7 +65,7 @@ pub(crate) fn toggle(app: &mut FigApp, targets: Vec, response: Opti } } -/// Draw the selection-colour groups (at least two): swatch opens the picker, hex and opacity +/// Draw the selection-colour groups (two, or one when a selected layer has children): swatch opens the picker, hex and opacity /// edits, style/variable detach/apply/bind, a style from this file or an enabled library, Create /// style, and “select layers with this color”; disabled during an interaction. pub fn section(app: &mut FigApp, ui: &mut Ui, doc: &Arc, ids: &[NodeId]) { @@ -73,7 +73,10 @@ pub fn section(app: &mut FigApp, ui: &mut Ui, doc: &Arc, ids: &[NodeId let interacting = ds.interaction.is_some(); let uid = ds.uid; let colors = colors(ui, uid, doc, ids, interacting); - if colors.len() < 2 { + // Measured in Figma: two distinct colours show the section; one colour does too when a selected + // layer has children (frame, group, component, instance). + let has_children = ids.iter().any(|id| doc.node(*id).is_some_and(|n| !n.children.is_empty())); + if colors.len() < 2 && !(colors.len() == 1 && has_children) { ui.data_mut(|d| d.remove::(create_form_id())); return; } diff --git a/crates/ui-egui/src/selection_colors_tests.rs b/crates/ui-egui/src/selection_colors_tests.rs new file mode 100644 index 000000000..2164d3a6e --- /dev/null +++ b/crates/ui-egui/src/selection_colors_tests.rs @@ -0,0 +1,96 @@ +//! When the Design panel shows Selection colors (#2188): measured in Figma's web app, a layer with +//! children shows the section from one distinct colour, while layers without children need two. +//! Driven through egui headless; each row has a "Select layers with this color" button. + +use egui::accesskit::Role; +use figcraft_doc::NodeId; +use figcraft_engine::Session; +use serde_json::{Value, json}; + +use crate::layers_drag_tests::Ui; + +const ROW_BUTTON: &str = "Select layers with this color"; + +fn id(v: Value) -> NodeId { + NodeId(v["id"].as_u64().unwrap()) +} + +fn rect(s: &mut Session, x: i32, color: &str, parent: Option) -> NodeId { + let mut p = json!({"x": x, "y": 0, "width": 40, "height": 40}); + if let Some(parent) = parent { + p["parent"] = json!(parent); + } + let r = id(s.execute("shape.rectangle", &p).unwrap()); + s.execute("fill.set", &json!({"ids": [r], "color": color})).unwrap(); + r +} + +fn frame(s: &mut Session, fill: Option<&str>) -> NodeId { + let f = id(s.execute("frame.create", &json!({"x": 0, "y": 0, "width": 200, "height": 200})).unwrap()); + match fill { + Some(c) => s.execute("fill.set", &json!({"ids": [f], "color": c})).unwrap(), + None => s.execute("fill.remove", &json!({"ids": [f], "index": 0})).unwrap(), + }; + f +} + +/// How many Selection colors rows the Design panel shows with `ids` selected. +fn rows(mut s: Session, ids: &[NodeId]) -> usize { + s.execute("select.set", &json!({"ids": ids})).unwrap(); + let mut u = Ui::new(s); + u.ctx.enable_accesskit(); + u.frame(vec![]); + let out = u.frame_output(vec![]); + let nodes = out.platform_output.accesskit_update.expect("an AccessKit update").nodes; + nodes.iter().filter(|(_, n)| n.role() == Role::Button && n.label() == Some(ROW_BUTTON)).count() +} + +#[test] +fn a_frame_holding_one_red_layer_shows_selection_colors_with_one_row() { + let mut s = Session::new(); + let f = frame(&mut s, None); + rect(&mut s, 10, "#FF0000", Some(f)); + assert_eq!(rows(s, &[f]), 1); +} + +#[test] +fn a_group_of_two_red_layers_shows_one_row() { + let mut s = Session::new(); + let a = rect(&mut s, 0, "#FF0000", None); + let b = rect(&mut s, 60, "#FF0000", None); + s.execute("select.set", &json!({"ids": [a, b]})).unwrap(); + let g = id(s.execute("object.group", &json!({"ids": [a, b]})).unwrap()); + assert_eq!(rows(s, &[g]), 1); +} + +#[test] +fn an_instance_whose_child_has_one_fill_shows_selection_colors() { + let mut s = Session::new(); + let f = frame(&mut s, None); + rect(&mut s, 10, "#FF0000", Some(f)); + let c = id(s.execute("component.create", &json!({"ids": [f]})).unwrap()); + let i = id(s.execute("instance.create", &json!({"component": c, "x": 400, "y": 0})).unwrap()); + assert_eq!(rows(s, &[i]), 1); +} + +#[test] +fn one_layer_or_two_of_the_same_colour_without_children_hide_it() { + let mut s = Session::new(); + let a = rect(&mut s, 0, "#FF0000", None); + assert_eq!(rows(s, &[a]), 0, "one red rectangle"); + let mut s = Session::new(); + let a = rect(&mut s, 0, "#FF0000", None); + let b = rect(&mut s, 60, "#FF0000", None); + assert_eq!(rows(s, &[a, b]), 0, "two red rectangles"); + let mut s = Session::new(); + let g = frame(&mut s, Some("#00FF00")); + assert_eq!(rows(s, &[g]), 0, "a childless green frame"); +} + +#[test] +fn two_loose_layers_of_different_colours_show_two_rows() { + let mut s = Session::new(); + let a = rect(&mut s, 0, "#FF0000", None); + let b = rect(&mut s, 60, "#0000FF", None); + assert_eq!(rows(s, &[a, b]), 2); +} diff --git a/docs/control-protocol.md b/docs/control-protocol.md index 4835bd1e1..b06d79932 100644 --- a/docs/control-protocol.md +++ b/docs/control-protocol.md @@ -67,6 +67,7 @@ state are answered without a frame (about half a second each), while `ui.screens Coordinates are page units, y down. `x`/`y` in `node.set`/`node.create` are relative to the parent frame (groups have no coordinate space of their own). +`rotation` in `node.set` is the layer's angle to its parent; `absoluteRotation` sets its rotation on the page (what the Design panel's field shows); a call takes one of the two. **Windows.** The desktop app can show files in several windows (`window.new`). Every method takes an optional `window` (an id from `window.list`; `0` is the main window) and then runs in that diff --git a/docs/mcp.md b/docs/mcp.md index d722e7cfa..a6c04af07 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -172,6 +172,7 @@ Or in a project's `.mcp.json`: - `create_node` and `set_properties` take `x`/`y` **relative to the parent frame** (the page when there is none, so they are page coordinates then). Groups and boolean groups have no coordinate space of their own: a layer in a group is placed in the frame (or on the page) the group is in. + `rotation` is the layer's angle to its parent (Figma's plugin API `rotation` is the same); `absoluteRotation` sets its rotation on the page, what the Design panel's field shows; a call takes one of the two. `inspect_document` reports `x`/`y` the same way, plus `absoluteBounds` in page coordinates. In `props`, `fill` and `stroke` also accept `"none"` (either case) or `null` as no paint, the same as an empty `fills`/`strokes` list, so an outline-only shape can be made in one call. diff --git a/docs/ui-parity.md b/docs/ui-parity.md index a9883b4d3..1911dbbcd 100644 --- a/docs/ui-parity.md +++ b/docs/ui-parity.md @@ -1,6 +1,6 @@ # UI and interaction parity -> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-10 · **Change:** minor (the crosshair of the shape and Text tools is drawn dark with a white edge, so it shows on a white frame whatever the system's pointer style (#2198); a boolean group takes a corner radius (and smoothing) that rounds every sharp corner of its result (#2222); the Point section's X and Y in vector edit mode show Mixed and set every selected point of the layer being edited, as in Figma; Preferences ▸ Invert zoom direction reverses wheel zoom, pinch unchanged (#2145); Shift while rotating lands on absolute multiples of 15°, measured in Figma; Flatten bakes a vector's point corner radius into its path (#2195); a click on a fill, stroke or effect row's grip or background highlights it, Cmd/Ctrl+C copies that paint or effect and Cmd/Ctrl+V pastes it onto the selected layers, as the help center's Copy and paste properties between layers says (#1494); wrap style per paragraph and in text styles (#1827); the Annotation tool (Shift+T, `tool.annotation {id?}`): with a layer selected (or an `id`) it asks the UI for that layer's note at once, and in the tool a press on a layer selects it and asks for its note, a press on empty canvas does nothing; the marquee follows Figma's measured rules: a partly covered frame or section gives the layers in it the marquee touches, a rotated shape is touched by its outline, a drag from inside a frame selects that frame only when the marquee also takes another top-level frame (then whole) (`marquee_behaviour_tests`); copy, cut and paste in vector edit mode act on the selected points and segments (#1875); M8, #2146: K focuses the Scale tool's factor field with its text selected, so K, 2, Enter scales the selection by two about the panel's origin (FigCraft's starts at the top left; Figma's grid starts at the centre, left for a follow-up because the origin also sets where a handle drag pivots, which is not measured) in one undo step, after which the tool returns to Move with the selection kept; Escape in the field closes it with the tool back on Move and nothing changed (measured in Figma's web app, 2026-11-09; `pressing_k_focuses_the_scale_field_with_its_text_selected`, `k_two_enter_scales_the_selection_by_two`, `escape_in_the_scale_field_closes_it_and_changes_nothing`); the main menu and its submenus stay inside the window, moving up to fit and scrolling when taller (#2217); locked layers ignore the arrow keys and a locked parent's children can't be locked on their own (#1560); the left rail's and tab strip's icons are larger, 20 pt (#553); pick select: Tab while the keyboard selection box shows (or the chord again) puts a pink outline on a layer and the keys walk the layer tree from it, as Accessibility at Figma says (#1836); scrubbing a field faster or slower by the pointer's height, with a notice of the speed, as the help center's Scrub fields says (#1837); component rows in the Layers panel at AA contrast in the theme's component tint, with the rows inside a selected component in a tone of its row (#1903); Cmd/Ctrl-click on a padding field sets all four sides with the value typed, a documented auto layout shortcut; a fill per region of a vector: with regions selected in edit mode, the Fill section and the fill commands edit those regions' own fills, as Edit vector layers says (#1875); the Fill section of a text whose characters were coloured differently while editing shows mixed content, characters that all share fills the layer doesn't have show those, and a layer-level fill edit reaches every character (#1856); a number field scrubs when dragged with Alt held, as the help center's scrub section says, not only by its label; reuse visible layer selection roots (M8); ; with a shape or frame tool chosen and nothing selected, the arrows show a placement crosshair in the middle of the view and move it, and Enter places there, as Accessibility at Figma says (#1839); text direction per paragraph: Text ▸ Text direction forces a paragraph left to right or right to left, as Add right-to-left text says (#1830), with `text.direction`, `node.set textDirection`, the Type settings control once a right-to-left script is in the text, inspect, the CSS `direction` and the `.fig` lines' `sourceDirectionality`; the boolean operation menu in the Design panel leads each entry with an original icon drawn in code, a filled preview of the result (#2003); a press on the open gradient's handles or stops on the canvas keeps the colour picker open through the drag, as its own control (#1852); a click with the Bend tool on a sharp point curves it, its handles along the line between its neighbours, as Edit vector layers says (#1875); wrap style: Auto, Balance and Pretty on a text layer decide where its lines break, as Explore text properties says (#1827), with the Type settings control, `text.wrapStyle`, `node.set wrapStyle`, inspect and the CSS `text-wrap`; Backspace or Delete at the start of a list item keeps the item's indentation level, as the lists article says; max lines on auto-width text keep it auto width, hugging that many lines, as the text properties article says; superscript and subscript are synthesised where the font has no glyphs for them, from the standard glyphs shrunk and shifted by the font's OS/2 metrics, and a run mixing available and unavailable glyphs is synthesised whole, as Explore text properties says (#1828); Alt+Enter while editing text opens the link at the caret, as the accessibility page documents; Minimize, by its shortcut or the button by the file name, collapses the navigation bar and both sidebars as the help center says, with the right sidebar back while something is selected (#1835); the interface size keys of the help center's accessibility page: Cmd/Ctrl+Shift+Alt with =, - and 0 step the interface through the Preferences sizes and back to the system's size; Cmd/Ctrl+Alt+arrows rotate the selection a degree at a time, 15 with Shift, as the help center's accessibility page says; they resized before; the Layers panel answers Ctrl+1 as well as Alt+1 on Windows and Linux, the two keys the help center gives it; the colour picker's Image tab shows a placeholder and Upload from computer, an asset preview, and a file dropped on it replaces the image, keeping the fill mode, crop and position (#1682); the keyboard's Menu key opens the context menu, as Shift+F10 does; the eyedropper with Cmd/Ctrl+Shift makes a colour style or variable of what it picks; sidebar number and text fields keep their text vertically centered when focused, including typography spacing; with the pen out, Enter or a double-click ends the path and edits the vector with the Move tool instead of drawing on (#1430); the Actions palette offers only commands that run from it, and no second row reading like a menu item: Place image opens the file dialog (#1574); Preferences ▸ Scroll wheel zoom: a mouse wheel zooms the canvas about the pointer and Cmd/Ctrl+wheel scrolls (#1390); boolean operations refuse input past their caps, and a boolean group past them draws without its result (#1104); the selection and hover outlines of rounded rectangles and frames follow their corners (#1506); colour picker review fixes for text undo, fitted sidebars, moving controls and gradient variables; Corner smoothing: an original icon and the shared number-field drag gesture, preserving fractional baselines; guides snap to layers when dragged; Crop image: Object ▸ Crop image, the right-click menu and the image fill row enter crop mode (`image.crop`, #1464); the Design panel's sections on one grid — 16 / 8 margins, 88 + 8 + 88 + 8 + 24 columns, 24 pt rows, 4 pt between a row's buttons (#858); the toolbar on one 32 pt grid, without its Resources button (#1210); colour picker LCH and OKLCH models; an XML (Android Vector Drawable) export format; Context menus: the Menu key reaches egui 0.37 but is unbound (row done → partial); the Text on a path tool; board tool keys pinned; community fixes: the text box by dragging, the font picker keys, the pen path on leaving Design, a still canvas in vector edit mode, a scrolling pages list, colour emoji, readable new text in frames, system theme on first run; the Small caps sample in Type settings drawn from capitals; recent files as cards; vector edit mode: hovering, hatching, selecting and dragging filled regions; home screen: Templates tab, first-run templates and Getting started tips; number fields: scrub rates, arrow steps, arithmetic with brackets, relative edits of mixed values; outline mode's hidden layers and object bounds; Hide when publishing; cursors per tool and modifier; panel widths; dark pages for files made in the dark theme; drag threshold and double-clicks into text in groups; rotation origin on Alt+R and placing with Enter: no documented shortcut missing; keyboard shortcut parity suite and bindings; cursor chat and spotlight in live sessions; layers and assets panels behaviour suite and fixes; vector multi-edit and the vector edit tail; canvas navigation, guides and grids behaviour suite and fixes; shapes and vector behaviour suite and fixes; paint and effects behaviour suite and fixes; frames, groups, sections and masks behaviour suite and fixes; layers panel keyboard: F2 rename, Shift+F10 context menu, F8 box selection; selection and transform behaviour suite and fixes; Display P3: gamut warning and soft-proof (true P3 blocked upstream); several windows; boolean hit testing on the result, group drags, frame outlines and slices; outlines for the selection, mask outlines; arc fields, live boolean editing, shape builder on strokes, one-sided widths; fields select their text on focus; Typography spacing icons support scrubbing (#373); CSS colour names in hex fields; a rename selects the whole name, so typing replaces it; Escape or Enter after a pen path stays on the same vector (#760); IME composition kept on through idle frames of a text edit, candidates at the caret (#747); Selection colors for mixed selections and smart-selection spacing (#753); submenus with a hover delay and a safe triangle; the Actions palette's tabs, ranked search, highlight and recents; menu items that ask for a value; editor fixes from the community batches) · **Target:** Figma Design UI3 (desktop app 126.10.7) +> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-10 · **Change:** minor (the text caret takes the text's solid fill colour (#2156); the Rotation field shows and sets the rotation on the page, in frames and groups, through node.set absoluteRotation (#2196); the eyedropper picks a magnified image's pixel under the pointer, not a blend with its neighbours (#2189); Selection colors shows from one distinct colour when a selected layer has children, and from two otherwise, measured in Figma's web app on 2026-11-09 on a frame, a group and plain rectangles; the crosshair of the shape and Text tools is drawn dark with a white edge, so it shows on a white frame whatever the system's pointer style (#2198); a boolean group takes a corner radius (and smoothing) that rounds every sharp corner of its result (#2222); the Point section's X and Y in vector edit mode show Mixed and set every selected point of the layer being edited, as in Figma; Preferences ▸ Invert zoom direction reverses wheel zoom, pinch unchanged (#2145); Shift while rotating lands on absolute multiples of 15°, measured in Figma; Flatten bakes a vector's point corner radius into its path (#2195); a click on a fill, stroke or effect row's grip or background highlights it, Cmd/Ctrl+C copies that paint or effect and Cmd/Ctrl+V pastes it onto the selected layers, as the help center's Copy and paste properties between layers says (#1494); wrap style per paragraph and in text styles (#1827); the Annotation tool (Shift+T, `tool.annotation {id?}`): with a layer selected (or an `id`) it asks the UI for that layer's note at once, and in the tool a press on a layer selects it and asks for its note, a press on empty canvas does nothing; the marquee follows Figma's measured rules: a partly covered frame or section gives the layers in it the marquee touches, a rotated shape is touched by its outline, a drag from inside a frame selects that frame only when the marquee also takes another top-level frame (then whole) (`marquee_behaviour_tests`); copy, cut and paste in vector edit mode act on the selected points and segments (#1875); M8, #2146: K focuses the Scale tool's factor field with its text selected, so K, 2, Enter scales the selection by two about the panel's origin (FigCraft's starts at the top left; Figma's grid starts at the centre, left for a follow-up because the origin also sets where a handle drag pivots, which is not measured) in one undo step, after which the tool returns to Move with the selection kept; Escape in the field closes it with the tool back on Move and nothing changed (measured in Figma's web app, 2026-11-09; `pressing_k_focuses_the_scale_field_with_its_text_selected`, `k_two_enter_scales_the_selection_by_two`, `escape_in_the_scale_field_closes_it_and_changes_nothing`); the main menu and its submenus stay inside the window, moving up to fit and scrolling when taller (#2217); locked layers ignore the arrow keys and a locked parent's children can't be locked on their own (#1560); the left rail's and tab strip's icons are larger, 20 pt (#553); pick select: Tab while the keyboard selection box shows (or the chord again) puts a pink outline on a layer and the keys walk the layer tree from it, as Accessibility at Figma says (#1836); scrubbing a field faster or slower by the pointer's height, with a notice of the speed, as the help center's Scrub fields says (#1837); component rows in the Layers panel at AA contrast in the theme's component tint, with the rows inside a selected component in a tone of its row (#1903); Cmd/Ctrl-click on a padding field sets all four sides with the value typed, a documented auto layout shortcut; a fill per region of a vector: with regions selected in edit mode, the Fill section and the fill commands edit those regions' own fills, as Edit vector layers says (#1875); the Fill section of a text whose characters were coloured differently while editing shows mixed content, characters that all share fills the layer doesn't have show those, and a layer-level fill edit reaches every character (#1856); a number field scrubs when dragged with Alt held, as the help center's scrub section says, not only by its label; reuse visible layer selection roots (M8); ; with a shape or frame tool chosen and nothing selected, the arrows show a placement crosshair in the middle of the view and move it, and Enter places there, as Accessibility at Figma says (#1839); text direction per paragraph: Text ▸ Text direction forces a paragraph left to right or right to left, as Add right-to-left text says (#1830), with `text.direction`, `node.set textDirection`, the Type settings control once a right-to-left script is in the text, inspect, the CSS `direction` and the `.fig` lines' `sourceDirectionality`; the boolean operation menu in the Design panel leads each entry with an original icon drawn in code, a filled preview of the result (#2003); a press on the open gradient's handles or stops on the canvas keeps the colour picker open through the drag, as its own control (#1852); a click with the Bend tool on a sharp point curves it, its handles along the line between its neighbours, as Edit vector layers says (#1875); wrap style: Auto, Balance and Pretty on a text layer decide where its lines break, as Explore text properties says (#1827), with the Type settings control, `text.wrapStyle`, `node.set wrapStyle`, inspect and the CSS `text-wrap`; Backspace or Delete at the start of a list item keeps the item's indentation level, as the lists article says; max lines on auto-width text keep it auto width, hugging that many lines, as the text properties article says; superscript and subscript are synthesised where the font has no glyphs for them, from the standard glyphs shrunk and shifted by the font's OS/2 metrics, and a run mixing available and unavailable glyphs is synthesised whole, as Explore text properties says (#1828); Alt+Enter while editing text opens the link at the caret, as the accessibility page documents; Minimize, by its shortcut or the button by the file name, collapses the navigation bar and both sidebars as the help center says, with the right sidebar back while something is selected (#1835); the interface size keys of the help center's accessibility page: Cmd/Ctrl+Shift+Alt with =, - and 0 step the interface through the Preferences sizes and back to the system's size; Cmd/Ctrl+Alt+arrows rotate the selection a degree at a time, 15 with Shift, as the help center's accessibility page says; they resized before; the Layers panel answers Ctrl+1 as well as Alt+1 on Windows and Linux, the two keys the help center gives it; the colour picker's Image tab shows a placeholder and Upload from computer, an asset preview, and a file dropped on it replaces the image, keeping the fill mode, crop and position (#1682); the keyboard's Menu key opens the context menu, as Shift+F10 does; the eyedropper with Cmd/Ctrl+Shift makes a colour style or variable of what it picks; sidebar number and text fields keep their text vertically centered when focused, including typography spacing; with the pen out, Enter or a double-click ends the path and edits the vector with the Move tool instead of drawing on (#1430); the Actions palette offers only commands that run from it, and no second row reading like a menu item: Place image opens the file dialog (#1574); Preferences ▸ Scroll wheel zoom: a mouse wheel zooms the canvas about the pointer and Cmd/Ctrl+wheel scrolls (#1390); boolean operations refuse input past their caps, and a boolean group past them draws without its result (#1104); the selection and hover outlines of rounded rectangles and frames follow their corners (#1506); colour picker review fixes for text undo, fitted sidebars, moving controls and gradient variables; Corner smoothing: an original icon and the shared number-field drag gesture, preserving fractional baselines; guides snap to layers when dragged; Crop image: Object ▸ Crop image, the right-click menu and the image fill row enter crop mode (`image.crop`, #1464); the Design panel's sections on one grid — 16 / 8 margins, 88 + 8 + 88 + 8 + 24 columns, 24 pt rows, 4 pt between a row's buttons (#858); the toolbar on one 32 pt grid, without its Resources button (#1210); colour picker LCH and OKLCH models; an XML (Android Vector Drawable) export format; Context menus: the Menu key reaches egui 0.37 but is unbound (row done → partial); the Text on a path tool; board tool keys pinned; community fixes: the text box by dragging, the font picker keys, the pen path on leaving Design, a still canvas in vector edit mode, a scrolling pages list, colour emoji, readable new text in frames, system theme on first run; the Small caps sample in Type settings drawn from capitals; recent files as cards; vector edit mode: hovering, hatching, selecting and dragging filled regions; home screen: Templates tab, first-run templates and Getting started tips; number fields: scrub rates, arrow steps, arithmetic with brackets, relative edits of mixed values; outline mode's hidden layers and object bounds; Hide when publishing; cursors per tool and modifier; panel widths; dark pages for files made in the dark theme; drag threshold and double-clicks into text in groups; rotation origin on Alt+R and placing with Enter: no documented shortcut missing; keyboard shortcut parity suite and bindings; cursor chat and spotlight in live sessions; layers and assets panels behaviour suite and fixes; vector multi-edit and the vector edit tail; canvas navigation, guides and grids behaviour suite and fixes; shapes and vector behaviour suite and fixes; paint and effects behaviour suite and fixes; frames, groups, sections and masks behaviour suite and fixes; layers panel keyboard: F2 rename, Shift+F10 context menu, F8 box selection; selection and transform behaviour suite and fixes; Display P3: gamut warning and soft-proof (true P3 blocked upstream); several windows; boolean hit testing on the result, group drags, frame outlines and slices; outlines for the selection, mask outlines; arc fields, live boolean editing, shape builder on strokes, one-sided widths; fields select their text on focus; Typography spacing icons support scrubbing (#373); CSS colour names in hex fields; a rename selects the whole name, so typing replaces it; Escape or Enter after a pen path stays on the same vector (#760); IME composition kept on through idle frames of a text edit, candidates at the caret (#747); Selection colors for mixed selections and smart-selection spacing (#753); submenus with a hover delay and a safe triangle; the Actions palette's tabs, ranked search, highlight and recents; menu items that ask for a value; editor fixes from the community batches) · **Target:** Figma Design UI3 (desktop app 126.10.7) Fine canvas control is what Figma users feel first: handles, snapping, nudging, modifier keys, drag behaviour, numeric precision. This checklist covers the tools, gestures and panels. Status: @@ -65,6 +65,7 @@ interaction feel not yet compared. | Escape with layers selected | done | clears the selection at once, whatever the nesting; it never selects the parent. Measured in the Figma web app (2026-11-08) with a rectangle in a group in a frame, selected from the canvas (a double-click into the group), from the Layers panel, and after Tab moved the selection to its sibling: one Escape selects nothing, a second leaves nothing selected. Escape still leaves text and vector editing, ends gestures and the pen first, and ends the focus view once nothing or the focused frame is selected (`selection_behaviour_tests`, `devfocus_tests`) | | Enter / Shift+Enter (children / parent), Tab / Shift+Tab (siblings) | done | Tab renames the next layer while renaming | | Resize handles: Shift keeps proportions, Alt from centre, constraints-aware | done | Alt shrinks too; past an edge flips (several layers mirror); groups and mixed rotations scale each layer along its own axes, keeping rotation and flip (no skew: children turned off a right angle are approximate); Cmd/Ctrl ignores a frame's constraints (`transform_behaviour_tests`) | +| Rotate just outside a corner; Shift in 15° steps | done | rotated handle box when layers share a rotation; the Rotation field shows and sets the rotation on the page (its own angle plus its parents'), in frames and groups alike, measured in Figma's web app 2026-11-10 (#2196): a rectangle drawn inside a turned frame reads 0, typing 7 makes it 7 on the page; the panel sends `node.set absoluteRotation`, while `rotation` stays the angle to the parent for scripts, inspect, codegen and the formats. Pinned, not measured: several layers read one value when their page angles agree (typing sets them all, one undo step); a flipped layer reads in the same form as before (a horizontal flip reads 180 plus the angle) and typing keeps the flip; a flipped parent is handled by the world math. Tests: `absolute_rotation_sets_the_rotation_on_the_page_keeping_the_centre`, `the_absolute_rotation_key_turns_about_a_moved_origin_too`, `the_rotation_field_shows_and_sets_the_rotation_on_the_page` | | Rotate just outside a corner; Shift in 15° steps | done | rotated handle box when layers share a rotation; Shift lands the rotation on multiples of 15° (measured in Figma: a layer at 7° or -4.27° ends at 15°), not 15° steps from where the drag began; layers with different rotations step the turn from 0 | | Flip, rotate 90° | done | | | Rotation origin (Alt+R) | done | a handle at the selection's centre to drag (snaps to the box's corners, edge middles and centre), double-click puts it back, Escape or Alt+R hides it; the corner handles, the rotation field, Rotate 90°/180° and `transform.rotate` turn about it; it follows the layers and lasts as long as the selection, not saved (the documentation doesn't say; pinned) | @@ -82,9 +83,9 @@ interaction feel not yet compared. | Locked layers | done | selectable from the layers panel; no handles, not dragged with the rest of a selection | | Edit ▸ Set default properties: new layers take the selected layer's properties | done | from a shape (any layer but text): new rectangles, ellipses, polygons and stars drawn or clicked with their tools take its fills, strokes and their settings, effects, opacity, blend and corners; from a text layer: new text from the Text tool takes its fills and font (#2028). Silent in the help center on frames, lines and arrows: they keep their own look, as do layers made by commands; the defaults last for the session | | Smart selection spacing | partial | with layers in a row, a column or an aligned grid selected, the Layout section shows horizontal and vertical spacing ("Mixed" until set; typed, scrubbed, fractional and negative) and pink handles in the gaps on the canvas drag them, one undo step, Escape cancels (`arrange.spacing`; sizes, parents and offsets within each track kept; at most 2,000 layers; flow children, locked layers and layers inside instances left out). A ring at each layer's centre drags it to another place in a regular row, column or complete top-left-aligned grid: the others close up and make room around it with the gaps kept, and with Cmd/Ctrl held the two layers swap places instead, previewed live while dragging (`selection_reorder_tests`; no ring on a layer under 16 px on screen). Not covered: reordering irregular grids, and several marked layers moved together. Checked by its author on macOS and in the app on Windows (#402) | -| Selection colors | partial | for a mixed selection the Design panel lists their solid and gradient paints (children and text ranges included; hidden paints, masks, images, patterns and boolean operands left out; styles and variables listed apart): editing a colour changes every matching fill and stroke in one undo step, a row selects the layers that use it or applies a color style or color variable of the document, and a row linked to a style or variable detaches it, keeping the color (`selection.colors`, `selection.setPaint`, `selection.applyColorStyle`, `selection.bindColorVariable`, `selection.detachColor`, `selection.selectColor`). No library styles or variables from there, and no new style or variable from a row (#403) | +| Selection colors | partial | the Design panel shows the section from two paint groups (paints sharing a style, a variable and a value count as one group), or from one when a selected layer has children (a frame, group, component or instance), and lists their solid and gradient paints (children and text ranges included; hidden paints, masks, images, patterns and boolean operands left out; styles and variables listed apart): editing a colour changes every matching fill and stroke in one undo step, a row selects the layers that use it or applies a color style or color variable of the document, and a row linked to a style or variable detaches it, keeping the color (`selection.colors`, `selection.setPaint`, `selection.applyColorStyle`, `selection.bindColorVariable`, `selection.detachColor`, `selection.selectColor`). A row's Styles menu also offers enabled libraries' published color styles and Create style (`selection.createColorStyle`); no library variables and no new variable from a row (#403) | | Keyboard box selection | done | Alt+Space on macOS, Ctrl+Space on Windows and Linux, or F8 (`select.area`): a box around the selection or in the middle of the view; arrows move it, Cmd/Ctrl+arrows or Shift+arrows size it (Shift with Cmd/Ctrl: farther), Enter selects like a marquee (Shift+Enter toggles, Cmd/Ctrl+Enter nested), Escape closes; Tab while the box shows, or the chord again, switches to pick select: a pink outline on the first selected layer (the page's top layer with nothing selected), Tab and Shift+Tab move it between sibling layers in Layers order, Enter into a frame's top child, Shift+Enter out to the parent, Space selects it, Escape or a press on the canvas ends it; `ui.key` takes the same keys (#1836) | -| Selection colors | partial | for a mixed selection the Design panel lists their solid and gradient paints (children and text ranges included; hidden paints, masks, images, patterns and boolean operands left out; styles and variables listed apart): editing a colour changes every matching fill and stroke in one undo step, a row selects the layers that use it or applies a color style or color variable of the document, and a row linked to a style or variable detaches it, keeping the color (`selection.colors`, `selection.setPaint`, `selection.applyColorStyle`, `selection.bindColorVariable`, `selection.detachColor`, `selection.selectColor`). A row's Styles menu also lists each enabled library's published color styles under the library's name (a library that can't be read offers none), and a linked row's menu switches it to another style; a library style is copied in, linked and read-only, in the same undo step (`selection.applyColorStyle` with `library`). Create style on an ordinary row asks for a name (the next free "Color n" first) and makes a style of the row's whole paint, gradients, opacity, blend mode and variables bound to gradient stops included, linked to every fill and stroke the row stands for in one undo step; a name in use keeps the window open (`selection.createColorStyle`). Text ranges with fills of their own take the style's value, without a link. No library variables from there, and no new variable from a row (#403) | +| Selection colors | partial | the Design panel shows the section from two paint groups (paints sharing a style, a variable and a value count as one group), or from one when a selected layer has children (a frame, group, component or instance; a layer without children shows it only with two paint groups, such as a red fill and a blue stroke; one paint group, however many layers share it, hides it), counting the selected layers' own fills and strokes and their descendants' (measured in Figma's web app, 2026-11-09, #2188, on frames, groups and rectangles only; the rule for components and instances is not measured), and lists their solid and gradient paints (children and text ranges included; hidden paints, masks, images, patterns and boolean operands left out; styles and variables listed apart): editing a colour changes every matching fill and stroke in one undo step, a row selects the layers that use it or applies a color style or color variable of the document, and a row linked to a style or variable detaches it, keeping the color (`selection.colors`, `selection.setPaint`, `selection.applyColorStyle`, `selection.bindColorVariable`, `selection.detachColor`, `selection.selectColor`). A row's Styles menu also lists each enabled library's published color styles under the library's name (a library that can't be read offers none), and a linked row's menu switches it to another style; a library style is copied in, linked and read-only, in the same undo step (`selection.applyColorStyle` with `library`). Create style on an ordinary row asks for a name (the next free "Color n" first) and makes a style of the row's whole paint, gradients, opacity, blend mode and variables bound to gradient stops included, linked to every fill and stroke the row stands for in one undo step; a name in use keeps the window open (`selection.createColorStyle`). Text ranges with fills of their own take the style's value, without a link. No library variables from there, and no new variable from a row (#403) | | Keyboard box selection | done | Alt+Space on macOS, Ctrl+Space on Windows and Linux, or F8 (`select.area`): a box around the selection or in the middle of the view; arrows move it, Cmd/Ctrl+arrows or Shift+arrows size it (Shift with Cmd/Ctrl: farther), Enter selects like a marquee (Shift+Enter toggles, Cmd/Ctrl+Enter nested), Escape closes | ## Tools @@ -100,12 +101,15 @@ interaction feel not yet compared. | Vector edit mode: bend, paint bucket, lasso, cut, eraser, transform box, point snapping, mirroring | done | a double-click a few pixels off a thin stroke enters edit mode (#646); entering edit mode and picking a region keep the canvas still (#322); a point dropped on another point merges with it, and dropping one end of an open path on the other closes it (a 2-point line's end just moves, #401); Flatten keeps open paths open (#377), and bakes a vector's point corner radius into its path (each rounded point becomes the arc's end points joined by curves, the layer stays a vector and its box fits the real geometry, #2195); paint bucket drags across areas; cut drags divide a shape into layers; delete and heal follows the curve; rounded points are drawn; Shift-click deselects a point at a corner of the box (`vector_behaviour_tests`); several vectors edited at once, Shift-click handles to drag them together, a cap and join per point, rounded points beside curves (`vector_multi_behaviour_tests`); filled regions with the Move tool: the area under the pointer is hatched ("/" lines in the selection colour, clipped by the area's own fill rule, holes left out, gone 3.5 px from a point or 2 px from a segment at any zoom), the line spacing follows octave folding (fitted to measurements at several zoom levels: 8 px at every power-of-two zoom, growing with the zoom and stepping back at √2 · 2ⁿ) and stays fixed to the shape when panning; a click selects the area and its points (moved with it but drawn unselected), Shift adds or removes an area, a press on a selected area drags the whole selection, no hover hatch during drags, a click on an empty spot (a hole) clears it and stays in edit mode; `vector.edit.select {regions}` (`regions_tests`, `vector_regions_tests`); a Bend click on a sharp point between two segments curves it (handles along the line between its neighbours, a third of the way to each, `ops::auto_smooth`), on a curved one sharpens it, a drag sets the handles by hand (#1875); with regions selected, the Fill section (its rows and the colour picker) and `fill.set`, `fill.add`, `fill.remove`, `fill.move` and `fill.paste` edit those regions' own fills, the layer's untouched, or the regions named by `regions: [index, ...]`; Copy fill takes the region's paint, the colour picker and its canvas gradient and crop handles edit it (an image from Upload from computer included; a file dropped on the picker goes to the canvas instead), what belongs to the layer (its fill style, a variable bound to its fill, the image crop button) stays off a region's rows, and `fill.pattern` sets the layer's fill (#1875). Not yet: areas of other layers edited at once | | Vector edit mode: bend, paint bucket, lasso, cut, eraser, transform box, point snapping, mirroring | done | a double-click a few pixels off a thin stroke enters edit mode (#646); entering edit mode and picking a region keep the canvas still (#322); a point dropped on another point merges with it, and dropping one end of an open path on the other closes it (a 2-point line's end just moves, #401); Flatten keeps open paths open (#377); paint bucket drags across areas; cut drags divide a shape into layers; delete and heal follows the curve; rounded points are drawn; Shift-click deselects a point at a corner of the box (`vector_behaviour_tests`); several vectors edited at once, Shift-click handles to drag them together, a cap and join per point, rounded points beside curves (`vector_multi_behaviour_tests`); filled regions with the Move tool: the area under the pointer is hatched ("/" lines in the selection colour, clipped by the area's own fill rule, holes left out, gone 3.5 px from a point or 2 px from a segment at any zoom), the line spacing follows octave folding (fitted to measurements at several zoom levels: 8 px at every power-of-two zoom, growing with the zoom and stepping back at √2 · 2ⁿ) and stays fixed to the shape when panning; a click selects the area and its points (moved with it but drawn unselected), Shift adds or removes an area, a press on a selected area drags the whole selection, no hover hatch during drags, a click on an empty spot (a hole) clears it and stays in edit mode; `vector.edit.select {regions}` (`regions_tests`, `vector_regions_tests`); a Bend click on a sharp point between two segments curves it (handles along the line between its neighbours, a third of the way to each, `ops::auto_smooth`), on a curved one sharpens it, a drag sets the handles by hand (#1875); with regions selected, the Fill section (its rows and the colour picker) and `fill.set`, `fill.add`, `fill.remove`, `fill.move` and `fill.paste` edit those regions' own fills, the layer's untouched, or the regions named by `regions: [index, ...]`; Copy fill takes the region's paint, the colour picker and its canvas gradient and crop handles edit it (an image from Upload from computer included; a file dropped on the picker goes to the canvas instead), what belongs to the layer (its fill style, a variable bound to its fill, the image crop button) stays off a region's rows, and `fill.pattern` sets the layer's fill (#1875); Copy and Cut with points or segments selected take just those (a lone point: the segments touching it) as a vector with the layer's look, at their own place, so a paste outside edit mode is a new layer in place; Cut removes them as Delete does, the path splitting in the same layer with edit mode staying on; Paste while editing adds the clipboard's segments, or a copied shape's or boolean's outline, to the edited network in place with the new points selected, skipping layers with no outline (text, frames, groups; named in `skipped`) and refusing when none has one, as measured in Figma (`vector_clipboard_tests`, #1875). Not yet: areas of other layers edited at once | | Shape builder (Shift+M) on fills, strokes and open paths; variable width (Shift+W), one side with Alt | done | | +| Boolean groups: clicked where the result is, double-click or Cmd/Ctrl-click into operands, live results while dragging or editing points, per-operand operations | done | a group past the path operations' caps (250 000 segments, 2 million possible crossings, 4 million segments swept over a fold) draws without its result, with a warning, and Flatten refuses it (#1104); the Design panel's Boolean groups menu leads Union, Subtract, Intersect and Exclude with their own icons, two offset squares with the result filled at reduced alpha (#2003) | +| Text: point, auto height, fixed; caret, words, lines, IME | done | Backspace or Delete at the start of a list item takes its marker and keeps its level, the paragraph starting where the item's text did ("delete the counter, but keep the same level of indentation", Create bulleted and numbered lists; `text_tail_tests::list_keys_at_list_items`, text crate `behaviour_tests`); max lines on auto-width text keep it auto width, hugging up to that many lines and growing with its longest line ("Text resizing is set to auto height or auto width", Explore text properties; `text_behaviour_tests::max_lines_on_auto_width_text_keeps_auto_width_and_hugs_that_many_lines`); Alt+Enter while editing opens the link at the caret, web and mail links only (`text.openLink`; "press ⌥Option Return/Alt Enter to activate a focused link", Accessibility at Figma; `text_link_tests`); the font picker previews a family on the canvas while hovered (no undo step; Escape restores, #653) and Up/Down step through it (#352); a selection highlight after a line break starts at that line's start and an empty last line shows its mark (#665); carets step over whole emoji and accented letters; colour emoji draw from their colour tables (#300); IME composition replayed in tests as macOS sends it, not yet checked on a Mac (#747); CJK words by script run (no dictionary); vertical trim in Type settings; the caret takes the text's solid fill colour, measured in Figma's web app, 2026-11-09; gradient and image fills (not measured) give a black caret on a light surface and a white one on a dark one (the nearest layer around the text whose top visible fill is a solid at least half opaque as drawn, counting layer opacity, else the page; a layer whose top fill is a gradient or an image is passed over), not the interface's text colour, which is white in the dark theme and vanished on the default light page (#2190) (#2156; `caret_tests`); no spell check | +| Text: wrap style (Auto, Balance, Pretty) | done | per text layer (`wrapStyle` on `node.set`, `text.wrapStyle`, the Type settings control under Vertical trim, inspect, CSS `text-wrap: balance` or `pretty`): Auto breaks greedily; Balance narrows each paragraph as far as it goes without another line, so its lines come out close to the same length (what browsers do for `text-wrap: balance`); Pretty keeps lines full and, when the last line is one word, narrows one of the last four lines just enough to give a word to the lines after it (Explore text properties: "Auto: Figma fits as many words as possible on each line before wrapping to the next", "Balance: Figma distributes text as evenly as possible across every line, so each line is close to the same length", "Pretty: Figma keeps each line full, but adjusts the last four lines to avoid an orphan"). Saved line breaks from a file still win. Not yet included: per-paragraph settings, text-style support and the `.fig` import/export mapping (#1827). Test: `text_behaviour_tests::balance_and_pretty_wrap_styles_break_lines_as_documented` | | Boolean groups: clicked where the result is, double-click or Cmd/Ctrl-click into operands, live results while dragging or editing points, per-operand operations | done | a group past the path operations' caps (250 000 segments, 2 million possible crossings, 4 million segments swept over a fold) draws without its result, with a warning, and Flatten refuses it (#1104); the Design panel's Boolean groups menu leads Union, Subtract, Intersect and Exclude with their own icons, two offset squares with the result filled at reduced alpha (#2003); a boolean group takes a corner radius from the Design panel and from `node.set cornerRadius`: every sharp corner of its result rounds, convex and concave, layers inside keep their own radius and do not stack with it, a radius larger than the edges allow shrinks to fit while the field keeps the value typed, Flatten bakes the arcs and a mixed selection reads Mixed; measured in Figma's web app on 2026-11-10 (#2222; `crates/pathops/src/round_tests.rs`, `crates/render/src/boolean_radius_tests.rs`, `crates/engine/src/boolean_radius_tests.rs`, the boolean group test in `crates/ui-egui/src/field_tests.rs`). Pinned and not yet compared with Figma: corner smoothing on a boolean group draws the polygon profile between straight edges, a corner beside a curve stays within the curve piece next to it, and there is no radius handle on the canvas | | Text: point, auto height, fixed; caret, words, lines, IME | done | Backspace or Delete at the start of a list item takes its marker and keeps its level, the paragraph starting where the item's text did ("delete the counter, but keep the same level of indentation", Create bulleted and numbered lists; `text_tail_tests::list_keys_at_list_items`, text crate `behaviour_tests`); max lines on auto-width text keep it auto width, hugging up to that many lines and growing with its longest line ("Text resizing is set to auto height or auto width", Explore text properties; `text_behaviour_tests::max_lines_on_auto_width_text_keeps_auto_width_and_hugs_that_many_lines`); Alt+Enter while editing opens the link at the caret, web and mail links only (`text.openLink`; "press ⌥Option Return/Alt Enter to activate a focused link", Accessibility at Figma; `text_link_tests`); the font picker previews a family on the canvas while hovered (no undo step; Escape restores, #653) and Up/Down step through it (#352); a selection highlight after a line break starts at that line's start and an empty last line shows its mark (#665); carets step over whole emoji and accented letters; colour emoji draw from their colour tables (#300); IME composition replayed in tests as macOS sends it, not yet checked on a Mac (#747); CJK words by script run (no dictionary); vertical trim in Type settings; no spell check | | Text: wrap style (Auto, Balance, Pretty) | done | per text layer (`wrapStyle` on `node.set`, `text.wrapStyle`, the Type settings control under Vertical trim, inspect, CSS `text-wrap: balance` or `pretty`): Auto breaks greedily; Balance narrows each paragraph as far as it goes without another line, so its lines come out close to the same length (what browsers do for `text-wrap: balance`); Pretty keeps lines full and, when the last line is one word, narrows one of the last four lines just enough to give a word to the lines after it (Explore text properties: "Auto: Figma fits as many words as possible on each line before wrapping to the next", "Balance: Figma distributes text as evenly as possible across every line, so each line is close to the same length", "Pretty: Figma keeps each line full, but adjusts the last four lines to avoid an orphan"). Saved line breaks from a file still win. At three levels (the text layer, a paragraph and a text style, per Explore text properties): the paragraph level is the caret's or the selection's paragraphs while editing (`text.wrapStyle`; the control follows them), or `start`/`end` on `node.set wrapStyle` (a paragraph's own style beats the layer's; setting the layer sets every paragraph again; Enter carries it to the new paragraph; inspect reports `lineWrapStyles` when paragraphs differ and CSS `text-wrap` only when they agree); the text-style level is a style's `wrapStyle` (shown read-only in the style editor, applied with the style, moved by `style.update`, unlinking when edited). The `.fig` import/export mapping stays open (#1827): a `.fig` export leaves the wrap styles out and a `.fig` import reads every text as Auto, so the wrap styles are lost through a `.fig` round trip. Test: `text_behaviour_tests::wrap_style_per_paragraph_overrides_the_layers`, `styles_behaviour_tests::text_styles_carry_the_wrap_style`, `text_behaviour_tests::balance_and_pretty_wrap_styles_break_lines_as_documented` | | Text: direction override (Text ▸ Text direction) | done | per paragraph (`ParaList::direction`: auto, ltr, rtl): Text ▸ Text direction ▸ Auto / Left to right / Right to left and `text.direction {direction, ids?}` set the edited paragraphs while editing, else every paragraph of the selected texts; `node.set textDirection` the layer's (or the chars `start`/`end` name); the Type settings control appears once a right-to-left script is in the text or a direction is forced; inspect reports `textDirection` when the paragraphs agree and `lineDirections` otherwise; Developer Mode's CSS writes `direction: ltr` or `rtl` when every paragraph is forced the same way (with `text-align: left` beside `rtl`, as Left is absolute on the canvas); `.fig` import and export carry each line's `sourceDirectionality`, read up to the paragraph count. Layout gives the paragraph its base level, so a forced right-to-left paragraph of Latin letters starts at the right, mirrors its list gutter and indent and orders its runs right to left, and a forced left-to-right paragraph of Hebrew the other way ("By default, Figma automatically handles text direction based on language detection. However, controls are available to override text direction per paragraph", "Go to Text > Text direction. Select Left to right or Right to left", Add right-to-left text). Not included: a direction in text styles (the article names none). Tests: `text_behaviour_tests::text_direction_is_forced_per_paragraph`, `fig::text_direction_tests` | | Text: superscript and subscript | done | `sups` / `subs` use the font's own glyphs where it has the feature and every letter or digit of the run gets one; otherwise the standard glyphs are drawn shrunk and raised or lowered by the font's OS/2 superscript and subscript metrics (0.65 em at 0.35 em up or 0.14 em down without them), and a run mixing available and unavailable glyphs is synthesised whole, as Explore text properties says ("Figma draws a synthesized version by using the font's standard version of the character, shrinking it, and positioning it accordingly"; mixed glyphs "all update to the synthesized form for consistency"), #1828; tests `text::tests::superscript_native_or_synthesised_and_never_mixed`, `text_behaviour_tests::superscript_and_subscript_are_synthesised_without_glyphs_for_them` | -| Eyedropper (I) | done | picks the colour seen under the pointer (opaque) into the selection's fill and the recent colours, one undo step (`fx_behaviour_tests`); with Cmd/Ctrl+Shift held it makes a colour style or variable of it instead, as the reference app's eyedropper does: a Create from color window asks which, its name (the next free "Color n") and a variable's collection (the file's first, or a new one made with it in the same undo step), and leaves the selection's fills alone (`eyedropper_create_tests`, `sampled_color_tests`) | +| Eyedropper (I) | done | picks the colour seen under the pointer (opaque) into the selection's fill and the recent colours, one undo step (`fx_behaviour_tests`): one screen pixel centred on the pointer, sampled as the canvas draws it when zoomed in, so an image magnified past 2x gives the pixel under the pointer, not a blend with its neighbours; zoomed out it samples the full-resolution image (the canvas may show a smaller copy, which the eyedropper does not use), so it can differ slightly from the shown colour (#2189, `eyedropper_image_tests`); with Cmd/Ctrl+Shift held it makes a colour style or variable of it instead, as the reference app's eyedropper does: a Create from color window asks which, its name (the next free "Color n") and a variable's collection (the file's first, or a new one made with it in the same undo step), and leaves the selection's fills alone (`eyedropper_create_tests`, `sampled_color_tests`) | | Comment (C), Shift+C to show/hide | done | local only | | Annotation tool (Shift+T) | done | picks the layer under the pointer, or the selection (or an `id`) with `tool.annotation`, and opens its note in the Inspect tab with the new-note field focused; it works in Developer Mode and in Design mode, and stays selected until V or Escape (inferred). Figma's placement, cursor and whether the tool stays selected are unmeasured (Developer Mode is paywalled in the web app); staying selected until V or Escape, like the Comment tool, is inferred, and there is no toolbar button or icon yet | | Text on a path (Figma Draw) | done | the Text on a path tool in the Text flyout (`tool.textOnPath`) shows the I-beam over a shape's or vector's path, and a click there puts new text on the path, starting at the click, with the path's effects and its fill when one shows; the path layer is removed, and the path comes back if nothing is typed. Also from the Design panel or `text.onPath`; the path is edited by resizing only | @@ -213,6 +217,10 @@ This audit records candidates for subsequent fixes; their behaviour is unchanged | Date | Change | Summary | |---|---|---| +| 2026-11-09 | patch | M3, #2156: the text caret takes the text's solid fill colour (red text, red caret; light grey on a dark frame, light grey, one colour and no inversion), measured in Figma's web app: the fill of the character before the caret (the first one's at the start); FigCraft draws it opaque (how Figma treats a translucent fill was not measured); gradient, image and hidden fills (not measured) give a black caret on a light surface and a white one on a dark one (the nearest layer around the text whose top visible fill is a solid at least half opaque as drawn, counting layer opacity, else the page; a layer whose top fill is a gradient or an image is passed over), not the interface's text colour (white in the dark theme, invisible on the default light page, #2190). Width and height unchanged; collaborators' carets unchanged. Tests: `caret_tests` | +| 2026-11-10 | minor | The Rotation field shows and sets the layer's rotation on the page (its own angle plus its parents' when no ancestor is flipped; with a flipped ancestor FigCraft reads the composed angle, which flips the sign of the layer's own angle, and Figma's behaviour there was not measured), in frames and groups alike, as measured in Figma's web app for rotated, unflipped parents (#2196) | +| 2026-11-09 | patch | M3, #2189: the eyedropper picks the colour the canvas shows. It sampled a 1x1 render without the canvas's magnified-image pixels, so on an image magnified past 2x it blended a 1 px line with its neighbours (#3D444D picked as #343B44 beside #151B23), and the pixel it sampled began at the pointer instead of being centred on it. It now matches the canvas when zoomed in; zoomed out it still samples the full-resolution image, not the smaller copy the canvas may show. Test: `eyedropper_image_tests` | +| 2026-11-09 | patch | M3, #2188: Selection colors shows for a selection holding a layer with children (a frame, group, component or instance) from one paint group, and for layers without children only from two paint groups (groups are counted by style, variable and paint value, as `collect` does, not by distinct colours); measured in Figma's web app on 2026-11-09 for the examples below only, and instance and component behaviour was not measured: a frame holding one red rectangle, a group of two red rectangles and a frame with a lone black-stroked rectangle show one row; one red rectangle, two red rectangles and a childless green frame show none; a red and a blue loose rectangle show two (two paint groups). A childless rectangle with a red fill and a blue stroke has two paint groups, so the engine shows the section (not measured). Tests: `selection_colors_tests`. Counts unchanged | | 2026-11-10 | patch | M1, #2198: with a shape, frame, slice or Text tool the pointer was the system's crosshair, white under some pointer styles on Windows and lost on the default white frame; it is now drawn at the pointer in dark lines with a white edge, open at the centre (`Glyph::Crosshair`), so it shows on any canvas colour. | | 2026-11-10 | minor | M4, #2222: a boolean group takes a corner radius that rounds every sharp corner of its result (measured in Figma's web app), Boolean groups row | | 2026-11-08 | minor | M8: measured in Figma on 2026-11-08, vector edit mode's Point section: X and Y show the value the selected points share, or Mixed when they differ, and a typed value sets every selected point's own coordinate in the layer being edited, points of other edited layers left as they are (it moved the group's top-left before); a relative edit (`+10`, `*2`, `/2`) typed into a Mixed field applies to each point's own value (`vector.edit.position` takes a number or `{add}`, `{mul}`, `{div}` per axis); the W and H row and other edited layers' points are unchanged. |