From e3189215d9f64205c159b4e2668ee0eb1176ae1c Mon Sep 17 00:00:00 2001 From: aiongg Date: Fri, 20 Nov 2026 03:08:23 +0000 Subject: [PATCH] Preset picker: a caption range keeps the field at its widest caption A chip whose caption follows a value (the Brush Preset chip's diameter) took the width of its current caption, so the chip widened as the caption gained a digit. During a size drag that moved what follows it on the bar, and the bar's kept measure no longer matched, so the frame ran a second pass. PresetPicker::caption_range names the captions at the two ends of what the caption shows; the field measures with the wider, as a number field holds the widest value of its range. BrushPresetPicker passes the captions of 1 and its largest diameter. Part of storytold/photocraft#15476, for storytold/photocraft#15859. --- crates/draw/src/ui/brush_presets/picker.rs | 1 + .../src/patterns/presets/picker.rs | 59 +++++++++++++------ .../src/patterns/presets/picker/stories.rs | 19 ++++++ crates/ui-patterns/tests/it/presets/picker.rs | 38 +++++++++++- 4 files changed, 97 insertions(+), 20 deletions(-) diff --git a/crates/draw/src/ui/brush_presets/picker.rs b/crates/draw/src/ui/brush_presets/picker.rs index 711264ae7..74ef04d95 100644 --- a/crates/draw/src/ui/brush_presets/picker.rs +++ b/crates/draw/src/ui/brush_presets/picker.rs @@ -467,6 +467,7 @@ impl<'a, K: Value + Eq + Hash> BrushPresetPicker<'a, K> { let mut picker = PresetPicker::new(words.picker.clone(), current.reborrowed(), rows, Bind::bound(&mut browser)) .field(PickerField::Chip) .caption(env.units().number(values.diameter.round(), 0..=0)) + .caption_range([1.0, max_diameter].map(|diameter| Label::from(env.units().number(diameter.round(), 0..=0)))) .cell_shape(CellShape::Square) .view(if parts.tip_only() { PresetView::Grid } else { PresetView::List }) .browser(!compact) diff --git a/crates/ui-patterns/src/patterns/presets/picker.rs b/crates/ui-patterns/src/patterns/presets/picker.rs index bbc557008..b70e0d2b1 100644 --- a/crates/ui-patterns/src/patterns/presets/picker.rs +++ b/crates/ui-patterns/src/patterns/presets/picker.rs @@ -193,6 +193,11 @@ pub struct PresetPicker<'a, K: Value + Eq + Hash + 'static> { /// A short line under the field's thumbnail (a brush's current size). #[prop(into)] caption: Option