From 4ff83a83e2541ea5bf5ca1834b67502ef22ea061 Mon Sep 17 00:00:00 2001 From: aiongg Date: Sun, 15 Nov 2026 04:46:08 +0000 Subject: [PATCH] dialogs-w9: net change of 5 commits - dialogs-w9: written from its sheet - dialogs-w9: repair 1 - Integration: imaging's trial list keeps dialogs-w17's raw_develop beside color_range - dialogs-w9: review fixes (review-1) - dialogs-w9: the color range trial's proxy is large enough that the preview fits it to the well inside the zoom range (top run round) --- crates/imaging/src/ui/color_range/dialog.rs | 321 +++++++++++++++++- crates/imaging/src/ui/color_range/hosted.rs | 177 ++++++++-- crates/imaging/src/ui/color_range/labels.rs | 30 ++ crates/imaging/src/ui/color_range/mod.rs | 14 +- crates/imaging/src/ui/color_range/stories.rs | 63 ++++ crates/imaging/src/ui/color_range/value.rs | 116 +++++-- crates/imaging/src/ui/mod.rs | 36 +- crates/imaging/tests/it/color_range.rs | 161 +++++++++ crates/imaging/tests/it/main.rs | 1 + .../src/patterns/form_dialogs/preview.rs | 37 +- 10 files changed, 856 insertions(+), 100 deletions(-) create mode 100644 crates/imaging/src/ui/color_range/stories.rs create mode 100644 crates/imaging/tests/it/color_range.rs 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