Keep screen labels visible with reference images
Beffroi/beffroi-tools/pipeline/head This commit looks good Details

This commit is contained in:
Dandaedre 2026-11-14 19:51:55 +01:00
parent d21fb9cf2a
commit ae0a7ee8c7
4 changed files with 34 additions and 8 deletions

View File

@ -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 {

View File

@ -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 {

View File

@ -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,

View File

@ -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.