mirror of
https://github.com/storytold/deckcraft.git
synced 2026-12-01 10:13:09 -06:00
presenter: production's padding and spacing, a filled end placeholder, a centred All slides heading on a dark sheet; View New Window opens at 960x640 with plain Previous/Next
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
250c2fc80e
commit
023f93bb46
@@ -4,6 +4,7 @@
|
||||
//! selection. It does not edit, and Arrange All is not here. Closing the window leaves the
|
||||
//! presentation open.
|
||||
|
||||
use craft::theme::Variant;
|
||||
use craft::ui::bars::{Bar, BarKind};
|
||||
use craft::ui::buttons::Button;
|
||||
use craft::ui::contract::{Pad, Props as _, SaveKey, Show as _, ShowContainer as _};
|
||||
@@ -92,8 +93,11 @@ pub fn show(app: &mut SlideApp, ui: &mut egui::Ui) {
|
||||
w.slide = slide;
|
||||
}
|
||||
let grayscale = app.ui.grayscale;
|
||||
let shown =
|
||||
ViewportWindow::new(title.clone()).kind(ViewportWindowKind::App).remember(SaveKey::new("deckcraft_ui_egui.doc_window")).show(ui, |ui, _| {
|
||||
let shown = ViewportWindow::new(title.clone())
|
||||
.kind(ViewportWindowKind::App)
|
||||
.overlay(|overlay| overlay.size(egui::vec2(960.0, 640.0)).min_size(egui::vec2(480.0, 360.0)))
|
||||
.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());
|
||||
}
|
||||
@@ -104,10 +108,10 @@ pub fn show(app: &mut SlideApp, ui: &mut egui::Ui) {
|
||||
.header(|ui, _| {
|
||||
Bar::new("Document navigation", BarKind::Tool)
|
||||
.trailing(|ui, _| {
|
||||
if Button::new("Previous").enabled(slide > 0).show(ui).clicked() {
|
||||
if Button::new("Previous").variant(Variant::GHOST).enabled(slide > 0).show(ui).clicked() {
|
||||
delta = Some(-1);
|
||||
}
|
||||
if Button::new("Next").enabled(slide + 1 < n).show(ui).clicked() {
|
||||
if Button::new("Next").variant(Variant::GHOST).enabled(slide + 1 < n).show(ui).clicked() {
|
||||
delta = Some(1);
|
||||
}
|
||||
})
|
||||
@@ -117,7 +121,7 @@ pub fn show(app: &mut SlideApp, ui: &mut egui::Ui) {
|
||||
});
|
||||
})
|
||||
.show(ui, |ui, _| {
|
||||
Stack::new().fill().pad(Pad::Regular).show(ui, |ui, _| {
|
||||
Stack::new().fill().pad(Pad::Roomy).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))
|
||||
|
||||
@@ -82,7 +82,7 @@ pub fn presenter_body(ui: &mut egui::Ui, _cx: &mut BodyCx<'_>, model: &Presenter
|
||||
.command_scope(ShowCommands::SCOPE)
|
||||
.theme(ThemeScope::new().mode(Mode::Dark))
|
||||
.surface(SurfaceKind::Background)
|
||||
.pad(Pad::Regular)
|
||||
.pad(Pad::Roomy)
|
||||
.gap(Gap::Stack)
|
||||
.show(ui, |ui, cx| {
|
||||
for (command, checked, title) in [
|
||||
@@ -96,7 +96,7 @@ pub fn presenter_body(ui: &mut egui::Ui, _cx: &mut BodyCx<'_>, model: &Presenter
|
||||
cx.publish(command, CommandState::new().checked(checked).title(title.as_str()));
|
||||
}
|
||||
Row::new().fill_width().align(RowAlign::SpaceBetween).show(ui, |ui, _| {
|
||||
Row::new().gap(Gap::Inline).show(ui, |ui, cx| {
|
||||
Row::new().gap(Gap::Section).show(ui, |ui, cx| {
|
||||
Text::new(crate::show::format_elapsed(model.elapsed))
|
||||
.role(TypeRole::Heading)
|
||||
.shade(if model.paused { Shade::Muted } else { Shade::Normal })
|
||||
@@ -211,7 +211,7 @@ fn pictures_and_notes(ui: &mut egui::Ui, model: &PresenterModel<'_>, aspect: f32
|
||||
Picture::painter(Word::plain("Next slide"), ThumbAspect::from_ratio(aspect), |cx, rect| match model.next {
|
||||
NextPic::Shown(texture) => cx.picture(texture.id, rect, texture.uv(), 0.0),
|
||||
NextPic::Pending | NextPic::End => {
|
||||
cx.surface(rect, SurfaceKind::Sunken, craft::ui::style::Corners::None);
|
||||
cx.surface(rect, SurfaceKind::Panel, craft::ui::style::Corners::None);
|
||||
if matches!(model.next, NextPic::End) {
|
||||
cx.with_draw(|draw| {
|
||||
draw.text(rect, &TextRun::new(end.as_str()).role(TypeRole::Caption).align(craft::ui::primitives::HAlign::Center));
|
||||
|
||||
@@ -2,12 +2,13 @@ use super::zoom::{GRID_CAP, grid_indices};
|
||||
use crate::thumb_source::{self, ThumbKey};
|
||||
use craft::behavior::{Flow, ItemLayout as _, Proposal, ScrollPos, Selection};
|
||||
use craft::i18n::{Direction, Word};
|
||||
use craft::ui::contract::{ActivateOn, Bind, CollectionEvent, Gap, SelectMode, Show as _, ShowCollection as _, ShowContainer as _};
|
||||
use craft::ui::contract::{ActivateOn, Bind, CollectionEvent, Gap, Pad, SelectMode, Show as _, ShowCollection as _, ShowContainer as _};
|
||||
use craft::ui::display::{Elide, Picture, Shade, Text};
|
||||
use craft::ui::layout_components::Stack;
|
||||
use craft::ui::layout::RowAlign;
|
||||
use craft::ui::layout_components::{Row, Stack};
|
||||
use craft::ui::list::ThumbAspect;
|
||||
use craft::ui::runtime::env::Env;
|
||||
use craft::ui::style::TypeRole;
|
||||
use craft::ui::style::{SurfaceKind, TypeRole};
|
||||
use craft::ui::tile_grid::{ColumnRule, Tile, TileGrid};
|
||||
use egui::{Rect, Ui};
|
||||
|
||||
@@ -45,11 +46,16 @@ fn grid<'a>(aspect: f32) -> TileGrid<'a, usize> {
|
||||
}
|
||||
|
||||
fn heading(ui: &mut Ui, note: bool) {
|
||||
Text::new(Word::plain("All slides")).role(TypeRole::Heading).elide(Elide::End).show(ui);
|
||||
let centred = || Row::new().fill_width().align(RowAlign::Center);
|
||||
centred().show(ui, |ui, _| {
|
||||
Text::new(Word::plain("All slides")).role(TypeRole::Heading).elide(Elide::End).show(ui);
|
||||
});
|
||||
if note {
|
||||
let env = Env::of(ui);
|
||||
let text = env.words.get(Word::plain("First {n} slides")).replace("{n}", &GRID_CAP.to_string());
|
||||
Text::new(text).shade(Shade::Muted).elide(Elide::End).show(ui);
|
||||
centred().show(ui, |ui, _| {
|
||||
Text::new(text.clone()).shade(Shade::Muted).elide(Elide::End).show(ui);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,6 +64,8 @@ fn header() -> Stack<'static> {
|
||||
}
|
||||
|
||||
fn rooms(ctx: &egui::Context, env: &Env, room: Rect, note: bool) -> (Rect, Rect) {
|
||||
// The sheet's `Pad::Roomy`.
|
||||
let room = room.shrink(env.tokens.space.pad.roomy);
|
||||
let height = header().measure_with_env(ctx, env, Proposal::Ideal, |ui, _| heading(ui, note)).y.min(room.height().max(0.0));
|
||||
let head = Rect::from_min_size(room.min, egui::vec2(room.width(), height));
|
||||
let body = Rect::from_min_max(head.left_bottom(), room.max);
|
||||
@@ -91,6 +99,8 @@ pub(crate) fn sheet(ui: &mut Ui, slides: GridSource<'_>, current: usize, aspect:
|
||||
let mut result = GridPick { picked: None, cells: vec![] };
|
||||
Stack::new()
|
||||
.fill()
|
||||
.surface(SurfaceKind::Canvas)
|
||||
.pad(Pad::Roomy)
|
||||
.gap(Gap::None)
|
||||
.header(|ui, _| {
|
||||
header().show(ui, |ui, _| heading(ui, note));
|
||||
|
||||
@@ -142,6 +142,35 @@ fn presenter_all_slides_does_not_cover_the_audience_screen() {
|
||||
assert!(!harness.state().show.as_ref().unwrap().presenter_grid, "G again closes it");
|
||||
}
|
||||
|
||||
/// The All slides cells the control channel reports are the tiles the sheet draws, padding and heading included, so a
|
||||
/// driver's click on a reported cell lands on its slide.
|
||||
#[test]
|
||||
fn the_reported_grid_cells_are_the_drawn_tiles() {
|
||||
use egui_kittest::kittest::Queryable;
|
||||
|
||||
let mut session = deckcraft_engine::Session::with_new();
|
||||
for _ in 0..5 {
|
||||
session.execute("slide.new", &json!({})).unwrap();
|
||||
}
|
||||
let doc = session.active().unwrap().doc.clone();
|
||||
let mut harness = harness_with(session, Services::default(), egui_kittest::Harness::builder().with_size(vec2(1100.0, 700.0)), |_| {});
|
||||
let mut show = Show::new(&doc, 0, false, false);
|
||||
show.grid = true;
|
||||
harness.state_mut().show = Some(show);
|
||||
harness.run_steps(2);
|
||||
let ctx = harness.ctx.clone();
|
||||
let value =
|
||||
harness.state().show.as_ref().unwrap().showing_value(&ctx, doc.slides.len(), super::zoom::slide_aspect(&doc), ctx.content_rect(), 0.0);
|
||||
let cells = value["cells"].as_array().expect("the grid reports its cells");
|
||||
assert_eq!(cells.len(), doc.slides.len());
|
||||
for cell in cells {
|
||||
let slide = cell["slide"].as_u64().unwrap();
|
||||
let at = pos2(cell["x"].as_f64().unwrap() as f32, cell["y"].as_f64().unwrap() as f32);
|
||||
let tile = harness.get_by_label(&(slide + 1).to_string()).rect();
|
||||
assert!(tile.contains(at) && tile.center().distance(at) < 1.0, "slide {}: reported {at:?}, drawn {tile:?}", slide + 1);
|
||||
}
|
||||
}
|
||||
|
||||
/// A silent mono 8 kHz WAV, so the clip has a real duration to seek in.
|
||||
fn silent_wav(secs: u32) -> Vec<u8> {
|
||||
let rate = 8_000u32;
|
||||
|
||||
Reference in New Issue
Block a user