use std::sync::Arc;
pub struct SendPtr<T>(*const T);
impl<T> SendPtr<T> {
pub fn new(ptr: *const T) -> Self {
Self(ptr)
}
pub unsafe fn get(&self) -> &T {
&*self.0
}
pub fn as_ptr(&self) -> *const T {
self.0
}
}
impl<T> Clone for SendPtr<T> {
fn clone(&self) -> Self {
Self(self.0)
}
}
impl<T> Copy for SendPtr<T> {}
unsafe impl<T> Send for SendPtr<T> {}
unsafe impl<T> Sync for SendPtr<T> {}
#[derive(Clone, Copy, Debug)]
pub enum RawWindowHandle {
AppKit(*mut std::ffi::c_void), Win32(*mut std::ffi::c_void), X11(u64), }
pub trait Editor: Send {
fn size(&self) -> (u32, u32);
fn open(&mut self, parent: RawWindowHandle, context: EditorContext);
fn close(&mut self);
fn idle(&mut self) {}
fn set_size(&mut self, _width: u32, _height: u32) -> bool {
false
}
fn can_resize(&self) -> bool {
false
}
fn set_scale_factor(&mut self, _factor: f64) {}
}
#[derive(Clone)]
pub struct EditorContext {
pub begin_edit: Arc<dyn Fn(u32) + Send + Sync>,
pub set_param: Arc<dyn Fn(u32, f64) + Send + Sync>,
pub end_edit: Arc<dyn Fn(u32) + Send + Sync>,
pub request_resize: Arc<dyn Fn(u32, u32) -> bool + Send + Sync>,
pub get_param: Arc<dyn Fn(u32) -> f64 + Send + Sync>,
pub get_param_plain: Arc<dyn Fn(u32) -> f64 + Send + Sync>,
pub format_param: Arc<dyn Fn(u32) -> String + Send + Sync>,
pub get_meter: Arc<dyn Fn(u32) -> f32 + Send + Sync>,
}