windows: the Presenter View and View New Window are ordinary app windows

Production opens both with ViewportBuilder::default(): the OS frame with
its title and close button, a taskbar entry and the normal level, and a
body that fills the window. The port opened them as tool windows: palettes
with no taskbar entry and the dialog's own title row inside a padded
frame. Both now take ViewportWindowKind::App (q352 = A).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Dylan M. Taylor
2026-11-28 11:29:53 +00:00
co-authored by Claude Opus 5.5
parent b99f4987c7
commit d313344470
2 changed files with 40 additions and 38 deletions
+38 -37
View File
@@ -11,7 +11,7 @@ use craft::ui::display::{Picture, PictureSize, Shade, Text};
use craft::ui::layout_components::Stack;
use craft::ui::list::ThumbAspect;
use craft::ui::primitives::Revision;
use craft::ui::shell::ViewportWindow;
use craft::ui::shell::{ViewportWindow, ViewportWindowKind};
use craft::ui::style::{SurfaceKind, TypeRole};
use deckcraft_render::RenderOpts;
use serde_json::{Value, json};
@@ -92,44 +92,45 @@ pub fn show(app: &mut SlideApp, ui: &mut egui::Ui) {
w.slide = slide;
}
let grayscale = app.ui.grayscale;
let shown = ViewportWindow::new(title.clone()).remember(SaveKey::new("deckcraft_ui_egui.doc_window")).show(ui, |ui, _| {
if let Some(w) = app.doc_window.as_mut() {
w.viewport = Some(ui.ctx().viewport_id());
}
let mut delta = None;
Stack::new()
.fill()
.surface(SurfaceKind::Canvas)
.header(|ui, _| {
Bar::new("Document navigation", BarKind::Tool)
.trailing(|ui, _| {
if Button::new("Previous").enabled(slide > 0).show(ui).clicked() {
delta = Some(-1);
}
if Button::new("Next").enabled(slide + 1 < n).show(ui).clicked() {
delta = Some(1);
}
})
.show(ui, |ui, _| {
Text::new(title.clone()).role(TypeRole::BodyStrong).show(ui);
Text::new(format!("Slide {} of {n}", slide + 1)).shade(Shade::Muted).show(ui);
let shown =
ViewportWindow::new(title.clone()).kind(ViewportWindowKind::App).remember(SaveKey::new("deckcraft_ui_egui.doc_window")).show(ui, |ui, _| {
if let Some(w) = app.doc_window.as_mut() {
w.viewport = Some(ui.ctx().viewport_id());
}
let mut delta = None;
Stack::new()
.fill()
.surface(SurfaceKind::Canvas)
.header(|ui, _| {
Bar::new("Document navigation", BarKind::Tool)
.trailing(|ui, _| {
if Button::new("Previous").enabled(slide > 0).show(ui).clicked() {
delta = Some(-1);
}
if Button::new("Next").enabled(slide + 1 < n).show(ui).clicked() {
delta = Some(1);
}
})
.show(ui, |ui, _| {
Text::new(title.clone()).role(TypeRole::BodyStrong).show(ui);
Text::new(format!("Slide {} of {n}", slide + 1)).shade(Shade::Muted).show(ui);
});
})
.show(ui, |ui, _| {
Stack::new().fill().pad(Pad::Regular).show(ui, |ui, _| {
let (w, h) = pixel_size(&doc, ui.available_width() * ui.ctx().pixels_per_point());
let key = (uid, revision, slide, w, h, grayscale);
Picture::new("Slide preview", uid, &|| slide_image(&doc, key))
.revision(Revision::of(&key))
.aspect(ThumbAspect::from_ratio((doc.slide_size.width / doc.slide_size.height) as f32))
.extent(PictureSize::Fit)
.show(ui);
});
})
.show(ui, |ui, _| {
Stack::new().fill().pad(Pad::Regular).show(ui, |ui, _| {
let (w, h) = pixel_size(&doc, ui.available_width() * ui.ctx().pixels_per_point());
let key = (uid, revision, slide, w, h, grayscale);
Picture::new("Slide preview", uid, &|| slide_image(&doc, key))
.revision(Revision::of(&key))
.aspect(ThumbAspect::from_ratio((doc.slide_size.width / doc.slide_size.height) as f32))
.extent(PictureSize::Fit)
.show(ui);
});
});
if let Some(delta) = delta {
let _ = app.run("view.newWindow", json!({"delta": delta}));
}
});
if let Some(delta) = delta {
let _ = app.run("view.newWindow", json!({"delta": delta}));
}
});
if shown.close_requested.is_some() {
app.doc_window = None;
}
+2 -1
View File
@@ -8,7 +8,7 @@ use craft::ui::contract::{Politeness, Show as _};
use craft::ui::notices::{Notice, NoticeAction, NoticeLayout};
use craft::ui::runtime::commands::{CommandRef, CommandSet as _};
use craft::ui::runtime::env::Env;
use craft::ui::shell::ViewportWindow;
use craft::ui::shell::{ViewportWindow, ViewportWindowKind};
use craft::web_host::link::{LinkError, LinkState, WindowLink};
use deckcraft_render::RenderOpts;
use std::sync::Arc;
@@ -135,6 +135,7 @@ pub(super) fn presenter_pass(ui: &mut Ui, app: &mut crate::SlideApp, show: &mut
slides: super::GridSource::Deck { doc, thumbs: &thumbs, source: &source },
};
ViewportWindow::new(Word::plain("Presenter View — DeckCraft"))
.kind(ViewportWindowKind::App)
// The view lays itself out over the window's room: the pictures, notes and slide grid fit it, and the
// notes and the grid scroll themselves.
.overlay(|overlay| overlay.size(egui::vec2(1100.0, 700.0)).body_scroll(false))