From bc61abdff2314f8450abc6e60c1278dd370f76fb Mon Sep 17 00:00:00 2001 From: aiongg Date: Mon, 16 Nov 2026 21:18:29 +0000 Subject: [PATCH] Gradient preview carries the gradient's direction, so a Reverse edit changes the paint a chip sets --- crates/color/src/ui/paint_chip.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/crates/color/src/ui/paint_chip.rs b/crates/color/src/ui/paint_chip.rs index 1d5f77a5b..428fecf87 100644 --- a/crates/color/src/ui/paint_chip.rs +++ b/crates/color/src/ui/paint_chip.rs @@ -88,12 +88,21 @@ craft_ui::words! { pub struct GradientPreview { /// Stops as (position 0–1, colour), ascending by position. pub stops: Vec<(f32, Srgba)>, + /// Whether the host's gradient runs end to start. The ramp keeps the stops as given; the flag is part of the + /// preview's value so that a Reverse edit, which leaves the stops alone, still changes the paint the chip sets. + pub reverse: bool, } impl GradientPreview { - /// A preview through `stops`. + /// A preview through `stops`, not reversed. pub fn new(stops: Vec<(f32, Srgba)>) -> Self { - GradientPreview { stops } + GradientPreview { stops, reverse: false } + } + + /// The preview with the gradient reversed or not. + pub fn reversed(mut self, reverse: bool) -> Self { + self.reverse = reverse; + self } }