diff --git a/crates/draw/src/ui/brush_presets/picker.rs b/crates/draw/src/ui/brush_presets/picker.rs index 74ef04d95..fb51e253a 100644 --- a/crates/draw/src/ui/brush_presets/picker.rs +++ b/crates/draw/src/ui/brush_presets/picker.rs @@ -4,7 +4,7 @@ use std::cell::{Cell, RefCell}; use std::hash::Hash; -use craft_behavior::{EditEvent, EditEvents, IconId, Mixed, Value}; +use craft_behavior::{Codec as _, EditEvent, EditEvents, IconId, Mixed, NumberCodec, Value}; use craft_ui::buttons::IconButton; use craft_ui::contract::{ Bind, BodyCx, EditResponse, Outcome, Props as _, Remember as _, SaveKey, Show as _, ShowContainer as _, TooltipSpec, Trigger, clicked, @@ -466,8 +466,8 @@ 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)))) + .caption(NumberCodec::new(env.units().reader(None), 0).format(&Some(values.diameter.round()))) + .caption_range((1.0..=max_diameter.round(), 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 b70e0d2b1..7aefb3eab 100644 --- a/crates/ui-patterns/src/patterns/presets/picker.rs +++ b/crates/ui-patterns/src/patterns/presets/picker.rs @@ -30,9 +30,10 @@ use crate::runtime::memory::StageAccess; use crate::runtime::overlay::CloseReason; use crate::style::{ComponentStyle, FocusLook, StyleCx, SurfaceLook, UiTokens}; use crate::tile_grid::TileZoom; -use craft_behavior::{EditEvent, EditEvents, HitLevel, HitPriority, Intent, Metrics, Mixed, PartKey, PressPhase, Sense, Value}; +use craft_behavior::{EditEvent, EditEvents, HitLevel, HitPriority, Intent, Metrics, Mixed, NumberCodec, PartKey, PressPhase, Sense, Value}; use egui::{Pos2, Rect, Response, Ui, Vec2}; use std::hash::Hash; +use std::ops::RangeInclusive; /// The face under the whole field. const FACE: PartKey = PartKey::new("face"); @@ -193,11 +194,12 @@ 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