mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-26 23:59:05 +00:00
Gradient palette: the presets take their content height up to five small control heights, then scroll
In a content-sized popover (the paint chip's Gradient tab) the palette's preset browser filled the popover's whole room, so the gradient options under it (Reverse, Dither, Align) fell below the window. The old palette scrolled past five small control heights, as PhotoCraft's 120 px preset list does; the browser's room_height gives that bound.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user