LR-CROP-STRAIGHTEN: the Angle field reads decimal commas

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 <noreply@anthropic.com>
This commit is contained in:
Nathaniel Ledford
2026-10-09 12:10:50 -04:00
co-authored by Claude Opus 5.5
parent f34c967900
commit 56ee34fcf8
2 changed files with 24 additions and 0 deletions
+2
View File
@@ -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),
+22
View File
@@ -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));
}
}