From aec8579000247716d4600804525f9b9a295288f8 Mon Sep 17 00:00:00 2001 From: Hector Villarreal Date: Sat, 24 Oct 2026 18:58:35 -0600 Subject: [PATCH 1/7] feat(ui): drag the zones of a Hue/Saturation colour range (#9252) The range bar's handles moved one at a time. As in Photoshop 2025, dragging between them moves them together: the fully-on span moves all four, the left or right fade its own two. A side stops at the other and the range never passes a turn. One history step per drag. Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/dialogs/adjust_editors.rs | 25 +++++++- .../dialogs/adjust_editors/hue_saturation.rs | 60 +++++++++++++++++++ .../src/dialogs/adjust_editors/ui_tests.rs | 29 +++++++++ docs/ui-parity.md | 3 +- 4 files changed, 115 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/src/dialogs/adjust_editors.rs b/crates/ui-egui/src/dialogs/adjust_editors.rs index c2c503d05c..a7cca0af24 100644 --- a/crates/ui-egui/src/dialogs/adjust_editors.rs +++ b/crates/ui-egui/src/dialogs/adjust_editors.rs @@ -45,7 +45,7 @@ use gradient_map::gradient_map; pub use gradient_map::{gradient_presets, is_gray, swatches}; use hue_saturation::hue_saturation; #[cfg(test)] -use hue_saturation::{lightness_track, move_hue_range_handle, saturation_track}; +use hue_saturation::{hue_range_zone, lightness_track, move_hue_range_handle, move_hue_range_zone, saturation_track}; use levels::levels; pub use levels::{auto_levels, gamma_from_pos, gamma_pos}; pub use session::{layer_editor, layer_mem, properties_coalesce, properties_reset, session_start}; @@ -261,6 +261,29 @@ mod tests { assert_eq!(track_stops(&cx(false), &stops), None); } + /// #9252: Photoshop 2025's zone drags on a colour range (measured on Reds): the fully-on span + /// moves all four handles, each fade its own two; a side stops at the other and the range + /// never passes a turn. + #[test] + fn hue_range_zones_move_their_handles() { + let reds = [-45.0, -15.0, 15.0, 45.0]; + assert_eq!(hue_range_zone(reds, 345.0 - 15.0), Some(0)); + assert_eq!(hue_range_zone(reds, 0.0), Some(1)); + assert_eq!(hue_range_zone(reds, 30.0), Some(2)); + assert_eq!(hue_range_zone(reds, 180.0), None); + let centre = move_hue_range_zone(reds, 1, 37.0); + assert_eq!(centre, [-8.0, 22.0, 52.0, 82.0], "all four, as Photoshop's 315/345…15\\45 → 352/21…52\\81"); + let left = move_hue_range_zone(centre, 0, -19.0); + assert_eq!(left, [-27.0, 3.0, 52.0, 82.0], "the left two only"); + let right = move_hue_range_zone(left, 2, 19.0); + assert_eq!(right, [-27.0, 3.0, 71.0, 101.0], "the right two only"); + assert_eq!(move_hue_range_zone(reds, 0, 100.0), [-15.0, 15.0, 15.0, 45.0], "the left side stops at the right"); + assert_eq!(move_hue_range_zone(reds, 2, -100.0), [-45.0, -15.0, -15.0, 15.0], "and the right at the left"); + let wide = move_hue_range_zone(reds, 2, 500.0); + assert!(wide[3] - wide[0] <= 359.0 + 1e-3, "{wide:?}"); + assert_eq!(move_hue_range_zone(reds, 1, f32::NAN), reds); + } + #[test] fn hue_range_drag_canonicalizes_bounds_before_clamping() { let moved = move_hue_range_handle([0.0, 350.0, 100.0, 200.0], 2, 354.0); diff --git a/crates/ui-egui/src/dialogs/adjust_editors/hue_saturation.rs b/crates/ui-egui/src/dialogs/adjust_editors/hue_saturation.rs index b1c61947fa..0e90c3ec6e 100644 --- a/crates/ui-egui/src/dialogs/adjust_editors/hue_saturation.rs +++ b/crates/ui-egui/src/dialogs/adjust_editors/hue_saturation.rs @@ -38,6 +38,46 @@ pub(super) fn move_hue_range_handle(bounds: [f32; 4], k: usize, deg: f32) -> [f3 b } +/// Which zone of a colour range a hue `deg` falls in, between its handles: 0 = the left fade +/// (between the first two), 1 = the fully-on span, 2 = the right fade; `None` outside the range. +pub(super) fn hue_range_zone(bounds: [f32; 4], deg: f32) -> Option { + let b = HueRange::canonical_bounds(bounds); + let rel = (deg - b[0]).rem_euclid(360.0); + let (one, two, three) = (b[1] - b[0], b[2] - b[0], b[3] - b[0]); + if rel <= one { + Some(0) + } else if rel <= two { + Some(1) + } else if rel <= three { + Some(2) + } else { + None + } +} + +/// A drag of `delta` degrees on a zone of a colour range (#9252), as in Photoshop: the left fade +/// moves the two left handles, the fully-on span all four, the right fade the two right handles; +/// a side never crosses the other or grows the range past a turn. +pub(super) fn move_hue_range_zone(start: [f32; 4], zone: u8, delta: f32) -> [f32; 4] { + let b = HueRange::canonical_bounds(start); + if !delta.is_finite() { + return b; + } + let moved = match zone { + 0 => { + let d = delta.min(b[2] - b[1]).max(b[3] - 359.0 - b[0]); + [b[0] + d, b[1] + d, b[2], b[3]] + } + 1 => b.map(|v| v + delta), + 2 => { + let d = delta.max(b[1] - b[2]).min(b[0] + 359.0 - b[3]); + [b[0], b[1], b[2] + d, b[3] + d] + } + _ => b, + }; + HueRange::canonical_bounds(moved) +} + /// The spectrum bar after the adjustment (what each hue becomes), sampled at `n` hues. fn adjusted_spectrum(v: &Value, n: usize) -> Vec { let adj = photocraft_engine::commands::adjustment_from_params("hueSaturation", v); @@ -177,14 +217,34 @@ pub(super) fn hue_saturation(ui: &mut egui::Ui, v: &mut Value, cx: &EditorCx) -> p.rect_filled(Rect::from_center_size(pos2(x, mid), vec2(5.0, 12.0)), 1.0, fill); p.rect_stroke(Rect::from_center_size(pos2(x, mid), vec2(5.0, 12.0)), 1.0, Stroke::new(1.0, t.text_dim), StrokeKind::Inside); } + ui.data_mut(|d| d.insert_temp(cx.mem.with("hs-range-bars"), bars)); let drag_id = cx.mem.with("hs-range-drag"); + let zone_id = cx.mem.with("hs-range-zone"); let mut which: Option = ui.data(|d| d.get_temp(drag_id)).flatten(); + // A press between the handles drags a zone (#9252): its zone, the bounds and x it began at. + let mut zone: Option<(u8, [f32; 4], f32)> = ui.data(|d| d.get_temp(zone_id)).flatten(); if bresp.is_pointer_button_down_on() && ui.input(|i| i.pointer.primary_pressed()) && let Some(pos) = ui.input(|i| i.pointer.press_origin()) { which = nearest(&b.map(xof), pos.x).filter(|k| (xof(b[*k as usize]) - pos.x).abs() < 10.0); + zone = if which.is_none() { hue_range_zone(b, deg_of(pos.x)).map(|z| (z, b, pos.x)) } else { None }; } + if bresp.is_pointer_button_down_on() + && let (Some((z, start, x0)), Some(pos)) = (zone, ui.input(|i| i.pointer.interact_pos())) + { + let before = b; + b = move_hue_range_zone(start, z, (pos.x - x0) / w * 360.0); + if b != before { + v[key]["range"] = json!(b.map(|x| x.round())); + e.changed = true; + } + } + if zone.is_some() && !bresp.is_pointer_button_down_on() { + zone = None; + e.commit = true; + } + ui.data_mut(|d| d.insert_temp(zone_id, zone)); if bresp.is_pointer_button_down_on() && let (Some(k), Some(pos)) = (which, ui.input(|i| i.pointer.interact_pos())) { diff --git a/crates/ui-egui/src/dialogs/adjust_editors/ui_tests.rs b/crates/ui-egui/src/dialogs/adjust_editors/ui_tests.rs index f41fe4eca0..68b9793d5a 100644 --- a/crates/ui-egui/src/dialogs/adjust_editors/ui_tests.rs +++ b/crates/ui-egui/src/dialogs/adjust_editors/ui_tests.rs @@ -995,3 +995,32 @@ fn gradient_map_stop_picker_closed_without_a_colour_changes_nothing() { assert!(h.state().live_adjust.is_none()); } } + +/// #9252: in a Hue/Saturation layer's Properties, dragging the zones between the range handles +/// moves them as Photoshop does: the fully-on span all four, a fade its own two; one history step +/// per drag. +#[test] +fn hue_saturation_range_zones_drag_their_handles() { + let mut h = app_harness("hueSaturation", "rgb", 8); + let (id, _) = layer(&h); + let mem = crate::adjust_editors::layer_mem(id); + h.ctx.data_mut(|d| d.insert_temp(mem.with("hs-range"), 3usize)); // Greens: 75/105…135\165 + h.run_steps(3); + let bars: Rect = h.ctx.data(|d| d.get_temp(mem.with("hs-range-bars"))).expect("the range bars"); + let x = |deg: f32| bars.left() + deg / 360.0 * bars.width(); + let y = bars.center().y; + let greens = |h: &Harness<'_, PhotocraftApp>| match layer(h).1 { + Adjustment::HueSaturation { ranges, .. } => ranges[2].bounds, + other => panic!("{other:?}"), + }; + let steps = h.state().session.active().unwrap().history.past_len(); + drag(&mut h, Pos2::new(x(120.0), y), Pos2::new(x(156.0), y)); + let b = greens(&h); + assert!((b[0] - 111.0).abs() <= 1.0 && (b[3] - 201.0).abs() <= 1.0 && (b[1] - b[0] - 30.0).abs() < 0.5, "all four moved ~36°: {b:?}"); + assert_eq!(h.state().session.active().unwrap().history.past_len(), steps + 1, "one step"); + let before = greens(&h); + drag(&mut h, Pos2::new(x((before[0] + before[1]) / 2.0), y), Pos2::new(x((before[0] + before[1]) / 2.0 - 18.0), y)); + let b = greens(&h); + assert!((b[0] - (before[0] - 18.0)).abs() <= 1.0 && (b[1] - (before[1] - 18.0)).abs() <= 1.0, "left two moved: {before:?} → {b:?}"); + assert_eq!([b[2], b[3]], [before[2], before[3]], "right two stay"); +} diff --git a/docs/ui-parity.md b/docs/ui-parity.md index 7031163bfb..e692a9d1b5 100644 --- a/docs/ui-parity.md +++ b/docs/ui-parity.md @@ -1,6 +1,6 @@ # UI parity: tools, handles, modifiers and feel -> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-06 · **Change:** minor (Channels panel menu: New Channel…, Duplicate Channel, Delete Channel, New Spot Channel…, Merge Spot Channel, Channel Options…, Split Channels, Merge Channels…, #11451; a Color Picker for another dialog's colour or the Crop shield shows the picked colour there before OK, #9886; Edit › Transform › Distort side handles move their edge, Perspective side handles skew, #10085; Ctrl + Alt + wheel zooms the canvas like ⌥ + wheel on Windows and Linux, where winit reports a held Ctrl as both ctrl and command, #10488; Layers panel filter by Color, #5898; 11 of 183 preferences do nothing: startup reads Graphics Adapter through the typed Performance section, so the scorecard audit sees it; Shape Fill/Stroke popover as Photoshop's, every colour swatch opens the full Color Picker with a live preview; the text and gradient stop Color Pickers show the picked colour on the canvas before OK, #5530; selected colour sets edit drawing, tone and supported filters; geometry remains open; a paragraph box that can't hold its text enlarges its lower-right handle and shows a black + in it, as the reference application; Free Transform of several selected layers, #6501; Path Operations fixes: the first component keeps combining, a hidden component selection is left alone, a dragged live shape stays live, a refused Pen draft ends once; Pen, Freeform Pen, Curvature Pen and Path Selection Path Operations menu, which changes selected components, `+` / `-` keys, #1397; the Pen carries on an open shape or vector mask path; selection-aware font controls, pending caret fonts and focused commit, plus direct font-name editing with a compact no-match message, #9338; New Group dialog and button modifiers; new layers go into an open active group and join a clipping mask, except that type, shapes, pastes and placed files go above a group whose lock would refuse them; Color panel Hue and Brightness Cube show the out-of-gamut ⚠ and nearest printable colour when the field is at least 53 pt tall, #8672; Art History Brush in the History group of the Y flyout, partial, TOOL-213-20, #1610; Histogram panel: Compact / Expanded / All Channels views, Luminosity and Colors channels, Source, range statistics, Uncached Refresh, live adjustment overlay, Cache Levels preference; the font menu opens on the current family, marked in the recent group when it is a recent one, #9160; Type options bar alignment and direction follow the target paragraph; a swatch click recolours selected type and shape layers with any tool, #9238; UI scale presets done: 105–120% steps, #3222; ⇧⌥ blend mode letters; painting tool Mode menus; ⌥ + an adjustment's shortcut reopens it at its last settings, ⌥⌘L / ⌥⌘M, #8900; Crop default mode: moving the image under the box snaps the frame's edges and centre, #8580; View › Extras hides the Move transform controls, #6699; adjustment clipping stays visible in compact Properties, #5231; Color panel modes from its panel menu, the same in every theme, UI-217-17, #6000; a picked colour recolours the selected type and shapes; Hand tool ⌘ / ⌥ are Zoom In / Zoom Out while held, #6434; the wheel steps value fields, #5473; a dragged guide shows its X or Y beside the pointer, #7680; Type options bar "T" icon scrubs the font size, #6437; Move tool: dragged selected pixels take their own outline as the selection, #7538; artboard backgrounds remain below child Free Transform previews; ⌫/Delete removes the selected smart filter, #4751; Object Finder foreground/background discrimination (#6548); rounded triangle, polygon and star corners; shape Fill/Stroke popovers accept hex RGB values, #6176; a guide let go over either ruler is removed, #6286; Crop rows corrected: saved crop presets and Delete Cropped Pixels off are done, #6562; marching ants in device pixels, #7489; Animated Zoom: holding the Zoom tool zooms continuously, #6210; shape Density and Feather, TOOL-214-12, #5846; Pen Auto Add/Delete on the path being drawn, #6140; Show Transform Controls frames every selected layer; guide keys and clicks; menu bar from the keyboard, #4988; Crop tool Content-Aware Fill; on-canvas corner radius widgets, TOOL-214-12; Curvature Pen edits the active path; Clip Thumbnails to Layer Bounds; Pen ⇧ 45°; last selected tool restored at launch; Layers panel filter-type dropdown with Kind, Name and Mode, #5048; Free Transform box and marching ants follow the selection, #5297; History: the trash deletes the selected snapshot, rows drag onto the trash, #5324; smart filter reordering by drag; smart object perspective row corrected to done, #426; Free Transform H/V skew fields; toolbar tool shortcuts can be reassigned; ⇧-dragged guides land on ruler ticks; layer and selection keys; tool keys; spring-loaded tool letters; type formatting keys; Pen Auto Add/Delete, #4144; smart filter rows; stale missing-tool rows corrected: Color Replacement, Red Eye and the Add/Delete Anchor Point pair are live toolbar tools, Frame landed; no percentage changed; selection-modifier and ⌥-wheel rows match their tests; Properties › Transform shows a shape's path geometry, without its stroke) · **Target:** Adobe Photoshop 2026 +> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-06 · **Change:** minor (Hue/Saturation range zones drag, #9252; Channels panel menu: New Channel…, Duplicate Channel, Delete Channel, New Spot Channel…, Merge Spot Channel, Channel Options…, Split Channels, Merge Channels…, #11451; a Color Picker for another dialog's colour or the Crop shield shows the picked colour there before OK, #9886; Edit › Transform › Distort side handles move their edge, Perspective side handles skew, #10085; Ctrl + Alt + wheel zooms the canvas like ⌥ + wheel on Windows and Linux, where winit reports a held Ctrl as both ctrl and command, #10488; Layers panel filter by Color, #5898; 11 of 183 preferences do nothing: startup reads Graphics Adapter through the typed Performance section, so the scorecard audit sees it; Shape Fill/Stroke popover as Photoshop's, every colour swatch opens the full Color Picker with a live preview; the text and gradient stop Color Pickers show the picked colour on the canvas before OK, #5530; selected colour sets edit drawing, tone and supported filters; geometry remains open; a paragraph box that can't hold its text enlarges its lower-right handle and shows a black + in it, as the reference application; Free Transform of several selected layers, #6501; Path Operations fixes: the first component keeps combining, a hidden component selection is left alone, a dragged live shape stays live, a refused Pen draft ends once; Pen, Freeform Pen, Curvature Pen and Path Selection Path Operations menu, which changes selected components, `+` / `-` keys, #1397; the Pen carries on an open shape or vector mask path; selection-aware font controls, pending caret fonts and focused commit, plus direct font-name editing with a compact no-match message, #9338; New Group dialog and button modifiers; new layers go into an open active group and join a clipping mask, except that type, shapes, pastes and placed files go above a group whose lock would refuse them; Color panel Hue and Brightness Cube show the out-of-gamut ⚠ and nearest printable colour when the field is at least 53 pt tall, #8672; Art History Brush in the History group of the Y flyout, partial, TOOL-213-20, #1610; Histogram panel: Compact / Expanded / All Channels views, Luminosity and Colors channels, Source, range statistics, Uncached Refresh, live adjustment overlay, Cache Levels preference; the font menu opens on the current family, marked in the recent group when it is a recent one, #9160; Type options bar alignment and direction follow the target paragraph; a swatch click recolours selected type and shape layers with any tool, #9238; UI scale presets done: 105–120% steps, #3222; ⇧⌥ blend mode letters; painting tool Mode menus; ⌥ + an adjustment's shortcut reopens it at its last settings, ⌥⌘L / ⌥⌘M, #8900; Crop default mode: moving the image under the box snaps the frame's edges and centre, #8580; View › Extras hides the Move transform controls, #6699; adjustment clipping stays visible in compact Properties, #5231; Color panel modes from its panel menu, the same in every theme, UI-217-17, #6000; a picked colour recolours the selected type and shapes; Hand tool ⌘ / ⌥ are Zoom In / Zoom Out while held, #6434; the wheel steps value fields, #5473; a dragged guide shows its X or Y beside the pointer, #7680; Type options bar "T" icon scrubs the font size, #6437; Move tool: dragged selected pixels take their own outline as the selection, #7538; artboard backgrounds remain below child Free Transform previews; ⌫/Delete removes the selected smart filter, #4751; Object Finder foreground/background discrimination (#6548); rounded triangle, polygon and star corners; shape Fill/Stroke popovers accept hex RGB values, #6176; a guide let go over either ruler is removed, #6286; Crop rows corrected: saved crop presets and Delete Cropped Pixels off are done, #6562; marching ants in device pixels, #7489; Animated Zoom: holding the Zoom tool zooms continuously, #6210; shape Density and Feather, TOOL-214-12, #5846; Pen Auto Add/Delete on the path being drawn, #6140; Show Transform Controls frames every selected layer; guide keys and clicks; menu bar from the keyboard, #4988; Crop tool Content-Aware Fill; on-canvas corner radius widgets, TOOL-214-12; Curvature Pen edits the active path; Clip Thumbnails to Layer Bounds; Pen ⇧ 45°; last selected tool restored at launch; Layers panel filter-type dropdown with Kind, Name and Mode, #5048; Free Transform box and marching ants follow the selection, #5297; History: the trash deletes the selected snapshot, rows drag onto the trash, #5324; smart filter reordering by drag; smart object perspective row corrected to done, #426; Free Transform H/V skew fields; toolbar tool shortcuts can be reassigned; ⇧-dragged guides land on ruler ticks; layer and selection keys; tool keys; spring-loaded tool letters; type formatting keys; Pen Auto Add/Delete, #4144; smart filter rows; stale missing-tool rows corrected: Color Replacement, Red Eye and the Add/Delete Anchor Point pair are live toolbar tools, Frame landed; no percentage changed; selection-modifier and ⌥-wheel rows match their tests; Properties › Transform shows a shape's path geometry, without its stroke) · **Target:** Adobe Photoshop 2026 How PhotoCraft's direct manipulation compares with Photoshop 2026 (27.11.0): the toolbox, the handles and modifier keys of each gesture, nudging, snapping, numeric precision, navigation, @@ -282,6 +282,7 @@ Paragraph; the rest open as in-app floating windows. | 2026-10-24 | minor | Path Selection selects path components and has the Path Operations menu; the menu and `+` / `-` change the selected components' operation (`path.setOperation`); the Pen carries on an open shape layer or vector mask path from its endpoint (#1397 feedback); row stays partial until the Shape tools have the menu; no percentage changed | | 2026-10-25 | minor | Every preference takes effect: 12 of 178 do nothing, the scorecard's count (it still said 46 of 149) | | 2026-10-25 | minor | Art History Brush is in the History group of the Y flyout (partial, TOOL-213-20, #1610) | +| 2026-10-24 | minor | Hue/Saturation: dragging between a colour range's handles moves them as Photoshop 2025 does: the fully-on span moves all four, each fade its own two (#9252). Scores unchanged. | | 2026-10-24 | minor | Color panel: Hue Cube and Brightness Cube show Photoshop's out-of-gamut ⚠ and the nearest printable colour under the chips when the field is at least 53 pt tall, as the slider modes did; a click takes it (#8672). No percentage changed | | 2026-10-24 | minor | Swatches: a click recolours the selected type layers and shape fills whatever the tool, as Photoshop 2025 does (measured with the Move and Brush tools); the Color panel still recolours them only with a Type, shape or Pen tool (#9238). Scores unchanged. | | 2026-10-24 | minor | Type options bar: the alignment and paragraph-direction buttons show the edited or selected type layer's paragraph instead of the tool defaults, as Photoshop's bar does. Scores unchanged. | From f2dcbee218edd0f220e7189e7ccba9933ef54cd6 Mon Sep 17 00:00:00 2001 From: Hector Villarreal Date: Sat, 24 Oct 2026 19:27:47 -0600 Subject: [PATCH 2/7] Hue/Saturation range bar: narrow zones stay selectable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CodeRabbit (discussion_r4369183389): at the narrowest Properties panel the bar is about 230 points, a 30° zone is ~19 points, and every press in it fell within the fixed 10-point handle reach, so no zone could be dragged. A handle's reach toward a neighbour is now a third of the gap (3 to 10 points), leaving the middle third of a narrow zone to the zone; an open side keeps the full 10 points. Test: hue_range_zones_stay_selectable_on_a_narrow_bar. Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/dialogs/adjust_editors.rs | 19 ++++++++++++++++++- .../dialogs/adjust_editors/hue_saturation.rs | 17 ++++++++++++++++- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/src/dialogs/adjust_editors.rs b/crates/ui-egui/src/dialogs/adjust_editors.rs index a7cca0af24..78ad692a8c 100644 --- a/crates/ui-egui/src/dialogs/adjust_editors.rs +++ b/crates/ui-egui/src/dialogs/adjust_editors.rs @@ -45,7 +45,7 @@ use gradient_map::gradient_map; pub use gradient_map::{gradient_presets, is_gray, swatches}; use hue_saturation::hue_saturation; #[cfg(test)] -use hue_saturation::{hue_range_zone, lightness_track, move_hue_range_handle, move_hue_range_zone, saturation_track}; +use hue_saturation::{hue_range_handle_at, hue_range_zone, lightness_track, move_hue_range_handle, move_hue_range_zone, saturation_track}; use levels::levels; pub use levels::{auto_levels, gamma_from_pos, gamma_pos}; pub use session::{layer_editor, layer_mem, properties_coalesce, properties_reset, session_start}; @@ -264,6 +264,23 @@ mod tests { /// #9252: Photoshop 2025's zone drags on a colour range (measured on Reds): the fully-on span /// moves all four handles, each fade its own two; a side stops at the other and the range /// never passes a turn. + /// #9272 review: at the narrowest Properties panel (a 230-point bar) a 30° zone is ~19 points + /// wide; a press in its middle grabs the zone, not a handle, while each handle stays grabbable. + #[test] + fn hue_range_zones_stay_selectable_on_a_narrow_bar() { + let w = 230.0; + let xs = [75.0f32, 105.0, 135.0, 165.0].map(|d| d / 360.0 * w); + for (a, z) in [(0, 1), (1, 2), (2, 3)] { + assert_eq!(hue_range_handle_at(xs, (xs[a] + xs[z]) / 2.0), None, "the middle of zone {a}..{z} is the zone's"); + } + for (k, x) in xs.iter().enumerate() { + assert_eq!(hue_range_handle_at(xs, *x + 1.0), Some(k as u8), "handle {k}"); + } + assert_eq!(hue_range_handle_at(xs, xs[0] - 9.0), Some(0), "the full reach outside the range"); + let stacked = [50.0, 50.0, 80.0, 120.0]; + assert!(hue_range_handle_at(stacked, 51.0).is_some(), "coinciding handles stay grabbable"); + } + #[test] fn hue_range_zones_move_their_handles() { let reds = [-45.0, -15.0, 15.0, 45.0]; diff --git a/crates/ui-egui/src/dialogs/adjust_editors/hue_saturation.rs b/crates/ui-egui/src/dialogs/adjust_editors/hue_saturation.rs index 0e90c3ec6e..27221ebb43 100644 --- a/crates/ui-egui/src/dialogs/adjust_editors/hue_saturation.rs +++ b/crates/ui-egui/src/dialogs/adjust_editors/hue_saturation.rs @@ -38,6 +38,21 @@ pub(super) fn move_hue_range_handle(bounds: [f32; 4], k: usize, deg: f32) -> [f3 b } +/// The range handle a press at `x` grabs, given the four handles' x positions: the nearest +/// within 10 points, or within a third of the gap to the next handle on that side, so the middle +/// third of a narrow zone still drags the zone (at least 3 points, for handles that coincide). +pub(super) fn hue_range_handle_at(xs: [f32; 4], x: f32) -> Option { + let k = nearest(&xs, x)?; + let d = x - xs[k as usize]; + let gap = xs + .iter() + .enumerate() + .filter(|&(j, &o)| j != k as usize && (o - xs[k as usize]) * d.signum() >= 0.0) + .map(|(_, &o)| (o - xs[k as usize]).abs()) + .fold(f32::INFINITY, f32::min); + (d.abs() < (gap / 3.0).clamp(3.0, 10.0)).then_some(k) +} + /// Which zone of a colour range a hue `deg` falls in, between its handles: 0 = the left fade /// (between the first two), 1 = the fully-on span, 2 = the right fade; `None` outside the range. pub(super) fn hue_range_zone(bounds: [f32; 4], deg: f32) -> Option { @@ -227,7 +242,7 @@ pub(super) fn hue_saturation(ui: &mut egui::Ui, v: &mut Value, cx: &EditorCx) -> && ui.input(|i| i.pointer.primary_pressed()) && let Some(pos) = ui.input(|i| i.pointer.press_origin()) { - which = nearest(&b.map(xof), pos.x).filter(|k| (xof(b[*k as usize]) - pos.x).abs() < 10.0); + which = hue_range_handle_at(b.map(xof), pos.x); zone = if which.is_none() { hue_range_zone(b, deg_of(pos.x)).map(|z| (z, b, pos.x)) } else { None }; } if bresp.is_pointer_button_down_on() From fe19df6077c64cb63416f34989518de5e4e71868 Mon Sep 17 00:00:00 2001 From: Hector Villarreal Date: Sat, 24 Oct 2026 19:45:09 -0600 Subject: [PATCH 3/7] Hue/Saturation range bar: handle reach counts neighbours across the seam CodeRabbit (discussion_r4369244320): Reds' fully-on zone crosses the bar's seam, so its two seam handles saw no neighbour on their open side and kept the full 10-point reach, swallowing the whole ~19-point zone on a 230-point bar. The bar is a hue circle: the gap now wraps to the first handle from the other edge. Test: hue_range_zones_stay_selectable_on_a_narrow_bar (a Reds case). Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/dialogs/adjust_editors.rs | 15 +++++++++++---- .../dialogs/adjust_editors/hue_saturation.rs | 17 +++++++++-------- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/crates/ui-egui/src/dialogs/adjust_editors.rs b/crates/ui-egui/src/dialogs/adjust_editors.rs index 78ad692a8c..998aa2b4f4 100644 --- a/crates/ui-egui/src/dialogs/adjust_editors.rs +++ b/crates/ui-egui/src/dialogs/adjust_editors.rs @@ -271,14 +271,21 @@ mod tests { let w = 230.0; let xs = [75.0f32, 105.0, 135.0, 165.0].map(|d| d / 360.0 * w); for (a, z) in [(0, 1), (1, 2), (2, 3)] { - assert_eq!(hue_range_handle_at(xs, (xs[a] + xs[z]) / 2.0), None, "the middle of zone {a}..{z} is the zone's"); + assert_eq!(hue_range_handle_at(xs, (xs[a] + xs[z]) / 2.0, w), None, "the middle of zone {a}..{z} is the zone's"); } for (k, x) in xs.iter().enumerate() { - assert_eq!(hue_range_handle_at(xs, *x + 1.0), Some(k as u8), "handle {k}"); + assert_eq!(hue_range_handle_at(xs, *x + 1.0, w), Some(k as u8), "handle {k}"); } - assert_eq!(hue_range_handle_at(xs, xs[0] - 9.0), Some(0), "the full reach outside the range"); + assert_eq!(hue_range_handle_at(xs, xs[0] - 9.0, w), Some(0), "the full reach outside the range"); let stacked = [50.0, 50.0, 80.0, 120.0]; - assert!(hue_range_handle_at(stacked, 51.0).is_some(), "coinciding handles stay grabbable"); + assert!(hue_range_handle_at(stacked, 51.0, w).is_some(), "coinciding handles stay grabbable"); + // Reds (315/345…15\45): its fully-on zone crosses the seam, ~9.6 points from each edge. + let reds = [315.0f32, 345.0, 15.0, 45.0].map(|d| d / 360.0 * w); + for x in [w - 1.0, w - 3.0, 0.5, 2.5] { + assert_eq!(hue_range_handle_at(reds, x, w), None, "x {x}: Reds' fully-on zone across the seam"); + } + assert_eq!(hue_range_handle_at(reds, reds[1] + 1.0, w), Some(1)); + assert_eq!(hue_range_handle_at(reds, reds[2] - 1.0, w), Some(2)); } #[test] diff --git a/crates/ui-egui/src/dialogs/adjust_editors/hue_saturation.rs b/crates/ui-egui/src/dialogs/adjust_editors/hue_saturation.rs index 27221ebb43..777ccf4a39 100644 --- a/crates/ui-egui/src/dialogs/adjust_editors/hue_saturation.rs +++ b/crates/ui-egui/src/dialogs/adjust_editors/hue_saturation.rs @@ -38,17 +38,18 @@ pub(super) fn move_hue_range_handle(bounds: [f32; 4], k: usize, deg: f32) -> [f3 b } -/// The range handle a press at `x` grabs, given the four handles' x positions: the nearest -/// within 10 points, or within a third of the gap to the next handle on that side, so the middle -/// third of a narrow zone still drags the zone (at least 3 points, for handles that coincide). -pub(super) fn hue_range_handle_at(xs: [f32; 4], x: f32) -> Option { +/// The range handle a press at `x` grabs, given the four handles' x positions on a bar `w` wide: +/// the nearest within 10 points, or within a third of the gap to the next handle on that side, so +/// the middle third of a narrow zone still drags the zone (at least 3 points, for handles that +/// coincide). The bar is a hue circle: the next handle past an edge is the first from the other. +pub(super) fn hue_range_handle_at(xs: [f32; 4], x: f32, w: f32) -> Option { let k = nearest(&xs, x)?; - let d = x - xs[k as usize]; + let (xk, d) = (xs[k as usize], x - xs[k as usize]); let gap = xs .iter() .enumerate() - .filter(|&(j, &o)| j != k as usize && (o - xs[k as usize]) * d.signum() >= 0.0) - .map(|(_, &o)| (o - xs[k as usize]).abs()) + .filter(|&(j, _)| j != k as usize) + .map(|(_, &o)| if d >= 0.0 { (o - xk).rem_euclid(w) } else { (xk - o).rem_euclid(w) }) .fold(f32::INFINITY, f32::min); (d.abs() < (gap / 3.0).clamp(3.0, 10.0)).then_some(k) } @@ -242,7 +243,7 @@ pub(super) fn hue_saturation(ui: &mut egui::Ui, v: &mut Value, cx: &EditorCx) -> && ui.input(|i| i.pointer.primary_pressed()) && let Some(pos) = ui.input(|i| i.pointer.press_origin()) { - which = hue_range_handle_at(b.map(xof), pos.x); + which = hue_range_handle_at(b.map(xof), pos.x, w); zone = if which.is_none() { hue_range_zone(b, deg_of(pos.x)).map(|z| (z, b, pos.x)) } else { None }; } if bresp.is_pointer_button_down_on() From 435d47adad1c2289704fd5faefcdb8b90d10e373 Mon Sep 17 00:00:00 2001 From: Hector Villarreal Date: Sun, 25 Oct 2026 09:35:37 -0600 Subject: [PATCH 4/7] Hue/Saturation: a range drag released in its move frame still lands CodeRabbit on #9272: when the pointer moves and lets go between two frames, the release frame isn't 'button down', so the zone drag skipped the final position and committed the bounds from before the move. The release frame now applies its position, for zone and handle drags alike. Test: a_zone_drag_released_in_the_frame_it_moves_still_moves Co-Authored-By: Claude Opus 5.5 --- .../dialogs/adjust_editors/hue_saturation.rs | 11 ++--- .../src/dialogs/adjust_editors/ui_tests.rs | 47 +++++++++++++++++++ 2 files changed, 52 insertions(+), 6 deletions(-) diff --git a/crates/ui-egui/src/dialogs/adjust_editors/hue_saturation.rs b/crates/ui-egui/src/dialogs/adjust_editors/hue_saturation.rs index 777ccf4a39..0ec3548798 100644 --- a/crates/ui-egui/src/dialogs/adjust_editors/hue_saturation.rs +++ b/crates/ui-egui/src/dialogs/adjust_editors/hue_saturation.rs @@ -246,9 +246,10 @@ pub(super) fn hue_saturation(ui: &mut egui::Ui, v: &mut Value, cx: &EditorCx) -> which = hue_range_handle_at(b.map(xof), pos.x, w); zone = if which.is_none() { hue_range_zone(b, deg_of(pos.x)).map(|z| (z, b, pos.x)) } else { None }; } - if bresp.is_pointer_button_down_on() - && let (Some((z, start, x0)), Some(pos)) = (zone, ui.input(|i| i.pointer.interact_pos())) - { + // The release frame applies its position too: a move and a release that land in one frame + // would otherwise commit the bounds from before the move. + let live = bresp.is_pointer_button_down_on() || ui.input(|i| i.pointer.primary_released()); + if live && let (Some((z, start, x0)), Some(pos)) = (zone, ui.input(|i| i.pointer.interact_pos())) { let before = b; b = move_hue_range_zone(start, z, (pos.x - x0) / w * 360.0); if b != before { @@ -261,9 +262,7 @@ pub(super) fn hue_saturation(ui: &mut egui::Ui, v: &mut Value, cx: &EditorCx) -> e.commit = true; } ui.data_mut(|d| d.insert_temp(zone_id, zone)); - if bresp.is_pointer_button_down_on() - && let (Some(k), Some(pos)) = (which, ui.input(|i| i.pointer.interact_pos())) - { + if live && let (Some(k), Some(pos)) = (which, ui.input(|i| i.pointer.interact_pos())) { let k = k as usize; let deg = deg_of(pos.x); let before = b; diff --git a/crates/ui-egui/src/dialogs/adjust_editors/ui_tests.rs b/crates/ui-egui/src/dialogs/adjust_editors/ui_tests.rs index 68b9793d5a..c0d550bcf8 100644 --- a/crates/ui-egui/src/dialogs/adjust_editors/ui_tests.rs +++ b/crates/ui-egui/src/dialogs/adjust_editors/ui_tests.rs @@ -1024,3 +1024,50 @@ fn hue_saturation_range_zones_drag_their_handles() { assert!((b[0] - (before[0] - 18.0)).abs() <= 1.0 && (b[1] - (before[1] - 18.0)).abs() <= 1.0, "left two moved: {before:?} → {b:?}"); assert_eq!([b[2], b[3]], [before[2], before[3]], "right two stay"); } + +/// CodeRabbit on #9272: a move and release that land in the same frame still move the zone; the +/// release frame applies its position before the drag commits. +#[test] +fn a_zone_drag_released_in_the_frame_it_moves_still_moves() { + let mut h = app_harness("hueSaturation", "rgb", 8); + let (id, _) = layer(&h); + let mem = crate::adjust_editors::layer_mem(id); + h.ctx.data_mut(|d| d.insert_temp(mem.with("hs-range"), 3usize)); // Greens: 75/105…135\165 + h.run_steps(3); + let bars: Rect = h.ctx.data(|d| d.get_temp(mem.with("hs-range-bars"))).expect("the range bars"); + let x = |deg: f32| bars.left() + deg / 360.0 * bars.width(); + let y = bars.center().y; + let steps = h.state().session.active().unwrap().history.past_len(); + let (from, to) = (Pos2::new(x(120.0), y), Pos2::new(x(156.0), y)); + h.hover_at(from); + h.run_steps(1); + h.drag_at(from); + h.run_steps(1); + // One frame: the pointer moves and lets go (the harness's queued events take a frame each, + // so both go straight into the next frame's input). + let events = &mut h.input_mut().events; + events.push(egui::Event::PointerMoved(to)); + events.push(egui::Event::PointerButton { pos: to, button: egui::PointerButton::Primary, pressed: false, modifiers: egui::Modifiers::NONE }); + h.run_steps(3); + let b = match layer(&h).1 { + Adjustment::HueSaturation { ranges, .. } => ranges[2].bounds, + other => panic!("{other:?}"), + }; + assert!((b[0] - 111.0).abs() <= 1.0 && (b[3] - 201.0).abs() <= 1.0, "all four moved ~36°: {b:?}"); + assert_eq!(h.state().session.active().unwrap().history.past_len(), steps + 1, "one step"); + // A handle released in the frame it moves lands there too. + let (from, to) = (Pos2::new(x(b[3]), y), Pos2::new(x(b[3] + 20.0), y)); + h.hover_at(from); + h.run_steps(1); + h.drag_at(from); + h.run_steps(1); + let events = &mut h.input_mut().events; + events.push(egui::Event::PointerMoved(to)); + events.push(egui::Event::PointerButton { pos: to, button: egui::PointerButton::Primary, pressed: false, modifiers: egui::Modifiers::NONE }); + h.run_steps(3); + let after = match layer(&h).1 { + Adjustment::HueSaturation { ranges, .. } => ranges[2].bounds, + other => panic!("{other:?}"), + }; + assert!((after[3] - (b[3] + 20.0)).abs() <= 1.0 && after[..3] == b[..3], "the right handle moved 20°: {b:?} → {after:?}"); +} From d2a70d63f18a8eefc6da15dc981c54073a2a4539 Mon Sep 17 00:00:00 2001 From: Hector Villarreal Date: Sun, 25 Oct 2026 09:50:37 -0600 Subject: [PATCH 5/7] Hue/Saturation: a range drag ends where the button let go CodeRabbit on #9272: when a release and more pointer movement land in one frame, interact_pos() is the later position, so a zone or handle drag committed bounds past the release. The release frame now reads the primary release event's own position. Test: a_zone_drag_released_in_the_frame_it_moves_still_moves (adds the release-then-move order) Co-Authored-By: Claude Opus 5.5 --- .../dialogs/adjust_editors/hue_saturation.rs | 16 ++++++++++++---- .../src/dialogs/adjust_editors/ui_tests.rs | 17 +++++++++++++++++ 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/crates/ui-egui/src/dialogs/adjust_editors/hue_saturation.rs b/crates/ui-egui/src/dialogs/adjust_editors/hue_saturation.rs index 0ec3548798..29393a4031 100644 --- a/crates/ui-egui/src/dialogs/adjust_editors/hue_saturation.rs +++ b/crates/ui-egui/src/dialogs/adjust_editors/hue_saturation.rs @@ -247,9 +247,17 @@ pub(super) fn hue_saturation(ui: &mut egui::Ui, v: &mut Value, cx: &EditorCx) -> zone = if which.is_none() { hue_range_zone(b, deg_of(pos.x)).map(|z| (z, b, pos.x)) } else { None }; } // The release frame applies its position too: a move and a release that land in one frame - // would otherwise commit the bounds from before the move. - let live = bresp.is_pointer_button_down_on() || ui.input(|i| i.pointer.primary_released()); - if live && let (Some((z, start, x0)), Some(pos)) = (zone, ui.input(|i| i.pointer.interact_pos())) { + // would otherwise commit the bounds from before the move. It ends where the button let go, + // not where the pointer went after that in the same frame. + let released_at = ui.input(|i| { + i.events.iter().find_map(|e| match e { + egui::Event::PointerButton { pos, button: egui::PointerButton::Primary, pressed: false, .. } => Some(*pos), + _ => None, + }) + }); + let live = bresp.is_pointer_button_down_on() || released_at.is_some(); + let drag_pos = released_at.or_else(|| ui.input(|i| i.pointer.interact_pos())); + if live && let (Some((z, start, x0)), Some(pos)) = (zone, drag_pos) { let before = b; b = move_hue_range_zone(start, z, (pos.x - x0) / w * 360.0); if b != before { @@ -262,7 +270,7 @@ pub(super) fn hue_saturation(ui: &mut egui::Ui, v: &mut Value, cx: &EditorCx) -> e.commit = true; } ui.data_mut(|d| d.insert_temp(zone_id, zone)); - if live && let (Some(k), Some(pos)) = (which, ui.input(|i| i.pointer.interact_pos())) { + if live && let (Some(k), Some(pos)) = (which, drag_pos) { let k = k as usize; let deg = deg_of(pos.x); let before = b; diff --git a/crates/ui-egui/src/dialogs/adjust_editors/ui_tests.rs b/crates/ui-egui/src/dialogs/adjust_editors/ui_tests.rs index c0d550bcf8..91dc186e4d 100644 --- a/crates/ui-egui/src/dialogs/adjust_editors/ui_tests.rs +++ b/crates/ui-egui/src/dialogs/adjust_editors/ui_tests.rs @@ -1070,4 +1070,21 @@ fn a_zone_drag_released_in_the_frame_it_moves_still_moves() { other => panic!("{other:?}"), }; assert!((after[3] - (b[3] + 20.0)).abs() <= 1.0 && after[..3] == b[..3], "the right handle moved 20°: {b:?} → {after:?}"); + // A release followed by more movement in one frame ends where the button let go. + let b = after; + let (from, to) = (Pos2::new(x((b[1] + b[2]) / 2.0), y), Pos2::new(x((b[1] + b[2]) / 2.0 + 10.0), y)); + h.hover_at(from); + h.run_steps(1); + h.drag_at(from); + h.run_steps(1); + let events = &mut h.input_mut().events; + events.push(egui::Event::PointerMoved(to)); + events.push(egui::Event::PointerButton { pos: to, button: egui::PointerButton::Primary, pressed: false, modifiers: egui::Modifiers::NONE }); + events.push(egui::Event::PointerMoved(Pos2::new(x(b[3] + 60.0), y))); + h.run_steps(3); + let last = match layer(&h).1 { + Adjustment::HueSaturation { ranges, .. } => ranges[2].bounds, + other => panic!("{other:?}"), + }; + assert!(last.iter().zip(&b).all(|(l, b)| (l - (b + 10.0)).abs() <= 1.0), "moved 10° to the release, not past it: {b:?} → {last:?}"); } From 15437c9ea0de29f9fefc09b140b911fcf3f23652 Mon Sep 17 00:00:00 2001 From: Hector Villarreal Date: Fri, 30 Oct 2026 22:28:25 -0600 Subject: [PATCH 6/7] Hue range tests: keep #9252's doc comment on its own test after the rebase Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/dialogs/adjust_editors.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/ui-egui/src/dialogs/adjust_editors.rs b/crates/ui-egui/src/dialogs/adjust_editors.rs index 998aa2b4f4..9b52140fea 100644 --- a/crates/ui-egui/src/dialogs/adjust_editors.rs +++ b/crates/ui-egui/src/dialogs/adjust_editors.rs @@ -261,9 +261,6 @@ mod tests { assert_eq!(track_stops(&cx(false), &stops), None); } - /// #9252: Photoshop 2025's zone drags on a colour range (measured on Reds): the fully-on span - /// moves all four handles, each fade its own two; a side stops at the other and the range - /// never passes a turn. /// #9272 review: at the narrowest Properties panel (a 230-point bar) a 30° zone is ~19 points /// wide; a press in its middle grabs the zone, not a handle, while each handle stays grabbable. #[test] @@ -288,6 +285,9 @@ mod tests { assert_eq!(hue_range_handle_at(reds, reds[2] - 1.0, w), Some(2)); } + /// #9252: Photoshop 2025's zone drags on a colour range (measured on Reds): the fully-on span + /// moves all four handles, each fade its own two; a side stops at the other and the range + /// never passes a turn. #[test] fn hue_range_zones_move_their_handles() { let reds = [-45.0, -15.0, 15.0, 45.0]; From f8ef7d78d03759de8a99ab8a56fca48af760d9d2 Mon Sep 17 00:00:00 2001 From: Hector Villarreal Date: Sun, 1 Nov 2026 02:08:43 -0600 Subject: [PATCH 7/7] Hue/Saturation range bar: test a zone drag across the 0/360 seam (FredApps review) Reds' fully-on span sits on both ends of the bar. Drags from its middle at either end move the whole range intact, one history step each, and the handles that pass the seam come out at the other end. Co-Authored-By: Claude Opus 5.5 --- .../src/dialogs/adjust_editors/ui_tests.rs | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/crates/ui-egui/src/dialogs/adjust_editors/ui_tests.rs b/crates/ui-egui/src/dialogs/adjust_editors/ui_tests.rs index 91dc186e4d..91d866a388 100644 --- a/crates/ui-egui/src/dialogs/adjust_editors/ui_tests.rs +++ b/crates/ui-egui/src/dialogs/adjust_editors/ui_tests.rs @@ -1088,3 +1088,42 @@ fn a_zone_drag_released_in_the_frame_it_moves_still_moves() { }; assert!(last.iter().zip(&b).all(|(l, b)| (l - (b + 10.0)).abs() <= 1.0), "moved 10° to the release, not past it: {b:?} → {last:?}"); } + +/// FredApps review on #9272: a zone drag across the 0/360 seam. Reds' fully-on span sits on both +/// ends of the bar; a drag from its middle third at either end (nearer a handle grabs the handle) +/// moves the whole range intact, and the handles that pass the seam come out at the other end. +#[test] +fn hue_saturation_range_zone_drags_across_the_seam() { + let mut h = app_harness("hueSaturation", "rgb", 8); + let (id, _) = layer(&h); + let mem = crate::adjust_editors::layer_mem(id); + h.ctx.data_mut(|d| d.insert_temp(mem.with("hs-range"), 1usize)); // Reds: 315/345…15\45 + h.run_steps(3); + let bars: Rect = h.ctx.data(|d| d.get_temp(mem.with("hs-range-bars"))).expect("the range bars"); + let x = |deg: f32| bars.left() + deg / 360.0 * bars.width(); + let y = bars.center().y; + let reds = |h: &Harness<'_, PhotocraftApp>| match layer(h).1 { + Adjustment::HueSaturation { ranges, .. } => ranges[0].bounds, + other => panic!("{other:?}"), + }; + let on_circle = |b: [f32; 4]| b.map(|d| d.rem_euclid(360.0).round()); + let widths = |b: [f32; 4]| [b[1] - b[0], b[2] - b[1], b[3] - b[2]]; + let mut steps = h.state().session.active().unwrap().history.past_len(); + // (press, release, where the four handles land on the circle) + for (from, to, want) in [ + // The span's right end, dragged left: 15\45 cross the seam to the right end. + (358.0, 298.0, [255.0, 285.0, 315.0, 345.0]), + // Back right from its middle: 315\345 cross the seam to the left end. + (300.0, 360.0, [315.0, 345.0, 15.0, 45.0]), + // The span's left end, dragged right: 315/345 cross the seam to the left end. + (2.0, 62.0, [15.0, 45.0, 75.0, 105.0]), + ] { + let before = reds(&h); + drag(&mut h, Pos2::new(x(from), y), Pos2::new(x(to), y)); + let b = reds(&h); + assert!(on_circle(b).iter().zip(&want).all(|(d, w)| (d - w).abs() <= 1.0), "{from}° → {to}°: {before:?} → {b:?}, want {want:?}"); + assert_eq!(widths(b), widths(before), "{from}° → {to}°: the range moves intact"); + steps += 1; + assert_eq!(h.state().session.active().unwrap().history.past_len(), steps, "{from}° → {to}°: one step"); + } +}