mirror of
https://github.com/storytold/figcraft.git
synced 2026-11-13 13:52:34 +00:00
M5: marquee: a drag from inside a frame takes it whole when it takes another top-level frame, as re-measured
In top-level mode the frame the drag started in is now selected whole (re-measure 2: [F1, F2], R1 not selected); with no other frame taken only the touched shapes are. Test 9 uses the re-measure's literal marquees; docs reworded and docs/mcp.md rewrapped. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Model-Effort: Opus 5.5 drove; Fable 5.1 briefed; Sonnet 5.5 wrote at medium
This commit is contained in:
1 parent
cb52621414
commit
604c78466c
4 files changed
+43
-20
No files matched your search
@@ -454,7 +454,8 @@ fn path_touches_rect(n: &Node, path: &BezPath, xf: figcraft_geom::Affine, rect:
|
||||
/// Whether a marquee takes a touched top-level layer whole, opens it for the layers in it, or skips it.
|
||||
enum Touch {
|
||||
Whole,
|
||||
/// The frame the drag started in: only the layers in it the marquee touches.
|
||||
/// The frame the drag started in: the layers in it the marquee touches, or the frame itself
|
||||
/// (whole) once the marquee is at the top level.
|
||||
Open,
|
||||
/// A partly covered frame or section: the layers in it, or the frame itself once the marquee is at the top level.
|
||||
Partial,
|
||||
@@ -464,9 +465,10 @@ enum Touch {
|
||||
/// Figma's marquee rule (measured in the web app, 2026-11-11): each top-level layer the marquee
|
||||
/// touches is selected whole, except a frame with children or a section with its contents shown:
|
||||
/// enclosed by the marquee it is selected itself, otherwise the marquee takes the layers in it that
|
||||
/// it touches. The frame the drag started in (`start_inside`) is never selected itself, only the
|
||||
/// layers in it the marquee touches. Selecting a frame or section whole keeps the marquee at the
|
||||
/// top level: no frame opens then, and a partly covered one is selected whole. Components, instances, board items and sections with hidden
|
||||
/// it touches. The frame the drag started in (`start_inside`) is selected only when the marquee also
|
||||
/// takes another top-level frame (then whole); otherwise only the layers in it the marquee touches.
|
||||
/// Selecting a frame or section whole keeps the marquee at the top level: no frame opens then, and a
|
||||
/// partly covered one is selected whole. Components, instances, board items and sections with hidden
|
||||
/// contents are selected only when enclosed.
|
||||
pub fn marquee_select(doc: &Document, page: NodeId, rect: Rect, start_inside: Option<NodeId>) -> Vec<NodeId> {
|
||||
let Some(page_node) = doc.node(page) else { return Vec::new() };
|
||||
@@ -500,13 +502,13 @@ pub fn marquee_select(doc: &Document, page: NodeId, rect: Rect, start_inside: Op
|
||||
for (t, act, _) in &classified {
|
||||
match act {
|
||||
Touch::Whole => out.push(*t),
|
||||
Touch::Partial if top_level_mode => out.push(*t),
|
||||
Touch::Open | Touch::Partial if !top_level_mode => {
|
||||
Touch::Open | Touch::Partial if top_level_mode => out.push(*t),
|
||||
Touch::Open | Touch::Partial => {
|
||||
if let Some(n) = doc.node(*t) {
|
||||
out.extend(marquee_children(doc, n, rect));
|
||||
}
|
||||
}
|
||||
Touch::Open | Touch::Partial | Touch::Skip => {}
|
||||
Touch::Skip => {}
|
||||
}
|
||||
}
|
||||
out
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
//! Marquee selection, as measured in Figma's web app (2026-11-11, the "marquee rules" and "confirming
|
||||
//! pass" readings) and described in the help-center article "Select layers and objects": a drag
|
||||
//! pass" readings, and the two evening re-measures) and described in the help-center article "Select layers and objects": a drag
|
||||
//! selects each top-level layer it touches; a partly covered frame or section gives the layers in it
|
||||
//! the marquee touches, an enclosed one is selected itself; a drag started inside a frame never selects
|
||||
//! that frame; selecting a frame whole keeps the marquee at the top level; a rotated shape is touched by
|
||||
//! the marquee touches, an enclosed one is selected itself; a drag started inside a frame selects that frame
|
||||
//! only when the marquee also takes another top-level frame (then whole); selecting a frame whole keeps the marquee at the top level; a rotated shape is touched by
|
||||
//! its outline, an unrotated one by its box.
|
||||
|
||||
use serde_json::{Value, json};
|
||||
@@ -154,17 +154,18 @@ fn a_rotated_ellipse_is_not_touched_by_its_axis_aligned_box() {
|
||||
fn a_rotated_ellipse_is_not_touched_through_the_corner_of_its_turned_box() {
|
||||
let mut s = Session::new();
|
||||
let k = scene(&mut s);
|
||||
// Not the measurement's literal numbers (see the brief, section 5): a point inside the turned box
|
||||
// but outside the ellipse.
|
||||
let p = Point::new(690.0, 420.0);
|
||||
// The re-measure's literal marquees (evening, section 1): corner A, the deeper B, and the control.
|
||||
let p = Point::new(692.0, 419.0);
|
||||
let doc = s.doc().unwrap();
|
||||
let n = doc.node(k.re).unwrap();
|
||||
assert!(n.local_rect().contains(doc.world_transform(k.re).inverse() * p), "the probe is inside the turned box");
|
||||
assert_eq!(selected(&mut s, (727.0, 407.0), (690.0, 420.0)), Vec::<NodeId>::new());
|
||||
assert_eq!(selected(&mut s, (715.0, 411.0), (692.0, 419.0)), Vec::<NodeId>::new(), "measured marquee A");
|
||||
assert_eq!(selected(&mut s, (715.0, 411.0), (683.0, 419.0)), Vec::<NodeId>::new(), "measured marquee B");
|
||||
assert_eq!(selected(&mut s, (715.0, 411.0), (667.0, 419.0)), vec![k.re], "measured control");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_drag_from_inside_a_frame_never_selects_it() {
|
||||
fn a_drag_from_inside_a_frame_selects_only_what_it_touches() {
|
||||
let mut s = Session::new();
|
||||
let k = scene(&mut s);
|
||||
let start_x = |s: &Session| s.doc().unwrap().world_bounds(k.f1).map(|b| (b.x0, b.y0));
|
||||
@@ -198,3 +199,20 @@ fn a_marquee_enclosing_an_empty_frame_takes_a_partly_covered_frame_whole() {
|
||||
let f2 = id(&ex(&mut s, "frame.create", json!({"x": 400, "y": 0, "width": 200, "height": 150})));
|
||||
assert_eq!(selected(&mut s, (650.0, 170.0), (40.0, -10.0)), sorted(vec![f1, f2]), "measured re-measure: F2 and F1, not R1");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_drag_from_inside_a_frame_takes_it_whole_when_it_takes_another_top_level_frame() {
|
||||
let mut s = Session::new();
|
||||
let f1 = id(&ex(&mut s, "frame.create", json!({"x": 0, "y": 0, "width": 300, "height": 200})));
|
||||
let r1 = rect(&mut s, 20.0, 20.0, 60.0, 60.0, Some(f1));
|
||||
let _r2 = rect(&mut s, 220.0, 120.0, 60.0, 60.0, Some(f1));
|
||||
let f2 = id(&ex(&mut s, "frame.create", json!({"x": 0, "y": 400, "width": 200, "height": 150})));
|
||||
let rr = rect(&mut s, 400.0, 400.0, 200.0, 100.0, None);
|
||||
ex(&mut s, "select.none", json!({}));
|
||||
assert_eq!(selected(&mut s, (150.0, 100.0), (90.0, 720.0)), sorted(vec![f1, f2]), "re-measure 2, case 1");
|
||||
let sel = selected(&mut s, (150.0, 50.0), (50.0, 720.0));
|
||||
assert_eq!(sel, sorted(vec![f1, f2]), "re-measure 2, case 2b: R1 is covered in part and still not selected");
|
||||
assert!(!sel.contains(&r1));
|
||||
assert_eq!(selected(&mut s, (150.0, 100.0), (450.0, 450.0)), sorted(vec![f1, f2, rr]), "re-measure 2, case 3");
|
||||
assert_eq!(selected(&mut s, (290.0, 100.0), (450.0, 450.0)), vec![rr], "re-measure 2, case 3b: the frame only when another is taken");
|
||||
}
|
||||
+5
-2
@@ -675,8 +675,11 @@ on; `key` resolves keys the way the canvas does. Commands behind keys:
|
||||
panel has the keyboard (after F6 or a click on a row), else on the canvas below the selection; the
|
||||
menu takes the keyboard and gives it back when it closes (no-op headless).
|
||||
- `select.area {x, y, width, height, add?, deep?}`: select what a marquee from `x, y` over that box
|
||||
(page units) would: the top-level layers it touches (a rotated shape by its outline), a frame or section
|
||||
only when the box covers it and otherwise the layers in it the box touches, never the frame the box starts in; `add` toggles like a Shift marquee, `deep` takes nested layers
|
||||
(page units) would: the top-level layers it touches (a rotated shape by its outline); an empty
|
||||
frame on touch; any other frame or section only when the box covers it, otherwise the layers in it
|
||||
the box touches, except that once the box takes a frame whole, a partly covered frame comes whole
|
||||
too, and the frame the box starts in is selected only then (when the box also takes another
|
||||
top-level frame); `add` toggles like a Shift marquee, `deep` takes nested layers
|
||||
like Cmd/Ctrl. Returns `{selection}`. Without a box (`F8` in the app) it draws one for the
|
||||
keyboard around the selection (or in the middle of the view): the arrows move it, Shift+arrows
|
||||
move its far corner (10 screen pixels a press), Enter selects (Shift+Enter adds, Cmd/Ctrl+Enter
|
||||
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
# UI and interaction parity
|
||||
|
||||
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-11 · **Change:** minor (the marquee follows Figma's measured rules: a partly covered frame or section gives the layers in it the marquee touches, a rotated shape is touched by its outline, a drag from inside a frame never selects that frame (`marquee_behaviour_tests`); the main menu and its submenus stay inside the window, moving up to fit and scrolling when taller (#2217); locked layers ignore the arrow keys and a locked parent's children can't be locked on their own (#1560); the left rail's and tab strip's icons are larger, 20 pt (#553); pick select: Tab while the keyboard selection box shows (or the chord again) puts a pink outline on a layer and the keys walk the layer tree from it, as Accessibility at Figma says (#1836); scrubbing a field faster or slower by the pointer's height, with a notice of the speed, as the help center's Scrub fields says (#1837); component rows in the Layers panel at AA contrast in the theme's component tint, with the rows inside a selected component in a tone of its row (#1903); Cmd/Ctrl-click on a padding field sets all four sides with the value typed, a documented auto layout shortcut; a fill per region of a vector: with regions selected in edit mode, the Fill section and the fill commands edit those regions' own fills, as Edit vector layers says (#1875); the Fill section of a text whose characters were coloured differently while editing shows mixed content, characters that all share fills the layer doesn't have show those, and a layer-level fill edit reaches every character (#1856); a number field scrubs when dragged with Alt held, as the help center's scrub section says, not only by its label; reuse visible layer selection roots (M8); ; with a shape or frame tool chosen and nothing selected, the arrows show a placement crosshair in the middle of the view and move it, and Enter places there, as Accessibility at Figma says (#1839); text direction per paragraph: Text ▸ Text direction forces a paragraph left to right or right to left, as Add right-to-left text says (#1830), with `text.direction`, `node.set textDirection`, the Type settings control once a right-to-left script is in the text, inspect, the CSS `direction` and the `.fig` lines' `sourceDirectionality`; the boolean operation menu in the Design panel leads each entry with an original icon drawn in code, a filled preview of the result (#2003); a press on the open gradient's handles or stops on the canvas keeps the colour picker open through the drag, as its own control (#1852); a click with the Bend tool on a sharp point curves it, its handles along the line between its neighbours, as Edit vector layers says (#1875); wrap style: Auto, Balance and Pretty on a text layer decide where its lines break, as Explore text properties says (#1827), with the Type settings control, `text.wrapStyle`, `node.set wrapStyle`, inspect and the CSS `text-wrap`; Backspace or Delete at the start of a list item keeps the item's indentation level, as the lists article says; max lines on auto-width text keep it auto width, hugging that many lines, as the text properties article says; superscript and subscript are synthesised where the font has no glyphs for them, from the standard glyphs shrunk and shifted by the font's OS/2 metrics, and a run mixing available and unavailable glyphs is synthesised whole, as Explore text properties says (#1828); Alt+Enter while editing text opens the link at the caret, as the accessibility page documents; Minimize, by its shortcut or the button by the file name, collapses the navigation bar and both sidebars as the help center says, with the right sidebar back while something is selected (#1835); the interface size keys of the help center's accessibility page: Cmd/Ctrl+Shift+Alt with =, - and 0 step the interface through the Preferences sizes and back to the system's size; Cmd/Ctrl+Alt+arrows rotate the selection a degree at a time, 15 with Shift, as the help center's accessibility page says; they resized before; the Layers panel answers Ctrl+1 as well as Alt+1 on Windows and Linux, the two keys the help center gives it; the colour picker's Image tab shows a placeholder and Upload from computer, an asset preview, and a file dropped on it replaces the image, keeping the fill mode, crop and position (#1682); the keyboard's Menu key opens the context menu, as Shift+F10 does; the eyedropper with Cmd/Ctrl+Shift makes a colour style or variable of what it picks; sidebar number and text fields keep their text vertically centered when focused, including typography spacing; with the pen out, Enter or a double-click ends the path and edits the vector with the Move tool instead of drawing on (#1430); the Actions palette offers only commands that run from it, and no second row reading like a menu item: Place image opens the file dialog (#1574); Preferences ▸ Scroll wheel zoom: a mouse wheel zooms the canvas about the pointer and Cmd/Ctrl+wheel scrolls (#13Line truncated
|
||||
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-11 · **Change:** minor (the marquee follows Figma's measured rules: a partly covered frame or section gives the layers in it the marquee touches, a rotated shape is touched by its outline, a drag from inside a frame selects that frame only when the marquee also takes another top-level frame (then whole) (`marquee_behaviour_tests`); the main menu and its submenus stay inside the window, moving up to fit and scrolling when taller (#2217); locked layers ignore the arrow keys and a locked parent's children can't be locked on their own (#1560); the left rail's and tab strip's icons are larger, 20 pt (#553); pick select: Tab while the keyboard selection box shows (or the chord again) puts a pink outline on a layer and the keys walk the layer tree from it, as Accessibility at Figma says (#1836); scrubbing a field faster or slower by the pointer's height, with a notice of the speed, as the help center's Scrub fields says (#1837); component rows in the Layers panel at AA contrast in the theme's component tint, with the rows inside a selected component in a tone of its row (#1903); Cmd/Ctrl-click on a padding field sets all four sides with the value typed, a documented auto layout shortcut; a fill per region of a vector: with regions selected in edit mode, the Fill section and the fill commands edit those regions' own fills, as Edit vector layers says (#1875); the Fill section of a text whose characters were coloured differently while editing shows mixed content, characters that all share fills the layer doesn't have show those, and a layer-level fill edit reaches every character (#1856); a number field scrubs when dragged with Alt held, as the help center's scrub section says, not only by its label; reuse visible layer selection roots (M8); ; with a shape or frame tool chosen and nothing selected, the arrows show a placement crosshair in the middle of the view and move it, and Enter places there, as Accessibility at Figma says (#1839); text direction per paragraph: Text ▸ Text direction forces a paragraph left to right or right to left, as Add right-to-left text says (#1830), with `text.direction`, `node.set textDirection`, the Type settings control once a right-to-left script is in the text, inspect, the CSS `direction` and the `.fig` lines' `sourceDirectionality`; the boolean operation menu in the Design panel leads each entry with an original icon drawn in code, a filled preview of the result (#2003); a press on the open gradient's handles or stops on the canvas keeps the colour picker open through the drag, as its own control (#1852); a click with the Bend tool on a sharp point curves it, its handles along the line between its neighbours, as Edit vector layers says (#1875); wrap style: Auto, Balance and Pretty on a text layer decide where its lines break, as Explore text properties says (#1827), with the Type settings control, `text.wrapStyle`, `node.set wrapStyle`, inspect and the CSS `text-wrap`; Backspace or Delete at the start of a list item keeps the item's indentation level, as the lists article says; max lines on auto-width text keep it auto width, hugging that many lines, as the text properties article says; superscript and subscript are synthesised where the font has no glyphs for them, from the standard glyphs shrunk and shifted by the font's OS/2 metrics, and a run mixing available and unavailable glyphs is synthesised whole, as Explore text properties says (#1828); Alt+Enter while editing text opens the link at the caret, as the accessibility page documents; Minimize, by its shortcut or the button by the file name, collapses the navigation bar and both sidebars as the help center says, with the right sidebar back while something is selected (#1835); the interface size keys of the help center's accessibility page: Cmd/Ctrl+Shift+Alt with =, - and 0 step the interface through the Preferences sizes and back to the system's size; Cmd/Ctrl+Alt+arrows rotate the selection a degree at a time, 15 with Shift, as the help center's accessibility page says; they resized before; the Layers panel answers Ctrl+1 as well as Alt+1 on Windows and Linux, the two keys the help center gives it; the colour picker's Image tab shows a placeholder and Upload from computer, an asset preview, and a file dropped on it replaces the image, keeping the fill mode, crop and position (#1682); the keyboard's Menu key opens the context menu, as Shift+F10 does; the eyedropper with Cmd/Ctrl+Shift makes a colour style or variable of what it picks; sidebar number and text fields keep their text vertically centered when focused, including typography spacing; with the pen out, Enter or a double-click ends the path and edits the vector with the Move tool instead of drawing on (#1430); the Actions palette offers only commands that run from it, and no second row reading like a menu item: Place image opens the file dialog (#1574); Preferences ▸ Scroll wheel zoom: a mouse wheel zoLine truncated
|
||||
|
||||
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:
|
||||
@@ -56,7 +56,7 @@ interaction feel not yet compared.
|
||||
|
||||
| Item | Status | Notes |
|
||||
|---|---|---|
|
||||
| Click, Shift-click, marquee, Shift-marquee toggle | done | Shift-drag on a selected layer moves the selection, kept to one axis (#498); a marquee selects the top-level layers it touches, by the box and a rotated shape by its outline (rectangle and ellipse measured, the other shapes by the same code); a partly covered top-level frame or section gives the layers in it the marquee touches, an enclosed one is selected itself, an empty frame on touch; a drag from a frame's background never selects that frame and also takes what it touches outside it; selecting a frame whole keeps the marquee at the top level (a partly covered frame then comes whole too); locked and hidden layers are skipped (`marquee_behaviour_tests`, `selection_behaviour_tests`; measured in Figma's web app, 2026-11-11; Shift and Cmd/Ctrl marquees not measured) (a locked layer selected from the panel ignores the arrow keys and the nudge commands; its properties still edit; measured in Figma's web app, 2026-11-10) |
|
||||
| Click, Shift-click, marquee, Shift-marquee toggle | done | Shift-drag on a selected layer moves the selection, kept to one axis (#498); a marquee selects the top-level layers it touches, by the box and a rotated shape by its outline (rectangle and ellipse measured, the other shapes by the same code); a partly covered top-level frame or section gives the layers in it the marquee touches, an enclosed one is selected itself, an empty frame on touch; a drag from a frame's background selects that frame only when the marquee also takes another top-level frame (then whole), and also takes what it touches outside it; selecting a frame whole keeps the marquee at the top level (a partly covered frame then comes whole too); locked and hidden layers are skipped (`marquee_behaviour_tests`, `selection_behaviour_tests`; measured in Figma's web app, 2026-11-11; Shift and Cmd/Ctrl marquees not measured) (a locked layer selected from the panel ignores the arrow keys and the nudge commands; its properties still edit; measured in Figma's web app, 2026-11-10) |
|
||||
| Deep select (Cmd/Ctrl-click, Cmd/Ctrl-marquee) | done | |
|
||||
| Select layer menu (every layer under the click) | done | |
|
||||
| Enter / Shift+Enter (children / parent), Tab / Shift+Tab (siblings) | done | Tab renames the next layer while renaming |
|
||||
@@ -187,7 +187,7 @@ in the table. `crates/ui-egui/src/shortcut_keys_tests.rs` drives the keys a look
|
||||
|
||||
| Date | Change | Summary |
|
||||
|---|---|---|
|
||||
| 2026-11-11 | patch | M5, gap 4: marquee selection as measured in Figma's web app (Select layers and objects, Selection marquee): a partly covered top-level frame or section gives the layers in it the marquee touches (it was selected only when enclosed, so nothing came), an empty frame is selected on touch, a rotated shape is touched by its outline and not its box, a drag from inside a frame never selects that frame and also takes the top-level layers it touches outside it, and selecting a frame whole keeps the marquee at the top level (a partly covered frame then comes whole, not its layers). Flipped: `marquee_selects_what_it_touches`, `cmd_marquee_selects_nested_layers`, `a_box_selects_like_a_marquee`. Tests: `marquee_behaviour_tests`. Counts unchanged |
|
||||
| 2026-11-11 | patch | M5, gap 4: marquee selection as measured in Figma's web app (Select layers and objects, Selection marquee): a partly covered top-level frame or section gives the layers in it the marquee touches (it was selected only when enclosed, so nothing came), an empty frame is selected on touch, a rotated shape is touched by its outline and not its box, a drag from inside a frame selects that frame only when the marquee also takes another top-level frame (then whole), and also takes the top-level layers it touches outside it, and selecting a frame whole keeps the marquee at the top level (a partly covered frame then comes whole, not its layers). Flipped: `marquee_selects_what_it_touches`, `cmd_marquee_selects_nested_layers`, `a_box_selects_like_a_marquee`. Tests: `marquee_behaviour_tests`. Counts unchanged |
|
||||
| 2026-11-10 | patch | M5, #1560: locked layers follow Figma's rules (Lock and unlock layers; measured in Figma's web app): a locked layer selected in the Layers panel ignores the arrow keys and the nudge commands while its properties still edit, and a child of a locked layer keeps its padlock inert (the Layers panel padlock, Lock/Unlock and `object.toggleLock` without a value no longer lock the child on its own) |
|
||||
| 2026-11-10 | patch | #2217: the main menu's submenus (Object, say) ran past the window's bottom, behind the taskbar, with the lowest commands out of reach, because submenus were not constrained to the window (to keep them beside their row). Every menu panel now scrolls when taller than the window less 8 pt margins, and a submenu is held within the window's height (moved up, never above the top) while keeping its place beside its row, so menu-aim is unchanged. Tests: `menu_overflow_tests.rs`. Numbers unchanged. |
|
||||
| 2026-11-02 | patch | Shortcuts: a Cmd/Ctrl-click on a padding field (the horizontal or vertical pair, or a side with Individual padding open) makes the value typed go to all four sides, in one undo step (Guide to auto layout, Keyboard shortcut guide); a plain click still edits that axis or side alone. A documented gesture row: 134 documented, 133 bound. Test: `padding_individual_tests` |
|
||||
|
||||
Reference in new issue
Block a user