mirror of
https://github.com/storytold/figcraft.git
synced 2026-11-17 23:58:24 +00:00
Merge branch 'main' into patch-7
This commit is contained in:
13 files changed
+240
-79
No files matched your search
Generated
+19
@@ -1200,6 +1200,14 @@ dependencies = [
|
||||
"zip 9.1.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "craft-vectordrawable"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=d13ac58a15c45d618f25910772502e38c4ce1d4c#d13ac58a15c45d618f25910772502e38c4ce1d4c"
|
||||
dependencies = [
|
||||
"kurbo",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "craft-web-api"
|
||||
version = "0.1.0"
|
||||
@@ -1228,6 +1236,15 @@ dependencies = [
|
||||
"wayland-client",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "craft-xml"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=d13ac58a15c45d618f25910772502e38c4ce1d4c#d13ac58a15c45d618f25910772502e38c4ce1d4c"
|
||||
dependencies = [
|
||||
"quick-xml 0.41.0",
|
||||
"thiserror 2.0.21",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "craft-zip"
|
||||
version = "0.1.0"
|
||||
@@ -2133,6 +2150,7 @@ name = "figcraft-svg"
|
||||
version = "0.18.1"
|
||||
dependencies = [
|
||||
"base64 0.22.1",
|
||||
"craft-xml",
|
||||
"figcraft-color",
|
||||
"figcraft-doc",
|
||||
"figcraft-geom",
|
||||
@@ -2194,6 +2212,7 @@ dependencies = [
|
||||
name = "figcraft-vectordrawable"
|
||||
version = "0.18.1"
|
||||
dependencies = [
|
||||
"craft-vectordrawable",
|
||||
"figcraft-color",
|
||||
"figcraft-doc",
|
||||
"figcraft-geom",
|
||||
|
||||
@@ -13,6 +13,8 @@ rust-version = "1.95"
|
||||
repository = "https://github.com/storytold/figcraft"
|
||||
|
||||
[workspace.dependencies]
|
||||
craft-xml = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "d13ac58a15c45d618f25910772502e38c4ce1d4c" }
|
||||
craft-vectordrawable = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "d13ac58a15c45d618f25910772502e38c4ce1d4c" }
|
||||
# internal
|
||||
figcraft-geom = { path = "crates/geom" }
|
||||
figcraft-color = { path = "crates/color" }
|
||||
|
||||
+1
-1
@@ -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-15 · **Change:** minor (CLI post-parse errors escape terminal controls in paths and failure text; a boolean group takes a corner radius (and smoothing) that rounds every sharp corner of its result (#2222); a text style binds a number variable to its weight (#2174); mind maps, first step: a first node with three children on curved branches, laid out again after every edit (`board.mindMap`, `board.mindMapAdd`, #2226); the handoff mode reads Developer Mode in the interface, its ids and saved fields unchanged; the left rail's and tab strip's icons are larger, 20 pt (#553); Suggest auto layout adds nested auto layout frames by rows and columns and keeps the placement of the design, as the help center describes (#1823); the Local variables window selects several variables (click, Shift+click for a range, Cmd/Ctrl+click to toggle, Escape to clear) and delete, move to a group and scope act on the selected local variables in one undo step (#2002); the desktop UI takes a system face for Ethiopic, Devanagari, Gurmukhi, Gujarati, Tamil, Telugu, Kannada and Malayalam, Sinhala, Lao, Myanmar, Khmer, Armenian and Georgian as it did for Hebrew and Arabic, so a String variable's Amharic value draws in the panels instead of boxes (#2014); a layer's effect binding takes only a field its effect has; ; the boolean operation menu leads each entry with an original icon (#2003); glass takes one sample instead of its dispersion window where the colours split under 1/256 px; 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 stamLine truncated
|
||||
> **Last reviewed:** 2026-11-15 · **Last updated:** 2026-11-15 · **Change:** minor (CLI post-parse errors escape terminal controls in paths and failure text; M6 `.fig` export writes text on a path (#2323), list spacing, hanging punctuation and lists, vertical trim (#2305), vector region paints (#2302), image adjustments (#2297) and a page's prototype background (#2326); M8 Tidy up keeps a row's or column's order and sizes and evens the gaps, rounds the gap, tidies overlapping rows and grids along their longer axis, and raises a negative gap so no layer reaches the one two before it, as measured in Figma (#2319); a polygon's or star's Count handle and a double-click on a layer's icon (zoom, range anchor) follow Figma; Tab while renaming moves only the rename and wraps from the last layer; Align is unavailable for a layer in an auto layout frame's flow; the Scale tool pivots on the opposite handle and starts its origin at the centre; Paste over selection puts the copies just above the selected layer; Crop from the image fill's menu crops with a drag (#2307); M10 code export writes every colour and gradient fill in paint order for CSS, SwiftUI, Compose and Flutter (#2271), CSS as one layered background; 24 pt icon buttons draw 16 pt glyphs (#2227, #2238); M5 marquee selection follows Figma's measured rules and Select layer lists locked layers with a padlock (#1560); M7 the Design panel shows the page's variable modes with nothing selected (#2215); M12 mind maps in a section or frame without a place centre on the view, stickies take a Small–Huge text-size menu, and M9 `.jam` shapes with text import as native board shapes (#1808); M4 a boolean group's corner radius rounds its result (#2222), Flatten bakes a point's corner radius into its path (#2195) and loops close through a joining segment (#1951); library links survive moving or cloning the project folder (#2132); renaming a variable group to a path with `/` nests it (#2353); SVG import, widget images, batches and grids take bounded work, and a host's server key is never sent over plain `ws://` to another machine (#1923); CI prefetches dependencies for Sonar coverage and runs Harden-Runner on every job; releases FigCraft v0.18.0 and v0.18.1 (Flatpak update fix); readiness estimates unchanged) · **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
|
||||
|
||||
@@ -9,6 +9,7 @@ description = "FigCraft SVG export (shapes, gradients, images, strokes, effects
|
||||
workspace = true
|
||||
|
||||
[dependencies]
|
||||
craft-xml = { workspace = true }
|
||||
figcraft-geom = { workspace = true }
|
||||
figcraft-color = { workspace = true }
|
||||
figcraft-doc = { workspace = true }
|
||||
|
||||
+3
-10
@@ -195,16 +195,9 @@ fn blend_style(b: figcraft_color::BlendMode) -> String {
|
||||
}
|
||||
}
|
||||
|
||||
/// `s` escaped for XML text and attribute values; characters XML 1.0 forbids (control characters
|
||||
/// other than tab, newline and carriage return, U+FFFE and U+FFFF) are left out.
|
||||
fn esc(s: &str) -> String {
|
||||
s.chars().filter(|&c| xml_char(c)).collect::<String>().replace('&', "&").replace('<', "<").replace('>', ">").replace('"', """)
|
||||
}
|
||||
|
||||
/// Whether XML 1.0 allows `c` (see [`esc`]).
|
||||
fn xml_char(c: char) -> bool {
|
||||
!matches!(c, '\u{0}'..='\u{8}' | '\u{b}' | '\u{c}' | '\u{e}'..='\u{1f}' | '\u{fffe}' | '\u{ffff}')
|
||||
}
|
||||
// Shared XML wire escaping and character validity; layer-name policy stays below.
|
||||
// Attribute escaping also preserves tabs/LF/CR through XML readers' whitespace normalization.
|
||||
use craft_xml::{esc_attr as esc, is_xml_char as xml_char};
|
||||
|
||||
fn hex(c: Color) -> String {
|
||||
format!("#{}", c.to_hex())
|
||||
|
||||
@@ -451,3 +451,15 @@ fn a_whole_ellipse_drawn_backwards_keeps_its_simple_stroke() {
|
||||
assert_eq!(backwards, forwards, "{align:?}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn shared_xml_escaping_keeps_markup_controls_and_attribute_whitespace() {
|
||||
let input = "A<&\"'\t\n\r\u{1}\u{fffe}🦊";
|
||||
assert_eq!(super::esc(input), "A<&"'	 🦊");
|
||||
let markup = format!("<svg label=\"{}\"/>", super::esc(input));
|
||||
let root = craft_xml::parse(markup.as_bytes()).unwrap();
|
||||
assert_eq!(root.attr("label"), Some("A<&\"'\t\n\r🦊"));
|
||||
for c in ['\0', '\u{b}', '\u{fffe}', '\u{ffff}'] {
|
||||
assert!(!super::xml_char(c));
|
||||
}
|
||||
}
|
||||
@@ -961,6 +961,7 @@ name = "English"
|
||||
"Nested instance" = "Nested instance"
|
||||
"New board" = "New board"
|
||||
"New design file" = "New design file"
|
||||
"New from selection" = "New from selection"
|
||||
"Newest first" = "Newest first"
|
||||
"Next or previous control in the focused region" = "Next or previous control in the focused region"
|
||||
"Next frame" = "Next frame"
|
||||
|
||||
@@ -0,0 +1,133 @@
|
||||
//! The Frame tool's panel starts with New from selection (#1683): with layers selected it wraps
|
||||
//! them in a frame, as Object ▸ Frame selection does, in one undo step, and returns to the Move
|
||||
//! tool; with nothing selected it does nothing.
|
||||
|
||||
use egui::accesskit::Role;
|
||||
use egui::{Pos2, pos2};
|
||||
use figcraft_doc::{NodeId, NodeKind};
|
||||
use figcraft_engine::{Session, ToolId};
|
||||
use serde_json::json;
|
||||
|
||||
use crate::layers_drag_tests::Ui;
|
||||
|
||||
/// Two rectangles, both selected when `select`, with the Frame tool active.
|
||||
fn scene(select: bool) -> (Ui, [NodeId; 2]) {
|
||||
let mut s = Session::new();
|
||||
let mut rect =
|
||||
|x: i32| NodeId(s.execute("shape.rectangle", &json!({"x": x, "y": 0, "width": 50, "height": 50})).unwrap()["id"].as_u64().unwrap());
|
||||
let ids = [rect(0), rect(80)];
|
||||
let selected: &[NodeId] = if select { &ids } else { &[] };
|
||||
s.execute("select.set", &json!({"ids": selected})).unwrap();
|
||||
s.execute("tool.set", &json!({"tool": "frame"})).unwrap();
|
||||
(Ui::new(s), ids)
|
||||
}
|
||||
|
||||
/// The middle of the button named `label`, found in the AccessKit tree, and whether it says it is
|
||||
/// disabled.
|
||||
fn named_button(u: &mut Ui, label: &str) -> (Pos2, bool) {
|
||||
u.ctx.enable_accesskit();
|
||||
u.frame(vec![]);
|
||||
let out = u.frame_output(vec![]);
|
||||
let nodes = out.platform_output.accesskit_update.expect("an AccessKit update").nodes;
|
||||
let n = nodes.iter().map(|(_, n)| n).find(|n| n.role() == Role::Button && n.label() == Some(label)).expect(label);
|
||||
let b = n.bounds().expect("bounds");
|
||||
(pos2(((b.x0 + b.x1) / 2.0) as f32, ((b.y0 + b.y1) / 2.0) as f32), n.is_disabled())
|
||||
}
|
||||
|
||||
fn click(u: &mut Ui, p: Pos2) {
|
||||
u.button(p, true);
|
||||
u.button(p, false);
|
||||
u.frame(vec![]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn new_from_selection_frames_the_selected_layers_and_returns_to_move() {
|
||||
let (mut u, [a, b]) = scene(true);
|
||||
let history = u.app.session.undo_depth().0;
|
||||
let (at, disabled) = named_button(&mut u, "New from selection");
|
||||
assert!(!disabled);
|
||||
click(&mut u, at);
|
||||
let doc = u.app.session.doc().unwrap();
|
||||
let parent = doc.node(a).unwrap().parent.expect("a parent");
|
||||
assert_eq!(doc.node(b).unwrap().parent, Some(parent), "both layers in the same frame");
|
||||
assert!(matches!(doc.node(parent).unwrap().kind, NodeKind::Frame), "the parent is a new frame");
|
||||
assert_eq!(u.app.session.undo_depth().0, history + 1, "one undo step");
|
||||
assert_eq!(u.app.session.tool.tool, ToolId::Move);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn new_from_selection_does_nothing_without_a_selection() {
|
||||
let (mut u, [a, _]) = scene(false);
|
||||
let page = u.app.session.doc().unwrap().node(a).unwrap().parent;
|
||||
let history = u.app.session.undo_depth().0;
|
||||
let (at, disabled) = named_button(&mut u, "New from selection");
|
||||
assert!(disabled, "screen readers hear it is disabled");
|
||||
click(&mut u, at);
|
||||
assert_eq!(u.app.session.doc().unwrap().node(a).unwrap().parent, page, "nothing was framed");
|
||||
assert_eq!(u.app.session.undo_depth().0, history);
|
||||
assert_eq!(u.app.session.tool.tool, ToolId::Frame, "the Frame tool stays");
|
||||
}
|
||||
|
||||
/// Sections never go in frames (`object.frameSelection` refuses them): with a section selected,
|
||||
/// alone or with other layers, the button is disabled, and clicking it shows no error and keeps
|
||||
/// the Frame tool.
|
||||
#[test]
|
||||
fn new_from_selection_is_disabled_for_a_section() {
|
||||
let (mut u, [a, b]) = scene(false);
|
||||
let section = NodeId(u.app.session.execute("object.wrapInSection", &json!({"ids": [a]})).unwrap()["id"].as_u64().unwrap());
|
||||
for selected in [vec![section], vec![section, b]] {
|
||||
u.app.session.execute("select.set", &json!({"ids": selected})).unwrap();
|
||||
u.app.session.execute("tool.set", &json!({"tool": "frame"})).unwrap();
|
||||
let history = u.app.session.undo_depth().0;
|
||||
let (at, disabled) = named_button(&mut u, "New from selection");
|
||||
assert!(disabled, "{selected:?}");
|
||||
click(&mut u, at);
|
||||
assert_eq!(u.app.session.undo_depth().0, history, "nothing was framed");
|
||||
assert!(u.app.ui.toast.is_none(), "no error: {:?}", u.app.ui.toast);
|
||||
assert_eq!(u.app.session.tool.tool, ToolId::Frame, "the Frame tool stays");
|
||||
}
|
||||
// A layer inside the section can be framed (in the section).
|
||||
u.app.session.execute("select.set", &json!({"ids": [a]})).unwrap();
|
||||
u.app.session.execute("tool.set", &json!({"tool": "frame"})).unwrap();
|
||||
let (at, disabled) = named_button(&mut u, "New from selection");
|
||||
assert!(!disabled);
|
||||
click(&mut u, at);
|
||||
let frame = u.app.session.doc().unwrap().node(a).unwrap().parent.unwrap();
|
||||
assert_eq!(u.app.session.doc().unwrap().node(frame).unwrap().parent, Some(section));
|
||||
assert_eq!(u.app.session.tool.tool, ToolId::Move);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn new_from_selection_respects_instance_structure_and_slots() {
|
||||
for slot in [false, true] {
|
||||
let mut s = Session::new();
|
||||
let frame = NodeId(s.execute("frame.create", &json!({"width": 200, "height": 200})).unwrap()["id"].as_u64().unwrap());
|
||||
let content = NodeId(s.execute("frame.create", &json!({"parent": frame, "width": 100, "height": 100})).unwrap()["id"].as_u64().unwrap());
|
||||
let rect = NodeId(s.execute("shape.rectangle", &json!({"parent": content, "width": 20, "height": 20})).unwrap()["id"].as_u64().unwrap());
|
||||
let component = NodeId(s.execute("component.create", &json!({"ids": [frame]})).unwrap()["id"].as_u64().unwrap());
|
||||
if slot {
|
||||
s.execute("component.makeSlot", &json!({"id": content})).unwrap();
|
||||
}
|
||||
let instance = NodeId(s.execute("instance.create", &json!({"component": component, "x": 300, "y": 0})).unwrap()["id"].as_u64().unwrap());
|
||||
let doc = s.doc().unwrap();
|
||||
let child = doc.subtree(instance).into_iter().find(|id| doc.node(*id).and_then(|n| n.source) == Some(rect)).unwrap();
|
||||
s.execute("select.set", &json!({"ids": [child]})).unwrap();
|
||||
s.execute("tool.set", &json!({"tool": "frame"})).unwrap();
|
||||
let mut u = Ui::new(s);
|
||||
let history = u.app.session.undo_depth().0;
|
||||
let parent = u.app.session.doc().unwrap().node(child).unwrap().parent;
|
||||
let (at, disabled) = named_button(&mut u, "New from selection");
|
||||
assert_eq!(disabled, !slot, "only content within a slot can be reframed");
|
||||
click(&mut u, at);
|
||||
assert!(u.app.ui.toast.is_none(), "disabled action must not raise an error");
|
||||
if slot {
|
||||
assert_eq!(u.app.session.undo_depth().0, history + 1);
|
||||
assert_ne!(u.app.session.doc().unwrap().node(child).unwrap().parent, parent);
|
||||
assert_eq!(u.app.session.tool.tool, ToolId::Move);
|
||||
} else {
|
||||
assert_eq!(u.app.session.undo_depth().0, history);
|
||||
assert_eq!(u.app.session.doc().unwrap().node(child).unwrap().parent, parent);
|
||||
assert_eq!(u.app.session.tool.tool, ToolId::Frame);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -116,6 +116,8 @@ mod font_menu_regrow_tests;
|
||||
#[cfg(test)]
|
||||
mod frame_label_tests;
|
||||
#[cfg(test)]
|
||||
mod frame_new_from_selection_tests;
|
||||
#[cfg(test)]
|
||||
mod gap_handle_tests;
|
||||
#[cfg(test)]
|
||||
mod gradient_shorthand_tests;
|
||||
|
||||
@@ -1,20 +1,49 @@
|
||||
//! The Frame tool's panel: frame presets by category. Clicking one adds a frame of that size next
|
||||
//! to the page's frames and returns to the Move tool.
|
||||
//! The Frame tool's panel: New from selection, then frame presets by category. Clicking a preset
|
||||
//! adds a frame of that size next to the page's frames; either returns to the Move tool.
|
||||
|
||||
use egui::{Align2, CornerRadius, Id, Sense, Ui, pos2, vec2};
|
||||
use figcraft_doc::{Document, NodeId, NodeKind};
|
||||
use serde_json::json;
|
||||
|
||||
use crate::FigApp;
|
||||
use crate::a11y;
|
||||
use crate::i18n::tr;
|
||||
use crate::icons::{self, Icon};
|
||||
use crate::theme::{Tokens, regular, semibold};
|
||||
use crate::widgets::{self, PAD};
|
||||
|
||||
/// Draw the expandable frame-preset categories; choosing a preset runs `frame.create`,
|
||||
/// switches to the Move tool and zooms to the new selection.
|
||||
/// Whether `object.frameSelection` would frame `selection`: layers on a page, none of them a
|
||||
/// section (sections never go in frames, #1683).
|
||||
fn can_frame(doc: &Document, selection: &[NodeId]) -> bool {
|
||||
!selection.is_empty()
|
||||
&& selection.iter().all(|i| doc.node(*i).is_some_and(|n| n.parent.is_some() && !matches!(n.kind, NodeKind::Section { .. })))
|
||||
&& figcraft_engine::cmd::edit::roots(doc, selection)
|
||||
.iter()
|
||||
.all(|id| doc.node(*id).and_then(|n| n.parent).is_some_and(|parent| !figcraft_engine::components::structure_locked(doc, parent)))
|
||||
}
|
||||
|
||||
/// Draw New from selection and the expandable frame-preset categories. New from selection wraps
|
||||
/// the selected layers in a frame (`object.frameSelection`, #1683); choosing a preset runs
|
||||
/// `frame.create` and zooms to the new selection. Both switch to the Move tool.
|
||||
pub fn panel(app: &mut FigApp, ui: &mut Ui) {
|
||||
let t = Tokens::get(ui.ctx());
|
||||
widgets::section_header(ui, tr("Frame"), &[], false);
|
||||
let framable = app.session.ds().is_ok_and(|ds| can_frame(&ds.doc, &ds.selection));
|
||||
let mut from_selection = false;
|
||||
ui.horizontal(|ui| {
|
||||
ui.add_space(PAD);
|
||||
let resp = widgets::button(ui, tr("New from selection"), false, framable);
|
||||
if !framable {
|
||||
a11y::disabled(&resp);
|
||||
}
|
||||
from_selection = resp.clicked();
|
||||
});
|
||||
ui.add_space(4.0);
|
||||
// The Frame tool stays when framing failed (its error is shown).
|
||||
if from_selection && app.run("object.frameSelection", json!({})).is_some() {
|
||||
app.run("tool.set", json!({"tool": "move"}));
|
||||
return;
|
||||
}
|
||||
let w = ui.available_width();
|
||||
let mut cats: Vec<&str> = Vec::new();
|
||||
for (c, ..) in figcraft_engine::cmd::create::FRAME_PRESETS {
|
||||
|
||||
@@ -9,6 +9,7 @@ description = "FigCraft Android Vector Drawable export (shapes, strokes, gradien
|
||||
workspace = true
|
||||
|
||||
[dependencies]
|
||||
craft-vectordrawable.workspace = true
|
||||
figcraft-geom = { workspace = true }
|
||||
figcraft-color = { workspace = true }
|
||||
figcraft-doc = { workspace = true }
|
||||
|
||||
@@ -5,48 +5,14 @@
|
||||
use std::fmt::Write as _;
|
||||
|
||||
use figcraft_color::Color;
|
||||
use figcraft_geom::BezPath;
|
||||
use figcraft_geom::kurbo::PathEl;
|
||||
|
||||
use crate::model::{Fill, GradKind, GroupItem, Item, ItemKind, NativeStroke, PathItem};
|
||||
|
||||
const ANDROID: &str = "http://schemas.android.com/apk/res/android";
|
||||
const AAPT: &str = "http://schemas.android.com/aapt";
|
||||
|
||||
/// A number as Android reads it: rounded to 3 decimals, no trailing zeros, `0` for anything
|
||||
/// non-finite (the walk leaves out shapes whose numbers aren't finite).
|
||||
pub(crate) fn num(v: f64) -> String {
|
||||
if !v.is_finite() {
|
||||
return "0".into();
|
||||
}
|
||||
// Android reads these as 32-bit floats, so clamp to that range; this also keeps the scaling
|
||||
// below from overflowing to infinity.
|
||||
let v = v.clamp(-f64::from(f32::MAX), f64::from(f32::MAX));
|
||||
let r = (v * 1000.0).round() / 1000.0;
|
||||
let s = format!("{r}");
|
||||
if s == "-0" { "0".into() } else { s }
|
||||
}
|
||||
|
||||
/// `s` for an attribute value: markup escaped, whitespace that parsers would fold kept as
|
||||
/// character references, and characters XML 1.0 forbids dropped.
|
||||
pub(crate) fn esc(s: &str) -> String {
|
||||
let mut out = String::with_capacity(s.len());
|
||||
for c in s.chars() {
|
||||
match c {
|
||||
'&' => out.push_str("&"),
|
||||
'<' => out.push_str("<"),
|
||||
'>' => out.push_str(">"),
|
||||
'"' => out.push_str("""),
|
||||
'\'' => out.push_str("'"),
|
||||
'\t' => out.push_str("	"),
|
||||
'\n' => out.push_str(" "),
|
||||
'\r' => out.push_str(" "),
|
||||
c if (c as u32) < 0x20 || c == '\u{FFFE}' || c == '\u{FFFF}' => {}
|
||||
c => out.push(c),
|
||||
}
|
||||
}
|
||||
out
|
||||
}
|
||||
// Shared wire primitives; app-specific drawable projection and colour policy stay here.
|
||||
pub(crate) use craft_vectordrawable::write::{esc, num, path_data};
|
||||
|
||||
/// `#RRGGBB`, or `#AARRGGBB` when not opaque.
|
||||
pub(crate) fn color(c: Color) -> String {
|
||||
@@ -54,33 +20,6 @@ pub(crate) fn color(c: Color) -> String {
|
||||
if a == 255 { format!("#{r:02X}{g:02X}{b:02X}") } else { format!("#{a:02X}{r:02X}{g:02X}{b:02X}") }
|
||||
}
|
||||
|
||||
/// SVG path syntax, absolute commands.
|
||||
pub(crate) fn path_data(p: &BezPath) -> String {
|
||||
let mut s = String::new();
|
||||
let pt = |x: f64, y: f64| format!("{},{}", num(x), num(y));
|
||||
for el in p.elements() {
|
||||
if !s.is_empty() {
|
||||
s.push(' ');
|
||||
}
|
||||
match *el {
|
||||
PathEl::MoveTo(a) => {
|
||||
let _ = write!(s, "M{}", pt(a.x, a.y));
|
||||
}
|
||||
PathEl::LineTo(a) => {
|
||||
let _ = write!(s, "L{}", pt(a.x, a.y));
|
||||
}
|
||||
PathEl::QuadTo(a, b) => {
|
||||
let _ = write!(s, "Q{} {}", pt(a.x, a.y), pt(b.x, b.y));
|
||||
}
|
||||
PathEl::CurveTo(a, b, c) => {
|
||||
let _ = write!(s, "C{} {} {}", pt(a.x, a.y), pt(b.x, b.y), pt(c.x, c.y));
|
||||
}
|
||||
PathEl::ClosePath => s.push('Z'),
|
||||
}
|
||||
}
|
||||
s
|
||||
}
|
||||
|
||||
struct Out {
|
||||
s: String,
|
||||
}
|
||||
@@ -244,3 +183,29 @@ fn path(o: &mut Out, depth: usize, p: &PathItem) {
|
||||
o.close(depth + 1, "aapt:attr");
|
||||
o.close(depth, "path");
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod shared_wire_tests {
|
||||
use super::*;
|
||||
use figcraft_geom::BezPath;
|
||||
|
||||
#[test]
|
||||
fn shared_attributes_preserve_exact_xml() {
|
||||
assert_eq!(esc("<&>\"'\t\n\r\0\u{ffff}é𝄞	"), "<&>"'	 é𝄞&#9;");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn shared_numbers_and_paths_preserve_android_syntax() {
|
||||
assert_eq!(num(-0.0001), "0");
|
||||
assert_eq!(num(f64::NAN), "0");
|
||||
assert_eq!(num(f64::INFINITY), "0");
|
||||
assert_eq!(num(1.23456), "1.235");
|
||||
let mut p = BezPath::new();
|
||||
p.move_to((0.0, -0.0));
|
||||
p.line_to((1.23456, 2.0));
|
||||
p.quad_to((3.0, 4.0), (5.0, 6.0));
|
||||
p.curve_to((7.0, 8.0), (9.0, 10.0), (11.0, 12.0));
|
||||
p.close_path();
|
||||
assert_eq!(path_data(&p), "M0,0 L1.235,2 Q3,4 5,6 C7,8 9,10 11,12 Z");
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
# FigCraft parity with Figma
|
||||
|
||||
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-11 · **Change:** minor (a boolean group takes a corner radius (and smoothing) that rounds every sharp corner of its result (#2222); the Point section's X and Y in vector edit mode show Mixed and set every selected point of the layer being edited, as in Figma; grid Fill (`fr`) tracks share the space of a fixed-size axis by their fractions and let a fixed-size child overflow, as measured in Figma (300 x 200, two rows, 100 x 150 and 100 x 20 children: rows 100 / 100, second child at y 100; with a row gap of 10, rows 95 / 95 and y 105; on Hug the rows fit their content, 150 / 20) -- this replaces the 2026-10-11 rule from the documentation; an exported layer with a background blur or glass keeps the blurred content behind it within its bounds (#2213); a typed number and a full stop at the start of a paragraph starts a numbered list at that number, as measured in Figma 2026-11-11; justified Chinese, Japanese and Korean text, written without spaces, spreads each line's room between its characters so its right edge aligns (#1970); joining the two ends of a path broken open by a deleted point closes it again, so its fill and selection outline follow the new segment and its corner radius instead of a straight line across the gap (#1951); glass's docs say which centre splay bends away from and where a shape gets no core; glass bends towards its core, rounded rectangles 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, measured against the reference tool; bulleted lists use the same bullet at every level of indentation, as the help center says, instead of a white bullet and a square at the deeper levels; typing `1)` and a space at the start of a paragraph starts a numbered list, as `1.` does, both being the help center's creation characters; a link on text is underlined by default, as the help center says, and Underline takes the underline off while the link stays; a Dash cap setting (none, round or square) on Dash and Custom strokes, drawn on both ends of every dash; gap 6: widgets draw lines and SVG pictures (plugin API 6); gap 6: a widget opens its plugin's panel (plugin API 5), whose callbacks redraw it; the browser build uses the fonts installed on the computer once asked, each read when text uses it (#1051); plugin widgets have hover styles: a layer's `hover` fill, stroke, opacity or text colour shows while the pointer is over it (gap 6); Thai, Lao, Khmer and Burmese lines break between words (#1219); MCP and control calls name their document (#998); shadows of images with transparent pixels follow their alpha (#1289); Arabic draft catalog; truncated text fills its last line before the ellipsis and keeps truncating when resized; auto-height text with max lines (#1375, #1376, #1377), numbers unchanged; 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; `.sketch` import, best effort: import/export breadth 86% → 87%, file formats 60% → 61%, headline numbers unchanged; Canvas & navigation's remaining work no longer lists outline mode's Include hidden layers and Include object bounds; boards: area 22 (weight 0, outside the weighted sum); 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, iteration marks 〱–〵 and the halfwidth parentheses; Turkish reviewed, Czech and Indonesian drafts, the Japanese draft completed; reviewed Russian catalog and integer plurals; vector edit mode regions: hover hatch, selection and drag; plugin log byte/count limits (#191); core editor leftovers: component playground, auto gap handles, variables inside styles, inner shadows and background blur on groups, command-made text readable on dark pages, a one-step frame/group convert, delays on mouse triggers and manual overlay offsets, wrapped-line alignment; starter templates, a Templates tab and Getting started tips on the home screen: essentials ~57% → ~59%; everyday editing partials: number fields, outline options, Hide when publishing, cursors, panel widths, dark pages, numbers unchanged but menu breadth 211/211; text box sizes measured against documents re-saved by other software: whole-pixel line heights, advances on a 1024-per-em grid, letter spacing between glyphs only, numbers unchanged; .fig export checked by opening written files in other software, numbers unchanged; a public figcraft-server: open hosting, owner tokens, per-address limits, idle expiry, moderation, install.sh; experimental .fig export; keyboard shortcut parity suite and bindings; Simplified Chinese draft catalog; Latin American Spanish overlay; prototyping tail: gamepad triggers, widgets in prototypes, mode Line truncated
|
||||
> **Last reviewed:** 2026-11-15 · **Last updated:** 2026-11-15 · **Change:** minor (M6 `.fig` export writes text on a path (#2323), list spacing, hanging punctuation and lists, vertical trim (#2305), vector region paints (#2302), image adjustments (#2297) and a page's prototype background (#2326); M8 Tidy up keeps a row's or column's order and sizes and evens the gaps, rounds the gap, tidies overlapping rows and grids along their longer axis, and raises a negative gap, as measured in Figma (#2319); a polygon's or star's Count handle and a double-click on a layer's icon (zoom, range anchor) follow Figma; Tab while renaming moves only the rename; Align is unavailable in an auto layout frame's flow; the Scale tool pivots on the opposite handle; Paste over selection puts copies above the selected layer; Crop from the image fill's menu crops with a drag (#2307); M10 code export writes every colour and gradient fill in paint order for CSS, SwiftUI, Compose and Flutter (#2271); 24 pt icon buttons draw 16 pt glyphs (#2227, #2238); M5 marquee selection follows Figma's measured rules and Select layer lists locked layers (#1560); M7 the Design panel shows the page's variable modes with nothing selected (#2215); M12 mind maps centre in a section or frame without a place, stickies take a Small–Huge text-size menu, and M9 `.jam` shapes with text import as native board shapes (#1808); M4 a boolean group's corner radius rounds its result (#2222), Flatten bakes a point's corner radius (#2195) and loops close through a joining segment (#1951); library links survive moving or cloning the project folder (#2132); a variable group renamed to a path with `/` nests (#2353); SVG import, widget images, batches and grids take bounded work, and a host's server key is never sent over plain `ws://` to another machine (#1923); releases FigCraft v0.18.0 and v0.18.1; the 2026-10-17 menu measurement (212 / 212) and every percentage and hour stand, not re-measured) · **Target:** Figma Design (desktop app 126.10.7, macOS)
|
||||
|
||||
The authoritative assessment of how close FigCraft is to Figma Design. [`ROADMAP.md`](../ROADMAP.md)
|
||||
summarizes it; [`gaps.md`](gaps.md) is the ranked work list; the measured menu checklist is
|
||||
@@ -11,6 +11,8 @@ summarizes it; [`gaps.md`](gaps.md) is the ranked work list; the measured menu c
|
||||
[`prototyping-parity.md`](prototyping-parity.md), [`dev-mode-parity.md`](dev-mode-parity.md),
|
||||
[`collaboration-parity.md`](collaboration-parity.md), [`boards-parity.md`](boards-parity.md).
|
||||
|
||||
> SVG XML wire follow-up (2026-11-16): export escaping and XML 1.0 character checks delegate to pinned `craft-xml`. Attribute tab/LF/CR are emitted as references to survive XML normalization. Local SVG document/path serialization and import mapping remain; this scoped change does not raise the parity grade. Hosted validation is pending.
|
||||
|
||||
## Headline
|
||||
|
||||
| Number | Value | Kind |
|
||||
@@ -649,6 +651,7 @@ Carried over from the ROADMAP's "Shipped so far" (2026-10-10). The test count th
|
||||
|
||||
| Date | Change | Summary |
|
||||
|---|---|---|
|
||||
| 2026-11-15 | minor | M6 `.fig` export writes text on a path (#2323), list spacing, hanging punctuation and lists, vertical trim (#2305), vector region paints (#2302), image adjustments (#2297) and a page's prototype background (#2326); M8 Tidy up keeps a row's or column's order and sizes and evens the gaps, rounds the gap, tidies overlapping rows and grids along their longer axis, and raises a negative gap, as measured in Figma (#2319); a polygon's or star's Count handle and a double-click on a layer's icon (zoom, range anchor) follow Figma; Tab while renaming moves only the rename; Align is unavailable in an auto layout frame's flow; the Scale tool pivots on the opposite handle; Paste over selection puts copies above the selected layer; Crop from the image fill's menu crops with a drag (#2307); M10 code export writes every colour and gradient fill in paint order for CSS, SwiftUI, Compose and Flutter (#2271); 24 pt icon buttons draw 16 pt glyphs (#2227, #2238); M5 marquee selection follows Figma's measured rules and Select layer lists locked layers (#1560); M7 the Design panel shows the page's variable modes with nothing selected (#2215); M12 mind maps centre in a section or frame without a place, stickies take a Small–Huge text-size menu, and M9 `.jam` shapes with text import as native board shapes (#1808); M4 a boolean group's corner radius rounds its result (#2222), Flatten bakes a point's corner radius (#2195) and loops close through a joining segment (#1951); library links survive moving or cloning the project folder (#2132); a variable group renamed to a path with `/` nests (#2353); SVG import, widget images, batches and grids take bounded work, and a host's server key is never sent over plain `ws://` to another machine (#1923); releases FigCraft v0.18.0 and v0.18.1; the 2026-10-17 menu measurement (212 / 212) and every percentage and hour stand, not re-measured |
|
||||
| 2026-11-10 | minor | M4, #2222: a boolean group's corner radius rounds every sharp corner of its result (row 4). Numbers unchanged |
|
||||
| 2026-11-08 | minor | M8: measured in Figma on 2026-11-08, vector edit mode's Point section: X and Y show the value the selected points share, or Mixed when they differ, and a typed value sets every selected point's own coordinate in the layer being edited, points of other edited layers left as they are (it moved the group's top-left before); a relative edit (`+10`, `*2`, `/2`) typed into a Mixed field applies to each point's own value (`vector.edit.position` takes a number or `{add}`, `{mul}`, `{div}` per axis); the W and H row and other edited layers' points are unchanged. |
|
||||
| 2026-11-11 | patch | M4: typing a number, a full stop and a space at the start of a plain paragraph starts a numbered list at that number (`5. ` then "x", Enter, "y" reads 5. then 6.), as measured in Figma web on 2026-11-11 (it has no start-number field: the start comes only from the typed number); before, only `1. ` and `1)` started a list. `0. `, `12a. ` and a bracket after a number other than 1 stay text (not measured), and the number is capped at 9999. Also measured: a plain paragraph or a bullet item between numbered items restarts the count at 1, and an indented sub-item does not break the outer count; those rows were pinned as silent. Tests: `text_tail_tests::typed_list_starts`, `typed_number_starts_the_list_there`, `tail_tests` restart rows. Numbers unchanged |
|
||||
|
||||
Reference in new issue
Block a user