Merge pull request #10729 from dotCooCoo/fix/issue-10639

Color Picker: the canvas stays undimmed while the picker and preview dialogs are open
This commit is contained in:
.CooCoo authored and GitHub committed 2026-12-03 10:14:03 -08:00
commit de5157cf88
9 files changed
+88 -8

No files matched your search

+6 -1
View File
@@ -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() });
@@ -287,6 +287,12 @@ pub fn open(app: &mut VectorcraftApp, p: &Value) -> Result<Value, String> {
if let Some((document, _, index, _)) = artboard {
dialog = dialog.instance((document, index));
}
// 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);
}
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) {
@@ -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<egui::Event>| {
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");
}
+7 -2
View File
@@ -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<Value, String> {
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();
+7 -2
View File
@@ -102,9 +102,14 @@ pub(crate) fn open(app: &mut VectorcraftApp) -> Result<Value, String> {
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")?;
+5 -1
View File
@@ -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| {
+6 -1
View File
@@ -144,8 +144,13 @@ fn try_open(app: &mut VectorcraftApp) -> Result<Value, String> {
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")?;
+5 -1
View File
@@ -515,7 +515,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 =
+3
View File
@@ -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, 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
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