42 lines
1.2 KiB
Rust
42 lines
1.2 KiB
Rust
use crate::wrapper::NodeGraphExecutionResult;
|
|
use crate::wrapper::messages::DesktopWrapperMessage;
|
|
|
|
pub(crate) enum AppEvent {
|
|
UiUpdate(wgpu::Texture),
|
|
CursorChange(crate::window::Cursor),
|
|
ScheduleBrowserWork(std::time::Instant),
|
|
WebCommunicationInitialized,
|
|
DesktopWrapperMessage(DesktopWrapperMessage),
|
|
NodeGraphExecutionResult(NodeGraphExecutionResult),
|
|
Exit,
|
|
#[cfg(target_os = "macos")]
|
|
AddLaunchDocuments(Vec<std::path::PathBuf>),
|
|
#[cfg(target_os = "macos")]
|
|
MenuEvent {
|
|
id: String,
|
|
},
|
|
}
|
|
|
|
#[derive(Clone)]
|
|
pub(crate) struct AppEventScheduler {
|
|
pub(crate) proxy: winit::event_loop::EventLoopProxy,
|
|
pub(crate) sender: std::sync::mpsc::Sender<AppEvent>,
|
|
}
|
|
|
|
impl AppEventScheduler {
|
|
pub(crate) fn schedule(&self, event: AppEvent) {
|
|
let _ = self.sender.send(event);
|
|
self.proxy.wake_up();
|
|
}
|
|
}
|
|
|
|
pub(crate) trait CreateAppEventSchedulerEventLoopExt {
|
|
fn create_app_event_scheduler(&self, sender: std::sync::mpsc::Sender<AppEvent>) -> AppEventScheduler;
|
|
}
|
|
|
|
impl CreateAppEventSchedulerEventLoopExt for winit::event_loop::EventLoop {
|
|
fn create_app_event_scheduler(&self, sender: std::sync::mpsc::Sender<AppEvent>) -> AppEventScheduler {
|
|
AppEventScheduler { proxy: self.create_proxy(), sender }
|
|
}
|
|
}
|