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` is one serialization;
6/// a future `.dais` format will be another. The engine and UI work with these
7/// types exclusively.
8#[derive(Debug, Clone, Default)]
9pub struct PresentationMetadata {
10    /// Presentation title, if known.
11    pub title: Option<String>,
12    /// Slide group definitions (page ranges).
13    pub groups: Vec<SlideGroupMeta>,
14    /// Per-page notes (`page_index` → markdown content).
15    pub notes: HashMap<usize, String>,
16    /// Optional "end" slide marker (page index after which slides are backup).
17    pub end_slide: Option<usize>,
18    /// Timer duration hint from sidecar, in minutes.
19    pub last_minutes: Option<u32>,
20    /// Per-slide timing data (logical slide index → seconds spent).
21    pub slide_timings: HashMap<usize, f64>,
22    /// Per-page slide annotations (`page_index` → completed strokes).
23    pub slide_annotations: HashMap<usize, Vec<InkStrokeMeta>>,
24    /// Whiteboard annotations (not tied to any slide).
25    pub whiteboard_annotations: Vec<InkStrokeMeta>,
26    /// Per-page text box overlays (`page_index` → boxes).
27    pub slide_text_boxes: HashMap<usize, Vec<TextBoxMeta>>,
28}
29
30/// A contiguous range of PDF pages forming one logical slide.
31#[derive(Debug, Clone)]
32pub struct SlideGroupMeta {
33    /// First page index in this group (0-based, inclusive).
34    pub start_page: usize,
35    /// Last page index in this group (0-based, inclusive).
36    pub end_page: usize,
37}
38
39/// A serializable ink stroke for sidecar persistence.
40#[derive(Debug, Clone, PartialEq)]
41pub struct InkStrokeMeta {
42    /// Points along the stroke (normalized 0..1 coordinates).
43    pub points: Vec<(f32, f32)>,
44    /// Stroke color as RGBA.
45    pub color: [u8; 4],
46    /// Stroke width in logical pixels.
47    pub width: f32,
48}
49
50/// A serializable text box for sidecar persistence.
51#[derive(Debug, Clone, PartialEq)]
52pub struct TextBoxMeta {
53    /// Unique identifier.
54    pub id: u64,
55    /// Normalized position and size: (x, y, w, h) in 0..1 coordinates.
56    pub rect: (f32, f32, f32, f32),
57    /// Text/Typst content.
58    pub content: String,
59    /// Font size in points.
60    pub font_size: f32,
61    /// Text color as RGBA.
62    pub color: [u8; 4],
63    /// Optional background fill as RGBA.
64    pub background: Option<[u8; 4]>,
65}