From 970a3e6745d27f7a1fab9e27e82553a7545aef66 Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Tue, 3 Nov 2026 04:22:36 +0000 Subject: [PATCH 1/9] fix(engine): check the opened file, not the looked-up path, before reading it read_capped checked the path's metadata (type and size) and then opened the path again, so an entry swapped between the two steps was read without those checks. The opened handle's metadata is checked as well; the path check stays, so a pipe is still refused before it is opened. --- crates/engine/src/automation/file_access.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/crates/engine/src/automation/file_access.rs b/crates/engine/src/automation/file_access.rs index b40a92f79..26f15700b 100644 --- a/crates/engine/src/automation/file_access.rs +++ b/crates/engine/src/automation/file_access.rs @@ -277,6 +277,14 @@ pub fn read_capped(path: impl AsRef, max: u64) -> Result> { return Err(refuse(format!("is {}, more than the {} allowed here", size(meta.len()), size(max)))); } let f = std::fs::File::open(p).map_err(io(path))?; + // What was opened, not what was looked at: the path could have been swapped in between. + let meta = f.metadata().map_err(io(path))?; + if !meta.is_file() { + return Err(refuse("isn't a regular file (a device or a pipe?), so it isn't read".into())); + } + if meta.len() > max { + return Err(refuse(format!("is {}, more than the {} allowed here", size(meta.len()), size(max)))); + } let mut bytes = Vec::with_capacity(usize::try_from(meta.len()).unwrap_or(0)); f.take(max.saturating_add(1)).read_to_end(&mut bytes).map_err(io(path))?; // It grew after it was looked at. From 31a60ed3606c18d8329a04e55faba6e16537419b Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Tue, 3 Nov 2026 04:35:27 +0000 Subject: [PATCH 2/9] fix(collab-net): give a management request one deadline for its answer reply read until the server answered, and every ping, pong or control frame renewed the per-read timeout, so a library endpoint could hold a background refresh (and the shared refresh permit) open indefinitely. The whole exchange now ends at one absolute deadline, the idle timeout from when the request went out. --- crates/collab-net/src/manage.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/crates/collab-net/src/manage.rs b/crates/collab-net/src/manage.rs index 04c718c5d..eecbca964 100644 --- a/crates/collab-net/src/manage.rs +++ b/crates/collab-net/src/manage.rs @@ -206,7 +206,15 @@ fn send(ws: &mut Ws, msg: &ClientMsg) -> Result<(), String> { /// The next answer `pick` takes, or why there is none. fn reply(ws: &mut Ws, limits: &NetLimits, pick: impl Fn(ServerMsg) -> Option) -> Result { + // One deadline for the whole answer: pings, pongs and a message trickling in each renew the + // read timeout, so without it a server could keep a request (and the refresh permit the + // caller holds) waiting for as long as it liked. + let until = std::time::Instant::now() + limits.idle_timeout; + ws.get_mut().read_until(Some(until)); loop { + if std::time::Instant::now() >= until { + return Err("no answer from the server (it took too long)".into()); + } return match ws.read() { Ok(Message::Binary(b)) => match message::decode::(&b, limits.max_server_message) { Ok(ServerMsg::Refused { reason }) => Err(format!("{REFUSED}{reason}")), From c673996fe792f8ae85e00bb52fd8e1572bf73eb6 Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Tue, 3 Nov 2026 04:37:12 +0000 Subject: [PATCH 3/9] fix(engine): install a directory plugin only with the permissions that were shown The confirmation showed the directory entry's access and commands, but the downloaded bundle's manifest was registered as is, so a directory could show a read-only plugin and install one that edits the document. A manifest asking for more than the entry showed is refused before it is saved. --- .../engine/src/extensions/plugin_directory.rs | 10 +++++++ crates/engine/src/plugin_directory_tests.rs | 26 +++++++++++++++++++ crates/engine/src/sharing/background/tests.rs | 11 ++++++-- 3 files changed, 45 insertions(+), 2 deletions(-) diff --git a/crates/engine/src/extensions/plugin_directory.rs b/crates/engine/src/extensions/plugin_directory.rs index 2f721feae..2c7e00e8f 100644 --- a/crates/engine/src/extensions/plugin_directory.rs +++ b/crates/engine/src/extensions/plugin_directory.rs @@ -127,6 +127,16 @@ fn install(s: &mut Session, p: &Value) -> Result { if manifest.id != entry.id || manifest.version != entry.version { return Err(fail("its manifest doesn't match the directory's entry")); } + // What was shown and approved is the entry's access and commands: a bundle whose manifest + // asks for more is refused, since the manifest is what the plugin then runs under. + if manifest.permissions.access == figcraft_plugin::manifest::Access::Write && !entry.access.trim().eq_ignore_ascii_case("write") { + return Err(fail("its manifest asks to write the document, but the directory showed it as read-only")); + } + if !entry.commands.is_empty() + && (manifest.permissions.commands.is_empty() || manifest.permissions.commands.iter().any(|c| !entry.commands.contains(c))) + { + return Err(fail("its manifest asks for commands the directory didn't show")); + } let source = address(&server); let path = save(s, &mut manifest, &bundle).map_err(|e| fail(&e))?; let out = json!({ diff --git a/crates/engine/src/plugin_directory_tests.rs b/crates/engine/src/plugin_directory_tests.rs index fa4d3d4cc..358845933 100644 --- a/crates/engine/src/plugin_directory_tests.rs +++ b/crates/engine/src/plugin_directory_tests.rs @@ -252,3 +252,29 @@ fn publishing_sends_a_checked_folder() { assert_eq!(r["id"], ID); let _ = std::fs::remove_dir_all(&dir); } + +#[test] +fn a_bundle_asking_for_more_than_the_directory_showed_is_not_installed() { + let (mut s, d) = session(); + // Shown as read-only with one command; the bundle's manifest asks to write, any command. + let text = + json!({"id": ID, "name": "Tiny", "version": "1.0.0", "author": "Ada", "main": "tiny.wasm", "permissions": {"access": "write"}}).to_string(); + let b = Bundle { manifest: text, wasm: wasm(), assets: vec![] }.encode(); + let mut e = entry(ID, "1.0.0", &b); + e.commands = vec!["node.get".into()]; + d.lock().unwrap().plugins.push((e, b)); + s.execute("plugin.directory.list", &json!({"server": "ws://127.0.0.1:9/"})).unwrap(); + let err = s.execute("plugin.directory.install", &json!({"id": ID, "confirm": true})).unwrap_err().to_string(); + assert!(err.contains("write"), "{err}"); + assert!(s.prefs.plugins.is_empty(), "nothing was installed"); + // Read-only as shown, but more commands than shown. + let text = json!({"id": ID, "name": "Tiny", "version": "1.0.1", "author": "Ada", "main": "tiny.wasm", "permissions": {"access": "read", "commands": ["node.get", "node.set"]}}).to_string(); + let b = Bundle { manifest: text, wasm: wasm(), assets: vec![] }.encode(); + let mut e = entry(ID, "1.0.1", &b); + e.commands = vec!["node.get".into()]; + d.lock().unwrap().plugins.clear(); + d.lock().unwrap().plugins.push((e, b)); + s.execute("plugin.directory.list", &json!({"server": "ws://127.0.0.1:9/"})).unwrap(); + let err = s.execute("plugin.directory.install", &json!({"id": ID, "confirm": true})).unwrap_err().to_string(); + assert!(err.contains("commands"), "{err}"); +} diff --git a/crates/engine/src/sharing/background/tests.rs b/crates/engine/src/sharing/background/tests.rs index fa4d00824..6f98841df 100644 --- a/crates/engine/src/sharing/background/tests.rs +++ b/crates/engine/src/sharing/background/tests.rs @@ -73,8 +73,15 @@ fn bundle() -> Vec { fn directory(req: PluginReq) -> PluginReply { let bytes = bundle(); - let entry = - PluginEntry { id: ID.into(), name: "Tiny tool".into(), version: "1.0.0".into(), sha256: sha256_hex(&bytes), ..PluginEntry::default() }; + let entry = PluginEntry { + id: ID.into(), + name: "Tiny tool".into(), + version: "1.0.0".into(), + access: "write".into(), + commands: vec!["shape.rectangle".into()], + sha256: sha256_hex(&bytes), + ..PluginEntry::default() + }; match req { PluginReq::List { .. } => PluginReply::List(vec![entry]), PluginReq::Fetch { .. } => PluginReply::Bundle { entry, bundle: bytes }, From d48aa59ec757ba9b6ebe346aebfbbaed87505d97 Mon Sep 17 00:00:00 2001 From: Trevor Brown Date: Tue, 3 Nov 2026 11:52:41 -0500 Subject: [PATCH 4/9] M12: drag a "+" handle to drop the next shape anywhere or join another object (#1919) The quick-create handles only took a click. As the help says ("drag the preview to any location on your board"), a handle can now be dragged: the preview follows the pointer and, let go on empty board, the next sticky or shape is made there, centred on the pointer, joined by a connector whose ends take the sides facing each other (board.addConnected gains at: [x, y]); let go on another sticky or shape, a connector joins the two instead (board.connector), that object outlined while over it. figcraft_engine::board::object_at exposes the hit test a stamp uses. The click is as before. Tests: board_connect_tests (two), board_connected_tests::the_next_one_goes_where_it_is_dropped. Docs: boards-parity row, status line and revision history. Co-Authored-By: Claude Fable 5.1 --- crates/engine/src/board_connected_tests.rs | 17 +++ crates/engine/src/boards/board.rs | 9 +- crates/engine/src/boards/board/items.rs | 16 +++ crates/ui-egui/src/board_connect_tests.rs | 53 ++++++++ crates/ui-egui/src/canvas/board_connect.rs | 138 +++++++++++++++++++-- docs/boards-parity.md | 5 +- 6 files changed, 225 insertions(+), 13 deletions(-) diff --git a/crates/engine/src/board_connected_tests.rs b/crates/engine/src/board_connected_tests.rs index 2e5f8a344..d6b962449 100644 --- a/crates/engine/src/board_connected_tests.rs +++ b/crates/engine/src/board_connected_tests.rs @@ -104,3 +104,20 @@ fn the_next_sticky_shortcut_joins_the_next_shape_and_leaves_stickies_as_they_wer assert!(r.get("connector").is_none(), "{r}"); assert!(matches!(node(&s, id(&r, "id")).board, Some(BoardItem::Sticky { .. }))); } + +/// `at` (#1919; "drag the preview to any location on your board", Build faster with quick create): +/// the next one is centred on that point, wherever it is, and the connector takes the sides facing +/// each other; `at` must be two finite numbers. +#[test] +fn the_next_one_goes_where_it_is_dropped() { + let mut s = board(); + let a = id(&s.execute("board.shape", &json!({"shape": "diamond", "x": 0, "y": 0, "width": 200, "height": 120})).unwrap(), "id"); + let r = s.execute("board.addConnected", &json!({"id": a, "side": "below", "at": [700, 60]})).unwrap(); + let (b, c) = (id(&r, "id"), id(&r, "connector")); + assert_eq!(at(&s, b), (600.0, 0.0), "centred on the point"); + let k = connector(&s, c); + assert_eq!((k.from, k.to), (End::Node { node: a, side: Side::Auto, at: None }, End::Node { node: b, side: Side::Auto, at: None })); + for wrong in [json!([1]), json!("x"), json!([0, "y"]), json!({"x": 1, "y": 2})] { + assert!(s.execute("board.addConnected", &json!({"id": a, "at": wrong})).is_err(), "{wrong}"); + } +} diff --git a/crates/engine/src/boards/board.rs b/crates/engine/src/boards/board.rs index bf7f8ccf1..d6c5dc255 100644 --- a/crates/engine/src/boards/board.rs +++ b/crates/engine/src/boards/board.rs @@ -33,6 +33,13 @@ pub use connectors::{END_HANDLE_PX, selected_connector_ends}; use connectors::{connector_cmd, reattach}; pub use derived::route; pub(crate) use derived::{settle_routes, settle_stamps, settle_text, stamp_target}; + +/// The sticky, shape or other object at `p` on `page`: the topmost layer of the page whose box +/// holds it (stamps, connectors, their labels and ink aside), other than `except`. What a stamp +/// sticks to, and what a "+" handle dragged onto it joins (#1919). +pub fn object_at(doc: &Document, page: NodeId, p: Point, except: Option) -> Option { + stamp_target(doc, page, p, except) +} pub use edit::label_of; pub(crate) use edit::{copied_items, copy_map, rejoin}; use edit::{label_cmd, set_color, set_style}; @@ -114,7 +121,7 @@ pub fn specs() -> Vec { spec!( "board.addConnected", "Add connected shape", - "{id? (a sticky or shape; default the selected or edited one), side?: right|below|left|above (default right), edit? (start typing in it; default false)} → {id, text, connector} the next one of the same kind, size and colour on that side, joined by a connector", + "{id? (a sticky or shape; default the selected or edited one), side?: right|below|left|above (default right), at? ([x, y] on the page: the next one's centre, anywhere, instead of its place on that side; the connector then takes the sides facing each other), edit? (start typing in it; default false)} → {id, text, connector} the next one of the same kind, size and colour on that side, joined by a connector", true, add_connected ), diff --git a/crates/engine/src/boards/board/items.rs b/crates/engine/src/boards/board/items.rs index 44708d944..981a8399e 100644 --- a/crates/engine/src/boards/board/items.rs +++ b/crates/engine/src/boards/board/items.rs @@ -223,6 +223,12 @@ pub(super) fn add_connected(s: &mut Session, p: &Value) -> Result { let color = color.unwrap_or(s.tool.board.sticky); let (to_at, from_side, to_side) = connected_place((at.x, at.y), (n.width, n.height), next, &side) .ok_or_else(|| bad(cmd, format!("`side` is right, below, left or above, not `{side}`")))?; + // Dropped somewhere by hand ("drag the preview to any location on your board", #1919): the + // next one is centred there, and the connector joins the sides facing each other. + let (to_at, from_side, to_side) = match drop_point(cmd, p)? { + Some((x, y)) => ((x - next.0 / 2.0, y - next.1 / 2.0), Side::Auto, Side::Auto), + None => (to_at, from_side, to_side), + }; let (routing, author, page) = (s.tool.board.routing, author(s), s.page()?); if editing.is_some() { textedit::end(s)?; @@ -246,6 +252,16 @@ pub(super) fn add_connected(s: &mut Session, p: &Value) -> Result { Ok(json!({"id": id, "text": text, "connector": line})) } +/// `at?` of `board.addConnected`: a point on the page, `[x, y]`, or none. +fn drop_point(cmd: &str, p: &Value) -> Result> { + let Some(v) = get(p, "at") else { return Ok(None) }; + let pair = v.as_array().filter(|a| a.len() == 2).and_then(|a| Some((a.first()?.as_f64()?, a.get(1)?.as_f64()?))); + match pair { + Some((x, y)) if x.is_finite() && y.is_finite() => Ok(Some((x, y))), + _ => Err(bad(cmd, "`at` is [x, y] on the page, two finite numbers")), + } +} + /// A shape with text's layers: the frame, its outline and its text. fn make_shape( doc: &mut Document, diff --git a/crates/ui-egui/src/board_connect_tests.rs b/crates/ui-egui/src/board_connect_tests.rs index 5a4712197..f3e4dc612 100644 --- a/crates/ui-egui/src/board_connect_tests.rs +++ b/crates/ui-egui/src/board_connect_tests.rs @@ -140,3 +140,56 @@ fn the_object_a_stamp_will_stick_to_is_highlighted() { u.button(off, false); assert_eq!((target(&u), on(&u)), (None, None), "let go off the shape: on nothing, and no outline"); } + +/// Dragging a "+" carries the preview ("Click to select and create the next shape in that +/// direction, or drag the preview to any location on your board", Build faster with quick create; +/// #1919): let go on empty board and the next shape is made there, centred on the pointer, joined +/// by a connector, with typing started; one undo takes both away. +#[test] +fn dragging_a_handle_drops_the_next_shape_where_it_is_let_go() { + let (mut u, a) = board_with_shape(); + u.app.session.execute("select.set", &json!({"ids": [a]})).unwrap(); + u.frame(vec![]); + u.frame(vec![]); + let before = u.app.session.doc().unwrap().ids().count(); + let from = handle(&u, "below").expect("a handle below").center(); + let to = from + egui::vec2(260.0, 180.0); + u.drag_to(from, to); + u.button(to, false); + u.frame(vec![]); + let doc = u.app.session.doc().unwrap(); + let next = doc.ids().find(|i| *i != a && matches!(doc.node(*i).unwrap().board, Some(BoardItem::Shape { .. }))).expect("a new shape"); + let line = doc.ids().find(|i| matches!(doc.node(*i).unwrap().board, Some(BoardItem::Connector(_)))).expect("a connector"); + let centre = screen_box(&u, next).center(); + assert!((centre - to).length() < 1.0, "centred where it was let go: {centre:?}, not {to:?}"); + assert!(matches!(&doc.node(line).unwrap().board, Some(BoardItem::Connector(c)) if c.from.node() == Some(a) && c.to.node() == Some(next))); + assert!(u.app.session.ds().unwrap().text_edit.is_some(), "typing in the new shape"); + figcraft_engine::textedit::end(&mut u.app.session).unwrap(); + u.app.session.execute("edit.undo", &json!({})).unwrap(); + assert_eq!(u.app.session.doc().unwrap().ids().count(), before, "undo takes the shape and its connector away"); +} + +/// A "+" dragged onto another sticky or shape joins the two with a connector instead of making a +/// new shape (#1919). +#[test] +fn dropping_a_handle_on_another_shape_joins_them() { + let (mut u, a) = board_with_shape(); + let b = id(&u.app.session.execute("board.shape", &json!({"shape": "ellipse", "x": 400, "y": 300, "width": 160, "height": 100})).unwrap()); + u.app.session.execute("select.set", &json!({"ids": [a]})).unwrap(); + u.frame(vec![]); + u.frame(vec![]); + let shapes = |u: &Ui| { + let doc = u.app.session.doc().unwrap(); + doc.ids().filter(|i| matches!(doc.node(*i).unwrap().board, Some(BoardItem::Shape { .. }))).count() + }; + assert_eq!(shapes(&u), 2); + let from = handle(&u, "right").expect("a handle right").center(); + let to = screen_box(&u, b).center(); + u.drag_to(from, to); + u.button(to, false); + u.frame(vec![]); + assert_eq!(shapes(&u), 2, "no new shape"); + let doc = u.app.session.doc().unwrap(); + let line = doc.ids().find(|i| matches!(doc.node(*i).unwrap().board, Some(BoardItem::Connector(_)))).expect("a connector"); + assert!(matches!(&doc.node(line).unwrap().board, Some(BoardItem::Connector(c)) if c.from.node() == Some(a) && c.to.node() == Some(b))); +} diff --git a/crates/ui-egui/src/canvas/board_connect.rs b/crates/ui-egui/src/canvas/board_connect.rs index 87211055b..aaac45af9 100644 --- a/crates/ui-egui/src/canvas/board_connect.rs +++ b/crates/ui-egui/src/canvas/board_connect.rs @@ -1,11 +1,13 @@ //! Boards: a "+" beside each side of the one selected sticky or shape (#1597). Hovering one shows //! where the next one goes; clicking it makes the next of the same kind there, joined by a -//! connector, and starts typing in it (`board.addConnected`). +//! connector, and starts typing in it (`board.addConnected`). Dragging one carries the preview +//! ("drag the preview to any location on your board", #1919): let go on empty board and the next +//! one is made there, joined; let go on another sticky or shape and a connector joins the two. -use egui::{Area, Color32, CornerRadius, Id, LayerId, Order, Pos2, Rect, Sense, Shape, Stroke, pos2, vec2}; +use egui::{Area, Color32, CornerRadius, Id, LayerId, Order, Pos2, Rect, Sense, Shape, Stroke, StrokeKind, pos2, vec2}; use figcraft_doc::{BoardItem, NodeId}; use figcraft_engine::ToolId; -use figcraft_engine::board::{STICKY, connected_place}; +use figcraft_engine::board::{STICKY, connected_place, object_at}; use serde_json::json; use crate::FigApp; @@ -18,6 +20,17 @@ pub(crate) const REACH: f32 = 36.0; const RADIUS: f32 = 9.0; const SIDES: [&str; 4] = ["above", "right", "below", "left"]; +/// A drag from a "+": the object and the side it started from, kept while the button is down. +#[derive(Clone)] +struct Drag { + from: NodeId, + side: &'static str, +} + +fn drag_id() -> Id { + Id::unique("board_connect_drag") +} + /// The sticky or shape the handles are for: its id, its box on the page and the next one's size. fn target(app: &FigApp) -> Option<(NodeId, figcraft_geom::Rect, (f64, f64))> { let editable = app.session.active_read_only().is_none(); @@ -51,8 +64,35 @@ fn handle_at(r: Rect, side: &str) -> Pos2 { } } +/// The middle of `side` of the object's screen box `r`, where its connector leaves. +fn side_middle(r: Rect, side: &str) -> Pos2 { + match side { + "above" => r.center_top(), + "right" => r.right_center(), + "below" => r.center_bottom(), + _ => r.left_center(), + } +} + +/// A "+" side as `board.connector` names it. +fn connector_side(side: &str) -> &'static str { + match side { + "above" => "top", + "below" => "bottom", + "left" => "left", + _ => "right", + } +} + pub fn show(app: &mut FigApp, ctx: &egui::Context) { - let Some((id, b, next)) = target(app) else { return }; + let drag: Option = ctx.data(|d| d.get_temp(drag_id())); + let Some((id, b, next)) = target(app) else { + // The selection or the tool changed under a drag: it is over. + if drag.is_some() { + ctx.data_mut(|d| d.remove::(drag_id())); + } + return; + }; let r = Rect::from_two_pos(app.to_screen(b.x0, b.y0), app.to_screen(b.x1, b.y1)); // Too small on screen to tell the handles from the object. if r.width() < 2.0 * RADIUS || r.height() < 2.0 * RADIUS { @@ -63,16 +103,18 @@ pub fn show(app: &mut FigApp, ctx: &egui::Context) { // Not over the toolbar at the bottom of the canvas. let toolbar = crate::toolbar::pill_rect(app.canvas.rect, crate::toolbar::bar_width(app)).expand(RADIUS); let mut picked = None; + let mut started = None; + let mut let_go = false; for side in SIDES { let c = handle_at(r, side); if !app.canvas.rect.shrink(RADIUS).contains(c) || toolbar.contains(c) { continue; } let area = Area::new(Id::unique(("board_connect", side))).fixed_pos(c - vec2(RADIUS, RADIUS)).order(Order::Middle); - let clicked = area + let (clicked, drag_started, drag_stopped) = area .show(ctx, |ui| { - let (rect, resp) = ui.allocate_exact_size(vec2(2.0 * RADIUS, 2.0 * RADIUS), Sense::click()); - let hot = resp.hovered(); + let (rect, resp) = ui.allocate_exact_size(vec2(2.0 * RADIUS, 2.0 * RADIUS), Sense::click_and_drag()); + let hot = resp.hovered() || resp.dragged(); let p = ui.painter(); p.circle_filled(rect.center(), RADIUS, if hot { accent } else { t.panel }); p.circle_stroke(rect.center(), RADIUS, Stroke::new(1.0, if hot { accent } else { t.border })); @@ -80,19 +122,58 @@ pub fn show(app: &mut FigApp, ctx: &egui::Context) { let arm = RADIUS * 0.45; p.line_segment([rect.center() - vec2(arm, 0.0), rect.center() + vec2(arm, 0.0)], ink); p.line_segment([rect.center() - vec2(0.0, arm), rect.center() + vec2(0.0, arm)], ink); - if hot { + // Where a click puts the next one; a drag shows its own preview. + if hot && drag.is_none() && !resp.dragged() { preview(app, ctx, b, next, side, accent); } - resp.on_hover_text(tr("Add a connected shape")).clicked() + let resp = resp.on_hover_text(tr("Add a connected shape")); + (resp.clicked(), resp.drag_started(), resp.drag_stopped()) }) .inner; if clicked { picked = Some(side); } + if drag_started { + started = Some(side); + } + let_go |= drag_stopped; } if let Some(side) = picked { app.run("board.addConnected", json!({"id": id, "side": side, "edit": true})); } + if let Some(side) = started { + ctx.data_mut(|d| d.insert_temp(drag_id(), Drag { from: id, side })); + } + // A drag carries the preview: the next one centred on the pointer, or the object under it, + // which the connector joins instead. + let Some(Drag { from, side }) = drag.filter(|d| d.from == id) else { return }; + let Some(pointer) = ctx.input(|i| i.pointer.latest_pos()) else { return }; + let over = object_under(app, from, pointer); + drag_preview(app, ctx, (b, next, side), pointer, over); + if let_go { + ctx.data_mut(|d| d.remove::(drag_id())); + match over { + Some(to) => { + app.run("board.connector", json!({"from": from, "to": to, "fromSide": connector_side(side)})); + } + None => { + let q = app.to_page(pointer); + app.run("board.addConnected", json!({"id": from, "side": side, "at": [q.x, q.y], "edit": true})); + } + } + } else if !ctx.input(|i| i.pointer.any_down()) { + // The button came up without the handle hearing of it (the pointer left the window). + ctx.data_mut(|d| d.remove::(drag_id())); + } +} + +/// The sticky, shape or other object under the screen point `p` on the canvas, other than `except`. +fn object_under(app: &FigApp, except: NodeId, p: Pos2) -> Option { + if !app.canvas.rect.contains(p) { + return None; + } + let ds = app.session.ds().ok()?; + object_at(&ds.doc, ds.page, app.to_page(p), Some(except)) } /// Where the next one goes for `side`, faintly: its box and the connector's line to it. @@ -107,9 +188,46 @@ fn preview(app: &FigApp, ctx: &egui::Context, b: figcraft_geom::Rect, next: (f64 _ => (from.left_center(), ghost.right_center()), }; let p = ctx.layer_painter(LayerId::new(Order::Middle, Id::unique("board_connect_preview"))); + let faint = Stroke::new(1.5, accent.gamma_multiply(0.6)); + ghost_box(&p, ghost, accent); + p.line_segment([a, z], faint); +} + +/// The next one's box, faintly: a tint and a dashed outline. +fn ghost_box(p: &egui::Painter, ghost: Rect, accent: Color32) { let faint = Stroke::new(1.5, accent.gamma_multiply(0.6)); p.rect_filled(ghost, CornerRadius::same(8), accent.gamma_multiply(0.08)); let corners = [ghost.left_top(), ghost.right_top(), ghost.right_bottom(), ghost.left_bottom(), ghost.left_top()]; p.extend(Shape::dashed_line(&corners, faint, 6.0, 4.0)); - p.line_segment([a, z], faint); +} + +/// The dragged preview: the next one centred on `pointer` and the connector's line to it from +/// `side` of the object's box `b`, or, over another object, that object outlined and the line to +/// it; the line arrives at the side of the box facing the object. +fn drag_preview(app: &FigApp, ctx: &egui::Context, (b, next, side): (figcraft_geom::Rect, (f64, f64), &str), pointer: Pos2, over: Option) { + let accent = crate::theme::canvas_accent(ctx); + let from = Rect::from_two_pos(app.to_screen(b.x0, b.y0), app.to_screen(b.x1, b.y1)); + let p = ctx.layer_painter(LayerId::new(Order::Middle, Id::unique("board_connect_preview"))); + let to_box = match over.and_then(|o| app.session.doc().ok()?.world_bounds(o)) { + Some(ob) => { + let r = Rect::from_two_pos(app.to_screen(ob.x0, ob.y0), app.to_screen(ob.x1, ob.y1)); + p.rect_stroke(r, CornerRadius::same(4), Stroke::new(1.5, accent), StrokeKind::Outside); + r + } + None => { + let size = app.to_screen(next.0, next.1) - app.to_screen(0.0, 0.0); + let ghost = Rect::from_center_size(pointer, size); + ghost_box(&p, ghost, accent); + ghost + } + }; + let d = to_box.center() - from.center(); + let z = if d.x.abs() >= d.y.abs() { + if d.x >= 0.0 { to_box.left_center() } else { to_box.right_center() } + } else if d.y >= 0.0 { + to_box.center_top() + } else { + to_box.center_bottom() + }; + p.line_segment([side_middle(from, side), z], Stroke::new(1.5, accent.gamma_multiply(0.6))); } diff --git a/docs/boards-parity.md b/docs/boards-parity.md index 7526d39aa..dd14d1b9f 100644 --- a/docs/boards-parity.md +++ b/docs/boards-parity.md @@ -1,6 +1,6 @@ # Boards parity -> **Last reviewed:** 2026-10-24 · **Last updated:** 2026-10-31 · **Change:** minor (a connector end moved with Cmd/Ctrl held goes on any part of an object, and stays there as the object moves or resizes; a connector end dropped along a side of a shape attaches to that side (#1708); a board connector's path can be reshaped by dragging its path handles (#1710); boards have 16 more shapes (arrows, polygons, star, plus and flowchart symbols), in pickers that lay them out in a grid; a board keeps earlier votes' results, listed newest first in Results and deleted one at a time; a connector's bar sets its start and end points, dashes, weight and any colour (#1596); cells copied from a spreadsheet paste onto a board as a table; Shift+Cmd/Ctrl+Enter on a selected board shape adds the next shape already joined to it, and goes on typing (#1597); "+" handles beside a selected sticky or shape make the next one, joined by a connector (#1597); a FigJam `.jam` file opens as a board (#1342); board grid settings: dots, lines, graph paper or none, spacing, size and contrast; the connector tool shows the connector it will make while dragging, ends snapping to attach points (#1387); templates and tables; facilitation: a shared timer and voting sessions; the dot grid, dragging a connector's end to re-attach it, curved connectors, elbows that go around what they join) · **Target:** the incumbent's whiteboard product (behaviour from its public help centre) +> **Last reviewed:** 2026-10-24 · **Last updated:** 2026-11-03 · **Change:** minor (a "+" handle dragged carries the preview: the next shape is made where it is let go, or a connector joins the object it is let go on (#1919); a connector end moved with Cmd/Ctrl held goes on any part of an object, and stays there as the object moves or resizes; a connector end dropped along a side of a shape attaches to that side (#1708); a board connector's path can be reshaped by dragging its path handles (#1710); boards have 16 more shapes (arrows, polygons, star, plus and flowchart symbols), in pickers that lay them out in a grid; a board keeps earlier votes' results, listed newest first in Results and deleted one at a time; a connector's bar sets its start and end points, dashes, weight and any colour (#1596); cells copied from a spreadsheet paste onto a board as a table; Shift+Cmd/Ctrl+Enter on a selected board shape adds the next shape already joined to it, and goes on typing (#1597); "+" handles beside a selected sticky or shape make the next one, joined by a connector (#1597); a FigJam `.jam` file opens as a board (#1342); board grid settings: dots, lines, graph paper or none, spacing, size and contrast; the connector tool shows the connector it will make while dragging, ends snapping to attach points (#1387); templates and tables; facilitation: a shared timer and voting sessions; the dot grid, dragging a connector's end to re-attach it, curved connectors, elbows that go around what they join) · **Target:** the incumbent's whiteboard product (behaviour from its public help centre) **Breadth ~47%, ready ~29% (estimated, erring low).** A board is a FigCraft file of its own kind (`file.newBoard`) with a dot grid on the page, sticky notes, shapes with text, connectors that @@ -38,7 +38,7 @@ all end with the same geometry. | Shapes with text | done | 23 outlines: rectangle, rounded rectangle, ellipse, diamond, triangle up and down, parallelogram right and left, trapezoid, pentagon, hexagon, octagon, star, plus, arrow left and right, chevron, speech bubble, and the flowchart symbols database, document, predefined process, manual input and internal storage; text centred and wrapping inside the outline; shape type and text size from the contextual bar | | Shape auto-fit to its text, the advanced shape libraries (engineering and other icon shapes) | missing | | | Connectors | done | from a layer's side (the facing one, or one named) to another layer or a free point, straight, elbow or curved, arrowheads (the stroke's caps), a label in the middle of the route by length (double-click to add); while one is dragged out it shows as it will be made (route, line and arrowhead), the object under the pointer outlined with its four attach points (side middles), the one the end goes to ringed, and within 10 px of one the end keeps that side; re-routed when either end moves or resizes; a deleted end stays where it was | -| Create the next shape already connected | done | a selected sticky or shape shows a "+" beside each side; hovering one shows where the next goes, clicking makes one of the same kind, size and colour there, joined by a connector as the Connector tool makes one, and starts typing in it; one undo step (`board.addConnected {id?, side?, edit?}`, #1597). Shift+Cmd/Ctrl+Enter on a selected (or edited) shape adds the next shape on its right, joined the same way, and goes on typing; on a sticky it adds a sticky beside it without a connector, as before | +| Create the next shape already connected | done | a selected sticky or shape shows a "+" beside each side; hovering one shows where the next goes, clicking makes one of the same kind, size and colour there, joined by a connector as the Connector tool makes one, and starts typing in it; one undo step (`board.addConnected {id?, side?, edit?}`, #1597). Shift+Cmd/Ctrl+Enter on a selected (or edited) shape adds the next shape on its right, joined the same way, and goes on typing; on a sticky it adds a sticky beside it without a connector, as before. Dragging a "+" carries the preview ("drag the preview to any location on your board"): let go on empty board and the next one is made there, centred on the pointer, joined by a connector whose ends take the sides facing each other (`at: [x, y]`); let go on another sticky or shape and a connector joins the two instead, the object outlined while over it (`board_connect_tests`, #1919) | | Curved connectors, elbows around objects, dragging an end to re-attach | done | `board.setStyle {style: curved}` (and the contextual bar): one curve leaving and arriving along the sides; an elbow whose short way would cross what it joins goes around their boxes, 24 units clear; a selected connector shows its two ends as handles, and dragging one onto an object attaches it there (the object is outlined while dragging), onto empty canvas leaves it free (`board.reattach {id, end, target, side?}`, one undo step) | | A connector end on any part of an object | done | holding Cmd/Ctrl while moving an end places it where the pointer is on the object, as a share of its box, so it follows moves and resizes; the line leaves by the side facing the other end. Without the key an end snaps to a side | | Connector paths reshaped by hand | done | a selected elbow or curved connector shows path handles: one on each run long enough to take one, one in the middle of a curve. Dragging a run moves it, and a first or last run gains an extra run to stay on its end; a curve's middle goes where it is dragged (`board.reshape`, one undo step). The shape travels with what the connector joins and is saved with the file; changing the style or moving an end to something else goes back to routing itself. No way back by itself otherwise: the public help describes none | @@ -70,6 +70,7 @@ all end with the same geometry. | Date | Change | Summary | |---|---|---| +| 2026-11-03 | minor | M12, #1919: as the quick create help says ("Click to select and create the next shape in that direction, or drag the preview to any location on your board"; "A new shape is created with a connector and its text field active"), a "+" beside the selected sticky or shape can be dragged: the preview follows the pointer and, let go on empty board, the next one is made there, centred on the pointer and joined by a connector whose ends take the sides facing each other (`board.addConnected` gains `at: [x, y]`); let go on another sticky or shape, a connector joins the two instead (`board.connector`), that object outlined while the pointer is over it. The click is as before. A shape picker on drop and choosing the connector type are not done (the help doesn't describe them). Tests: `board_connect_tests` (two), engine `board_connected_tests::the_next_one_goes_where_it_is_dropped`. Numbers unchanged. | | 2026-10-31 | minor | M12: as the help describes, holding Cmd/Ctrl while moving a connector's end places it on any part of an object instead of snapping to a side. It keeps that spot as a fraction of the object's box, so it follows the object when it moves or resizes, and without the key an end snaps as before. `board.connector {fromAt, toAt}` and `board.reattach {at}` take it; saved only when set. Numbers unchanged | | 2026-10-31 | patch | M12, #1708: a connector end dropped on the outer half of a shape takes the side it is towards, instead of only within 10 px of a side's middle, so a drop anywhere along an edge chooses that edge (dragging a selected connector's end and with the connector tool, ring included); a drop in the middle of a shape still takes the facing side. | | 2026-10-31 | minor | M12, #1710: a selected elbow or curved connector shows path handles. Dragging a run moves it and a first or last run gains an extra run to stay on its end; a curve's middle goes where it is dragged (`board.reshape`, one undo step). The shape travels with what the connector joins, is saved with the file, and goes back to routing itself when the style changes or an end moves to something else. | From 246a89733ca0b4472280d4729e008c75c699d0f5 Mon Sep 17 00:00:00 2001 From: Trevor Brown Date: Tue, 3 Nov 2026 12:44:59 -0500 Subject: [PATCH 5/9] M12: quick-create drag: stickies and shapes in sections, parent coordinates, the handle's side, no drop off the canvas (#1919) Review: the drop target is the topmost sticky or shape under the pointer, sections and frames looked into (board::sticky_or_shape_at, instead of the stamp's any-layer hit test on the page's children); the drop point is placed in the parent's coordinates; the connector leaves by the handle's side (as the preview draws it) and arrives by the facing side; a handle let go off the canvas makes nothing; the parity rows on quick-create handles agree. Tests: dropping_a_handle_on_a_shape_inside_a_frame_joins_it, letting_a_handle_go_over_a_panel_makes_nothing, the_next_one_goes_where_it_is_dropped (frame case). Co-Authored-By: Claude Fable 5.1 --- crates/engine/src/board_connected_tests.rs | 13 ++++++- crates/engine/src/boards/board.rs | 35 +++++++++++++++--- crates/engine/src/boards/board/items.rs | 11 +++++- crates/ui-egui/src/board_connect_tests.rs | 43 ++++++++++++++++++++++ crates/ui-egui/src/canvas/board_connect.rs | 19 +++++++--- docs/boards-parity.md | 8 ++-- 6 files changed, 111 insertions(+), 18 deletions(-) diff --git a/crates/engine/src/board_connected_tests.rs b/crates/engine/src/board_connected_tests.rs index d6b962449..d23129c19 100644 --- a/crates/engine/src/board_connected_tests.rs +++ b/crates/engine/src/board_connected_tests.rs @@ -116,7 +116,18 @@ fn the_next_one_goes_where_it_is_dropped() { let (b, c) = (id(&r, "id"), id(&r, "connector")); assert_eq!(at(&s, b), (600.0, 0.0), "centred on the point"); let k = connector(&s, c); - assert_eq!((k.from, k.to), (End::Node { node: a, side: Side::Auto, at: None }, End::Node { node: b, side: Side::Auto, at: None })); + assert_eq!( + (k.from, k.to), + (End::Node { node: a, side: Side::Bottom, at: None }, End::Node { node: b, side: Side::Auto, at: None }), + "leaves by the handle's side" + ); + // Inside a frame at (1000, 500): the page point lands in the frame's coordinates. + let f = id(&s.execute("frame.create", &json!({"x": 1000, "y": 500, "width": 800, "height": 600})).unwrap(), "id"); + let inner = id(&s.execute("board.shape", &json!({"shape": "ellipse", "x": 0, "y": 0, "width": 200, "height": 120, "parent": f})).unwrap(), "id"); + let r = s.execute("board.addConnected", &json!({"id": inner, "at": [1300, 700]})).unwrap(); + let placed = id(&r, "id"); + assert_eq!(node(&s, placed).parent, Some(f), "beside it, in the frame"); + assert_eq!(at(&s, placed), (200.0, 140.0), "centred on the page point, in the frame's coordinates"); for wrong in [json!([1]), json!("x"), json!([0, "y"]), json!({"x": 1, "y": 2})] { assert!(s.execute("board.addConnected", &json!({"id": a, "at": wrong})).is_err(), "{wrong}"); } diff --git a/crates/engine/src/boards/board.rs b/crates/engine/src/boards/board.rs index d6c5dc255..1f10f5d94 100644 --- a/crates/engine/src/boards/board.rs +++ b/crates/engine/src/boards/board.rs @@ -34,11 +34,34 @@ use connectors::{connector_cmd, reattach}; pub use derived::route; pub(crate) use derived::{settle_routes, settle_stamps, settle_text, stamp_target}; -/// The sticky, shape or other object at `p` on `page`: the topmost layer of the page whose box -/// holds it (stamps, connectors, their labels and ink aside), other than `except`. What a stamp -/// sticks to, and what a "+" handle dragged onto it joins (#1919). -pub fn object_at(doc: &Document, page: NodeId, p: Point, except: Option) -> Option { - stamp_target(doc, page, p, except) +/// The topmost sticky or shape at `p` on `page`, other than `except`, sections and frames looked +/// into: what a "+" handle dragged onto it joins (#1919). +pub fn sticky_or_shape_at(doc: &Document, page: NodeId, p: Point, except: Option) -> Option { + fn find(doc: &Document, id: NodeId, p: Point, except: Option, depth: usize) -> Option { + let n = doc.node(id)?; + for c in n.children.iter().rev() { + let Some(k) = doc.node(*c) else { continue }; + if !k.visible { + continue; + } + match k.board { + Some(BoardItem::Sticky { .. } | BoardItem::Shape { .. }) => { + if Some(*c) != except && doc.world_bounds(*c).is_some_and(|b| b.contains(p)) { + return Some(*c); + } + } + // Not a board object of its own (a section, a frame): what is inside it may be. + None if depth < 32 => { + if let Some(hit) = find(doc, *c, p, except, depth + 1) { + return Some(hit); + } + } + _ => {} + } + } + None + } + find(doc, page, p, except, 0) } pub use edit::label_of; pub(crate) use edit::{copied_items, copy_map, rejoin}; @@ -121,7 +144,7 @@ pub fn specs() -> Vec { spec!( "board.addConnected", "Add connected shape", - "{id? (a sticky or shape; default the selected or edited one), side?: right|below|left|above (default right), at? ([x, y] on the page: the next one's centre, anywhere, instead of its place on that side; the connector then takes the sides facing each other), edit? (start typing in it; default false)} → {id, text, connector} the next one of the same kind, size and colour on that side, joined by a connector", + "{id? (a sticky or shape; default the selected or edited one), side?: right|below|left|above (default right), at? ([x, y] on the page: the next one's centre, anywhere, instead of its place on that side; the connector then leaves by `side` and arrives by the side facing it), edit? (start typing in it; default false)} → {id, text, connector} the next one of the same kind, size and colour on that side, joined by a connector", true, add_connected ), diff --git a/crates/engine/src/boards/board/items.rs b/crates/engine/src/boards/board/items.rs index 981a8399e..b409eeb90 100644 --- a/crates/engine/src/boards/board/items.rs +++ b/crates/engine/src/boards/board/items.rs @@ -224,9 +224,16 @@ pub(super) fn add_connected(s: &mut Session, p: &Value) -> Result { let (to_at, from_side, to_side) = connected_place((at.x, at.y), (n.width, n.height), next, &side) .ok_or_else(|| bad(cmd, format!("`side` is right, below, left or above, not `{side}`")))?; // Dropped somewhere by hand ("drag the preview to any location on your board", #1919): the - // next one is centred there, and the connector joins the sides facing each other. + // next one is centred on that point of the page (placed in the parent's coordinates), and the + // connector leaves by the handle's side and arrives by the side facing it. let (to_at, from_side, to_side) = match drop_point(cmd, p)? { - Some((x, y)) => ((x - next.0 / 2.0, y - next.1 / 2.0), Side::Auto, Side::Auto), + Some((x, y)) => { + let local = doc.world_transform(parent).inverse() * figcraft_geom::Point::new(x, y); + if !(local.x.is_finite() && local.y.is_finite()) { + return Err(bad(cmd, "`at` can't be placed in that parent")); + } + ((local.x - next.0 / 2.0, local.y - next.1 / 2.0), from_side, Side::Auto) + } None => (to_at, from_side, to_side), }; let (routing, author, page) = (s.tool.board.routing, author(s), s.page()?); diff --git a/crates/ui-egui/src/board_connect_tests.rs b/crates/ui-egui/src/board_connect_tests.rs index f3e4dc612..7d109dbb3 100644 --- a/crates/ui-egui/src/board_connect_tests.rs +++ b/crates/ui-egui/src/board_connect_tests.rs @@ -193,3 +193,46 @@ fn dropping_a_handle_on_another_shape_joins_them() { let line = doc.ids().find(|i| matches!(doc.node(*i).unwrap().board, Some(BoardItem::Connector(_)))).expect("a connector"); assert!(matches!(&doc.node(line).unwrap().board, Some(BoardItem::Connector(c)) if c.from.node() == Some(a) && c.to.node() == Some(b))); } + +/// A sticky or shape inside a section or frame takes the drop too (review): the connector joins it. +#[test] +fn dropping_a_handle_on_a_shape_inside_a_frame_joins_it() { + let (mut u, a) = board_with_shape(); + let f = id(&u.app.session.execute("frame.create", &json!({"x": 300, "y": 200, "width": 500, "height": 400})).unwrap()); + let b = id(&u + .app + .session + .execute("board.shape", &json!({"shape": "ellipse", "x": 100, "y": 100, "width": 160, "height": 100, "parent": f})) + .unwrap()); + u.app.session.execute("select.set", &json!({"ids": [a]})).unwrap(); + u.frame(vec![]); + u.frame(vec![]); + let from = handle(&u, "right").expect("a handle right").center(); + let to = screen_box(&u, b).center(); + u.drag_to(from, to); + u.button(to, false); + u.frame(vec![]); + let doc = u.app.session.doc().unwrap(); + let line = doc.ids().find(|i| matches!(doc.node(*i).unwrap().board, Some(BoardItem::Connector(_)))).expect("a connector"); + assert!( + matches!(&doc.node(line).unwrap().board, Some(BoardItem::Connector(c)) if c.from.node() == Some(a) && c.to.node() == Some(b)), + "joined to the shape in the frame, not the frame" + ); +} + +/// A handle let go off the canvas, over a panel, makes nothing (review). +#[test] +fn letting_a_handle_go_over_a_panel_makes_nothing() { + let (mut u, a) = board_with_shape(); + u.app.session.execute("select.set", &json!({"ids": [a]})).unwrap(); + u.frame(vec![]); + u.frame(vec![]); + let before = u.app.session.doc().unwrap().ids().count(); + let from = handle(&u, "left").expect("a handle left").center(); + // The left sidebar. + let to = Pos2::new(u.app.canvas.rect.min.x - 60.0, from.y); + u.drag_to(from, to); + u.button(to, false); + u.frame(vec![]); + assert_eq!(u.app.session.doc().unwrap().ids().count(), before, "nothing made"); +} diff --git a/crates/ui-egui/src/canvas/board_connect.rs b/crates/ui-egui/src/canvas/board_connect.rs index aaac45af9..4ea0d9a4d 100644 --- a/crates/ui-egui/src/canvas/board_connect.rs +++ b/crates/ui-egui/src/canvas/board_connect.rs @@ -2,12 +2,13 @@ //! where the next one goes; clicking it makes the next of the same kind there, joined by a //! connector, and starts typing in it (`board.addConnected`). Dragging one carries the preview //! ("drag the preview to any location on your board", #1919): let go on empty board and the next -//! one is made there, joined; let go on another sticky or shape and a connector joins the two. +//! one is made there, joined by a connector leaving by the handle's side; let go on another sticky +//! or shape (inside a section too) and a connector joins the two; let go off the canvas, nothing. use egui::{Area, Color32, CornerRadius, Id, LayerId, Order, Pos2, Rect, Sense, Shape, Stroke, StrokeKind, pos2, vec2}; use figcraft_doc::{BoardItem, NodeId}; use figcraft_engine::ToolId; -use figcraft_engine::board::{STICKY, connected_place, object_at}; +use figcraft_engine::board::{STICKY, connected_place, sticky_or_shape_at}; use serde_json::json; use crate::FigApp; @@ -149,9 +150,16 @@ pub fn show(app: &mut FigApp, ctx: &egui::Context) { let Some(Drag { from, side }) = drag.filter(|d| d.from == id) else { return }; let Some(pointer) = ctx.input(|i| i.pointer.latest_pos()) else { return }; let over = object_under(app, from, pointer); - drag_preview(app, ctx, (b, next, side), pointer, over); + // Off the canvas (over a panel) there is nothing to show and nothing to make. + let on_canvas = app.canvas.rect.contains(pointer); + if on_canvas { + drag_preview(app, ctx, (b, next, side), pointer, over); + } if let_go { ctx.data_mut(|d| d.remove::(drag_id())); + if !on_canvas { + return; + } match over { Some(to) => { app.run("board.connector", json!({"from": from, "to": to, "fromSide": connector_side(side)})); @@ -167,13 +175,14 @@ pub fn show(app: &mut FigApp, ctx: &egui::Context) { } } -/// The sticky, shape or other object under the screen point `p` on the canvas, other than `except`. +/// The sticky or shape under the screen point `p` on the canvas (inside a section or frame too), +/// other than `except`. fn object_under(app: &FigApp, except: NodeId, p: Pos2) -> Option { if !app.canvas.rect.contains(p) { return None; } let ds = app.session.ds().ok()?; - object_at(&ds.doc, ds.page, app.to_page(p), Some(except)) + sticky_or_shape_at(&ds.doc, ds.page, app.to_page(p), Some(except)) } /// Where the next one goes for `side`, faintly: its box and the connector's line to it. diff --git a/docs/boards-parity.md b/docs/boards-parity.md index dd14d1b9f..115885f0b 100644 --- a/docs/boards-parity.md +++ b/docs/boards-parity.md @@ -38,13 +38,13 @@ all end with the same geometry. | Shapes with text | done | 23 outlines: rectangle, rounded rectangle, ellipse, diamond, triangle up and down, parallelogram right and left, trapezoid, pentagon, hexagon, octagon, star, plus, arrow left and right, chevron, speech bubble, and the flowchart symbols database, document, predefined process, manual input and internal storage; text centred and wrapping inside the outline; shape type and text size from the contextual bar | | Shape auto-fit to its text, the advanced shape libraries (engineering and other icon shapes) | missing | | | Connectors | done | from a layer's side (the facing one, or one named) to another layer or a free point, straight, elbow or curved, arrowheads (the stroke's caps), a label in the middle of the route by length (double-click to add); while one is dragged out it shows as it will be made (route, line and arrowhead), the object under the pointer outlined with its four attach points (side middles), the one the end goes to ringed, and within 10 px of one the end keeps that side; re-routed when either end moves or resizes; a deleted end stays where it was | -| Create the next shape already connected | done | a selected sticky or shape shows a "+" beside each side; hovering one shows where the next goes, clicking makes one of the same kind, size and colour there, joined by a connector as the Connector tool makes one, and starts typing in it; one undo step (`board.addConnected {id?, side?, edit?}`, #1597). Shift+Cmd/Ctrl+Enter on a selected (or edited) shape adds the next shape on its right, joined the same way, and goes on typing; on a sticky it adds a sticky beside it without a connector, as before. Dragging a "+" carries the preview ("drag the preview to any location on your board"): let go on empty board and the next one is made there, centred on the pointer, joined by a connector whose ends take the sides facing each other (`at: [x, y]`); let go on another sticky or shape and a connector joins the two instead, the object outlined while over it (`board_connect_tests`, #1919) | +| Create the next shape already connected | done | a selected sticky or shape shows a "+" beside each side; hovering one shows where the next goes, clicking makes one of the same kind, size and colour there, joined by a connector as the Connector tool makes one, and starts typing in it; one undo step (`board.addConnected {id?, side?, edit?}`, #1597). Shift+Cmd/Ctrl+Enter on a selected (or edited) shape adds the next shape on its right, joined the same way, and goes on typing; on a sticky it adds a sticky beside it without a connector, as before. Dragging a "+" carries the preview ("drag the preview to any location on your board"): let go on empty board and the next one is made there, centred on the pointer, joined by a connector leaving by the handle's side (`at: [x, y]`, a point of the page); let go on another sticky or shape, inside a section too, and a connector joins the two instead, the object outlined while over it; let go off the canvas, nothing (`board_connect_tests`, #1919) | | Curved connectors, elbows around objects, dragging an end to re-attach | done | `board.setStyle {style: curved}` (and the contextual bar): one curve leaving and arriving along the sides; an elbow whose short way would cross what it joins goes around their boxes, 24 units clear; a selected connector shows its two ends as handles, and dragging one onto an object attaches it there (the object is outlined while dragging), onto empty canvas leaves it free (`board.reattach {id, end, target, side?}`, one undo step) | | A connector end on any part of an object | done | holding Cmd/Ctrl while moving an end places it where the pointer is on the object, as a share of its box, so it follows moves and resizes; the line leaves by the side facing the other end. Without the key an end snaps to a side | | Connector paths reshaped by hand | done | a selected elbow or curved connector shows path handles: one on each run long enough to take one, one in the middle of a curve. Dragging a run moves it, and a first or last run gains an extra run to stay on its end; a curve's middle goes where it is dragged (`board.reshape`, one undo step). The shape travels with what the connector joins and is saved with the file; changing the style or moving an end to something else goes back to routing itself. No way back by itself otherwise: the public help describes none | -| Quick-create handles (drag out a connected copy) | missing | | +| Quick-create handles (drag out a connected copy) | done | a "+" dragged carries the preview: the next one is made where it is let go, joined; or a connector joins the sticky or shape it is let go on (#1919) | | Connector waypoints placed by hand | missing | routes are computed from the ends; no bend points of your own | -| Quick-create handles | partial | a "+" beside each side of the one selected sticky or shape makes the next one there, joined by a connector (`board.addConnected`, also Shift+Cmd/Ctrl+Enter); no dragging a handle out to place it | +| Quick-create handles | done | a "+" beside each side of the one selected sticky or shape makes the next one there, joined by a connector (`board.addConnected`, also Shift+Cmd/Ctrl+Enter); dragged, it places the next one where it is let go, or joins the sticky or shape it is let go on (#1919) | | Marker and highlighter | done | the Pencil's stroke fitting with board presets: marker opaque, highlighter wide, see-through and multiplying | | Eraser | done | drag over marker and highlighter strokes to remove them, one undo step | | Pen colours and widths in the toolbar | partial | `tool.marker {color}`, `tool.highlighter {color}`; colour changes on a selected stroke from the contextual bar | @@ -70,7 +70,7 @@ all end with the same geometry. | Date | Change | Summary | |---|---|---| -| 2026-11-03 | minor | M12, #1919: as the quick create help says ("Click to select and create the next shape in that direction, or drag the preview to any location on your board"; "A new shape is created with a connector and its text field active"), a "+" beside the selected sticky or shape can be dragged: the preview follows the pointer and, let go on empty board, the next one is made there, centred on the pointer and joined by a connector whose ends take the sides facing each other (`board.addConnected` gains `at: [x, y]`); let go on another sticky or shape, a connector joins the two instead (`board.connector`), that object outlined while the pointer is over it. The click is as before. A shape picker on drop and choosing the connector type are not done (the help doesn't describe them). Tests: `board_connect_tests` (two), engine `board_connected_tests::the_next_one_goes_where_it_is_dropped`. Numbers unchanged. | +| 2026-11-03 | minor | M12, #1919: as the quick create help says ("Click to select and create the next shape in that direction, or drag the preview to any location on your board"; "A new shape is created with a connector and its text field active"), a "+" beside the selected sticky or shape can be dragged: the preview follows the pointer and, let go on empty board, the next one is made there, centred on the pointer, and joined by a connector leaving by the handle's side and arriving by the side facing it (`board.addConnected` gains `at: [x, y]`, a point of the page placed in the parent's coordinates); let go on another sticky or shape, inside a section or frame too (`board::sticky_or_shape_at`), a connector joins the two instead (`board.connector`), that object outlined while the pointer is over it; let go off the canvas, nothing. The click is as before. A shape picker on drop and choosing the connector type are not done (the help doesn't describe them). Tests: `board_connect_tests` (two), engine `board_connected_tests::the_next_one_goes_where_it_is_dropped`. Numbers unchanged. | | 2026-10-31 | minor | M12: as the help describes, holding Cmd/Ctrl while moving a connector's end places it on any part of an object instead of snapping to a side. It keeps that spot as a fraction of the object's box, so it follows the object when it moves or resizes, and without the key an end snaps as before. `board.connector {fromAt, toAt}` and `board.reattach {at}` take it; saved only when set. Numbers unchanged | | 2026-10-31 | patch | M12, #1708: a connector end dropped on the outer half of a shape takes the side it is towards, instead of only within 10 px of a side's middle, so a drop anywhere along an edge chooses that edge (dragging a selected connector's end and with the connector tool, ring included); a drop in the middle of a shape still takes the facing side. | | 2026-10-31 | minor | M12, #1710: a selected elbow or curved connector shows path handles. Dragging a run moves it and a first or last run gains an extra run to stay on its end; a curve's middle goes where it is dragged (`board.reshape`, one undo step). The shape travels with what the connector joins, is saved with the file, and goes back to routing itself when the style changes or an end moves to something else. | From 96ef28cc67f56421b71b615022a3b6728d29978a Mon Sep 17 00:00:00 2001 From: Trevor Brown Date: Tue, 3 Nov 2026 13:42:03 -0500 Subject: [PATCH 6/9] M12: quick-create drag ends when the selection moves; no drop on the toolbar (#1919) Review: a drag whose object is no longer the selected one is dropped from egui's data at once (it lingered when the selection moved to another sticky or shape and could still act once the first was selected again); a handle let go over the floating toolbar, which lies inside the canvas rectangle, makes nothing, like one let go over a panel. Tests: a_drag_ends_when_the_selection_moves_to_another_shape, letting_a_handle_go_over_the_toolbar_makes_nothing. Co-Authored-By: Claude Fable 5.1 --- crates/ui-egui/src/board_connect_tests.rs | 39 ++++++++++++++++++++++ crates/ui-egui/src/canvas/board_connect.rs | 12 +++++-- 2 files changed, 48 insertions(+), 3 deletions(-) diff --git a/crates/ui-egui/src/board_connect_tests.rs b/crates/ui-egui/src/board_connect_tests.rs index 7d109dbb3..b6466a9ff 100644 --- a/crates/ui-egui/src/board_connect_tests.rs +++ b/crates/ui-egui/src/board_connect_tests.rs @@ -236,3 +236,42 @@ fn letting_a_handle_go_over_a_panel_makes_nothing() { u.frame(vec![]); assert_eq!(u.app.session.doc().unwrap().ids().count(), before, "nothing made"); } + +/// A handle let go over the floating toolbar at the bottom of the canvas makes nothing either +/// (review): the toolbar lies inside the canvas rectangle. +#[test] +fn letting_a_handle_go_over_the_toolbar_makes_nothing() { + let (mut u, a) = board_with_shape(); + u.app.session.execute("select.set", &json!({"ids": [a]})).unwrap(); + u.frame(vec![]); + u.frame(vec![]); + let before = u.app.session.doc().unwrap().ids().count(); + let from = handle(&u, "below").expect("a handle below").center(); + let to = crate::toolbar::pill_rect(u.app.canvas.rect, crate::toolbar::bar_width(&u.app)).center(); + u.drag_to(from, to); + u.button(to, false); + u.frame(vec![]); + assert_eq!(u.app.session.doc().unwrap().ids().count(), before, "nothing made behind the toolbar"); +} + +/// The selection moving to another shape under a drag ends the drag (review): letting go later, +/// even with the first shape selected again, makes nothing. +#[test] +fn a_drag_ends_when_the_selection_moves_to_another_shape() { + let (mut u, a) = board_with_shape(); + let b = id(&u.app.session.execute("board.shape", &json!({"shape": "ellipse", "x": 600, "y": 0, "width": 160, "height": 100})).unwrap()); + u.app.session.execute("select.set", &json!({"ids": [a]})).unwrap(); + u.frame(vec![]); + u.frame(vec![]); + let before = u.app.session.doc().unwrap().ids().count(); + let from = handle(&u, "below").expect("a handle below").center(); + let to = from + egui::vec2(0.0, 160.0); + u.drag_to(from, to); + u.app.session.execute("select.set", &json!({"ids": [b]})).unwrap(); + u.frame(vec![Event::PointerMoved(to)]); + u.app.session.execute("select.set", &json!({"ids": [a]})).unwrap(); + u.frame(vec![Event::PointerMoved(to)]); + u.button(to, false); + u.frame(vec![]); + assert_eq!(u.app.session.doc().unwrap().ids().count(), before, "the drag was over"); +} diff --git a/crates/ui-egui/src/canvas/board_connect.rs b/crates/ui-egui/src/canvas/board_connect.rs index 4ea0d9a4d..b78946ef3 100644 --- a/crates/ui-egui/src/canvas/board_connect.rs +++ b/crates/ui-egui/src/canvas/board_connect.rs @@ -147,11 +147,17 @@ pub fn show(app: &mut FigApp, ctx: &egui::Context) { } // A drag carries the preview: the next one centred on the pointer, or the object under it, // which the connector joins instead. - let Some(Drag { from, side }) = drag.filter(|d| d.from == id) else { return }; + let Some(Drag { from, side }) = drag else { return }; + // The selection moved to another sticky or shape under the drag: it is over too. + if from != id { + ctx.data_mut(|d| d.remove::(drag_id())); + return; + } let Some(pointer) = ctx.input(|i| i.pointer.latest_pos()) else { return }; let over = object_under(app, from, pointer); - // Off the canvas (over a panel) there is nothing to show and nothing to make. - let on_canvas = app.canvas.rect.contains(pointer); + // Off the canvas (over a panel) or over the floating toolbar there is nothing to show and + // nothing to make. + let on_canvas = app.canvas.rect.contains(pointer) && !toolbar.contains(pointer); if on_canvas { drag_preview(app, ctx, (b, next, side), pointer, over); } From 5eb28b310adb6ac9872e69fee0d926198768eea6 Mon Sep 17 00:00:00 2001 From: Trevor Brown Date: Tue, 3 Nov 2026 14:47:46 -0500 Subject: [PATCH 7/9] M12: the bar above the selection stays away while a quick-create handle is dragged (#1919) Review: letting a handle go over the selection bar made the next shape behind it. The bar hides while a "+" is dragged, as it does for any drag (board_connect::dragging), so there is nothing to drop behind; the drop makes the next one where the bar was, and the bar is back once typing in it ends. Test the_bar_stays_away_while_a_handle_is_dragged; the docs rows say the toolbar and the bar. Co-Authored-By: Claude Fable 5.1 --- crates/ui-egui/src/board_connect_tests.rs | 34 ++++++++++++++++++++++ crates/ui-egui/src/canvas/board_bar.rs | 5 ++-- crates/ui-egui/src/canvas/board_connect.rs | 9 +++++- docs/boards-parity.md | 4 +-- 4 files changed, 47 insertions(+), 5 deletions(-) diff --git a/crates/ui-egui/src/board_connect_tests.rs b/crates/ui-egui/src/board_connect_tests.rs index b6466a9ff..fffa1f61c 100644 --- a/crates/ui-egui/src/board_connect_tests.rs +++ b/crates/ui-egui/src/board_connect_tests.rs @@ -34,6 +34,12 @@ fn handle(u: &Ui, side: &str) -> Option { u.ctx.memory(|m| m.areas().visible_last_frame(&layer)).then(|| u.ctx.memory(|m| m.area_rect(layer.id))).flatten() } +/// Where the bar above the selection shows, if it does. +fn bar(u: &Ui) -> Option { + let layer = LayerId::new(Order::Middle, Id::unique("board_bar")); + u.ctx.memory(|m| m.areas().visible_last_frame(&layer)).then(|| u.ctx.memory(|m| m.area_rect(layer.id))).flatten() +} + fn click(u: &mut Ui, p: Pos2) { for pressed in [true, false] { u.frame(vec![Event::PointerMoved(p), Event::PointerButton { pos: p, button: PointerButton::Primary, pressed, modifiers: Modifiers::NONE }]); @@ -275,3 +281,31 @@ fn a_drag_ends_when_the_selection_moves_to_another_shape() { u.frame(vec![]); assert_eq!(u.app.session.doc().unwrap().ids().count(), before, "the drag was over"); } + +/// The bar above the selection stays away while a handle is dragged, as for any drag (review): +/// letting go where it was makes the next one there, not behind it, and the bar is back after. +#[test] +fn the_bar_stays_away_while_a_handle_is_dragged() { + let (mut u, a) = board_with_shape(); + u.app.session.execute("select.set", &json!({"ids": [a]})).unwrap(); + u.frame(vec![]); + u.frame(vec![]); + let r = bar(&u).expect("the bar shows"); + let from = handle(&u, "above").expect("a handle above").center(); + let to = r.center(); + u.drag_to(from, to); + assert!(bar(&u).is_none(), "no bar while a handle is dragged"); + u.button(to, false); + u.frame(vec![]); + let doc = u.app.session.doc().unwrap(); + let next = doc.ids().find(|i| *i != a && matches!(doc.node(*i).unwrap().board, Some(BoardItem::Shape { .. }))).expect("a new shape"); + let line = doc.ids().find(|i| matches!(doc.node(*i).unwrap().board, Some(BoardItem::Connector(_)))).expect("a connector"); + let centre = screen_box(&u, next).center(); + assert!((centre - to).length() < 1.0, "centred where the bar was: {centre:?}, not {to:?}"); + assert!(matches!(&doc.node(line).unwrap().board, Some(BoardItem::Connector(c)) if c.from.node() == Some(a) && c.to.node() == Some(next))); + // Typing in the new one keeps the bar away, as before; done typing, it is back. + figcraft_engine::textedit::end(&mut u.app.session).unwrap(); + u.frame(vec![]); + u.frame(vec![]); + assert!(bar(&u).is_some(), "the bar is back for the new selection"); +} diff --git a/crates/ui-egui/src/canvas/board_bar.rs b/crates/ui-egui/src/canvas/board_bar.rs index f9a43935c..d85f14901 100644 --- a/crates/ui-egui/src/canvas/board_bar.rs +++ b/crates/ui-egui/src/canvas/board_bar.rs @@ -191,10 +191,11 @@ pub(crate) fn place(sel: Rect, size: egui::Vec2, canvas: Rect) -> Pos2 { pos2(cx - w / 2.0, y) } -/// The bar above a board's selection, while nothing is being dragged and the file can be edited. +/// The bar above a board's selection, while nothing is being dragged (a "+" handle included) and +/// the file can be edited. pub fn show(app: &mut FigApp, ctx: &egui::Context) { let editable = app.session.active_read_only().is_none(); - if app.session.tool.busy() || !editable || !app.session.doc().is_ok_and(figcraft_engine::board::is_board) { + if app.session.tool.busy() || !editable || !app.session.doc().is_ok_and(figcraft_engine::board::is_board) || crate::board_connect::dragging(ctx) { return; } let Some(h) = has(app) else { return }; diff --git a/crates/ui-egui/src/canvas/board_connect.rs b/crates/ui-egui/src/canvas/board_connect.rs index b78946ef3..ea96e922a 100644 --- a/crates/ui-egui/src/canvas/board_connect.rs +++ b/crates/ui-egui/src/canvas/board_connect.rs @@ -3,7 +3,8 @@ //! connector, and starts typing in it (`board.addConnected`). Dragging one carries the preview //! ("drag the preview to any location on your board", #1919): let go on empty board and the next //! one is made there, joined by a connector leaving by the handle's side; let go on another sticky -//! or shape (inside a section too) and a connector joins the two; let go off the canvas, nothing. +//! or shape (inside a section too) and a connector joins the two; let go off the canvas or over the +//! toolbar, nothing. The bar above the selection stays away while a "+" is dragged, as for any drag. use egui::{Area, Color32, CornerRadius, Id, LayerId, Order, Pos2, Rect, Sense, Shape, Stroke, StrokeKind, pos2, vec2}; use figcraft_doc::{BoardItem, NodeId}; @@ -55,6 +56,12 @@ pub(crate) fn shown(app: &FigApp) -> bool { target(app).is_some() } +/// A "+" is being dragged: the bar above the selection stays away meanwhile, as for any drag, so +/// nothing is made behind it. +pub(crate) fn dragging(ctx: &egui::Context) -> bool { + ctx.data(|d| d.get_temp::(drag_id())).is_some() +} + /// The centre of the "+" for `side` of the object's screen box `r`. fn handle_at(r: Rect, side: &str) -> Pos2 { match side { diff --git a/docs/boards-parity.md b/docs/boards-parity.md index 115885f0b..2ea4f6e95 100644 --- a/docs/boards-parity.md +++ b/docs/boards-parity.md @@ -38,7 +38,7 @@ all end with the same geometry. | Shapes with text | done | 23 outlines: rectangle, rounded rectangle, ellipse, diamond, triangle up and down, parallelogram right and left, trapezoid, pentagon, hexagon, octagon, star, plus, arrow left and right, chevron, speech bubble, and the flowchart symbols database, document, predefined process, manual input and internal storage; text centred and wrapping inside the outline; shape type and text size from the contextual bar | | Shape auto-fit to its text, the advanced shape libraries (engineering and other icon shapes) | missing | | | Connectors | done | from a layer's side (the facing one, or one named) to another layer or a free point, straight, elbow or curved, arrowheads (the stroke's caps), a label in the middle of the route by length (double-click to add); while one is dragged out it shows as it will be made (route, line and arrowhead), the object under the pointer outlined with its four attach points (side middles), the one the end goes to ringed, and within 10 px of one the end keeps that side; re-routed when either end moves or resizes; a deleted end stays where it was | -| Create the next shape already connected | done | a selected sticky or shape shows a "+" beside each side; hovering one shows where the next goes, clicking makes one of the same kind, size and colour there, joined by a connector as the Connector tool makes one, and starts typing in it; one undo step (`board.addConnected {id?, side?, edit?}`, #1597). Shift+Cmd/Ctrl+Enter on a selected (or edited) shape adds the next shape on its right, joined the same way, and goes on typing; on a sticky it adds a sticky beside it without a connector, as before. Dragging a "+" carries the preview ("drag the preview to any location on your board"): let go on empty board and the next one is made there, centred on the pointer, joined by a connector leaving by the handle's side (`at: [x, y]`, a point of the page); let go on another sticky or shape, inside a section too, and a connector joins the two instead, the object outlined while over it; let go off the canvas, nothing (`board_connect_tests`, #1919) | +| Create the next shape already connected | done | a selected sticky or shape shows a "+" beside each side; hovering one shows where the next goes, clicking makes one of the same kind, size and colour there, joined by a connector as the Connector tool makes one, and starts typing in it; one undo step (`board.addConnected {id?, side?, edit?}`, #1597). Shift+Cmd/Ctrl+Enter on a selected (or edited) shape adds the next shape on its right, joined the same way, and goes on typing; on a sticky it adds a sticky beside it without a connector, as before. Dragging a "+" carries the preview ("drag the preview to any location on your board"): let go on empty board and the next one is made there, centred on the pointer, joined by a connector leaving by the handle's side (`at: [x, y]`, a point of the page); let go on another sticky or shape, inside a section too, and a connector joins the two instead, the object outlined while over it; let go off the canvas or over the toolbar, nothing, and the bar above the selection stays away meanwhile (`board_connect_tests`, #1919) | | Curved connectors, elbows around objects, dragging an end to re-attach | done | `board.setStyle {style: curved}` (and the contextual bar): one curve leaving and arriving along the sides; an elbow whose short way would cross what it joins goes around their boxes, 24 units clear; a selected connector shows its two ends as handles, and dragging one onto an object attaches it there (the object is outlined while dragging), onto empty canvas leaves it free (`board.reattach {id, end, target, side?}`, one undo step) | | A connector end on any part of an object | done | holding Cmd/Ctrl while moving an end places it where the pointer is on the object, as a share of its box, so it follows moves and resizes; the line leaves by the side facing the other end. Without the key an end snaps to a side | | Connector paths reshaped by hand | done | a selected elbow or curved connector shows path handles: one on each run long enough to take one, one in the middle of a curve. Dragging a run moves it, and a first or last run gains an extra run to stay on its end; a curve's middle goes where it is dragged (`board.reshape`, one undo step). The shape travels with what the connector joins and is saved with the file; changing the style or moving an end to something else goes back to routing itself. No way back by itself otherwise: the public help describes none | @@ -70,7 +70,7 @@ all end with the same geometry. | Date | Change | Summary | |---|---|---| -| 2026-11-03 | minor | M12, #1919: as the quick create help says ("Click to select and create the next shape in that direction, or drag the preview to any location on your board"; "A new shape is created with a connector and its text field active"), a "+" beside the selected sticky or shape can be dragged: the preview follows the pointer and, let go on empty board, the next one is made there, centred on the pointer, and joined by a connector leaving by the handle's side and arriving by the side facing it (`board.addConnected` gains `at: [x, y]`, a point of the page placed in the parent's coordinates); let go on another sticky or shape, inside a section or frame too (`board::sticky_or_shape_at`), a connector joins the two instead (`board.connector`), that object outlined while the pointer is over it; let go off the canvas, nothing. The click is as before. A shape picker on drop and choosing the connector type are not done (the help doesn't describe them). Tests: `board_connect_tests` (two), engine `board_connected_tests::the_next_one_goes_where_it_is_dropped`. Numbers unchanged. | +| 2026-11-03 | minor | M12, #1919: as the quick create help says ("Click to select and create the next shape in that direction, or drag the preview to any location on your board"; "A new shape is created with a connector and its text field active"), a "+" beside the selected sticky or shape can be dragged: the preview follows the pointer and, let go on empty board, the next one is made there, centred on the pointer, and joined by a connector leaving by the handle's side and arriving by the side facing it (`board.addConnected` gains `at: [x, y]`, a point of the page placed in the parent's coordinates); let go on another sticky or shape, inside a section or frame too (`board::sticky_or_shape_at`), a connector joins the two instead (`board.connector`), that object outlined while the pointer is over it; let go off the canvas or over the toolbar, nothing, and the bar above the selection stays away meanwhile, as for any drag. The click is as before. A shape picker on drop and choosing the connector type are not done (the help doesn't describe them). Tests: `board_connect_tests` (the drag ones), engine `board_connected_tests::the_next_one_goes_where_it_is_dropped`. Numbers unchanged. | | 2026-10-31 | minor | M12: as the help describes, holding Cmd/Ctrl while moving a connector's end places it on any part of an object instead of snapping to a side. It keeps that spot as a fraction of the object's box, so it follows the object when it moves or resizes, and without the key an end snaps as before. `board.connector {fromAt, toAt}` and `board.reattach {at}` take it; saved only when set. Numbers unchanged | | 2026-10-31 | patch | M12, #1708: a connector end dropped on the outer half of a shape takes the side it is towards, instead of only within 10 px of a side's middle, so a drop anywhere along an edge chooses that edge (dragging a selected connector's end and with the connector tool, ring included); a drop in the middle of a shape still takes the facing side. | | 2026-10-31 | minor | M12, #1710: a selected elbow or curved connector shows path handles. Dragging a run moves it and a first or last run gains an extra run to stay on its end; a curve's middle goes where it is dragged (`board.reshape`, one undo step). The shape travels with what the connector joins, is saved with the file, and goes back to routing itself when the style changes or an end moves to something else. | From 9aad73169324d1e2ca6dee90cb56efd5966511ca Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Wed, 4 Nov 2026 01:29:49 +0000 Subject: [PATCH 8/9] address review: use the request-reply timeout for the reply deadline --- crates/collab-net/src/manage.rs | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/crates/collab-net/src/manage.rs b/crates/collab-net/src/manage.rs index eecbca964..aa73a2ec5 100644 --- a/crates/collab-net/src/manage.rs +++ b/crates/collab-net/src/manage.rs @@ -209,7 +209,9 @@ fn reply(ws: &mut Ws, limits: &NetLimits, pick: impl Fn(ServerMsg) -> Option< // One deadline for the whole answer: pings, pongs and a message trickling in each renew the // read timeout, so without it a server could keep a request (and the refresh permit the // caller holds) waiting for as long as it liked. - let until = std::time::Instant::now() + limits.idle_timeout; + // The request-reply bound, not the session idle one: a publish uploads a whole file and can + // legitimately take minutes to be answered (see `connect`). + let until = std::time::Instant::now() + limits.request_reply_timeout; ws.get_mut().read_until(Some(until)); loop { if std::time::Instant::now() >= until { @@ -259,6 +261,27 @@ mod tests { rx.recv_timeout(Duration::from_secs(3)).is_ok() } + /// A server that keeps pinging and never answers ends the wait at the request-reply bound. + #[test] + fn reply_gives_up_at_the_request_reply_deadline_against_a_pinging_server() { + let listener = std::net::TcpListener::bind("127.0.0.1:0").unwrap(); + let addr = listener.local_addr().unwrap(); + std::thread::spawn(move || { + let (s, _) = listener.accept().unwrap(); + if let Ok(mut ws) = tungstenite::accept(s) { + while ws.send(Message::Ping(Bytes::new())).is_ok() { + std::thread::sleep(Duration::from_millis(10)); + } + } + }); + let limits = NetLimits { request_reply_timeout: Duration::from_millis(400), ..NetLimits::default() }; + let server = Endpoint { host: addr.to_string(), path: "/".into(), secure: false }; + let mut ws = connect(&server, &limits, Duration::from_secs(2)).unwrap(); + let started = std::time::Instant::now(); + assert!(reply::<()>(&mut ws, &limits, |_| None).is_err()); + assert!(started.elapsed() < Duration::from_secs(3), "{:?}", started.elapsed()); + } + /// A server that keeps pinging and never answers the close must not pin `close` forever. #[test] fn close_returns_against_a_server_that_keeps_pinging() { From 20f1219fbcd7550c01ff8ef668d7b4ff98bb06da Mon Sep 17 00:00:00 2001 From: Filip Strajnar Date: Fri, 6 Nov 2026 12:55:21 +0100 Subject: [PATCH 9/9] M1: Set default properties gives new shapes and text the layer's properties (#2028) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Edit ▸ Set default properties put the selected layer's properties into the Paste properties clipboard and did nothing else: a rectangle drawn afterwards was still the default grey, and what Copy properties had copied was replaced. The defaults are now kept apart (`Session::default_props`: one set for shapes, set from any layer but text, and one for text). Rectangles, ellipses, polygons and stars drawn or clicked with their tools take the shape defaults: fills, strokes and their settings, effects, opacity, blend and corners (only where the shape has corners), through `apply_copied_props`, the rules Paste properties already used (now shared). New text from the Text tool takes a text layer's fills and font and is laid out at that size. Frames, sections, slices, lines, arrows, vectors and layers made by commands keep their own look; the help center is silent on those. `edit.setDefaultProperties` answers `{for: shapes|text, properties}`. Tests: `default_props_tests::new_shapes_drawn_with_the_tools_take_the_default_properties`, `setting_defaults_leaves_the_copied_properties_alone`, `new_text_takes_a_text_layers_defaults_and_shapes_keep_theirs`. Docs: ui-parity.md, ROADMAP.md. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01LvG6E2LxvJ6MuFmiLA6Zqm --- ROADMAP.md | 3 +- crates/engine/src/canvas/tools/click.rs | 17 +++- crates/engine/src/canvas/tools/draw.rs | 11 +++ crates/engine/src/cmd/edit.rs | 27 ++++-- crates/engine/src/cmd/edit/clipboard.rs | 26 +++-- crates/engine/src/default_props_tests.rs | 117 +++++++++++++++++++++++ crates/engine/src/lib.rs | 6 +- crates/engine/src/prefs.rs | 12 +++ crates/engine/src/session/new.rs | 1 + docs/ui-parity.md | 4 +- 10 files changed, 200 insertions(+), 24 deletions(-) create mode 100644 crates/engine/src/default_props_tests.rs diff --git a/ROADMAP.md b/ROADMAP.md index 60f5962d2..29926e0c5 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -2,7 +2,7 @@ **Stage: alpha** · next: beta, ~26 points and ~162–292 h away (one Opus 5.5 agent; ~33–67 h wall-clock with 5 agents) -> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-02 · **Change:** minor (glass bends towards its core, and rounded rectangles work it out in closed form; glass's light is a line on its bevel and splay turns the bend towards the centre; glass bends with a thick-lens profile and splits its colours over 8 steps; glass effects take variables and keep their frost within 0–100; web host bridge: `?host=parent` or `data-host="page"` hands a page the app's files, documented in the hosting guide; a connector end moved with Cmd/Ctrl held goes on any part of an object, and stays there as the object moves or resizes; a tap on a plugin panel's button keeps what was typed in its fields; a Dash cap setting (none, round or square) on Dash and Custom strokes, drawn on both ends of every dash; library analytics list how many layers and files use each style and variable; the Controller menu names each button as PlayStation and Switch controllers do; widgets draw lines and SVG pictures (plugin API 6); a connector end dropped along a side of a shape attaches to that side (#1708); regression tests pin a rounded shape's one-sided stroke and SVG ids and font families without XML-forbidden characters (#1351, #1124); a damaged image is refused with a reason instead of showing as an empty box (#1474); an image copied in another app pastes again on the desktop, and in the browser for the first time (#492); SwiftUI and Compose code names a bound variable by its iOS or Android code syntax; 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 Frame tool's Phone presets have the iPhone 17 family (#1691); Show in folder works in the Flatpak build and selects the file on Linux (#1701); a dashed line starts and ends with a half-length dash, on the canvas and in exports; the Pages, Layers and Assets search fields keep their text in the middle of the field (#1703); a board connector's path can be reshaped by dragging its path handles (#1710); boards have 16 more shapes (arrows, polygons, star, plus and flowchart symbols), in pickers that lay them out in a grid; library analytics count insertions and show insertions and detachments over the past 30 days, 90 days or year; a stroke's Custom style takes a dash pattern of any length as a comma-separated list (#1681); a control request can set its own timeout, up to 10 minutes (`timeoutMs`; `figcraft-cli mcp --attach PORT --timeout SECONDS`) (#1696); gap 6: a widget opens its plugin's panel (plugin API 5), whose callbacks redraw it; the keyboard's Menu key opens the context menu, as Shift+F10 does; an Open link action can open in place of the prototype, with "Open in new tab" off (gap 15); a collection of this file can be extended (Extend collection on its row, `variable.extendCollection`), its extension following its edits at once, and extended collections extend again in the file; the eyedropper with Cmd/Ctrl+Shift makes a colour style or variable of what it picks; a live session's welcome sends the document compressed to clients that read it, about seven times smaller (#1665); a control request that times out says truthfully whether it was dropped or is still running and will take effect, and only screenshots and input blame the window (#1673); a board keeps earlier votes' results, listed newest first in Results and deleted one at a time; the object a stamp will stick to is outlined while the stamp tool is over it or a stamp is dragged over it, and board objects take no drops (gap 24); a server can list the files shared from it now for everyone who reaches it, Home ▸ Online shows them and their links carry no secret (`team_files`, part of #742); team library analytics count detached instances per component and file (gap 10); skipping the Open link notice by command is saved with the preferences at once (gap 15); a selected connector's bar on a board sets its start and end points, solid or dashed, its weight and any colour (#1596); cells copied from a spreadsheet paste onto a board as a table; a long layer name stays on one line in the Export button and the Dev Mode header, ending with an ellipsis, and no longer covers the Design panel (#1650); with hundreds of layers selected, the Design panel and the selection overlays stop going over the whole selection on every frame, so dragging 648 layers averages about 1.1 ms of UI per frame (#1571); plugin panels show pictures: an `image` control, base64 within 256 KB and 4,096 px a side, named by its label (gap 6); `.fig` connector labels without a saved snapshot are kept, centred on their line (gap 1); a drag moving many layers re-runs only what sits around them, not each layer's bindings, sizing, text and instance checks, on every move (#1571); damaged font tracking table offsets are checked instead of wrapping on 32-bit targets, and font indexing makes its existing offset bounds explicit (#1125); Bosnian (`bs`) draft catalog; text style dedupe is O(spans) via a last-two cache and fingerprint buckets (#1102); pasted layers whose image the clipboard lacks are named and show a placeholder that reads as missing (#1646); paint-style colours on layers pasted from another design app keep their style instead of turning black (#1638); progress docs cleaned of what merges left twice: rows merged into one, repeated status items removed, and `cargo xtask docs` (in `ci`) fails on a repeated table row or status item; a name typed for a variable or collection finds the one with that exact id before one named like it, and stored mode ids, font family variables and the panels' labels read exact ids (#1613); plugin widgets have hover styles: a layer's `hover` fill, stroke, opacity or text colour shows while the pointer is over it (gap 6); `.fig` elbowed and curved connectors without a saved path are routed like board connectors instead of drawn straight (gap 1); every file a command reads whole by path is a regular file within a cap that fits it: documents 16 GiB, placed images 256 MiB, CLI scripts 1 GiB; `figcraft-cli connect publish` publishes a code repository's code connect mappings to a design file (gap 16); while a drag only moves a large selection, its outlines, box, slots, spacing and Design panel values are worked out once and shifted, not rebuilt on every move (#1571); Shift+Cmd/Ctrl+Enter on a selected board shape adds the next shape already joined to it, and goes on typing (#1597); an imported or pasted file finds an installed family under the other names its fonts give it, and with other case and spacing, instead of reporting it missing (#1292); a development example generates figcraft-cli's shell completions and man pages from its clap definitions (part of #1396); `.fig` ZIP image reads share a total byte budget and count skipped images in the import warnings (#1076); German terminology corrections (M10): gradient stops, OpenType stylistic sets and the Home-screen preference; a component set's property rows fit the 240 px right panel: variant values wrap two to a line there and every + and − stays in view; the server key is checked by comparing SHA-256 hashes of the presented and the kept key, as the deployment guide says (#1130); opening a file contacts no team library server it names until you check it (#1097); a hostile server can no longer grow a client's memory with made-up people, and a session remembers a bounded number of deleted layer ids (#1121); `doc.list` gives AI agents and plugins the open files' names, not their paths (#1117); with a large selection, frames where nothing changed reuse the selection's outlines, box and slots and the Design panel's instance and position values instead of working them out again (#1571); team libraries and plugins larger than the 16 MiB download burst can be downloaded again, more slowly (#1089); a batch keeps one undo snapshot, not one per step (#1099); files nested 256 levels deep import on the browser's 1 MB stack (#1101); SVG and PDF exports count pattern sources and the renders they embed from the layer's depth, so one cap bounds a whole export (#1082); an explicit variables file path (`variable.import`, the `variables` of `file.open` and `file.import`) is refused past 256 MiB or when it isn't a regular file, as the sibling `variables.json` already was (part of #1114); joining and leaving a file nobody is editing reads and writes nothing on the server: it stays loaded a minute after everyone leaves (#1074); opening a `.figcraft` file unpacks at most 6 GiB in all (2 GiB in the browser), every area together (#1079); hovering the canvas hit-tests once per pointer move, not on every frame, and moving an auto layout frame no longer lays out its contents again on every move (#1571); `.fig` instance expansion no longer walks variable nodes for every instance or copies every outer override row into each nested instance (#1077); `comment.people` lists names that were only @mentioned, and `comment.next` and `comment.prompt` carry the mentions too (#1415); grid auto-placement looks for free cells a 64-bit word at a time and skips what blocks it, with the same placements (#1083); 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); a recovery copy made while a version is previewed holds the file, not the version shown; a FigJam `.jam` file opens as a board (#1342); 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); share links can comment: a third access level beside edit and view, whose holder sees the file live and adds, replies to, reacts to and resolves comments but can't change the design; Preferences ▸ Scroll wheel zoom: a mouse wheel zooms the canvas about the pointer and Cmd/Ctrl+wheel scrolls (#1390); `comment.list {mentions}` lists only the threads that @mention a name (#1415); in the browser an internal error that stops the page keeps its unsaved files, which open again on reload (#1123); boolean operations refuse input past their caps, and a boolean group past them draws without its result (#1104); figcraft-cli parses its arguments with clap, following RFC-0012 (#1396); the selection and hover outlines of rounded rectangles and frames follow their corners (#1506); component properties keep the order they were made in when one is renamed, and Make slot asks for the slot's name first (#1536, #1537); the browser build publishes files to a server, so Share ▸ Online and Publish to server work there (#917); the browser build uses the fonts installed on the computer once asked, each read when text uses it (#1051); SVG import reads `color()` and `color-mix()` colours, with a note and a grey for those it can't (#1550); the portable Windows zip keeps its settings, recovery copies and plugins in `config\` beside the executable, starting with an installed copy's preferences; the window starts on other graphics when its first ones fail before the first frame: Direct3D 12 compiles with FXC and no device compiles wgpu's indirect-validation shaders, then Vulkan, OpenGL and lower requirements on the power-saving GPU (#965, #1438); Thai, Lao, Khmer and Burmese lines break between words (#1219); an AI agent attached over MCP shows where it works (#1416); a manual overlay's position can be dragged on the canvas (#405); one name for live sessions and comments: Preferences ▸ Your name, in the Join dialog too, kept in the browser, and a rename shows at once in the sessions you are in (#1380); requests that change a server's files have a budget per address, the server key's too, and join codes are found by their hash (#1075); the Join dialog shows a join from the click until its file is ready, with Cancel, and a failed join with Try again (#1381); SVG import draws each pattern tile once per scale, within the layer budget (#1080); Vietnamese letters typed with combining marks (decomposed) take one font that has every mark, instead of missing-glyph boxes beside the letter (#1478); comment.list reports each message's @mentions (#1415); mask groups draw only over the area they can paint, and nested isolated layers share one memory budget (#1061); components can't contain their own instances, directly or through other components; `edit.duplicate` returns an id map with `map: true` (#995); the batches kept for reconnecting apps are bounded in bytes by default, and `figcraft-server` takes `max_log_mb` (#1069); MCP and control calls name their document (#998); sibling placement in live sessions searches instead of counting (#1065); an AI agent attached over MCP comments under its own name, with an Agent label (#1414); the instance-swap menus have a search field (#1338); a refused batch's fixes take time linear in the batch (#1063); the connector tool shows the connector it will make while dragging, ends snapping to attach points (#1387); large images on the canvas draw from a smaller copy, so two 16k images no longer lag (#1483); a file's JPEG thumbnail can't crash the home screen (#1491's progressive JPEG check, now shared); `.fig` import: library text styles linked by asset key, and override rows restating a nested level (#1234); `.fig` import keeps the file's saved line breaks while the text and its box are unedited (#1236); Download a missing free font from the Missing fonts window (`font.download`, #754); the web build's wasm back under its 24 MiB gate (#1472); shadows of images with transparent pixels follow their alpha (#1289); Crop image: Object ▸ Crop image, the right-click menu and the image fill row enter crop mode (`image.crop`, #1464); offline Penpot 2.x import/export (#1143); optional batch continue-on-error with per-step outcomes (#1386); the Design panel's sections on one grid (#858); FigJam outer shape outlines and sticky body fallback beside author text (#1341, #1397); images placed at their own size, 2x screenshots in points (#1360); the toolbar on one 32 pt grid, without its Resources button (#1210); M4: zero-length round-capped dashes draw dots; dash expansion uses the existing safety budget; extracted from #1143; Arabic draft catalog; scaled instances keep their scale when their main is rebuilt (#922); .fig embedded images are copied once per blob, not once per hash (#1059); page ruler guides survive save and reopen (#1476); colour picker LCH and OKLCH models; non-ASCII layer names transliterate in code export (#1235); branches in live sessions and branch history entries, gap 17; plugin widgets take text input and a property menu (plugin API 4); boards: templates and tables; boards: a shared timer and voting sessions; boards: the dot grid, connector ends dragged to re-attach, curved connectors; Installed weights of an embedded font family (#1246); `.sketch` import, best effort (Sketch 48 and newer); CJK line breaking: JIS X 4051's line-start and line-end sets completed with the halfwidth small kana, the halfwidth and spacing (semi-)voiced sound marks, the iteration marks 〱–〵 and the halfwidth parentheses, with behaviour cases for each; Adobe Fonts found on macOS (#298); egui 0.37 hidden-capture deadline contract; Dev Mode measurements kept on the canvas and a read-only layers panel; boards: a board area row and progress entry; community fixes in #507, #510, #529 and #530: auto-save, a text box by dragging, batch step references, removing someone from a live session, Russian and Turkish catalogs reviewed, Czech and Indonesian drafts, the Japanese draft completed, zoom previews, the web clipboard, Alt-drag snapping and Cmd+D repeat, recovery copies, crash and rollback fixes, colour emoji, `.fig` import fixes; earlier changes are in the revision history below) · **Target:** Figma Design (desktop app 126.10.7) +> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-06 · **Change:** patch (Edit ▸ Set default properties now gives new shapes and text drawn with the tools the selected layer's fills, strokes, effects, opacity and corners (text: its font) instead of only copying them for Paste properties (#2028); glass bends towards its core, and rounded rectangles work it out in closed form; glass's light is a line on its bevel and splay turns the bend towards the centre; glass bends with a thick-lens profile and splits its colours over 8 steps; glass effects take variables and keep their frost within 0–100; web host bridge: `?host=parent` or `data-host="page"` hands a page the app's files, documented in the hosting guide; a connector end moved with Cmd/Ctrl held goes on any part of an object, and stays there as the object moves or resizes; a tap on a plugin panel's button keeps what was typed in its fields; a Dash cap setting (none, round or square) on Dash and Custom strokes, drawn on both ends of every dash; library analytics list how many layers and files use each style and variable; the Controller menu names each button as PlayStation and Switch controllers do; widgets draw lines and SVG pictures (plugin API 6); a connector end dropped along a side of a shape attaches to that side (#1708); regression tests pin a rounded shape's one-sided stroke and SVG ids and font families without XML-forbidden characters (#1351, #1124); a damaged image is refused with a reason instead of showing as an empty box (#1474); an image copied in another app pastes again on the desktop, and in the browser for the first time (#492); SwiftUI and Compose code names a bound variable by its iOS or Android code syntax; 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 Frame tool's Phone presets have the iPhone 17 family (#1691); Show in folder works in the Flatpak build and selects the file on Linux (#1701); a dashed line starts and ends with a half-length dash, on the canvas and in exports; the Pages, Layers and Assets search fields keep their text in the middle of the field (#1703); a board connector's path can be reshaped by dragging its path handles (#1710); boards have 16 more shapes (arrows, polygons, star, plus and flowchart symbols), in pickers that lay them out in a grid; library analytics count insertions and show insertions and detachments over the past 30 days, 90 days or year; a stroke's Custom style takes a dash pattern of any length as a comma-separated list (#1681); a control request can set its own timeout, up to 10 minutes (`timeoutMs`; `figcraft-cli mcp --attach PORT --timeout SECONDS`) (#1696); gap 6: a widget opens its plugin's panel (plugin API 5), whose callbacks redraw it; the keyboard's Menu key opens the context menu, as Shift+F10 does; an Open link action can open in place of the prototype, with "Open in new tab" off (gap 15); a collection of this file can be extended (Extend collection on its row, `variable.extendCollection`), its extension following its edits at once, and extended collections extend again in the file; the eyedropper with Cmd/Ctrl+Shift makes a colour style or variable of what it picks; a live session's welcome sends the document compressed to clients that read it, about seven times smaller (#1665); a control request that times out says truthfully whether it was dropped or is still running and will take effect, and only screenshots and input blame the window (#1673); a board keeps earlier votes' results, listed newest first in Results and deleted one at a time; the object a stamp will stick to is outlined while the stamp tool is over it or a stamp is dragged over it, and board objects take no drops (gap 24); a server can list the files shared from it now for everyone who reaches it, Home ▸ Online shows them and their links carry no secret (`team_files`, part of #742); team library analytics count detached instances per component and file (gap 10); skipping the Open link notice by command is saved with the preferences at once (gap 15); a selected connector's bar on a board sets its start and end points, solid or dashed, its weight and any colour (#1596); cells copied from a spreadsheet paste onto a board as a table; a long layer name stays on one line in the Export button and the Dev Mode header, ending with an ellipsis, and no longer covers the Design panel (#1650); with hundreds of layers selected, the Design panel and the selection overlays stop going over the whole selection on every frame, so dragging 648 layers averages about 1.1 ms of UI per frame (#1571); plugin panels show pictures: an `image` control, base64 within 256 KB and 4,096 px a side, named by its label (gap 6); `.fig` connector labels without a saved snapshot are kept, centred on their line (gap 1); a drag moving many layers re-runs only what sits around them, not each layer's bindings, sizing, text and instance checks, on every move (#1571); damaged font tracking table offsets are checked instead of wrapping on 32-bit targets, and font indexing makes its existing offset bounds explicit (#1125); Bosnian (`bs`) draft catalog; text style dedupe is O(spans) via a last-two cache and fingerprint buckets (#1102); pasted layers whose image the clipboard lacks are named and show a placeholder that reads as missing (#1646); paint-style colours on layers pasted from another design app keep their style instead of turning black (#1638); progress docs cleaned of what merges left twice: rows merged into one, repeated status items removed, and `cargo xtask docs` (in `ci`) fails on a repeated table row or status item; a name typed for a variable or collection finds the one with that exact id before one named like it, and stored mode ids, font family variables and the panels' labels read exact ids (#1613); plugin widgets have hover styles: a layer's `hover` fill, stroke, opacity or text colour shows while the pointer is over it (gap 6); `.fig` elbowed and curved connectors without a saved path are routed like board connectors instead of drawn straight (gap 1); every file a command reads whole by path is a regular file within a cap that fits it: documents 16 GiB, placed images 256 MiB, CLI scripts 1 GiB; `figcraft-cli connect publish` publishes a code repository's code connect mappings to a design file (gap 16); while a drag only moves a large selection, its outlines, box, slots, spacing and Design panel values are worked out once and shifted, not rebuilt on every move (#1571); Shift+Cmd/Ctrl+Enter on a selected board shape adds the next shape already joined to it, and goes on typing (#1597); an imported or pasted file finds an installed family under the other names its fonts give it, and with other case and spacing, instead of reporting it missing (#1292); a development example generates figcraft-cli's shell completions and man pages from its clap definitions (part of #1396); `.fig` ZIP image reads share a total byte budget and count skipped images in the import warnings (#1076); German terminology corrections (M10): gradient stops, OpenType stylistic sets and the Home-screen preference; a component set's property rows fit the 240 px right panel: variant values wrap two to a line there and every + and − stays in view; the server key is checked by comparing SHA-256 hashes of the presented and the kept key, as the deployment guide says (#1130); opening a file contacts no team library server it names until you check it (#1097); a hostile server can no longer grow a client's memory with made-up people, and a session remembers a bounded number of deleted layer ids (#1121); `doc.list` gives AI agents and plugins the open files' names, not their paths (#1117); with a large selection, frames where nothing changed reuse the selection's outlines, box and slots and the Design panel's instance and position values instead of working them out again (#1571); team libraries and plugins larger than the 16 MiB download burst can be downloaded again, more slowly (#1089); a batch keeps one undo snapshot, not one per step (#1099); files nested 256 levels deep import on the browser's 1 MB stack (#1101); SVG and PDF exports count pattern sources and the renders they embed from the layer's depth, so one cap bounds a whole export (#1082); an explicit variables file path (`variable.import`, the `variables` of `file.open` and `file.import`) is refused past 256 MiB or when it isn't a regular file, as the sibling `variables.json` already was (part of #1114); joining and leaving a file nobody is editing reads and writes nothing on the server: it stays loaded a minute after everyone leaves (#1074); opening a `.figcraft` file unpacks at most 6 GiB in all (2 GiB in the browser), every area together (#1079); hovering the canvas hit-tests once per pointer move, not on every frame, and moving an auto layout frame no longer lays out its contents again on every move (#1571); `.fig` instance expansion no longer walks variable nodes for every instance or copies every outer override row into each nested instance (#1077); `comment.people` lists names that were only @mentioned, and `comment.next` and `comment.prompt` carry the mentions too (#1415); grid auto-placement looks for free cells a 64-bit word at a time and skips what blocks it, with the same placements (#1083); 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); a recovery copy made while a version is previewed holds the file, not the version shown; a FigJam `.jam` file opens as a board (#1342); 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); share links can comment: a third access level beside edit and view, whose holder sees the file live and adds, replies to, reacts to and resolves comments but can't change the design; Preferences ▸ Scroll wheel zoom: a mouse wheel zooms the canvas about the pointer and Cmd/Ctrl+wheel scrolls (#1390); `comment.list {mentions}` lists only the threads that @mention a name (#1415); in the browser an internal error that stops the page keeps its unsaved files, which open again on reload (#1123); boolean operations refuse input past their caps, and a boolean group past them draws without its result (#1104); figcraft-cli parses its arguments with clap, following RFC-0012 (#1396); the selection and hover outlines of rounded rectangles and frames follow their corners (#1506); component properties keep the order they were made in when one is renamed, and Make slot asks for the slot's name first (#1536, #1537); the browser build publishes files to a server, so Share ▸ Online and Publish to server work there (#917); the browser build uses the fonts installed on the computer once asked, each read when text uses it (#1051); SVG import reads `color()` and `color-mix()` colours, with a note and a grey for those it can't (#1550); the portable Windows zip keeps its settings, recovery copies and plugins in `config\` beside the executable, starting with an installed copy's preferences; the window starts on other graphics when its first ones fail before the first frame: Direct3D 12 compiles with FXC and no device compiles wgpu's indirect-validation shaders, then Vulkan, OpenGL and lower requirements on the power-saving GPU (#965, #1438); Thai, Lao, Khmer and Burmese lines break between words (#1219); an AI agent attached over MCP shows where it works (#1416); a manual overlay's position can be dragged on the canvas (#405); one name for live sessions and comments: Preferences ▸ Your name, in the Join dialog too, kept in the browser, and a rename shows at once in the sessions you are in (#1380); requests that change a server's files have a budget per address, the server key's too, and join codes are found by their hash (#1075); the Join dialog shows a join from the click until its file is ready, with Cancel, and a failed join with Try again (#1381); SVG import draws each pattern tile once per scale, within the layer budget (#1080); Vietnamese letters typed with combining marks (decomposed) take one font that has every mark, instead of missing-glyph boxes beside the letter (#1478); comment.list reports each message's @mentions (#1415); mask groups draw only over the area they can paint, and nested isolated layers share one memory budget (#1061); components can't contain their own instances, directly or through other components; `edit.duplicate` returns an id map with `map: true` (#995); the batches kept for reconnecting apps are bounded in bytes by default, and `figcraft-server` takes `max_log_mb` (#1069); MCP and control calls name their document (#998); sibling placement in live sessions searches instead of counting (#1065); an AI agent attached over MCP comments under its own name, with an Agent label (#1414); the instance-swap menus have a search field (#1338); a refused batch's fixes take time linear in the batch (#1063); the connector tool shows the connector it will make while dragging, ends snapping to attach points (#1387); large images on the canvas draw from a smaller copy, so two 16k images no longer lag (#1483); a file's JPEG thumbnail can't crash the home screen (#1491's progressive JPEG check, now shared); `.fig` import: library text styles linked by asset key, and override rows restating a nested level (#1234); `.fig` import keeps the file's saved line breaks while the text and its box are unedited (#1236); Download a missing free font from the Missing fonts window (`font.download`, #754); the web build's wasm back under its 24 MiB gate (#1472); shadows of images with transparent pixels follow their alpha (#1289); Crop image: Object ▸ Crop image, the right-click menu and the image fill row enter crop mode (`image.crop`, #1464); offline Penpot 2.x import/export (#1143); optional batch continue-on-error with per-step outcomes (#1386); the Design panel's sections on one grid (#858); FigJam outer shape outlines and sticky body fallback beside author text (#1341, #1397); images placed at their own size, 2x screenshots in points (#1360); the toolbar on one 32 pt grid, without its Resources button (#1210); M4: zero-length round-capped dashes draw dots; dash expansion uses the existing safety budget; extracted from #1143; Arabic draft catalog; scaled instances keep their scale when their main is rebuilt (#922); .fig embedded images are copied once per blob, not once per hash (#1059); page ruler guides survive save and reopen (#1476); colour picker LCH and OKLCH models; non-ASCII layer names transliterate in code export (#1235); branches in live sessions and branch history entries, gap 17; plugin widgets take text input and a property menu (plugin API 4); boards: templates and tables; boards: a shared timer and voting sessions; boards: the dot grid, connector ends dragged to re-attach, curved connectors; Installed weights of an embedded font family (#1246); `.sketch` import, best effort (Sketch 48 and newer); CJK line breaking: JIS X 4051's line-start and line-end sets completed with the halfwidth small kana, the halfwidth and spacing (semi-)voiced sound marks, the iteration marks 〱–〵 and the halfwidth parentheses, with behaviour cases for each; Adobe Fonts found on macOS (#298); egui 0.37 hidden-capture deadline contract; Dev Mode measurements kept on the canvas and a read-only layers panel; boards: a board area row and progress entry; community fixes in #507, #510, #529 and #530: auto-save, a text box by dragging, batch step references, removing someone from a live session, Russian and Turkish catalogs reviewed, Czech and Indonesian drafts, the Japanese draft completed, zoom previews, the web clipboard, Alt-drag snapping and Cmd+D repeat, recovery copies, crash and rollback fixes, colour emoji, `.fig` import fixes; earlier changes are in the revision history below) · **Target:** Figma Design (desktop app 126.10.7) FigCraft is a clean-room, open-source, pure-Rust reimplementation of the Figma design workflow, native on macOS, Windows, Linux and FreeBSD and in the browser, fully drivable by agents through @@ -358,6 +358,7 @@ Ranked; detail and milestones in [`docs/roadmap.md`](docs/roadmap.md). | Date | Change | Summary | |---|---|---| +| 2026-11-06 | patch | M1, #2028: Edit ▸ Set default properties gives new rectangles, ellipses, polygons and stars drawn with the tools (and, set from a text layer, new text) the selected layer's properties; it only copied them for Paste properties. Tests: `default_props_tests` (3). Numbers unchanged | | 2026-11-02 | patch | M8, #1885: a glass whose shape is too big to keep whole at the zoom (past `MAX_SHAPE_PX` with its core's margin) bends along its edge normals instead of working out a core, so its fields never cover more pixels than a kept shape's, and the core's feature transform holds 16 bytes a pixel. The edge normals are box-blurred twice again and the bend directions once, as documented. Test: `glass::tests::a_shape_too_big_to_keep_bends_along_its_normals`. Numbers unchanged | | 2026-11-02 | minor | M3, #1885: glass bends the backdrop towards its core, the shape shrunk by `depth` and the bevel, as the reference tool's: round a sharp corner the bend turns smoothly instead of meeting along the diagonal, and a part thinner than twice that (a capsule, a letter's stroke) bends across itself towards its own middle (pixels about as deep as any within 2 px). Rectangles, frames, components, instances and sections whose corners aren't smoothed work their glass out in closed form, with nothing to rasterise, transform or keep: a zoom frame draws in 40 ms instead of 54 and a resize frame in 46 instead of 67 (`glass_render_timings`, release, 2×). Other shapes keep their fields, with the bend directions for the last two depths asked for beside them, so dragging the Depth slider works out only those again. Tests: `glass::tests::a_sharp_corner_bends_round_towards_the_core`, `glass::tests::a_thin_part_bends_across_itself`, `glass::tests::neighbouring_strokes_bend_towards_their_own_middles`, `glass::tests::a_rounded_rectangle_in_closed_form_matches_its_distance_transform`, `glass_cut_tests::what_the_shape_depends_on_works_it_out_again_and_nothing_else_does`. Numbers unchanged | | 2026-11-02 | minor | M3, #1885: glass's light is a line on its 1-unit bevel added to the backdrop, as the reference tool's: fully where the edge faces the light, none below 0.35 of facing it and 0.6 as much on the opposite side, with a faint gradient across the curve, 5% darker facing the light and lighter opposite (it was a glow mixed towards white, as deep as `splay` made it). `splay` turns the bend from along the edge's normal towards the way away from the layer's centre, as the reference tool's does, and no longer widens the light: files with a splay above 0 look different. The direction to the centre is worked out in the shape's own frame, so cut renders match. Tests: `glass::tests::the_light_lies_on_the_bevel_and_the_gradient_across_the_curve`, `backdrop_tests::splay_turns_the_bend_towards_the_centre`, `glass_cut_tests::the_light_is_a_line_on_the_bevel`. Numbers unchanged | diff --git a/crates/engine/src/canvas/tools/click.rs b/crates/engine/src/canvas/tools/click.rs index a48b215bc..35a97a77a 100644 --- a/crates/engine/src/canvas/tools/click.rs +++ b/crates/engine/src/canvas/tools/click.rs @@ -193,6 +193,7 @@ impl Session { } // New text at the click (Figma puts the baseline-ish top-left there). let parent = frame_at(&doc, page, ev.p(), &[]).unwrap_or(page); + let defaults = self.default_props.text.clone(); let ds = self.ds_mut()?; let d = ds.doc_mut(); let id = d.alloc_id(); @@ -204,12 +205,18 @@ impl Session { if let Some(fills) = readable_text_fills(d, parent) { n.fills = fills; } - if let Some((w, h)) = figcraft_text::auto_size(&n) { - n.width = w.max(1.0); - n.height = h; - } - let line = n.height; d.insert(n, parent, None)?; + // Edit ▸ Set default properties from a text layer: its fills and font (best effort). + if let Some(defaults) = &defaults { + let _ = crate::cmd::edit::apply_copied_props("edit.setDefaultProperties", d, id, defaults); + } + let line = d.node_mut(id).map_or(14.0, |n| { + if let Some((w, h)) = figcraft_text::auto_size(n) { + n.width = w.max(1.0); + n.height = h; + } + n.height + }); ds.selection = vec![id]; textedit::begin(self, id, Some(0), true)?; self.tool.gesture = Gesture::TextBox { id, start: ev.p(), line }; diff --git a/crates/engine/src/canvas/tools/draw.rs b/crates/engine/src/canvas/tools/draw.rs index d59a2b904..499bfce89 100644 --- a/crates/engine/src/canvas/tools/draw.rs +++ b/crates/engine/src/canvas/tools/draw.rs @@ -38,6 +38,13 @@ impl Session { let pixel = self.ds().map(|d| d.view.snap_pixel).unwrap_or(true); let mut created = id; let page = self.page()?; + // Edit ▸ Set default properties: what new shapes take (not frames, sections, slices, lines + // or arrows, which keep their own look). + let defaults = if matches!(tool, ToolId::Rectangle | ToolId::Ellipse | ToolId::Polygon | ToolId::Star) { + self.default_props.shape.clone() + } else { + None + }; self.preview(|doc, sel| { let (mut a, mut b) = (start, p); if pixel { @@ -89,6 +96,10 @@ impl Session { n.transform = pw.inverse() * Affine::translate((r.x0, r.y0)); } doc.insert(n, parent, None)?; + if let Some(d) = &defaults { + // Best effort: a default the shape can't take leaves it as drawn. + let _ = crate::cmd::edit::apply_copied_props("edit.setDefaultProperties", doc, nid, d); + } *sel = vec![nid]; created = Some(nid); let _ = page; diff --git a/crates/engine/src/cmd/edit.rs b/crates/engine/src/cmd/edit.rs index 700fa7414..a0652e4c0 100644 --- a/crates/engine/src/cmd/edit.rs +++ b/crates/engine/src/cmd/edit.rs @@ -17,6 +17,7 @@ mod clipboard; mod props; mod select; +pub(crate) use clipboard::apply_copied_props; pub use clipboard::{CLIP_CLOSE, CLIP_OPEN, copy_to_clipboard, design_clipboard_buffer, paste_into}; use clipboard::{copy, copy_props, copy_props_of, cut, paste, paste_design_layers, paste_over, paste_props, paste_replace}; use props::{ @@ -142,12 +143,26 @@ pub fn specs() -> Vec { true, find_replace ), - spec!("edit.setDefaultProperties", "Set default properties", "{id?}", false, |s, p| { - let id = targets(s, p).first().copied().ok_or_else(|| bad("edit.setDefaultProperties", "select a layer"))?; - let v = copy_props_of(s.doc()?, id); - s.clipboard.props = Some(v); - ok() - }), + spec!( + "edit.setDefaultProperties", + "Set default properties", + "{id?} the layer's fills, strokes, effects, opacity and corners (a text layer's: also its font) become what new rectangles, ellipses, polygons and stars (or, from a text layer, new text) drawn with the tools take → {for: shapes|text, properties}", + false, + |s, p| { + let id = targets(s, p).first().copied().ok_or_else(|| bad("edit.setDefaultProperties", "select a layer"))?; + let doc = s.doc()?; + let text = matches!(doc.get(id)?.kind, NodeKind::Text(_)); + let v = copy_props_of(doc, id); + let kind = if text { + s.default_props.text = Some(v.clone()); + "text" + } else { + s.default_props.shape = Some(v.clone()); + "shapes" + }; + Ok(json!({"for": kind, "properties": v})) + } + ), spec!("select.set", "Select", "{ids: [..]} (replace the selection)", false, |s, p| { let ids = match get(p, "ids") { Some(Value::Array(a)) => a.iter().filter_map(id_of).collect(), diff --git a/crates/engine/src/cmd/edit/clipboard.rs b/crates/engine/src/cmd/edit/clipboard.rs index 546aa863c..150a3b577 100644 --- a/crates/engine/src/cmd/edit/clipboard.rs +++ b/crates/engine/src/cmd/edit/clipboard.rs @@ -357,21 +357,27 @@ pub(super) fn copy_props(s: &mut Session, p: &Value) -> Result { Ok(v) } +/// Give layer `id` the properties [`copy_props_of`] copied (`props`), those it can take: the text +/// properties only to text, the corners only to a layer with corners. +pub(crate) fn apply_copied_props(cmd: &str, doc: &mut Document, id: NodeId, props: &Value) -> Result<()> { + let mut m = props.as_object().cloned().unwrap_or_default(); + let is_text = matches!(doc.get(id)?.kind, NodeKind::Text(_)); + if !is_text { + m.retain(|k, _| !k.starts_with("font") && k != "lineHeight" && k != "letterSpacing"); + } + if !doc.get(id)?.kind.has_corner_radius() { + m.remove("cornerRadius"); + m.remove("cornerSmoothing"); + } + crate::cmd::props::apply(cmd, doc, id, &m) +} + pub(super) fn paste_props(s: &mut Session, p: &Value) -> Result { let props = s.clipboard.props.clone().ok_or_else(|| EngineError::Disabled("edit.pasteProperties".into(), "no copied properties".into()))?; let ids = req_targets("edit.pasteProperties", s, p)?; let doc = s.doc_mut()?; for i in ids { - let mut m = props.as_object().cloned().unwrap_or_default(); - let is_text = matches!(doc.get(i)?.kind, NodeKind::Text(_)); - if !is_text { - m.retain(|k, _| !k.starts_with("font") && k != "lineHeight" && k != "letterSpacing"); - } - if !doc.get(i)?.kind.has_corner_radius() { - m.remove("cornerRadius"); - m.remove("cornerSmoothing"); - } - crate::cmd::props::apply("edit.pasteProperties", doc, i, &m)?; + apply_copied_props("edit.pasteProperties", doc, i, &props)?; } ok() } diff --git a/crates/engine/src/default_props_tests.rs b/crates/engine/src/default_props_tests.rs new file mode 100644 index 000000000..ea5d16293 --- /dev/null +++ b/crates/engine/src/default_props_tests.rs @@ -0,0 +1,117 @@ +//! Edit ▸ Set default properties (#2028): new rectangles, ellipses, polygons and stars drawn with +//! the tools take the properties of the layer it was set from, and new text takes a text layer's; +//! it no longer only copied them for Paste properties. + +use figcraft_color::Color; +use figcraft_doc::{Node, NodeId, NodeKind}; +use serde_json::{Value, json}; + +use crate::Session; +use crate::params::id_of; +use crate::tools::{PointerEvent, PointerKind, ToolId}; + +/// Run `cmd`, failing the test on an error. +fn ex(s: &mut Session, cmd: &str, p: Value) -> Value { + s.execute(cmd, &p).unwrap_or_else(|e| panic!("{cmd}: {e}")) +} + +/// The layer `id` as it is now. +fn node(s: &Session, id: NodeId) -> Node { + s.doc().unwrap().node(id).unwrap().clone() +} + +/// Draw with `tool` from `a` to `b` (a click when they're equal); the new layer. +fn draw(s: &mut Session, tool: ToolId, a: (f64, f64), b: (f64, f64)) -> NodeId { + s.set_tool(tool); + s.pointer(&PointerEvent::at(PointerKind::Down, a.0, a.1, 1.0)).unwrap(); + if a != b { + s.pointer(&PointerEvent::at(PointerKind::Move, (a.0 + b.0) / 2.0, (a.1 + b.1) / 2.0, 1.0)).unwrap(); + s.pointer(&PointerEvent::at(PointerKind::Move, b.0, b.1, 1.0)).unwrap(); + } + s.pointer(&PointerEvent::at(PointerKind::Up, b.0, b.1, 1.0)).unwrap(); + *s.selection().first().unwrap() +} + +/// The first solid fill's colour of layer `n`. +fn fill(n: &Node) -> Option { + n.fills.first().and_then(|p| p.solid_color()) +} + +/// A red, half-transparent rectangle with a 4 pt blue stroke and 12 pt corners. +fn styled(s: &mut Session) -> NodeId { + let id = id_of(&ex(s, "shape.rectangle", json!({"x": 0, "y": 0, "width": 50, "height": 50}))["id"]).unwrap(); + ex(s, "node.set", json!({"id": id, "props": {"fill": "#FF0000", "stroke": "#0000FF", "strokeWeight": 4, "opacity": 0.5, "cornerRadius": 12}})); + id +} + +/// Rectangles, ellipses, polygons and stars drawn or clicked with their tools take the shape +/// defaults (corners only where a shape has them, its own drawn size); frames, lines and layers made +/// by commands keep their own look; undo takes a drawn shape away whole. +#[test] +fn new_shapes_drawn_with_the_tools_take_the_default_properties() { + let mut s = Session::new(); + let source = styled(&mut s); + let set = ex(&mut s, "edit.setDefaultProperties", json!({"id": source})); + assert_eq!(set["for"], "shapes"); + let red = Some(Color::from_hex("#FF0000").unwrap()); + // Dragged and clicked (a click places a 100×100 shape) alike. + for (tool, a, b) in + [(ToolId::Rectangle, (200.0, 0.0), (300.0, 80.0)), (ToolId::Ellipse, (400.0, 0.0), (400.0, 0.0)), (ToolId::Star, (600.0, 0.0), (660.0, 60.0))] + { + let id = draw(&mut s, tool, a, b); + let n = node(&s, id); + assert_eq!(fill(&n), red, "{tool:?}"); + assert_eq!((n.stroke.weight, n.opacity), (4.0, 0.5), "{tool:?}"); + assert_eq!(n.strokes.first().and_then(|p| p.solid_color()), Some(Color::from_hex("#0000FF").unwrap()), "{tool:?}"); + } + let rect = draw(&mut s, ToolId::Rectangle, (0.0, 200.0), (80.0, 260.0)); + assert_eq!(node(&s, rect).corners.radii, [12.0; 4], "corners go to layers with corners"); + assert_eq!((node(&s, rect).width, node(&s, rect).height), (80.0, 60.0), "the drawn size, not the source's"); + // Frames and lines keep their own look; a shape made by a command too. + let frame = draw(&mut s, ToolId::Frame, (0.0, 400.0), (100.0, 500.0)); + assert_ne!(fill(&node(&s, frame)), red); + let line = draw(&mut s, ToolId::Line, (0.0, 600.0), (100.0, 600.0)); + assert_ne!(node(&s, line).stroke.weight, 4.0); + let made = id_of(&ex(&mut s, "shape.rectangle", json!({"x": 0, "y": 700, "width": 10, "height": 10}))["id"]).unwrap(); + assert_ne!(fill(&node(&s, made)), red); + // Undo takes a drawn shape away whole, defaults included. + let drawn = draw(&mut s, ToolId::Polygon, (800.0, 0.0), (860.0, 60.0)); + ex(&mut s, "edit.undo", json!({})); + assert!(s.doc().unwrap().node(drawn).is_none()); +} + +/// Setting defaults no longer overwrites what Copy properties copied. +#[test] +fn setting_defaults_leaves_the_copied_properties_alone() { + let mut s = Session::new(); + let copied = id_of(&ex(&mut s, "shape.rectangle", json!({"x": 0, "y": 0, "width": 50, "height": 50}))["id"]).unwrap(); + ex(&mut s, "node.set", json!({"id": copied, "props": {"fill": "#00FF00"}})); + ex(&mut s, "edit.copyProperties", json!({"id": copied})); + let source = styled(&mut s); + ex(&mut s, "edit.setDefaultProperties", json!({"id": source})); + let target = id_of(&ex(&mut s, "shape.ellipse", json!({"x": 0, "y": 100, "width": 50, "height": 50}))["id"]).unwrap(); + ex(&mut s, "edit.pasteProperties", json!({"ids": [target]})); + assert_eq!(fill(&node(&s, target)), Some(Color::from_hex("#00FF00").unwrap()), "Paste properties pastes what was copied"); +} + +/// A text layer sets the defaults of new text (its font and fills, laid out at that size), and the +/// shapes' defaults stay as they were. +#[test] +fn new_text_takes_a_text_layers_defaults_and_shapes_keep_theirs() { + let mut s = Session::new(); + let shape = styled(&mut s); + ex(&mut s, "edit.setDefaultProperties", json!({"id": shape})); + let text = id_of(&ex(&mut s, "text.create", json!({"text": "Title", "x": 0, "y": 200}))["id"]).unwrap(); + ex(&mut s, "node.set", json!({"id": text, "props": {"fontSize": 32, "fill": "#008000"}})); + let set = ex(&mut s, "edit.setDefaultProperties", json!({"id": text})); + assert_eq!(set["for"], "text"); + let id = draw(&mut s, ToolId::Text, (300.0, 300.0), (300.0, 300.0)); + let n = node(&s, id); + let NodeKind::Text(t) = &n.kind else { panic!("a text layer") }; + assert_eq!(t.style.font_size, 32.0); + assert_eq!(fill(&n), Some(Color::from_hex("#008000").unwrap())); + assert!(n.height > 30.0, "laid out at the default size: {}", n.height); + // The shapes' defaults are still the rectangle's. + let rect = draw(&mut s, ToolId::Rectangle, (0.0, 500.0), (80.0, 560.0)); + assert_eq!(fill(&node(&s, rect)), Some(Color::from_hex("#FF0000").unwrap())); +} diff --git a/crates/engine/src/lib.rs b/crates/engine/src/lib.rs index e919444e2..c10de9a23 100644 --- a/crates/engine/src/lib.rs +++ b/crates/engine/src/lib.rs @@ -110,7 +110,7 @@ mod view_state; pub use derived::{changed_nodes, normalize}; pub use doc_state::{DocState, History, HistoryEntry, Interaction, PREVIEW_READ_ONLY, Preedit, TextEdit, VersionPreview}; pub use error::{EngineError, Result, bad}; -pub use prefs::{Clipboard, MAX_RECENT_ACTIONS, Prefs, UI_SCALE_MAX, UI_SCALE_MIN, UI_SCALE_SIZES, UiRequest, clamp_ui_scale}; +pub use prefs::{Clipboard, DefaultProps, MAX_RECENT_ACTIONS, Prefs, UI_SCALE_MAX, UI_SCALE_MIN, UI_SCALE_SIZES, UiRequest, clamp_ui_scale}; pub use session::Forward; pub use view_state::ViewState; @@ -119,6 +119,8 @@ pub struct Session { pub docs: Vec, pub active: usize, pub clipboard: Clipboard, + /// Edit ▸ Set default properties: what new shapes and text drawn with the tools take. + pub default_props: DefaultProps, pub prefs: Prefs, /// A command changed a preference that is kept at once (not only when the app quits): the app /// saves the preferences and clears this. @@ -275,6 +277,8 @@ mod dash_cap_tests; #[cfg(test)] mod datafill_tests; #[cfg(test)] +mod default_props_tests; +#[cfg(test)] mod design_paste_tests; #[cfg(test)] mod dev_measurements_tests; diff --git a/crates/engine/src/prefs.rs b/crates/engine/src/prefs.rs index 5c455aa35..48d68a901 100644 --- a/crates/engine/src/prefs.rs +++ b/crates/engine/src/prefs.rs @@ -173,6 +173,18 @@ pub struct UiRequest { pub data: Value, } +/// What Edit ▸ Set default properties keeps: the properties new layers drawn with the tools take, +/// as Copy properties copies them (fills, strokes and their settings, effects, opacity, blend, +/// corners; for text also the font, size, line height and letter spacing). One set for shapes +/// (rectangles, ellipses, polygons and stars), set from any layer but text, and one for text. +#[derive(Clone, Debug, Default, PartialEq)] +pub struct DefaultProps { + /// For new rectangles, ellipses, polygons and stars. + pub shape: Option, + /// For new text. + pub text: Option, +} + /// Clipboard contents (internal; the UI mirrors to the system clipboard). #[derive(Clone, Debug, Default)] pub struct Clipboard { diff --git a/crates/engine/src/session/new.rs b/crates/engine/src/session/new.rs index c7eee09f1..f3b75b630 100644 --- a/crates/engine/src/session/new.rs +++ b/crates/engine/src/session/new.rs @@ -14,6 +14,7 @@ impl Session { docs: Vec::new(), active: 0, clipboard: Clipboard::default(), + default_props: Default::default(), prefs: Prefs::default(), prefs_unsaved: false, tool: tools::ToolState::default(), diff --git a/docs/ui-parity.md b/docs/ui-parity.md index d98a6ed73..5489ecbb3 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-04 · **Change:** patch (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-06 · **Change:** patch (Edit ▸ Set default properties now gives new shapes and text drawn with the tools the selected layer's fills, strokes, effects, opacity and corners (text: its font) instead of only copying them for Paste properties (#2028); 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: @@ -73,6 +73,7 @@ interaction feel not yet compared. | Numeric fields: arithmetic, scrubbing by dragging the label, mixed values | done | Numeric panels use `widgets::number_field`; Corner smoothing has an original code-drawn icon, a 24 pt drag target and an accessible name, with live changes, fractional values preserved across consecutive drags, Shift/Alt rates, 0–100% clamping and one-step undo/redo (`corner_individual_tests`); Typography line height, letter spacing and paragraph spacing share its leading-icon scrub logic (#373), retaining their existing unit parsing, Auto/Mixed values, variable chips and selected-character targeting (`typography_scrub_tests`). Scrubbing the label: a step a point (1 px; 1% of opacity, 1° of rotation), ten with Shift, a tenth with Alt, each stretch at the rate held while it was dragged, one undo step when let go; past the edge of the screen it goes on where the platform reports the mouse's own motion (desktop), otherwise it stops there. Arrow keys: Up/Down step a pixel field by the small nudge and Shift by the big nudge (the preferences), other fields by their own step and ten of it; they work while typing (from what is typed) and with the keyboard on the field. Typing: `+ - * /`, brackets, units (`px`, `°`, `%`, `x`, `ms`), a decimal comma; `+10`, `*2`, `/4` are relative to the value, and `50%`, `+10%`, `-10%` too in a field that isn't a percentage. Enter, Tab or a click elsewhere commits (Tab and Shift+Tab move to the next and previous control), Escape restores; a field left as it was commits nothing (no undo step, and a rounded display isn't written back). Mixed values show "Mixed": a number sets them all, a relative edit or an arrow key goes to each layer from its own value in one undo step, for X, Y, W, H, rotation, opacity, corner radius and stroke weight (elsewhere `+10` on Mixed sets 10 and `*2` does nothing) (`field_tests`). Left: scrubbing a Mixed field (nothing happens), `x2`-style suffix edits, the pointer isn't wrapped to the other side of the screen; rates not compared with Figma's | | Transform box at small sizes | done | a press inside a layer smaller than its handles moves it, the nearest handle wins, handles answer just outside and are hidden under 16 px on screen; cursors follow each handle and the box's rotation | | 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) | | 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 | @@ -178,6 +179,7 @@ in the table. `crates/ui-egui/src/shortcut_keys_tests.rs` drives the keys a look | Date | Change | Summary | |---|---|---| +| 2026-11-06 | patch | M1, #2028: Edit ▸ Set default properties copied the selected layer's properties into the Paste properties clipboard and nothing else, so a new rectangle drawn afterwards was still grey (and what Copy properties had copied was lost). The defaults are now kept apart (`Session::default_props`, one set for shapes and one for text): rectangles, ellipses, polygons and stars drawn or clicked with their tools take the shape defaults (`apply_copied_props`, the same rules as Paste properties: corners only where a layer has them), and new text from the Text tool takes a text layer's fills and font and is laid out at that size. Frames, sections, slices, lines, arrows, vectors and layers made by commands keep their own look. `edit.setDefaultProperties` answers `{for: shapes|text, properties}`. Tests: `default_props_tests` (3) | | 2026-11-04 | patch | M1, #1852: a press on one of the open gradient's handles or stops on the canvas is the colour picker's own, not a press outside it (Figma keeps the picker and the handles up while a handle or stop is dragged; the stops are made to be dragged: "You can click and drag a stop to change its placement on the gradient", Use gradients as a fill or stroke). The canvas took the press and began the drag, then the picker, drawn later in the same frame, saw a press outside its card and closed, committing the drag's interaction at once; the handles vanished with it and the drag went on without an undo step of its own. Now the picker stays while a gradient handle or stop drags, and the drag is one undo step; a press elsewhere on the canvas still closes it. A handle drag whose button goes up off the canvas (over a panel or the picker) ends there too, instead of waiting, uncommitted, to move the handle to the next press on the canvas. Tests: `colorpicker_selection_tests::dragging_a_gradient_handle_on_the_canvas_keeps_the_picker_open`, `colorpicker_selection_tests::a_gradient_drag_released_off_the_canvas_ends_there`. | | 2026-11-02 | patch | M8, #1875: a click with the Bend tool on a sharp point between two segments gives it handles along the line between its neighbours, a third of the way to each ("Click on a point or path where you want to add a curve", Edit vector layers); a click on a curved point still makes it sharp, a drag still sets the handles by hand, an endpoint is left alone. Between a handle's end and a point both within reach of the pointer, the nearer one on the page is hit (the handle on a tie), so a short path's point (its handles a few pixels long) can be clicked again. Before, only a drag curved a point, and a short one left two tiny handles in its direction. Tests: `vectoredit::tests::short_handles_leave_their_point_clickable`, `vectoredit::tests::a_bend_click_curves_a_sharp_point_between_its_neighbours`, `bend_tool_smooths_and_sharpens_points`. Numbers unchanged. | | 2026-11-02 | minor | M4, #1827: wrap style on a text layer (`WrapStyle`: Auto, Balance, Pretty): Balance re-breaks each paragraph at the narrowest width that keeps its line count (bisection over the greedy breaker, as browsers balance), Pretty narrows one of the last four lines just enough so the last line isn't one word; `text.wrapStyle`, `node.set wrapStyle` (`textWrap` too), inspect `wrapStyle`, Dev Mode CSS `text-wrap` (Tailwind `text-balance` / `text-pretty`), the Type settings control under Vertical trim. Per-paragraph settings, text-style support and the `.fig` import/export mapping stay open. Test: `text_behaviour_tests::balance_and_pretty_wrap_styles_break_lines_as_documented`. |