Skip to main content

dais_sidecar/
types.rs

1use std::collections::HashMap;
2
3/// Dais's internal presentation metadata — the authoritative representation.
4///
5/// This is not tied to any specific file format. `.pdfpc` compatibility and
6/// Dais-native sidecar files are serializations of these shared types.
7#[derive(Debug, Clone, Default)]
8pub struct PresentationMetadata {
9    /// Presentation title, if known.
10    pub title: Option<String>,
11    /// Slide group definitions (page ranges).
12    pub groups: Vec<SlideGroupMeta>,
13    /// Per-page notes (`page_index` → markdown content).
14    pub notes: HashMap<usize, String>,
15    /// Optional "end" slide marker (page index after which slides are backup).
16    pub end_slide: Option<usize>,
17    /// Timer duration hint from sidecar, in minutes.
18    pub last_minutes: Option<u32>,
19    /// Per-slide timing data (logical slide index → seconds spent).
20    pub slide_timings: HashMap<usize, f64>,
21    /// Planned per-slide durations (logical slide index → target seconds).
22    pub slide_target_durations: HashMap<usize, f64>,
23    /// Per-page slide annotations (`page_index` → completed strokes).
24    pub slide_annotations: HashMap<usize, Vec<InkStrokeMeta>>,
25    /// Whiteboard annotations (not tied to any slide).
26    pub whiteboard_annotations: Vec<InkStrokeMeta>,
27    /// Per-page text box overlays (`page_index` → boxes).
28    pub slide_text_boxes: HashMap<usize, Vec<TextBoxMeta>>,
29}
30
31/// A contiguous range of PDF pages forming one logical slide.
32#[derive(Debug, Clone)]
33pub struct SlideGroupMeta {
34    /// First page index in this group (0-based, inclusive).
35    pub start_page: usize,
36    /// Last page index in this group (0-based, inclusive).
37    pub end_page: usize,
38}
39
40/// A serializable ink stroke for sidecar persistence.
41#[derive(Debug, Clone, PartialEq)]
42pub struct InkStrokeMeta {
43    /// Points along the stroke (normalized 0..1 coordinates).
44    pub points: Vec<(f32, f32)>,
45    /// Stroke color as RGBA.
46    pub color: [u8; 4],
47    /// Stroke width in logical pixels.
48    pub width: f32,
49}
50
51/// A serializable text box for sidecar persistence.
52#[derive(Debug, Clone, PartialEq)]
53pub struct TextBoxMeta {
54    /// Unique identifier.
55    pub id: u64,
56    /// Normalized position and size: (x, y, w, h) in 0..1 coordinates.
57    pub rect: (f32, f32, f32, f32),
58    /// Text/Typst content.
59    pub content: String,
60    /// Font size in points.
61    pub font_size: f32,
62    /// Text color as RGBA.
63    pub color: [u8; 4],
64    /// Optional background fill as RGBA.
65    pub background: Option<[u8; 4]>,
66    /// Additional Typst setup inserted after Dais defaults and before content.
67    pub typst_prelude: String,
68}