From deed4858d9342752524b9fc86c7480ac67ac2587 Mon Sep 17 00:00:00 2001 From: AZ Software <66299945+AZProductions@users.noreply.github.com> Date: Thu, 29 Dec 2022 15:41:06 +0100 Subject: [PATCH] Windows Implementation without a timer --- src/lib.rs | 9 ++++++++- src/windows.rs | 25 ++++++++++++------------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 96d0662..cdd7ff3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -4,7 +4,12 @@ mod mac_os; #[cfg(target_os = "windows")] mod windows; +#[cfg(target_os = "macos")] use self::mac_os::{Timer}; + +#[cfg(target_os = "windows")] +use self::windows::{Timer}; + use nih_plug::prelude::{Editor, GuiContext, ParamSetter}; use raw_window_handle::RawWindowHandle; use serde_json::Value; @@ -177,8 +182,10 @@ impl Editor for WebViewEditor { let inner_context = self.context.clone(); let mut webview_builder = match parent.handle { + #[cfg(target_os = "macos")] RawWindowHandle::AppKit(handle) => WebViewBuilder::new(Window { ns_view: handle.ns_view }).unwrap(), - RawWindowHandle::Win32(_handle) => todo!("Windows implementation."), + #[cfg(target_os = "windows")] + RawWindowHandle::Win32(_handle) => WebViewBuilder::new(Window { hwnd: _handle.hwnd}).unwrap(), _ => panic!(), }; diff --git a/src/windows.rs b/src/windows.rs index 155ecf8..186ad15 100644 --- a/src/windows.rs +++ b/src/windows.rs @@ -10,13 +10,12 @@ pub struct Timer {} impl Timer { pub fn new(interval: f64, func: Box) -> Box { - todo!() + Box::new(Self{}) } } impl Drop for Timer { fn drop(&mut self) { - todo!() } } @@ -25,16 +24,16 @@ unsafe impl Send for Timer {} type Callback = Box; -impl NativeWebView { - pub fn new(handle: RawWindowHandle, source: Arc, size: (u32, u32), callback: Callback) -> Self { - todo!() - } +// impl NativeWebView { +// pub fn new(handle: RawWindowHandle, source: Arc, size: (u32, u32), callback: Callback) -> Self { +// todo!() +// } - pub fn set_size(&mut self, size: (u32, u32)) { - todo!() - } +// pub fn set_size(&mut self, size: (u32, u32)) { +// todo!() +// } - pub fn evaluate_javascript(&self, js: &str) { - todo!() - } -} +// pub fn evaluate_javascript(&self, js: &str) { +// todo!() +// } +// }