diff --git a/src/app.rs b/src/app.rs index 687524a8..142e441e 100644 --- a/src/app.rs +++ b/src/app.rs @@ -376,6 +376,9 @@ pub struct App { /// The tool in hand last frame (picking the Camera tool adds a camera). pub last_tool: Tool, pub status: Option, + /// The frame shown was not all drawn when the stage last looked (ADR 0128): the status bar + /// has said so, and says it again only after a frame that was whole. + pub left_out_said: bool, pub prompt: Option, /// The Convert to Symbol dialog, and what it chose last (ADR 0053). pub convert: Option, @@ -802,6 +805,7 @@ impl App { camera_preview: false, last_tool: Tool::Select, status: None, + left_out_said: false, prompt: None, convert: None, layer_props: None, diff --git a/src/rulers_tests.rs b/src/rulers_tests.rs index 154eeaf4..1b2911e0 100644 --- a/src/rulers_tests.rs +++ b/src/rulers_tests.rs @@ -24,6 +24,34 @@ fn app() -> (egui::Context, App) { (ctx, app) } +/// ADR 0128: a frame too large to draw in full is drawn in part, and the status bar says so +/// once, as an error that stays; going to a frame that is whole and back says it again. +#[test] +fn a_frame_with_artwork_left_out_says_so_in_the_status_bar() { + let mut large = sample::doubling(31); + // Thousands of empty layers in every symbol: the allowance goes on looking at them, so + // the frame is cut short with little to draw. + for sym in &mut large.library { + let tl = &mut std::sync::Arc::make_mut(sym).timeline; + for i in 0..5_000 { + tl.layers.push(std::sync::Arc::new(anicraft_engine::doc::Layer::new(anicraft_engine::doc::LayerId(9_000 + i), "empty"))); + } + } + let ctx = egui::Context::default(); + let mut big = App::with_context(&ctx, Session::new(large), Some(std::path::PathBuf::from("unused.png"))); + frame(&ctx, &mut big, vec![]); + let said = big.status.as_ref().map(|s| (s.text.clone(), s.error)); + assert!(said.as_ref().is_some_and(|(text, error)| *error && text.contains("left out")), "{said:?}"); + // Said once: a later message is not written over while the frame stays as it is. + big.status_ok("something else"); + frame(&ctx, &mut big, vec![]); + assert_eq!(big.status.as_ref().map(|s| s.text.as_str()), Some("something else")); + // An ordinary document says nothing. + let (ctx, mut app) = app(); + frame(&ctx, &mut app, vec![]); + assert!(!app.status.as_ref().is_some_and(|s| s.text.contains("left out"))); +} + fn press(p: Pos2, pressed: bool) -> Event { Event::PointerButton { pos: p, button: PointerButton::Primary, pressed, modifiers: Modifiers::NONE } } diff --git a/src/stage.rs b/src/stage.rs index 704c8ca8..fb36b654 100644 --- a/src/stage.rs +++ b/src/stage.rs @@ -230,6 +230,21 @@ fn to_v(p: Pos2) -> Vec2 { Vec2::new(p.x, p.y) } +/// Says in the status bar, once each time it starts, that the frame shown is not all there: its +/// artwork took more than a frame's allowance of work, so the rest was left out (ADR 0128). A +/// picture with parts missing and nothing said would read as lost work. Not asked while +/// playing, where it would cost an evaluation every frame; the frame playback stops on is. +fn note_left_out(app: &mut App) { + if app.playing { + return; + } + let cut = app.s.display_list().left_out; + if cut && !app.left_out_said { + app.status_err(tr!("This frame holds more artwork than AniCraft draws at once, so some of it is left out. Nothing is lost: look for symbols nested many times over.")); + } + app.left_out_said = cut; +} + pub fn show(app: &mut App, ui: &mut egui::Ui) { // View › Rulers along the top and the left (ADR 0076); the stage view in what is left. let (canvas, bars) = crate::rulers::layout(app, ui.max_rect()); @@ -237,6 +252,7 @@ pub fn show(app: &mut App, ui: &mut egui::Ui) { crate::camera_tool::on_tool_change(app); crate::shape_envelope::settle(app); crate::camera_tool::tick(app, ui.ctx(), now); + note_left_out(app); let canvas_was = std::mem::replace(&mut app.stage_cache.canvas, canvas); let laid_out = std::mem::replace(&mut app.stage_cache.laid_out, true); // While a colour picker popup is open the stage is its eyedropper (ADR 0109): a click