diff --git a/crates/draw/src/ui/gradient/palette/mod.rs b/crates/draw/src/ui/gradient/palette/mod.rs index f1ada39931..33a73b12f4 100644 --- a/crates/draw/src/ui/gradient/palette/mod.rs +++ b/crates/draw/src/ui/gradient/palette/mod.rs @@ -4,7 +4,7 @@ use craft_ui::contract::{Bind, NoValue, Outcome, Pattern}; use craft_ui::patterns::presets::{CellShape, PresetBrowser, PresetEvent, PresetRow, PresetState}; -use craft_ui::runtime::env::Label; +use craft_ui::runtime::env::{Env, Label}; use egui::{Response, Ui}; #[cfg(feature = "screen-testing")] @@ -12,6 +12,9 @@ mod stories; use craft_color::ui::gradient::{GradientRamp, GradientStops, Sampler, StopRows, default_sampler}; +/// The presets take their content height up to this many small control heights, then scroll. +const MAX_ROWS: f32 = 5.0; + /// A named group of gradient presets. #[derive(Clone, Debug, PartialEq)] #[non_exhaustive] @@ -100,7 +103,8 @@ impl GradientRef { /// left; the gradients are not), Up and Down to the nearest cell in the row above or below /// across group labels, Home and End to the first and last. In List, Up, Down, Home and End /// move and Left and Right do nothing. A focus move scrolls the cell into view. -/// - The area scrolls past `max_height`. +/// - The presets take their content height up to five small control heights and scroll past it, also in a host +/// that sizes to its content (a popover), where a filling browser would take the whole room. /// - AccessKit: Grid is a `Group` named `label` with `Button` cells; List is a `ListBox` of /// `ListBoxOption`s with `selected` on the chosen one. Cells carry their place and the set's /// size. A screen reader's Focus action on a cell moves the palette's stop to it. @@ -203,7 +207,9 @@ impl<'a> GradientPalette<'a> { } }; let (wide, high) = GradientRamp::CHIP_ASPECT; - let mut browser = PresetBrowser::new(self.label, self.state, &rows).cell_shape(CellShape::ratio(wide, high)).thumb(thumb); + let most = Env::of(ui).tokens.size.control.sm * MAX_ROWS; + let mut browser = + PresetBrowser::new(self.label, self.state, &rows).cell_shape(CellShape::ratio(wide, high)).room_height(most).thumb(thumb); if let Some(selected) = self.selected { browser = browser.selected(selected); }