diff --git a/crates/color/src/ui/area.rs b/crates/color/src/ui/area.rs index accd128c2..12fc357f8 100644 --- a/crates/color/src/ui/area.rs +++ b/crates/color/src/ui/area.rs @@ -73,6 +73,14 @@ impl<'a> ColorArea<'a> { self.quantize.map(|levels| levels.max(2)) } + /// The values the pointer at `at` picks in `rect`: the picker's own point-to-value mapping, then the settle and + /// quantise steps. `ColorHud` drives it with the host's pointer. + #[allow(dead_code)] // P3(panels-w7): pn.C32 + pub(crate) fn value_at(&self, rect: Rect, values: &ModelValues, at: egui::Pos2) -> ModelValues { + let _ = (rect, values, at); + todo!("pn.C32") + } + /// The picker over `shown`, whose backdrop paints the field of `base`. fn picker<'c>(&self, shown: Option<&ModelValues>, field: bool) -> PointPicker<'c> { let model = self.mode.model(); diff --git a/crates/color/src/ui/hud.rs b/crates/color/src/ui/hud.rs new file mode 100644 index 000000000..2e4e9978c --- /dev/null +++ b/crates/color/src/ui/hud.rs @@ -0,0 +1,62 @@ +//! [`ColorHud`]: the colour area and hue strip in a popover at a point, driven by the host's press. + +use craft_behavior::EditEvents; +use craft_theme::Srgba; +use craft_ui::contract::{Bind, Pattern}; +use craft_ui::runtime::env::Label; +use craft_ui::runtime::overlay::CloseReason; +use egui::{Pos2, Response, Ui}; + +/// The area and hue strip in a popover at `at`, with the start colour under it, driven by the host's press: the pick +/// maps `pointer` through `ColorArea` and the strip's `value_at`; no pick while `pointer` is still `at`; one gesture +/// per open; Escape or `held(false)` commits and closes. Every input is a prop of the pass; the HUD keeps no state. +#[must_use = "show the HUD with `show`"] +#[derive(Pattern)] +#[allow(dead_code)] // P3(panels-w7): pn.C31 +pub struct ColorHud<'a> { + label: Label, + at: Pos2, + color: Bind<'a, Srgba>, + pointer: Option, + held: bool, +} + +impl<'a> ColorHud<'a> { + /// A HUD named `label` at `at` over `color`. + pub fn new(label: impl Into