Lock down test platform implementation

This commit is contained in:
Mikayla 2024-01-20 14:56:50 -08:00
parent 017661818d
commit 4184686e8d
No known key found for this signature in database
9 changed files with 20 additions and 33 deletions

View file

@ -10,7 +10,7 @@ use std::{
sync::{self, Arc},
};
pub struct TestWindowState {
pub(crate) struct TestWindowState {
pub(crate) bounds: WindowBounds,
pub(crate) handle: AnyWindowHandle,
display: Rc<dyn PlatformDisplay>,
@ -23,11 +23,11 @@ pub struct TestWindowState {
active_status_change_callback: Option<Box<dyn FnMut(bool)>>,
resize_callback: Option<Box<dyn FnMut(Size<Pixels>, f32)>>,
moved_callback: Option<Box<dyn FnMut()>>,
input_handler: Option<Box<dyn PlatformInputHandler>>,
input_handler: Option<PlatformInputHandler>,
}
#[derive(Clone)]
pub struct TestWindow(pub(crate) Arc<Mutex<TestWindowState>>);
pub(crate) struct TestWindow(pub(crate) Arc<Mutex<TestWindowState>>);
impl TestWindow {
pub fn new(
@ -117,9 +117,6 @@ impl TestWindow {
self.0.lock().input_handler = Some(input_handler);
}
pub fn edited(&self) -> bool {
self.0.lock().edited
}
}
impl PlatformWindow for TestWindow {
@ -163,11 +160,11 @@ impl PlatformWindow for TestWindow {
self
}
fn set_input_handler(&mut self, input_handler: Box<dyn crate::PlatformInputHandler>) {
fn set_input_handler(&mut self, input_handler: PlatformInputHandler) {
self.0.lock().input_handler = Some(input_handler);
}
fn take_input_handler(&mut self) -> Option<Box<dyn PlatformInputHandler>> {
fn take_input_handler(&mut self) -> Option<PlatformInputHandler> {
self.0.lock().input_handler.take()
}
@ -269,12 +266,12 @@ impl PlatformWindow for TestWindow {
}
}
pub struct TestAtlasState {
pub(crate) struct TestAtlasState {
next_id: u32,
tiles: HashMap<AtlasKey, AtlasTile>,
}
pub struct TestAtlas(Mutex<TestAtlasState>);
pub(crate) struct TestAtlas(Mutex<TestAtlasState>);
impl TestAtlas {
pub fn new() -> Self {