#![allow(dead_code)]
use slint::PhysicalSize;
use slint::platform::software_renderer::{MinimalSoftwareWindow, RepaintBufferType};
use slint::platform::{PlatformError, WindowAdapter};
use std::rc::Rc;
thread_local! {
static WINDOW: Rc<MinimalSoftwareWindow> =
MinimalSoftwareWindow::new(RepaintBufferType::ReusedBuffer);
}
struct TestPlatform;
impl slint::platform::Platform for TestPlatform {
fn create_window_adapter(&self) -> Result<Rc<dyn WindowAdapter>, PlatformError> {
Ok(WINDOW.with(|x| x.clone()))
}
}
pub fn setup(width: u32, height: u32) -> Rc<MinimalSoftwareWindow> {
slint::platform::set_platform(Box::new(TestPlatform)).ok();
let window = WINDOW.with(|x| x.clone());
window.set_size(PhysicalSize::new(width, height));
window
}