LightCraft: An open-source non-destructive photo editor written by scratch in pure Rust
LR-LIB-CULL: a typed similarity keeps its thousandths (#2275)
helgehelge1236b3cc777c147
diff --git a/crates/ui-egui/src/panels/dialogs.rs b/crates/ui-egui/src/panels/dialogs.rsindex d90e3285a..205e9d1c6 100644--- a/crates/ui-egui/src/panels/dialogs.rs+++ b/crates/ui-egui/src/panels/dialogs.rs@@ -364,8 +364,10 @@ pub fn show(app: &mut LightcraftApp, ctx: &egui::Context) {egui::Slider::new(similarity, 0.70..=0.99).clamping(egui::SliderClamping::Never).text(crate::i18n::tr("Burst: how alike (loose … strict)"))- .step_by(0.01)- .fixed_decimals(2),+ // a typed 0.995 is kept (whole hundredths would round it to 1.00)+ .step_by(0.001)+ .min_decimals(2)+ .max_decimals(3),);crate::widgets::register(ui.ctx(), "field:cullSimilar", r.rect);clamp_cull_burst(burst_gap, similarity);@@ -2511,6 +2513,13 @@ mod cull_dialog_tests {assert_eq!(burst(&h), (0.0, 1.0));type_value(&mut h, "field:cullGap", "1800");assert_eq!(burst(&h).0, 1800.0);+ // a similarity between the slider's hundredths is kept to the thousandth+ type_value(&mut h, "field:cullSimilar", "0.995");+ assert_eq!(burst(&h).1, 0.995);+ type_value(&mut h, "field:cullSimilar", "0.9951");+ assert_eq!(burst(&h).1, 0.995);+ type_value(&mut h, "field:cullSimilar", "1.0");+ assert_eq!(burst(&h).1, 1.0);// OK hands them to photo.analyze as typed (it refuses values out of its range)let r = h.request("ui.dialog.confirm", json!({}), T);assert_eq!(r["ok"], true, "{r}");