From 36b2ee28fdf409f50a771e6a84248e72a1d2e6a2 Mon Sep 17 00:00:00 2001 From: Trevor Brown Date: Sat, 7 Nov 2026 23:10:28 -0500 Subject: [PATCH 1/3] Fields: scrubbing a label moves half a step a point, as measured in Figma Measured in Figma: X from 100 gained 6 for a 12.2 px drag and 31 for 61.2 px; rotation 6 degrees and opacity 5% for 12.2 px. The base rate is now half a step a point (SCRUB_STEPS_PER_POINT); Shift x10, Alt x0.1 and the speed by height are kept on top and were not measured. No scrub direction changed. Tests that pinned the old rate follow the new one; docs/ui-parity.md updated. Co-Authored-By: Claude Sonnet 5.5 Model-Effort: Opus 5.5 drove; Opus 5.5 briefed; Sonnet 5.5 wrote at medium --- crates/ui-egui/src/corner_individual_tests.rs | 6 +- crates/ui-egui/src/field_tests.rs | 76 +++++++++---------- crates/ui-egui/src/panels/selection_colors.rs | 10 +-- crates/ui-egui/src/selection_spacing_tests.rs | 2 +- crates/ui-egui/src/typography_scrub_tests.rs | 16 ++-- crates/ui-egui/src/widgets.rs | 9 ++- crates/ui-egui/src/windows_qa_tests.rs | 4 +- docs/ui-parity.md | 3 +- 8 files changed, 66 insertions(+), 60 deletions(-) diff --git a/crates/ui-egui/src/corner_individual_tests.rs b/crates/ui-egui/src/corner_individual_tests.rs index 281ab6f2a..53464a48a 100644 --- a/crates/ui-egui/src/corner_individual_tests.rs +++ b/crates/ui-egui/src/corner_individual_tests.rs @@ -75,7 +75,7 @@ fn ios_button_sets_corner_smoothing_to_60_percent() { #[test] fn corner_smoothing_icon_scrubs_with_modifiers_and_one_undo_step() { for (dx, modifiers, want) in - [(16.0, Modifiers::NONE, 0.66), (8.0, Modifiers::SHIFT, 1.0), (16.0, Modifiers::ALT, 0.516), (-80.0, Modifiers::NONE, 0.0)] + [(16.0, Modifiers::NONE, 0.58), (16.0, Modifiers::SHIFT, 1.0), (16.0, Modifiers::ALT, 0.508), (-160.0, Modifiers::NONE, 0.0)] { let (mut u, r) = scene(); u.app.run("node.set", json!({"ids": [r], "props": {"cornerSmoothing": 0.5}})); @@ -117,7 +117,7 @@ fn consecutive_smoothing_drags_preserve_fractional_percentages() { let history = u.app.session.undo_depth().0; let smoothing = |u: &Ui| u.app.session.doc().unwrap().node(r).unwrap().corners.smoothing; for (step, (dx, modifiers, want)) in - [(16.0, Modifiers::ALT, 0.516), (16.0, Modifiers::ALT, 0.532), (8.0, Modifiers::NONE, 0.612)].into_iter().enumerate() + [(16.0, Modifiers::ALT, 0.508), (16.0, Modifiers::ALT, 0.516), (8.0, Modifiers::NONE, 0.556)].into_iter().enumerate() { let from = u.ctx.read_response(Id::unique("smoothing").with("lead")).unwrap().rect.center(); u.frame_with(vec![Event::PointerMoved(from)], modifiers); @@ -133,7 +133,7 @@ fn consecutive_smoothing_drags_preserve_fractional_percentages() { assert!((smoothing(&u) - want).abs() < 1e-9, "gesture {step}: expected {want}, got {}", smoothing(&u)); assert_eq!(u.app.session.undo_depth().0, history + step + 1); } - for want in [0.532, 0.516, 0.5] { + for want in [0.516, 0.508, 0.5] { u.app.session.undo().unwrap(); assert!((smoothing(&u) - want).abs() < 1e-9, "undo restores the precise value"); } diff --git a/crates/ui-egui/src/field_tests.rs b/crates/ui-egui/src/field_tests.rs index e3bdad1dd..9a18254f6 100644 --- a/crates/ui-egui/src/field_tests.rs +++ b/crates/ui-egui/src/field_tests.rs @@ -111,17 +111,17 @@ fn typed_text_is_a_number_arithmetic_or_an_edit_relative_to_the_value() { } #[test] -fn a_scrub_moves_a_step_a_point_ten_with_shift_and_a_tenth_with_alt() { +fn a_scrub_moves_half_a_step_a_point_ten_times_that_with_shift_and_a_tenth_with_alt() { // (points dragged, the field's step, Shift, Alt) → how far the value moves let rows = [ - ((25.0, 1.0, false, false), 25.0), - ((-25.0, 1.0, false, false), -25.0), - ((10.0, 1.0, true, false), 100.0), - ((20.0, 1.0, false, true), 2.0), - ((20.0, 1.0, true, true), 20.0), - ((10.0, 0.1, false, false), 1.0), - ((10.0, 0.1, true, false), 10.0), - ((10.0, 10.0, false, false), 100.0), + ((25.0, 1.0, false, false), 12.5), + ((-25.0, 1.0, false, false), -12.5), + ((10.0, 1.0, true, false), 50.0), + ((20.0, 1.0, false, true), 1.0), + ((20.0, 1.0, true, true), 10.0), + ((10.0, 0.1, false, false), 0.5), + ((10.0, 0.1, true, false), 5.0), + ((10.0, 10.0, false, false), 50.0), ((0.0, 1.0, true, false), 0.0), ]; for ((dx, step, shift, alt), want) in rows { @@ -308,7 +308,7 @@ fn moving_up_or_down_while_scrubbing_changes_the_speed_and_says_so() { let (mut u, a, _) = setup(); let toast = |u: &Ui| u.app.ui.toast.clone().map(|t| t.0).unwrap_or_default(); // (rise in points, how far 40 points of scrub move X, the notice) - for (rise, want, notice) in [(150.0, 80.0, "2x"), (0.0, 40.0, ""), (-150.0, 20.0, "1/2"), (-300.0, 10.0, "1/4"), (40.0, 40.0, "")] { + for (rise, want, notice) in [(150.0, 40.0, "2x"), (0.0, 20.0, ""), (-150.0, 10.0, "1/2"), (-300.0, 5.0, "1/4"), (40.0, 20.0, "")] { let x0 = geom(&u, a).0; u.app.ui.toast = None; scrub_at_height(&mut u, "X", rise, 40.0); @@ -319,7 +319,7 @@ fn moving_up_or_down_while_scrubbing_changes_the_speed_and_says_so() { assert!(toast(&u).contains(notice), "rise {rise}: the notice says {}", toast(&u)); } } - // Speeds compose with the modifiers' rates: 2x with Shift is twenty steps a point. + // Speeds compose with the modifiers' rates: 2x with Shift is ten steps a point. let x0 = geom(&u, a).0; let from = label(&mut u, "X"); let shift = Modifiers { shift: true, ..Modifiers::NONE }; @@ -333,7 +333,7 @@ fn moving_up_or_down_while_scrubbing_changes_the_speed_and_says_so() { let to = pos2(up.x + 10.0, up.y); u.frame_with(vec![Event::PointerMoved(to), press(false, to)], shift); u.frame(vec![]); - assert_eq!(geom(&u, a).0 - x0, 200.0, "ten points at 2x with Shift"); + assert_eq!(geom(&u, a).0 - x0, 100.0, "ten points at 2x with Shift"); // The pointer reported gone from the window (egui's PointerGone) with the button still down // keeps the speed it had: no notice of 1x, and the scrub goes on at 2x once it is back. let x0 = geom(&u, a).0; @@ -356,7 +356,7 @@ fn moving_up_or_down_while_scrubbing_changes_the_speed_and_says_so() { let to = pos2(up.x + 30.0, up.y); u.frame_with(vec![Event::PointerMoved(to), press(false, to)], m); u.frame(vec![]); - assert_eq!(geom(&u, a).0 - x0, 40.0, "ten points before and ten after the pointer was gone, at 2x both"); + assert_eq!(geom(&u, a).0 - x0, 20.0, "ten points before and ten after the pointer was gone, at 2x both"); } #[test] @@ -366,11 +366,11 @@ fn scrubbing_the_label_moves_the_value_and_is_one_undo_step() { let alt = Modifiers { alt: true, ..Modifiers::NONE }; // (field, points, modifiers, x after): X starts at 10. let rows = [ - ("X", 25.0, Modifiers::NONE, 35.0), - ("X", 10.0, shift, 135.0), - ("X", 20.0, alt, 137.0), - ("X", -37.0, Modifiers::NONE, 100.0), - ("X", -8.0, shift, 20.0), + ("X", 24.0, Modifiers::NONE, 22.0), + ("X", 10.0, shift, 72.0), + ("X", 20.0, alt, 73.0), + ("X", -36.0, Modifiers::NONE, 55.0), + ("X", -8.0, shift, 15.0), ]; for (name, dx, m, want) in rows { let steps = undo_steps(&u); @@ -379,18 +379,18 @@ fn scrubbing_the_label_moves_the_value_and_is_one_undo_step() { assert_eq!(undo_steps(&u), steps + 1, "one undo step for the whole scrub"); } u.app.run("edit.undo", json!({})); - assert_eq!(geom(&u, a).0, 100.0, "undo takes back the last scrub alone"); + assert_eq!(geom(&u, a).0, 55.0, "undo takes back the last scrub alone"); // A few points aren't a drag yet (a click on the label), then it counts from the press. // Alt gives tenths (the field shows them); the fraction stays under a plain scrub. let width = |u: &Ui| u.app.session.doc().unwrap().node(a).unwrap().width; - scrub(&mut u, "Width", 7.0, alt); - assert_eq!(width(&u), 40.7); + scrub(&mut u, "Width", 8.0, alt); + assert_eq!(width(&u), 40.4); scrub(&mut u, "Width", 8.0, Modifiers::NONE); - assert_eq!(width(&u), 48.7); - // Fractional fields: opacity moves a percent a point, rotation a degree. - scrub(&mut u, "Opacity", -30.0, Modifiers::NONE); + assert_eq!(width(&u), 44.4); + // Fractional fields: opacity moves half a percent a point, rotation half a degree. + scrub(&mut u, "Opacity", -60.0, Modifiers::NONE); assert_eq!(u.app.session.doc().unwrap().node(a).unwrap().opacity, 0.7); - scrub(&mut u, "Rotation", 15.0, Modifiers::NONE); + scrub(&mut u, "Rotation", 30.0, Modifiers::NONE); let rot = figcraft_geom::rotation_degrees(u.app.session.doc().unwrap().node(a).unwrap().transform); assert!((rot.abs() - 15.0).abs() < 1e-6, "rotation {rot}"); // A press on the label that doesn't move changes nothing. @@ -607,7 +607,7 @@ fn scrubbing_colour_picker_fields_is_live_and_one_undo_step() { let steps = undo_steps(&u); let from = lead(&u, Id::unique(("cp_f", "r"))); drag(&mut u, from, -20.0, Modifiers::NONE); - assert_eq!((rgba(&u)[0], undo_steps(&u)), (r0 - 20, steps + 1), "R"); + assert_eq!((rgba(&u)[0], undo_steps(&u)), (r0 - 10, steps + 1), "R"); // Committing adds a recent colour row and can lift the anchored picker. Settle its layout. for _ in 0..3 { u.frame(vec![]); @@ -721,7 +721,7 @@ fn scrubbing_a_prototype_delay_sets_it_once_when_let_go() { figcraft_doc::proto::Trigger::AfterDelay { ms } => ms, _ => panic!("still after a delay"), }; - assert_eq!((ms, undo_steps(&u)), (800, steps + 1)); + assert_eq!((ms, undo_steps(&u)), (650, steps + 1)); } /// Asserts scrubbing the scale panel's width scales the layer live in one undo step. @@ -734,7 +734,7 @@ fn scrubbing_the_scale_panel_width_scales_live_in_one_undo_step() { let from = lead(&u, Id::unique("scale_w")); drag(&mut u, from, 20.0, Modifiers::NONE); let (_, _, w, h) = geom(&u, a); - assert_eq!((w, h, undo_steps(&u)), (60.0, 45.0, steps + 1), "40×30 scaled to a width of 60"); + assert_eq!((w, h, undo_steps(&u)), (50.0, 37.5, steps + 1), "40×30 scaled to a width of 50"); } /// The texts painted in the last frame: what they say, whether they end in an ellipsis, and where @@ -1314,10 +1314,10 @@ fn the_page_background_opacity_field_sets_the_page_colour_alpha() { type_into(&mut u, "Opacity", "50", Key::Enter); assert!(near(page_bg(&u).a, 0.5), "{:?}", page_bg(&u)); assert_eq!(undo_steps(&u), steps + 1, "one undo step for the commit"); - // No label is drawn, so the field's leading strip scrubs it: a percent a point, live, and one + // No label is drawn, so the field's leading strip scrubs it: half a percent a point, live, and one // undo step for the whole drag. let edge = lead(&u, Id::unique("pagebg_a")); - drag(&mut u, edge, -25.0, Modifiers::NONE); + drag(&mut u, edge, -50.0, Modifiers::NONE); assert!(near(page_bg(&u).a, 0.25), "{:?}", page_bg(&u)); assert_eq!(undo_steps(&u), steps + 2, "one undo step for the whole scrub"); u.app.run("edit.undo", json!({})); @@ -1350,7 +1350,7 @@ fn the_page_background_opacity_field_sets_the_page_colour_alpha() { /// "You can also hover the input field itself and hold down the modifier key: Mac: ⌥ Option /// Windows: Alt" to scrub it (Adjust alignment, rotation, position, and dimensions). Alt is what -/// makes the drag a scrub there, not the fine rate: a point moves a step, as on the label. Without +/// makes the drag a scrub there, not the fine rate: a point moves half a step, as on the label. Without /// Alt a drag on the field is no click, so it neither edits nor moves anything. #[test] fn alt_held_over_a_field_scrubs_it() { @@ -1361,13 +1361,13 @@ fn alt_held_over_a_field_scrubs_it() { // a drag only once it has seen Alt; egui assigns a press by the frame before it). let alt = Modifiers { alt: true, ..Modifiers::NONE }; u.frame_with(vec![Event::PointerMoved(at)], alt); - drag(&mut u, at, 25.0, alt); - assert_eq!(geom(&u, a).0, 35.0, "a step a point: X from 10"); + drag(&mut u, at, 24.0, alt); + assert_eq!(geom(&u, a).0, 22.0, "half a step a point: X from 10"); assert_eq!(undo_steps(&u), steps + 1, "one undo step for the whole scrub"); - assert_eq!(field(&mut u, "X").1, "35", "the field shows it and isn't editing"); + assert_eq!(field(&mut u, "X").1, "22", "the field shows it and isn't editing"); let (at, _) = field(&mut u, "X"); drag(&mut u, at, 25.0, Modifiers::NONE); - assert_eq!(geom(&u, a).0, 35.0, "without Alt the field doesn't scrub"); + assert_eq!(geom(&u, a).0, 22.0, "without Alt the field doesn't scrub"); assert_eq!(undo_steps(&u), steps + 1); // Alt let go before the button still ends the scrub with its undo step. let (at, _) = field(&mut u, "X"); @@ -1380,7 +1380,7 @@ fn alt_held_over_a_field_scrubs_it() { let to = pos2(at.x + 20.0, at.y); u.frame_with(vec![Event::PointerMoved(to), press(false, Modifiers::NONE, to)], Modifiers::NONE); u.frame(vec![]); - assert_eq!(geom(&u, a).0, 55.0, "twenty more"); + assert_eq!(geom(&u, a).0, 32.0, "ten more"); assert_eq!(undo_steps(&u), steps + 2, "committed when the button went up, without Alt"); // Without Alt the field doesn't take the drag at all (a touch swipe over it is the panel's to // scroll): the press is a click of the field's, not a drag. @@ -1392,7 +1392,7 @@ fn alt_held_over_a_field_scrubs_it() { assert!(!u.ctx.is_being_dragged(field_id), "a plain press on the field isn't a drag of the field's"); u.frame_with(vec![Event::PointerMoved(pos2(at.x + 10.0, at.y)), press(false, Modifiers::NONE, pos2(at.x + 10.0, at.y))], Modifiers::NONE); u.frame(vec![]); - assert_eq!(geom(&u, a).0, 55.0, "nothing scrubbed"); + assert_eq!(geom(&u, a).0, 32.0, "nothing scrubbed"); // With Alt held over it, the field does take the drag. let (at, _) = field(&mut u, "X"); u.frame_with(vec![Event::PointerMoved(at)], alt); @@ -1401,5 +1401,5 @@ fn alt_held_over_a_field_scrubs_it() { assert!(u.ctx.is_being_dragged(field_id), "with Alt the drag is the field's"); u.frame_with(vec![Event::PointerMoved(pos2(at.x + 10.0, at.y)), press(false, alt, pos2(at.x + 10.0, at.y))], alt); u.frame(vec![]); - assert_eq!(geom(&u, a).0, 65.0, "ten more"); + assert_eq!(geom(&u, a).0, 37.0, "five more"); } diff --git a/crates/ui-egui/src/panels/selection_colors.rs b/crates/ui-egui/src/panels/selection_colors.rs index dbb6f16e4..98ca91393 100644 --- a/crates/ui-egui/src/panels/selection_colors.rs +++ b/crates/ui-egui/src/panels/selection_colors.rs @@ -500,7 +500,7 @@ mod tests { let red = texts.into_iter().find(|(text, _)| text == "FF0000").unwrap().1; let start = Pos2::new(167.0, red.y); p.modifiers.alt = true; - for expected in [0.989, 0.979] { + for expected in [0.994, 0.989] { p.frame(vec![ Event::PointerMoved(start), Event::PointerButton { pos: start, button: egui::PointerButton::Primary, pressed: true, modifiers: p.modifiers }, @@ -518,8 +518,8 @@ mod tests { let opacity = p.app.session.doc().unwrap().node(a).unwrap().fills[0].opacity; assert!((opacity - expected).abs() < 1e-6, "fine scrub kept fractional baseline: {opacity}"); } - assert!(p.frame(vec![]).iter().any(|(text, _)| text == "97.9%")); - for expected in [0.989, 0.999] { + assert!(p.frame(vec![]).iter().any(|(text, _)| text == "98.9%")); + for expected in [0.994, 0.999] { p.app.run("edit.undo", json!({})); let opacity = p.app.session.doc().unwrap().node(a).unwrap().fills[0].opacity; assert!((opacity - expected).abs() < 1e-6, "each fine scrub is one undo step: {opacity}"); @@ -555,13 +555,13 @@ mod tests { Event::PointerMoved(start), Event::PointerButton { pos: start, button: egui::PointerButton::Primary, pressed: true, modifiers: Default::default() }, ]); - for dx in [-10.0, -20.0, -30.0] { + for dx in [-20.0, -40.0, -60.0] { p.frame(vec![Event::PointerMoved(start + vec2(dx, 0.0))]); } assert!(p.app.session.ds().unwrap().interaction.is_some(), "the scrub commits only on release"); assert!(p.frame(vec![]).iter().any(|(text, _)| text == "70%"), "the live opacity stays visible while scrubbing"); p.frame(vec![Event::PointerButton { - pos: start - vec2(30.0, 0.0), + pos: start - vec2(60.0, 0.0), button: egui::PointerButton::Primary, pressed: false, modifiers: Default::default(), diff --git a/crates/ui-egui/src/selection_spacing_tests.rs b/crates/ui-egui/src/selection_spacing_tests.rs index d23f34360..46a484fcc 100644 --- a/crates/ui-egui/src/selection_spacing_tests.rs +++ b/crates/ui-egui/src/selection_spacing_tests.rs @@ -62,7 +62,7 @@ fn spacing_fields_type_scrub_and_keep_one_undo_step() { u.frame(vec![]); let lead = u.ctx.read_response(field.with("lead")).unwrap().rect.center(); drag(&mut u, lead, vec2(16., 0.), true); - assert_eq!(xy(&u, ids[1]), (196., 100.)); + assert_eq!(xy(&u, ids[1]), (188., 100.)); assert_eq!(u.app.session.undo_depth().0, history + 1); u.app.run("edit.undo", json!({})); assert_eq!(xy(&u, ids[1]), (180., 100.)); diff --git a/crates/ui-egui/src/typography_scrub_tests.rs b/crates/ui-egui/src/typography_scrub_tests.rs index df61936db..13fe993b3 100644 --- a/crates/ui-egui/src/typography_scrub_tests.rs +++ b/crates/ui-egui/src/typography_scrub_tests.rs @@ -84,18 +84,18 @@ fn typography_icon_drag_changes_each_spacing_field_in_one_undo_step() { let mut f = Fields::new(); let undo = f.app.session.undo_depth().0; f.drag(key, 16.0, Modifiers::NONE); - assert_eq!(f.value(key), before + 16.0, "{key}: dragging the icon must change the value"); + assert_eq!(f.value(key), before + 8.0, "{key}: dragging the icon must change the value"); assert_eq!(f.app.session.undo_depth().0, undo + 1, "{key}: one gesture, one undo step"); f.app.session.undo().unwrap(); assert_eq!(f.value(key), before); f.app.session.redo().unwrap(); - assert_eq!(f.value(key), before + 16.0); + assert_eq!(f.value(key), before + 8.0); } } #[test] fn typography_icon_scrub_uses_shift_and_alt_rates_and_the_resize_cursor() { - for (modifiers, delta) in [(Modifiers::SHIFT, 160.0), (Modifiers::ALT, 1.6)] { + for (modifiers, delta) in [(Modifiers::SHIFT, 80.0), (Modifiers::ALT, 0.8)] { for (key, start) in [("ty_lh", 24.0), ("ty_ls", 0.0), ("ty_ps", 12.0)] { let mut f = Fields::new(); let p = f.lead(key); @@ -114,10 +114,10 @@ fn typography_icon_scrub_preserves_units_and_clamps_only_nonnegative_fields() { f.drag("ty_lh", 16.0, Modifiers::NONE); f.drag("ty_ls", -16.0, Modifiers::NONE); let t = f.app.session.doc().unwrap().node(f.text).unwrap().kind.text().unwrap(); - assert_eq!(t.style.line_height, LineHeight::Percent(166.0)); - assert_eq!(t.style.letter_spacing, LetterSpacing::Pixels(-14.0)); - f.drag("ty_lh", -200.0, Modifiers::NONE); - f.drag("ty_ps", -200.0, Modifiers::NONE); + assert_eq!(t.style.line_height, LineHeight::Percent(158.0)); + assert_eq!(t.style.letter_spacing, LetterSpacing::Pixels(-6.0)); + f.drag("ty_lh", -320.0, Modifiers::NONE); + f.drag("ty_ps", -320.0, Modifiers::NONE); assert_eq!(f.value("ty_lh"), 0.0); assert_eq!(f.value("ty_ps"), 0.0); assert!(f.app.ui.last_error.is_none(), "{:?}", f.app.ui.last_error); @@ -152,7 +152,7 @@ fn typography_icon_scrub_changes_only_the_selected_characters_without_ending_tex f.drag("ty_ls", 16.0, Modifiers::NONE); let t = f.app.session.doc().unwrap().node(f.text).unwrap().kind.text().unwrap(); assert_eq!(t.style_at(0).letter_spacing, LetterSpacing::Pixels(0.0)); - assert_eq!(t.style_at(1).letter_spacing, LetterSpacing::Pixels(16.0)); + assert_eq!(t.style_at(1).letter_spacing, LetterSpacing::Pixels(8.0)); assert_eq!(t.style_at(4).letter_spacing, LetterSpacing::Pixels(0.0)); assert!(f.app.session.ds().unwrap().text_edit.is_some()); assert_eq!(f.app.session.undo_depth().0, undo); diff --git a/crates/ui-egui/src/widgets.rs b/crates/ui-egui/src/widgets.rs index eae46fd81..008c387db 100644 --- a/crates/ui-egui/src/widgets.rs +++ b/crates/ui-egui/src/widgets.rs @@ -114,10 +114,15 @@ fn key_steps(ctx: &egui::Context, suffix: &str, step: f64) -> (f64, f64) { } } -/// How far a scrub of `dx` points moves a value whose field steps by `step`: 1 step a point, ten -/// with Shift, a tenth with Alt (fine). +/// The steps a point of scrubbing moves a field by: half, as measured in Figma (12.2 px moved X +/// by 6, 61.2 px by 31). +pub const SCRUB_STEPS_PER_POINT: f64 = 0.5; + +/// How far a scrub of `dx` points moves a value whose field steps by `step`: half a step a point +/// ([`SCRUB_STEPS_PER_POINT`]), ten times that with Shift, a tenth with Alt (fine). pub fn scrub_amount(dx: f64, step: f64, shift: bool, alt: bool) -> f64 { dx * step + * SCRUB_STEPS_PER_POINT * match (shift, alt) { (true, false) => 10.0, (false, true) => 0.1, diff --git a/crates/ui-egui/src/windows_qa_tests.rs b/crates/ui-egui/src/windows_qa_tests.rs index f4b1fd7f4..40db85af1 100644 --- a/crates/ui-egui/src/windows_qa_tests.rs +++ b/crates/ui-egui/src/windows_qa_tests.rs @@ -70,10 +70,10 @@ fn a_scrubbed_field_keeps_its_value_when_the_pointer_lets_go() { for k in 1..=10 { u.frame(vec![Event::PointerMoved(from + vec2(4.0 * k as f32, 0.0))]); } - assert_eq!(width(&u, a).0, 80.0, "40 points to the right while dragging"); + assert_eq!(width(&u, a).0, 60.0, "40 points to the right while dragging: half a step a point"); u.button(from + vec2(40.0, 0.0), false); u.frame(vec![]); - assert_eq!(width(&u, a).0, 80.0, "kept after the release"); + assert_eq!(width(&u, a).0, 60.0, "kept after the release"); assert_eq!(u.app.session.doc().unwrap().node(a).unwrap().height, 30.0); } diff --git a/docs/ui-parity.md b/docs/ui-parity.md index aa0ef25bd..d0fa0c254 100644 --- a/docs/ui-parity.md +++ b/docs/ui-parity.md @@ -73,7 +73,7 @@ interaction feel not yet compared. | Ctrl to suspend snapping while dragging (macOS) | done | Control on macOS (Cmd keeps working), Ctrl elsewhere; moving, resizing and drawing | | Measure (Alt hover, Cmd+Alt nested, Shift+Alt padding/gaps) | done | labels never overlap; the arrows still nudge while measuring (Shift: the big step) and the distances follow; the selection's handles and size label hide while measuring (`measure_nudge_tests`, #894) | | Pixel grid snapping, pixel preview, 2x preview | done | moves, resizes and new shapes land on whole pixels; the pixel grid shows from 400% (`view_behaviour_tests`) | -| Numeric fields: arithmetic, scrubbing by dragging the label (or the field itself with Alt held), 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; while scrubbing, the pointer's height sets the speed (more than 100 points above where the scrub began: 2x; that far below: 1/2; twice as far: 1/4), a toast names the speed when it changes, and Shift and Alt multiply as before ("Change the speed that you scrub the field by moving the cursor towards the top of the screen to increase the scrubbing speed, or towards the bottom of the screen to reduce it", Scrub fields; #1837) | +| Numeric fields: arithmetic, scrubbing by dragging the label (or the field itself with Alt held), 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: half a step a point (0.5 px; 0.5% of opacity, 0.5° of rotation), as measured in Figma on 2026-11-08 (a 12.2 px drag moved X by 6, a 61.2 px drag by 31; rotation by 6° and opacity by 5% for 12.2 px; `plan/loop/measurements/scrub-and-panels.md`), ten times that with Shift, a tenth with Alt (neither measured), 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; the Shift and Alt rates and the speed by height are not compared with Figma's, and the rotation scrub's direction is not confirmed; while scrubbing, the pointer's height sets the speed (more than 100 points above where the scrub began: 2x; that far below: 1/2; twice as far: 1/4), a toast names the speed when it changes, and Shift and Alt multiply as before ("Change the speed that you scrub the field by moving the cursor towards the top of the screen to increase the scrubbing speed, or towards the bottom of the screen to reduce it", Scrub fields; #1837) | | 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 | @@ -187,6 +187,7 @@ in the table. `crates/ui-egui/src/shortcut_keys_tests.rs` drives the keys a look | Date | Change | Summary | |---|---|---| +| 2026-11-07 | patch | Number fields: scrubbing a label moves half a step a point, not a step, as measured in Figma (X from 100: +6 for a 12.2 px drag, +31 for 61.2 px; rotation 6° and opacity 5% for 12.2 px); Shift (x10), Alt (x0.1) and the speed by height are kept on top of it and were not measured, and no field's scrub direction changed | | 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` | | 2026-11-01 | patch | Number fields: dragging the field itself with Alt held scrubs it ("You can also hover the input field itself and hold down the modifier key: Mac: ⌥ Option Windows: Alt", Adjust alignment, rotation, position, and dimensions), with the resize cursor and the label's rates (Alt is the enabler there, so it isn't the fine rate); a click with Alt doesn't open the editor. Found by a documentation audit of the ui-parity rows. Test: `field_tests::alt_held_over_a_field_scrubs_it`. Counts unchanged | | 2026-11-02 | patch | M6, #1839: 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 by the nudge amounts (`tool.crosshair`), Enter places the object there (`tool.place`), Escape or a tool change takes it away; the canvas draws the crosshair and `ui.inspect` reports it (`tool.crosshair`), the Keyboard shortcuts panel lists the gesture ("Use the arrow keys to activate the crosshair cursor...", Accessibility at Figma). The board Shapes tool places on it too (its 160 px shape centred, as the tool centres a press), and the view pans by the overshoot when the crosshair is nudged past its edge. Tests: `place_crosshair_tests`, `shortcut_keys_tests::arrows_show_and_move_the_placement_crosshair_with_a_shape_tool`. | From c6c2696079c27a9e123b1d266eb0cc818a86c1d0 Mon Sep 17 00:00:00 2001 From: Trevor Brown Date: Sun, 8 Nov 2026 00:31:58 -0500 Subject: [PATCH 2/3] Docs: Shift and Alt scrub rates spelled out; one date; no local notes path (#2102 review) Co-Authored-By: Claude Opus 5.5 Model-Effort: Opus 5.5 drove and wrote --- crates/ui-egui/src/widgets.rs | 2 +- docs/ui-parity.md | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/ui-egui/src/widgets.rs b/crates/ui-egui/src/widgets.rs index 008c387db..aed1f05e1 100644 --- a/crates/ui-egui/src/widgets.rs +++ b/crates/ui-egui/src/widgets.rs @@ -119,7 +119,7 @@ fn key_steps(ctx: &egui::Context, suffix: &str, step: f64) -> (f64, f64) { pub const SCRUB_STEPS_PER_POINT: f64 = 0.5; /// How far a scrub of `dx` points moves a value whose field steps by `step`: half a step a point -/// ([`SCRUB_STEPS_PER_POINT`]), ten times that with Shift, a tenth with Alt (fine). +/// ([`SCRUB_STEPS_PER_POINT`]), ten times that with Shift (5 steps a point), a tenth of that with Alt (0.05 steps a point, fine). pub fn scrub_amount(dx: f64, step: f64, shift: bool, alt: bool) -> f64 { dx * step * SCRUB_STEPS_PER_POINT diff --git a/docs/ui-parity.md b/docs/ui-parity.md index d0fa0c254..c999b0a66 100644 --- a/docs/ui-parity.md +++ b/docs/ui-parity.md @@ -73,7 +73,7 @@ interaction feel not yet compared. | Ctrl to suspend snapping while dragging (macOS) | done | Control on macOS (Cmd keeps working), Ctrl elsewhere; moving, resizing and drawing | | Measure (Alt hover, Cmd+Alt nested, Shift+Alt padding/gaps) | done | labels never overlap; the arrows still nudge while measuring (Shift: the big step) and the distances follow; the selection's handles and size label hide while measuring (`measure_nudge_tests`, #894) | | Pixel grid snapping, pixel preview, 2x preview | done | moves, resizes and new shapes land on whole pixels; the pixel grid shows from 400% (`view_behaviour_tests`) | -| Numeric fields: arithmetic, scrubbing by dragging the label (or the field itself with Alt held), 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: half a step a point (0.5 px; 0.5% of opacity, 0.5° of rotation), as measured in Figma on 2026-11-08 (a 12.2 px drag moved X by 6, a 61.2 px drag by 31; rotation by 6° and opacity by 5% for 12.2 px; `plan/loop/measurements/scrub-and-panels.md`), ten times that with Shift, a tenth with Alt (neither measured), 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; the Shift and Alt rates and the speed by height are not compared with Figma's, and the rotation scrub's direction is not confirmed; while scrubbing, the pointer's height sets the speed (more than 100 points above where the scrub began: 2x; that far below: 1/2; twice as far: 1/4), a toast names the speed when it changes, and Shift and Alt multiply as before ("Change the speed that you scrub the field by moving the cursor towards the top of the screen to increase the scrubbing speed, or towards the bottom of the screen to reduce it", Scrub fields; #1837) | +| Numeric fields: arithmetic, scrubbing by dragging the label (or the field itself with Alt held), 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: half a step a point (0.5 px; 0.5% of opacity, 0.5° of rotation), as measured in Figma on 2026-11-08 (a 12.2 px drag moved X by 6, a 61.2 px drag by 31; rotation by 6° and opacity by 5% for 12.2 px), ten times that with Shift (5 steps a point) and a tenth of that with Alt (0.05 steps a point; neither measured), 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; the Shift and Alt rates and the speed by height are not compared with Figma's, and the rotation scrub's direction is not confirmed; while scrubbing, the pointer's height sets the speed (more than 100 points above where the scrub began: 2x; that far below: 1/2; twice as far: 1/4), a toast names the speed when it changes, and Shift and Alt multiply as before ("Change the speed that you scrub the field by moving the cursor towards the top of the screen to increase the scrubbing speed, or towards the bottom of the screen to reduce it", Scrub fields; #1837) | | 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 | @@ -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-07 | patch | Number fields: scrubbing a label moves half a step a point, not a step, as measured in Figma (X from 100: +6 for a 12.2 px drag, +31 for 61.2 px; rotation 6° and opacity 5% for 12.2 px); Shift (x10), Alt (x0.1) and the speed by height are kept on top of it and were not measured, and no field's scrub direction changed | +| 2026-11-08 | patch | Number fields: scrubbing a label moves half a step a point, not a step, as measured in Figma (X from 100: +6 for a 12.2 px drag, +31 for 61.2 px; rotation 6° and opacity 5% for 12.2 px); Shift (x10), Alt (x0.1) and the speed by height are kept on top of it and were not measured, and no field's scrub direction changed | | 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` | | 2026-11-01 | patch | Number fields: dragging the field itself with Alt held scrubs it ("You can also hover the input field itself and hold down the modifier key: Mac: ⌥ Option Windows: Alt", Adjust alignment, rotation, position, and dimensions), with the resize cursor and the label's rates (Alt is the enabler there, so it isn't the fine rate); a click with Alt doesn't open the editor. Found by a documentation audit of the ui-parity rows. Test: `field_tests::alt_held_over_a_field_scrubs_it`. Counts unchanged | | 2026-11-02 | patch | M6, #1839: 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 by the nudge amounts (`tool.crosshair`), Enter places the object there (`tool.place`), Escape or a tool change takes it away; the canvas draws the crosshair and `ui.inspect` reports it (`tool.crosshair`), the Keyboard shortcuts panel lists the gesture ("Use the arrow keys to activate the crosshair cursor...", Accessibility at Figma). The board Shapes tool places on it too (its 160 px shape centred, as the tool centres a press), and the view pans by the overshoot when the crosshair is nudged past its edge. Tests: `place_crosshair_tests`, `shortcut_keys_tests::arrows_show_and_move_the_placement_crosshair_with_a_shape_tool`. | From c0dbaecec3f10d8851b59864c8210a9b80a52189 Mon Sep 17 00:00:00 2001 From: Trevor Brown Date: Thu, 12 Nov 2026 06:01:15 -0500 Subject: [PATCH 3/3] Merge fix: main's field tests with this PR's scrub rate main's the_rotation_field_shows_and_sets_the_rotation_on_the_page (added in #2200) scrubbed the Rotation field 15 points and expected +15 degrees, the old one-step-a-point rate. This PR measured the rotation icon in Figma at about half a degree a point (a 12.2 px drag gave 6 degrees), and the PR's own scrubbing_the_label_moves_the_value test already drags Rotation 30 points for 15 degrees. The test now drags 30 points; the +15 expectation and what it checks (page angle through a rotated parent, one undo step) are unchanged. Co-Authored-By: Claude Sonnet 5.5 Model-Effort: Opus 5.5 drove; Opus 5.5 briefed; Sonnet 5.5 wrote at medium --- crates/ui-egui/src/field_tests.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/ui-egui/src/field_tests.rs b/crates/ui-egui/src/field_tests.rs index 8e54f7b3e..483acd444 100644 --- a/crates/ui-egui/src/field_tests.rs +++ b/crates/ui-egui/src/field_tests.rs @@ -470,7 +470,7 @@ fn the_rotation_field_shows_and_sets_the_rotation_on_the_page() { assert_eq!(field(&mut u, "Rotation").1, "18°"); // Scrubbing is one undo step. let steps = undo_steps(&u); - scrub(&mut u, "Rotation", 15.0, Modifiers::NONE); + scrub(&mut u, "Rotation", 30.0, Modifiers::NONE); assert!((page(&u, r) - 33.0).abs() < 1e-6, "{}", page(&u, r)); assert_eq!(undo_steps(&u), steps + 1); // Mixed: layers in differently turned parents agree when their page angles do.