LightCraft: An open-source non-destructive photo editor written by scratch in pure Rust
LR-CROP-STRAIGHTEN: the Angle field reads decimal commas
Nathaniel Ledford56ee34fcf8a8
diff --git a/crates/ui-egui/src/panels/right.rs b/crates/ui-egui/src/panels/right.rsindex 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.rsindex 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));+ }+}