feat(stage): the status bar says when the frame shown has artwork left out (M8)

This commit is contained in:
Tanish Manku committed 2026-11-21 13:32:05 -07:00
1 parent d9b8bcadd1
commit c7d2fdb6d5
3 files changed
+48

No files matched your search

+4
View File
@@ -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<Status>,
/// 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<Prompt>,
/// The Convert to Symbol dialog, and what it chose last (ADR 0053).
pub convert: Option<crate::convert_symbol::ConvertDialog>,
@@ -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,
+28
View File
@@ -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 }
}
+16
View File
@@ -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