From 1b3312fd8c7912873b070610e00d842039649c87 Mon Sep 17 00:00:00 2001 From: DuBearte <130190089+DuBearte@users.noreply.github.com> Date: Sat, 7 Nov 2026 14:12:06 -0500 Subject: [PATCH 01/27] Brush Preset picker: Size and Hardness take whole numbers and alert when out of range Fixes #11817. Co-Authored-By: Claude Opus 5.5 --- .../src/brush_picker_range_alert_tests.rs | 88 +++++++++++++++++++ crates/ui-egui/src/lib.rs | 2 + crates/ui-egui/src/tools/brush_picker.rs | 56 ++++++++++-- 3 files changed, 139 insertions(+), 7 deletions(-) create mode 100644 crates/ui-egui/src/brush_picker_range_alert_tests.rs diff --git a/crates/ui-egui/src/brush_picker_range_alert_tests.rs b/crates/ui-egui/src/brush_picker_range_alert_tests.rs new file mode 100644 index 0000000000..80fdabe2ae --- /dev/null +++ b/crates/ui-egui/src/brush_picker_range_alert_tests.rs @@ -0,0 +1,88 @@ +//! #11817: the Brush Preset picker's Size and Hardness take whole numbers; a value typed past the +//! range becomes the closest one and, once the field is left, an alert with OK says so. The +//! picker stays open after OK. + +use egui::vec2; +use egui_kittest::Harness; +use egui_kittest::kittest::{NodeT, Queryable}; +use serde_json::json; + +use crate::brush_picker::{HARDNESS_RANGE_ALERT, SIZE_RANGE_ALERT}; +use crate::state::DialogKind; +use crate::{PhotocraftApp, Services, Tool}; + +fn harness() -> Harness<'static, PhotocraftApp> { + let mut h = Harness::builder().with_size(vec2(1400.0, 900.0)).with_step_dt(1.0 / 60.0).build_eframe(|cc| { + PhotocraftApp::setup_context(&cc.egui_ctx, Default::default()); + let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), Services::default()); + app.run("file.new", json!({"width": 400, "height": 300})).unwrap(); + app.run("tools.setBrush", json!({"brush": {"size": 20, "hardness": 0.5}})).unwrap(); + app.ui.tool = Tool::Brush; + app + }); + h.run_steps(5); + let ctx = h.ctx.clone(); + let c = h.state().last_canvas_rect.center(); + crate::brush_picker::open(&mut h.state_mut().ui, &ctx, [c.x, c.y]); + h.run_steps(3); + h +} + +/// Type `text` into the picker field named `name`, then Tab out of it. +fn type_into(h: &mut Harness<'static, PhotocraftApp>, name: &str, text: &str) { + h.query_all_by_role(egui::accesskit::Role::SpinButton).find(|n| n.accesskit_node().label().as_deref() == Some(name)).expect("the field").click(); + h.run_steps(1); + h.key_press_modifiers(egui::Modifiers::COMMAND, egui::Key::A); + h.event(egui::Event::Text(text.into())); + h.run_steps(1); + h.key_press(egui::Key::Tab); + h.run_steps(3); +} + +fn alert(h: &Harness<'static, PhotocraftApp>) -> Option { + h.state().ui.dialogs.iter().find(|d| d.kind == DialogKind::Error).and_then(|d| d.fields.get("message")).and_then(|m| m.as_str()).map(str::to_owned) +} + +fn size(h: &Harness<'static, PhotocraftApp>) -> f32 { + h.state().session.tools.brush.size +} + +#[test] +fn size_past_the_range_takes_the_closest_value_and_alerts() { + for (typed, want) in [("9999", 5000.0), ("0", 1.0), ("-5", 1.0)] { + let mut h = harness(); + type_into(&mut h, "Size", typed); + assert_eq!(size(&h), want, "{typed}"); + assert_eq!(alert(&h).as_deref(), Some(SIZE_RANGE_ALERT), "{typed}"); + assert!(h.state().ui.brush_picker.is_some(), "{typed}: the picker stays open under the alert"); + h.get_by_label("OK").click(); + h.run_steps(4); + assert_eq!(alert(&h), None, "{typed}: OK closes the alert"); + assert!(h.state().ui.brush_picker.is_some(), "{typed}: the picker stays open after OK"); + } +} + +#[test] +fn size_in_range_cuts_fractions_without_an_alert() { + let mut h = harness(); + type_into(&mut h, "Size", "2.5"); + assert_eq!(size(&h), 2.0); + assert_eq!(alert(&h), None); + type_into(&mut h, "Size", "abc"); + assert_eq!(size(&h), 2.0, "not a number: the value stays"); + assert_eq!(alert(&h), None); +} + +#[test] +fn hardness_past_the_range_takes_100_and_alerts() { + let mut h = harness(); + type_into(&mut h, "Hardness", "150"); + assert_eq!(h.state().session.tools.brush.hardness, 1.0); + assert_eq!(alert(&h).as_deref(), Some(HARDNESS_RANGE_ALERT)); + h.get_by_label("OK").click(); + h.run_steps(4); + assert!(h.state().ui.brush_picker.is_some()); + type_into(&mut h, "Hardness", "33.7"); + assert_eq!(h.state().session.tools.brush.hardness, 0.33, "a whole percent"); + assert_eq!(alert(&h), None); +} diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs index f19ec41da9..1853c7fab3 100644 --- a/crates/ui-egui/src/lib.rs +++ b/crates/ui-egui/src/lib.rs @@ -997,6 +997,8 @@ mod pen_path_ownership_tests; #[cfg(test)] mod artboard_options_bar_tests; #[cfg(test)] +mod brush_picker_range_alert_tests; +#[cfg(test)] mod doc_tab_menu_tests; #[cfg(test)] mod layers_empty_area_menu_tests; diff --git a/crates/ui-egui/src/tools/brush_picker.rs b/crates/ui-egui/src/tools/brush_picker.rs index 3e59a90444..01e0f2404c 100644 --- a/crates/ui-egui/src/tools/brush_picker.rs +++ b/crates/ui-egui/src/tools/brush_picker.rs @@ -65,8 +65,15 @@ pub enum Pick { NewPreset, /// Import brushes (.abr) with the file dialog. Import, + /// A value typed out of range was replaced by the closest one: say so in an alert with OK, + /// as Photoshop does (#11817). The English message, translated when shown. + RangeAlert(&'static str), } +/// The alerts for Size and Hardness typed out of range (#11817). +pub const SIZE_RANGE_ALERT: &str = "An integer between 1 pixel and 5000 Pixels is required. Closest value inserted."; +pub const HARDNESS_RANGE_ALERT: &str = "An integer between 0% and 100% is required. Closest value inserted."; + impl Pick { /// Does this pick dismiss the picker? A double-click on a preset does (Photoshop), and so does /// anything that opens another panel or dialog. @@ -204,6 +211,17 @@ pub fn apply(app: &mut PhotocraftApp, ctx: &egui::Context, picks: Vec) { Pick::Import => { let _ = crate::preset_files_ui::import_brushes(app); } + Pick::RangeAlert(message) => { + let message = tl!(message).to_owned(); + let shown = app + .ui + .dialogs + .iter() + .any(|d| d.kind == crate::state::DialogKind::Error && d.fields.get("message").and_then(|m| m.as_str()) == Some(&message)); + if !shown { + app.ui.open_dialog(crate::state::DialogKind::Error, json!({ "message": message }).as_object().cloned().unwrap_or_default()); + } + } } } } @@ -231,6 +249,24 @@ pub fn settings_toggle(app: &mut PhotocraftApp, ui: &mut egui::Ui) { } } +/// A picker field of whole numbers in `lo..=hi` (#11817): a typed fraction is cut off (2.5 → 2), +/// text that is no number leaves the value, and a value past the range becomes the closest one, +/// with `alert` once the field is left. +fn integer_field(ui: &mut egui::Ui, value: &mut f32, (lo, hi): (f32, f32), suffix: &str, name: &str, alert: &'static str, picks: &mut Vec) -> bool { + // The field's own range is wide, so the typed value reaches here unclamped. + let mut typed = *value; + let r = widgets::value_field(ui, &mut typed, -1.0e9..=1.0e9, suffix, 72.0).accessible_name(tl!(name)); + let out_id = r.id.with("out-of-range"); + if r.changed() && typed.is_finite() { + *value = typed.trunc().clamp(lo, hi); + ui.ctx().data_mut(|d| d.insert_temp(out_id, typed < lo || typed > hi)); + } + if r.lost_focus() && ui.ctx().data_mut(|d| d.remove_temp::(out_id)).unwrap_or(false) { + picks.push(Pick::RangeAlert(alert)); + } + r.changed() && typed.is_finite() +} + /// An icon button's accessible name (icon buttons have only a tooltip). pub(crate) fn named(resp: egui::Response, label: &str) -> egui::Response { resp.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Button, true, tl!(label))); @@ -269,10 +305,7 @@ pub fn body( ui.horizontal(|ui| { ui.label(RichText::new(tl!("Size")).color(t.text_dim)); ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| { - let mut size = b.size; - if widgets::value_field(ui, &mut size, 1.0..=MAX_BRUSH_SIZE, "px", 72.0).accessible_name(tl!("Size")).changed() { - b.size = size.round().clamp(1.0, MAX_BRUSH_SIZE); - } + integer_field(ui, &mut b.size, (1.0, MAX_BRUSH_SIZE), "px", "Size", SIZE_RANGE_ALERT, &mut picks); }); }); let mut lv = b.size.max(1.0).ln(); @@ -282,10 +315,19 @@ pub fn body( } dismiss_popup(&size_slider); if b.tip == TipShape::Round { + // Like Size: a caption and a whole-number field, then the slider. let mut hard = b.hardness * 100.0; - let hardness = widgets::slider_row(ui, "Hardness", &mut hard, 0.0..=100.0, "%", None); - if hardness.changed() { - b.hardness = (hard / 100.0).clamp(0.0, 1.0); + let mut typed = false; + ui.horizontal(|ui| { + ui.label(RichText::new(tl!("Hardness")).color(t.text_dim)); + ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| { + typed = integer_field(ui, &mut hard, (0.0, 100.0), "%", "Hardness", HARDNESS_RANGE_ALERT, &mut picks); + }); + }); + let hardness = widgets::slider(ui, &mut hard, 0.0..=100.0, None); + hardness.widget_info(|| egui::WidgetInfo::slider(true, f64::from(hard), tl!("Hardness"))); + if typed || hardness.changed() { + b.hardness = (hard.round() / 100.0).clamp(0.0, 1.0); } dismiss_popup(&hardness); } From aac79a649920bd7f9c3e290e16842e35931e2b5b Mon Sep 17 00:00:00 2001 From: Trevor Brown Date: Sat, 14 Nov 2026 01:53:39 -0500 Subject: [PATCH 02/27] Check Spelling: Enter and Escape close the dialog like Done (#14179) spelling_window now consumes Enter and Escape before its widgets and the canvas see them and runs Done (close_spelling), keeping every change made so far. Enter also runs Done while the focus is in Change To (it does not run Change); Enter on a focused button keeps that button's action. Nothing is consumed while a modal dialog sits above. Co-Authored-By: Claude Sonnet 5.5 Model-Effort: Opus 5.5 drove; Opus 5.5 briefed; Sonnet 5.5 wrote at medium --- crates/ui-egui/src/panels.rs | 3 + crates/ui-egui/src/panels/type_panels_ui.rs | 11 ++ .../src/panels/type_spell_keys_tests.rs | 109 ++++++++++++++++++ 3 files changed, 123 insertions(+) create mode 100644 crates/ui-egui/src/panels/type_spell_keys_tests.rs diff --git a/crates/ui-egui/src/panels.rs b/crates/ui-egui/src/panels.rs index b8eb48bd4f..657e1df2c7 100644 --- a/crates/ui-egui/src/panels.rs +++ b/crates/ui-egui/src/panels.rs @@ -1308,6 +1308,9 @@ mod tool_flyout_drag_tests { #[cfg(test)] mod type_flyout_tests; +#[cfg(test)] +mod type_spell_keys_tests; + #[cfg(test)] mod toolbar_hidden_tests { use super::*; diff --git a/crates/ui-egui/src/panels/type_panels_ui.rs b/crates/ui-egui/src/panels/type_panels_ui.rs index 607e4f6c64..decd873ac8 100644 --- a/crates/ui-egui/src/panels/type_panels_ui.rs +++ b/crates/ui-egui/src/panels/type_panels_ui.rs @@ -835,6 +835,17 @@ fn spelling_window(app: &mut PhotocraftApp, ctx: &egui::Context) { let mut act: Option<&str> = None; let mut change_to = d.change_to.clone(); let mut all_layers = d.all_layers; + // Done is the default button (#14179): Enter (also in Change To, where it must not Change) and + // Escape run it. Consumed before the widgets and the canvas see them, and only while no modal + // dialog sits above this one; Enter on a focused button keeps that button's own action. + if ctx.memory(|m| m.top_modal_layer().is_none()) { + let enter_free = ctx.memory(|m| m.focused().is_none()) || ctx.egui_wants_keyboard_input(); + let none = egui::Modifiers::NONE; + let (esc, enter) = ctx.input_mut(|i| (i.consume_key(none, egui::Key::Escape), enter_free && i.consume_key(none, egui::Key::Enter))); + if esc || enter { + act = Some("done"); + } + } egui::Window::new(tl!("Check Spelling")) .id(egui::Id::unique("check-spelling")) .collapsible(false) diff --git a/crates/ui-egui/src/panels/type_spell_keys_tests.rs b/crates/ui-egui/src/panels/type_spell_keys_tests.rs new file mode 100644 index 0000000000..6d18e8954d --- /dev/null +++ b/crates/ui-egui/src/panels/type_spell_keys_tests.rs @@ -0,0 +1,109 @@ +//! #14179: Enter and Escape close the Check Spelling dialog like Done, keeping the changes made so +//! far; neither key reaches the canvas or the tool shortcuts while the dialog is open. + +use super::type_panels_ui::{menu, windows}; +use crate::PhotocraftApp; +use egui::vec2; +use egui_kittest::kittest::Queryable; +use serde_json::json; +use std::cell::Cell; +use std::rc::Rc; + +fn app_with_text(text: &str) -> PhotocraftApp { + let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), crate::Services::default()); + app.run("file.new", json!({"width": 300, "height": 120, "background": "white"})).unwrap(); + app.run("type.create", json!({"x": 10, "y": 60, "text": text})).unwrap(); + app.sync_views(); + app +} + +fn layer_text(app: &PhotocraftApp) -> String { + let s = app.session.active().unwrap(); + let id = s.active_layer.unwrap(); + let photocraft_doc::LayerContent::Text(t) = &s.doc.layer(id).unwrap().content else { panic!("not text") }; + t.text.clone() +} + +/// Opens the dialog on `text` and builds a harness drawing it. `seen` records whether an Enter or +/// Escape key press was still visible to the rest of the frame (the canvas, the shortcuts). +fn harness(text: &str, seen: Rc>) -> egui_kittest::Harness<'static, PhotocraftApp> { + let mut app = app_with_text(text); + menu(&mut app, "edit.checkSpelling", &json!({})).unwrap().unwrap(); + // The fonts are set up after the harness's first frame: the window appears after it. + let spell = app.ui.type_panels.spell.take(); + let mut h = egui_kittest::Harness::builder().with_size(vec2(1000.0, 700.0)).build_ui_state( + move |ui, app| { + windows(app, ui.ctx()); + let keys = ui.ctx().input(|i| (i.key_pressed(egui::Key::Enter), i.key_pressed(egui::Key::Escape))); + if keys.0 || keys.1 { + let old = seen.get(); + seen.set((old.0 || keys.0, old.1 || keys.1)); + } + }, + app, + ); + PhotocraftApp::setup_context(&h.ctx, crate::theme::ThemeKind::ALL[0]); + h.state_mut().ui.type_panels.spell = spell; + h.run_steps(3); + h +} + +fn change_first_word(app: &mut PhotocraftApp) { + let item = app.ui.type_panels.spell.as_ref().unwrap().items[0].clone(); + let change = json!({"action": "change", "layer": item["layer"], "start": item["start"], "end": item["end"], "word": "Teh", "replace": "The"}); + crate::actions::spelling_change(app, change).unwrap(); +} + +#[test] +fn escape_closes_the_dialog_and_keeps_the_changes_made() { + let seen = Rc::new(Cell::new((false, false))); + let mut h = harness("Teh cat. Wrold", seen.clone()); + assert!(h.state().ui.type_panels.spell.is_some()); + // Change the first word the way the Change button does, refresh the list, then press Escape. + change_first_word(h.state_mut()); + h.state_mut().ui.type_panels.spell.as_mut().unwrap().index = 0; + h.run_steps(2); + assert!(layer_text(h.state()).starts_with("The cat"), "the change was made: {}", layer_text(h.state())); + h.key_press(egui::Key::Escape); + h.run_steps(3); + assert!(h.state().ui.type_panels.spell.is_none(), "Escape closed Check Spelling"); + assert!(layer_text(h.state()).starts_with("The cat"), "and the change stays: {}", layer_text(h.state())); + assert!(!seen.get().1, "Escape did not reach the rest of the frame"); +} + +#[test] +fn enter_in_change_to_runs_done_and_does_not_change_the_word() { + let seen = Rc::new(Cell::new((false, false))); + let mut h = harness("Teh cat", seen.clone()); + let before = layer_text(h.state()); + h.get_by_role_and_label(egui::accesskit::Role::TextInput, "Change To:").click(); + h.run_steps(2); + h.key_press(egui::Key::Enter); + h.run_steps(3); + assert!(h.state().ui.type_panels.spell.is_none(), "Enter closed Check Spelling"); + assert_eq!(layer_text(h.state()), before, "the current word was not changed"); + assert!(!seen.get().0, "Enter did not reach the canvas or the tool shortcuts"); +} + +#[test] +fn enter_with_the_focus_elsewhere_runs_done_too() { + let seen = Rc::new(Cell::new((false, false))); + let mut h = harness("Teh cat", seen.clone()); + let before = layer_text(h.state()); + h.key_press(egui::Key::Enter); + h.run_steps(3); + assert!(h.state().ui.type_panels.spell.is_none()); + assert_eq!(layer_text(h.state()), before); + assert!(!seen.get().0); +} + +#[test] +fn the_keys_do_nothing_when_the_dialog_is_closed() { + let seen = Rc::new(Cell::new((false, false))); + let mut h = harness("Teh cat", seen.clone()); + h.state_mut().ui.type_panels.spell = None; + h.key_press(egui::Key::Escape); + h.key_press(egui::Key::Enter); + h.run_steps(2); + assert!(seen.get().0 && seen.get().1, "with no dialog the keys reach the frame as before"); +} From f59a5526e2594dd4bfb47130853cf800bf81f5a2 Mon Sep 17 00:00:00 2001 From: Trevor Brown Date: Sun, 15 Nov 2026 10:45:10 -0500 Subject: [PATCH 03/27] Check Spelling: Enter on a focused button keeps its action, and keys in another window leave the dialog open Two review items on #14328. Enter ran Done even with a button focused, because egui_wants_keyboard_input is true whenever anything is focused, so a focused Change button never got its Enter. Escape and Enter also ran Done whatever held the focus, so a key typed into another open window (Styles, Glyphs) closed Check Spelling. Done now runs on Enter or Escape only when nothing is focused or the focus is inside the Check Spelling window (compared by layer), and Enter additionally needs that focus to be a text edit. A text edit gives up its focus on Escape or Enter before the dialog runs, so with either key down the focus of the previous frame is used. Co-Authored-By: Claude Sonnet 5.5 Model-Effort: Opus 5.5 drove; Opus 5.5 briefed; Sonnet 5.5 wrote at medium --- crates/ui-egui/src/panels/type_panels_ui.rs | 24 +++++++-- .../src/panels/type_spell_keys_tests.rs | 51 +++++++++++++++++++ 2 files changed, 71 insertions(+), 4 deletions(-) diff --git a/crates/ui-egui/src/panels/type_panels_ui.rs b/crates/ui-egui/src/panels/type_panels_ui.rs index decd873ac8..b89f126407 100644 --- a/crates/ui-egui/src/panels/type_panels_ui.rs +++ b/crates/ui-egui/src/panels/type_panels_ui.rs @@ -837,17 +837,33 @@ fn spelling_window(app: &mut PhotocraftApp, ctx: &egui::Context) { let mut all_layers = d.all_layers; // Done is the default button (#14179): Enter (also in Change To, where it must not Change) and // Escape run it. Consumed before the widgets and the canvas see them, and only while no modal - // dialog sits above this one; Enter on a focused button keeps that button's own action. + // dialog sits above this one. They only count when nothing is focused or the focus is inside this + // window (a key typed into another open window, such as Styles, is not ours), and Enter also + // needs that focus to be a text edit, so a focused button keeps its own Enter (its click). + // A text edit gives up its focus on Escape or Enter, possibly before this runs, so with either key + // down the focus of the frame before is used when nothing is focused now. + let window_id = egui::Id::unique("check-spelling"); + let last_focus_id = egui::Id::unique("check-spelling-last-focus"); + let focused = ctx.memory(|m| m.focused()); + let key_down = ctx.input(|i| i.key_pressed(egui::Key::Escape) || i.key_pressed(egui::Key::Enter)); + let last_focus = ctx.data(|d| d.get_temp::>(last_focus_id)).flatten(); + if !key_down { + ctx.data_mut(|d| d.insert_temp(last_focus_id, focused)); + } if ctx.memory(|m| m.top_modal_layer().is_none()) { - let enter_free = ctx.memory(|m| m.focused().is_none()) || ctx.egui_wants_keyboard_input(); + let window_layer = egui::LayerId::new(egui::Order::Middle, window_id); + let in_window = |f: egui::Id| ctx.read_response(f).is_some_and(|r| r.layer_id == window_layer); + let key_focus = focused.or(if key_down { last_focus } else { None }); + let inside = key_focus.is_none_or(in_window); + let enter_free = key_focus.is_none_or(|f| in_window(f) && egui::TextEdit::load_state(ctx, f).is_some()); let none = egui::Modifiers::NONE; - let (esc, enter) = ctx.input_mut(|i| (i.consume_key(none, egui::Key::Escape), enter_free && i.consume_key(none, egui::Key::Enter))); + let (esc, enter) = ctx.input_mut(|i| (inside && i.consume_key(none, egui::Key::Escape), enter_free && i.consume_key(none, egui::Key::Enter))); if esc || enter { act = Some("done"); } } egui::Window::new(tl!("Check Spelling")) - .id(egui::Id::unique("check-spelling")) + .id(window_id) .collapsible(false) .resizable(false) .frame(float_frame(&t).inner_margin(egui::Margin::same(14))) diff --git a/crates/ui-egui/src/panels/type_spell_keys_tests.rs b/crates/ui-egui/src/panels/type_spell_keys_tests.rs index 6d18e8954d..2b5fec429e 100644 --- a/crates/ui-egui/src/panels/type_spell_keys_tests.rs +++ b/crates/ui-egui/src/panels/type_spell_keys_tests.rs @@ -27,12 +27,18 @@ fn layer_text(app: &PhotocraftApp) -> String { /// Opens the dialog on `text` and builds a harness drawing it. `seen` records whether an Enter or /// Escape key press was still visible to the rest of the frame (the canvas, the shortcuts). fn harness(text: &str, seen: Rc>) -> egui_kittest::Harness<'static, PhotocraftApp> { + harness_with(text, seen, |_| {}) +} + +/// `harness` that also runs `extra` every frame, for drawing another window beside the dialog. +fn harness_with(text: &str, seen: Rc>, mut extra: impl FnMut(&egui::Context) + 'static) -> egui_kittest::Harness<'static, PhotocraftApp> { let mut app = app_with_text(text); menu(&mut app, "edit.checkSpelling", &json!({})).unwrap().unwrap(); // The fonts are set up after the harness's first frame: the window appears after it. let spell = app.ui.type_panels.spell.take(); let mut h = egui_kittest::Harness::builder().with_size(vec2(1000.0, 700.0)).build_ui_state( move |ui, app| { + extra(ui.ctx()); windows(app, ui.ctx()); let keys = ui.ctx().input(|i| (i.key_pressed(egui::Key::Enter), i.key_pressed(egui::Key::Escape))); if keys.0 || keys.1 { @@ -107,3 +113,48 @@ fn the_keys_do_nothing_when_the_dialog_is_closed() { h.run_steps(2); assert!(seen.get().0 && seen.get().1, "with no dialog the keys reach the frame as before"); } + +#[test] +fn enter_on_the_focused_change_button_runs_change() { + let seen = Rc::new(Cell::new((false, false))); + let mut h = harness("Teh cat. Wrold", seen); + h.state_mut().ui.type_panels.spell.as_mut().unwrap().change_to = "The".into(); + h.run_steps(2); + h.get_by_role_and_label(egui::accesskit::Role::Button, "Change").focus(); + h.run_steps(2); + h.key_press(egui::Key::Enter); + h.run_steps(3); + assert!(layer_text(h.state()).starts_with("The cat"), "Enter on Change changed the word: {}", layer_text(h.state())); + assert!(h.state().ui.type_panels.spell.is_some(), "and the dialog stays open"); +} + +fn other_window() -> impl FnMut(&egui::Context) { + let mut buf = String::new(); + move |ctx| { + egui::Window::new("Other").show(ctx, |ui| { + ui.add(egui::TextEdit::singleline(&mut buf)).accessible_name("Other field"); + }); + } +} + +#[test] +fn escape_in_another_window_leaves_check_spelling_open() { + let seen = Rc::new(Cell::new((false, false))); + let mut h = harness_with("Teh cat. Wrold", seen, other_window()); + h.get_by_role_and_label(egui::accesskit::Role::TextInput, "Other field").focus(); + h.run_steps(2); + h.key_press(egui::Key::Escape); + h.run_steps(3); + assert!(h.state().ui.type_panels.spell.is_some(), "Escape in the other window left Check Spelling open"); +} + +#[test] +fn enter_in_another_window_leaves_check_spelling_open() { + let seen = Rc::new(Cell::new((false, false))); + let mut h = harness_with("Teh cat. Wrold", seen, other_window()); + h.get_by_role_and_label(egui::accesskit::Role::TextInput, "Other field").focus(); + h.run_steps(2); + h.key_press(egui::Key::Enter); + h.run_steps(3); + assert!(h.state().ui.type_panels.spell.is_some(), "Enter in the other window left Check Spelling open"); +} From 7f2a24a88edbfd6d36c384e3964f72dde5373516 Mon Sep 17 00:00:00 2001 From: Trevor Brown Date: Sun, 15 Nov 2026 11:47:25 -0500 Subject: [PATCH 04/27] Check Spelling: the focus is read after every window, and Enter on a focused button stays in the dialog Two more review items on #14328. The focus kept for Escape and Enter was recorded inside spelling_window, before the windows drawn after it, so a later window (such as the analysis window's text field) could take focus that frame and leave a stale record. It is now recorded by a SpellingFocus egui plugin in on_end_pass, after every window has drawn, and spelling_window only reads it. Enter on a focused button keeps the button's own action, but it stayed visible to the canvas and the shortcuts. It is now consumed after the dialog has drawn when the focus is inside the dialog and no modal is up. Co-Authored-By: Claude Sonnet 5.5 Model-Effort: Opus 5.5 drove; Opus 5.5 briefed; Sonnet 5.5 wrote at medium --- crates/ui-egui/src/app/prefs.rs | 1 + crates/ui-egui/src/panels/type_panels_ui.rs | 42 +++++++++++++++---- .../src/panels/type_spell_keys_tests.rs | 37 ++++++++++++++-- 3 files changed, 69 insertions(+), 11 deletions(-) diff --git a/crates/ui-egui/src/app/prefs.rs b/crates/ui-egui/src/app/prefs.rs index 8f70519889..55a977005a 100644 --- a/crates/ui-egui/src/app/prefs.rs +++ b/crates/ui-egui/src/app/prefs.rs @@ -57,6 +57,7 @@ impl PhotocraftApp { // The wheel goes to a focused value field before the canvas or a panel sees it (#5473), in // every window: a floated panel's window has input of its own (#11353). ctx.add_plugin(field_wheel::FieldWheel); + ctx.add_plugin(crate::type_panels_ui::SpellingFocus); theme::install_fonts(ctx); egui_extras::install_image_loaders(ctx); theme::apply(ctx, kind); diff --git a/crates/ui-egui/src/panels/type_panels_ui.rs b/crates/ui-egui/src/panels/type_panels_ui.rs index b89f126407..5bf48f94ec 100644 --- a/crates/ui-egui/src/panels/type_panels_ui.rs +++ b/crates/ui-egui/src/panels/type_panels_ui.rs @@ -827,6 +827,29 @@ fn spelling_change_all_params(item: &Value, word: &str, replace: &str, all_layer params } +fn last_focus_id() -> egui::Id { + egui::Id::unique("check-spelling-last-focus") +} + +/// Records the focus at the end of every pass, after every window has drawn, for Check Spelling to +/// read the next frame. While Escape or Enter is down the record is kept: the key itself makes a +/// text edit drop its focus, and the record must stay the focus the key was typed into. +pub(crate) struct SpellingFocus; + +impl egui::Plugin for SpellingFocus { + fn debug_name(&self) -> &'static str { + "SpellingFocus" + } + + fn on_end_pass(&mut self, ui: &mut egui::Ui) { + let ctx = ui.ctx(); + if !ctx.input(|i| i.key_pressed(egui::Key::Escape) || i.key_pressed(egui::Key::Enter)) { + let focused = ctx.memory(|m| m.focused()); + ctx.data_mut(|d| d.insert_temp(last_focus_id(), focused)); + } + } +} + /// Render spelling navigation and corrections using the retained opening receiver and paused-action continuation. fn spelling_window(app: &mut PhotocraftApp, ctx: &egui::Context) { let t = Tokens::get(ctx); @@ -841,20 +864,20 @@ fn spelling_window(app: &mut PhotocraftApp, ctx: &egui::Context) { // window (a key typed into another open window, such as Styles, is not ours), and Enter also // needs that focus to be a text edit, so a focused button keeps its own Enter (its click). // A text edit gives up its focus on Escape or Enter, possibly before this runs, so with either key - // down the focus of the frame before is used when nothing is focused now. + // down the focus at the end of the frame before is used when nothing is focused now (recorded by + // `SpellingFocus`, after every window has drawn). let window_id = egui::Id::unique("check-spelling"); - let last_focus_id = egui::Id::unique("check-spelling-last-focus"); let focused = ctx.memory(|m| m.focused()); let key_down = ctx.input(|i| i.key_pressed(egui::Key::Escape) || i.key_pressed(egui::Key::Enter)); - let last_focus = ctx.data(|d| d.get_temp::>(last_focus_id)).flatten(); - if !key_down { - ctx.data_mut(|d| d.insert_temp(last_focus_id, focused)); - } - if ctx.memory(|m| m.top_modal_layer().is_none()) { + let last_focus = ctx.data(|d| d.get_temp::>(last_focus_id())).flatten(); + let no_modal = ctx.memory(|m| m.top_modal_layer().is_none()); + let mut dialog_has_focus = false; + if no_modal { let window_layer = egui::LayerId::new(egui::Order::Middle, window_id); let in_window = |f: egui::Id| ctx.read_response(f).is_some_and(|r| r.layer_id == window_layer); let key_focus = focused.or(if key_down { last_focus } else { None }); let inside = key_focus.is_none_or(in_window); + dialog_has_focus = inside; let enter_free = key_focus.is_none_or(|f| in_window(f) && egui::TextEdit::load_state(ctx, f).is_some()); let none = egui::Modifiers::NONE; let (esc, enter) = ctx.input_mut(|i| (inside && i.consume_key(none, egui::Key::Escape), enter_free && i.consume_key(none, egui::Key::Enter))); @@ -948,6 +971,11 @@ fn spelling_window(app: &mut PhotocraftApp, ctx: &egui::Context) { }); }); }); + // Enter on a focused button was left to the button (its click is made at the start of the pass): + // it stays in the dialog, so the canvas and the shortcuts after it do not see it. + if no_modal && dialog_has_focus { + ctx.input_mut(|i| i.consume_key(egui::Modifiers::NONE, egui::Key::Enter)); + } if let Some(s) = app.ui.type_panels.spell.as_mut() { s.change_to = change_to.clone(); s.all_layers = all_layers; diff --git a/crates/ui-egui/src/panels/type_spell_keys_tests.rs b/crates/ui-egui/src/panels/type_spell_keys_tests.rs index 2b5fec429e..be6681e5a3 100644 --- a/crates/ui-egui/src/panels/type_spell_keys_tests.rs +++ b/crates/ui-egui/src/panels/type_spell_keys_tests.rs @@ -30,16 +30,31 @@ fn harness(text: &str, seen: Rc>) -> egui_kittest::Harness<'s harness_with(text, seen, |_| {}) } -/// `harness` that also runs `extra` every frame, for drawing another window beside the dialog. -fn harness_with(text: &str, seen: Rc>, mut extra: impl FnMut(&egui::Context) + 'static) -> egui_kittest::Harness<'static, PhotocraftApp> { +/// `harness` that also runs `extra` every frame before the dialog, for drawing another window. +fn harness_with(text: &str, seen: Rc>, extra: impl FnMut(&egui::Context) + 'static) -> egui_kittest::Harness<'static, PhotocraftApp> { + harness_ordered(text, seen, extra, false) +} + +/// `harness_with`, `after` choosing whether `extra` draws after the dialog instead of before it. +fn harness_ordered( + text: &str, + seen: Rc>, + mut extra: impl FnMut(&egui::Context) + 'static, + after: bool, +) -> egui_kittest::Harness<'static, PhotocraftApp> { let mut app = app_with_text(text); menu(&mut app, "edit.checkSpelling", &json!({})).unwrap().unwrap(); // The fonts are set up after the harness's first frame: the window appears after it. let spell = app.ui.type_panels.spell.take(); let mut h = egui_kittest::Harness::builder().with_size(vec2(1000.0, 700.0)).build_ui_state( move |ui, app| { - extra(ui.ctx()); + if !after { + extra(ui.ctx()); + } windows(app, ui.ctx()); + if after { + extra(ui.ctx()); + } let keys = ui.ctx().input(|i| (i.key_pressed(egui::Key::Enter), i.key_pressed(egui::Key::Escape))); if keys.0 || keys.1 { let old = seen.get(); @@ -117,7 +132,7 @@ fn the_keys_do_nothing_when_the_dialog_is_closed() { #[test] fn enter_on_the_focused_change_button_runs_change() { let seen = Rc::new(Cell::new((false, false))); - let mut h = harness("Teh cat. Wrold", seen); + let mut h = harness("Teh cat. Wrold", seen.clone()); h.state_mut().ui.type_panels.spell.as_mut().unwrap().change_to = "The".into(); h.run_steps(2); h.get_by_role_and_label(egui::accesskit::Role::Button, "Change").focus(); @@ -126,6 +141,7 @@ fn enter_on_the_focused_change_button_runs_change() { h.run_steps(3); assert!(layer_text(h.state()).starts_with("The cat"), "Enter on Change changed the word: {}", layer_text(h.state())); assert!(h.state().ui.type_panels.spell.is_some(), "and the dialog stays open"); + assert!(!seen.get().0, "Enter did not reach the canvas or the tool shortcuts either"); } fn other_window() -> impl FnMut(&egui::Context) { @@ -158,3 +174,16 @@ fn enter_in_another_window_leaves_check_spelling_open() { h.run_steps(3); assert!(h.state().ui.type_panels.spell.is_some(), "Enter in the other window left Check Spelling open"); } + +#[test] +fn escape_after_a_window_drawn_later_took_the_focus_leaves_check_spelling_open() { + let seen = Rc::new(Cell::new((false, false))); + let mut h = harness_ordered("Teh cat. Wrold", seen, other_window(), true); + // The click gives the later window's field the focus in a frame where the dialog has already + // drawn; the very next frame carries Escape. + h.get_by_role_and_label(egui::accesskit::Role::TextInput, "Other field").click(); + h.run_steps(1); + h.key_press(egui::Key::Escape); + h.run_steps(3); + assert!(h.state().ui.type_panels.spell.is_some(), "Escape in the later window left Check Spelling open"); +} From a6910e5fd101335fb65ca1a4bcf5926300fcec63 Mon Sep 17 00:00:00 2001 From: Trevor Brown Date: Sun, 15 Nov 2026 12:40:21 -0500 Subject: [PATCH 05/27] Check Spelling: Escape belongs to the dialog over the view keys, and the focus test fails without the end-of-pass record Two more review items on #14328. handle_escape_and_view_keys runs before the dialog and its esc_taken list did not include Check Spelling, so with nothing focused Escape reset a rotated view, left full screen or deselected, and the dialog never ran Done. Check Spelling now owns Escape there. Only the Escape branches are gated by esc_taken; tool letters, Page/Home/End and the opacity keys are unchanged. The test for the focus record now fails without it: another window's field takes the focus by request on one frame after the dialog has drawn, and Escape comes on the next frame. A second test runs the real shortcut handling before the windows, as frame.rs does, with a rotated view and a selection. Co-Authored-By: Claude Sonnet 5.5 Model-Effort: Opus 5.5 drove; Opus 5.5 briefed; Sonnet 5.5 wrote at medium --- crates/ui-egui/src/input/shortcuts.rs | 3 +- .../src/panels/type_spell_keys_tests.rs | 48 +++++++++++++++---- 2 files changed, 41 insertions(+), 10 deletions(-) diff --git a/crates/ui-egui/src/input/shortcuts.rs b/crates/ui-egui/src/input/shortcuts.rs index f82cbf11ce..5ad030002b 100644 --- a/crates/ui-egui/src/input/shortcuts.rs +++ b/crates/ui-egui/src/input/shortcuts.rs @@ -912,13 +912,14 @@ fn handle_escape_and_view_keys(app: &mut PhotocraftApp, ctx: &egui::Context) { // Esc with no active operation leaves a full screen mode, else deselects (#2674), like ⌘D. // The key is never taken from a state that handles Esc itself: menus, dialogs, text fields // and inline type returned above, transform, pen, lasso and crop consumed it, and these own - // theirs later in the frame: the palette, the canvas and layer menus, the brush picker, + // theirs later in the frame: Check Spelling (Esc is its Done), the palette, the canvas and layer menus, the brush picker, // Rotate View, Adaptive Wide Angle, the Filter Gallery, the TIFF prompt, any open egui popup // and the toolbar tool and "…" flyouts. A canvas drag in progress (a marquee being drawn) keeps it too. let esc_taken = app.drag.is_some() // A Direct Selection drag (a Cmd-drag on an anchor) never reaches `app.drag`: Esc must not // leave full screen or deselect pixels while its release is still to come (#13072). || (app.ui.tool == Tool::DeleteAnchorPoint && app.ui.direct_selection.drag.is_some()) + || app.ui.type_panels.spell.is_some() || app.ui.palette_open || app.ui.canvas_tool_menu.is_some() || app.ui.layer_menu.is_some() diff --git a/crates/ui-egui/src/panels/type_spell_keys_tests.rs b/crates/ui-egui/src/panels/type_spell_keys_tests.rs index be6681e5a3..363717b750 100644 --- a/crates/ui-egui/src/panels/type_spell_keys_tests.rs +++ b/crates/ui-egui/src/panels/type_spell_keys_tests.rs @@ -32,15 +32,17 @@ fn harness(text: &str, seen: Rc>) -> egui_kittest::Harness<'s /// `harness` that also runs `extra` every frame before the dialog, for drawing another window. fn harness_with(text: &str, seen: Rc>, extra: impl FnMut(&egui::Context) + 'static) -> egui_kittest::Harness<'static, PhotocraftApp> { - harness_ordered(text, seen, extra, false) + harness_ordered(text, seen, extra, false, false) } -/// `harness_with`, `after` choosing whether `extra` draws after the dialog instead of before it. +/// `harness_with`, `after` choosing whether `extra` draws after the dialog instead of before it, and +/// `shortcuts` running the real per-frame key handling before the windows, in frame.rs's order. fn harness_ordered( text: &str, seen: Rc>, mut extra: impl FnMut(&egui::Context) + 'static, after: bool, + shortcuts: bool, ) -> egui_kittest::Harness<'static, PhotocraftApp> { let mut app = app_with_text(text); menu(&mut app, "edit.checkSpelling", &json!({})).unwrap().unwrap(); @@ -48,6 +50,9 @@ fn harness_ordered( let spell = app.ui.type_panels.spell.take(); let mut h = egui_kittest::Harness::builder().with_size(vec2(1000.0, 700.0)).build_ui_state( move |ui, app| { + if shortcuts { + crate::shortcuts::handle(app, ui.ctx()); + } if !after { extra(ui.ctx()); } @@ -145,10 +150,18 @@ fn enter_on_the_focused_change_button_runs_change() { } fn other_window() -> impl FnMut(&egui::Context) { + other_window_focusing(Rc::new(Cell::new(false))) +} + +/// The other window's field takes the focus (a request, not a click) on the one frame `take_focus` is set. +fn other_window_focusing(take_focus: Rc>) -> impl FnMut(&egui::Context) { let mut buf = String::new(); move |ctx| { egui::Window::new("Other").show(ctx, |ui| { - ui.add(egui::TextEdit::singleline(&mut buf)).accessible_name("Other field"); + let field = ui.add(egui::TextEdit::singleline(&mut buf)).accessible_name("Other field"); + if take_focus.replace(false) { + field.request_focus(); + } }); } } @@ -178,12 +191,29 @@ fn enter_in_another_window_leaves_check_spelling_open() { #[test] fn escape_after_a_window_drawn_later_took_the_focus_leaves_check_spelling_open() { let seen = Rc::new(Cell::new((false, false))); - let mut h = harness_ordered("Teh cat. Wrold", seen, other_window(), true); - // The click gives the later window's field the focus in a frame where the dialog has already - // drawn; the very next frame carries Escape. - h.get_by_role_and_label(egui::accesskit::Role::TextInput, "Other field").click(); - h.run_steps(1); + let take_focus = Rc::new(Cell::new(false)); + let mut h = harness_ordered("Teh cat. Wrold", seen, other_window_focusing(take_focus.clone()), true, false); + // The later window's field takes the focus on one frame, after the dialog has drawn; Escape is + // on the very next frame, where egui drops the focus before the dialog runs. + take_focus.set(true); + h.step(); h.key_press(egui::Key::Escape); - h.run_steps(3); + h.step(); + h.run_steps(2); assert!(h.state().ui.type_panels.spell.is_some(), "Escape in the later window left Check Spelling open"); } + +#[test] +fn escape_runs_done_before_the_view_keys_reset_a_rotated_view_or_deselect() { + let seen = Rc::new(Cell::new((false, false))); + let mut h = harness_ordered("Teh cat. Wrold", seen, |_| {}, false, true); + h.state_mut().run("select.all", json!({})).unwrap(); + let index = h.state().session.active_index().unwrap(); + h.state_mut().ui.views[index].rotation = 0.5; + h.run_steps(2); + h.key_press(egui::Key::Escape); + h.run_steps(3); + assert!(h.state().ui.type_panels.spell.is_none(), "Escape closed Check Spelling"); + assert_eq!(h.state().ui.views[index].rotation, 0.5, "the rotated view was not reset"); + assert!(h.state().session.active().unwrap().doc.selection.is_some(), "the selection stays"); +} From 0cc9afbe69b6d9e70b20e500e3fc0bef0f68939f Mon Sep 17 00:00:00 2001 From: Trevor Brown Date: Sun, 15 Nov 2026 17:13:18 -0500 Subject: [PATCH 06/27] Check Spelling: a plain Esc or Enter runs no shortcut under the open dialog (#14179) One gate in preflight_keys replaces chasing each Esc and Enter branch: while Check Spelling is open, a frame with a plain Esc or Enter runs no shortcut, so neither commits or cancels a pending crop, polygon, Pen path or shape beneath the dialog, as with Photoshop's modal dialog. The dialog, drawn later, still reads them for Done. Co-Authored-By: Claude Opus 5.5 Model-Effort: Opus 5.5 driver, no subagent --- crates/ui-egui/src/input/shortcuts.rs | 9 +++++ .../src/panels/type_spell_keys_tests.rs | 33 +++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/crates/ui-egui/src/input/shortcuts.rs b/crates/ui-egui/src/input/shortcuts.rs index 1f5bc3f302..c3627ef942 100644 --- a/crates/ui-egui/src/input/shortcuts.rs +++ b/crates/ui-egui/src/input/shortcuts.rs @@ -528,6 +528,15 @@ fn preflight_keys(app: &mut PhotocraftApp, ctx: &egui::Context) -> bool { if app.ui.stroke_editor.is_some() && !ctx.input(|i| i.modifiers.command || i.modifiers.ctrl) { return false; } + // Check Spelling owns a plain Esc and ↵ (Done, #14179), as Photoshop's modal dialog does: in a + // frame with either, no shortcut below runs, so neither commits or cancels a crop, a polygon, a + // Pen path or a shape under the dialog, nor resets the view. The dialog, drawn later, reads them. + if app.ui.type_panels.spell.is_some() { + let plain = |e: &egui::Event| matches!(e, egui::Event::Key { key: Key::Escape | Key::Enter, pressed: true, modifiers, .. } if modifiers.is_none()); + if ctx.input(|i| i.events.iter().any(plain)) { + return false; + } + } // So does the right-click menu of text being edited: Esc closes only it, and keys typed while // it is open don't reach the text beneath. The crop menu's likewise: Esc and ↵ don't cancel or // commit the crop under it (#6561). diff --git a/crates/ui-egui/src/panels/type_spell_keys_tests.rs b/crates/ui-egui/src/panels/type_spell_keys_tests.rs index 363717b750..84d096a0ff 100644 --- a/crates/ui-egui/src/panels/type_spell_keys_tests.rs +++ b/crates/ui-egui/src/panels/type_spell_keys_tests.rs @@ -217,3 +217,36 @@ fn escape_runs_done_before_the_view_keys_reset_a_rotated_view_or_deselect() { assert_eq!(h.state().ui.views[index].rotation, 0.5, "the rotated view was not reset"); assert!(h.state().session.active().unwrap().doc.selection.is_some(), "the selection stays"); } + +#[test] +fn enter_and_escape_run_done_and_leave_a_pending_crop_alone() { + for key in [egui::Key::Enter, egui::Key::Escape] { + let seen = Rc::new(Cell::new((false, false))); + let mut h = harness_ordered("Teh cat. Wrold", seen, |_| {}, false, true); + h.state_mut().ui.tool = crate::state::Tool::Crop; + h.state_mut().ui.crop_rect = Some([10.0, 10.0, 100.0, 60.0]); + h.state_mut().crop.default_frame = false; + h.run_steps(2); + h.key_press(key); + h.run_steps(3); + assert!(h.state().ui.type_panels.spell.is_none(), "{key:?} closed Check Spelling"); + assert_eq!(h.state().ui.crop_rect, Some([10.0, 10.0, 100.0, 60.0]), "{key:?} left the crop frame pending"); + assert_eq!(h.state().session.active().unwrap().doc.size.width, 300, "{key:?} did not crop"); + } +} + +#[test] +fn enter_and_escape_run_done_and_leave_a_pen_path_in_progress_alone() { + for key in [egui::Key::Enter, egui::Key::Escape] { + let seen = Rc::new(Cell::new((false, false))); + let mut h = harness_ordered("Teh cat. Wrold", seen, |_| {}, false, true); + h.state_mut().ui.tool = crate::state::Tool::Pen; + let owner = crate::vector_ui::capture_pen_owner(h.state()); + h.state_mut().ui.pen = Some(crate::vector_ui::PenPath { knots: vec![[[50.0, 50.0]; 3], [[150.0, 50.0]; 3]], owner, ..Default::default() }); + h.run_steps(2); + h.key_press(key); + h.run_steps(3); + assert!(h.state().ui.type_panels.spell.is_none(), "{key:?} closed Check Spelling"); + assert!(h.state().ui.pen.as_ref().is_some_and(|p| p.knots.len() == 2), "{key:?} left the Pen path in progress"); + } +} From 2a32a22624a2f24623e1289b3fae485debfd2fed Mon Sep 17 00:00:00 2001 From: David Mann Date: Sun, 29 Nov 2026 15:52:21 +0100 Subject: [PATCH 07/27] Brush Preset picker: a Size or Hardness typed out of range opens the range alert (#11817) The picker's head now reports a value typed past its range (storytold/craft-libs#4273); apply opens the shared range alert for it, as the options bar does, and the picker stays open under it. Co-Authored-By: Claude Opus 5.5 --- .../src/brush_picker_range_alert_tests.rs | 92 +++++++++++++++++++ crates/ui-egui/src/tools/brush_picker.rs | 20 ++-- 2 files changed, 106 insertions(+), 6 deletions(-) create mode 100644 crates/ui-egui/src/brush_picker_range_alert_tests.rs diff --git a/crates/ui-egui/src/brush_picker_range_alert_tests.rs b/crates/ui-egui/src/brush_picker_range_alert_tests.rs new file mode 100644 index 0000000000..7232f03ba4 --- /dev/null +++ b/crates/ui-egui/src/brush_picker_range_alert_tests.rs @@ -0,0 +1,92 @@ +//! #11817: a Size or Hardness typed past its range in the Brush Preset picker takes the closest value and opens the +//! range alert; the picker stays open under it and after OK. A value in range and a slider press open none. + +use crate::app::framework::BuildApp as _; +use egui::{Event, Modifiers, vec2}; +use egui_kittest::Harness; +use egui_kittest::kittest::{NodeT, Queryable}; +use serde_json::json; + +use crate::PhotocraftApp; +use crate::state::Tool; + +fn harness() -> Harness<'static, Box> { + let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), crate::Services::default()); + app.run("file.new", json!({"width": 400, "height": 300})).unwrap(); + app.run("tools.setBrush", json!({"brush": {"size": 20, "hardness": 0.5}})).unwrap(); + app.ui.tool = Tool::Brush; + app.sync_views(); + let mut h = Harness::builder().with_size(vec2(1200.0, 800.0)).with_step_dt(1.0 / 60.0).with_context(app.ctx().clone()).build_app( + |ui, app: &mut PhotocraftApp| { + if !ui.ctx().fonts(|f| f.families().contains(&egui::FontFamily::Name("medium".into()))) { + return; + } + // The canvas shows the picker itself (`canvas_tool_menu::run`). + egui::CentralPanel::default().show(ui, |ui| crate::canvas::testing::document_area(app, ui)); + }, + app, + ); + PhotocraftApp::setup_context(&h.ctx, crate::theme::AppTheme::pro()); + h.run_steps(4); + let c = h.state().last_canvas_rect.center(); + crate::brush_picker::open(h.state_mut(), [c.x, c.y]); + h.run_steps(3); + h +} + +/// Type `text` into the picker's `n`th spin field (0 Size, 1 Hardness), then Tab. +fn type_into(h: &mut Harness<'static, Box>, n: usize, text: &str) { + h.get_all_by_role(egui::accesskit::Role::SpinButton).nth(n).expect("the field").click(); + h.run_steps(1); + h.key_press_modifiers(Modifiers::COMMAND, egui::Key::A); + h.event(Event::Text(text.into())); + h.run_steps(1); + h.key_press(egui::Key::Tab); + h.run_steps(3); +} + +fn alerts(h: &Harness<'static, Box>) -> usize { + h.state().framework.dialogs.open_dialogs().len() +} + +fn size_and_hardness(h: &Harness<'static, Box>) -> (f32, f32) { + let b = &h.state().session.tools.brush; + (b.size, b.hardness) +} + +#[test] +fn size_and_hardness_typed_out_of_range_alert_and_the_picker_stays_open() { + for (n, typed, want) in [(0, "9999", (5000.0, 0.5)), (0, "0", (1.0, 0.5)), (1, "150", (20.0, 1.0))] { + let mut h = harness(); + type_into(&mut h, n, typed); + assert_eq!(size_and_hardness(&h), want, "{typed}: the closest value"); + assert_eq!(alerts(&h), 1, "{typed}: one range alert"); + assert!(h.state().ui.brush_picker.is_some(), "{typed}: the picker stays open under the alert"); + h.get_by_label("OK").click(); + h.run_steps(4); + assert_eq!(alerts(&h), 0, "{typed}: OK closes the alert"); + assert_eq!(size_and_hardness(&h), want, "{typed}: OK keeps the closest value"); + assert!(h.state().ui.brush_picker.is_some(), "{typed}: the picker stays open after OK"); + } +} + +#[test] +fn a_value_in_range_and_a_slider_press_open_no_alert() { + let mut h = harness(); + type_into(&mut h, 0, "40"); + assert_eq!(size_and_hardness(&h).0, 40.0); + let slider = h + .get_all_by_role(egui::accesskit::Role::Slider) + .find(|n| n.accesskit_node().label().as_deref() == Some("Hardness")) + .expect("the Hardness slider") + .rect(); + let at = slider.left_center() + vec2(slider.width() * 0.8, 0.0); + h.event(Event::PointerMoved(at)); + h.run_steps(1); + h.event(Event::PointerButton { pos: at, button: egui::PointerButton::Primary, pressed: true, modifiers: Modifiers::NONE }); + h.run_steps(1); + h.event(Event::PointerButton { pos: at, button: egui::PointerButton::Primary, pressed: false, modifiers: Modifiers::NONE }); + h.run_steps(3); + assert!(size_and_hardness(&h).1 > 0.5, "the press moved Hardness"); + assert_eq!(alerts(&h), 0, "nothing was typed out of range"); +} diff --git a/crates/ui-egui/src/tools/brush_picker.rs b/crates/ui-egui/src/tools/brush_picker.rs index 16abf9696e..a0fc3024d8 100644 --- a/crates/ui-egui/src/tools/brush_picker.rs +++ b/crates/ui-egui/src/tools/brush_picker.rs @@ -98,9 +98,10 @@ fn commit_edits(app: &mut PhotocraftApp, events: &EditEvents, set: impl Fn } } -/// Runs what the picker reported: the head's edits, Escape's revert, the saved view and the picks. -/// `keys` are every row's key in list order (a reorder pick is placed by them). -pub(crate) fn apply(app: &mut PhotocraftApp, ctx: &egui::Context, keys: &[BrushKey], out: BrushPresetPickerOutput) { +/// Runs what the picker reported: the head's edits, Escape's revert, the range alert for a Size or Hardness typed out +/// of range (the picker stays open under it, #11817), the saved view and the picks. `keys` are every row's key in list +/// order (a reorder pick is placed by them); `ui` words the alert's range. +pub(crate) fn apply(app: &mut PhotocraftApp, ui: &egui::Ui, keys: &[BrushKey], out: BrushPresetPickerOutput) { commit_edits(app, &out.diameter, |b, v| b.size = *v as f32); commit_edits(app, &out.hardness, |b, v| b.hardness = *v as f32); commit_edits(app, &out.tip, |b, v| { @@ -121,12 +122,15 @@ pub(crate) fn apply(app: &mut PhotocraftApp, ctx: &egui::Context, keys: &[BrushK // One command and no history step: `tools.setBrush` without a coalesce key is a tool setting. commit_keyed(app, &now, &after, None); } + if let Some(alert) = &out.out_of_range { + crate::tools::option_cells::range_alert(app, ui, alert); + } if let Some(settings) = &out.settings { save(app, settings); } for pick in out.picks { match pick { - BrushPick::OpenSettings => open_settings(app, ctx), + BrushPick::OpenSettings => open_settings(app, ui.ctx()), other => run_picks(app, vec![other], keys), } } @@ -157,7 +161,7 @@ pub(crate) fn show_at(ui: &mut egui::Ui, app: &mut PhotocraftApp) { }; let _ = MemoView::new("brush-preset-canvas", props, canvas_view).show(ui); for CanvasEvent { out, keys, eraser, closed } in sent { - apply(app, ui.ctx(), &keys, out); + apply(app, ui, &keys, out); if let Some(rows) = eraser { commit_keyed(app, &rows.before, &rows.brush, rows.key); if app.ui.tool_options.bg_tolerance_control != rows.tolerance { @@ -249,7 +253,7 @@ pub(crate) fn show_field(ui: &mut egui::Ui, app: &mut PhotocraftApp, enabled: bo }; let _ = MemoView::new("brush-preset-field", props, field_view).show(ui); for FieldEvent(out, keys) in sent { - apply(app, ui.ctx(), &keys, out); + apply(app, ui, &keys, out); } } @@ -393,3 +397,7 @@ fn toggle_view(props: &mut ToggleProps<'_>, ui: &mut egui::Ui) { #[cfg(test)] #[path = "../brush_picker_gear_menu_tests.rs"] mod gear_menu_tests; + +#[cfg(test)] +#[path = "../brush_picker_range_alert_tests.rs"] +mod range_alert_tests; From 768592563375efe1ccd71c9fcfbf7f6e9c041877 Mon Sep 17 00:00:00 2001 From: David Mann Date: Sun, 29 Nov 2026 21:57:23 +0100 Subject: [PATCH 08/27] Brush Preset picker range alert test: show the dialogs, so OK can be pressed Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/brush_picker_range_alert_tests.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/ui-egui/src/brush_picker_range_alert_tests.rs b/crates/ui-egui/src/brush_picker_range_alert_tests.rs index 7232f03ba4..4ebdea739d 100644 --- a/crates/ui-egui/src/brush_picker_range_alert_tests.rs +++ b/crates/ui-egui/src/brush_picker_range_alert_tests.rs @@ -23,6 +23,7 @@ fn harness() -> Harness<'static, Box> { } // The canvas shows the picker itself (`canvas_tool_menu::run`). egui::CentralPanel::default().show(ui, |ui| crate::canvas::testing::document_area(app, ui)); + crate::dialogs::run(app, ui); }, app, ); From 8aeac67bce86a29cac6c48fb93f1e120c5656087 Mon Sep 17 00:00:00 2001 From: David Mann Date: Sun, 29 Nov 2026 22:06:56 +0100 Subject: [PATCH 09/27] Move the craft-libs pin to 4311149 (Check Spelling: Enter is Done, storytold/craft-libs#4322) Co-Authored-By: Claude Opus 5.5 --- Cargo.lock | 188 +++++++++++++++++----------------- Cargo.toml | 82 +++++++-------- crates/engine-core/Cargo.toml | 2 +- crates/ipp/Cargo.toml | 2 +- 4 files changed, 137 insertions(+), 137 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 368341024a..ddede24653 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1365,7 +1365,7 @@ dependencies = [ [[package]] name = "craft" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=4311149eab3340e2c03236e2bafd47ed35a9fae1#4311149eab3340e2c03236e2bafd47ed35a9fae1" dependencies = [ "craft-automation", "craft-behavior", @@ -1406,7 +1406,7 @@ dependencies = [ [[package]] name = "craft-affinity" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=4311149eab3340e2c03236e2bafd47ed35a9fae1#4311149eab3340e2c03236e2bafd47ed35a9fae1" dependencies = [ "crc32fast", "flate2", @@ -1427,7 +1427,7 @@ dependencies = [ [[package]] name = "craft-appkit" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=4311149eab3340e2c03236e2bafd47ed35a9fae1#4311149eab3340e2c03236e2bafd47ed35a9fae1" dependencies = [ "block2 0.6.2", "objc2 0.6.5", @@ -1438,7 +1438,7 @@ dependencies = [ [[package]] name = "craft-atomic" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=4311149eab3340e2c03236e2bafd47ed35a9fae1#4311149eab3340e2c03236e2bafd47ed35a9fae1" dependencies = [ "rustix 1.1.6", ] @@ -1446,7 +1446,7 @@ dependencies = [ [[package]] name = "craft-automation" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=4311149eab3340e2c03236e2bafd47ed35a9fae1#4311149eab3340e2c03236e2bafd47ed35a9fae1" dependencies = [ "base64 0.23.1", "craft-behavior", @@ -1471,7 +1471,7 @@ dependencies = [ [[package]] name = "craft-behavior" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=4311149eab3340e2c03236e2bafd47ed35a9fae1#4311149eab3340e2c03236e2bafd47ed35a9fae1" dependencies = [ "accesskit", "bitflags 2.13.2", @@ -1489,7 +1489,7 @@ dependencies = [ [[package]] name = "craft-browse" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=4311149eab3340e2c03236e2bafd47ed35a9fae1#4311149eab3340e2c03236e2bafd47ed35a9fae1" dependencies = [ "craft-behavior", "craft-docpath", @@ -1507,7 +1507,7 @@ dependencies = [ [[package]] name = "craft-cloud-ui" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=4311149eab3340e2c03236e2bafd47ed35a9fae1#4311149eab3340e2c03236e2bafd47ed35a9fae1" dependencies = [ "egui", ] @@ -1515,7 +1515,7 @@ dependencies = [ [[package]] name = "craft-cms" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=4311149eab3340e2c03236e2bafd47ed35a9fae1#4311149eab3340e2c03236e2bafd47ed35a9fae1" dependencies = [ "md-5", "rayon", @@ -1524,12 +1524,12 @@ dependencies = [ [[package]] name = "craft-codepage" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=4311149eab3340e2c03236e2bafd47ed35a9fae1#4311149eab3340e2c03236e2bafd47ed35a9fae1" [[package]] name = "craft-color" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=4311149eab3340e2c03236e2bafd47ed35a9fae1#4311149eab3340e2c03236e2bafd47ed35a9fae1" dependencies = [ "serde", ] @@ -1537,7 +1537,7 @@ dependencies = [ [[package]] name = "craft-color-transform" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=4311149eab3340e2c03236e2bafd47ed35a9fae1#4311149eab3340e2c03236e2bafd47ed35a9fae1" dependencies = [ "craft-cms", "craft-color", @@ -1547,7 +1547,7 @@ dependencies = [ [[package]] name = "craft-color-ui" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=4311149eab3340e2c03236e2bafd47ed35a9fae1#4311149eab3340e2c03236e2bafd47ed35a9fae1" dependencies = [ "craft-behavior", "craft-cms", @@ -1567,7 +1567,7 @@ dependencies = [ [[package]] name = "craft-control" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=4311149eab3340e2c03236e2bafd47ed35a9fae1#4311149eab3340e2c03236e2bafd47ed35a9fae1" dependencies = [ "craft-ai-agents", "craft-atomic", @@ -1583,7 +1583,7 @@ dependencies = [ [[package]] name = "craft-control-protocol" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=4311149eab3340e2c03236e2bafd47ed35a9fae1#4311149eab3340e2c03236e2bafd47ed35a9fae1" dependencies = [ "getrandom 0.3.4", "serde_json", @@ -1593,7 +1593,7 @@ dependencies = [ [[package]] name = "craft-crs" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=4311149eab3340e2c03236e2bafd47ed35a9fae1#4311149eab3340e2c03236e2bafd47ed35a9fae1" dependencies = [ "craft-metadata", "craft-xml", @@ -1603,7 +1603,7 @@ dependencies = [ [[package]] name = "craft-crw" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=4311149eab3340e2c03236e2bafd47ed35a9fae1#4311149eab3340e2c03236e2bafd47ed35a9fae1" dependencies = [ "thiserror 2.0.21", ] @@ -1611,7 +1611,7 @@ dependencies = [ [[package]] name = "craft-dds" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=4311149eab3340e2c03236e2bafd47ed35a9fae1#4311149eab3340e2c03236e2bafd47ed35a9fae1" dependencies = [ "rayon", ] @@ -1619,7 +1619,7 @@ dependencies = [ [[package]] name = "craft-develop" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=4311149eab3340e2c03236e2bafd47ed35a9fae1#4311149eab3340e2c03236e2bafd47ed35a9fae1" dependencies = [ "craft-color", "craft-color-transform", @@ -1634,7 +1634,7 @@ dependencies = [ [[package]] name = "craft-develop-model" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=4311149eab3340e2c03236e2bafd47ed35a9fae1#4311149eab3340e2c03236e2bafd47ed35a9fae1" dependencies = [ "craft-geom", "craft-metadata", @@ -1646,7 +1646,7 @@ dependencies = [ [[package]] name = "craft-dialogs" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=4311149eab3340e2c03236e2bafd47ed35a9fae1#4311149eab3340e2c03236e2bafd47ed35a9fae1" dependencies = [ "block2 0.6.2", "craft-appkit", @@ -1672,7 +1672,7 @@ dependencies = [ [[package]] name = "craft-docpath" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=4311149eab3340e2c03236e2bafd47ed35a9fae1#4311149eab3340e2c03236e2bafd47ed35a9fae1" dependencies = [ "serde", ] @@ -1680,7 +1680,7 @@ dependencies = [ [[package]] name = "craft-draw" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=4311149eab3340e2c03236e2bafd47ed35a9fae1#4311149eab3340e2c03236e2bafd47ed35a9fae1" dependencies = [ "craft-behavior", "craft-color-ui", @@ -1699,12 +1699,12 @@ dependencies = [ [[package]] name = "craft-eps" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=4311149eab3340e2c03236e2bafd47ed35a9fae1#4311149eab3340e2c03236e2bafd47ed35a9fae1" [[package]] name = "craft-file-formats" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=4311149eab3340e2c03236e2bafd47ed35a9fae1#4311149eab3340e2c03236e2bafd47ed35a9fae1" dependencies = [ "craft-eps", "craft-idml", @@ -1722,7 +1722,7 @@ dependencies = [ [[package]] name = "craft-flags" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=4311149eab3340e2c03236e2bafd47ed35a9fae1#4311149eab3340e2c03236e2bafd47ed35a9fae1" dependencies = [ "craft-atomic", "dirs", @@ -1732,7 +1732,7 @@ dependencies = [ [[package]] name = "craft-font-catalog" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=4311149eab3340e2c03236e2bafd47ed35a9fae1#4311149eab3340e2c03236e2bafd47ed35a9fae1" dependencies = [ "fontique", "harfrust 0.13.3", @@ -1747,7 +1747,7 @@ dependencies = [ [[package]] name = "craft-font-manager" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=4311149eab3340e2c03236e2bafd47ed35a9fae1#4311149eab3340e2c03236e2bafd47ed35a9fae1" dependencies = [ "craft-behavior", "craft-font-catalog", @@ -1767,7 +1767,7 @@ dependencies = [ [[package]] name = "craft-font-os-windows" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=4311149eab3340e2c03236e2bafd47ed35a9fae1#4311149eab3340e2c03236e2bafd47ed35a9fae1" dependencies = [ "windows-registry", "windows-sys 0.61.2", @@ -1776,7 +1776,7 @@ dependencies = [ [[package]] name = "craft-font-store" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=4311149eab3340e2c03236e2bafd47ed35a9fae1#4311149eab3340e2c03236e2bafd47ed35a9fae1" dependencies = [ "cap-primitives", "craft-atomic", @@ -1799,12 +1799,12 @@ dependencies = [ [[package]] name = "craft-fonts-build" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=4311149eab3340e2c03236e2bafd47ed35a9fae1#4311149eab3340e2c03236e2bafd47ed35a9fae1" [[package]] name = "craft-geom" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=4311149eab3340e2c03236e2bafd47ed35a9fae1#4311149eab3340e2c03236e2bafd47ed35a9fae1" dependencies = [ "serde", ] @@ -1812,7 +1812,7 @@ dependencies = [ [[package]] name = "craft-heif" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=4311149eab3340e2c03236e2bafd47ed35a9fae1#4311149eab3340e2c03236e2bafd47ed35a9fae1" dependencies = [ "heic-rs", "rayon", @@ -1821,7 +1821,7 @@ dependencies = [ [[package]] name = "craft-host" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=4311149eab3340e2c03236e2bafd47ed35a9fae1#4311149eab3340e2c03236e2bafd47ed35a9fae1" dependencies = [ "bitflags 2.13.2", "craft-i18n", @@ -1834,7 +1834,7 @@ dependencies = [ [[package]] name = "craft-i18n" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=4311149eab3340e2c03236e2bafd47ed35a9fae1#4311149eab3340e2c03236e2bafd47ed35a9fae1" dependencies = [ "chrono", "fixed_decimal", @@ -1862,7 +1862,7 @@ dependencies = [ [[package]] name = "craft-idml" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=4311149eab3340e2c03236e2bafd47ed35a9fae1#4311149eab3340e2c03236e2bafd47ed35a9fae1" dependencies = [ "craft-xml", "craft-zip", @@ -1872,7 +1872,7 @@ dependencies = [ [[package]] name = "craft-image-codecs" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=4311149eab3340e2c03236e2bafd47ed35a9fae1#4311149eab3340e2c03236e2bafd47ed35a9fae1" dependencies = [ "craft-dds", "craft-heif", @@ -1900,7 +1900,7 @@ dependencies = [ [[package]] name = "craft-imaging" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=4311149eab3340e2c03236e2bafd47ed35a9fae1#4311149eab3340e2c03236e2bafd47ed35a9fae1" dependencies = [ "craft-behavior", "craft-color-ui", @@ -1918,12 +1918,12 @@ dependencies = [ [[package]] name = "craft-ipp" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=4311149eab3340e2c03236e2bafd47ed35a9fae1#4311149eab3340e2c03236e2bafd47ed35a9fae1" [[package]] name = "craft-jpeg" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=4311149eab3340e2c03236e2bafd47ed35a9fae1#4311149eab3340e2c03236e2bafd47ed35a9fae1" dependencies = [ "thiserror 2.0.21", ] @@ -1931,7 +1931,7 @@ dependencies = [ [[package]] name = "craft-keymap" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=4311149eab3340e2c03236e2bafd47ed35a9fae1#4311149eab3340e2c03236e2bafd47ed35a9fae1" dependencies = [ "craft-host", "craft-i18n", @@ -1946,7 +1946,7 @@ dependencies = [ [[package]] name = "craft-kra" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=4311149eab3340e2c03236e2bafd47ed35a9fae1#4311149eab3340e2c03236e2bafd47ed35a9fae1" dependencies = [ "craft-xml", "craft-zip", @@ -1956,7 +1956,7 @@ dependencies = [ [[package]] name = "craft-layers" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=4311149eab3340e2c03236e2bafd47ed35a9fae1#4311149eab3340e2c03236e2bafd47ed35a9fae1" dependencies = [ "craft-behavior", "craft-i18n", @@ -1970,7 +1970,7 @@ dependencies = [ [[package]] name = "craft-menu" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=4311149eab3340e2c03236e2bafd47ed35a9fae1#4311149eab3340e2c03236e2bafd47ed35a9fae1" dependencies = [ "craft-behavior", "craft-host", @@ -1988,7 +1988,7 @@ dependencies = [ [[package]] name = "craft-metadata" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=4311149eab3340e2c03236e2bafd47ed35a9fae1#4311149eab3340e2c03236e2bafd47ed35a9fae1" dependencies = [ "brotli-decompressor 6.3.2", "chrono", @@ -2000,7 +2000,7 @@ dependencies = [ [[package]] name = "craft-ora" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=4311149eab3340e2c03236e2bafd47ed35a9fae1#4311149eab3340e2c03236e2bafd47ed35a9fae1" dependencies = [ "craft-xml", "craft-zip", @@ -2010,7 +2010,7 @@ dependencies = [ [[package]] name = "craft-pages" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=4311149eab3340e2c03236e2bafd47ed35a9fae1#4311149eab3340e2c03236e2bafd47ed35a9fae1" dependencies = [ "craft-behavior", "craft-keymap", @@ -2026,7 +2026,7 @@ dependencies = [ [[package]] name = "craft-pcraft-bundle" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=4311149eab3340e2c03236e2bafd47ed35a9fae1#4311149eab3340e2c03236e2bafd47ed35a9fae1" dependencies = [ "blake3", "craft-atomic", @@ -2039,7 +2039,7 @@ dependencies = [ [[package]] name = "craft-pcraft-format" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=4311149eab3340e2c03236e2bafd47ed35a9fae1#4311149eab3340e2c03236e2bafd47ed35a9fae1" dependencies = [ "flate2", "serde", @@ -2050,7 +2050,7 @@ dependencies = [ [[package]] name = "craft-pdf" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=4311149eab3340e2c03236e2bafd47ed35a9fae1#4311149eab3340e2c03236e2bafd47ed35a9fae1" dependencies = [ "bytemuck", "flate2", @@ -2065,7 +2065,7 @@ dependencies = [ [[package]] name = "craft-pdn" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=4311149eab3340e2c03236e2bafd47ed35a9fae1#4311149eab3340e2c03236e2bafd47ed35a9fae1" dependencies = [ "flate2", "thiserror 2.0.21", @@ -2074,7 +2074,7 @@ dependencies = [ [[package]] name = "craft-platform" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=4311149eab3340e2c03236e2bafd47ed35a9fae1#4311149eab3340e2c03236e2bafd47ed35a9fae1" dependencies = [ "async-channel", "async-io", @@ -2105,7 +2105,7 @@ dependencies = [ [[package]] name = "craft-plist" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=4311149eab3340e2c03236e2bafd47ed35a9fae1#4311149eab3340e2c03236e2bafd47ed35a9fae1" dependencies = [ "thiserror 2.0.21", ] @@ -2113,7 +2113,7 @@ dependencies = [ [[package]] name = "craft-print" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=4311149eab3340e2c03236e2bafd47ed35a9fae1#4311149eab3340e2c03236e2bafd47ed35a9fae1" dependencies = [ "craft-behavior", "craft-host", @@ -2137,7 +2137,7 @@ dependencies = [ [[package]] name = "craft-psd" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=4311149eab3340e2c03236e2bafd47ed35a9fae1#4311149eab3340e2c03236e2bafd47ed35a9fae1" dependencies = [ "encoding_rs", "flate2", @@ -2148,7 +2148,7 @@ dependencies = [ [[package]] name = "craft-quit" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=4311149eab3340e2c03236e2bafd47ed35a9fae1#4311149eab3340e2c03236e2bafd47ed35a9fae1" dependencies = [ "dispatch2", "egui", @@ -2161,7 +2161,7 @@ dependencies = [ [[package]] name = "craft-raw" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=4311149eab3340e2c03236e2bafd47ed35a9fae1#4311149eab3340e2c03236e2bafd47ed35a9fae1" dependencies = [ "chrono", "craft-crw", @@ -2179,7 +2179,7 @@ dependencies = [ [[package]] name = "craft-review" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=4311149eab3340e2c03236e2bafd47ed35a9fae1#4311149eab3340e2c03236e2bafd47ed35a9fae1" dependencies = [ "base64 0.23.1", "craft-behavior", @@ -2198,7 +2198,7 @@ dependencies = [ [[package]] name = "craft-settings" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=4311149eab3340e2c03236e2bafd47ed35a9fae1#4311149eab3340e2c03236e2bafd47ed35a9fae1" dependencies = [ "craft-atomic", "craft-host", @@ -2215,7 +2215,7 @@ dependencies = [ [[package]] name = "craft-svg" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=4311149eab3340e2c03236e2bafd47ed35a9fae1#4311149eab3340e2c03236e2bafd47ed35a9fae1" dependencies = [ "craft-image-codecs", "craft-xml", @@ -2236,7 +2236,7 @@ dependencies = [ [[package]] name = "craft-table" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=4311149eab3340e2c03236e2bafd47ed35a9fae1#4311149eab3340e2c03236e2bafd47ed35a9fae1" dependencies = [ "craft-behavior", "craft-keymap", @@ -2248,7 +2248,7 @@ dependencies = [ [[package]] name = "craft-testkit" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=4311149eab3340e2c03236e2bafd47ed35a9fae1#4311149eab3340e2c03236e2bafd47ed35a9fae1" dependencies = [ "rustix 1.1.6", "tempfile", @@ -2258,7 +2258,7 @@ dependencies = [ [[package]] name = "craft-text" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=4311149eab3340e2c03236e2bafd47ed35a9fae1#4311149eab3340e2c03236e2bafd47ed35a9fae1" dependencies = [ "craft-behavior", "craft-font-manager", @@ -2281,7 +2281,7 @@ dependencies = [ [[package]] name = "craft-theme" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=4311149eab3340e2c03236e2bafd47ed35a9fae1#4311149eab3340e2c03236e2bafd47ed35a9fae1" dependencies = [ "bitflags 2.13.2", "craft-tracked", @@ -2296,7 +2296,7 @@ dependencies = [ [[package]] name = "craft-theme-editor" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=4311149eab3340e2c03236e2bafd47ed35a9fae1#4311149eab3340e2c03236e2bafd47ed35a9fae1" dependencies = [ "craft-behavior", "craft-theme", @@ -2307,7 +2307,7 @@ dependencies = [ [[package]] name = "craft-theme-store" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=4311149eab3340e2c03236e2bafd47ed35a9fae1#4311149eab3340e2c03236e2bafd47ed35a9fae1" dependencies = [ "craft-atomic", "craft-behavior", @@ -2322,7 +2322,7 @@ dependencies = [ [[package]] name = "craft-tiff" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=4311149eab3340e2c03236e2bafd47ed35a9fae1#4311149eab3340e2c03236e2bafd47ed35a9fae1" dependencies = [ "serde", "thiserror 2.0.21", @@ -2332,7 +2332,7 @@ dependencies = [ [[package]] name = "craft-time" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=4311149eab3340e2c03236e2bafd47ed35a9fae1#4311149eab3340e2c03236e2bafd47ed35a9fae1" dependencies = [ "serde", "thiserror 2.0.21", @@ -2341,7 +2341,7 @@ dependencies = [ [[package]] name = "craft-timeline" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=4311149eab3340e2c03236e2bafd47ed35a9fae1#4311149eab3340e2c03236e2bafd47ed35a9fae1" dependencies = [ "craft-behavior", "craft-keymap", @@ -2356,7 +2356,7 @@ dependencies = [ [[package]] name = "craft-tracked" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=4311149eab3340e2c03236e2bafd47ed35a9fae1#4311149eab3340e2c03236e2bafd47ed35a9fae1" dependencies = [ "serde", ] @@ -2364,7 +2364,7 @@ dependencies = [ [[package]] name = "craft-ui" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=4311149eab3340e2c03236e2bafd47ed35a9fae1#4311149eab3340e2c03236e2bafd47ed35a9fae1" dependencies = [ "craft-cloud-ui", "craft-ui-canvas", @@ -2378,7 +2378,7 @@ dependencies = [ [[package]] name = "craft-ui-canvas" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=4311149eab3340e2c03236e2bafd47ed35a9fae1#4311149eab3340e2c03236e2bafd47ed35a9fae1" dependencies = [ "craft-behavior", "craft-i18n", @@ -2394,7 +2394,7 @@ dependencies = [ [[package]] name = "craft-ui-contract" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=4311149eab3340e2c03236e2bafd47ed35a9fae1#4311149eab3340e2c03236e2bafd47ed35a9fae1" dependencies = [ "accesskit", "craft-behavior", @@ -2436,7 +2436,7 @@ dependencies = [ [[package]] name = "craft-ui-macros" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=4311149eab3340e2c03236e2bafd47ed35a9fae1#4311149eab3340e2c03236e2bafd47ed35a9fae1" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -2447,7 +2447,7 @@ dependencies = [ [[package]] name = "craft-ui-panels" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=4311149eab3340e2c03236e2bafd47ed35a9fae1#4311149eab3340e2c03236e2bafd47ed35a9fae1" dependencies = [ "craft-behavior", "craft-host", @@ -2465,7 +2465,7 @@ dependencies = [ [[package]] name = "craft-ui-patterns" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=4311149eab3340e2c03236e2bafd47ed35a9fae1#4311149eab3340e2c03236e2bafd47ed35a9fae1" dependencies = [ "craft-behavior", "craft-host", @@ -2486,7 +2486,7 @@ dependencies = [ [[package]] name = "craft-ui-shell" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=4311149eab3340e2c03236e2bafd47ed35a9fae1#4311149eab3340e2c03236e2bafd47ed35a9fae1" dependencies = [ "craft-behavior", "craft-host", @@ -2506,7 +2506,7 @@ dependencies = [ [[package]] name = "craft-ui-widgets" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=4311149eab3340e2c03236e2bafd47ed35a9fae1#4311149eab3340e2c03236e2bafd47ed35a9fae1" dependencies = [ "craft-behavior", "craft-host", @@ -2525,7 +2525,7 @@ dependencies = [ [[package]] name = "craft-update" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=4311149eab3340e2c03236e2bafd47ed35a9fae1#4311149eab3340e2c03236e2bafd47ed35a9fae1" dependencies = [ "base64 0.22.1", "chrono", @@ -2557,7 +2557,7 @@ dependencies = [ [[package]] name = "craft-win32" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=4311149eab3340e2c03236e2bafd47ed35a9fae1#4311149eab3340e2c03236e2bafd47ed35a9fae1" dependencies = [ "winsafe", ] @@ -2565,7 +2565,7 @@ dependencies = [ [[package]] name = "craft-window" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=4311149eab3340e2c03236e2bafd47ed35a9fae1#4311149eab3340e2c03236e2bafd47ed35a9fae1" dependencies = [ "craft-appkit", "craft-atomic", @@ -2597,7 +2597,7 @@ dependencies = [ [[package]] name = "craft-xcf" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=4311149eab3340e2c03236e2bafd47ed35a9fae1#4311149eab3340e2c03236e2bafd47ed35a9fae1" dependencies = [ "flate2", "thiserror 2.0.21", @@ -2606,7 +2606,7 @@ dependencies = [ [[package]] name = "craft-xml" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=4311149eab3340e2c03236e2bafd47ed35a9fae1#4311149eab3340e2c03236e2bafd47ed35a9fae1" dependencies = [ "quick-xml 0.41.0", "serde", @@ -2616,7 +2616,7 @@ dependencies = [ [[package]] name = "craft-zip" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=4311149eab3340e2c03236e2bafd47ed35a9fae1#4311149eab3340e2c03236e2bafd47ed35a9fae1" dependencies = [ "flate2", "thiserror 2.0.21", @@ -4136,7 +4136,7 @@ dependencies = [ [[package]] name = "hayro" version = "0.7.1" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=4311149eab3340e2c03236e2bafd47ed35a9fae1#4311149eab3340e2c03236e2bafd47ed35a9fae1" dependencies = [ "bytemuck", "hayro-interpret", @@ -4166,7 +4166,7 @@ dependencies = [ [[package]] name = "hayro-interpret" version = "0.7.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=4311149eab3340e2c03236e2bafd47ed35a9fae1#4311149eab3340e2c03236e2bafd47ed35a9fae1" dependencies = [ "bitflags 2.13.2", "hayro-cmap", @@ -4184,7 +4184,7 @@ dependencies = [ [[package]] name = "hayro-jbig2" version = "0.3.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=4311149eab3340e2c03236e2bafd47ed35a9fae1#4311149eab3340e2c03236e2bafd47ed35a9fae1" dependencies = [ "fearless_simd", "hayro-ccitt", @@ -4208,7 +4208,7 @@ checksum = "bc2d80da85f31c3fdc0366431f44cfd645a9da1e242ed1f4a61f213d9765660f" [[package]] name = "hayro-syntax" version = "0.7.2" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=4311149eab3340e2c03236e2bafd47ed35a9fae1#4311149eab3340e2c03236e2bafd47ed35a9fae1" dependencies = [ "flate2", "hayro-ccitt", @@ -5301,7 +5301,7 @@ checksum = "d4a5ff6bcca6c4867b1c4fd4ef63e4db7436ef363e0ad7531d1558856bae64f4" [[package]] name = "linesweeper" version = "0.5.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=4311149eab3340e2c03236e2bafd47ed35a9fae1#4311149eab3340e2c03236e2bafd47ed35a9fae1" dependencies = [ "arrayvec", "kurbo 0.13.1", @@ -9811,7 +9811,7 @@ dependencies = [ [[package]] name = "vello_common" version = "0.0.8" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=4311149eab3340e2c03236e2bafd47ed35a9fae1#4311149eab3340e2c03236e2bafd47ed35a9fae1" dependencies = [ "bytemuck", "fearless_simd", @@ -9859,7 +9859,7 @@ dependencies = [ [[package]] name = "vello_cpu" version = "0.0.8" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=4311149eab3340e2c03236e2bafd47ed35a9fae1#4311149eab3340e2c03236e2bafd47ed35a9fae1" dependencies = [ "bytemuck", "glifo 0.1.1", @@ -11505,14 +11505,14 @@ source = "git+https://github.com/storytold/egui.git?rev=14c39fed181756be6f357c28 [[patch.unused]] name = "hayro-cmap" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=4311149eab3340e2c03236e2bafd47ed35a9fae1#4311149eab3340e2c03236e2bafd47ed35a9fae1" [[patch.unused]] name = "hayro-postscript" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=4311149eab3340e2c03236e2bafd47ed35a9fae1#4311149eab3340e2c03236e2bafd47ed35a9fae1" [[patch.unused]] name = "krilla" version = "0.8.2" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=4311149eab3340e2c03236e2bafd47ed35a9fae1#4311149eab3340e2c03236e2bafd47ed35a9fae1" diff --git a/Cargo.toml b/Cargo.toml index cb9fb0ef3b..caab581031 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,21 +12,21 @@ rust-version = "1.95" [workspace.dependencies] # The craft framework through its facade (`craft::ui::…`). The egui `[patch]` below must match # `craft::egui_fork::REV` (checked by `cargo xtask ci`). -craft = { git = "https://github.com/storytold/craft-libs", rev = "f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa", default-features = false } -craft-tracked = { git = "https://github.com/storytold/craft-libs", rev = "f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" } -craft-ui-macros = { git = "https://github.com/storytold/craft-libs", rev = "f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" } +craft = { git = "https://github.com/storytold/craft-libs", rev = "4311149eab3340e2c03236e2bafd47ed35a9fae1", default-features = false } +craft-tracked = { git = "https://github.com/storytold/craft-libs", rev = "4311149eab3340e2c03236e2bafd47ed35a9fae1" } +craft-ui-macros = { git = "https://github.com/storytold/craft-libs", rev = "4311149eab3340e2c03236e2bafd47ed35a9fae1" } # internal photocraft-geom = { path = "crates/geom" } photocraft-color = { path = "crates/color" } photocraft-raster = { path = "crates/raster" } photocraft-doc = { path = "crates/doc" } photocraft-ops = { path = "crates/ops" } -craft-plist = { git = "https://github.com/storytold/craft-libs", rev = "f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" } -craft-psd = { git = "https://github.com/storytold/craft-libs", rev = "f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" } -photocraft-codecs = { package = "craft-image-codecs", git = "https://github.com/storytold/craft-libs", rev = "f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" } -photocraft-formats = { package = "craft-file-formats", git = "https://github.com/storytold/craft-libs", rev = "f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa", features = ["raster-codecs", "pdf", "svg", "ora", "kra", "xcf", "pdn", "raw", "psd", "affinity", "pcraft"] } +craft-plist = { git = "https://github.com/storytold/craft-libs", rev = "4311149eab3340e2c03236e2bafd47ed35a9fae1" } +craft-psd = { git = "https://github.com/storytold/craft-libs", rev = "4311149eab3340e2c03236e2bafd47ed35a9fae1" } +photocraft-codecs = { package = "craft-image-codecs", git = "https://github.com/storytold/craft-libs", rev = "4311149eab3340e2c03236e2bafd47ed35a9fae1" } +photocraft-formats = { package = "craft-file-formats", git = "https://github.com/storytold/craft-libs", rev = "4311149eab3340e2c03236e2bafd47ed35a9fae1", features = ["raster-codecs", "pdf", "svg", "ora", "kra", "xcf", "pdn", "raw", "psd", "affinity", "pcraft"] } photocraft-raw = { path = "crates/raw" } -craft-affinity = { git = "https://github.com/storytold/craft-libs", rev = "f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" } +craft-affinity = { git = "https://github.com/storytold/craft-libs", rev = "4311149eab3340e2c03236e2bafd47ed35a9fae1" } photocraft-compose = { path = "crates/compose" } photocraft-gpu = { path = "crates/gpu" } photocraft-paint = { path = "crates/paint" } @@ -48,36 +48,36 @@ photocraft-ipp = { path = "crates/ipp" } # external # ICC colour management: the shared crate (replaces crates/cms; craft-libs#779). -craft-cms = { git = "https://github.com/storytold/craft-libs", rev = "f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" } -craft-print = { git = "https://github.com/storytold/craft-libs", rev = "f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" } +craft-cms = { git = "https://github.com/storytold/craft-libs", rev = "4311149eab3340e2c03236e2bafd47ed35a9fae1" } +craft-print = { git = "https://github.com/storytold/craft-libs", rev = "4311149eab3340e2c03236e2bafd47ed35a9fae1" } # HEIC/HEIF: the shared decoder (replaces crates/heif; craft-libs#784). -craft-heif = { git = "https://github.com/storytold/craft-libs", rev = "f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" } -craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa", features = ["raster", "write-raster"] } -craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" } -craft-docpath = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" } -craft-jpeg = { git = "https://github.com/storytold/craft-libs", rev = "f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" } -craft-pcraft-format = { git = "https://github.com/storytold/craft-libs", rev = "f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" } -craft-pcraft-bundle = { git = "https://github.com/storytold/craft-libs", rev = "f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" } -craft-zip = { git = "https://github.com/storytold/craft-libs", rev = "f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" } -craft-ora = { git = "https://github.com/storytold/craft-libs", rev = "f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" } -craft-kra = { git = "https://github.com/storytold/craft-libs", rev = "f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" } -craft-xcf = { git = "https://github.com/storytold/craft-libs", rev = "f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" } -craft-pdn = { git = "https://github.com/storytold/craft-libs", rev = "f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" } +craft-heif = { git = "https://github.com/storytold/craft-libs", rev = "4311149eab3340e2c03236e2bafd47ed35a9fae1" } +craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "4311149eab3340e2c03236e2bafd47ed35a9fae1", features = ["raster", "write-raster"] } +craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "4311149eab3340e2c03236e2bafd47ed35a9fae1" } +craft-docpath = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "4311149eab3340e2c03236e2bafd47ed35a9fae1" } +craft-jpeg = { git = "https://github.com/storytold/craft-libs", rev = "4311149eab3340e2c03236e2bafd47ed35a9fae1" } +craft-pcraft-format = { git = "https://github.com/storytold/craft-libs", rev = "4311149eab3340e2c03236e2bafd47ed35a9fae1" } +craft-pcraft-bundle = { git = "https://github.com/storytold/craft-libs", rev = "4311149eab3340e2c03236e2bafd47ed35a9fae1" } +craft-zip = { git = "https://github.com/storytold/craft-libs", rev = "4311149eab3340e2c03236e2bafd47ed35a9fae1" } +craft-ora = { git = "https://github.com/storytold/craft-libs", rev = "4311149eab3340e2c03236e2bafd47ed35a9fae1" } +craft-kra = { git = "https://github.com/storytold/craft-libs", rev = "4311149eab3340e2c03236e2bafd47ed35a9fae1" } +craft-xcf = { git = "https://github.com/storytold/craft-libs", rev = "4311149eab3340e2c03236e2bafd47ed35a9fae1" } +craft-pdn = { git = "https://github.com/storytold/craft-libs", rev = "4311149eab3340e2c03236e2bafd47ed35a9fae1" } # Keep the shared embedded-image validation API until the framework revision includes it. -craft-svg = { git = "https://github.com/storytold/craft-libs", rev = "f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa", features = ["tree-render", "tree-render-system-fonts"] } -craft-raw = { git = "https://github.com/storytold/craft-libs", rev = "f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" } -craft-tiff = { git = "https://github.com/storytold/craft-libs", rev = "f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" } +craft-svg = { git = "https://github.com/storytold/craft-libs", rev = "4311149eab3340e2c03236e2bafd47ed35a9fae1", features = ["tree-render", "tree-render-system-fonts"] } +craft-raw = { git = "https://github.com/storytold/craft-libs", rev = "4311149eab3340e2c03236e2bafd47ed35a9fae1" } +craft-tiff = { git = "https://github.com/storytold/craft-libs", rev = "4311149eab3340e2c03236e2bafd47ed35a9fae1" } # Camera-field EXIF reader/writer, shared prerequisite craft-libs#1563. -craft-metadata = { git = "https://github.com/storytold/craft-libs", rev = "f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" } -craft-crs = { git = "https://github.com/storytold/craft-libs", rev = "f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" } -craft-develop = { git = "https://github.com/storytold/craft-libs", rev = "f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" } -craft-develop-model = { git = "https://github.com/storytold/craft-libs", rev = "f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" } +craft-metadata = { git = "https://github.com/storytold/craft-libs", rev = "4311149eab3340e2c03236e2bafd47ed35a9fae1" } +craft-crs = { git = "https://github.com/storytold/craft-libs", rev = "4311149eab3340e2c03236e2bafd47ed35a9fae1" } +craft-develop = { git = "https://github.com/storytold/craft-libs", rev = "4311149eab3340e2c03236e2bafd47ed35a9fae1" } +craft-develop-model = { git = "https://github.com/storytold/craft-libs", rev = "4311149eab3340e2c03236e2bafd47ed35a9fae1" } # Interface translations: lookup, fallback, CLDR plurals and language names over the craft-i18n # catalogs that `crates/ui-egui/build.rs` embeds from `CRAFT_I18N_DIR` (storytold/craft-i18n, at # the commit in `craft-i18n.rev`). Already in the tree through craft. -craft-i18n = { git = "https://github.com/storytold/craft-libs", rev = "f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" } +craft-i18n = { git = "https://github.com/storytold/craft-libs", rev = "4311149eab3340e2c03236e2bafd47ed35a9fae1" } # craft-update: app-specific pretend versions apply to startup and manual checks. -craft-update = { git = "https://github.com/storytold/craft-libs", version = "=0.1.0", rev = "f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa", features = ["ui"] } +craft-update = { git = "https://github.com/storytold/craft-libs", version = "=0.1.0", rev = "4311149eab3340e2c03236e2bafd47ed35a9fae1", features = ["ui"] } thiserror = "2" serde = { version = "1", features = ["derive", "rc"] } serde_json = "1" @@ -350,16 +350,16 @@ opt-level = 3 # Keep the complete egui family and native event bridge on reviewed fork commits. [patch.crates-io] -krilla = { git = "https://github.com/storytold/craft-libs", rev = "f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" } -hayro = { git = "https://github.com/storytold/craft-libs", rev = "f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" } -hayro-interpret = { git = "https://github.com/storytold/craft-libs", rev = "f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" } -hayro-syntax = { git = "https://github.com/storytold/craft-libs", rev = "f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" } -hayro-jbig2 = { git = "https://github.com/storytold/craft-libs", rev = "f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" } -hayro-cmap = { git = "https://github.com/storytold/craft-libs", rev = "f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" } -hayro-postscript = { git = "https://github.com/storytold/craft-libs", rev = "f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" } -linesweeper = { git = "https://github.com/storytold/craft-libs", rev = "f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" } -vello_common = { git = "https://github.com/storytold/craft-libs", rev = "f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" } -vello_cpu = { git = "https://github.com/storytold/craft-libs", rev = "f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" } +krilla = { git = "https://github.com/storytold/craft-libs", rev = "4311149eab3340e2c03236e2bafd47ed35a9fae1" } +hayro = { git = "https://github.com/storytold/craft-libs", rev = "4311149eab3340e2c03236e2bafd47ed35a9fae1" } +hayro-interpret = { git = "https://github.com/storytold/craft-libs", rev = "4311149eab3340e2c03236e2bafd47ed35a9fae1" } +hayro-syntax = { git = "https://github.com/storytold/craft-libs", rev = "4311149eab3340e2c03236e2bafd47ed35a9fae1" } +hayro-jbig2 = { git = "https://github.com/storytold/craft-libs", rev = "4311149eab3340e2c03236e2bafd47ed35a9fae1" } +hayro-cmap = { git = "https://github.com/storytold/craft-libs", rev = "4311149eab3340e2c03236e2bafd47ed35a9fae1" } +hayro-postscript = { git = "https://github.com/storytold/craft-libs", rev = "4311149eab3340e2c03236e2bafd47ed35a9fae1" } +linesweeper = { git = "https://github.com/storytold/craft-libs", rev = "4311149eab3340e2c03236e2bafd47ed35a9fae1" } +vello_common = { git = "https://github.com/storytold/craft-libs", rev = "4311149eab3340e2c03236e2bafd47ed35a9fae1" } +vello_cpu = { git = "https://github.com/storytold/craft-libs", rev = "4311149eab3340e2c03236e2bafd47ed35a9fae1" } ecolor = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" } emath = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" } epaint = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" } diff --git a/crates/engine-core/Cargo.toml b/crates/engine-core/Cargo.toml index 41bb4f31ea..878bdefb2b 100644 --- a/crates/engine-core/Cargo.toml +++ b/crates/engine-core/Cargo.toml @@ -19,7 +19,7 @@ photocraft-geom = { workspace = true } photocraft-color = { workspace = true } craft-cms = { workspace = true } # PCTIP codec from craft-libs#1564; kept at the same shared revision as the workspace. -craft-pcraft-tip = { package = "craft-pcraft-format", git = "https://github.com/storytold/craft-libs", rev = "f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" } +craft-pcraft-tip = { package = "craft-pcraft-format", git = "https://github.com/storytold/craft-libs", rev = "4311149eab3340e2c03236e2bafd47ed35a9fae1" } photocraft-raster = { workspace = true } photocraft-doc = { workspace = true } photocraft-ops = { workspace = true } diff --git a/crates/ipp/Cargo.toml b/crates/ipp/Cargo.toml index 23fc19a72f..3d2c48a45d 100644 --- a/crates/ipp/Cargo.toml +++ b/crates/ipp/Cargo.toml @@ -7,7 +7,7 @@ license.workspace = true rust-version.workspace = true [dependencies] -craft-ipp = { git = "https://github.com/storytold/craft-libs", rev = "f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" } +craft-ipp = { git = "https://github.com/storytold/craft-libs", rev = "4311149eab3340e2c03236e2bafd47ed35a9fae1" } [lints] workspace = true From 5766096e97052208f64c8793a7c9cf3b6e4a2f00 Mon Sep 17 00:00:00 2001 From: David Mann Date: Sun, 29 Nov 2026 23:00:55 +0100 Subject: [PATCH 10/27] Arrange: a press that activates another pane's document draws the frame again The panes draw before SplitViews reports the press, so the Crop task bar, the active pane and the tile title kept the old document for that frame. A labeled row's first appearance used to force a discard pass that hid this; craft-libs#4311 dropped that pass, which surfaced it in crop_task_bar::with_tiled_documents_the_bar_sits_on_the_active_tile. Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/canvas/document_area.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/src/canvas/document_area.rs b/crates/ui-egui/src/canvas/document_area.rs index 95bd4f4264..f5385f73b9 100644 --- a/crates/ui-egui/src/canvas/document_area.rs +++ b/crates/ui-egui/src/canvas/document_area.rs @@ -310,8 +310,13 @@ fn arranged(app: &mut PhotocraftApp, ui: &mut egui::Ui, rect: Rect, active: usiz } } } - if let Some(d) = selected { - app.session.set_active(d); + if let Some(d) = selected + && d != active + && app.session.set_active(d) + { + // The panes drew with the document active before the press: the task bars, the active pane and the tab + // highlight would show the old one for this frame, so the frame is drawn again with the new one. + ui.ctx().request_discard("a pane activated its document"); } // A clean document can leave the session immediately, so close only after the pane indices were used. for id in closing { From 3a0d94d4be59f883c5411e0898a292d451477db6 Mon Sep 17 00:00:00 2001 From: David Mann Date: Mon, 30 Nov 2026 02:25:46 +0100 Subject: [PATCH 11/27] WIP: Fill: work in Multichannel documents (#17479) From 6ba302bea917b62e4b8d22071863c20a9b0f1f30 Mon Sep 17 00:00:00 2001 From: David Mann Date: Mon, 30 Nov 2026 02:36:39 +0100 Subject: [PATCH 12/27] Fill: write the fill's grey into every channel of a Multichannel document (#17479) Co-Authored-By: Claude Opus 5.5 --- .../engine-core/src/cmd/multichannel_cmds.rs | 5 + crates/engine-paint/src/cmd/fill_cmds.rs | 70 ++++++++- .../cmd/fill_cmds/multichannel_fill_tests.rs | 147 ++++++++++++++++++ .../src/cmd/table/paint/edit_menu.rs | 4 +- 4 files changed, 222 insertions(+), 4 deletions(-) create mode 100644 crates/engine-paint/src/cmd/fill_cmds/multichannel_fill_tests.rs diff --git a/crates/engine-core/src/cmd/multichannel_cmds.rs b/crates/engine-core/src/cmd/multichannel_cmds.rs index 77846d17c5..ebf209c7d9 100644 --- a/crates/engine-core/src/cmd/multichannel_cmds.rs +++ b/crates/engine-core/src/cmd/multichannel_cmds.rs @@ -259,6 +259,11 @@ pub fn ink_names(doc: &Document) -> Vec { doc.channels.iter().filter(|c| c.spot.is_some()).map(|c| c.name.clone()).collect() } +/// The ink (spot) channels of a Multichannel image, in order, to write into. +pub fn inks_mut(doc: &mut Document) -> impl Iterator { + doc.channels.iter_mut().filter(|c| c.spot.is_some()).map(|c| &mut c.surface) +} + pub fn specs() -> Vec { vec![CommandSpec { id: "image.mode.multichannel", diff --git a/crates/engine-paint/src/cmd/fill_cmds.rs b/crates/engine-paint/src/cmd/fill_cmds.rs index 7968d1cc76..e4861e2359 100644 --- a/crates/engine-paint/src/cmd/fill_cmds.rs +++ b/crates/engine-paint/src/cmd/fill_cmds.rs @@ -6,7 +6,7 @@ //! Every parameter is validated: a bad one is an error, never a panic. use photocraft_algo::content_aware::FillOptions; -use photocraft_color::BlendMode; +use photocraft_color::{BlendMode, ColorMode, SampleType}; use photocraft_geom::Rect; #[cfg(test)] use photocraft_geom::TILE_SIZE; @@ -69,6 +69,15 @@ fn flag(p: &Value, k: &str, d: bool) -> Result { } } +/// Edit › Fill's precondition: a pixel layer or a targeted channel, or an 8-bit Multichannel document, whose ink +/// channels it fills (#17479). +pub fn enabled(s: &Session) -> std::result::Result<(), String> { + if s.active().is_some_and(|st| st.doc.mode == ColorMode::Multichannel && st.doc.depth == SampleType::U8) { + return Ok(()); + } + crate::commands::has_pixel_or_channel(s) +} + /// Edit › Fill. pub fn fill(s: &mut Session, p: &Value) -> Result { let contents = contents(p)?; @@ -76,7 +85,17 @@ pub fn fill(s: &mut Session, p: &Value) -> Result { let opacity = opacity(p, mode)?; let preserve = flag(p, "preserveTransparency", false)?; let channel = crate::channel_cmds::is_channel_target(p); - let id = if channel { None } else { Some(layer_param(s, p)?) }; + // A Multichannel document has no layer: a fill of its pixels goes into every ink channel (#17479). + let inks = !channel && crate::channel_cmds::gray_target(p).is_none() && s.active().is_some_and(|st| st.doc.mode == ColorMode::Multichannel); + if inks && s.active().is_some_and(|st| st.doc.depth != SampleType::U8) { + return Err(EngineError::Other("Fill into every channel of a 16- or 32-bit Multichannel document is not supported yet; target one channel".into())); + } + if inks && matches!(contents, "history" | "contentAware") { + return Err(EngineError::Other( + "Fill from History and Content-Aware Fill need a layer, and a Multichannel document has none; target one channel".into(), + )); + } + let id = if channel || inks { None } else { Some(layer_param(s, p)?) }; let st = s.active().ok_or(EngineError::NoDocument)?; check_mode_available(CMD, &st.doc, mode)?; let doc_bounds = st.doc.bounds(); @@ -142,6 +161,13 @@ pub fn fill(s: &mut Session, p: &Value) -> Result { } _ => return Err(bad(format!("unknown contents `{contents}`"))), }; + // The reference writes a colour's one grey into every ink channel; it is not split into inks. + let source = match source { + Source::Color(c) | Source::Cmyk { rgba: c, .. } if inks && matches!(contents, "foreground" | "background" | "color") => { + Source::Color(multichannel_grey(s, c)) + } + source => source, + }; if area.is_empty() { return Ok(out); } @@ -150,6 +176,19 @@ pub fn fill(s: &mut Session, p: &Value) -> Result { photocraft_color::convert::with_cmyk_space(cmyk.as_ref(), || { s.edit("Fill", |doc, _| { let sel = doc.selection.clone(); + if inks { + let blend = Blend { mode, opacity, keep_alpha: false, restore }; + // A pattern reaches the first ink only; the others come out white, as the reference fills them. + let white = Source::Color([1.0; 4]); + for (k, surf) in photocraft_engine_core::multichannel_cmds::inks_mut(doc).enumerate() { + let src = if k > 0 && matches!(source, Source::Pixels(..)) { &white } else { &source }; + // An ink channel stores density: blend over its tone, then back to density. + invert(surf, area)?; + blend_into(surf, area, src, sel.as_ref(), blend)?; + invert(surf, area)?; + } + return Ok(()); + } let (surf, lock) = crate::channel_cmds::target_surface(doc, id, p)?; blend_into(surf, area, &source, sel.as_ref(), Blend { mode, opacity, keep_alpha: preserve || lock, restore })?; Ok(()) @@ -158,6 +197,30 @@ pub fn fill(s: &mut Session, p: &Value) -> Result { Ok(out) } +/// A fill colour as a Multichannel document takes it (#17479): its grey in Gray Gamma 2.2, the one +/// value the reference writes into every channel (RGB 200,30,30 gives 104 and 30,30,200 gives 64). +/// A failed conversion keeps the colour. +fn multichannel_grey(s: &Session, c: [f32; 4]) -> [f32; 4] { + use crate::color_cmds::ColorExt; + let dst = std::sync::Arc::new(craft_cms::Builtin::GrayGamma22.profile().clone()); + let opts = craft_cms::TransformOptions { intent: craft_cms::Intent::RelativeColorimetric, bpc: true, ..Default::default() }; + let Ok(t) = craft_cms::cached(&s.color().working(ColorMode::Rgb), &dst, opts) else { return c }; + let mut out = [0.0f32; 16]; + if t.eval(&[c[0], c[1], c[2]], &mut out).is_err() || !out[0].is_finite() { + return c; + } + let g = out[0].clamp(0.0, 1.0); + [g, g, g, c[3]] +} + +/// Inverts `area` of a channel (density to tone and back). +fn invert(surf: &mut photocraft_raster::Surface, area: Rect) -> Result<()> { + let mut v = crate::allocation::read_region(surf, area, "filling a Multichannel channel")?; + v.iter_mut().for_each(|x| *x = 1.0 - *x); + surf.try_write_region(area, &v)?; + Ok(()) +} + /// A fill colour: the inks it was picked as when it was picked as CMYK (#4196), else plain sRGB. fn color_source(s: &Session, c: [f32; 4], role: usize) -> Source { match s.tools.picked_role_cmyk(role) { @@ -175,3 +238,6 @@ mod mode_by_document_tests; #[cfg(test)] #[path = "fill_dissolve_opacity_rounding_tests.rs"] mod fill_dissolve_opacity_rounding_tests; + +#[cfg(test)] +mod multichannel_fill_tests; diff --git a/crates/engine-paint/src/cmd/fill_cmds/multichannel_fill_tests.rs b/crates/engine-paint/src/cmd/fill_cmds/multichannel_fill_tests.rs new file mode 100644 index 0000000000..d5625620ca --- /dev/null +++ b/crates/engine-paint/src/cmd/fill_cmds/multichannel_fill_tests.rs @@ -0,0 +1,147 @@ +//! #17479: Edit › Fill works in a Multichannel document. With no channel targeted it writes the fill's one grey into +//! every ink channel, as the reference application does (Foreground 200,30,30 → 104 in each channel, Background +//! 30,30,200 → 64), blends per channel, and is one "Fill" history step. One targeted channel still takes the fill +//! alone. + +use super::*; +use serde_json::json; + +/// A 64×32 RGB document at `depth` bits, red on the left half and blue on the right, converted to Multichannel +/// (Cyan, Magenta, Yellow; tone 255 = no ink). +fn session(depth: u32) -> Session { + let mut s = crate::session(); + s.execute("file.new", json!({"width": 64, "height": 32, "mode": "rgb", "depth": depth, "background": "white"})).unwrap(); + s.execute("select.rect", json!({"x": 0, "y": 0, "width": 32, "height": 32})).unwrap(); + s.execute("edit.fill", json!({"contents": "color", "color": "#ff0000"})).unwrap(); + s.execute("select.rect", json!({"x": 32, "y": 0, "width": 32, "height": 32})).unwrap(); + s.execute("edit.fill", json!({"contents": "color", "color": "#0000ff"})).unwrap(); + s.execute("select.deselect", json!({})).unwrap(); + s.execute("image.mode.multichannel", json!({})).unwrap(); + s +} + +/// The tone (0..255, 255 = no ink) of every ink channel at (x, 10). +fn tones(s: &Session, x: i32) -> Vec { + let st = s.active().unwrap(); + st.doc + .channels + .iter() + .filter(|c| c.spot.is_some()) + .map(|c| ((1.0 - c.surface.read_region(Rect::new(x, 10, x + 1, 11))[0]) * 255.0).round() as i32) + .collect() +} + +const RED: i32 = 10; +const BLUE: i32 = 50; + +fn rgb(r: u8, g: u8, b: u8) -> [f32; 4] { + [f32::from(r) / 255.0, f32::from(g) / 255.0, f32::from(b) / 255.0, 1.0] +} + +/// Every ink of both halves after filling a fresh document with `params`. +fn filled(params: serde_json::Value) -> (Vec, Vec) { + let mut s = session(8); + s.tools.foreground = rgb(200, 30, 30); + s.tools.background = rgb(30, 30, 200); + s.execute("edit.fill", params).unwrap(); + (tones(&s, RED), tones(&s, BLUE)) +} + +fn near(got: &[i32], want: i32, tol: i32) -> bool { + got.iter().all(|v| (v - want).abs() <= tol) +} + +#[test] +fn starts_as_the_measured_inks() { + let s = session(8); + assert_eq!((tones(&s, RED), tones(&s, BLUE)), (vec![255, 0, 0], vec![0, 0, 255])); +} + +#[test] +fn fill_is_enabled_and_one_history_step() { + let mut s = session(8); + assert!(s.is_enabled("edit.fill"), "Edit › Fill is greyed in a Multichannel document"); + let before = s.active().unwrap().history.past_len(); + s.execute("edit.fill", json!({"contents": "white"})).unwrap(); + let st = s.active().unwrap(); + assert_eq!((st.history.past_len(), st.history.undo_label()), (before + 1, Some("Fill"))); +} + +#[test] +fn colour_fills_write_one_grey_into_every_channel() { + // (contents, the measured grey, our tolerance): the colours go through the grey, not split into inks. + for (params, want, tol) in [ + (json!({"contents": "foreground"}), 104, 1), + (json!({"contents": "background"}), 64, 1), + (json!({"contents": "color", "color": "#8c8c8c"}), 139, 1), + (json!({"color": "#8c8c8c"}), 139, 1), + (json!({"contents": "black"}), 0, 0), + (json!({"contents": "gray"}), 128, 0), + (json!({"contents": "white"}), 255, 0), + ] { + let (red, blue) = filled(params.clone()); + assert!(near(&red, want, tol) && near(&blue, want, tol), "{params}: red half {red:?}, blue half {blue:?}, want {want} in every channel"); + } +} + +#[test] +fn opacity_and_mode_blend_per_channel() { + let (red, blue) = filled(json!({"contents": "white", "opacity": 50})); + assert!(near(&red[1..], 128, 1) && red[0] == 255, "white at 50 %: red half {red:?}"); + assert!(near(&blue[..2], 128, 1) && blue[2] == 255, "white at 50 %: blue half {blue:?}"); + let (red, blue) = filled(json!({"contents": "white", "mode": "multiply"})); + assert_eq!((red, blue), (vec![255, 0, 0], vec![0, 0, 255]), "white Multiply changes nothing"); +} + +#[test] +fn a_selection_limits_the_fill() { + let mut s = session(8); + s.execute("select.rect", json!({"x": 0, "y": 0, "width": 32, "height": 32})).unwrap(); + s.execute("edit.fill", json!({"contents": "black"})).unwrap(); + assert_eq!((tones(&s, RED), tones(&s, BLUE)), (vec![0, 0, 0], vec![0, 0, 255])); +} + +#[test] +fn pattern_reaches_the_first_channel_and_whitens_the_rest() { + let mut s = session(8); + s.execute("edit.fill", json!({"contents": "pattern"})).unwrap(); + let st = s.active().unwrap(); + let inks: Vec> = st.doc.channels.iter().filter(|c| c.spot.is_some()).map(|c| c.surface.read_region(st.doc.bounds())).collect(); + assert!(inks[0].iter().any(|d| *d > 0.0), "the pattern left no ink in the first channel"); + for ink in &inks[1..] { + assert!(ink.iter().all(|d| *d == 0.0), "a channel after the first kept ink"); + } +} + +#[test] +fn one_targeted_channel_takes_the_fill_alone() { + let mut s = session(8); + s.execute("channel.target", json!({"channel": {"alpha": 0}})).unwrap(); + // Today's one-channel fill writes the value into the stored ink (not measured, unchanged here): White inks it. + s.execute("edit.fill", json!({"contents": "white"})).unwrap(); + let (red, blue) = (tones(&s, RED), tones(&s, BLUE)); + assert_ne!(red[0], 255, "the targeted channel did not change"); + assert_eq!((&red[1..], &blue[1..]), (&[0, 0][..], &[0, 255][..]), "the other channels changed"); +} + +#[test] +fn deeper_multichannel_refuses_without_changing_anything() { + for depth in [16, 32] { + let mut s = session(depth); + let before = (tones(&s, RED), tones(&s, BLUE), s.active().unwrap().history.past_len()); + assert!(s.execute("edit.fill", json!({"contents": "black"})).is_err(), "{depth}-bit"); + assert_eq!((tones(&s, RED), tones(&s, BLUE), s.active().unwrap().history.past_len()), before, "{depth}-bit"); + } +} + +#[test] +fn history_and_content_aware_refuse_without_changing_anything() { + let mut s = session(8); + s.execute("select.rect", json!({"x": 4, "y": 4, "width": 8, "height": 8})).unwrap(); + let before = (tones(&s, RED), tones(&s, BLUE), s.active().unwrap().history.past_len()); + for contents in ["history", "contentAware"] { + let err = s.execute("edit.fill", json!({"contents": contents})).unwrap_err().to_string(); + assert!(err.contains("Multichannel"), "{contents}: {err}"); + assert_eq!((tones(&s, RED), tones(&s, BLUE), s.active().unwrap().history.past_len()), before, "{contents}"); + } +} diff --git a/crates/engine-paint/src/cmd/table/paint/edit_menu.rs b/crates/engine-paint/src/cmd/table/paint/edit_menu.rs index 2659b54567..23ce5b7df7 100644 --- a/crates/engine-paint/src/cmd/table/paint/edit_menu.rs +++ b/crates/engine-paint/src/cmd/table/paint/edit_menu.rs @@ -1,4 +1,4 @@ -use crate::commands::{CommandSpec, has_pixel_or_channel}; +use crate::commands::CommandSpec; /// Edit menu: Fill. pub fn specs() -> Vec { @@ -8,7 +8,7 @@ pub fn specs() -> Vec { ["Edit"], Some("Shift+F5"), r##"{"contents":"foreground|background|color|contentAware|pattern|history|black|gray|white"="color","color":"#rrggbb|[r,g,b,a]"=foreground (contents=color),"colorCmyk":[c,m,y,k]? (native inks 0..1 for contents=color),"pattern":id|name (contents=pattern),"scale":%=100,"angle":deg,"state":row?,"snapshot":id? (contents=history: a History panel row as history.setSource, redo rows last, or a snapshot; default the History Brush source),"colorAdaptation":bool=true,"scaleAdaptation":bool=false,"mirror":bool=false,"rotationAdaptation":bool=false (contents=contentAware: enable quarter-turn source candidates within the sampling budget),"mode":"normal|multiply|…"="normal","opacity":0..100=100,"preserveTransparency":bool=false,"target":"pixels"|"mask"|"filterMask"|"quickMask"|{"channel":i}?}"##, - has_pixel_or_channel, + crate::fill_cmds::enabled, crate::fill_cmds::fill )] } From 68fff566071c4f74e3869ce76d7a93883d855ef5 Mon Sep 17 00:00:00 2001 From: David Mann Date: Mon, 30 Nov 2026 02:43:12 +0100 Subject: [PATCH 13/27] Fill: keep the layer fill in a Multichannel document that has layers Co-Authored-By: Claude Opus 5.5 --- crates/engine-paint/src/cmd/fill_cmds.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/crates/engine-paint/src/cmd/fill_cmds.rs b/crates/engine-paint/src/cmd/fill_cmds.rs index e4861e2359..d7e0004349 100644 --- a/crates/engine-paint/src/cmd/fill_cmds.rs +++ b/crates/engine-paint/src/cmd/fill_cmds.rs @@ -69,10 +69,15 @@ fn flag(p: &Value, k: &str, d: bool) -> Result { } } +/// A Multichannel document as the conversion leaves it: ink channels and no layer to fill. +fn inks_only(doc: &photocraft_doc::Document) -> bool { + doc.mode == ColorMode::Multichannel && doc.layers.is_empty() +} + /// Edit › Fill's precondition: a pixel layer or a targeted channel, or an 8-bit Multichannel document, whose ink /// channels it fills (#17479). pub fn enabled(s: &Session) -> std::result::Result<(), String> { - if s.active().is_some_and(|st| st.doc.mode == ColorMode::Multichannel && st.doc.depth == SampleType::U8) { + if s.active().is_some_and(|st| inks_only(&st.doc) && st.doc.depth == SampleType::U8) { return Ok(()); } crate::commands::has_pixel_or_channel(s) @@ -86,7 +91,7 @@ pub fn fill(s: &mut Session, p: &Value) -> Result { let preserve = flag(p, "preserveTransparency", false)?; let channel = crate::channel_cmds::is_channel_target(p); // A Multichannel document has no layer: a fill of its pixels goes into every ink channel (#17479). - let inks = !channel && crate::channel_cmds::gray_target(p).is_none() && s.active().is_some_and(|st| st.doc.mode == ColorMode::Multichannel); + let inks = !channel && crate::channel_cmds::gray_target(p).is_none() && s.active().is_some_and(|st| inks_only(&st.doc)); if inks && s.active().is_some_and(|st| st.doc.depth != SampleType::U8) { return Err(EngineError::Other("Fill into every channel of a 16- or 32-bit Multichannel document is not supported yet; target one channel".into())); } From f738fa4345af4f20567fdda560bca3e7f2b0be83 Mon Sep 17 00:00:00 2001 From: qvest-ssels <214787280+qvest-ssels@users.noreply.github.com> Date: Mon, 30 Nov 2026 08:18:37 +0100 Subject: [PATCH 14/27] Fill dialog in Quick Mask greys what the channel can't take In Quick Mask, Fill lists the fill from surroundings and History greyed in Contents, Preserve Transparency greyed off, and Darker Color, Lighter Color, Hue, Saturation, Color and Luminosity (and Behind and Clear once listed) greyed in Mode. A remembered Mode that is greyed opens on Normal and stays remembered for fills elsewhere. Out of Quick Mask the dialog is unchanged. Fixes #17488. --- .../dialogs/fill_quick_mask_greyed_tests.rs | 101 ++++++++++++++++++ crates/ui-egui/src/dialogs/fill_ui.rs | 67 +++++++++++- 2 files changed, 163 insertions(+), 5 deletions(-) create mode 100644 crates/ui-egui/src/dialogs/fill_quick_mask_greyed_tests.rs diff --git a/crates/ui-egui/src/dialogs/fill_quick_mask_greyed_tests.rs b/crates/ui-egui/src/dialogs/fill_quick_mask_greyed_tests.rs new file mode 100644 index 0000000000..55e8b0a229 --- /dev/null +++ b/crates/ui-egui/src/dialogs/fill_quick_mask_greyed_tests.rs @@ -0,0 +1,101 @@ +//! #17488: in Quick Mask the Fill dialog greys what doesn't work on the channel: the fill from surroundings and History +//! in Contents, Preserve Transparency (off), and Darker Color, Lighter Color, Hue, Saturation, Color and Luminosity in +//! Mode. A remembered choice that is greyed opens on an enabled one and stays remembered; out of Quick Mask the dialog +//! is as before. + +use craft::ui::patterns::form_dialogs::HostedParamDialog; +use photocraft_color::BlendMode; +use serde_json::json; + +use super::*; +use crate::smart_filter_dialog::tests::{cancel, confirm, set}; + +/// A white 40×30 RGB document with a pixel layer "Paint" active and a selection. +fn app() -> Box { + let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), Default::default()); + app.run("file.new", json!({"width": 40, "height": 30, "background": "white"})).unwrap(); + app.run("layer.new.layer", json!({"name": "Paint"})).unwrap(); + app.run("select.rect", json!({"x": 5, "y": 5, "width": 20, "height": 15})).unwrap(); + app +} + +fn quick_mask_on(app: &mut PhotocraftApp, on: bool) { + app.run("select.editInQuickMaskMode", json!({"on": on})).unwrap(); +} + +fn row(app: &PhotocraftApp, key: &str) -> Param { + rows(app, [0.0; 3], None, None).into_iter().find(|r| r.key == key).unwrap_or_else(|| panic!("a {key} row")) +} + +/// A field of the open dialog `id`, and whether it takes `value`. +fn field(app: &mut PhotocraftApp, id: DialogId, key: &str) -> serde_json::Value { + let dialog = app.framework.dialogs.get_by_id::(id).expect("a hosted dialog"); + let fields = dialog.fields(); + fields.text(key).map(|t| json!(t)).or_else(|| fields.bool(key).map(|b| json!(b))).unwrap_or(serde_json::Value::Null) +} + +fn takes(app: &mut PhotocraftApp, id: DialogId, key: &str, value: serde_json::Value) -> bool { + let ctx = app.ctx().clone(); + app.framework.dialogs.set_json_field(&ctx, id, key, value).is_ok() +} + +const CHANNEL_GREYED: [BlendMode; 6] = + [BlendMode::DarkerColor, BlendMode::LighterColor, BlendMode::Hue, BlendMode::Saturation, BlendMode::Color, BlendMode::Luminosity]; + +#[test] +fn quick_mask_greys_contents_mode_and_preserve_transparency() { + let mut app = app(); + quick_mask_on(&mut app, true); + let contents = row(&app, "contents"); + for (key, _) in CONTENTS { + assert_eq!(contents.option_enabled(key), !matches!(key, "contentAware" | "history"), "Contents {key}"); + } + let mode = row(&app, "mode"); + for m in BlendMode::LAYER_MODES { + assert_eq!(mode.option_enabled(m.key()), !CHANNEL_GREYED.contains(&m), "Mode {}", m.label()); + } + assert!(!mode.option_enabled("behind") && !mode.option_enabled("clear"), "Behind and Clear greyed once listed"); + + let id = open(&mut app); + assert_eq!(field(&mut app, id, "preserveTransparency"), json!(false), "Preserve Transparency unchecked"); + assert!(!takes(&mut app, id, "preserveTransparency", json!(true)), "Preserve Transparency greyed"); + assert!(!takes(&mut app, id, "mode", json!("hue")), "Hue greyed"); + assert!(!takes(&mut app, id, "contents", json!("history")), "History greyed"); + assert!(takes(&mut app, id, "mode", json!("multiply")), "Multiply enabled"); + assert!(takes(&mut app, id, "contents", json!("pattern")), "Pattern enabled"); + cancel(&mut app, id); +} + +#[test] +fn greyed_remembered_choices_open_enabled_and_stay_remembered() { + let mut app = app(); + let id = open(&mut app); + set(&mut app, id, "mode", json!("hue")); + set(&mut app, id, "preserveTransparency", json!(true)); + set(&mut app, id, "contents", json!("black")); + confirm(&mut app, id); + + quick_mask_on(&mut app, true); + let id = open(&mut app); + assert_eq!(field(&mut app, id, "mode"), json!("normal"), "a greyed remembered Mode opens on Normal"); + assert_eq!(field(&mut app, id, "preserveTransparency"), json!(false), "and Preserve Transparency unchecked"); + set(&mut app, id, "contents", json!("white")); + confirm(&mut app, id); + quick_mask_on(&mut app, false); + + let id = open(&mut app); + assert_eq!(field(&mut app, id, "mode"), json!("hue"), "the remembered Mode is kept"); + assert_eq!(field(&mut app, id, "preserveTransparency"), json!(true), "the remembered Preserve Transparency is kept"); + cancel(&mut app, id); +} + +#[test] +fn out_of_quick_mask_the_dialog_is_unchanged() { + let app = app(); + let contents = row(&app, "contents"); + assert!(CONTENTS.iter().all(|(key, _)| contents.option_enabled(key)), "every Contents entry enabled with a selection"); + let mode = row(&app, "mode"); + assert!(BlendMode::LAYER_MODES.iter().all(|m| mode.option_enabled(m.key())), "every Mode enabled in RGB 8 bit"); + let pt = row(&app, "preserveTransparency"); + assert!(matches!(pt.kind, ParamKind::Bool { .. })); +} diff --git a/crates/ui-egui/src/dialogs/fill_ui.rs b/crates/ui-egui/src/dialogs/fill_ui.rs index 8450823468..540b4ea0b1 100644 --- a/crates/ui-egui/src/dialogs/fill_ui.rs +++ b/crates/ui-egui/src/dialogs/fill_ui.rs @@ -8,7 +8,7 @@ use craft::ui::contract::Bind; use craft::ui::dialog::DialogId; use craft::ui::patterns::form_dialogs::{DialogFields, FieldValue, Param, ParamDialog, ParamKind, ParamResult}; use craft::ui::runtime::env::Label; -use craft::ui::runtime::memory::{MemoryStage, SaveKey, set_saved_value}; +use craft::ui::runtime::memory::{MemoryStage, SaveKey, saved_value, set_saved_value}; use photocraft_color::BlendMode; use serde_json::{Value, json}; @@ -40,12 +40,38 @@ pub(crate) fn hex(c: [f32; 3]) -> String { format!("#{:02x}{:02x}{:02x}", b(c[0]), b(c[1]), b(c[2])) } +/// The blend modes Fill greys on the Quick Mask channel (#17488): the colour-only modes, which a channel can't take, +/// and Behind and Clear. +const QUICK_MASK_GREYED_MODES: [BlendMode; 6] = + [BlendMode::DarkerColor, BlendMode::LighterColor, BlendMode::Hue, BlendMode::Saturation, BlendMode::Color, BlendMode::Luminosity]; + +/// The target Fill edits: a layer mask or channel the panels target, else the paint target. +fn fill_target(app: &PhotocraftApp) -> Value { + let target = app.with_mask_target(COMMAND, json!({})); + target.get("target").cloned().unwrap_or_else(|| crate::canvas::paint_target(app)) +} + +/// Whether Fill opens on the Quick Mask channel. +fn quick_mask(app: &PhotocraftApp) -> bool { + fill_target(app).as_str() == Some("quickMask") +} + +/// The keys of the Mode entries greyed on the Quick Mask channel. +fn quick_mask_greyed_keys() -> impl Iterator { + QUICK_MASK_GREYED_MODES.iter().map(|m| m.key().to_string()).chain(["behind".to_string(), "clear".to_string()]) +} + /// The dialog's rows, with the Preserve Transparency the target forces. fn rows(app: &PhotocraftApp, foreground: [f32; 3], first_pattern: Option, preserve: Option) -> Vec { + let quick_mask = quick_mask(app); let contents = CONTENTS.iter().map(|(k, l)| (k.to_string(), Label::from(tl!(l)))).collect(); let mut contents = Param::new("contents", tl!("Contents:"), ParamKind::choice(contents, Some("foreground".into()))); // Content-Aware fills a selection from around it: without one it is listed greyed, as in the reference (#17462). - if app.session.active().is_none_or(|st| st.doc.selection.is_none()) { + // On the Quick Mask channel the fill from surroundings and History are greyed too (#17488). + let no_selection = app.session.active().is_none_or(|st| st.doc.selection.is_none()); + if quick_mask { + contents = contents.disabled_options(["contentAware", "history"]); + } else if no_selection { contents = contents.disabled_options(["contentAware"]); } let mut rows = vec![ @@ -55,6 +81,14 @@ fn rows(app: &PhotocraftApp, foreground: [f32; 3], first_pattern: Option Param::new("colorAdaptation", tl!("Color Adaptation"), ParamKind::bool(true)).visible_when("contents", "contentAware"), ]; rows.extend(blending_rows(app, preserve)); + if quick_mask { + // The modes the document greys stay greyed; the channel adds its own (#17488). + for row in rows.iter_mut().filter(|row| row.key == "mode") { + let greyed: Vec = + BlendMode::LAYER_MODES.iter().map(|m| m.key().to_string()).filter(|k| !row.option_enabled(k)).chain(quick_mask_greyed_keys()).collect(); + *row = row.clone().disabled_options(greyed); + } + } rows } @@ -77,11 +111,11 @@ fn defaults(foreground: [f32; 3], first_pattern: Option, inks: Option<[f /// Open Fill with the current editing target captured, so live UI changes cannot redirect confirmation. pub fn open(app: &mut PhotocraftApp) -> DialogId { - let target = app.with_mask_target(COMMAND, json!({})); - let target = target.get("target").cloned().unwrap_or_else(|| crate::canvas::paint_target(app)); + let target = fill_target(app); // Alpha and Quick Mask belong to the document, independently of its active layer. let layer_bound = target.as_str() != Some("quickMask") && target.get("channel").is_none(); - let preserve = forced_preserve_transparency(app, &target); + // Preserve Transparency has no meaning on the Quick Mask channel: greyed off there (#17488). + let preserve = if target.as_str() == Some("quickMask") { Some(false) } else { forced_preserve_transparency(app, &target) }; let mut held = json!({ "target": target }); if let Some(st) = app.session.active() { held["document"] = json!(st.doc.id.0); @@ -161,7 +195,12 @@ pub(crate) fn run(app: &mut PhotocraftApp, ctx: &egui::Context, result: ParamRes let captured = captured(app, &result.key); match app.run(COMMAND, params(&result.fields, &captured)) { Ok(_) => { + // A Mode remembered before that the Quick Mask channel greys is kept for the next fill elsewhere (#17488). + let kept_mode = (captured.get("target").and_then(Value::as_str) == Some("quickMask")).then(|| remembered_mode(ctx, &result.key)).flatten(); remember_blending(ctx, &result); + if let Some(mode) = kept_mode.filter(|mode| quick_mask_greyed_keys().any(|k| &k == mode)) { + keep_mode(ctx, &result.key, mode); + } // The framework remembers visible parameter rows only; keep their ink companion in the same saved tier. let mut inks = DialogFields::new(); if let Some(value) = result.fields.get(&crate::color_picker_ui::ink_field("color")) { @@ -173,9 +212,27 @@ pub(crate) fn run(app: &mut PhotocraftApp, ctx: &egui::Context, result: ParamRes } } +/// The Mode the dialog `key` remembers. +fn remembered_mode(ctx: &egui::Context, key: &str) -> Option { + let saved = saved_value::>(ctx, &SaveKey::named(super::params::memory_scope(key)))?; + saved.text("mode").map(str::to_owned) +} + +/// Puts `mode` back as the Mode the dialog `key` remembers. +fn keep_mode(ctx: &egui::Context, key: &str, mode: String) { + let save = SaveKey::named(super::params::memory_scope(key)); + if let Some(mut saved) = saved_value::>(ctx, &save) { + saved.set("mode", mode); + set_saved_value(ctx, &save, Some(saved)); + } +} + #[cfg(test)] mod content_aware_greyed_tests; #[cfg(test)] +#[path = "fill_quick_mask_greyed_tests.rs"] +mod fill_quick_mask_greyed_tests; +#[cfg(test)] mod opacity_alert_tests; #[cfg(test)] mod preserve_transparency_state_tests; From 24272a529843f7a0308c58a6bb3a077e3ec7af92 Mon Sep 17 00:00:00 2001 From: NaufalDzz Date: Mon, 30 Nov 2026 12:52:53 +0000 Subject: [PATCH 15/27] Art History Brush: keep pressure toggles on Reset Tool (#18335) Co-authored-by: OpenBot <335604065+openbotgit[bot]@users.noreply.github.com> --- .../panels/art_history_bar_controls_tests.rs | 9 ++-- .../art_history_reset_keeps_pressure_tests.rs | 48 +++++++++++++++++++ crates/ui-egui/src/tools/tool_reset.rs | 10 ++-- 3 files changed, 60 insertions(+), 7 deletions(-) create mode 100644 crates/ui-egui/src/tools/art_history_reset_keeps_pressure_tests.rs diff --git a/crates/ui-egui/src/panels/art_history_bar_controls_tests.rs b/crates/ui-egui/src/panels/art_history_bar_controls_tests.rs index fc8e6b9e11..0aa7f6d6cc 100644 --- a/crates/ui-egui/src/panels/art_history_bar_controls_tests.rs +++ b/crates/ui-egui/src/panels/art_history_bar_controls_tests.rs @@ -1,7 +1,8 @@ //! #12629: the Art History Brush's options bar has a Pressure for Opacity toggle right after //! Opacity, and an Angle field and a Pressure for Size toggle after Tolerance, with the reference -//! application's tooltips, off / 0° by default and after Reset Tool. They edit the tool's own -//! brush, not the History Brush's or the Brush's, and the bar has no Flow and no Airbrush. +//! application's tooltips. The toggles start off and keep their state after Reset Tool (#18335), +//! which restores the angle to 0°. The controls belong to the Art History Brush, and the bar has +//! no Flow or Airbrush. use egui::accesskit::Role; use egui::{Modifiers, Rect, vec2}; @@ -99,7 +100,7 @@ fn the_controls_carry_the_reference_tooltips() { } #[test] -fn the_controls_are_off_and_0_by_default_and_after_reset_tool() { +fn reset_tool_restores_the_angle_and_keeps_pressure_toggles() { let mut h = bar(Tool::ArtHistoryBrush); assert_eq!(controls(h.state()), (false, 0.0, false)); assert!(angle_field(&h).and_then(|n| n.accesskit_node().numeric_value()) == Some(0.0), "the field shows 0°"); @@ -112,7 +113,7 @@ fn the_controls_are_off_and_0_by_default_and_after_reset_tool() { let ctx = h.ctx.clone(); crate::menus::invoke(h.state_mut(), &ctx, "tool.reset", json!({})).unwrap(); h.run_steps(3); - assert_eq!(controls(h.state()), (false, 0.0, false)); + assert_eq!(controls(h.state()), (true, 0.0, true)); } #[test] diff --git a/crates/ui-egui/src/tools/art_history_reset_keeps_pressure_tests.rs b/crates/ui-egui/src/tools/art_history_reset_keeps_pressure_tests.rs new file mode 100644 index 0000000000..26c6cbd15a --- /dev/null +++ b/crates/ui-egui/src/tools/art_history_reset_keeps_pressure_tests.rs @@ -0,0 +1,48 @@ +use serde_json::json; + +use super::{RESET, RESET_ALL, invoke}; +use crate::PhotocraftApp; +use crate::state::{Tool, ToolOptions}; + +fn art_history_brush(pressure_size: bool, pressure_opacity: bool) -> Box { + let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), crate::Services::default()); + app.run("file.new", json!({"width": 200, "height": 200})).unwrap(); + app.ui.tool = Tool::ArtHistoryBrush; + crate::paint_mouse::sync_tool_brush(&mut app); + app.run("tools.setBrush", json!({"brush": {"pressureSize": pressure_size, "pressureOpacity": pressure_opacity}})).unwrap(); + app +} + +fn pressure(app: &PhotocraftApp) -> (bool, bool) { + let brush = &app.session.tools.brush; + (brush.pressure_size, brush.pressure_opacity) +} + +#[test] +fn reset_tool_keeps_each_art_history_brush_pressure_toggle() { + let defaults = ToolOptions::default(); + for toggles in [(true, false), (false, true), (true, true), (false, false)] { + let mut app = art_history_brush(toggles.0, toggles.1); + assert_eq!(pressure(&app), toggles); + app.ui.tool_options.art_history_style = "dab".into(); + app.ui.tool_options.art_history_area = 120.0; + app.ui.tool_options.art_history_tolerance = 25.0; + + invoke(&mut app, RESET, &json!({})).unwrap().unwrap(); + + assert_eq!(pressure(&app), toggles); + assert_eq!(app.ui.tool_options.art_history_style, defaults.art_history_style); + assert_eq!(app.ui.tool_options.art_history_area, defaults.art_history_area); + assert_eq!(app.ui.tool_options.art_history_tolerance, defaults.art_history_tolerance); + } +} + +#[test] +fn reset_all_tools_clears_the_art_history_brush_pressure_toggles() { + let mut app = art_history_brush(true, true); + assert_eq!(pressure(&app), (true, true)); + + invoke(&mut app, RESET_ALL, &json!({"confirmed": true})).unwrap().unwrap(); + + assert_eq!(pressure(&app), (false, false)); +} diff --git a/crates/ui-egui/src/tools/tool_reset.rs b/crates/ui-egui/src/tools/tool_reset.rs index f40ccc6c38..b52b42f1d0 100644 --- a/crates/ui-egui/src/tools/tool_reset.rs +++ b/crates/ui-egui/src/tools/tool_reset.rs @@ -90,10 +90,10 @@ fn reset_tool(app: &mut PhotocraftApp, tool: Tool) { // The session brush is the options bar's tool's: make sure it is `tool`'s before resetting. crate::paint_mouse::sync_tool_brush(app); app.ui.tool_brushes.retain(|(t, _)| *t != tool); - // The Eraser's Reset Tool resets the tip but keeps Pressure for Size and Pressure for - // Opacity as they were (#17700). + // Reset the tip but keep Pressure for Size and Pressure for Opacity for the Eraser + // (#17700) and Art History Brush (#18335). let brush = &app.session.tools.brush; - let pressure = (tool == Tool::Eraser).then_some((brush.pressure_size, brush.pressure_opacity)); + let pressure = matches!(tool, Tool::Eraser | Tool::ArtHistoryBrush).then_some((brush.pressure_size, brush.pressure_opacity)); reset_session_brush(app); if let Some((size, opacity)) = pressure { app.session.tools.brush.pressure_size = size; @@ -483,3 +483,7 @@ mod patch_sample_all_default_tests; #[cfg(test)] #[path = "eraser_reset_keeps_pressure_tests.rs"] mod eraser_reset_keeps_pressure_tests; + +#[cfg(test)] +#[path = "art_history_reset_keeps_pressure_tests.rs"] +mod art_history_reset_keeps_pressure_tests; From fc177b03c7baf0cf6dba97b638c703bf607f28fc Mon Sep 17 00:00:00 2001 From: RickiNano <81099017+RickiNano@users.noreply.github.com> Date: Mon, 30 Nov 2026 16:36:20 +0100 Subject: [PATCH 16/27] Move tool: show W and H beside the pointer while drawing the layer marquee (#18162) A Move drag that starts on empty canvas (or only on locked layers) with Auto-Select draws the layer marquee, and nothing showed its size. The marquee now asks for the same W and H readout the selection marquee shows, in its words and pixel units, on every drag step. Show Transformation Values hides it as it hides the drag readout. The release and the layers it selects are unchanged. --- crates/ui-egui/src/canvas/tools/move_tool.rs | 5 +- crates/ui-egui/src/tools/move_box.rs | 15 ++++ .../src/tools/move_marquee_readout_tests.rs | 75 +++++++++++++++++++ 3 files changed, 94 insertions(+), 1 deletion(-) create mode 100644 crates/ui-egui/src/tools/move_marquee_readout_tests.rs diff --git a/crates/ui-egui/src/canvas/tools/move_tool.rs b/crates/ui-egui/src/canvas/tools/move_tool.rs index 6c49cb207c..4c53eba55d 100644 --- a/crates/ui-egui/src/canvas/tools/move_tool.rs +++ b/crates/ui-egui/src/canvas/tools/move_tool.rs @@ -353,7 +353,10 @@ impl CanvasTool for MoveRun<'_> { let at = space.view.to_doc(pointer.pos); match run.kind { Kind::Marquee => { - self.scope.with_app(|app| crate::move_box::drag_to(app, [at.x, at.y])); + self.scope.with_app(|app| { + crate::move_box::drag_to(app, [at.x, at.y]); + crate::move_box::readout(app, cx); + }); } Kind::Refused => { if !std::mem::replace(&mut run.prompted, true) { diff --git a/crates/ui-egui/src/tools/move_box.rs b/crates/ui-egui/src/tools/move_box.rs index 24632762b4..b69547897c 100644 --- a/crates/ui-egui/src/tools/move_box.rs +++ b/crates/ui-egui/src/tools/move_box.rs @@ -7,6 +7,8 @@ use serde_json::json; use craft::behavior::kurbo::{Point, Rect}; +use craft::imaging::ui::select::SelectWords; +use craft::ui::canvas::ToolContext; use craft::ui::canvas_controls::Marquee; use craft::ui::contract::Show as _; @@ -85,6 +87,15 @@ pub(crate) fn cancel(app: &mut PhotocraftApp) { app.layer_box = None; } +/// The marquee's W and H beside the pointer while it is dragged, in the selection marquee's words and units +/// (Show Transformation Values hides it, as it hides the drag readout). +pub(crate) fn readout(app: &PhotocraftApp, cx: &mut ToolContext<'_>) { + let Some(b) = app.layer_box else { return }; + let rect = Rect::from_points(Point::new(b.start[0], b.start[1]), Point::new(b.end[0], b.end[1])); + let (words, units) = (cx.words::(), cx.units()); + cx.readout(vec![(words.width.clone(), units.pixels(rect.width())), (words.height.clone(), units.pixels(rect.height()))]); +} + /// The marquee being dragged, over the canvas `canvas`. pub(crate) fn show(app: &PhotocraftApp, ui: &mut egui::Ui, canvas: egui::Rect) { let Some(b) = app.layer_box else { return }; @@ -205,3 +216,7 @@ mod tests { assert_eq!(app.session.active().unwrap().selected_layers(), vec![paint]); } } + +#[cfg(test)] +#[path = "move_marquee_readout_tests.rs"] +mod move_marquee_readout_tests; diff --git a/crates/ui-egui/src/tools/move_marquee_readout_tests.rs b/crates/ui-egui/src/tools/move_marquee_readout_tests.rs new file mode 100644 index 0000000000..93e226884c --- /dev/null +++ b/crates/ui-egui/src/tools/move_marquee_readout_tests.rs @@ -0,0 +1,75 @@ +//! #18162: the Move tool's layer marquee shows its W and H beside the pointer while it is dragged, as a layer drag +//! shows its distances, and adds no history step. + +use serde_json::json; + +use crate::canvas::{ToolEvent, tool_event, tool_event_response}; +use crate::state::Tool; +use crate::{PhotocraftApp, Services}; + +/// A white document whose only layer is the locked Background, with the Move tool and Auto-Select on: a press +/// anywhere on the canvas starts the layer marquee. +fn app() -> Box { + let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), Services::default()); + app.run("file.new", json!({"width": 200, "height": 150})).unwrap(); + app.sync_views(); + app.ui.tool = Tool::Move; + app.ui.tool_options.move_auto_select = true; + app +} + +/// The readout rows of the pass that moves the pointer to `to`, as label and value text. +fn readout(app: &mut PhotocraftApp, to: [f64; 2]) -> Vec<(String, String)> { + tool_event_response(app, ToolEvent::Move { x: to[0], y: to[1], pressure: 1.0 }, egui::Modifiers::NONE) + .readout + .expect("the layer marquee has a readout") + .rows + .into_iter() + .map(|(label, value)| (label.as_str().to_owned(), value)) + .collect() +} + +/// The number a readout value shows ("42 px" reads 42). +fn number(value: &str) -> f64 { + value.trim_end_matches("px").trim().parse().unwrap_or_else(|_| panic!("a pixel value: {value:?}")) +} + +#[test] +fn the_layer_marquee_reads_its_width_and_height_as_it_grows() { + let mut app = app(); + tool_event(&mut app, ToolEvent::Down { x: 20.0, y: 20.0, pressure: 1.0 }, egui::Modifiers::NONE); + let first = readout(&mut app, [60.0, 50.0]); + assert!(app.layer_box.is_some(), "the press started the layer marquee"); + let [(w_label, w), (h_label, h)] = first.as_slice() else { panic!("two rows, W and H: {first:?}") }; + assert!(w_label.starts_with('W') && h_label.starts_with('H'), "{first:?}"); + assert!(w.ends_with("px") && h.ends_with("px"), "{first:?}"); + assert!(number(w) > 0.0 && number(h) > 0.0, "{first:?}"); + + let wider = readout(&mut app, [120.0, 50.0]); + assert!(number(&wider[0].1) > number(w), "a wider drag reads a larger W: {first:?} then {wider:?}"); + assert_eq!(wider[1].1, *h, "H stays while only the width changes"); + + let taller = readout(&mut app, [120.0, 110.0]); + assert!(number(&taller[1].1) > number(&wider[1].1), "a taller drag reads a larger H: {wider:?} then {taller:?}"); + + // Up and to the left of the press, the box reads its size, not a negative one. + let back = readout(&mut app, [5.0, 10.0]); + assert!(number(&back[0].1) > 0.0 && number(&back[1].1) > 0.0, "{back:?}"); +} + +#[test] +fn the_layer_marquee_adds_no_history_step_and_leaves_the_background() { + let mut app = app(); + let (steps, bg, bounds) = { + let st = app.session.active().unwrap(); + let bg = st.active_layer.unwrap(); + (st.history.past_len(), bg, st.doc.layer(bg).unwrap().surface().unwrap().content_bounds()) + }; + tool_event(&mut app, ToolEvent::Down { x: 20.0, y: 20.0, pressure: 1.0 }, egui::Modifiers::NONE); + assert!(!readout(&mut app, [90.0, 70.0]).is_empty()); + tool_event(&mut app, ToolEvent::Up { x: 90.0, y: 70.0 }, egui::Modifiers::NONE); + let st = app.session.active().unwrap(); + assert_eq!(st.history.past_len(), steps, "no history step"); + assert_eq!(st.doc.layer(bg).unwrap().surface().unwrap().content_bounds(), bounds, "the Background did not move"); + assert!(app.layer_box.is_none()); +} From 5ff7b5de8905229925e935f7dce2e99ccf597370 Mon Sep 17 00:00:00 2001 From: David Mann Date: Mon, 30 Nov 2026 17:42:18 +0100 Subject: [PATCH 17/27] Fill in Quick Mask keeps a remembered Mode the document greys A Mode greyed by the document's colour mode or depth (Overlay in RGB 32 bit) opened as Normal in Quick Mask, and OK saved Normal over it. Keep it like the modes the channel greys. Co-Authored-By: Claude Opus 5.5 --- .../dialogs/fill_quick_mask_greyed_tests.rs | 19 +++++++++++++++++++ crates/ui-egui/src/dialogs/fill_ui.rs | 13 ++++++++++--- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/crates/ui-egui/src/dialogs/fill_quick_mask_greyed_tests.rs b/crates/ui-egui/src/dialogs/fill_quick_mask_greyed_tests.rs index 55e8b0a229..72a9746407 100644 --- a/crates/ui-egui/src/dialogs/fill_quick_mask_greyed_tests.rs +++ b/crates/ui-egui/src/dialogs/fill_quick_mask_greyed_tests.rs @@ -89,6 +89,25 @@ fn greyed_remembered_choices_open_enabled_and_stay_remembered() { cancel(&mut app, id); } +#[test] +fn a_remembered_mode_the_document_greys_in_quick_mask_stays_remembered() { + let mut app = app(); + let id = open(&mut app); + set(&mut app, id, "mode", json!("overlay")); + confirm(&mut app, id); + + // RGB 32 bit greys Overlay by its depth, not by the channel. + app.run("file.new", json!({"width": 40, "height": 30, "background": "white", "depth": 32})).unwrap(); + app.run("select.rect", json!({"x": 5, "y": 5, "width": 20, "height": 15})).unwrap(); + quick_mask_on(&mut app, true); + let id = open(&mut app); + assert_eq!(field(&mut app, id, "mode"), json!("normal"), "a greyed remembered Mode opens on Normal"); + set(&mut app, id, "contents", json!("white")); + confirm(&mut app, id); + let ctx = app.ctx().clone(); + assert_eq!(remembered_mode(&ctx, COMMAND).as_deref(), Some("overlay"), "OK in Quick Mask keeps the remembered Mode"); +} + #[test] fn out_of_quick_mask_the_dialog_is_unchanged() { let app = app(); diff --git a/crates/ui-egui/src/dialogs/fill_ui.rs b/crates/ui-egui/src/dialogs/fill_ui.rs index 5f80598582..3301ac5e97 100644 --- a/crates/ui-egui/src/dialogs/fill_ui.rs +++ b/crates/ui-egui/src/dialogs/fill_ui.rs @@ -210,12 +210,19 @@ pub(crate) fn check(app: &mut PhotocraftApp, result: &ParamResult) -> Result<(), /// Fill with the confirmed choices; they are remembered only when the fill succeeded. pub(crate) fn run(app: &mut PhotocraftApp, ctx: &egui::Context, result: ParamResult) { let captured = captured(app, &result.key); + // The Mode entries the dialog greyed on the Quick Mask channel: the channel's and the document's. + let greyed: Vec = if captured.get("target").and_then(Value::as_str) == Some("quickMask") { + let document = app.session.active().map_or(&[][..], |st| photocraft_engine::fill_cmds::greyed_modes(st.doc.mode, st.doc.depth)); + quick_mask_greyed_keys().chain(document.iter().map(|m| m.key().to_string())).collect() + } else { + Vec::new() + }; match app.run(COMMAND, params(&result.fields, &captured)) { Ok(_) => { - // A Mode remembered before that the Quick Mask channel greys is kept for the next fill elsewhere (#17488). - let kept_mode = (captured.get("target").and_then(Value::as_str) == Some("quickMask")).then(|| remembered_mode(ctx, &result.key)).flatten(); + // A Mode remembered before that the Quick Mask dialog greyed is kept for the next fill elsewhere (#17488). + let kept_mode = (!greyed.is_empty()).then(|| remembered_mode(ctx, &result.key)).flatten(); remember_blending(ctx, &result); - if let Some(mode) = kept_mode.filter(|mode| quick_mask_greyed_keys().any(|k| &k == mode)) { + if let Some(mode) = kept_mode.filter(|mode| greyed.contains(mode)) { keep_mode(ctx, &result.key, mode); } // The framework remembers visible parameter rows only; keep their ink companion in the same saved tier. From 34fb0596f9f39c403e56e762f6a108141a2e5a64 Mon Sep 17 00:00:00 2001 From: David Mann Date: Mon, 30 Nov 2026 17:44:22 +0100 Subject: [PATCH 18/27] WIP: Gradient tool: keep the Classic mode out of tool presets (#17494) From 74f137ffdbdafef88ad7877f57d78166f8898aba Mon Sep 17 00:00:00 2001 From: David Mann Date: Mon, 30 Nov 2026 17:49:00 +0100 Subject: [PATCH 19/27] Gradient tool: keep the Classic mode out of tool presets (#17494) A Gradient tool preset neither stores nor applies gradient_classic, so choosing one leaves the Gradient / Classic gradient mode as it is, also for presets saved by older builds that still hold the key. The other options still apply, and Reset Tool / Reset All Tools still reset the mode. Co-Authored-By: Claude Opus 5.5 --- .../gradient_preset_classic_mode_tests.rs | 114 ++++++++++++++++++ .../src/panels/preset_panels/tool_presets.rs | 17 ++- 2 files changed, 128 insertions(+), 3 deletions(-) create mode 100644 crates/ui-egui/src/panels/preset_panels/gradient_preset_classic_mode_tests.rs diff --git a/crates/ui-egui/src/panels/preset_panels/gradient_preset_classic_mode_tests.rs b/crates/ui-egui/src/panels/preset_panels/gradient_preset_classic_mode_tests.rs new file mode 100644 index 0000000000..e9b01687ec --- /dev/null +++ b/crates/ui-egui/src/panels/preset_panels/gradient_preset_classic_mode_tests.rs @@ -0,0 +1,114 @@ +//! #17494: a Gradient tool preset neither stores nor changes the Gradient / Classic gradient mode, as in the +//! reference application, and still restores the tool's other options. Reset Tool and Reset All Tools still +//! put the mode back to Gradient. + +use photocraft_engine::presets::PresetsExt; +use serde_json::{Value, json}; + +use super::{new_params, select}; +use crate::PhotocraftApp; +use crate::state::Tool; + +fn app() -> Box { + let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), crate::Services::default()); + app.run("file.new", json!({"width": 64, "height": 48})).unwrap(); + app.sync_views(); + app.ui.tool = Tool::Gradient; + app +} + +/// The + button's preset, made from the current Gradient tool options; its name and stored options. +fn save(app: &mut PhotocraftApp) -> (String, serde_json::Map) { + let name = app.run("tool.presets.new", new_params(app, Tool::Gradient)).unwrap()["name"].as_str().unwrap().to_string(); + let stored = app.session.presets().tool_presets.iter().find(|t| t.name == name).unwrap().options["toolOptions"].as_object().unwrap().clone(); + (name, stored) +} + +#[test] +fn a_new_gradient_preset_does_not_store_the_mode() { + for classic in [false, true] { + let mut app = app(); + app.ui.tool_options.gradient_classic = classic; + let (_, stored) = save(&mut app); + assert!(!stored.contains_key("gradient_classic"), "classic {classic}: {stored:?}"); + assert!(stored.contains_key("gradient_style"), "the tool's own options are still stored: {stored:?}"); + } +} + +/// Both ways: made in one mode, chosen in the other, the mode stays. +#[test] +fn choosing_a_gradient_preset_keeps_the_mode() { + for made_classic in [false, true] { + let mut app = app(); + app.ui.tool_options.gradient_classic = made_classic; + let (name, _) = save(&mut app); + app.ui.tool_options.gradient_classic = !made_classic; + select(&mut app, &name); + assert_eq!(app.ui.tool, Tool::Gradient); + assert_eq!(app.ui.tool_options.gradient_classic, !made_classic, "a preset made with classic {made_classic} changed the mode"); + } +} + +/// A preset saved by an older build still holds the key: choosing it leaves the mode alone too. +#[test] +fn an_older_preset_holding_the_mode_leaves_it_alone() { + for stored_classic in [false, true] { + let mut app = app(); + app.run( + "tool.presets.new", + json!({"name": "Old", "tool": "gradient", "options": {"toolOptions": {"gradient_classic": stored_classic, "gradient_style": "radial"}}}), + ) + .unwrap(); + app.ui.tool_options.gradient_classic = !stored_classic; + select(&mut app, "Old"); + assert_eq!(app.ui.tool_options.gradient_classic, !stored_classic, "an old preset with classic {stored_classic} changed the mode"); + assert_eq!(app.ui.tool_options.gradient_style, "radial", "its other options still apply"); + } +} + +#[test] +fn choosing_a_gradient_preset_restores_the_other_options() { + let mut app = app(); + let o = &mut app.ui.tool_options; + o.gradient_style = "radial".into(); + o.gradient_reverse = !o.gradient_reverse; + o.gradient_dither = !o.gradient_dither; + o.gradient_blend_mode = photocraft_color::BlendMode::Multiply; + o.fill_opacity = 50.0; + let made = (*app.ui.tool_options).clone(); + let (name, _) = save(&mut app); + + let o = &mut app.ui.tool_options; + o.gradient_style = "linear".into(); + o.gradient_reverse = !made.gradient_reverse; + o.gradient_dither = !made.gradient_dither; + o.gradient_blend_mode = photocraft_color::BlendMode::Normal; + o.fill_opacity = 100.0; + select(&mut app, &name); + let o = &app.ui.tool_options; + assert_eq!(o.gradient_style, made.gradient_style); + assert_eq!(o.gradient_reverse, made.gradient_reverse); + assert_eq!(o.gradient_dither, made.gradient_dither); + assert_eq!(o.gradient_blend_mode, made.gradient_blend_mode); + assert_eq!(o.fill_opacity, made.fill_opacity); +} + +/// Reset Tool with the Gradient tool and Reset All Tools still put the mode back to Gradient; Reset Tool on +/// another tool leaves it. +#[test] +fn reset_still_resets_the_mode() { + let mut app = app(); + let ctx = app.ctx().clone(); + app.ui.tool_options.gradient_classic = true; + app.ui.tool = Tool::Brush; + crate::menus::invoke(&mut app, &ctx, crate::tool_reset::RESET, json!({})).unwrap(); + assert!(app.ui.tool_options.gradient_classic, "the Brush's Reset Tool is not the Gradient tool's"); + + app.ui.tool = Tool::Gradient; + crate::menus::invoke(&mut app, &ctx, crate::tool_reset::RESET, json!({})).unwrap(); + assert!(!app.ui.tool_options.gradient_classic); + + app.ui.tool_options.gradient_classic = true; + crate::menus::invoke(&mut app, &ctx, crate::tool_reset::RESET_ALL, json!({"confirmed": true})).unwrap(); + assert!(!app.ui.tool_options.gradient_classic); +} diff --git a/crates/ui-egui/src/panels/preset_panels/tool_presets.rs b/crates/ui-egui/src/panels/preset_panels/tool_presets.rs index 69a3b6bd85..aa97a057e4 100644 --- a/crates/ui-egui/src/panels/preset_panels/tool_presets.rs +++ b/crates/ui-egui/src/panels/preset_panels/tool_presets.rs @@ -6,6 +6,10 @@ use super::run; use crate::PhotocraftApp; use crate::state::Tool; +/// Options a tool preset neither stores nor applies, though Reset Tool resets them: the +/// Gradient / Classic gradient mode sits outside the reference application's tool presets (#17494). +const NOT_IN_PRESETS: &[&str] = &["gradient_classic"]; + /// Apply a tool preset: the engine sets the brush/colour, the shell switches tool and options. pub fn select(app: &mut PhotocraftApp, name: &str) { // PLAN: assumes `ToolOptions::crop` is `Clone + PartialEq` (tools-w45). @@ -27,7 +31,7 @@ pub fn select(app: &mut PhotocraftApp, name: &str) { crate::tool_memory::upgrade(&mut stored); let mut cur = serde_json::to_value(&app.ui.tool_options).unwrap_or_default(); if let (Some(c), Some(o)) = (cur.as_object_mut(), stored.as_object()) { - for (k, v) in o { + for (k, v) in o.iter().filter(|(k, _)| !NOT_IN_PRESETS.contains(&k.as_str())) { // An object option (`sample_all`, one per tool) takes only the entries the // preset stored, so the other tools' keep theirs (#5524). match (c.get_mut(k), v) { @@ -53,8 +57,11 @@ pub fn select(app: &mut PhotocraftApp, name: &str) { /// preset later leaves the other tools' settings alone. pub(crate) fn new_params(app: &PhotocraftApp, tool: Tool) -> Value { let all = serde_json::to_value(&app.ui.tool_options).unwrap_or_default(); - let mut own: serde_json::Map = - crate::tool_reset::option_keys(tool).iter().filter_map(|k| Some(((*k).to_string(), all.get(*k)?.clone()))).collect(); + let mut own: serde_json::Map = crate::tool_reset::option_keys(tool) + .iter() + .filter(|k| !NOT_IN_PRESETS.contains(k)) + .filter_map(|k| Some(((*k).to_string(), all.get(*k)?.clone()))) + .collect(); // Sample All Layers is each tool's own (#5524): store `tool`'s alone. if let Some(k) = crate::tool_reset::sample_all_key(tool) && let Some(v) = all.get("sample_all").and_then(|m| m.get(&k)) @@ -64,6 +71,10 @@ pub(crate) fn new_params(app: &PhotocraftApp, tool: Tool) -> Value { json!({"name": tool.label(), "tool": tool.id(), "options": {"toolOptions": own}}) } +#[cfg(test)] +#[path = "gradient_preset_classic_mode_tests.rs"] +mod gradient_preset_classic_mode_tests; + #[cfg(test)] mod tests { use super::*; From 71cc84045daab454147289caa4151e8bf363e71f Mon Sep 17 00:00:00 2001 From: Dan Date: Mon, 30 Nov 2026 17:09:12 +0000 Subject: [PATCH 20/27] Open Select Data Points from a checked Custom submenu item --- crates/ui-egui/src/menu_catalog.rs | 2 +- .../analysis/data_points_submenu_tests.rs | 45 +++++++++++++++++++ crates/ui-egui/src/tools/analysis/mod.rs | 5 +++ 3 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 crates/ui-egui/src/tools/analysis/data_points_submenu_tests.rs diff --git a/crates/ui-egui/src/menu_catalog.rs b/crates/ui-egui/src/menu_catalog.rs index de927bce10..10d1b57d61 100644 --- a/crates/ui-egui/src/menu_catalog.rs +++ b/crates/ui-egui/src/menu_catalog.rs @@ -242,7 +242,7 @@ pub static CATALOG: &[(&[&str], &str, Option<&str>, &str)] = &[ (&["Image"], "Trap…", None, "image.trap"), (&["Image"], "---", None, "---"), (&["Image", "Analysis"], "Set Measurement Scale…", None, "image.analysis.setMeasurementScale"), - (&["Image", "Analysis"], "Select Data Points…", None, "image.analysis.selectDataPoints"), + (&["Image", "Analysis", "Select Data Points"], "Custom…", None, "image.analysis.selectDataPoints"), (&["Image", "Analysis"], "---", None, "---"), (&["Image", "Analysis"], "Record Measurements", None, "image.analysis.recordMeasurements"), (&["Image", "Analysis"], "---", None, "---"), diff --git a/crates/ui-egui/src/tools/analysis/data_points_submenu_tests.rs b/crates/ui-egui/src/tools/analysis/data_points_submenu_tests.rs new file mode 100644 index 0000000000..40783e3aa3 --- /dev/null +++ b/crates/ui-egui/src/tools/analysis/data_points_submenu_tests.rs @@ -0,0 +1,45 @@ +use serde_json::{Value, json}; + +use crate::PhotocraftApp; +use crate::control::{ControlRequest, Reply}; + +const COMMAND: &str = "image.analysis.selectDataPoints"; + +fn call(app: &mut PhotocraftApp, method: &str, params: Value) -> Value { + let ctx = app.ctx().clone(); + let (request, _) = ControlRequest::new(method, params); + let Reply::Done(reply) = crate::control::handle(app, &ctx, &request) else { panic!("{method} replies immediately") }; + assert_eq!(reply["ok"], true, "{method}: {reply}"); + reply["result"].clone() +} + +#[test] +fn data_points_submenu_has_only_a_checked_custom_item_and_opens_the_dialog() { + let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), crate::Services::default()); + app.run("file.new", json!({"width": 32, "height": 24})).unwrap(); + + let menu = call(&mut app, "ui.menu.list", json!({})); + let rows = menu.as_array().unwrap(); + let titled_path = json!(["Image", "Analysis", "Select Data Points"]); + let data_points: Vec<_> = rows.iter().filter(|row| row["path"] == titled_path || row["id"] == COMMAND).collect(); + assert_eq!(data_points.len(), 1, "one entry and no separator: {data_points:?}"); + let custom = data_points[0]; + assert_eq!(custom["path"], titled_path); + assert_eq!(custom["id"], COMMAND); + assert_eq!(custom["label"], "Custom…"); + assert_eq!(custom["checked"], true); + assert_eq!(custom["enabled"], true); + assert_eq!(custom["shortcut"], Value::Null); + + let opened = call(&mut app, "ui.menu.invoke", json!({"id": custom["id"]})); + assert_eq!(opened["dialog"], "dataPoints"); + assert!(app.dialog_open()); +} + +#[test] +fn data_points_submenu_keeps_the_engine_command_available_to_scripts() { + let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), crate::Services::default()); + let selected = call(&mut app, "engine.execute", json!({"id": COMMAND, "params": {"selection": ["area"], "ruler": [], "count": []}})); + assert_eq!(selected["dataPoints"]["selection"], json!(["area"])); + assert!(!app.dialog_open()); +} diff --git a/crates/ui-egui/src/tools/analysis/mod.rs b/crates/ui-egui/src/tools/analysis/mod.rs index fce2102caa..a567de1c71 100644 --- a/crates/ui-egui/src/tools/analysis/mod.rs +++ b/crates/ui-egui/src/tools/analysis/mod.rs @@ -30,6 +30,9 @@ mod tests; #[cfg(test)] mod sampler_menu_tests; +#[cfg(test)] +mod data_points_submenu_tests; + #[cfg(test)] #[path = "../count_readout_tests.rs"] mod count_readout_tests; @@ -120,6 +123,8 @@ pub fn checked(app: &PhotocraftApp, id: &str) -> Option { "window.panel.notes" => Some(crate::panel_docking::is_shown(app, NOTES)), "image.analysis.rulerTool" => Some(app.ui.tool == Tool::Ruler), "image.analysis.countTool" => Some(app.ui.tool == Tool::Count), + // The data point set is always Custom until named presets are supported. + "image.analysis.selectDataPoints" => Some(true), _ => { // View › Proof Setup simulations: checked while that proof is shown. // A check item with no document too: an item's kind never changes (native menus). From f2ed4c6dfd24a7d6269d2b9f203c7229d4b1a10e Mon Sep 17 00:00:00 2001 From: Dan Date: Mon, 30 Nov 2026 17:37:51 +0000 Subject: [PATCH 21/27] Retry Windows CI after texture page order failure From 93a120630d162b8ad889318b81c3a81d30a16678 Mon Sep 17 00:00:00 2001 From: David Mann Date: Mon, 30 Nov 2026 19:08:58 +0100 Subject: [PATCH 22/27] Brush Preset picker range alert test: a typed Size fraction is cut off Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/brush_picker_range_alert_tests.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/crates/ui-egui/src/brush_picker_range_alert_tests.rs b/crates/ui-egui/src/brush_picker_range_alert_tests.rs index 4ebdea739d..981358c5c0 100644 --- a/crates/ui-egui/src/brush_picker_range_alert_tests.rs +++ b/crates/ui-egui/src/brush_picker_range_alert_tests.rs @@ -1,5 +1,6 @@ //! #11817: a Size or Hardness typed past its range in the Brush Preset picker takes the closest value and opens the -//! range alert; the picker stays open under it and after OK. A value in range and a slider press open none. +//! range alert; the picker stays open under it and after OK. A value in range (a typed fraction cut off) and a slider +//! press open none. use crate::app::framework::BuildApp as _; use egui::{Event, Modifiers, vec2}; @@ -74,6 +75,8 @@ fn size_and_hardness_typed_out_of_range_alert_and_the_picker_stays_open() { #[test] fn a_value_in_range_and_a_slider_press_open_no_alert() { let mut h = harness(); + type_into(&mut h, 0, "2.5"); + assert_eq!(size_and_hardness(&h).0, 2.0, "a typed fraction is cut off, not rounded"); type_into(&mut h, 0, "40"); assert_eq!(size_and_hardness(&h).0, 40.0); let slider = h From 1bd46c520d103225ebde666a3669b417d7e13498 Mon Sep 17 00:00:00 2001 From: David Mann Date: Mon, 30 Nov 2026 19:48:10 +0100 Subject: [PATCH 23/27] ui-egui: give dialogs a roomier margin (#18416) PhotoCraft left the shared space.pad.dialog token at its default (12 px Comfortable, 8 px Compact), so title, message and buttons sat right at the dialog's edge. Set it to 24 and 16 px in the app's size overrides; only dialogs read this token. Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/app/framework.rs | 3 ++- crates/ui-egui/src/app/sizes.json | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/src/app/framework.rs b/crates/ui-egui/src/app/framework.rs index 9c58f81255..65b2763f99 100644 --- a/crates/ui-egui/src/app/framework.rs +++ b/crates/ui-egui/src/app/framework.rs @@ -271,7 +271,8 @@ fn defaults() -> AppDefaults { } } -/// PhotoCraft's size overrides: Photoshop's panel dock width, and 12-point Label and Mono text in the compact density. +/// PhotoCraft's size overrides: Photoshop's panel dock width, a roomier dialog margin (twice the panel padding, so +/// short questions such as "Unsaved changes" do not look cramped), and 12-point Label and Mono text in the compact density. const SIZES: &[u8] = include_bytes!("sizes.json"); /// The size overrides, parsed once: the root keeps one `Arc` so the runtime's token and hit-size caches, which key on diff --git a/crates/ui-egui/src/app/sizes.json b/crates/ui-egui/src/app/sizes.json index 5727ea93d8..afa5f5a7fa 100644 --- a/crates/ui-egui/src/app/sizes.json +++ b/crates/ui-egui/src/app/sizes.json @@ -1 +1 @@ -{ "all": { "size.dock.column": 290 }, "compact": { "typography.label.size": 12, "typography.mono.size": 12 } } +{ "all": { "size.dock.column": 290 }, "compact": { "space.pad.dialog": 16, "typography.label.size": 12, "typography.mono.size": 12 }, "comfortable": { "space.pad.dialog": 24 } } From 965aebff55cb8da55eacf7268162e411a211c742 Mon Sep 17 00:00:00 2001 From: David Mann Date: Mon, 30 Nov 2026 20:16:29 +0100 Subject: [PATCH 24/27] Fill: Cross Weave script (#17429) Edit > Fill > Pattern > Script > Cross Weave weaves the pattern tile in a basket weave: square cells of the mean tile side plus Spacing alternate between a flat and an upright tile like a checkerboard, leaving a 5 x 5 transparent hole at every 35 px grid point for a 40 x 30 tile, each tile turned half way or not at random (repeatable by seed). edit.fill and the dialog preview both lay scripts out through one render() in scripted_pattern.rs. Co-Authored-By: Claude Opus 5.5 --- crates/compose/src/scripted_pattern.rs | 166 +++++++++-- crates/engine-paint/src/cmd/fill_cmds.rs | 10 +- .../src/fill_script_brick_tests.rs | 4 +- .../src/fill_script_cross_weave_tests.rs | 257 ++++++++++++++++++ crates/engine-paint/src/lib.rs | 2 + crates/ui-egui/src/dialogs/fill_script_ui.rs | 21 +- .../src/dialogs/fill_script_ui_tests.rs | 52 +++- 7 files changed, 477 insertions(+), 35 deletions(-) create mode 100644 crates/engine-paint/src/fill_script_cross_weave_tests.rs diff --git a/crates/compose/src/scripted_pattern.rs b/crates/compose/src/scripted_pattern.rs index 9def7a7493..2e40e1da93 100644 --- a/crates/compose/src/scripted_pattern.rs +++ b/crates/compose/src/scripted_pattern.rs @@ -1,5 +1,6 @@ //! Scripted patterns: Edit › Fill › Pattern with Script on lays the chosen pattern out as separate tiles instead of a -//! plain repeat. Brick Fill is the first script; the others extend [`SCRIPTS`] and [`controls`] with their own layout. +//! plain repeat. Brick Fill and Cross Weave paint today; the others extend [`SCRIPTS`], [`controls`] and [`render`] with +//! their own layout. //! //! Every script shares the per-tile Color and Brightness randomness ([`Jitter`]): at 0 a tile keeps the pattern's //! exact colours, above 0 each placed tile drifts by its own random amount. Areas no tile covers stay transparent. @@ -19,7 +20,7 @@ pub const SCRIPTS: [(&str, &str); 6] = [ ]; /// The scripts that paint today; the rest are listed but answer "not supported yet". -pub const SUPPORTED: [&str; 1] = ["brickFill"]; +pub const SUPPORTED: [&str; 2] = ["brickFill", "crossWeave"]; /// The parameter value of a script name, matched without regard to case. pub fn script_key(name: &str) -> Option<&'static str> { @@ -70,6 +71,35 @@ pub fn controls(script: &str, width: u32, height: u32) -> Option> { Control::new("patternRotateAngle", 0.0, -180.0, 180.0, 0), ]) } + "crossWeave" => { + let (lo, hi) = spacing_range(width, height); + Some(vec![ + Control::new("patternScale", 1.0, 0.1, 1.25, 2), + Control::new("spacing", 0.0, lo, hi, 0), + Control::new("colorRandomness", 0.05, 0.0, 1.0, 2), + Control::new("brightnessRandomness", 0.1, 0.0, 1.0, 2), + ]) + } + _ => None, + } +} + +/// `script` laid out over `rect` with a `width` x `height` pattern: `value` gives each of its [`controls`] (in range), +/// `seed` makes the per-tile randomness repeatable. `None` for a script that does not paint yet. +pub fn render(script: &str, value: impl Fn(&str) -> f64, seed: u64, tile: &Tile, width: u32, height: u32, rect: Rect) -> Option> { + let jitter = Jitter { color: value("colorRandomness") as f32, brightness: value("brightnessRandomness") as f32, seed }; + match script { + "brickFill" => { + let brick = BrickFill { + scale: value("patternScale"), + spacing: value("spacing"), + offset: value("offsetBetweenRows"), + angle: value("patternRotateAngle"), + jitter, + }; + Some(brick.render(tile, width, height, rect)) + } + "crossWeave" => Some(CrossWeave { scale: value("patternScale"), spacing: value("spacing"), jitter }.render(tile, width, height, rect)), _ => None, } } @@ -129,6 +159,36 @@ pub struct BrickFill { /// frontmost tiles all let some of it through ever reaches it; an opaque tile ends the pixel at once. const MAX_LAYERS: usize = 1024; +/// A repeatable value for tile `(row, col)` from `seed`, independent of the colour drift. +fn tile_bits(seed: u64, row: i64, col: i64) -> u64 { + let mut z = (seed ^ 0xD6E8_FEB8_6659_FD93) + .wrapping_add((row as u64).wrapping_mul(0xA076_1D64_78BD_642F)) + .wrapping_add((col as u64).wrapping_mul(0xE703_7ED1_A0B4_28DB)); + z = (z ^ (z >> 30)).wrapping_mul(0xBF58_476D_1CE4_E5B9); + z = (z ^ (z >> 27)).wrapping_mul(0x94D0_49BB_1331_11EB); + z ^ (z >> 31) +} + +/// Adds tile colour `q`, drifted by `d`, behind what `acc` already holds (front to back: what is in front covers it). +fn blend_behind(acc: &mut [f32; 4], mut q: [f32; 4], d: [f32; 3]) { + // Without a drift a tile keeps its exact colour, also a float one past 1. + for ch in 0..3 { + if d[ch] != 0.0 { + q[ch] = (q[ch] + d[ch]).clamp(0.0, 1.0); + } + } + let k = q[3] * (1.0 - acc[3]); + for ch in 0..3 { + acc[ch] += q[ch] * k; + } + acc[3] += k; +} + +/// The straight colour of a front-to-back sum; transparent where no tile covered the pixel. +fn finish(acc: [f32; 4]) -> [f32; 4] { + if acc[3] > 0.0 { [acc[0] / acc[3], acc[1] / acc[3], acc[2] / acc[3], acc[3].min(1.0)] } else { [0.0; 4] } +} + /// The x range where the convex polygon `corners` (in order) meets the line at height `y`, if it does. fn span(corners: &[(f64, f64); 4], y: f64) -> Option<(f64, f64)> { let mut range: Option<(f64, f64)> = None; @@ -203,25 +263,95 @@ impl BrickFill { continue; } layers += 1; - let mut q = tile.sample_area(&place, px, py); - let d = self.jitter.offsets(row, col); - // Without a drift a tile keeps its exact colour, also a float one past 1. - for ch in 0..3 { - if d[ch] != 0.0 { - q[ch] = (q[ch] + d[ch]).clamp(0.0, 1.0); - } - } - // Front to back: what is already in front covers this tile. - let k = q[3] * (1.0 - acc[3]); - for ch in 0..3 { - acc[ch] += q[ch] * k; - } - acc[3] += k; + blend_behind(&mut acc, tile.sample_area(&place, px, py), self.jitter.offsets(row, col)); } } - if acc[3] > 0.0 { - out[i] = [acc[0] / acc[3], acc[1] / acc[3], acc[2] / acc[3], acc[3].min(1.0)]; + out[i] = finish(acc); + i += 1; + } + } + out + } +} + +/// Cross Weave: a basket weave on a square grid of cells, each as wide as the mean of the tile's sides plus the spacing. +/// The cells alternate like a checkerboard between the tile lying flat and the tile turned a quarter (the origin cell), +/// every tile centred half its longer side right of and below its cell's corner, so a 40 x 30 tile leaves a 5 x 5 hole +/// at every 35 px grid point. Each tile is also turned half way or not at random (flat ones lie at 0° or 180°, upright +/// ones at 90° either way), as in the reference result with no colour randomness. +#[derive(Clone, Copy, Debug, PartialEq)] +pub struct CrossWeave { + /// Tile size as a fraction (0.1..1.25). + pub scale: f64, + /// Pixels between neighbouring tiles; negative overlaps them. + pub spacing: f64, + pub jitter: Jitter, +} + +impl CrossWeave { + /// Whether cell `(row, col)` holds the tile turned a quarter. + pub fn upright(row: i64, col: i64) -> bool { + (row + col).rem_euclid(2) == 0 + } + + /// The tiles of a `width` x `height` pattern woven over `rect` (row-major straight RGBA, transparent in the holes). + /// Later tiles (down, then right) lie over earlier ones where they overlap. + pub fn render(&self, tile: &Tile, width: u32, height: u32, rect: Rect) -> Vec<[f32; 4]> { + let len = rect.width() as usize * rect.height() as usize; + let mut out = vec![[0.0f32; 4]; len]; + // At the f32 precision the placement maps with, so the tile bounds here are the ones it samples. + let scale = if self.scale.is_finite() && self.scale > 0.0 { f64::from(self.scale as f32) } else { 1.0 }; + let (tw, th) = (f64::from(width) * scale, f64::from(height) * scale); + if len == 0 || tw <= 0.0 || th <= 0.0 { + return out; + } + let spacing = if self.spacing.is_finite() { self.spacing } else { 0.0 }; + // At least a pixel between cells, so every layout ends. + let pitch = ((tw + th) / 2.0 + spacing).max(1.0); + // A tile's centre lies this far right of and below its cell's corner, and reaches at most this far from it. + let reach = tw.max(th) / 2.0; + let centre = |i: i64| i as f64 * pitch + reach; + let placement = |row: i64, col: i64| { + let quarter = if Self::upright(row, col) { 90.0 } else { 0.0 }; + let angle: f64 = quarter + if tile_bits(self.jitter.seed, row, col) & 1 == 1 { 180.0 } else { 0.0 }; + let (c, s) = (angle.to_radians().cos(), angle.to_radians().sin()); + // The corner the tile's (0, 0) lands on once it is turned about its centre (y down, counter-clockwise). + let (hx, hy) = (-tw / 2.0, -th / 2.0); + let origin = (centre(col) + hx * c + hy * s, centre(row) - hx * s + hy * c); + Placement::anchored(origin, true, (0.0, 0.0), scale as f32, angle as f32) + }; + let mut i = 0; + for y in rect.y0..rect.y1 { + let py = f64::from(y) + 0.5; + // Rows and columns whose tiles can reach this pixel, the last drawn (topmost) first. + let top_row = (py / pitch).floor() as i64; + let low_row = ((py - 2.0 * reach) / pitch).ceil() as i64; + for x in rect.x0..rect.x1 { + let px = f64::from(x) + 0.5; + let right = (px / pitch).floor() as i64; + let left = ((px - 2.0 * reach) / pitch).ceil() as i64; + let mut acc = [0.0f32; 4]; + let mut layers = 0; + 'rows: for row in (low_row..=top_row).rev() { + for col in (left..=right).rev() { + if layers >= MAX_LAYERS || acc[3] >= 1.0 { + break 'rows; + } + // A flat tile reaches half its width across and half its height down; an upright one the other way. + let (ax, ay) = if Self::upright(row, col) { (th / 2.0, tw / 2.0) } else { (tw / 2.0, th / 2.0) }; + if (px - centre(col)).abs() > ax || (py - centre(row)).abs() > ay { + continue; + } + let place = placement(row, col); + let (u, v) = place.map(px, py); + if !(0.0..f64::from(width)).contains(&u) || !(0.0..f64::from(height)).contains(&v) { + continue; + } + layers += 1; + blend_behind(&mut acc, tile.sample_area(&place, px, py), self.jitter.offsets(row, col)); + } } + out[i] = finish(acc); i += 1; } } diff --git a/crates/engine-paint/src/cmd/fill_cmds.rs b/crates/engine-paint/src/cmd/fill_cmds.rs index bd5228cd88..f4d46ee4ad 100644 --- a/crates/engine-paint/src/cmd/fill_cmds.rs +++ b/crates/engine-paint/src/cmd/fill_cmds.rs @@ -212,9 +212,9 @@ fn script(p: &Value) -> Result> { /// The scripted pattern `script` laid out over `area`, with its values from `p` (each clamped to its range, the factory /// value when missing) and an optional whole-number `seed` for the per-tile randomness. fn scripted(p: &Value, script: &str, tile: &photocraft_compose::pattern::Tile, pat: &photocraft_doc::pattern::Pattern, area: Rect) -> Result> { - use photocraft_compose::scripted_pattern::{BrickFill, Jitter, controls}; - let controls = - controls(script, pat.width, pat.height).ok_or_else(|| bad(format!("the `{script}` script is not supported yet; only brickFill paints today")))?; + use photocraft_compose::scripted_pattern::{SUPPORTED, controls, render}; + let unsupported = || bad(format!("the `{script}` script is not supported yet; only {} paint today", SUPPORTED.join(" and "))); + let controls = controls(script, pat.width, pat.height).ok_or_else(unsupported)?; let mut values = std::collections::HashMap::new(); for c in &controls { let v = match p.get(c.key) { @@ -228,9 +228,7 @@ fn scripted(p: &Value, script: &str, tile: &photocraft_compose::pattern::Tile, p Some(v) => v.as_u64().ok_or_else(|| bad(format!("`seed` must be a whole number, not {v}")))?, }; let get = |k: &str| values.get(k).copied().unwrap_or_default(); - let jitter = Jitter { color: get("colorRandomness") as f32, brightness: get("brightnessRandomness") as f32, seed }; - let brick = BrickFill { scale: get("patternScale"), spacing: get("spacing"), offset: get("offsetBetweenRows"), angle: get("patternRotateAngle"), jitter }; - Ok(brick.render(tile, pat.width, pat.height, area)) + render(script, get, seed, tile, pat.width, pat.height, area).ok_or_else(unsupported) } /// The reference application refuses Fill on the Quick Mask with a colour-only blend mode, Preserve Transparency or diff --git a/crates/engine-paint/src/fill_script_brick_tests.rs b/crates/engine-paint/src/fill_script_brick_tests.rs index a541190710..b3d04899e4 100644 --- a/crates/engine-paint/src/fill_script_brick_tests.rs +++ b/crates/engine-paint/src/fill_script_brick_tests.rs @@ -1,6 +1,6 @@ //! #17428: Edit › Fill › Pattern with Script on lays the pattern out tile by tile. `edit.fill` takes `script` and the //! script's values; Brick Fill paints rows of whole tiles from the canvas origin with every second row shifted left by -//! the row offset (50 % of the tile width by default). An unknown script is an error, not a plain fill; the five +//! the row offset (50 % of the tile width by default). An unknown script is an error, not a plain fill; the //! listed scripts without a layout yet answer "not supported". use serde_json::{Value, json}; @@ -163,7 +163,7 @@ fn an_unknown_script_is_an_error_and_the_unbuilt_ones_are_unsupported() { let before = undo_label(&s); let err = s.execute("edit.fill", brick(json!({"script": "noSuchScript"}))).unwrap_err().to_string(); assert!(err.contains("unknown script"), "{err}"); - for script in ["crossWeave", "placeAlongPath", "randomFill", "spiral", "symmetryFill"] { + for script in ["placeAlongPath", "randomFill", "spiral", "symmetryFill"] { let err = s.execute("edit.fill", brick(json!({"script": script}))).unwrap_err().to_string(); assert!(err.contains("not supported"), "{script}: {err}"); } diff --git a/crates/engine-paint/src/fill_script_cross_weave_tests.rs b/crates/engine-paint/src/fill_script_cross_weave_tests.rs new file mode 100644 index 0000000000..ae63a4e309 --- /dev/null +++ b/crates/engine-paint/src/fill_script_cross_weave_tests.rs @@ -0,0 +1,257 @@ +//! #17429: the Cross Weave script of Edit › Fill › Pattern weaves the pattern tile in a basket weave. With a 40 x 30 +//! tile the cells are 35 px: flat and upright tiles alternate like a checkerboard (the origin cell upright) and leave a +//! transparent 5 x 5 hole at every grid point (x, y = 0, 35, 70, ...). Each tile is turned half way or not at random. + +use serde_json::{Value, json}; + +use crate::Session; + +const RED: [u8; 3] = [255, 0, 0]; +const BLUE: [u8; 3] = [0, 0, 255]; +const GREEN: [u8; 3] = [0, 255, 0]; + +/// The probe tile: 40 x 30, left half red, right half blue, the bottom-right 20 x 15 quarter green. +fn define_probe(s: &mut Session, mode: &str, depth: u32) { + s.execute("file.new", json!({"width": 40, "height": 30, "mode": mode, "depth": depth, "background": "white"})).unwrap(); + for (rect, color) in [([0, 0, 20, 30], "#ff0000"), ([20, 0, 20, 15], "#0000ff"), ([20, 15, 20, 15], "#00ff00")] { + s.execute("select.rect", json!({"x": rect[0], "y": rect[1], "width": rect[2], "height": rect[3]})).unwrap(); + s.execute("edit.fill", json!({"contents": "color", "color": color})).unwrap(); + } + s.execute("edit.definePattern", json!({"name": "probe", "rect": [0, 0, 40, 30]})).unwrap(); +} + +/// A 600 x 400 white document of `mode` / `depth` with an empty pixel layer on top (active), the probe defined. +fn session_in(mode: &str, depth: u32) -> Session { + let mut s = crate::session(); + define_probe(&mut s, mode, depth); + s.execute("file.new", json!({"width": 600, "height": 400, "mode": mode, "depth": depth, "background": "white"})).unwrap(); + s.execute("layer.new.layer", json!({})).unwrap(); + s +} + +fn session() -> Session { + session_in("rgb", 8) +} + +/// Cross Weave with both randomness values at 0 and `extra` values on top. +fn weave(extra: Value) -> Value { + let mut p = json!({"contents": "pattern", "pattern": "probe", "script": "crossWeave", "colorRandomness": 0, "brightnessRandomness": 0}); + for (k, v) in extra.as_object().into_iter().flatten() { + p[k] = v.clone(); + } + p +} + +fn pixel(s: &Session, x: i32, y: i32) -> [f32; 4] { + let st = s.active().unwrap(); + st.doc.layer(st.active_layer.unwrap()).unwrap().surface().unwrap().rgba(x, y) +} + +fn rgb8(px: [f32; 4]) -> [u8; 3] { + [0, 1, 2].map(|c| (px[c] * 255.0).round() as u8) +} + +fn undo_label(s: &Session) -> Option { + s.active().unwrap().history.undo_label().map(str::to_string) +} + +/// Whether the tile in the `w` x `h` box at (`x0`, `y0`) is red over half of its long side, split across the long side: +/// a flat tile is red in its left or right half, an upright one in its top or bottom half. +fn red_half(s: &Session, x0: i32, y0: i32, w: i32, h: i32) -> Option<&'static str> { + let red = |x: i32, y: i32| rgb8(pixel(s, x, y)) == RED; + let all = |xs: std::ops::Range, ys: std::ops::Range| xs.clone().all(|x| ys.clone().all(|y| red(x, y))); + let none = |xs: std::ops::Range, ys: std::ops::Range| xs.clone().all(|x| ys.clone().all(|y| !red(x, y))); + let (a, b) = + if w > h { ((x0..x0 + w / 2, y0..y0 + h), (x0 + w / 2..x0 + w, y0..y0 + h)) } else { ((x0..x0 + w, y0..y0 + h / 2), (x0..x0 + w, y0 + h / 2..y0 + h)) }; + if all(a.0.clone(), a.1.clone()) && none(b.0.clone(), b.1.clone()) { + Some("first") + } else if none(a.0, a.1) && all(b.0, b.1) { + Some("second") + } else { + None + } +} + +#[test] +fn cross_weave_leaves_a_transparent_hole_at_every_grid_point() { + let mut s = session(); + let r = s.execute("edit.fill", weave(json!({}))).unwrap(); + assert_eq!(r["script"], "crossWeave"); + for gy in (0..400).step_by(35) { + for gx in (0..600).step_by(35) { + // The 5 x 5 hole itself, and painted pixels right after it on both sides. + for (dx, dy) in [(0, 0), (4, 0), (0, 4), (4, 4), (2, 2)] { + if gx + dx < 600 && gy + dy < 400 { + assert_eq!(pixel(&s, gx + dx, gy + dy)[3], 0.0, "hole at ({}, {})", gx + dx, gy + dy); + } + } + for (x, y) in [(gx + 5, gy + 2), (gx + 2, gy + 5)] { + if x < 600 && y < 400 { + assert!(pixel(&s, x, y)[3] > 0.99, "painted beside the hole at ({x}, {y})"); + } + } + } + } + assert_eq!(pixel(&s, 37, 37)[3], 0.0, "the measured hole sample"); + assert_eq!(undo_label(&s).as_deref(), Some("Fill")); +} + +#[test] +fn flat_and_upright_tiles_alternate_like_a_checkerboard() { + let mut s = session(); + s.execute("edit.fill", weave(json!({}))).unwrap(); + let (mut turned, mut upright_turned) = (std::collections::HashSet::new(), std::collections::HashSet::new()); + for row in 0..10 { + for col in 0..16 { + let (x, y) = (35 * col, 35 * row); + let (upright, side) = if (row + col) % 2 == 0 { + // Upright, 30 x 40: from 5 px right of the cell corner, down into the next cell. + (true, red_half(&s, x + 5, y, 30, 40)) + } else { + // Flat, 40 x 30: from the cell corner, 5 px below it, into the next cell. + (false, red_half(&s, x, y + 5, 40, 30)) + }; + let side = side.unwrap_or_else(|| panic!("cell ({row}, {col}) holds a whole {} tile", if upright { "upright" } else { "flat" })); + if upright { &mut upright_turned } else { &mut turned }.insert(side); + } + } + // Both ways round occur among flat and among upright tiles (the half turn is random per tile). + assert_eq!(turned.len(), 2, "flat tiles at 0° and 180°"); + assert_eq!(upright_turned.len(), 2, "upright tiles at 90° both ways"); + // The other colours sit in the tile's other half: blue and green in the origin cell's upright tile. + let other: Vec<[u8; 3]> = [(10, 2), (30, 2), (10, 37), (30, 37)].iter().map(|&(x, y)| rgb8(pixel(&s, x, y))).collect(); + assert!(other.contains(&BLUE) && other.contains(&GREEN), "{other:?}"); +} + +#[test] +fn the_weave_differs_from_the_plain_and_the_brick_fill() { + let mut plain = session(); + plain.execute("edit.fill", json!({"contents": "pattern", "pattern": "probe"})).unwrap(); + let mut brick = session(); + brick.execute("edit.fill", weave(json!({"script": "brickFill"}))).unwrap(); + let mut woven = session(); + woven.execute("edit.fill", weave(json!({}))).unwrap(); + for other in [&plain, &brick] { + assert!(pixel(other, 2, 2)[3] > 0.99, "the other fills cover the origin"); + } + assert_eq!(pixel(&woven, 2, 2)[3], 0.0, "the weave leaves its hole there"); +} + +#[test] +fn the_same_seed_weaves_the_same_tiles() { + let mut a = session(); + a.execute("edit.fill", weave(json!({"seed": 7}))).unwrap(); + let mut b = session(); + b.execute("edit.fill", weave(json!({"seed": 7}))).unwrap(); + let mut c = session(); + c.execute("edit.fill", weave(json!({"seed": 8}))).unwrap(); + let samples = |s: &Session| (0..10).flat_map(|r| (0..16).map(move |c| (35 * c + 15, 35 * r + 20))).map(|(x, y)| rgb8(pixel(s, x, y))).collect::>(); + assert_eq!(samples(&a), samples(&b)); + assert_ne!(samples(&a), samples(&c), "another seed turns other tiles"); +} + +#[test] +fn spacing_and_scale_move_the_tiles() { + // Spacing 10 leaves a 10 px gap between the origin cell's upright tile (x 5-34) and the flat one beside it. + let mut s = session(); + s.execute("edit.fill", weave(json!({"spacing": 10}))).unwrap(); + assert!(pixel(&s, 34, 20)[3] > 0.99, "the upright tile"); + assert_eq!(pixel(&s, 40, 20)[3], 0.0, "the gap"); + assert!(pixel(&s, 45, 20)[3] > 0.99, "the flat tile after the gap"); + // Half the scale halves the tile and the cell: 2.5 px holes on a 17.5 px grid, so (35, 35) is still a hole. + let mut s = session(); + s.execute("edit.fill", weave(json!({"patternScale": 0.5}))).unwrap(); + assert_eq!(pixel(&s, 35, 35)[3], 0.0); + assert!(pixel(&s, 38, 3)[3] > 0.99, "a full-size weave has a hole here, the half-size one a tile"); + // Overlapping tiles close the holes. + let mut s = session(); + s.execute("edit.fill", weave(json!({"spacing": -10}))).unwrap(); + for (x, y) in [(2, 2), (37, 37), (72, 37)] { + assert!(pixel(&s, x, y)[3] > 0.99, "no hole at ({x}, {y})"); + } +} + +#[test] +fn randomness_varies_tiles_only_above_zero() { + let mut drift = session(); + drift.execute("edit.fill", weave(json!({"colorRandomness": 0.5, "brightnessRandomness": 0.5}))).unwrap(); + let mut exact = session(); + exact.execute("edit.fill", weave(json!({}))).unwrap(); + let colours = + |s: &Session| (0..400).step_by(7).flat_map(|y| (0..600).step_by(7).map(move |x| (x, y))).map(|(x, y)| rgb8(pixel(s, x, y))).collect::>(); + let pure = [RED, BLUE, GREEN, [0, 0, 0]]; + assert!(colours(&exact).iter().all(|c| pure.contains(c)), "at 0 every tile keeps the pattern's colours"); + assert!(colours(&drift).iter().any(|c| !pure.contains(c)), "above 0 the tiles drift"); +} + +#[test] +fn the_fill_stays_in_the_selection_with_mode_and_opacity() { + let mut s = session(); + s.execute("select.rect", json!({"x": 0, "y": 0, "width": 100, "height": 50})).unwrap(); + s.execute("edit.fill", weave(json!({"opacity": 50}))).unwrap(); + let inside = pixel(&s, 10, 10); + assert!((inside[3] - 0.5).abs() < 0.01, "half opacity: {inside:?}"); + assert_eq!(pixel(&s, 150, 10)[3], 0.0, "outside the selection"); + assert_eq!(pixel(&s, 10, 80)[3], 0.0, "below the selection"); + assert_eq!(undo_label(&s).as_deref(), Some("Fill")); + s.execute("edit.undo", json!({})).unwrap(); + assert_eq!(pixel(&s, 10, 10)[3], 0.0, "one history state"); + // Multiply over red paint keeps red only where the weave is red or transparent. + let mut s = session(); + s.execute("edit.fill", json!({"contents": "color", "color": "#ff0000"})).unwrap(); + s.execute("edit.fill", weave(json!({"mode": "multiply"}))).unwrap(); + assert_eq!(rgb8(pixel(&s, 2, 2)), RED, "the hole leaves the red paint"); + let blue_or_green = (0..600).step_by(5).any(|x| rgb8(pixel(&s, x, 10)) == [0, 0, 0]); + assert!(blue_or_green, "multiplying red by blue or green gives black"); +} + +#[test] +fn bad_values_are_errors_and_extreme_ones_never_hang_or_panic() { + let mut s = session(); + for bad in [json!({"patternScale": "big"}), json!({"spacing": [1]}), json!({"seed": -1}), json!({"colorRandomness": true})] { + assert!(s.execute("edit.fill", weave(bad.clone())).is_err(), "{bad}"); + } + assert_eq!(pixel(&s, 10, 10)[3], 0.0, "nothing filled"); + for extreme in [ + json!({"patternScale": 1e9}), + json!({"patternScale": -5}), + json!({"spacing": -1e12}), + json!({"spacing": 1e12}), + json!({"colorRandomness": 1e9, "brightnessRandomness": -1e9}), + json!({"seed": u64::MAX}), + // Offset and angle belong to Brick Fill; Cross Weave ignores them. + json!({"offsetBetweenRows": 75, "patternRotateAngle": 45}), + ] { + let mut s = session(); + s.execute("edit.fill", weave(extreme.clone())).unwrap_or_else(|e| panic!("{extreme}: {e}")); + } +} + +#[test] +fn a_long_thin_tile_reaches_far_from_its_centre() { + // A 4000 x 4 tile at the largest overlap: 2000 px cells, each tile reaching 2000 px from its centre. The flat tile + // of cell (-1, 0) lies along the top edge, the upright one of cell (-1, -1) along the left edge. + let mut s = crate::session(); + s.execute("file.new", json!({"width": 4000, "height": 4, "background": "white"})).unwrap(); + s.execute("edit.fill", json!({"contents": "color", "color": "#ff0000"})).unwrap(); + s.execute("edit.definePattern", json!({"name": "bar", "rect": [0, 0, 4000, 4]})).unwrap(); + s.execute("file.new", json!({"width": 300, "height": 200, "background": "white"})).unwrap(); + s.execute("layer.new.layer", json!({})).unwrap(); + s.execute("edit.fill", weave(json!({"pattern": "bar", "spacing": -2}))).unwrap(); + for (x, y) in [(150, 1), (299, 0), (1, 100), (0, 199)] { + let px = pixel(&s, x, y); + assert!(px[3] > 0.99 && rgb8(px) == RED, "({x}, {y}): {px:?}"); + } + assert_eq!(pixel(&s, 150, 100)[3], 0.0, "between the tiles"); +} + +#[test] +fn cross_weave_runs_in_every_mode_and_depth() { + for (mode, depth) in [("rgb", 8), ("rgb", 16), ("rgb", 32), ("cmyk", 8), ("lab", 8), ("gray", 8), ("gray", 16)] { + let mut s = session_in(mode, depth); + s.execute("edit.fill", weave(json!({}))).unwrap_or_else(|e| panic!("{mode}/{depth}: {e}")); + assert_eq!(pixel(&s, 37, 37)[3], 0.0, "{mode}/{depth}: hole"); + assert!(pixel(&s, 20, 20)[3] > 0.99, "{mode}/{depth}: painted"); + assert_eq!(undo_label(&s).as_deref(), Some("Fill"), "{mode}/{depth}"); + } +} diff --git a/crates/engine-paint/src/lib.rs b/crates/engine-paint/src/lib.rs index 21025b6ed9..2645cfe41e 100644 --- a/crates/engine-paint/src/lib.rs +++ b/crates/engine-paint/src/lib.rs @@ -48,6 +48,8 @@ mod fill_quick_mask_refusals_tests; #[cfg(test)] mod fill_script_brick_tests; #[cfg(test)] +mod fill_script_cross_weave_tests; +#[cfg(test)] mod mixer_indexed_bitmap_tests; #[cfg(test)] mod mixer_toggle_commands_tests; diff --git a/crates/ui-egui/src/dialogs/fill_script_ui.rs b/crates/ui-egui/src/dialogs/fill_script_ui.rs index 4d042d0eff..77ecf122bc 100644 --- a/crates/ui-egui/src/dialogs/fill_script_ui.rs +++ b/crates/ui-egui/src/dialogs/fill_script_ui.rs @@ -11,7 +11,7 @@ use craft::ui::runtime::env::Label; use craft::ui::runtime::memory::{MemoryStage, SaveKey}; use craft::ui::sections::{DialogRole, FooterButton}; use craft::ui::value_drag::SliderScale; -use photocraft_compose::scripted_pattern::{BrickFill, Control, Jitter, SCRIPTS, controls}; +use photocraft_compose::scripted_pattern::{Control, SCRIPTS, controls, render}; use serde_json::{Map, Value, json}; use crate::PhotocraftApp; @@ -236,7 +236,7 @@ pub(crate) fn take(app: &mut PhotocraftApp, ctx: &egui::Context) { if let Some(held) = app.framework.captured.get_mut(&key) { held["lastPreset"] = json!(now); } - let picture = pattern.and_then(|p| preview(ctx, id, &p, &shown, &controls)); + let picture = pattern.and_then(|p| preview(ctx, id, script_of(&key), &p, &shown, &controls)); if let Some(dialog) = app.framework.dialogs.get_mut_by_id::(id) { dialog.set_preview(Some(match picture { Some(texture) => PreviewState::Ready(egui::load::SizedTexture::from_handle(&texture)), @@ -246,9 +246,16 @@ pub(crate) fn take(app: &mut PhotocraftApp, ctx: &egui::Context) { } } -/// The preview of the values `f`: the script laid out over a sample area with pattern `p`, on white. The texture is -/// kept per dialog and drawn again only when the values or the pattern change. -fn preview(ctx: &egui::Context, id: DialogId, p: &photocraft_doc::Pattern, f: &DialogFields, controls: &[Control]) -> Option { +/// The preview of the values `f`: `script` laid out over a sample area with pattern `p`, on white. The texture is kept +/// per dialog and drawn again only when the values or the pattern change. +fn preview( + ctx: &egui::Context, + id: DialogId, + script: &str, + p: &photocraft_doc::Pattern, + f: &DialogFields, + controls: &[Control], +) -> Option { let values: Vec = controls.iter().map(|c| c.clamp(f.number(c.key).unwrap_or(c.default))).collect(); let stamp = format!("{}:{values:?}", p.id); let cache = egui::Id::unique(("fill-script-preview", id.value())); @@ -259,9 +266,7 @@ fn preview(ctx: &egui::Context, id: DialogId, p: &photocraft_doc::Pattern, f: &D } let tile = photocraft_compose::pattern::Tile::new(p)?; let get = |k: &str| controls.iter().zip(&values).find(|(c, _)| c.key == k).map_or(0.0, |(_, v)| *v); - let jitter = Jitter { color: get("colorRandomness") as f32, brightness: get("brightnessRandomness") as f32, seed: 1 }; - let brick = BrickFill { scale: get("patternScale"), spacing: get("spacing"), offset: get("offsetBetweenRows"), angle: get("patternRotateAngle"), jitter }; - let px = brick.render(&tile, p.width, p.height, photocraft_geom::Rect::new(0, 0, PREVIEW as i32, PREVIEW as i32)); + let px = render(script, get, 1, &tile, p.width, p.height, photocraft_geom::Rect::new(0, 0, PREVIEW as i32, PREVIEW as i32))?; let level = |v: f32| (v.clamp(0.0, 1.0) * 255.0).round() as u8; let rgba: Vec = px.iter().flat_map(|q| [0, 1, 2].map(|c| level(q[c] * q[3] + (1.0 - q[3]))).into_iter().chain([255])).collect(); let image = egui::ColorImage::from_rgba_unmultiplied([PREVIEW as usize, PREVIEW as usize], &rgba); diff --git a/crates/ui-egui/src/dialogs/fill_script_ui_tests.rs b/crates/ui-egui/src/dialogs/fill_script_ui_tests.rs index c689e76018..4fda381962 100644 --- a/crates/ui-egui/src/dialogs/fill_script_ui_tests.rs +++ b/crates/ui-egui/src/dialogs/fill_script_ui_tests.rs @@ -1,6 +1,7 @@ //! #17428: Fill › Pattern has a Script check box and list (greyed until ticked); OK with Script on opens the script's own //! dialog and only that dialog's OK fills. Preset › Default sets the factory values, a changed value turns Preset to -//! Custom, Reset puts back the opening values, and the values are remembered per script. +//! Custom, Reset puts back the opening values, and the values are remembered per script. Cross Weave +//! (#17429) opens its own four values. use craft::ui::patterns::form_dialogs::HostedParamDialog; use egui::accesskit::Role; @@ -207,3 +208,52 @@ fn a_typed_value_past_the_range_is_clamped_with_the_range_alert() { let script = dialogs.iter().find(|d| d.key.as_deref() == Some("edit.fill.script.brickFill")).map(|d| d.id).unwrap(); assert_eq!(h.state().framework.dialogs.get_by_id::(script).unwrap().fields().number("patternScale"), Some(1.25)); } + +#[test] +fn cross_weave_opens_its_dialog_with_its_four_values() { + let mut app = app(); + let before = past(&app); + fill_with_script(&mut app, "crossWeave"); + assert_eq!(top_key(&app).as_deref(), Some("edit.fill.script.crossWeave")); + for (key, default) in [("patternScale", 1.0), ("spacing", 0.0), ("colorRandomness", 0.05), ("brightnessRandomness", 0.1)] { + assert_eq!(field(&app, key), Some(default), "{key}"); + } + let h = harness(app); + assert!(h.query_all_by_role(Role::Dialog).any(|n| n.accesskit_node().label().as_deref() == Some("Cross Weave")), "titled with the script's name"); + // Each value's field and its range, top to bottom; Brick Fill's row offset and angle are not there. + let fields: Vec<(String, Option, Option)> = h + .query_all_by_role(Role::SpinButton) + .filter_map(|n| { + let node = n.accesskit_node(); + Some((node.label()?.to_string(), node.min_numeric_value(), node.max_numeric_value())) + }) + .collect(); + let labels: Vec<&str> = fields.iter().map(|(l, _, _)| l.as_str()).collect(); + let order = ["Pattern Scale", "Spacing", "Color randomness", "Brightness randomness"]; + let at: Vec> = order.iter().map(|o| labels.iter().position(|l| l.starts_with(o))).collect(); + assert!(at.iter().all(Option::is_some) && at.windows(2).all(|w| w[0] < w[1]), "{labels:?}"); + assert!(!labels.iter().any(|l| l.starts_with("Offset between rows") || l.starts_with("Pattern rotate angle")), "{labels:?}"); + let range = |name: &str| fields.iter().find(|(l, _, _)| l.starts_with(name)).map(|(_, lo, hi)| (*lo, *hi)); + assert_eq!(range("Pattern Scale"), Some((Some(0.1), Some(1.25)))); + assert_eq!(range("Color randomness"), Some((Some(0.0), Some(1.0)))); + assert_eq!(range("Brightness randomness"), Some((Some(0.0), Some(1.0)))); + let spacing = range("Spacing").unwrap(); + assert!(spacing.0.is_some_and(|lo| lo < 0.0) && spacing.1.is_some_and(|hi| hi > 0.0), "tiles may overlap or stand apart: {spacing:?}"); + // OK fills once, as "Fill". + let mut app = h.into_state(); + let top = newest(&app); + confirm(&mut app, top); + assert_eq!(past(&app), before + 1); + assert_eq!(app.session.active().unwrap().history.undo_label(), Some("Fill")); +} + +#[test] +fn cancel_in_cross_weave_fills_nothing() { + let mut app = app(); + let before = past(&app); + fill_with_script(&mut app, "crossWeave"); + let top = newest(&app); + cancel(&mut app, top); + assert_eq!(open_count(&app), 0); + assert_eq!(past(&app), before); +} From c7c89496a38a06913c97fe4a917629316d56570a Mon Sep 17 00:00:00 2001 From: David Mann Date: Mon, 30 Nov 2026 20:59:56 +0100 Subject: [PATCH 25/27] Fill: no canvas-sized buffers when filling Multichannel inks Normal blends linearly, so the fill is turned into density and the channel is filled as it is, sharing solid tiles. Other modes turn the channel into tone and back one tile at a time. Co-Authored-By: Claude Opus 5.5 --- crates/engine-paint/src/cmd/fill_cmds.rs | 27 ++++++++++++++++--- .../cmd/fill_cmds/multichannel_fill_tests.rs | 20 ++++++++++++++ 2 files changed, 43 insertions(+), 4 deletions(-) diff --git a/crates/engine-paint/src/cmd/fill_cmds.rs b/crates/engine-paint/src/cmd/fill_cmds.rs index 65b5dc6cde..af85bd6c5a 100644 --- a/crates/engine-paint/src/cmd/fill_cmds.rs +++ b/crates/engine-paint/src/cmd/fill_cmds.rs @@ -228,10 +228,7 @@ pub fn fill(s: &mut Session, p: &Value) -> Result { let white = Source::Color([1.0; 4]); for (k, surf) in photocraft_engine_core::multichannel_cmds::inks_mut(doc).enumerate() { let src = if k > 0 && matches!(source, Source::Pixels(..)) { &white } else { &source }; - // An ink channel stores density: blend over its tone, then back to density. - invert(surf, area)?; - blend_into(surf, area, src, sel.as_ref(), blend)?; - invert(surf, area)?; + ink_fill(surf, area, src, sel.as_ref(), blend)?; } return Ok(()); } @@ -262,6 +259,28 @@ fn multichannel_grey(s: &Session, c: [f32; 4]) -> [f32; 4] { [g, g, g, c[3]] } +/// Blends `src` into an ink channel, which stores density, as if over its tone. Normal blends linearly, so the +/// source is turned into density instead and the channel is filled as it is, solid tiles shared. Other modes turn +/// the channel into tone and back one tile at a time. +fn ink_fill(surf: &mut photocraft_raster::Surface, area: Rect, src: &Source, sel: Option<&photocraft_raster::Surface>, blend: Blend) -> Result<()> { + let density = |c: [f32; 4]| [1.0 - c[0], 1.0 - c[1], 1.0 - c[2], c[3]]; + match src { + Source::Color(c) if blend.mode == BlendMode::Normal => blend_into(surf, area, &Source::Color(density(*c)), sel, blend), + Source::Pixels(r, px) if blend.mode == BlendMode::Normal => { + blend_into(surf, area, &Source::Pixels(*r, px.iter().map(|c| density(*c)).collect()), sel, blend) + } + _ => { + for tc in area.tiles() { + let r = tc.rect().intersect(&area); + invert(surf, r)?; + blend_into(surf, r, src, sel, blend)?; + invert(surf, r)?; + } + Ok(()) + } + } +} + /// Inverts `area` of a channel (density to tone and back). fn invert(surf: &mut photocraft_raster::Surface, area: Rect) -> Result<()> { let mut v = crate::allocation::read_region(surf, area, "filling a Multichannel channel")?; diff --git a/crates/engine-paint/src/cmd/fill_cmds/multichannel_fill_tests.rs b/crates/engine-paint/src/cmd/fill_cmds/multichannel_fill_tests.rs index d5625620ca..9c082032c4 100644 --- a/crates/engine-paint/src/cmd/fill_cmds/multichannel_fill_tests.rs +++ b/crates/engine-paint/src/cmd/fill_cmds/multichannel_fill_tests.rs @@ -145,3 +145,23 @@ fn history_and_content_aware_refuse_without_changing_anything() { assert_eq!((tones(&s, RED), tones(&s, BLUE), s.active().unwrap().history.past_len()), before, "{contents}"); } } + +#[test] +fn non_normal_modes_blend_over_the_tone_across_tiles() { + // Wider than a tile, so the other modes' tile-by-tile tone pass meets a tile border. + let w = TILE_SIZE * 2 + 40; + let mut s = crate::session(); + s.execute("file.new", json!({"width": w, "height": 16, "mode": "rgb", "depth": 8, "background": "white"})).unwrap(); + s.execute("image.mode.multichannel", json!({})).unwrap(); + s.execute("select.rect", json!({"x": 10, "y": 0, "width": w - 20, "height": 16})).unwrap(); + s.execute("edit.fill", json!({"contents": "gray", "mode": "multiply"})).unwrap(); + let st = s.active().unwrap(); + for x in [5, 20, TILE_SIZE - 1, TILE_SIZE, w - 15, w - 5] { + let inside = (10..w - 10).contains(&x); + for c in st.doc.channels.iter().filter(|c| c.spot.is_some()) { + let tone = ((1.0 - c.surface.read_region(Rect::new(x, 8, x + 1, 9))[0]) * 255.0).round() as i32; + let want = if inside { 128 } else { 255 }; + assert!((tone - want).abs() <= 1, "x {x}: tone {tone}, want {want}"); + } + } +} From 67f8cdb20241cf41150eaabe77a6abfec9f88865 Mon Sep 17 00:00:00 2001 From: David Mann Date: Mon, 30 Nov 2026 22:27:43 +0100 Subject: [PATCH 26/27] Fill scripts: tiles clear at a pixel do not use up the layer limit (#17429) A tile that covers a pixel but is transparent there counted toward the 1024-layer cap, so with a mostly clear pattern at the largest overlap the cap ran out before the tiles that show at that pixel were reached and the pixel stayed empty. Only visible samples count now; a separate, larger visit cap keeps the work per pixel bounded. Applies to Brick Fill and Cross Weave alike. Co-Authored-By: Claude Opus 5.5 --- crates/compose/src/scripted_pattern.rs | 29 ++++++++++++++----- .../src/fill_script_cross_weave_tests.rs | 20 +++++++++++++ 2 files changed, 42 insertions(+), 7 deletions(-) diff --git a/crates/compose/src/scripted_pattern.rs b/crates/compose/src/scripted_pattern.rs index 2e40e1da93..a0263160e2 100644 --- a/crates/compose/src/scripted_pattern.rs +++ b/crates/compose/src/scripted_pattern.rs @@ -156,9 +156,14 @@ pub struct BrickFill { } /// Most tiles composited into one pixel, front to back: bounds the work of extreme overlaps. Only a pixel whose -/// frontmost tiles all let some of it through ever reaches it; an opaque tile ends the pixel at once. +/// frontmost tiles all let some of it through ever reaches it; an opaque tile ends the pixel at once. A tile that is +/// transparent at the pixel does not count, so it cannot use up the limit before the tiles that show there. const MAX_LAYERS: usize = 1024; +/// Most tiles looked at for one pixel, transparent there or not: the work bound when many overlapping tiles are clear +/// at that pixel (a mostly transparent pattern at the largest overlap). +const MAX_VISITS: usize = 16 * MAX_LAYERS; + /// A repeatable value for tile `(row, col)` from `seed`, independent of the colour drift. fn tile_bits(seed: u64, row: i64, col: i64) -> u64 { let mut z = (seed ^ 0xD6E8_FEB8_6659_FD93) @@ -246,7 +251,7 @@ impl BrickFill { for x in rect.x0..rect.x1 { let px = f64::from(x) + 0.5; let mut acc = [0.0f32; 4]; - let mut layers = 0; + let (mut layers, mut visits) = (0, 0); 'rows: for row in (low_row..=top_row).rev() { // Only the tiles of this row whose centre lies in the turned rectangle around the pixel cover it. let Some((lo, hi)) = span(&corners, row as f64 * pitch_y + th / 2.0 - py) else { continue }; @@ -254,7 +259,7 @@ impl BrickFill { let right = ((px + hi + row_shift - tw / 2.0) / pitch_x).floor() as i64; let left = ((px + lo + row_shift - tw / 2.0) / pitch_x).ceil() as i64; for col in (left..=right).rev() { - if layers >= MAX_LAYERS || acc[3] >= 1.0 { + if layers >= MAX_LAYERS || visits >= MAX_VISITS || acc[3] >= 1.0 { break 'rows; } let place = placement(row, col); @@ -262,8 +267,13 @@ impl BrickFill { if !(0.0..f64::from(width)).contains(&u) || !(0.0..f64::from(height)).contains(&v) { continue; } + visits += 1; + let q = tile.sample_area(&place, px, py); + if q[3] <= 0.0 { + continue; + } layers += 1; - blend_behind(&mut acc, tile.sample_area(&place, px, py), self.jitter.offsets(row, col)); + blend_behind(&mut acc, q, self.jitter.offsets(row, col)); } } out[i] = finish(acc); @@ -331,10 +341,10 @@ impl CrossWeave { let right = (px / pitch).floor() as i64; let left = ((px - 2.0 * reach) / pitch).ceil() as i64; let mut acc = [0.0f32; 4]; - let mut layers = 0; + let (mut layers, mut visits) = (0, 0); 'rows: for row in (low_row..=top_row).rev() { for col in (left..=right).rev() { - if layers >= MAX_LAYERS || acc[3] >= 1.0 { + if layers >= MAX_LAYERS || visits >= MAX_VISITS || acc[3] >= 1.0 { break 'rows; } // A flat tile reaches half its width across and half its height down; an upright one the other way. @@ -347,8 +357,13 @@ impl CrossWeave { if !(0.0..f64::from(width)).contains(&u) || !(0.0..f64::from(height)).contains(&v) { continue; } + visits += 1; + let q = tile.sample_area(&place, px, py); + if q[3] <= 0.0 { + continue; + } layers += 1; - blend_behind(&mut acc, tile.sample_area(&place, px, py), self.jitter.offsets(row, col)); + blend_behind(&mut acc, q, self.jitter.offsets(row, col)); } } out[i] = finish(acc); diff --git a/crates/engine-paint/src/fill_script_cross_weave_tests.rs b/crates/engine-paint/src/fill_script_cross_weave_tests.rs index ae63a4e309..6eb091b61d 100644 --- a/crates/engine-paint/src/fill_script_cross_weave_tests.rs +++ b/crates/engine-paint/src/fill_script_cross_weave_tests.rs @@ -255,3 +255,23 @@ fn cross_weave_runs_in_every_mode_and_depth() { assert_eq!(undo_label(&s).as_deref(), Some("Fill"), "{mode}/{depth}"); } } + +#[test] +fn tiles_clear_at_a_pixel_do_not_hide_the_ones_that_show_there() { + // A clear 100 x 100 tile with an opaque 10 x 10 middle, at the largest overlap (2 px between tiles): about 1100 + // tiles in front are clear at (0, 0) before the ones whose middle covers it. + let mut s = crate::session(); + s.execute("file.new", json!({"width": 100, "height": 100, "background": "transparent"})).unwrap(); + s.execute("select.rect", json!({"x": 45, "y": 45, "width": 10, "height": 10})).unwrap(); + s.execute("edit.fill", json!({"contents": "color", "color": "#ff0000"})).unwrap(); + s.execute("edit.definePattern", json!({"name": "dot", "rect": [0, 0, 100, 100]})).unwrap(); + s.execute("file.new", json!({"width": 40, "height": 40, "background": "white"})).unwrap(); + s.execute("layer.new.layer", json!({})).unwrap(); + // Brick Fill lays its tiles out the same way and must find them too. + for script in ["crossWeave", "brickFill"] { + s.execute("edit.fill", weave(json!({"script": script, "pattern": "dot", "spacing": -98}))).unwrap(); + let px = pixel(&s, 0, 0); + assert!(px[3] > 0.99 && rgb8(px) == RED, "{script}: {px:?}"); + s.execute("edit.undo", json!({})).unwrap(); + } +} From 7cbe48c80f28190341a70d929d970ecfc6571019 Mon Sep 17 00:00:00 2001 From: Elvis33LE <67311580+Elvis33LE@users.noreply.github.com> Date: Mon, 30 Nov 2026 22:46:01 +0100 Subject: [PATCH 27/27] CI: Split the panic hunt and cap Linux Rayon pools (#18439) Run the existing panic hunt as eight ignored Nextest cases in one test binary, preserving every command and input, the harness self-test, and the 180-second deadline per test process. Set RAYON_NUM_THREADS=4 for the Linux gate and no-HEIF job. That limits the default global Rayon pool per process; it does not cap total Nextest concurrency or demonstrate that cluster contention or OOMs are fixed. The eight cases and self-test passed in hosted Ubuntu and Windows on the earlier merge preview and in the scoped current-main Linux validation. The latter used Rayon two. --- .github/workflows/ci.yml | 2 ++ crates/engine/tests/panic_hunt.rs | 33 ++++++++++++++++++++++++++----- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 47c0dc60c0..922fa9b659 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -206,6 +206,7 @@ jobs: CARGO_PROFILE_TEST_STRIP=symbols PHOTOCRAFT_CI_EXCLUDE=${{ needs.platforms.outputs.linux_skip }} PHOTOCRAFT_CORPUS_TESTS=1 + RAYON_NUM_THREADS=4 timeout-minutes: 100 cache-workspace-crates: true lint-cache: false @@ -347,6 +348,7 @@ jobs: CARGO_NET_RETRY: 10 CARGO_PROFILE_DEV_DEBUG: "0" CARGO_PROFILE_TEST_STRIP: symbols + RAYON_NUM_THREADS: "4" steps: - name: Harden runner uses: step-security/harden-runner@1d88384fd173af6ecb012dfd0264a306b711241a # v2.22.4 diff --git a/crates/engine/tests/panic_hunt.rs b/crates/engine/tests/panic_hunt.rs index 91435bea1a..b0708f25d5 100644 --- a/crates/engine/tests/panic_hunt.rs +++ b/crates/engine/tests/panic_hunt.rs @@ -61,9 +61,10 @@ fn run_guarded(id: &str, p: &Value) -> Result<(), String> { } } -#[test] -#[ignore = "slow full-registry fuzz; run with --ignored"] -fn no_command_panics_or_hangs_on_adversarial_params() { +const SHARDS: usize = 8; + +fn run_panic_hunt_shard(shard: usize) { + assert!(shard < SHARDS); let params: Vec = vec![ json!({}), json!({"x": -9, "y": -9, "radius": 0, "amount": 0, "angle": 0, "opacity": 0, "scale": 0, "levels": 0, "tolerance": 0, "gamma": 0, "layer": 999999, "channel": 999, "index": 999999, "count": 0}), @@ -76,7 +77,10 @@ fn no_command_panics_or_hangs_on_adversarial_params() { json!({"subtractPoints": "none", "order": ["-"], "labMinimum": [0, 0, 0], "labMaximum": [100, 0, 0]}), ]; let mut bad: Vec = Vec::new(); - for spec in command_specs() { + for (idx, spec) in command_specs().iter().enumerate() { + if idx % SHARDS != shard { + continue; + } for p in ¶ms { // Print and Print One Copy reach real printers (lp, or the Windows driver): fuzz them // as dry runs so the hunt never prints a page. @@ -93,9 +97,28 @@ fn no_command_panics_or_hangs_on_adversarial_params() { } } } - assert!(bad.is_empty(), "{} commands panicked:\n{}", bad.len(), bad.join("\n")); + assert!(bad.is_empty(), "shard {shard}: {} commands panicked:\n{}", bad.len(), bad.join("\n")); } +macro_rules! panic_hunt_shard { + ($name:ident, $shard:expr) => { + #[test] + #[ignore = "slow full-registry fuzz; run with --ignored"] + fn $name() { + run_panic_hunt_shard($shard); + } + }; +} + +panic_hunt_shard!(panic_hunt_shard_0, 0); +panic_hunt_shard!(panic_hunt_shard_1, 1); +panic_hunt_shard!(panic_hunt_shard_2, 2); +panic_hunt_shard!(panic_hunt_shard_3, 3); +panic_hunt_shard!(panic_hunt_shard_4, 4); +panic_hunt_shard!(panic_hunt_shard_5, 5); +panic_hunt_shard!(panic_hunt_shard_6, 6); +panic_hunt_shard!(panic_hunt_shard_7, 7); + /// #4982: a panic the code under test contains still fails the run; a graceful `Err` does not. #[test] fn contained_panics_count_and_graceful_errors_do_not() {