From 02e8f644fde722ee647228cbacc9c090dab9a09b Mon Sep 17 00:00:00 2001 From: Ahmed5Emad Date: Sun, 18 Oct 2026 21:02:22 +0300 Subject: [PATCH] M2: doc comments for the padding diff's functions --- crates/engine/src/cmd/layout.rs | 1 + crates/ui-egui/src/layout_panel.rs | 2 ++ crates/ui-egui/src/padding_individual_tests.rs | 5 +++++ 3 files changed, 8 insertions(+) diff --git a/crates/engine/src/cmd/layout.rs b/crates/engine/src/cmd/layout.rs index b545e52d..da1301ec 100644 --- a/crates/engine/src/cmd/layout.rs +++ b/crates/engine/src/cmd/layout.rs @@ -149,6 +149,7 @@ mod tests { assert!(s.execute("node.set", &json!({"id": b, "props": {"absolute": "maybe"}})).is_err()); } + /// Each side key writes its own padding slot and leaves the other three alone. #[test] fn each_side_padding_sets_its_side_alone() { let mut s = Session::new(); diff --git a/crates/ui-egui/src/layout_panel.rs b/crates/ui-egui/src/layout_panel.rs index 9f69c6c4..6c8d6693 100644 --- a/crates/ui-egui/src/layout_panel.rs +++ b/crates/ui-egui/src/layout_panel.rs @@ -401,6 +401,8 @@ fn alignment(app: &mut FigApp, ui: &mut Ui, ids: &[NodeId], l: &AutoLayout) { } } +/// The Spacing row: gap fields, then the H/V padding pair (or the 2x2 per-side +/// grid while the individual-padding toggle is open). fn spacing(app: &mut FigApp, ui: &mut Ui, ids: &[NodeId], l: &AutoLayout) { let col = widgets::col_width(ui.available_width()); let [pt, pr, pb, pl] = l.padding; diff --git a/crates/ui-egui/src/padding_individual_tests.rs b/crates/ui-egui/src/padding_individual_tests.rs index 8fdb3192..28a207bc 100644 --- a/crates/ui-egui/src/padding_individual_tests.rs +++ b/crates/ui-egui/src/padding_individual_tests.rs @@ -23,16 +23,19 @@ fn scene() -> (Ui, NodeId) { (Ui::new(s), f) } +/// The frame's padding as `[top, right, bottom, left]`. fn padding(u: &Ui, f: NodeId) -> [f64; 4] { u.app.session.doc().unwrap().node(f).unwrap().layout.clone().unwrap().padding } +/// A full press-and-release at `p`, then settling one frame. fn click(u: &mut Ui, p: Pos2) { u.button(p, true); u.button(p, false); u.frame(vec![]); } +/// A press-and-release of Enter, committing the focused number field. fn enter(u: &mut Ui) { u.frame(vec![ Event::Key { key: Key::Enter, physical_key: None, pressed: true, repeat: false, modifiers: Modifiers::NONE }, @@ -51,6 +54,8 @@ fn named_button(u: &mut Ui, label: &str) -> Pos2 { pos2(((b.x0 + b.x1) / 2.0) as f32, ((b.y0 + b.y1) / 2.0) as f32) } +/// The side fields stay hidden until the toggle opens, then typing in one sets +/// that side alone in a single undo step. #[test] fn side_fields_show_only_once_the_toggle_opens_and_set_one_side() { let (mut u, f) = scene();