show: letterbox the slide in black with the slide page's pasteboard

The show canvas set a black pasteboard colour but showed no Pasteboard, so the
bands around the slide were the canvas surface. The show body now shows the
slide page with no border under everything it draws.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Dylan M. Taylor
2026-11-28 20:27:13 +00:00
co-authored by Claude Opus 5.5
parent 62ab9ac554
commit ef1dd23549
2 changed files with 36 additions and 3 deletions
+30
View File
@@ -62,6 +62,36 @@ fn a_still_cursor_hides_over_a_clickable_shape() {
assert_eq!(craft::ui::runtime::cursor::current(&harness.ctx), Some(Cursor::Painted(PaintedCursor::Hidden)), "still for 3 s: hidden");
}
/// The bands a window of another shape leaves around the slide are black, as a projector shows them, not the editor's
/// canvas surface.
#[test]
fn the_show_letterboxes_the_slide_in_black() {
fn fills(shapes: &[egui::Shape], at: Pos2, out: &mut Vec<egui::Color32>) {
for shape in shapes {
match shape {
egui::Shape::Vec(nested) => fills(nested, at, out),
egui::Shape::Rect(r) if r.rect.contains(at) => out.push(r.fill),
egui::Shape::Path(p) if p.closed && egui::Rect::from_points(&p.points).contains(at) => out.push(p.fill),
egui::Shape::Mesh(m) if m.calc_bounds().contains(at) => out.extend(m.vertices.first().map(|v| v.color)),
_ => {}
}
}
}
let session = deckcraft_engine::Session::with_new();
let mut harness = harness_with(session, Services::default(), egui_kittest::Harness::builder().with_size(vec2(1000.0, 700.0)), |_| {});
harness.state_mut().ui.presenter_view = false;
harness.run_steps(3);
harness.state_mut().start_show(0, false);
harness.run_steps(3);
// A 16:9 slide in a 10:7 window leaves a band above it.
let band = pos2(500.0, 8.0);
let shapes: Vec<egui::Shape> = harness.output().shapes.iter().map(|clipped| clipped.shape.clone()).collect();
let mut painted = Vec::new();
fills(&shapes, band, &mut painted);
let top = painted.into_iter().rev().find(|fill| fill.a() == 255).expect("something opaque is painted over the band");
assert!(top.r().max(top.g()).max(top.b()) < 16, "the band above the slide is {top:?}");
}
/// #1445: Keep mouse cursor visible leaves a still pointer showing over a link, so a branching
/// deck's choices stay targetable; the setting outlives the show and the link still follows.
#[test]
+6 -3
View File
@@ -5,15 +5,15 @@ use super::presenter::{PresenterTimer, presenter_pass};
use super::tool::{Out, ShowTool};
use super::{Blank, PresenterStart, Show, ShowZoomInputs, SlideApp, bars, grid};
use craft::behavior::canvas::zoom;
use craft::behavior::kurbo::{Point, Size};
use craft::behavior::kurbo::{Point, Rect as DocRect, Size};
use craft::behavior::{CanvasView, IconId, PixelSize, Proposal, ZoomFloor, ZoomScheme};
use craft::theme::ControlSize;
use craft::timeline::ui::transport::MediaControls;
use craft::ui::bars::BarBackgroundPress;
use craft::ui::buttons::IconButton;
use craft::ui::canvas::{
AppPaint, Canvas, NavigationOptions, PasteboardColor, RasterDisplay, ToolHost, ViewCommands, ViewFit, ViewTarget, WheelScheme, tool_pass,
with_canvas_space,
AppPaint, Canvas, NavigationOptions, PageBorder, PageFrame, Pasteboard, PasteboardColor, RasterDisplay, ToolHost, ViewCommands, ViewFit,
ViewTarget, WheelScheme, tool_pass, with_canvas_space,
};
use craft::ui::contract::{Bind, BodyCx, Props as _, Show as _, ShowContainer as _, clicked};
use craft::ui::primitives::texture_side;
@@ -155,6 +155,9 @@ fn canvas_pass(app: &mut SlideApp, ui: &mut Ui, bcx: &mut BodyCx<'_>, show: &mut
.show(&mut child, |ui, body| {
let Some(mut pass) = tool_pass(&body.env) else { return };
let Some(mut space) = pass.space else { return };
// The letterbox around the slide is the canvas's black pasteboard, under everything the show draws.
let page = [PageFrame::new(DocRect::from_origin_size((0.0, 0.0), p.zoom.size))];
Pasteboard::new(Word::plain("Slide show pasteboard"), &page).border(PageBorder::None).show_at(ui, body.rect);
let given = show.view.zoom;
show.view = pass.view.unwrap_or_else(|| space.target());
// The canvas zooms only with Ctrl or Cmd + wheel here; that zoom takes over an armed zoom click.