PhotoCraft: An open-source, photo editor written by scratch in pure Rust
fix: hook Animated Zoom preference
Gustavo Ziger8c1548109161
diff --git a/crates/engine/src/prefs.rs b/crates/engine/src/prefs.rsindex cffc39bcc..8f82bc033 100644--- a/crates/engine/src/prefs.rs+++ b/crates/engine/src/prefs.rs@@ -1049,7 +1049,6 @@ pub const SECTIONS: [(&str, &str); 18] = [/// preference is read anywhere outside `prefs.rs`, and while an unlisted one is read nowhere.pub const HIDDEN_UNTIL_IMPLEMENTED: &[&str] = &["general.colorPicker",- "general.animatedZoom","general.zoomResizesWindows","workspace.autoShowHiddenPanels","workspace.enableFloatingDocumentWindowDocking",diff --git a/crates/ui-egui/src/actions.rs b/crates/ui-egui/src/actions.rsindex 2f7dd960e..5a52212a2 100644--- a/crates/ui-egui/src/actions.rs+++ b/crates/ui-egui/src/actions.rs@@ -144,22 +144,22 @@ pub(crate) fn run_view(app: &mut PhotocraftApp, id: &str, params: Value) -> Resumatch id {"view.fitOnScreen" => {v.fit_pending = true;- v.zoom_animating = true;+ v.request_zoom_animation(app.session.prefs().general.animated_zoom);}"view.zoomIn" => {v.fit_pending = false;v.zoom = crate::zoom_levels::step(v.zoom, 1, v.doc_size);- v.zoom_animating = true;+ v.request_zoom_animation(app.session.prefs().general.animated_zoom);}"view.zoomOut" => {v.fit_pending = false;v.zoom = crate::zoom_levels::step(v.zoom, -1, v.doc_size);- v.zoom_animating = true;+ v.request_zoom_animation(app.session.prefs().general.animated_zoom);}"view.actualPixels" => {v.fit_pending = false;v.zoom = 1.0;- v.zoom_animating = true;+ v.request_zoom_animation(app.session.prefs().general.animated_zoom);}_ => return Err(format!("unsupported view command: {id}")),}diff --git a/crates/ui-egui/src/artboard_ui.rs b/crates/ui-egui/src/artboard_ui.rsindex 1dda153ff..fe7f5f77e 100644--- a/crates/ui-egui/src/artboard_ui.rs+++ b/crates/ui-egui/src/artboard_ui.rs@@ -73,7 +73,7 @@ pub fn fit_artboard(app: &mut PhotocraftApp) -> Result<Value, String> {// overflows an i32 sum (#981).v.center = [((f64::from(b.x0) + f64::from(b.x1)) / 2.0) as f32, ((f64::from(b.y0) + f64::from(b.y1)) / 2.0) as f32];v.fit_pending = false;- v.zoom_animating = true;+ v.request_zoom_animation(app.session.prefs().general.animated_zoom);v.zoom_anchor = None;Ok(json!({"zoom": v.zoom, "artboard": id.0, "bounds": [b.x0, b.y0, b.x1, b.y1]}))}diff --git a/crates/ui-egui/src/canvas.rs b/crates/ui-egui/src/canvas.rsindex 2c2682e6b..ac29caeec 100644--- a/crates/ui-egui/src/canvas.rs+++ b/crates/ui-egui/src/canvas.rs@@ -804,7 +804,8 @@ impl ViewXform {/// The main canvas's mapping for the active document as last laid out (inside the rulers).pub fn active(app: &PhotocraftApp) -> Option<Self> {let v = app.ui.views.get(app.session.active_index()?)?;- let (zoom, center) = if v.zoom_animating { v.display_camera.unwrap_or((v.zoom, v.center)) } else { (v.zoom, v.center) };+ let (zoom, center) =+ if v.zoom_animating && app.session.prefs().general.animated_zoom { v.display_camera.unwrap_or((v.zoom, v.center)) } else { (v.zoom, v.center) };Some(Self {rect: crate::rulers::content_rect(app, app.last_canvas_rect),zoom: zoom / app.canvas_ppp(),@@ -897,7 +898,10 @@ pub fn fit_view(view: &mut View, doc: &Document, area: Vec2, ppp: f32, aspect: f}/// Ease a transient presentation camera over 220 ms without changing the requested camera.-fn animated_view(view: &mut View, xf: ViewXform, ppp: f32, time: f64) -> View {+fn animated_view(view: &mut View, xf: ViewXform, ppp: f32, animated_zoom: bool, time: f64) -> View {+ if !animated_zoom {+ view.request_zoom_animation(false);+ }let target = (view.zoom, view.center);// Clamping, a canvas resize, or another camera command can make the original anchor// incompatible with the requested camera. The target must always win.@@ -2674,7 +2678,7 @@ pub fn canvas_view(app: &mut PhotocraftApp, ui: &mut egui::Ui, idx: usize, rect:let target_xf = ViewXform { rect, zoom: view.zoom / ppp, center: view.center, flip, rotation: view.rotation, aspect };let render_zoom = view.zoom;let render_visible = visible_doc_rect(&target_xf);- let mut display_view = animated_view(&mut view, target_xf, ppp, ctx.input(|i| i.time));+ let mut display_view = animated_view(&mut view, target_xf, ppp, app.session.prefs().general.animated_zoom, ctx.input(|i| i.time));if primary && let Some(stored) = app.ui.views.get_mut(idx) {stored.zoom_animating = view.zoom_animating;stored.display_camera = view.display_camera;@@ -3343,7 +3347,7 @@ pub fn canvas_view(app: &mut PhotocraftApp, ui: &mut egui::Ui, idx: usize, rect:let doc_anchor = xf.to_doc(p);let screen_anchor = p;zoom_about(&mut view, &xf, p, nz, center, ppp);- view.zoom_animating = nz != display_view.zoom;+ view.request_zoom_animation(app.session.prefs().general.animated_zoom && nz != display_view.zoom);view.zoom_anchor = (view.zoom_animating && !center).then_some((doc_anchor, [screen_anchor.x, screen_anchor.y]));}// A click with the (temporary) Hand does nothing, never the tool underneath.@@ -7268,35 +7272,86 @@ mod zoom_animation_tests {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, 0.0);+ 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, 0.0);+ 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, 0.22);+ 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, 0.0);+ 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, 0.0);+ 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, 0.11);+ 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, 0.22).center, target);+ assert_eq!(animated_view(&mut v, xf, 1.0, true, 0.22).center, target);}#[test]@@ -7304,21 +7359,21 @@ mod zoom_animation_tests {let mut a = view();let mut b = view();let xf = camera(&a);- animated_view(&mut a, xf, 1.0, 0.0);- animated_view(&mut b, xf, 1.0, 0.0);+ 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, 0.0);+ 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, 0.11);- assert_eq!(animated_view(&mut a, xf, 1.0, 0.22).zoom, 2.0);- let shown = animated_view(&mut b, xf, 1.0, 0.22);+ 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, 0.23);+ 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());}diff --git a/crates/ui-egui/src/canvas_tool_menu.rs b/crates/ui-egui/src/canvas_tool_menu.rsindex 9bfd0f9f3..41171a555 100644--- a/crates/ui-egui/src/canvas_tool_menu.rs+++ b/crates/ui-egui/src/canvas_tool_menu.rs@@ -494,7 +494,7 @@ fn choose_view(app: &mut PhotocraftApp, ctx: &Context, menu: &CanvasToolMenu, colet v = app.ui.views.get_mut(i).ok_or("no document view")?;v.fit_pending = false;v.fill_pending = true;- v.zoom_animating = true;+ v.request_zoom_animation(app.session.prefs().general.animated_zoom);v.zoom_anchor = None;return Ok(());}@@ -511,7 +511,7 @@ fn choose_view(app: &mut PhotocraftApp, ctx: &Context, menu: &CanvasToolMenu, co// from the centre shrinks (or grows) by the zoom ratio, whatever the rotation or flip.let ratio = zoom0 / v.zoom;v.center = if center_on_point || !ratio.is_finite() { d } else { [d[0] - (d[0] - c[0]) * ratio, d[1] - (d[1] - c[1]) * ratio] };- v.zoom_anchor = (!center_on_point).then_some(([d[0] as f64, d[1] as f64], menu.pos));+ v.zoom_anchor = (v.zoom_animating && !center_on_point).then_some(([d[0] as f64, d[1] as f64], menu.pos));Ok(())}@@ -1150,6 +1150,30 @@ mod tests {assert!((screen_of(h.state(), doc) - p).length() < 1.0);}+ #[test]+ fn animated_zoom_off_view_menu_keeps_the_anchor_without_a_transition() {+ for command in ["view.zoomIn", "view.zoomOut", FILL_SCREEN] {+ let mut app = zoom_app(400, 300);+ app.ui.tool = Tool::Zoom;+ app.run("prefs.set", json!({"values": {"general.animatedZoom": false, "tools.zoomClickedPointToCenter": false}})).unwrap();+ let mut h = harness(app);+ let doc = [300.0, 100.0];+ let p = screen_of(h.state(), doc);+ right_click(&mut h, p, Modifiers::NONE);+ let ctx = h.ctx.clone();+ choose(h.state_mut(), &ctx, command);+ assert!(!h.state().ui.views[0].zoom_animating, "{command}");+ h.step();+ let v = &h.state().ui.views[0];+ let xf = crate::canvas::ViewXform::active(h.state()).unwrap();+ assert_eq!((xf.zoom, xf.center), (v.zoom, v.center), "{command}");+ assert!(v.zoom_anchor.is_none() && v.zoom_transition.is_none(), "{command}");+ if command != FILL_SCREEN {+ assert!(screen_of(h.state(), doc).distance(p) < 1.0, "{command}: preserve the clicked point");+ }+ }+ }+#[test]fn view_menu_zoom_keeps_its_anchor_during_the_animation() {let mut app = zoom_app(400, 300);diff --git a/crates/ui-egui/src/panels.rs b/crates/ui-egui/src/panels.rsindex 4a2fa63c8..baec9ba90 100644--- a/crates/ui-egui/src/panels.rs+++ b/crates/ui-egui/src/panels.rs@@ -1348,14 +1348,14 @@ pub fn options_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui) {&& let Some(i) = app.session.active_index(){app.ui.views[i].fit_pending = true;- app.ui.views[i].zoom_animating = true;+ app.ui.views[i].request_zoom_animation(app.session.prefs().general.animated_zoom);app.ui.views[i].zoom_anchor = None;}if widgets::secondary_button(ui, "100%", 0.0).clicked()&& let Some(i) = app.session.active_index(){app.ui.views[i].zoom = 1.0;- app.ui.views[i].zoom_animating = true;+ app.ui.views[i].request_zoom_animation(app.session.prefs().general.animated_zoom);app.ui.views[i].zoom_anchor = None;app.ui.views[i].fit_pending = false;app.ui.views[i].fill_pending = false;@@ -1384,7 +1384,7 @@ pub fn options_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui) {&& let Some(i) = app.session.active_index(){app.ui.views[i].zoom = 1.0;- app.ui.views[i].zoom_animating = true;+ app.ui.views[i].request_zoom_animation(app.session.prefs().general.animated_zoom);app.ui.views[i].zoom_anchor = None;app.ui.views[i].fit_pending = false;app.ui.views[i].fill_pending = false;@@ -1393,7 +1393,7 @@ pub fn options_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui) {&& let Some(i) = app.session.active_index(){app.ui.views[i].fit_pending = true;- app.ui.views[i].zoom_animating = true;+ app.ui.views[i].request_zoom_animation(app.session.prefs().general.animated_zoom);app.ui.views[i].zoom_anchor = None;app.ui.views[i].fill_pending = false;}@@ -1401,7 +1401,7 @@ pub fn options_bar(app: &mut PhotocraftApp, ui: &mut egui::Ui) {&& let Some(i) = app.session.active_index(){app.ui.views[i].fill_pending = true;- app.ui.views[i].zoom_animating = true;+ app.ui.views[i].request_zoom_animation(app.session.prefs().general.animated_zoom);app.ui.views[i].zoom_anchor = None;app.ui.views[i].fit_pending = false;}@@ -1878,14 +1878,14 @@ fn navigator(app: &mut PhotocraftApp, ui: &mut egui::Ui) {for (lbl, z) in [("200%", 2.0), ("100%", 1.0)] {if widgets::pill_tab(ui, lbl, (v.zoom - z).abs() < 1e-3).clicked() {app.ui.views[idx].zoom = z;- app.ui.views[idx].zoom_animating = true;+ app.ui.views[idx].request_zoom_animation(app.session.prefs().general.animated_zoom);app.ui.views[idx].zoom_anchor = None;app.ui.views[idx].fit_pending = false;}}if widgets::pill_tab(ui, tl!("Fit"), false).clicked() {app.ui.views[idx].fit_pending = true;- app.ui.views[idx].zoom_animating = true;+ app.ui.views[idx].request_zoom_animation(app.session.prefs().general.animated_zoom);app.ui.views[idx].zoom_anchor = None;}});@@ -5719,3 +5719,53 @@ mod properties_target_regressions {assert_eq!(after, before, "pending width belongs to the old document/layer");}}++#[cfg(test)]+mod navigator_animated_zoom_tests {+ use super::*;++ #[test]+ fn animated_zoom_off_navigator_buttons_jump_without_a_transition() {+ let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), crate::Services::default());+ app.run("file.new", json!({"width": 200, "height": 100})).unwrap();+ app.run("prefs.set", json!({"values": {"general.animatedZoom": false}})).unwrap();+ app.sync_views();+ app.ui.views[0].fit_pending = false;+ let mut h = egui_kittest::Harness::builder().with_size(vec2(430.0, 460.0)).build_ui_state(+ |ui, app: &mut PhotocraftApp| {+ if ui.ctx().fonts(|f| f.families().contains(&egui::FontFamily::Name("medium".into()))) {+ navigator(app, ui);+ }+ },+ app,+ );+ PhotocraftApp::setup_context(&h.ctx, crate::theme::ThemeKind::Studio);+ h.run_steps(4);+ let width = |label: &str| h.ctx.fonts_mut(|f| f.layout_no_wrap(label.into(), crate::theme::medium(12.5), Color32::WHITE).size().x + 20.0);+ let spacing = h.ctx.style_of(h.ctx.theme()).spacing.item_spacing.x;+ let widths = [width("200%"), width("100%"), width("Fit")];+ let controls = last_navigator_controls(&h.ctx).unwrap();+ let mut right = controls.right();+ for (index, zoom) in [2.0, 1.0].into_iter().enumerate() {+ let pointer = pos2(right - widths[index] / 2.0, controls.top() + 16.0);+ h.hover_at(pointer);+ for pressed in [true, false] {+ h.event(egui::Event::PointerButton { pos: pointer, button: egui::PointerButton::Primary, pressed, modifiers: egui::Modifiers::NONE });+ h.step();+ }+ right -= widths[index] + spacing;+ let view = &h.state().ui.views[0];+ assert_eq!(view.zoom, zoom);+ assert_eq!(view.display_camera, Some((view.zoom, view.center)));+ assert!(!view.zoom_animating && view.zoom_anchor.is_none() && view.zoom_transition.is_none());+ }+ let pointer = pos2(right - widths[2] / 2.0, controls.top() + 16.0);+ h.hover_at(pointer);+ for pressed in [true, false] {+ h.event(egui::Event::PointerButton { pos: pointer, button: egui::PointerButton::Primary, pressed, modifiers: egui::Modifiers::NONE });+ h.step();+ }+ assert!(h.state().ui.views[0].fit_pending);+ assert!(!h.state().ui.views[0].zoom_animating);+ }+}diff --git a/crates/ui-egui/src/prefs_ui.rs b/crates/ui-egui/src/prefs_ui.rsindex 202944b58..04c992d98 100644--- a/crates/ui-egui/src/prefs_ui.rs+++ b/crates/ui-egui/src/prefs_ui.rs@@ -2749,6 +2749,7 @@ mod tests {assert!(!prefs::is_hidden("rawDefaults.openInCameraRaw"));assert!(prefs::is_hidden("rawDefaults.applyAutoTone"));assert!(!prefs::is_hidden("general.autoShowHomeScreen"));+ assert!(!prefs::is_hidden("general.animatedZoom"));assert!(!prefs::is_hidden("interface.uiScale"));assert!(!prefs::is_hidden("interface.uiFontSize"));// Hidden values still round-trip through the dialog untouched.diff --git a/crates/ui-egui/src/state.rs b/crates/ui-egui/src/state.rsindex e6178aa8d..b85402504 100644--- a/crates/ui-egui/src/state.rs+++ b/crates/ui-egui/src/state.rs@@ -499,6 +499,19 @@ pub(crate) struct ZoomTransition {pub started: f64,}+impl View {+ /// Start a discrete zoom only when Animated Zoom is enabled; otherwise discard the+ /// presentation camera so the requested camera takes effect immediately.+ pub(crate) fn request_zoom_animation(&mut self, enabled: bool) {+ self.zoom_animating = enabled;+ self.zoom_anchor = None;+ if !enabled {+ self.zoom_transition = None;+ self.display_camera = Some((self.zoom, self.center));+ }+ }+}+impl Default for View {fn default() -> Self {Self {diff --git a/crates/ui-egui/src/view_cmds.rs b/crates/ui-egui/src/view_cmds.rsindex 6d062fc7c..9d3fe9a32 100644--- a/crates/ui-egui/src/view_cmds.rs+++ b/crates/ui-egui/src/view_cmds.rs@@ -709,7 +709,7 @@ fn run(app: &mut PhotocraftApp, ctx: &egui::Context, id: &str, p: &Value) -> Reslet screen = app.session.prefs().units_and_rulers.screen_resolution.max(1.0) as f32;let z = if id == "view.twoHundredPercent" { 2.0 } else { screen / dpi };app.ui.views[i].zoom = crate::zoom_levels::clamp(z, size);- app.ui.views[i].zoom_animating = true;+ app.ui.views[i].request_zoom_animation(app.session.prefs().general.animated_zoom);app.ui.views[i].zoom_anchor = None;Ok(json!({"zoom": app.ui.views[i].zoom}))}@@ -742,7 +742,7 @@ fn fit_layers(app: &mut PhotocraftApp) -> Result<Value, String> {v.zoom = crate::zoom_levels::clamp(points * ppp, size);v.center = [(b.x0 + b.x1) as f32 / 2.0, (b.y0 + b.y1) as f32 / 2.0];v.fit_pending = false;- v.zoom_animating = true;+ v.request_zoom_animation(app.session.prefs().general.animated_zoom);v.zoom_anchor = None;Ok(json!({"zoom": v.zoom, "bounds": [b.x0, b.y0, b.x1, b.y1]}))}@@ -815,10 +815,11 @@ fn arrange(app: &mut PhotocraftApp, k: &str, p: &Value) -> Result<Value, String>let src = app.ui.views.get(i).cloned().ok_or("no document")?;let (zoom, loc, rot) =(matches!(k, "matchZoom" | "matchAll"), matches!(k, "matchLocation" | "matchAll"), matches!(k, "matchRotation" | "matchAll"));+ let animated_zoom = app.session.prefs().general.animated_zoom;let apply = |v: &mut crate::state::View| {if zoom {v.zoom = src.zoom;- v.zoom_animating = true;+ v.request_zoom_animation(animated_zoom);v.zoom_anchor = None;}if loc {diff --git a/crates/ui-egui/src/zoom_tool.rs b/crates/ui-egui/src/zoom_tool.rsindex c892041e7..7ace657bc 100644--- a/crates/ui-egui/src/zoom_tool.rs+++ b/crates/ui-egui/src/zoom_tool.rs@@ -196,6 +196,71 @@ mod tests {assert_eq!(h.state().current_zoom(), crate::zoom_levels::step(zc, 1, h.state().ui.views[0].doc_size));}+ #[test]+ fn animated_zoom_off_click_jumps_to_the_anchored_target() {+ let mut h = harness(true, 1.0);+ h.state_mut()+ .run("prefs.set", json!({"values": {"general.animatedZoom": false, "tools.zoomClickedPointToCenter": false, "tools.overscroll": true}}))+ .unwrap();+ let pointer = h.state().last_canvas_rect.center() + vec2(90.0, -45.0);+ let anchor = view_xf(&h).to_doc(pointer);+ let start = h.state().current_zoom();+ h.event(Event::PointerMoved(pointer));+ h.step();+ press(&mut h, pointer, true);+ press(&mut h, pointer, false);+ let target = crate::zoom_levels::step(start, 1, [400, 300]);+ let v = &h.state().ui.views[0];+ assert_eq!(v.zoom, target);+ assert_eq!(view_xf(&h).zoom, target);+ assert!(!v.zoom_animating && v.zoom_anchor.is_none() && v.zoom_transition.is_none());+ assert!(view_xf(&h).to_screen(anchor[0] as f32, anchor[1] as f32).distance(pointer) < 0.5);+ }++ #[test]+ fn animated_zoom_off_view_commands_show_the_target_on_the_first_frame() {+ for command in+ ["view.zoomIn", "view.zoomOut", "view.actualPixels", "view.fitOnScreen", "view.twoHundredPercent", "view.printSize", "view.fitLayersOnScreen"]+ {+ let mut h = harness(true, 1.0);+ h.state_mut().run("prefs.set", json!({"values": {"general.animatedZoom": false}})).unwrap();+ if crate::view_cmds::handles(command) {+ crate::view_cmds::invoke(h.state_mut(), &egui::Context::default(), command, &json!({})).unwrap().unwrap();+ } else {+ h.state_mut().run(command, json!({})).unwrap();+ }+ assert!(!h.state().ui.views[0].zoom_animating, "{command}");+ h.step();+ let v = &h.state().ui.views[0];+ let xf = view_xf(&h);+ assert_eq!((xf.zoom, xf.center), (v.zoom, v.center), "{command}");+ assert!(v.zoom_anchor.is_none() && v.zoom_transition.is_none(), "{command}");+ }+ }++ #[test]+ fn disabling_animated_zoom_during_a_transition_snaps_and_does_not_resume() {+ let mut h = harness(true, 1.0);+ h.state_mut().run("view.zoomIn", json!({})).unwrap();+ h.step();+ let time = h.ctx.input(|i| i.time) + 0.11;+ h.input_mut().time = Some(time);+ h.step();+ assert!(h.state().ui.views[0].zoom_animating);+ let target = (h.state().ui.views[0].zoom, h.state().ui.views[0].center);+ assert_ne!(view_xf(&h).zoom, target.0);+ h.state_mut().run("prefs.set", json!({"values": {"general.animatedZoom": false}})).unwrap();+ assert_eq!((view_xf(&h).zoom, view_xf(&h).center), target, "pointer mapping switches immediately");+ h.step();+ let v = &h.state().ui.views[0];+ assert!(!v.zoom_animating && v.zoom_anchor.is_none() && v.zoom_transition.is_none());+ assert_eq!((view_xf(&h).zoom, view_xf(&h).center), target);+ h.state_mut().run("prefs.set", json!({"values": {"general.animatedZoom": true}})).unwrap();+ h.step();+ assert!(!h.state().ui.views[0].zoom_animating);+ assert_eq!((view_xf(&h).zoom, view_xf(&h).center), target);+ }+#[test]fn discrete_zoom_animates_and_keeps_its_document_anchor_fixed() {let mut h = harness(true, 1.0);@@ -285,6 +350,18 @@ mod tests {}assert!(!h.state().ui.views[0].zoom_animating);assert_eq!(view_xf(&h).zoom, target);+ h.state_mut().run("prefs.set", json!({"values": {"general.animatedZoom": false}})).unwrap();+ h.state_mut().run("view.zoomIn", json!({})).unwrap();+ h.state_mut().perf.last_refresh = "";+ h.step();+ assert_eq!(view_xf(&h).zoom, h.state().current_zoom());+ assert!(!h.state().ui.views[0].zoom_animating);+ assert!(h.state().perf.gpu);+ assert_eq!(h.state().perf.last_refresh, "", "immediate zoom reuses the GPU composite");+ let image = h.render().unwrap();+ if let Some(directory) = &directory {+ image.save(directory.join("photocraft-zoom-disabled.png")).unwrap();+ }}#[test]diff --git a/docs/scorecard.md b/docs/scorecard.mdindex 78a086454..3096ac15e 100644--- a/docs/scorecard.md+++ b/docs/scorecard.md@@ -9,7 +9,7 @@ Generated by `cargo xtask scorecard` from `perf/budgets.toml`, `perf/baseline.js| [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 || [Tools](#tools) | 28 | 14 | 1 | |-| [Workspace and UI](#workspace-and-ui) | 13 | 5 | 5 | settings that do nothing: 27 of 156 (target 0) |+| [Workspace and UI](#workspace-and-ui) | 13 | 5 | 5 | settings that do nothing: 26 of 156 (target 0) || [Type](#type) | 4 | 2 | 3 | || [Automation](#automation) | 4 | 2 | 5 | 631 of 631 menu items live (100.0%) || [Reliability](#reliability) | 5 | 2 | 0 | never-crash lints on 28 of 28 crates; panic_hunt present |@@ -176,9 +176,9 @@ Corpus floors (`crates/io/tests/corpus.rs`): the enforced minimums; the corpus t## Workspace and UI-**Settings that do nothing: 27 of 156** (target 0, #204). Counted by the prefs audit (`xtask/src/scorecard.rs`): a `Preferences` field counts as read when code outside the prefs model (`prefs.rs` except its `impl Session` blocks; tests excluded; the schema-driven dialog never names a field) accesses `section.field`, or `.section` and `.field` in the same file, or calls a section method that reads `self.field`. It is a heuristic lower bound: a generic name can look read when it isn't.+**Settings that do nothing: 26 of 156** (target 0, #204). Counted by the prefs audit (`xtask/src/scorecard.rs`): a `Preferences` field counts as read when code outside the prefs model (`prefs.rs` except its `impl Session` blocks; tests excluded; the schema-driven dialog never names a field) accesses `section.field`, or `.section` and `.field` in the same file, or calls a section method that reads `self.field`. It is a heuristic lower bound: a generic name can look read when it isn't.-Unread: `general.color_picker`, `general.animated_zoom`, `general.zoom_resizes_windows`, `workspace.auto_show_hidden_panels`, `workspace.enable_floating_document_window_docking`, `file_handling.save_in_background`, `file_handling.maximize_psd_compatibility`, `performance.cache_levels`, `performance.legacy_compositing`, `scratch_disks.disks`, `units_and_rulers.column_width`, `units_and_rulers.gutter`, `plug_ins.show_extension_panels`, `plug_ins.allow_scripts_to_connect`, `plug_ins.generator_enabled`, `type_.text_engine`, `type_.recent_fonts`, `enhanced_controls.scrubby_slider_acceleration`, `enhanced_controls.touch_gestures`, `raw_defaults.color_space`, `raw_defaults.bit_depth`, `raw_defaults.resolution`, `raw_defaults.sharpen_for`, `raw_defaults.open_as_smart_object`, `raw_defaults.apply_auto_tone`, `integrations.allow_agent_control`, `integrations.control_port`.+Unread: `general.color_picker`, `general.zoom_resizes_windows`, `workspace.auto_show_hidden_panels`, `workspace.enable_floating_document_window_docking`, `file_handling.save_in_background`, `file_handling.maximize_psd_compatibility`, `performance.cache_levels`, `performance.legacy_compositing`, `scratch_disks.disks`, `units_and_rulers.column_width`, `units_and_rulers.gutter`, `plug_ins.show_extension_panels`, `plug_ins.allow_scripts_to_connect`, `plug_ins.generator_enabled`, `type_.text_engine`, `type_.recent_fonts`, `enhanced_controls.scrubby_slider_acceleration`, `enhanced_controls.touch_gestures`, `raw_defaults.color_space`, `raw_defaults.bit_depth`, `raw_defaults.resolution`, `raw_defaults.sharpen_for`, `raw_defaults.open_as_smart_object`, `raw_defaults.apply_auto_tone`, `integrations.allow_agent_control`, `integrations.control_port`.| Id | Target | Status | Issue | Note ||---|---|---|---|---|@@ -279,7 +279,7 @@ Never-crash attribute on 28 of 28 crate roots.| BUG-203-5 | On any failure the original file is untouched and the temp file removed | done | [#203](https://github.com/storytold/photocraft/issues/203) | atomic.rs removes the temp file on every failure; tests assert the original bytes survive write and rename failures || BUG-203-6 | Failure-injection tests: mid-write, rename and read-only dir errors keep original bytes | done | [#203](https://github.com/storytold/photocraft/issues/203) | format/src/atomic/tests.rs: Faulty AtomicFs injects mid-write StorageFull, rename failure and a read-only dir; locked-target retries, symlink and file-mode preservation covered too || BUG-204-1 | Interface prefs (UI scale, font size, channels in colour, sliders, tooltips) wired or hidden | done | [#204](https://github.com/storytold/photocraft/issues/204) | prefs_ui.rs tick reads ui_scale (sync_display_scale), ui_font_size (theme::set_ui_font_size) and show_tooltips (sync_tooltips); show_channels_in_color is wired in channel_thumbs and the canvas channel view (#2385); dynamic_color_sliders is in prefs::HIDDEN_UNTIL_IMPLEMENTED |-| BUG-204-2 | workspace.large_tabs, animated_zoom, auto_show_home_screen wired or hidden | done | [#204](https://github.com/storytold/photocraft/issues/204) | workspace.large_tabs controls document tab height in canvas.rs; auto_show_home_screen drives the Home screen; animated_zoom is in prefs::HIDDEN_UNTIL_IMPLEMENTED |+| BUG-204-2 | workspace.large_tabs, animated_zoom, auto_show_home_screen wired or hidden | done | [#204](https://github.com/storytold/photocraft/issues/204) | workspace.large_tabs controls document tab height in canvas.rs; auto_show_home_screen drives the Home screen; general.animated_zoom gates discrete canvas zoom transitions and is exposed in General preferences || BUG-204-3 | RAW prefs and ask_before_saving_layered_tiff read, or hidden | done | [#204](https://github.com/storytold/photocraft/issues/204) | ask_before_saving_layered_tiff drives the TIFF Options prompt (ui-egui tiff_options_ui.rs); raw_defaults.open_in_camera_raw drives the Camera Raw dialog (camera_raw_ui.rs); the other raw_defaults fields are in prefs::HIDDEN_UNTIL_IMPLEMENTED || BUG-204-4 | Recent files persisted through prefs across restarts | done | [#204](https://github.com/storytold/photocraft/issues/204) | crates/ui-egui/src/lib.rs::push_recent stores the list in preferences; prefs_ui::load restores it and recent_files_survive_a_restart_and_honour_the_count verifies reload || BUG-204-5 | Recent-files list honours recent_file_count (default 20) | done | [#204](https://github.com/storytold/photocraft/issues/204) | lib.rs push_recent caps the list with recent_cap (recent_file_count); menus.rs covers default and custom limits |diff --git a/docs/ui-parity.md b/docs/ui-parity.mdindex 2afb2b0d0..634bce8f1 100644--- a/docs/ui-parity.md+++ b/docs/ui-parity.md@@ -164,7 +164,7 @@ Triangle and Curvature Pen (minus legacy Rounded Rectangle and Targeted Adjustme| Hold any tool letter for a temporary tool | missing | #2672 || Scrubby zoom | done | `zoom_tool.rs` || Flick panning | done | `flick_pan.rs` (Preferences › Tools › Enable Flick Panning) |-| Animated zoom | done | `canvas.rs`, `zoom_tool.rs`; #566; discrete Zoom clicks and View zoom controls ease over 220 ms by default, with anchored transitions and immediate direct navigation; the existing preference remains hidden |+| Animated zoom | done | `canvas.rs`, `zoom_tool.rs`; #566; discrete Zoom clicks and View zoom controls ease over 220 ms by default, with anchored transitions and immediate direct navigation; General › Animated Zoom (default on) controls transitions; off snaps immediately, including when disabled mid-transition || Double-click Zoom tool = 100%, double-click Hand = fit | partial | Zoom missing (#2508) || ⌥-wheel zoom in gentle steps | missing | UI-217-18 || Wheel, smooth scrolling and pinch as in Photoshop | partial | #2485, #2463, #1989 |@@ -220,3 +220,4 @@ Paragraph; the rest open as in-app floating windows.| 2026-10-11 | minor | ⇧-drag a guide out of a ruler lands on the nearest ruler tick (#3770) || 2026-10-11 | minor | Layer and selection keys from Photoshop's shortcut set: ⌘, toggles, ⌘\, /, ⌘⌥2, ⌘⌥⌫, Tab rename-next, ⌥-click thumbnail to fit || 2026-10-11 | minor | Tool keys from Photoshop's shortcut set: ← / → rotate the brush tip, ⇧-click for new type, Space+F canvas colour |+| 2026-10-12 | minor | General › Animated Zoom is visible and gates every discrete zoom transition; disabling it snaps all views to their target on the next frame |diff --git a/scorecard/bugs.toml b/scorecard/bugs.tomlindex a4620bf7d..d60c29cf9 100644--- a/scorecard/bugs.toml+++ b/scorecard/bugs.toml@@ -60,7 +60,7 @@ id = "BUG-204-2"target = "workspace.large_tabs, animated_zoom, auto_show_home_screen wired or hidden"status = "done"issue = 204-note = "workspace.large_tabs controls document tab height in canvas.rs; auto_show_home_screen drives the Home screen; animated_zoom is in prefs::HIDDEN_UNTIL_IMPLEMENTED"+note = "workspace.large_tabs controls document tab height in canvas.rs; auto_show_home_screen drives the Home screen; general.animated_zoom gates discrete canvas zoom transitions and is exposed in General preferences"[[item]]id = "BUG-204-3"