diff --git a/crates/imaging/src/ui/color_range/dialog.rs b/crates/imaging/src/ui/color_range/dialog.rs index 520f28ae8..1c916786f 100644 --- a/crates/imaging/src/ui/color_range/dialog.rs +++ b/crates/imaging/src/ui/color_range/dialog.rs @@ -1,11 +1,30 @@ //! The Color Range dialog's body. -use craft_ui::canvas::RasterSource; -use craft_ui::contract::{Bind, EditResponse, NoValue, Outcome, Pattern, Props}; -use craft_ui::runtime::env::Label; -use egui::{Response, Ui}; +use std::ops::RangeInclusive; +use std::sync::Arc; -use super::ColorRangeValue; +use craft_behavior::{CursorBadge, EditEvent, EditEvents, IconId, Mixed}; +use craft_ui::buttons::Button; +use craft_ui::canvas::{PixelRect, RasterSource}; +use craft_ui::choice::{Checkbox, Radio, RadioGroup, Segmented}; +use craft_ui::contract::{ + Bind, CanvasGesture, EditResponse, Entry, NoValue, Outcome, Pattern, Props, Sampler as _, Show as _, ShowContainer as _, clicked, +}; +use craft_ui::display::{Shade, Text}; +use craft_ui::form::{Field, FieldGroup, SliderField}; +use craft_ui::layout_components::{Row, Stack}; +use craft_ui::patterns::form_dialogs::{PreviewPane, PreviewState, PreviewView}; +use craft_ui::pickers::Select; +use craft_ui::primitives::{IconSpec, TextureCache}; +use craft_ui::runtime::env::{Env, Label, UnitKind}; +use craft_ui::runtime::pointer; +use craft_ui::style::TypeRole; +use egui::load::SizedTexture; +use egui::{Color32, ColorImage, Response, Ui, Vec2}; + +use super::{ColorRangeSelect, ColorRangeValue, ColorRangeWords, SampleTool}; +use crate::selection::PreviewMode; +use crate::ui::selection::SelectionWords; /// What the Color Range body reports. #[derive(Debug)] @@ -15,6 +34,12 @@ pub struct ColorRangeOutput { pub edit: EditResponse, /// The body's response. pub response: Response, + /// The sample tool picked this pass. + pub tool: Option, + /// The view picked this pass: `true` for Image, `false` for Selection. + pub show_image: Option, + /// The Selection Preview mode picked this pass. + pub preview: Option, } impl Outcome for ColorRangeOutput { @@ -26,9 +51,14 @@ impl Outcome for ColorRangeOutput { } /// The Color Range body: the select, the sliders, the selection preview and the sampling tools. +/// +/// The sample tool, the Selection / Image view and the Selection Preview mode are dialog state beside the value: the +/// caller passes them in and takes the changes from the output. +/// +/// A press (and each pass the held pointer moves) in the preview samples a colour while Sampled Colors is selected. +/// Each pass applies only the press phase of its own input, so a second pass in the same frame samples nothing. #[must_use = "show the dialog body with `show`"] #[derive(Pattern, Props)] -#[allow(dead_code)] // P3(dialogs-w9): dl.K54 pub struct ColorRangeDialog<'a> { label: Label, value: Bind<'a, ColorRangeValue>, @@ -41,24 +71,295 @@ pub struct ColorRangeDialog<'a> { /// The integer proxy factor `k`, halved by integer division. #[prop] picture_scale: u32, + /// The document's size in pixels, which a sample is clamped to. + #[prop] + document: [u32; 2], /// An error to show under the preview. #[prop] error: Option