Skip to content

LightCraft: An open-source non-destructive photo editor written by scratch in pure Rust

Merge PR #1402: Fix slider wheel edits after leaving and returning to the Edit panel

aionggfb316ee5ea04
diff --cc crates/ui-egui/src/widgets/tests_numeric_entry.rs
index 403ed7292,730f4333b..eb2e3c9b8
--- a/crates/ui-egui/src/widgets/tests_numeric_entry.rs
+++ b/crates/ui-egui/src/widgets/tests_numeric_entry.rs
@@@ -177,21 -177,133 +177,152 @@@ fn a_disabled_value_does_not_scrub()
assert_eq!(h.value, 0.71);
}
+#[test]
+fn a_long_click_keeps_the_field_open() {
+ // A press held past egui's click time (here a second and a half) used to close the field on
+ // release; it stays open for typing.
+ let mut h = Harness::new();
+ let pos = h.rect.center();
+ let button = |pressed| Event::PointerButton { pos, button: PointerButton::Primary, pressed, modifiers: Modifiers::NONE };
+ h.frame(vec![Event::PointerMoved(pos)]);
+ h.frame(vec![button(true)]);
+ for _ in 0..75 {
+ h.frame(vec![]);
+ }
+ assert_eq!(h.frame(vec![button(false)]).value, None);
+ h.frame(vec![]);
+ assert!(h.view.ctx.egui_wants_keyboard_input(), "the field keeps the keyboard after a long click");
+ h.frame(vec![Event::Text("2".into())]);
+ assert_eq!(h.key(Key::Enter).value, Some(2.0));
+}
++
+ #[test]
+ fn leaving_a_slider_disarms_wheel_edits_until_it_is_selected_again() {
+ let mut h = Harness::new();
+ let inside = h.track.center();
+ let outside = egui::pos2(5.0, 80.0);
+ let button = |pressed| Event::PointerButton { pos: inside, button: PointerButton::Primary, pressed, modifiers: Modifiers::NONE };
+ let wheel = || Event::MouseWheel {
+ unit: egui::MouseWheelUnit::Point,
+ delta: vec2(0.0, 120.0),
+ phase: egui::TouchPhase::Move,
+ modifiers: Modifiers::NONE,
+ };
+ h.frame(vec![Event::PointerMoved(inside)]);
+ h.frame(vec![button(true)]);
+ h.frame(vec![button(false)]);
+ let selected = h.value;
+ h.frame(vec![wheel()]);
+ for _ in 0..40 {
+ h.frame(vec![]);
+ }
+ assert!(h.value > selected, "selecting a slider enables wheel nudges");
+ h.frame(vec![Event::PointerMoved(outside)]);
+ let before_return = h.value;
+ h.frame(vec![Event::PointerMoved(inside), wheel()]);
+ for _ in 0..40 {
+ h.frame(vec![]);
+ }
+ assert_eq!(h.value, before_return, "scrolling back over a previously selected slider must not edit it");
+ h.frame(vec![Event::PointerMoved(outside)]);
+ let before_arrow = h.value;
+ h.key(Key::ArrowUp);
+ assert!(h.value > before_arrow, "leaving must preserve keyboard arrows");
+ // Sideways scrolling remains independent of vertical wheel selection (#1465).
+ let before_sideways = h.value;
+ h.frame(vec![
+ Event::PointerMoved(inside),
+ Event::MouseWheel { unit: egui::MouseWheelUnit::Point, delta: vec2(120.0, 0.0), phase: egui::TouchPhase::Move, modifiers: Modifiers::NONE },
+ ]);
+ for _ in 0..40 {
+ h.frame(vec![]);
+ }
+ let after_sideways = h.value;
+ assert!(after_sideways > before_sideways, "a disarmed slider still accepts sideways nudges");
+ h.frame(vec![wheel()]);
+ for _ in 0..40 {
+ h.frame(vec![]);
+ }
+ assert_eq!(h.value, after_sideways, "sideways nudges do not re-arm vertical wheel edits");
+ h.frame(vec![Event::PointerMoved(inside)]);
+ h.frame(vec![button(true)]);
+ h.frame(vec![button(false)]);
+ let selected_again = h.value;
+ h.frame(vec![wheel()]);
+ for _ in 0..40 {
+ h.frame(vec![]);
+ }
+ assert!(h.value > selected_again, "selecting it again restores wheel nudges");
+ }
+
+ #[test]
+ fn leaving_the_row_during_a_drag_keeps_dragging_but_release_disarms_the_wheel() {
+ let mut h = Harness::new();
+ let inside = h.track.center();
+ let outside = egui::pos2(h.track.right() - 20.0, 80.0);
+ let button = |pos, pressed| Event::PointerButton { pos, button: PointerButton::Primary, pressed, modifiers: Modifiers::NONE };
+ h.frame(vec![Event::PointerMoved(inside)]);
+ h.frame(vec![button(inside, true)]);
+ let initial = h.value;
+ h.frame(vec![Event::PointerMoved(outside)]);
+ assert!(h.value > initial, "an owned drag keeps editing outside the row");
+ h.frame(vec![button(outside, false)]);
+ let released = h.value;
+ h.frame(vec![
+ Event::PointerMoved(inside),
+ Event::MouseWheel { unit: egui::MouseWheelUnit::Point, delta: vec2(0.0, -120.0), phase: egui::TouchPhase::Move, modifiers: Modifiers::NONE },
+ ]);
+ for _ in 0..40 {
+ h.frame(vec![]);
+ }
+ assert_eq!(h.value, released, "releasing outside disarms subsequent wheel edits");
+ }
+
+ #[test]
+ fn a_drag_that_leaves_and_ends_back_in_the_row_disarms_the_wheel() {
+ let mut h = Harness::new();
+ let inside = h.track.center();
+ let outside = egui::pos2(h.track.right() - 20.0, 80.0);
+ let button = |pos, pressed| Event::PointerButton { pos, button: PointerButton::Primary, pressed, modifiers: Modifiers::NONE };
+ h.frame(vec![Event::PointerMoved(inside)]);
+ h.frame(vec![button(inside, true)]);
+ h.frame(vec![Event::PointerMoved(outside)]);
+ h.frame(vec![Event::PointerMoved(inside)]);
+ h.frame(vec![button(inside, false)]);
+ let released = h.value;
+ h.frame(vec![Event::MouseWheel {
+ unit: egui::MouseWheelUnit::Point,
+ delta: vec2(0.0, 120.0),
+ phase: egui::TouchPhase::Move,
+ modifiers: Modifiers::NONE,
+ }]);
+ for _ in 0..40 {
+ h.frame(vec![]);
+ }
+ assert_eq!(h.value, released, "the drag left the row, so the wheel needs a fresh selection");
+ }
+
+ #[test]
+ fn leaving_and_returning_within_one_frame_still_disarms_the_wheel() {
+ let wheel = || Event::MouseWheel {
+ unit: egui::MouseWheelUnit::Point,
+ delta: vec2(0.0, 120.0),
+ phase: egui::TouchPhase::Move,
+ modifiers: Modifiers::NONE,
+ };
+ // a slow frame merges the moves out of the row and back (or out of the window and back)
+ for away in [Event::PointerMoved(egui::pos2(5.0, 80.0)), Event::PointerGone] {
+ let mut h = Harness::new();
+ let inside = h.track.center();
+ let button = |pressed| Event::PointerButton { pos: inside, button: PointerButton::Primary, pressed, modifiers: Modifiers::NONE };
+ h.frame(vec![Event::PointerMoved(inside)]);
+ h.frame(vec![button(true)]);
+ h.frame(vec![button(false)]);
+ let selected = h.value;
+ h.frame(vec![away.clone(), Event::PointerMoved(inside), wheel()]);
+ for _ in 0..40 {
+ h.frame(vec![]);
+ }
+ assert_eq!(h.value, selected, "the pointer left the row between two frames ({away:?})");
+ }
+ }
diff --cc docs/parity-checklist.md
index 55bc35bb4,73ae79b76..0fbda3fbe
--- a/docs/parity-checklist.md
+++ b/docs/parity-checklist.md
@@@ -673,8 -673,8 +673,8 @@@ From `06-shortcuts.md` part 1. Evidenc
| KEY-CROP-RESET | Reset crop — ⌥⌘R | P0 | ✅ | `cmd:crop.reset` | |
| KEY-STRAIGHTEN | Straighten while held — ⌘ drag | P1 | ✅ | `cmd:crop.straighten`, `crates/ui-egui/src/panels/detail.rs` (`straighten_overlay`) | ⌘-drag in Crop draws a level line; the crop tool stays active |
| KEY-SLIDER-RESET | Reset slider — double-click | P0 | ✅ | `crates/ui-egui/src/widgets.rs`, `crates/ui-egui/src/tests_slider_reset.rs` | double-click a slider's name or thumb: back to its default as one undo step (a click on the thumb no longer moves it first, which made it two); resting the pointer on either says so (“Exposure — double-click to reset it”, as the curve channels), the value keeps “Click to type a value” (issue #1436); a disabled slider's name doesn't reset it. No per-slider reset button (Lightroom has none); no ⌥ panel headings turning into Reset buttons yet (`cmd:develop.resetSection` is command-only) |
- | KEY-SLIDER-NUDGE | Nudge slider — ↑/↓ | P1 | ✅ | `crates/ui-egui/src/widgets.rs` (`nudged`), `cmd:develop.adjust` | ↑/↓ over any slider: ≈ 1/200 of its range (exposure 0.05, most sliders 1, temperature 50 K); ⇧ ×5; one undo step each. Scrolling sideways over any slider (trackpad swipe, tilting wheel, ⇧+wheel) nudges it the same way, one wheel notch a step, without selecting it first; only a mostly sideways movement counts, so scrolling the panel leaves sliders alone (`crates/ui-egui/src/tests_masking.rs`, `sideways_scrolling_adjusts_the_slider_under_the_pointer`) |
+ | KEY-SLIDER-NUDGE | Nudge slider — ↑/↓ | P1 | ✅ | `crates/ui-egui/src/widgets.rs` (`nudged`), `cmd:develop.adjust` | ↑/↓ over any slider: ≈ 1/200 of its range (exposure 0.05, most sliders 1, temperature 50 K); ⇧ ×5; one undo step each. Scrolling sideways over any slider (trackpad swipe, tilting wheel, ⇧+wheel) nudges it the same way, one wheel notch a step, without selecting it first; only a mostly sideways movement counts, so scrolling the panel leaves sliders alone (`crates/ui-egui/src/tests_masking.rs`, `sideways_scrolling_adjusts_the_slider_under_the_pointer`). The vertical wheel nudges only a slider a click or drag selected, while the pointer stays in its row: leaving the row (even within one frame) disarms it until the next click or drag, and Tab focus arms only the arrow keys (issue #1355, `crates/ui-egui/src/widgets/tests_numeric_entry.rs`) |
-| KEY-SLIDER-TYPE | Type a slider value | P1 | ✅ | `crates/ui-egui/src/widgets.rs` (`typed_value`), `crates/ui-egui/src/text_field.rs`, `crates/ui-egui/src/widgets/tests_numeric_entry.rs` (`opening_release_honors_return_and_escape_immediately`), `crates/ui-egui/src/tests_keymap.rs` (`opening_numeric_release_keeps_keys_in_the_editor`) | click the value next to any slider's name and type one (`1.5`, `+0,25`, `-20`, `5600 K`): Return or clicking away applies it on the control's steps and range as one undo step, Esc keeps the old value; issue #322; Return/Escape take effect on the opening release, retaining the stored value on Escape; typing stays in the editor without triggering global shortcuts |
+| KEY-SLIDER-TYPE | Type a slider value | P1 | ✅ | `crates/ui-egui/src/widgets.rs` (`typed_value`), `crates/ui-egui/src/text_field.rs`, `crates/ui-egui/src/widgets/tests_numeric_entry.rs` (`opening_release_honors_return_and_escape_immediately`, `a_long_click_keeps_the_field_open`), `crates/ui-egui/src/tests_keymap.rs` (`opening_numeric_release_keeps_keys_in_the_editor`) | click the value next to any slider's name and type one (`1.5`, `+0,25`, `-20`, `5600 K`): Return or clicking away applies it on the control's steps and range as one undo step, Esc keeps the old value; issue #322; Return/Escape take effect on the opening release, retaining the stored value on Escape; typing stays in the editor without triggering global shortcuts; the field stays open however long the click is held (a release over the value keeps it, issue #1435) |
| KEY-SLIDER-SCRUB | Scrub a slider value — drag the number | P1 | ✅ | `crates/ui-egui/src/widgets.rs` (`slider`, `SCRUB_START`), `crates/ui-egui/src/widgets/tests_numeric_entry.rs` (`dragging_the_value_sideways_scrubs_it_like_the_thumb`, `scrubbing_back_and_with_shift`, `a_press_that_barely_moves_still_types`) | drag the value next to any slider's name sideways: it moves as dragging the thumb would (the pointer's travel over the track's width, ⇧ a tenth as far), on the control's steps and range, as one undo step; a press that moves less than 3 points sideways stays a click that types a value (KEY-SLIDER-TYPE); the pointer over the value is the horizontal-resize cursor, as Lightroom's scrubby value |
| KEY-SHORTCUTS | Shortcut list — ⌘/ | P1 | ✅ | `cmd:app.shortcuts` | |
| KEY-HELP | Help — F1 | P2 | ✅ | `cmd:app.help` | |
@@@ -797,7 -797,7 +797,8 @@@ Latin stays upright. Advanced Japanese
| Date | Change | Summary |
|---|---|---|
+ | 2026-10-21 | patch | KEY-SLIDER-NUDGE: vertical wheel nudges need a click or drag in the slider's row; leaving it (even between two frames) or Tab focus alone does not arm them (issue #1355); status unchanged |
+| 2026-10-20 | minor | LR-PRE-PANEL: the preset applied to a photo is marked again (with its Amount slider) on returning to the photo, until the photo is edited further (#2392); status unchanged (✅) |
| 2026-10-20 | patch | LR-VIEW-ZOOM: the 20 ms rule clears a slow-drag verdict only on a drag timed at full size; a drag that drafts small leaves it unchanged, as the code does; status unchanged |
| 2026-10-19 | patch | LR-VIEW-ZOOM: the slow slider-drag verdict is described as per photo and control, as the code keys it; status unchanged |
| 2026-10-15 | minor | LR-VIEW-ZOOM: a slow slider-drag verdict needs two drags over 20 ms and expires after 30 s (doubling to 240 s); hidden-window frame times are ignored; the slow set forgets its oldest entry, not all (issue #330); status unchanged |