diff --git a/crates/midra-layout/src/gui.rs b/crates/midra-layout/src/gui.rs index 378d23a..ba67933 100644 --- a/crates/midra-layout/src/gui.rs +++ b/crates/midra-layout/src/gui.rs @@ -2503,11 +2503,7 @@ impl Editor { } // Artwork uses half-screen coordinates at twice the camera scale. Since // the output stays centered, allow the label's overhang on both sides. - let label_margin = if self.references.is_empty() { - SCREEN_LABEL_TOP * 4.0 * artwork_scale(output) - } else { - 0.0 - }; + let label_margin = SCREEN_LABEL_TOP * 4.0 * artwork_scale(output); // Help is optional: reclaim its footer when width is tight, or when it // would reduce the fitted output's scale. Toolbar tooltips remain available. let width_fitted_height = (r.width() - 40.0) / sw * (sh + label_margin) + 24.0; @@ -2865,6 +2861,7 @@ impl Editor { } else { screen_artwork(&screen, &self.backdrop_title, output); } + screen_labels(&screen, output); if self.references.is_empty() { screen_reference_hint(&screen, output); } @@ -4163,12 +4160,18 @@ mod tests { #[test] fn fit_screen_keeps_output_labels_inside_the_viewport() { + let mut png = std::io::Cursor::new(Vec::new()); + image::RgbaImage::from_pixel(16, 9, image::Rgba([50, 90, 120, 255])) + .write_to(&mut png, image::ImageFormat::Png) + .unwrap(); for size in [ Vec2::new(1000.0, 720.0), Vec2::new(1440.0, 940.0), Vec2::new(2000.0, 720.0), ] { - for captions in [false, true] { + for (captions, reference) in + [(false, false), (true, false), (false, true), (true, true)] + { let ctx = egui::Context::default(); let mut app = Editor { show_toolbar_icon_names: captions, @@ -4176,6 +4179,18 @@ mod tests { pan: Vec2::new(100.0, -200.0), ..Default::default() }; + if reference { + app.load_reference( + &ctx, + &egui::DroppedFile { + name: "reference.png".into(), + bytes: Some(png.get_ref().clone().into()), + ..Default::default() + }, + ); + app.wait_reference(); + assert_eq!(app.references.len(), 1); + } app.fit_screen(); let output = ctx.run( egui::RawInput { diff --git a/crates/midra-layout/src/main.rs b/crates/midra-layout/src/main.rs index 743353a..34d81d6 100644 --- a/crates/midra-layout/src/main.rs +++ b/crates/midra-layout/src/main.rs @@ -130,10 +130,9 @@ fn artwork_scale(output: [u32; 2]) -> f32 { (output[0] as f32 / 1920.0).min(output[1] as f32 / 1080.0) } -fn screen_artwork(ink: &Ink, title: &str, output: [u32; 2]) { +fn screen_labels(ink: &Ink, output: [u32; 2]) { let palette = theme::palette(ink.painter.ctx()); let width = output[0] as f32 / 2.0; - let height = output[1] as f32 / 2.0; let k = artwork_scale(output); ink.text( 0.0, @@ -149,6 +148,13 @@ fn screen_artwork(ink: &Ink, title: &str, output: [u32; 2]) { FontId::proportional(13.0 * k * ink.scale), palette.muted, ); +} + +fn screen_artwork(ink: &Ink, title: &str, output: [u32; 2]) { + let palette = theme::palette(ink.painter.ctx()); + let width = output[0] as f32 / 2.0; + let height = output[1] as f32 / 2.0; + let k = artwork_scale(output); ink.rect(0.0, 0.0, width, height, palette.canvas); screen_title(ink, title, output); for n in 0..=8 { diff --git a/docs/midra-layout/README.md b/docs/midra-layout/README.md index f373515..b85ed57 100644 --- a/docs/midra-layout/README.md +++ b/docs/midra-layout/README.md @@ -329,6 +329,9 @@ selection state, including when several layers are selected. ### Reference pictures +The screen name and output resolution remain visible above the output when reference +images are loaded; Fit screen includes room for both labels. + Imported images accumulate in a purple **Reference images** section below the layer list, newest/topmost first. **Add image…** and **+ Add…** accept multiple files. Use each eye icon to show/hide a guide, the remove icon to delete it, diff --git a/docs/midra-layout/changelog.md b/docs/midra-layout/changelog.md index e5cd009..485381c 100644 --- a/docs/midra-layout/changelog.md +++ b/docs/midra-layout/changelog.md @@ -4,6 +4,8 @@ ## Unreleased +- Keep the screen name and output resolution visible with reference images, reserving their fit-screen margin. Viewport tests check label visibility and clipping with and without imported images. + - Double-click again in visual crop mode to finish editing; preserve selection and framing. Viewport regression coverage checks entering, exiting and reopening without geometry changes. - Pool input captures across matching queued layers and automatic previews, including requests queued during a fetch. Share one decoded texture and consume matching requests on failure to avoid per-layer retries; preserve existing manual stills. Regression tests cover direct, automatic and import captures, failure handling and different-input isolation.