From 73aa4348905f2fc8b35a32c03af62beb4484f1ac Mon Sep 17 00:00:00 2001 From: bflatastic Date: Sat, 21 Nov 2026 21:26:53 +0700 Subject: [PATCH] widgets-w6: net change of 1 commits - widgets-w6: written from its sheet --- crates/color-ui/src/ui/pair.rs | 226 +++++++++++++----- crates/color-ui/src/ui/pair/stories.rs | 78 ++++-- crates/color-ui/tests/it/pair.rs | 87 ++++++- crates/ui-contract/src/primitives/face.rs | 9 +- crates/ui-widgets/src/choice/swatch.rs | 131 +++++++--- .../ui-widgets/src/choice/swatch/stories.rs | 44 +++- 6 files changed, 447 insertions(+), 128 deletions(-) diff --git a/crates/color-ui/src/ui/pair.rs b/crates/color-ui/src/ui/pair.rs index 9b983a1f4..723517708 100644 --- a/crates/color-ui/src/ui/pair.rs +++ b/crates/color-ui/src/ui/pair.rs @@ -6,17 +6,19 @@ use craft_ui::buttons::IconButton; use craft_ui::choice::{ChoiceWords, Swatch, SwatchMetrics, SwatchStyle}; use craft_ui::contract::{ Access, Bind, BindMut, Common, Component, Cx, Edit as _, EditResponse, Focus as _, MeasureCx, Meta as _, Outcome, Overlay, OverlayUi, - Overlays as _, PaintUi, PartsCx, Pointer as _, Props as _, Remember as _, Role, WordSetCx as _, + DragPreview, DropMark, DropOperation, DropTarget, Overlays as _, PaintUi, PartsCx, Pointer as _, Props as _, Remember as _, Role, + WordSetCx as _, }; -use craft_ui::primitives::{DataWidth, Draw, Glyph, IconSpec, PaintShape, StrokeWidth}; +use craft_ui::primitives::{Glyph, IconSpec, PaintShape, StrokeWidth}; use craft_ui::runtime::commands::FireSource; use craft_ui::runtime::env::Label; -use craft_ui::style::{ComponentStyle, DataColor, Flags, FocusLook, GlyphRole, StyleColor, StyleCx, SurfaceEdge, SurfaceStyle, UiTokens}; +use craft_ui::style::{ComponentStyle, Flags, FocusLook, GlyphRole, StyleColor, StyleCx, SurfaceEdge, SurfaceStyle, UiTokens}; use egui::emath::GuiRounding as _; use egui::{Color32, CornerRadius, Painter, Pos2, Rect, Response, Shape, Stroke, StrokeKind, Vec2, pos2, vec2}; +use super::paint_chip::{WellLook, paint_well}; use super::popover::compact_picker; -use super::{ColorPicker, Paint, PickedColor, ScreenPickGesture}; +use super::{ColorPicker, Paint, PaintWords, PickedColor, ScreenPickGesture}; #[cfg(feature = "screen-testing")] mod stories; @@ -27,8 +29,6 @@ const WELL: PartKey = PartKey::new("well"); const DEFAULT: PartKey = PartKey::new("default"); /// The Swap Colours button. const SWAP: PartKey = PartKey::new("swap"); -/// A ring well's band, as a share of the well's side. -const RING_SHARE: f32 = 0.3; /// One of a [`SwatchPair`]'s wells. The primary one is at the start, top, the secondary one is /// offset towards the end and down: foreground and background, or fill and stroke. @@ -86,17 +86,7 @@ impl PairWell { /// A well named `label` showing any paint through `paint_well`; `Mixed::Mixed` for a selection whose paints differ. /// A ring well clips the face to its band; the popover picker starts from the solid colour or the first stop. pub fn paint(label: impl Into