From 93ed763cd404fa976f99a011c0191aea37989390 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Thu, 3 Dec 2026 06:30:42 -0800 Subject: [PATCH 1/2] Fix #10639: the Color Picker and preview dialogs leave the canvas undimmed Every dialog has a modal rank with a scrim, and the cover layer leaves the scrim off only the canvas a dialog registers. The Color Picker opened from the Color panel or a shortcut and the Color Balance, Vector Halftone, Convert to Indexed Color, Step and Repeat, Transform Each and Flatten Transparency dialogs registered no canvas, so the scrim darkened the art while they previewed it. They now pass the current window's canvas, as the effect (#10297) and transform (#10255) dialogs do. The picker turns off canvas sampling, since the app does not take its canvas eyedropper request: the wheel, a middle-button drag and a drag with Space held still move the view under it, and other presses on the canvas do not reach the tools. --- crates/ui-egui/src/dialogs/color_balance.rs | 7 ++- crates/ui-egui/src/dialogs/color_picker.rs | 5 +++ .../ui-egui/src/dialogs/color_picker/tests.rs | 43 +++++++++++++++++++ crates/ui-egui/src/dialogs/flatten.rs | 9 +++- crates/ui-egui/src/dialogs/halftone.rs | 9 +++- crates/ui-egui/src/dialogs/indexed_color.rs | 6 ++- crates/ui-egui/src/dialogs/step_repeat.rs | 7 ++- crates/ui-egui/src/dialogs/transform_each.rs | 6 ++- docs/mcp.md | 3 ++ 9 files changed, 87 insertions(+), 8 deletions(-) diff --git a/crates/ui-egui/src/dialogs/color_balance.rs b/crates/ui-egui/src/dialogs/color_balance.rs index 110c124717..f508f52904 100644 --- a/crates/ui-egui/src/dialogs/color_balance.rs +++ b/crates/ui-egui/src/dialogs/color_balance.rs @@ -93,8 +93,13 @@ impl Adjust { { old.preview.cancel(app); } + let canvas = crate::doc_windows::current(app).map(crate::canvas::canvas_id); let dialog = HostedParamDialog::new(&ctx, self.kind, (self.initial)(), move |fields| { - ParamDialog::new(self.kind, self.label, (self.rows)()).values(Bind::bound(fields)).previews(true) + let dialog = ParamDialog::new(self.kind, self.label, (self.rows)()).values(Bind::bound(fields)).previews(true); + match canvas { + Some(canvas) => dialog.canvas(canvas), + None => dialog, + } }); let id = host::open_held(app, dialog, move |app, answer| self.commit(app, answer)).ok_or(NO_WINDOW)?; *(self.slot)(&mut app.color_dialogs) = Some(Open { id, document, preview: LivePreview::default() }); diff --git a/crates/ui-egui/src/dialogs/color_picker.rs b/crates/ui-egui/src/dialogs/color_picker.rs index 6863ee28a7..042e6c74c0 100644 --- a/crates/ui-egui/src/dialogs/color_picker.rs +++ b/crates/ui-egui/src/dialogs/color_picker.rs @@ -212,6 +212,11 @@ pub fn open(app: &mut VectorcraftApp, p: &Value) -> Result { if let Some((document, _, index, _)) = artboard { dialog = dialog.instance((document, index)); } + // The canvas stays undimmed under the picker, so its live preview shows the true color. Presses on it stay blocked: + // the app does not take the picker's canvas eyedropper request. + if let Some(canvas) = crate::doc_windows::current(app).map(crate::canvas::canvas_id) { + dialog = dialog.canvas(canvas).canvas_samples(false); + } let id = dialogs.with(|h| h.open(dialog)); // A picker the open replaced leaves its preview behind: end it. if let Some(at) = app.color_dialogs.pickers.iter().position(|open| open.id == id) { diff --git a/crates/ui-egui/src/dialogs/color_picker/tests.rs b/crates/ui-egui/src/dialogs/color_picker/tests.rs index 1abafe7025..4d7e820a29 100644 --- a/crates/ui-egui/src/dialogs/color_picker/tests.rs +++ b/crates/ui-egui/src/dialogs/color_picker/tests.rs @@ -451,3 +451,46 @@ fn the_artboard_picker_leaves_restored_artboards_unchanged() { assert_eq!(artboard_color(&app).map(|c| c.to_hex()).as_deref(), Some("#abcdef")); } } + +/// The picker keeps the document's canvas open under its modal layer (#10639): the canvas is not dimmed, so the live +/// preview shows the true color, and the wheel over the canvas still scrolls the view. +#[test] +fn the_canvas_stays_open_under_the_picker() { + let step = |app: &mut VectorcraftApp, ctx: &egui::Context, events: Vec| { + let screen = egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(1600.0, 850.0)); + crate::testing::app_frame(app, ctx, egui::RawInput { screen_rect: Some(screen), events, ..Default::default() }); + }; + let (mut app, ctx) = app(); + for _ in 0..3 { + step(&mut app, &ctx, vec![]); + } + app.run("ui.colorPicker", json!({})).unwrap(); + for _ in 0..3 { + step(&mut app, &ctx, vec![]); + } + assert!(!app.color_dialogs.pickers.is_empty(), "the picker is open"); + let at = app.canvas_view().unwrap().rect.left_top() + egui::vec2(20.0, 20.0); + for _ in 0..3 { + step(&mut app, &ctx, vec![egui::Event::PointerMoved(at)]); + } + let before = app.canvas_view().unwrap().center; + let wheel = egui::Event::MouseWheel { + unit: egui::MouseWheelUnit::Line, + delta: egui::vec2(0.0, -3.0), + phase: egui::TouchPhase::Move, + modifiers: egui::Modifiers::default(), + source: egui::MouseWheelSource::Unknown, + }; + for _ in 0..5 { + step(&mut app, &ctx, vec![egui::Event::PointerMoved(at), wheel.clone()]); + } + assert_ne!(app.canvas_view().unwrap().center, before, "the wheel over the canvas scrolls the view under the picker"); + // A click on the canvas stays blocked: it does not reach the tool and clear the selection. + let selected = app.session.doc().unwrap().selection.clone(); + let press = + |pressed| egui::Event::PointerButton { pos: at, button: egui::PointerButton::Primary, pressed, modifiers: egui::Modifiers::default() }; + step(&mut app, &ctx, vec![egui::Event::PointerMoved(at), press(true)]); + step(&mut app, &ctx, vec![press(false)]); + step(&mut app, &ctx, vec![]); + assert_eq!(app.session.doc().unwrap().selection, selected, "the click under the picker leaves the selection"); +} diff --git a/crates/ui-egui/src/dialogs/flatten.rs b/crates/ui-egui/src/dialogs/flatten.rs index 2b3760f38f..796a829836 100644 --- a/crates/ui-egui/src/dialogs/flatten.rs +++ b/crates/ui-egui/src/dialogs/flatten.rs @@ -249,8 +249,13 @@ pub(crate) fn apply_custom(job: &mut SavePdfJob, parent: &HostedPdfExport, field /// Open Flatten Transparency for the selection with the default preset. pub(crate) fn open(app: &mut VectorcraftApp) -> Result { let ctx = app.ui_ctx.clone().ok_or("no window")?; - let dialog = HostedParamDialog::new(&ctx, KEY, option_fields(&FlattenOptions::default()), |fields| { - ParamDialog::new(KEY, tl!("Flatten Transparency"), option_params(&[], "")).values(Bind::bound(fields)).previews(true) + let canvas = crate::doc_windows::current(app).map(crate::canvas::canvas_id); + let dialog = HostedParamDialog::new(&ctx, KEY, option_fields(&FlattenOptions::default()), move |fields| { + let dialog = ParamDialog::new(KEY, tl!("Flatten Transparency"), option_params(&[], "")).values(Bind::bound(fields)).previews(true); + match canvas { + Some(canvas) => dialog.canvas(canvas), + None => dialog, + } }) // Flattening complex art is slow: the preview waits until it is turned on. .preview_off(); diff --git a/crates/ui-egui/src/dialogs/halftone.rs b/crates/ui-egui/src/dialogs/halftone.rs index ebc54223f6..916208960a 100644 --- a/crates/ui-egui/src/dialogs/halftone.rs +++ b/crates/ui-egui/src/dialogs/halftone.rs @@ -84,9 +84,14 @@ pub(crate) fn open(app: &mut VectorcraftApp) -> Result { let defaults = fields(); let rows = screen_params(false, &DialogFields::new()); let initial = fields_of(&rows, defaults.as_object().unwrap_or(&Default::default())); - let dialog = HostedParamDialog::command(&ctx, CMD, initial, |fields| { + let canvas = crate::doc_windows::current(app).map(crate::canvas::canvas_id); + let dialog = HostedParamDialog::command(&ctx, CMD, initial, move |fields| { let rows = screen_params(false, fields); - ParamDialog::command(CMD, tl!("Vector Halftone"), rows).previews(true).values(Bind::bound(fields)) + let dialog = ParamDialog::command(CMD, tl!("Vector Halftone"), rows).previews(true).values(Bind::bound(fields)); + match canvas { + Some(canvas) => dialog.canvas(canvas), + None => dialog, + } }); let ok = |app: &mut VectorcraftApp, result: &ParamResult| { let open = app.effect_dialogs.halftone.as_ref().ok_or("the dialog is closed")?; diff --git a/crates/ui-egui/src/dialogs/indexed_color.rs b/crates/ui-egui/src/dialogs/indexed_color.rs index 0f1aec1462..d9850c0edd 100644 --- a/crates/ui-egui/src/dialogs/indexed_color.rs +++ b/crates/ui-egui/src/dialogs/indexed_color.rs @@ -103,7 +103,11 @@ pub fn open(app: &mut VectorcraftApp) { if let Some(old) = app.object_dialogs.indexed.take() { old.cancel_preview(app); } - let dialog = HostedParamDialog::new(&ctx, KIND, DialogFields::new(), build); + let canvas = crate::doc_windows::current(app).map(crate::canvas::canvas_id); + let dialog = HostedParamDialog::new(&ctx, KIND, DialogFields::new(), move |fields| match canvas { + Some(canvas) => build(fields).canvas(canvas), + None => build(fields), + }); let opening = Arc::new(()); let cancelled = Arc::clone(&opening); let ok = |app: &mut VectorcraftApp, r: &ParamResult| { diff --git a/crates/ui-egui/src/dialogs/step_repeat.rs b/crates/ui-egui/src/dialogs/step_repeat.rs index 4a14fe4d2a..ab34502299 100644 --- a/crates/ui-egui/src/dialogs/step_repeat.rs +++ b/crates/ui-egui/src/dialogs/step_repeat.rs @@ -144,8 +144,13 @@ fn try_open(app: &mut VectorcraftApp) -> Result { let lengths = LengthUnits::new(UnitKind::Points, super::rearrange_artboards::length_kind(app.session.general_unit()), 72.0); let lengths = crate::fields::bare_points(lengths, app.session.prefs.numbers_without_units_are_points); let cuts = cut_options(app); + let canvas = crate::doc_windows::current(app).map(crate::canvas::canvas_id); let dialog = HostedParamDialog::command(&ctx, CMD, fields(), move |fields| { - ParamDialog::command(CMD, tl!("Step and Repeat"), rows(lengths, cuts.clone())).previews(true).values(Bind::bound(fields)) + let dialog = ParamDialog::command(CMD, tl!("Step and Repeat"), rows(lengths, cuts.clone())).previews(true).values(Bind::bound(fields)); + match canvas { + Some(canvas) => dialog.canvas(canvas), + None => dialog, + } }); let ok = |app: &mut VectorcraftApp, result: &ParamResult| { let mut open = app.object_dialogs.step.take().ok_or("the dialog is closed")?; diff --git a/crates/ui-egui/src/dialogs/transform_each.rs b/crates/ui-egui/src/dialogs/transform_each.rs index 6bb3b55915..529da2d359 100644 --- a/crates/ui-egui/src/dialogs/transform_each.rs +++ b/crates/ui-egui/src/dialogs/transform_each.rs @@ -509,7 +509,11 @@ pub(crate) fn open(app: &mut VectorcraftApp) { } } apply_links(&mut f, shared); - let dialog = HostedParamDialog::new(&ctx, KEY, f, move |fields| form(fields, shared, lengths)); + let canvas = crate::doc_windows::current(app).map(crate::canvas::canvas_id); + let dialog = HostedParamDialog::new(&ctx, KEY, f, move |fields| match canvas { + Some(canvas) => form(fields, shared, lengths).canvas(canvas), + None => form(fields, shared, lengths), + }); let options = HeldOptions { cancel: Some(Box::new(cancel)), ..Default::default() }; if let Some(id) = open_held_with(app, dialog, move |app, result| ok(app, &ctx, result), options) { app.object_dialogs.each = diff --git a/docs/mcp.md b/docs/mcp.md index 30ac0bfb82..9d2203d7f1 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -684,6 +684,9 @@ space. RGB edits preserve the other native channels; HSB uses those same working display sRGB retain their native numeric values. `ui.colorPanel` selects the panel mode and `ui.colorPicker` opens the picker through `run_command` with the remote backend. Edit › Keyboard Shortcuts lists `ui.colorPicker` as Color Picker… with no default key; a key assigned there opens the picker for the proxy in front, as `{}` does. +While the picker is open, the canvas of the current window is not dimmed, so the live preview shows the picked color. +The wheel scrolls and zooms the view, and a middle-button drag or a drag with Space held pans it; other presses on the +canvas do not reach the tools or sample a color. `ui.colorPanel {"recentColors": false}` unchecks the panel menu's Show Recent Colors, which hides the Color panel's Recent Colors row, and `true` shows it again; applied colors still join the list while it is hidden. `ui.colorPanel {"rgbPercent": true}` shows the Color panel's RGB fields in percent, as a double-click right of an RGB From 9711371ab97d7400ed886ca5361aad757e587992 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Thu, 3 Dec 2026 07:36:01 -0800 Subject: [PATCH 2/2] Color picker: say the picker adds no dimming of its own Another open dialog, such as New Swatch, keeps its own scrim over the canvas while the picker is open. The doc line in docs/mcp.md and the comment in dialogs/color_picker.rs now say so. --- crates/ui-egui/src/dialogs/color_picker.rs | 3 ++- docs/mcp.md | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/src/dialogs/color_picker.rs b/crates/ui-egui/src/dialogs/color_picker.rs index 042e6c74c0..479cbd1a34 100644 --- a/crates/ui-egui/src/dialogs/color_picker.rs +++ b/crates/ui-egui/src/dialogs/color_picker.rs @@ -212,7 +212,8 @@ pub fn open(app: &mut VectorcraftApp, p: &Value) -> Result { if let Some((document, _, index, _)) = artboard { dialog = dialog.instance((document, index)); } - // The canvas stays undimmed under the picker, so its live preview shows the true color. Presses on it stay blocked: + // The picker adds no dimming of its own over the canvas, so its live preview shows the true color; another open + // dialog's scrim can still dim the canvas. Presses on it stay blocked: // the app does not take the picker's canvas eyedropper request. if let Some(canvas) = crate::doc_windows::current(app).map(crate::canvas::canvas_id) { dialog = dialog.canvas(canvas).canvas_samples(false); diff --git a/docs/mcp.md b/docs/mcp.md index 9d2203d7f1..40b15fe52e 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -684,7 +684,7 @@ space. RGB edits preserve the other native channels; HSB uses those same working display sRGB retain their native numeric values. `ui.colorPanel` selects the panel mode and `ui.colorPicker` opens the picker through `run_command` with the remote backend. Edit › Keyboard Shortcuts lists `ui.colorPicker` as Color Picker… with no default key; a key assigned there opens the picker for the proxy in front, as `{}` does. -While the picker is open, the canvas of the current window is not dimmed, so the live preview shows the picked color. +While the picker is open, it adds no dimming of its own over the canvas of the current window, so the live preview shows the picked color. Another open dialog, such as New Swatch, can still dim the canvas with its own scrim. The wheel scrolls and zooms the view, and a middle-button drag or a drag with Space held pans it; other presses on the canvas do not reach the tools or sample a color. `ui.colorPanel {"recentColors": false}` unchecks the panel menu's Show Recent Colors, which hides the Color panel's