PhotoCraft: An open-source, photo editor written by scratch in pure Rust
Merge main into feat/zoom-animation-566
Gustavo Ziger7f72cb81562b
diff --cc crates/ui-egui/src/canvas.rsindex bd7061812,231b4612c..87369c415--- a/crates/ui-egui/src/canvas.rs+++ b/crates/ui-egui/src/canvas.rs@@@ -7691,121 -7700,6 +7797,124 @@@ mod rotation_preview_isolation_tests}}+#[cfg(test)]+mod zoom_animation_tests {+ use super::*;++ fn camera(view: &View) -> ViewXform {+ ViewXform { rect: Rect::from_min_size(Pos2::ZERO, vec2(1000.0, 700.0)), zoom: view.zoom, center: view.center, flip: false, rotation: 0.0, aspect: 1.0 }+ }++ fn view() -> View {+ View { zoom: 1.0, center: [200.0, 150.0], doc_size: [400, 300], fit_pending: false, ..Default::default() }+ }++ #[test]+ fn disabling_animated_zoom_snaps_a_secondary_canvas_on_its_next_frame() {+ let ctx = egui::Context::default();+ let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), Default::default());+ app.run("file.new", json!({"width": 400, "height": 300})).unwrap();+ app.sync_views();+ let rect = Rect::from_min_size(Pos2::ZERO, vec2(400.0, 300.0));+ let mut secondary = view();+ let frame = |app: &mut PhotocraftApp, view: View, time: f64| {+ let input = egui::RawInput { screen_rect: Some(rect), time: Some(time), ..Default::default() };+ let mut shown = view.clone();+ let mut out = ctx.run_ui(input, |ui| {+ shown = canvas_view(app, ui, 0, rect, view.clone(), false);+ });+ out.textures_delta.clear();+ shown+ };+ secondary = frame(&mut app, secondary, 0.0);+ secondary.zoom = 2.0;+ secondary.request_zoom_animation(true);+ secondary = frame(&mut app, secondary, 0.01);+ secondary = frame(&mut app, secondary, 0.12);+ assert!(secondary.zoom_animating);+ assert!(secondary.display_camera.unwrap().0 < secondary.zoom);+ app.run("prefs.set", serde_json::json!({"values": {"general.animatedZoom": false}})).unwrap();+ secondary = frame(&mut app, secondary, 0.13);+ assert_eq!(secondary.display_camera, Some((secondary.zoom, secondary.center)));+ assert_eq!(secondary.zoom, 2.0);+ assert!(!secondary.zoom_animating && secondary.zoom_transition.is_none() && secondary.zoom_anchor.is_none());+ }++ #[test]+ fn animated_zoom_off_cancels_each_views_presentation_camera() {+ for target in [(2.0, [210.0, 170.0]), (3.0, [250.0, 180.0])] {+ let mut v = view();+ let xf = camera(&v);+ animated_view(&mut v, xf, 1.0, true, 0.0);+ v.zoom = target.0;+ v.center = target.1;+ v.request_zoom_animation(true);+ animated_view(&mut v, xf, 1.0, true, 0.0);+ let halfway = animated_view(&mut v, xf, 1.0, true, 0.11);+ assert_ne!((halfway.zoom, halfway.center), target);+ v.zoom_anchor = Some(([200.0, 150.0], [500.0, 350.0]));+ let shown = animated_view(&mut v, xf, 1.0, false, 0.11);+ assert_eq!((shown.zoom, shown.center), target);+ assert_eq!(v.display_camera, Some(target));+ assert!(!v.zoom_animating && v.zoom_anchor.is_none() && v.zoom_transition.is_none());+ }+ }++ #[test]+ fn zoom_animation_obeys_clamped_targets_and_eases_recentering() {+ let mut v = view();+ let xf = camera(&v);+ animated_view(&mut v, xf, 1.0, true, 0.0);+ let pointer = xf.to_screen(390.0, 150.0);+ zoom_about(&mut v, &xf, pointer, 2.0, false, 1.0);+ v.zoom_anchor = Some(([390.0, 150.0], [pointer.x, pointer.y]));+ v.zoom_animating = true;+ crate::scrollbars::clamp_view(&mut v, xf.rect.size(), 1.0);+ let xf = camera(&v);+ animated_view(&mut v, xf, 1.0, true, 0.0);+ assert!(v.zoom_anchor.is_none());+ let done = animated_view(&mut v, xf, 1.0, true, 0.22);+ assert_eq!((done.zoom, done.center), (v.zoom, v.center));+ assert!(!v.zoom_animating);++ let mut v = view();+ let xf = camera(&v);+ animated_view(&mut v, xf, 1.0, true, 0.0);+ zoom_about(&mut v, &xf, pointer, 2.0, true, 1.0);+ v.zoom_animating = true;+ let target = v.center;+ let xf = camera(&v);+ let start = animated_view(&mut v, xf, 1.0, true, 0.0);+ assert_eq!(start.center, [200.0, 150.0], "recentering must not teleport");+ let halfway = animated_view(&mut v, xf, 1.0, true, 0.11);+ assert!(halfway.center[0] > start.center[0] && halfway.center[0] < target[0]);+ assert_eq!(animated_view(&mut v, xf, 1.0, true, 0.22).center, target);+ }++ #[test]+ fn zoom_animation_views_are_independent_and_direct_navigation_snaps() {+ let mut a = view();+ let mut b = view();+ let xf = camera(&a);+ animated_view(&mut a, xf, 1.0, true, 0.0);+ animated_view(&mut b, xf, 1.0, true, 0.0);+ a.zoom = 2.0;+ a.zoom_animating = true;+ animated_view(&mut a, xf, 1.0, true, 0.0);+ b.zoom = 3.0;+ b.zoom_animating = true;+ animated_view(&mut b, xf, 1.0, true, 0.11);+ assert_eq!(animated_view(&mut a, xf, 1.0, true, 0.22).zoom, 2.0);+ let shown = animated_view(&mut b, xf, 1.0, true, 0.22);+ assert!(shown.zoom > 1.0 && shown.zoom < 3.0);+ assert!(b.zoom_animating && !a.zoom_animating);+ b.zoom_animating = false;+ b.center = [220.0, 170.0];+ let shown = animated_view(&mut b, xf, 1.0, true, 0.23);+ assert_eq!((shown.zoom, shown.center), (b.zoom, b.center));+ assert!(b.zoom_transition.is_none() && b.zoom_anchor.is_none());+ }+}+ #[cfg(test)]+ #[path = "canvas_display_memo_tests.rs"]+ mod display_memo_tests;diff --cc crates/ui-egui/src/chrome_ui.rsindex 55a796c94,b20e913a7..f5fadc48a--- a/crates/ui-egui/src/chrome_ui.rs+++ b/crates/ui-egui/src/chrome_ui.rs@@@ -156,10 -156,8 +156,10 @@@ pub fn status_bar_pro(app: &mut Photocr);let mut pct = app.ui.views[i].zoom * 100.0;let control_h = crate::panels::status_bar_heights(&t).1;- if widgets::compact_value_field(ui, &mut pct, crate::zoom_levels::percent_range(&app.ui.views[i]), "%", 64.0, control_h).changed() {+ if widgets::compact_wrapping_value_field(ui, &mut pct, crate::zoom_levels::percent_range(&app.ui.views[i]), "%", vec2(64.0, control_h)).changed() {app.ui.views[i].zoom = crate::zoom_levels::clamp(pct / 100.0, app.ui.views[i].doc_size);+ app.ui.views[i].zoom_animating = false;+ app.ui.views[i].zoom_anchor = None;app.ui.views[i].fit_pending = false;}ui.add_space(12.0);diff --cc crates/ui-egui/src/panels.rsindex 3b4b851eb,2ab7fbf79..694e5e48c--- a/crates/ui-egui/src/panels.rs+++ b/crates/ui-egui/src/panels.rs@@@ -1596,10 -1600,10 +1612,12 @@@ pub fn status_bar(app: &mut PhotocraftAlet (w, h, mode, bits, layers) =(st.doc.size.width, st.doc.size.height, crate::canvas::mode_label(&st.doc), st.doc.depth.bits(), st.doc.layer_count());let mut pct = app.ui.views[i].zoom * 100.0;- if widgets::compact_value_field(ui, &mut pct, crate::zoom_levels::percent_range(&app.ui.views[i]), "%", 78.0, control_h).changed() {+ if widgets::compact_wrapping_value_field(ui, &mut pct, crate::zoom_levels::percent_range(&app.ui.views[i]), "%", vec2(78.0, control_h))+ .changed()+ {app.ui.views[i].zoom = crate::zoom_levels::clamp(pct / 100.0, app.ui.views[i].doc_size);+ app.ui.views[i].zoom_animating = false;+ app.ui.views[i].zoom_anchor = None;app.ui.views[i].fit_pending = false;}widgets::vline(ui, 16.0);diff --cc docs/scorecard.mdindex 0dd360d7b,1ad3f3aa3..60cd53051--- a/docs/scorecard.md+++ b/docs/scorecard.md@@@ -7,10 -7,10 +7,10 @@@ Generated by `cargo xtask scorecard` fr| Area | Done | Partial | Missing | Key numbers ||---|---:|---:|---:|---|| [Performance](#performance) | 3 | 22 | 22 | 56 scenarios: 3 within budget, 22 over budget or failing, 9 tracked only, 17 not run, 5 not measurable yet (baseline 2026-10-05) |- | [File compatibility](#file-compatibility) | 6 | 13 | 8 | io corpus: oracle ≥ 146/170, round trip ≥ 169/170; psd-tools corpus: oracle ≥ 236/309, round trip ≥ 308/309; photoshop oracles: oracle ≥ 133/256, round trip ≥ 258/256 |+ | [File compatibility](#file-compatibility) | 6 | 13 | 8 | io corpus: oracle ≥ 146/170, round trip ≥ 169/170; psd-tools corpus: oracle ≥ 236/309, round trip ≥ 308/309; photoshop oracles: oracle ≥ 145/256, round trip ≥ 258/256 || [Tools](#tools) | 28 | 14 | 1 | |- | [Workspace and UI](#workspace-and-ui) | 13 | 5 | 5 | settings that do nothing: 25 of 156 (target 0) |- | [Type](#type) | 4 | 2 | 3 | |-| [Workspace and UI](#workspace-and-ui) | 13 | 6 | 4 | settings that do nothing: 26 of 156 (target 0) |++| [Workspace and UI](#workspace-and-ui) | 13 | 6 | 4 | settings that do nothing: 25 of 156 (target 0) |+ | [Type](#type) | 4 | 3 | 2 | || [Automation](#automation) | 5 | 2 | 4 | 631 of 631 menu items live (100.0%) || [Reliability](#reliability) | 5 | 2 | 0 | never-crash lints on 28 of 28 crates; panic_hunt present || [Distribution](#distribution) | 5 | 4 | 2 | |diff --cc docs/ui-parity.mdindex c07069462,2f620ecdc..1f5565785--- a/docs/ui-parity.md+++ b/docs/ui-parity.md@@@ -1,6 -1,6 +1,6 @@@# UI parity: tools, handles, modifiers and feel- > **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-12 · **Change:** minor (toolbar tool shortcuts can be reassigned; ⇧-dragged guides land on ruler ticks; layer and selection keys; tool keys; spring-loaded tool letters; type formatting keys; Pen Auto Add/Delete, #4144; animated zoom) · **Target:** Adobe Photoshop 2026-> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-12 · **Change:** minor (Free Transform H/V skew fields; toolbar tool shortcuts can be reassigned; ⇧-dragged guides land on ruler ticks; layer and selection keys; tool keys; spring-loaded tool letters; type formatting keys; Pen Auto Add/Delete, #4144; smart filter rows) · **Target:** Adobe Photoshop 2026++> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-12 · **Change:** minor (Free Transform H/V skew fields; toolbar tool shortcuts can be reassigned; ⇧-dragged guides land on ruler ticks; layer and selection keys; tool keys; spring-loaded tool letters; type formatting keys; Pen Auto Add/Delete, #4144; smart filter rows; animated zoom) · **Target:** Adobe Photoshop 2026How PhotoCraft's direct manipulation compares with Photoshop 2026 (27.11.0): the toolbox, thehandles and modifier keys of each gesture, nudging, snapping, numeric precision, navigation,