From 3f8dbe0121bde69e399efcfe46ae3e1bc247b70e Mon Sep 17 00:00:00 2001 From: bflatastic Date: Sat, 21 Nov 2026 21:26:58 +0700 Subject: [PATCH] color-w1: net change of 1 commits - color-w1: written from its sheet --- crates/color-ui/src/ui/palette.rs | 29 +++-- crates/color-ui/src/ui/palette/stories.rs | 22 +++- crates/color-ui/src/ui/ramp.rs | 39 +++++-- crates/color-ui/src/ui/ramp/stories.rs | 11 ++ crates/ui-widgets/src/choice/swatch_table.rs | 103 ++++++++++++------ .../src/choice/swatch_table/stories.rs | 58 +++++++++- 6 files changed, 204 insertions(+), 58 deletions(-) diff --git a/crates/color-ui/src/ui/palette.rs b/crates/color-ui/src/ui/palette.rs index db62b23c9..e94ece836 100644 --- a/crates/color-ui/src/ui/palette.rs +++ b/crates/color-ui/src/ui/palette.rs @@ -13,6 +13,9 @@ use std::sync::Arc; #[cfg(feature = "screen-testing")] mod stories; +/// The table's drag mapper, type-erased so the palette needs no payload parameter. +type TableMap<'a> = Arc) -> SwatchTable<'a> + 'a>; + /// What a [`SwatchPalette`] reports. #[derive(Debug)] #[non_exhaustive] @@ -49,38 +52,46 @@ pub struct SwatchPalette<'a> { label: Label, color: Bind<'a, Srgba>, swatches: &'a [(Label, Srgba)], + spacing: SwatchSpacing, + drag: Option>, } impl<'a> SwatchPalette<'a> { /// A palette named `label` of `swatches`, each a name and a colour, choosing the colour bound to `color`. pub fn new(label: impl Into