diff --git a/crates/ui-egui/src/canvas/handles.rs b/crates/ui-egui/src/canvas/handles.rs index e5f3a38a0..87bde6962 100644 --- a/crates/ui-egui/src/canvas/handles.rs +++ b/crates/ui-egui/src/canvas/handles.rs @@ -554,6 +554,7 @@ pub fn draw(app: &mut FigApp, painter: &egui::Painter) { return; } let Some(z) = al_zones(app) else { return }; + let tokens = crate::theme::Tokens::get(painter.ctx()); let handles = padding_handles(&z.bands); let active_side = match &dragging { Some(Drag::Padding { side, .. }) => Some(*side), @@ -571,8 +572,13 @@ pub fn draw(app: &mut FigApp, painter: &egui::Painter) { pink_label(painter, crate::canvas::fmt(*v), handle.center() + offset); } let grip = Rect::from_center_size(handle.center(), if side.is_multiple_of(2) { vec2(16.0, 4.0) } else { vec2(4.0, 16.0) }); - painter.rect_filled(grip, CornerRadius::same(2), if linked { PINK } else { PINK.gamma_multiply(0.6) }); - painter.rect_stroke(grip, CornerRadius::same(2), Stroke::new(if linked { 1.5 } else { 1.0 }, Color32::WHITE), StrokeKind::Outside); + painter.rect_filled(grip, CornerRadius::same(2), if linked { tokens.padding_grip } else { tokens.padding_grip.gamma_multiply(0.6) }); + painter.rect_stroke( + grip, + CornerRadius::same(2), + Stroke::new(if linked { 1.5 } else { 1.0 }, tokens.padding_grip_border), + StrokeKind::Outside, + ); } let drag_key = match &dragging { Some(Drag::Gap { key, .. }) => Some(*key), diff --git a/crates/ui-egui/src/canvas/handles/padding_tests.rs b/crates/ui-egui/src/canvas/handles/padding_tests.rs index a29734089..84756db67 100644 --- a/crates/ui-egui/src/canvas/handles/padding_tests.rs +++ b/crates/ui-egui/src/canvas/handles/padding_tests.rs @@ -274,3 +274,32 @@ fn padding_grips_preserve_secondary_click_context_menus() { assert_eq!(u.app.session.undo_depth(), history); } } + +/// Custom light/dark palettes must control both grip states and their outlines. +#[test] +fn padding_grips_use_the_theme_fill_and_outline() { + for mut tokens in [crate::theme::Tokens::light(), crate::theme::Tokens::dark()] { + let (mut u, _) = scene(); + let grips = painted_grips(&u.frame_output(vec![Event::PointerGone])); + assert_eq!(grips.len(), 4); + tokens.padding_grip = if tokens.dark { egui::Color32::from_rgb(20, 40, 60) } else { egui::Color32::from_rgb(120, 40, 60) }; + tokens.padding_grip_border = egui::Color32::from_rgb(210, 180, 150); + for active in [false, true] { + let events = if active { vec![Event::PointerMoved(grips[0].center())] } else { vec![Event::PointerGone] }; + let raw = egui::RawInput { screen_rect: Some(Rect::from_min_size(egui::Pos2::ZERO, u.screen)), events, ..Default::default() }; + let mut output = u.ctx.clone().run_ui(raw, |ui| { + crate::theme::apply(ui.ctx(), tokens); + super::draw(&mut u.app, ui.painter()); + }); + output.textures_delta.clear(); + let shapes = crate::live_tests::flat(&output.shapes); + for (side, grip) in grips.iter().enumerate() { + let linked = active && side == 0; + let fill = if linked { tokens.padding_grip } else { tokens.padding_grip.gamma_multiply(0.6) }; + assert!(shapes.iter().any(|shape| matches!(shape, egui::Shape::Rect(r) if r.rect == *grip && r.fill == fill))); + let width = if linked { 1.5 } else { 1.0 }; + assert!(shapes.iter().any(|shape| matches!(shape, egui::Shape::Rect(r) if r.rect == *grip && r.stroke.color == tokens.padding_grip_border && r.stroke.width == width))); + } + } + } +} diff --git a/crates/ui-egui/src/theme.rs b/crates/ui-egui/src/theme.rs index e8a039ba5..784ada713 100644 --- a/crates/ui-egui/src/theme.rs +++ b/crates/ui-egui/src/theme.rs @@ -42,6 +42,10 @@ pub struct Tokens { pub success: Color32, pub warning: Color32, pub guide: Color32, + /// Auto layout padding grips on the canvas. + pub padding_grip: Color32, + /// Contrasting edge around padding grips, including their dimmed state. + pub padding_grip_border: Color32, pub tab_bar: Color32, pub tab_active: Color32, pub shadow: Color32, @@ -133,6 +137,8 @@ impl Tokens { success: DEV_READY, warning: Color32::from_rgb(0xFF, 0xCD, 0x29), guide: Color32::from_rgb(0xF2, 0x48, 0x22), + padding_grip: Color32::from_rgb(0xF2, 0x48, 0x8C), + padding_grip_border: Color32::WHITE, tab_bar: Color32::from_rgb(0xE8, 0xE8, 0xE8), tab_active: Color32::from_rgb(0xFF, 0xFF, 0xFF), shadow: Color32::from_black_alpha(40), @@ -176,6 +182,8 @@ impl Tokens { success: DEV_READY, warning: Color32::from_rgb(0xFF, 0xCD, 0x29), guide: Color32::from_rgb(0xF2, 0x48, 0x22), + padding_grip: Color32::from_rgb(0xF2, 0x48, 0x8C), + padding_grip_border: Color32::WHITE, tab_bar: Color32::from_rgb(0x1E, 0x1E, 0x1E), tab_active: Color32::from_rgb(0x2C, 0x2C, 0x2C), shadow: Color32::from_black_alpha(90), diff --git a/docs/auto-layout-parity.md b/docs/auto-layout-parity.md index 70048cc60..691936b65 100644 --- a/docs/auto-layout-parity.md +++ b/docs/auto-layout-parity.md @@ -1,6 +1,6 @@ # Auto layout and constraints parity -> **Last reviewed:** 2026-10-11 · **Last updated:** 2026-11-13 · **Change:** patch (padding grips preserve canvas hover and right-click menus; padding grips stay reachable on tiny frames and at reduced zoom; 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; a child dragged within its own auto layout row or column passes a sibling when its leading edge reaches the sibling's middle, as measured in Figma's web app, wherever it is grabbed; a Cmd/Ctrl-click on a padding field sets all four sides with the value typed, as the Guide to auto layout's shortcut guide says; Suggest auto layout is its own command, as the help center says: it adds as many auto layout frames as needed, splitting a frame's layers into rows or columns by the gaps between them, and keeps the placement of the design where the gaps are even (#1823); baseline alignment puts a layer without text with its bottom on the line, as the help center's figure shows an icon next to text (#1825); fill children share the free space by their content area, border-box fashion, as the Flexbox article says (#1824); double-click an edge of an auto layout frame's box for Hug contents, Alt+double-click an edge of a child's box for Fill container, as the Guide to auto layout says (#1838); a child resized to the full available space of its auto layout frame becomes Fill container on that axis, as the Guide to auto layout says; a text keeps a max height or a number of max lines, not both, as the Guide to auto layout says: a max height sets max lines to Auto and max lines remove the max height; Remove all auto layout, as the help center's More layout options has it: `layout.removeAll` takes the auto layout off a frame and every frame nested in it in one undo step; grid auto-placement looks for free cells a 64-bit word at a time and skips what blocks it, with the same placements (#1083); Layout sidebar: Add auto layout (+) is available for groups and converts a single group to a frame in place, with mask order, flow-only inference and Fill sizing preserved; adding auto layout to an empty frame keeps its size (#369); `node.set` applies auto layout keys only to frames, with warnings (#603); core editor leftovers: auto gap handles, wrapped-line alignment; behaviour suite written from the public documentation, every rule's status; fixes and the missing settings it found) · **Target:** Figma Design (desktop app 126.10.7) +> **Last reviewed:** 2026-10-11 · **Last updated:** 2026-11-13 · **Change:** patch (padding grip fills and outlines follow theme tokens; padding grips preserve canvas hover and right-click menus; padding grips stay reachable on tiny frames and at reduced zoom; 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; a child dragged within its own auto layout row or column passes a sibling when its leading edge reaches the sibling's middle, as measured in Figma's web app, wherever it is grabbed; a Cmd/Ctrl-click on a padding field sets all four sides with the value typed, as the Guide to auto layout's shortcut guide says; Suggest auto layout is its own command, as the help center says: it adds as many auto layout frames as needed, splitting a frame's layers into rows or columns by the gaps between them, and keeps the placement of the design where the gaps are even (#1823); baseline alignment puts a layer without text with its bottom on the line, as the help center's figure shows an icon next to text (#1825); fill children share the free space by their content area, border-box fashion, as the Flexbox article says (#1824); double-click an edge of an auto layout frame's box for Hug contents, Alt+double-click an edge of a child's box for Fill container, as the Guide to auto layout says (#1838); a child resized to the full available space of its auto layout frame becomes Fill container on that axis, as the Guide to auto layout says; a text keeps a max height or a number of max lines, not both, as the Guide to auto layout says: a max height sets max lines to Auto and max lines remove the max height; Remove all auto layout, as the help center's More layout options has it: `layout.removeAll` takes the auto layout off a frame and every frame nested in it in one undo step; grid auto-placement looks for free cells a 64-bit word at a time and skips what blocks it, with the same placements (#1083); Layout sidebar: Add auto layout (+) is available for groups and converts a single group to a frame in place, with mask order, flow-only inference and Fill sizing preserved; adding auto layout to an empty frame keeps its size (#369); `node.set` applies auto layout keys only to frames, with warnings (#603); core editor leftovers: auto gap handles, wrapped-line alignment; behaviour suite written from the public documentation, every rule's status; fixes and the missing settings it found) · **Target:** Figma Design (desktop app 126.10.7) Auto layout is the most used layout feature in Figma and the one where small differences (a hugging frame one pixel off, text wrapping at another width) break real files. **Breadth ~98%, @@ -116,6 +116,7 @@ Status: **pass** (a case in the suite holds), **fixed** (the suite found a diver | Date | Change | Summary | |---|---|---| +| 2026-11-13 | patch | M2, #2152: Padding grip fills and outlines come from dedicated theme tokens, preserving linked-state emphasis and border widths. A rendering regression checks custom light and dark palettes. | | 2026-11-13 | patch | M2, #2152: Padding grips preserve canvas hover and secondary-click context menus while retaining their resize cursor. Only primary presses and active handle drags capture input. Regressions reproduce both stale layer hover and blocked right-click menus. | | 2026-11-11 | patch | M2.1: 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). Layout behaviour suite: three cases flipped, three added | | 2026-11-10 | patch | M2: Opposite padding grips separate to at least 20 screen pixels on tiny frames or at reduced zoom. Overlapping targets select the nearest visible grip, shared by hover, highlighting and drag. Regression tests click every painted grip, drag and undo on thin, narrow and tiny frames, including an inside stroke and 25% zoom. |