use ass_core::parser::ast::EventType;
#[cfg(feature = "std")]
use std::borrow::Cow;
#[cfg(not(feature = "std"))]
use alloc::{borrow::Cow, string::ToString};
#[derive(Debug, Default)]
pub struct EventBuilder<'a> {
pub(super) event_type: Option<EventType>,
pub(super) start: Option<Cow<'a, str>>,
pub(super) end: Option<Cow<'a, str>>,
pub(super) style: Option<Cow<'a, str>>,
pub(super) name: Option<Cow<'a, str>>,
pub(super) text: Option<Cow<'a, str>>,
pub(super) layer: Option<Cow<'a, str>>,
pub(super) margin_l: Option<Cow<'a, str>>,
pub(super) margin_r: Option<Cow<'a, str>>,
pub(super) margin_v: Option<Cow<'a, str>>,
pub(super) margin_t: Option<Cow<'a, str>>,
pub(super) margin_b: Option<Cow<'a, str>>,
pub(super) effect: Option<Cow<'a, str>>,
}
impl<'a> EventBuilder<'a> {
pub fn new() -> Self {
Self::default()
}
pub fn dialogue() -> Self {
Self {
event_type: Some(EventType::Dialogue),
..Self::default()
}
}
pub fn comment() -> Self {
Self {
event_type: Some(EventType::Comment),
..Self::default()
}
}
pub fn start_time<S: Into<Cow<'a, str>>>(mut self, time: S) -> Self {
self.start = Some(time.into());
self
}
pub fn end_time<S: Into<Cow<'a, str>>>(mut self, time: S) -> Self {
self.end = Some(time.into());
self
}
pub fn speaker<S: Into<Cow<'a, str>>>(mut self, name: S) -> Self {
self.name = Some(name.into());
self
}
pub fn text<S: Into<Cow<'a, str>>>(mut self, text: S) -> Self {
self.text = Some(text.into());
self
}
pub fn style<S: Into<Cow<'a, str>>>(mut self, style: S) -> Self {
self.style = Some(style.into());
self
}
pub fn layer(mut self, layer: u32) -> Self {
self.layer = Some(Cow::Owned(layer.to_string()));
self
}
pub fn margin_left(mut self, margin: u32) -> Self {
self.margin_l = Some(Cow::Owned(margin.to_string()));
self
}
pub fn margin_right(mut self, margin: u32) -> Self {
self.margin_r = Some(Cow::Owned(margin.to_string()));
self
}
pub fn margin_vertical(mut self, margin: u32) -> Self {
self.margin_v = Some(Cow::Owned(margin.to_string()));
self
}
pub fn margin_top(mut self, margin: u32) -> Self {
self.margin_t = Some(Cow::Owned(margin.to_string()));
self
}
pub fn margin_bottom(mut self, margin: u32) -> Self {
self.margin_b = Some(Cow::Owned(margin.to_string()));
self
}
pub fn effect<S: Into<Cow<'a, str>>>(mut self, effect: S) -> Self {
self.effect = Some(effect.into());
self
}
}