use teksilo_core::{TeksiloWindowId, WindowConfig, WindowOps, WindowState};
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct RecordedWindow {
pub title: String,
pub string_id: Option<String>,
pub size: (u32, u32),
pub assigned_id: TeksiloWindowId,
}
#[derive(Debug, Default)]
pub struct RecordingWindowOps {
next_id: u64,
pub opened: Vec<RecordedWindow>,
pub focused: Vec<TeksiloWindowId>,
pub closed: Vec<TeksiloWindowId>,
}
impl RecordingWindowOps {
pub fn new() -> Self {
Self::default()
}
}
impl WindowOps for RecordingWindowOps {
fn open_window(&mut self, config: WindowConfig) -> TeksiloWindowId {
let id = TeksiloWindowId::new(0x1000_0000 + self.next_id);
self.next_id += 1;
self.opened.push(RecordedWindow {
title: config.title.clone(),
string_id: config.string_id.clone(),
size: config.size,
assigned_id: id,
});
id
}
fn find_window(&self, string_id: &str) -> Option<TeksiloWindowId> {
self.opened
.iter()
.find(|w| w.string_id.as_deref() == Some(string_id))
.map(|w| w.assigned_id)
}
fn window_state(&self, _id: TeksiloWindowId) -> Option<WindowState> {
None
}
fn windows(&self) -> Vec<WindowState> {
Vec::new()
}
fn focus_window(&mut self, id: TeksiloWindowId) {
self.focused.push(id);
}
fn close_window_by_id(&mut self, id: TeksiloWindowId) {
self.closed.push(id);
}
}