LR-LIB-CULL: a typed similarity keeps its thousandths (#2275)

The similarity slider stepped and showed whole hundredths, and egui applies both
to a typed value too, so 0.995 became 1.00 before photo.analyze saw it. It now
steps by a thousandth and shows two or three decimals: dragging still lands on
round values, and a typed 0.995 is kept.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
helgehelge123
2026-10-22 20:49:20 +02:00
co-authored by Claude Opus 5.5
parent 6f056745e1
commit 6b3cc777c1
+11 -2
View File
@@ -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}");