From d3133444703f3be2f025c0f2dabff73adbbfb5ed Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Sat, 28 Nov 2026 11:29:53 +0000 Subject: [PATCH] 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 --- crates/ui-egui/src/doc_window.rs | 75 ++++++++++++++-------------- crates/ui-egui/src/show/presenter.rs | 3 +- 2 files changed, 40 insertions(+), 38 deletions(-) diff --git a/crates/ui-egui/src/doc_window.rs b/crates/ui-egui/src/doc_window.rs index 1eb123efd..ea90fe244 100644 --- a/crates/ui-egui/src/doc_window.rs +++ b/crates/ui-egui/src/doc_window.rs @@ -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; } diff --git a/crates/ui-egui/src/show/presenter.rs b/crates/ui-egui/src/show/presenter.rs index d40b8e16e..69aefd27e 100644 --- a/crates/ui-egui/src/show/presenter.rs +++ b/crates/ui-egui/src/show/presenter.rs @@ -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))