From 56ee34fcf8a889731f3fc32a214b8fb7c21a8ed9 Mon Sep 17 00:00:00 2001 From: Nathaniel Ledford Date: Fri, 9 Oct 2026 12:06:29 -0400 Subject: [PATCH] LR-CROP-STRAIGHTEN: the Angle field reads decimal commas MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit egui's own parser dropped "-3,25" silently, while the Straighten value takes it (issue #322). The field now reads a typed angle through the same `typed_value`: a decimal comma, a trailing degree sign, and an angle past ±45° held at the limit. Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/panels/right.rs | 2 ++ crates/ui-egui/src/tests_crop_rotate.rs | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/crates/ui-egui/src/panels/right.rs b/crates/ui-egui/src/panels/right.rs index 8e7da9ef1..bf7c400ed 100644 --- a/crates/ui-egui/src/panels/right.rs +++ b/crates/ui-egui/src/panels/right.rs @@ -198,6 +198,8 @@ fn crop(app: &mut LightcraftApp, ui: &mut egui::Ui, id: PhotoId) { .speed(0.05) .fixed_decimals(2) .suffix("°") + // read as the Straighten value reads a typed one: "-3,25" too + .custom_parser(|text| crate::widgets::typed_value(&spec, text.trim().trim_end_matches('°'))) // a typed angle applies on Return (or leaving the field), not keystroke by // keystroke: no half-typed angles, one undo step .update_while_editing(false), diff --git a/crates/ui-egui/src/tests_crop_rotate.rs b/crates/ui-egui/src/tests_crop_rotate.rs index 60d58552d..5313ff0f2 100644 --- a/crates/ui-egui/src/tests_crop_rotate.rs +++ b/crates/ui-egui/src/tests_crop_rotate.rs @@ -329,3 +329,25 @@ fn a_rotation_cut_short_leaves_nothing_behind() { assert!(!has(&h, "cropAngleReadout"), "no angle"); assert!(!has(&h, "cropRotateCursor"), "no rotation glyph"); } + +/// The Angle field reads a typed angle as the Straighten value does: a decimal comma, a degree +/// sign, and an angle past ±45° held at the limit. +#[test] +fn the_angle_field_reads_angles_as_people_type_them() { + let mut h = crop_tool(); + for (typed, want) in [("-3,25", -3.25), ("1.5°", 1.5), ("60", 45.0)] { + let r = h.request("ui.clickWidget", json!({"id": "cropAngleField"}), T); + assert_eq!(r["ok"], true, "{r}"); + h.settle(SETTLE); + for key in ["a", "Backspace"] { + let r = h.request("ui.key", json!({"key": key, "cmd": key == "a"}), T); + assert_eq!(r["ok"], true, "{r}"); + } + let r = h.request("ui.text", json!({"text": typed}), T); + assert_eq!(r["ok"], true, "{r}"); + let r = h.request("ui.key", json!({"key": "Enter"}), T); + assert_eq!(r["ok"], true, "{r}"); + h.settle(SETTLE); + assert!((angle(&h) - want).abs() < 1e-9, "{typed:?}: want {want}, got {}", angle(&h)); + } +}