From eba0b09fcb49fcc30ac1c5fffaa0e7d6dc5a75eb Mon Sep 17 00:00:00 2001 From: yoriswind Date: Sun, 15 Nov 2026 07:06:47 -0800 Subject: [PATCH 1/4] Reset Mixer Brush to its measured per-tool defaults --- crates/ui-egui/src/canvas/paint_mouse.rs | 15 +- crates/ui-egui/tests/it/main.rs | 1 + .../ui-egui/tests/it/mixer_reset_defaults.rs | 212 ++++++++++++++++++ 3 files changed, 227 insertions(+), 1 deletion(-) create mode 100644 crates/ui-egui/tests/it/mixer_reset_defaults.rs diff --git a/crates/ui-egui/src/canvas/paint_mouse.rs b/crates/ui-egui/src/canvas/paint_mouse.rs index cb10304723..461823461a 100644 --- a/crates/ui-egui/src/canvas/paint_mouse.rs +++ b/crates/ui-egui/src/canvas/paint_mouse.rs @@ -90,6 +90,8 @@ fn session_fields(current: &BrushSettings, brush: &BrushSettings) -> BrushSettin /// The Brush tool's tip after Reset Tool, as the reference measures it (#11810): size, hardness /// and spacing of a 13 px soft round at 25 % spacing. const BRUSH_TOOL_TIP: (f32, f32, f32) = (13.0, 0.0, 0.25); +/// The Mixer Brush's tip after Reset Tool (#11945): a 35 px soft round at 25 % spacing. +const MIXER_BRUSH_TIP: (f32, f32, f32) = (35.0, 0.0, 0.25); /// The Eraser's tip after Reset Tool (#11936): a 13 px hard round at 25 % spacing, with no /// smoothing. const ERASER_TOOL_TIP: (f32, f32, f32) = (13.0, 1.0, 0.25); @@ -113,7 +115,8 @@ const SMUDGE_TOOL_TIP: (f32, f32, f32) = (13.0, 0.0, 0.25); /// `tool`'s brush as it starts out (Reset Tool, #2825): the default brush at Photoshop's /// smoothing, with the session's own fields of `current`. The Brush tool's tip is -/// [`BRUSH_TOOL_TIP`], the Eraser's [`ERASER_TOOL_TIP`] with no smoothing, the Background Eraser's [`BACKGROUND_ERASER_TIP`], the Healing Brush's +/// [`BRUSH_TOOL_TIP`], the Mixer Brush's [`MIXER_BRUSH_TIP`] and measured mixer settings, the +/// Eraser's [`ERASER_TOOL_TIP`] with no smoothing, the Background Eraser's [`BACKGROUND_ERASER_TIP`], the Healing Brush's /// [`HEALING_BRUSH_TIP`], the Burn, Dodge and Sponge tools' [`TONING_TOOL_TIP`], the Clone Stamp's /// [`CLONE_STAMP_TIP`] with no smoothing, the Remove tool's size [`REMOVE_TOOL_SIZE`], the Smudge /// tool's [`SMUDGE_TOOL_TIP`] and the Pencil's [`PENCIL_TOOL_TIP`]; the other tools keep the @@ -122,6 +125,16 @@ pub(crate) fn fresh_brush(tool: Tool, current: &BrushSettings) -> BrushSettings let mut brush = BrushSettings { smoothing: first_smoothing(), ..BrushSettings::default() }; match tool { Tool::Brush => (brush.size, brush.hardness, brush.spacing) = BRUSH_TOOL_TIP, + Tool::MixerBrush => { + (brush.size, brush.hardness, brush.spacing) = MIXER_BRUSH_TIP; + brush.mixer.wet = 0.8; + brush.mixer.load = 0.75; + brush.mixer.mix = 0.9; + brush.mixer.flow = 1.0; + brush.mixer.load_after_stroke = true; + brush.mixer.clean_after_stroke = true; + brush.mixer.sample_all_layers = false; + } Tool::Eraser => { (brush.size, brush.hardness, brush.spacing) = ERASER_TOOL_TIP; brush.smoothing.amount = 0.0; diff --git a/crates/ui-egui/tests/it/main.rs b/crates/ui-egui/tests/it/main.rs index ea4a520871..349a2148f8 100644 --- a/crates/ui-egui/tests/it/main.rs +++ b/crates/ui-egui/tests/it/main.rs @@ -47,6 +47,7 @@ mod live_stroke_canvas; mod magnetic_lasso_right_click; mod marching_ants_pixels; mod marquee_autoscroll; +mod mixer_reset_defaults; mod paint_bucket_all_layers; mod pattern_preview_canvas; mod radial_blur_center; diff --git a/crates/ui-egui/tests/it/mixer_reset_defaults.rs b/crates/ui-egui/tests/it/mixer_reset_defaults.rs new file mode 100644 index 0000000000..c55f7f3ff3 --- /dev/null +++ b/crates/ui-egui/tests/it/mixer_reset_defaults.rs @@ -0,0 +1,212 @@ +//! #11945: Mixer Brush reset defaults belong to the UI tool, not command constructors. + +use egui::{Context, RawInput, Shape}; +use photocraft_color::BlendMode; +use photocraft_engine::{BrushSettings, Session}; +use photocraft_ui_egui::control::{ControlRequest, Outcome, handle}; +use photocraft_ui_egui::{PhotocraftApp, Tool}; +use serde_json::{Value, json}; + +fn app() -> PhotocraftApp { + let mut app = PhotocraftApp::new(Session::new(), Default::default()); + app.run("file.new", json!({"width": 64, "height": 48})).unwrap(); + app.sync_views(); + app +} + +fn control(app: &mut PhotocraftApp, params: Value) { + let ctx = Context::default(); + let (req, _rx) = ControlRequest::new("ui.menu.invoke", params); + let Outcome::Done(reply) = handle(app, &ctx, &req) else { panic!("reset must finish synchronously") }; + assert_eq!(reply["ok"], true, "{reply}"); + app.sync_views(); +} + +fn pick(app: &mut PhotocraftApp, tool: Tool) { + app.ui.tool = tool; + photocraft_ui_egui::paint_mouse::sync_tool_brush(app); + app.sync_views(); +} + +fn reset(app: &mut PhotocraftApp) { + control(app, json!({"id": "tool.reset"})); +} + +fn reset_all(app: &mut PhotocraftApp) { + control(app, json!({"id": "tool.resetAll", "params": {"confirmed": true}})); +} + +fn tip(app: &mut PhotocraftApp) -> [f64; 5] { + let b = app.run("brush.get", json!({})).unwrap(); + ["size", "hardness", "spacing", "angle", "roundness"].map(|k| (b[k].as_f64().unwrap() * 1e4).round() / 1e4) +} + +fn scramble(app: &mut PhotocraftApp) { + let b = &mut app.session.tools.brush; + (b.size, b.hardness, b.spacing, b.angle, b.roundness) = (57.0, 0.4, 0.6, 30.0, 0.5); + (b.flip_x, b.flip_y, b.pressure_size) = (true, true, true); + b.opacity = 0.3; + b.mode = BlendMode::Multiply; + b.smoothing.amount = 0.6; + let m = &mut b.mixer; + (m.wet, m.load, m.mix, m.flow) = (0.1, 0.2, 0.3, 0.4); + (m.load_after_stroke, m.clean_after_stroke, m.sample_all_layers) = (false, false, true); +} + +fn assert_mixer_reset(app: &mut PhotocraftApp) { + assert_eq!(tip(app), [35.0, 0.0, 0.25, 0.0, 1.0]); + let b = &app.session.tools.brush; + assert_eq!((b.flip_x, b.flip_y, b.pressure_size), (false, false, false)); + assert_eq!((b.opacity, b.mode, b.smoothing.amount), (1.0, BlendMode::Normal, 0.1)); + let m = &b.mixer; + assert_eq!((m.wet, m.load, m.mix, m.flow), (0.8, 0.75, 0.9, 1.0)); + assert_eq!((m.load_after_stroke, m.clean_after_stroke, m.sample_all_layers), (true, true, false)); +} + +/// Check the actual painted chip label, scoped to its public response rectangle. +fn assert_chip(app: &mut PhotocraftApp, label: &str) { + fn has_text(shape: &Shape, rect: egui::Rect, label: &str) -> bool { + match shape { + Shape::Text(text) => text.galley.text() == label && rect.contains(text.pos), + Shape::Vec(shapes) => shapes.iter().any(|shape| has_text(shape, rect, label)), + _ => false, + } + } + let ctx = Context::default(); + PhotocraftApp::setup_context(&ctx, Default::default()); + let screen_rect = Some(egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(1400.0, 300.0))); + let mut out = ctx.run_ui(RawInput { screen_rect, ..Default::default() }, |ui| photocraft_ui_egui::panels::options_bar(app, ui)); + let rect = ctx.read_response(photocraft_ui_egui::brush_picker::chip_id()).expect("brush chip response").rect; + assert!(out.shapes.iter().any(|shape| has_text(&shape.shape, rect, label)), "painted chip {label}"); + out.textures_delta.clear(); +} + +#[test] +fn reset_tool_gives_the_mixer_its_35_px_soft_tip_and_measured_options() { + let mut app = app(); + pick(&mut app, Tool::MixerBrush); + scramble(&mut app); + assert_chip(&mut app, "57"); + reset(&mut app); + assert_mixer_reset(&mut app); + assert_chip(&mut app, "35"); +} + +#[test] +fn reset_all_gives_the_mixer_its_defaults_active_or_picked_later() { + let mut active = app(); + pick(&mut active, Tool::MixerBrush); + scramble(&mut active); + reset_all(&mut active); + assert_mixer_reset(&mut active); + assert_chip(&mut active, "35"); + let mut inactive = app(); + pick(&mut inactive, Tool::MixerBrush); + scramble(&mut inactive); + pick(&mut inactive, Tool::Brush); + reset_all(&mut inactive); + pick(&mut inactive, Tool::MixerBrush); + assert_mixer_reset(&mut inactive); + assert_chip(&mut inactive, "35"); +} + +#[test] +fn mixer_reset_preserves_the_brush_and_eraser_own_resets() { + let mut app = app(); + pick(&mut app, Tool::MixerBrush); + reset(&mut app); + for (tool, expected) in [(Tool::Brush, [13.0, 0.0, 0.25, 0.0, 1.0]), (Tool::Eraser, [13.0, 1.0, 0.25, 0.0, 1.0])] { + pick(&mut app, tool); + scramble(&mut app); + reset(&mut app); + assert_eq!(tip(&mut app), expected, "{tool:?} Reset Tool"); + } + pick(&mut app, Tool::MixerBrush); + reset_all(&mut app); + for (tool, expected) in [(Tool::Brush, [13.0, 0.0, 0.25, 0.0, 1.0]), (Tool::Eraser, [13.0, 1.0, 0.25, 0.0, 1.0])] { + pick(&mut app, tool); + assert_eq!(tip(&mut app), expected, "{tool:?} Reset All"); + } +} + +#[test] +fn switching_back_keeps_the_mixers_edited_brush() { + let mut app = app(); + pick(&mut app, Tool::MixerBrush); + reset(&mut app); + scramble(&mut app); + let edited = app.session.tools.brush.clone(); + pick(&mut app, Tool::Brush); + let brush = app.session.tools.brush.clone(); + pick(&mut app, Tool::MixerBrush); + assert_eq!(app.session.tools.brush, edited); + pick(&mut app, Tool::Brush); + assert_eq!(app.session.tools.brush, brush); +} + +#[test] +fn mixer_reset_keeps_session_fields_and_clears_the_current_preset() { + let mut app = app(); + pick(&mut app, Tool::MixerBrush); + let b = &mut app.session.tools.brush; + b.color = [0.2, 0.4, 0.6, 1.0]; + b.background = [0.8, 0.6, 0.4, 1.0]; + b.erase = true; + b.seed = 1234; + let fields = (b.color, b.background, b.erase, b.seed); + app.session.tools.current_preset = Some("mixer-before-reset".into()); + reset(&mut app); + assert_mixer_reset(&mut app); + let b = &app.session.tools.brush; + assert_eq!((b.color, b.background, b.erase, b.seed), fields); + assert_eq!(app.session.tools.current_preset, None); +} + +#[test] +fn constructors_and_implicit_mixer_commands_keep_global_defaults() { + let defaults = BrushSettings::default(); + assert_eq!((defaults.size, defaults.hardness, defaults.spacing), (20.0, 1.0, 0.1)); + assert_eq!(defaults.smoothing.amount, 0.0); + let m = defaults.mixer; + assert_eq!((m.wet, m.load, m.mix, m.flow), (0.5, 0.5, 0.5, 1.0)); + assert_eq!((m.load_after_stroke, m.clean_after_stroke, m.sample_all_layers), (true, true, false)); + // A session starts at 10% smoothing (ToolState::default), unlike the raw brush constructor. + let session_defaults = BrushSettings { smoothing: photocraft_paint::Smoothing { amount: 0.1, ..Default::default() }, ..BrushSettings::default() }; + assert_eq!(Session::new().tools.brush, session_defaults); + let mut implicit = app(); + let mut explicit = app(); + for app in [&mut implicit, &mut explicit] { + assert_eq!(app.session.tools.brush, session_defaults); + app.run("layer.new.layer", json!({})).unwrap(); + app.run("edit.fill", json!({"color": "#8090a0"})).unwrap(); + } + let before = { + let st = implicit.session.active().unwrap(); + st.doc.layer(st.active_layer.unwrap()).unwrap().surface().unwrap().pixel(30, 24) + }; + implicit.run("paint.mixerBrush", json!({"points": [[20, 24], [40, 24]], "seed": 17})).unwrap(); + explicit.run("paint.mixerBrush", json!({"points": [[20, 24], [40, 24]], "seed": 17, "wet": 50, "load": 50, "mix": 50, "flow": 100})).unwrap(); + let a = implicit.session.active().unwrap(); + let b = explicit.session.active().unwrap(); + let a = a.doc.layer(a.active_layer.unwrap()).unwrap().surface().unwrap(); + let b = b.doc.layer(b.active_layer.unwrap()).unwrap().surface().unwrap(); + assert_ne!(a.pixel(30, 24), before, "the default-settings control actually paints"); + for y in 0..48 { + for x in 0..64 { + assert_eq!(a.pixel(x, y), b.pixel(x, y), "implicit mixer defaults at {x},{y}"); + } + } + assert_eq!(implicit.session.tools.brush, session_defaults); +} + +#[test] +fn first_use_without_reset_keeps_existing_inheritance() { + // A compatibility control, not a claim that the reference's first use was measured. + let mut app = app(); + pick(&mut app, Tool::Blur); + scramble(&mut app); + let old = app.session.tools.brush.clone(); + pick(&mut app, Tool::MixerBrush); + let expected = BrushSettings { mode: BlendMode::Normal, smoothing: photocraft_paint::Smoothing { amount: 0.1, ..Default::default() }, ..old }; + assert_eq!(app.session.tools.brush, expected); +} From 2738fc6e5af593eb2bcea448b1185f39a88d73f7 Mon Sep 17 00:00:00 2001 From: yoriswind Date: Sun, 15 Nov 2026 08:00:29 -0800 Subject: [PATCH 2/4] Align Artboards to Files order control with current filename contract --- crates/engine/src/cmd/artboard_cmds/pdf_page_order_tests.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/engine/src/cmd/artboard_cmds/pdf_page_order_tests.rs b/crates/engine/src/cmd/artboard_cmds/pdf_page_order_tests.rs index 49356105a6..4f0a38691a 100644 --- a/crates/engine/src/cmd/artboard_cmds/pdf_page_order_tests.rs +++ b/crates/engine/src/cmd/artboard_cmds/pdf_page_order_tests.rs @@ -54,5 +54,7 @@ fn artboards_to_files_keeps_its_top_first_order() { let r = s.execute("file.export.artboardsToFiles", json!({"dir": dir.to_string_lossy(), "prefix": "p"})).unwrap(); let _ = std::fs::remove_dir_all(&dir); let files: Vec<&str> = r["files"].as_array().unwrap().iter().filter_map(Value::as_str).collect(); - assert!(files[0].ends_with("p_0000_Empty Board.png") && files[2].ends_with("p_0002_Red Board.png"), "{files:?}"); + // #13633: the prefix is followed directly by the board name, with PNG spaces hyphenated. + let names: Vec<&str> = files.iter().map(|path| std::path::Path::new(path).file_name().unwrap().to_str().unwrap()).collect(); + assert_eq!(names, ["pEmpty-Board.png", "pBlue-Board.png", "pRed-Board.png"]); } From 970943ff026115e514d640c5fd34a2f865719e2c Mon Sep 17 00:00:00 2001 From: Yoris Date: Sun, 15 Nov 2026 10:38:13 -0800 Subject: [PATCH 3/4] Apply exact hosted CI canonical lock ordering --- Cargo.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index d3935c94a4..03aadc6d20 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5859,8 +5859,8 @@ dependencies = [ name = "photocraft-text" version = "0.23.1" dependencies = [ - "craft-plist", "base64 0.23.1", + "craft-plist", "craft-psd", "flate2", "parley", From 2255b817ef198141f256eca4ded1936578555486 Mon Sep 17 00:00:00 2001 From: Yoris Date: Sun, 15 Nov 2026 13:37:16 -0800 Subject: [PATCH 4/4] Match upstream shortcut fixture initializer without changing assertions --- .../ui-egui/src/prefs/prefs_ui/shortcut_set_switch_tests.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/crates/ui-egui/src/prefs/prefs_ui/shortcut_set_switch_tests.rs b/crates/ui-egui/src/prefs/prefs_ui/shortcut_set_switch_tests.rs index 31bc9bf711..68a82501d9 100644 --- a/crates/ui-egui/src/prefs/prefs_ui/shortcut_set_switch_tests.rs +++ b/crates/ui-egui/src/prefs/prefs_ui/shortcut_set_switch_tests.rs @@ -165,9 +165,8 @@ fn an_unmodified_set_switches_at_once() { fn an_action_function_key_is_no_edit() { let (mut h, first) = dialog(); h.state_mut().ui.dialogs.retain(|d| d.id != first); - let sepia = h.state().session.actions.list.len(); - h.state_mut().session.actions.list.push(photocraft_engine::actions_cmds::Action::new("Sepia", vec![])); - crate::actions::assign_shortcut(h.state_mut(), sepia, "F2").unwrap(); + h.state_mut().session.actions.list.push(photocraft_engine::actions_cmds::Action::new("Sepia", Vec::new())); + crate::actions::assign_shortcut(h.state_mut(), 0, "F2").unwrap(); let ctx = h.ctx.clone(); let id = crate::menus::invoke(h.state_mut(), &ctx, "edit.keyboardShortcuts", json!({})).unwrap()["dialog"].as_u64().unwrap(); h.run_steps(4);