//! What ElyShow keeps per deck. use std::{ collections::{HashMap, HashSet}, sync::Arc, }; use ely_lok::{ Sheets, history::Step, show::{Design, Objects}, }; use gpui::RenderImage; /// Parts, edits, caret and selected frame. pub type Seen = (u64, u64, bool, Option); /// What ElyShow keeps per deck. #[derive(Default)] pub struct Extra { pub slides: Sheets, /// The document as the last read saw it. pub read_at: Option, /// What the view showed at the last read. pub read: Option, pub reading: bool, pub design: Option, pub objects: Option, pub notes: Option, pub remarks: Vec, /// The shown slide's transition and effects; none on a master. pub motion: Option<(ely_lok::show::Transition, Vec)>, pub media: Vec, /// Counts completed reads. pub reads: u64, /// The slide size in twips. pub size: (i64, i64), /// Undo and redo lists at the last read. pub history: Option<(Vec, Vec)>, /// A size sent (1/100 mm) and its input, until read. pub size_asked: Option<((i64, i64), u64)>, /// A transition sent for a slide, until read back. pub transition_asked: Option<(String, ely_lok::show::Transition, u64)>, /// Pictures by slide name; stale ones show until repainted. pub thumbs: HashMap>, pub retired: ely_gpui_component::primitives::Retired, pub stale: HashSet, /// Pictures that failed; retried after the next read. pub failed: HashSet, pub painting: bool, /// The parts are masters. pub masters: bool, /// The scheme the pictures were painted with. pub dark: Option, /// The view was fitted to the slide once. pub fitted: bool, } impl Extra { /// The size to show, in 1/100 mm: asked, else read. pub fn shown_size(&self) -> (i64, i64) { self.size_asked .map_or_else(|| crate::design::mm100(self.size), |(size, _)| size) } /// The size input that landed before this read began. pub fn size_landed(&self, view: &ely_lok::LokView) -> Option { let (_, seq) = self.size_asked?; view.reached(seq).then_some(seq) } /// Forgets the asked size once read back, taken or refused. pub fn settle_size(&mut self, landed: Option) { let read = crate::design::mm100(self.size); if self.size_asked.is_some_and(|((w, h), seq)| { landed == Some(seq) || (w - read.0).abs() <= 50 && (h - read.1).abs() <= 50 }) { self.size_asked = None; } } }