use std::cell::RefCell;
use std::rc::Rc;
use waft_embedder::{CaptionSettings, CaptionStyle, MediaChangeFuture};
use crate::media::Changes;
#[derive(Clone)]
pub struct MockCaptionSettings(Rc<CaptionSettingsShared>);
struct CaptionSettingsShared {
style: RefCell<CaptionStyle>,
changes: Changes,
}
impl MockCaptionSettings {
pub fn new(style: CaptionStyle) -> MockCaptionSettings {
MockCaptionSettings(Rc::new(CaptionSettingsShared {
style: RefCell::new(style),
changes: Changes::default(),
}))
}
pub fn set_style(&self, style: CaptionStyle) {
*self.0.style.borrow_mut() = style;
self.0.changes.notify();
}
}
impl CaptionSettings for MockCaptionSettings {
fn style(&self) -> CaptionStyle {
self.0.style.borrow().clone()
}
fn changed(&self) -> MediaChangeFuture {
self.0.changes.next()
}
}