use crate::types::{Coord, PositionProps};
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum MediaType {
Video,
Audio,
}
#[derive(Debug, Clone)]
pub struct MediaObject {
pub object_name: String,
pub media_type: MediaType,
pub media_rid: u32,
pub poster_rid: Option<u32>,
pub extension: String,
pub options: MediaOptions,
}
#[derive(Debug, Clone)]
pub struct MediaOptions {
pub position: PositionProps,
pub alt_text: Option<String>,
}
impl Default for MediaOptions {
fn default() -> Self {
MediaOptions {
position: PositionProps::default(),
alt_text: None,
}
}
}
pub struct MediaOptionsBuilder {
opts: MediaOptions,
}
impl MediaOptionsBuilder {
pub fn new() -> Self {
MediaOptionsBuilder { opts: MediaOptions::default() }
}
pub fn x(mut self, v: f64) -> Self { self.opts.position.x = Some(Coord::Inches(v)); self }
pub fn y(mut self, v: f64) -> Self { self.opts.position.y = Some(Coord::Inches(v)); self }
pub fn w(mut self, v: f64) -> Self { self.opts.position.w = Some(Coord::Inches(v)); self }
pub fn h(mut self, v: f64) -> Self { self.opts.position.h = Some(Coord::Inches(v)); self }
pub fn pos(self, x: f64, y: f64) -> Self { self.x(x).y(y) }
pub fn size(self, w: f64, h: f64) -> Self { self.w(w).h(h) }
pub fn rect(self, r: crate::layout::CellRect) -> Self {
self.pos(r.x, r.y).size(r.w, r.h)
}
pub fn bounds(self, x: f64, y: f64, w: f64, h: f64) -> Self {
self.pos(x, y).size(w, h)
}
pub fn alt_text(mut self, t: impl Into<String>) -> Self { self.opts.alt_text = Some(t.into()); self }
pub fn build(self) -> MediaOptions {
self.opts
}
}
impl Default for MediaOptionsBuilder {
fn default() -> Self {
Self::new()
}
}