|
@@ -5,6 +5,10 @@ use std::sync::{Arc, RwLock};
|
|
|
|
|
|
use dioxus_core::*;
|
|
use dioxus_core::*;
|
|
|
|
|
|
|
|
+use wry::application::event::{Event, WindowEvent};
|
|
|
|
+use wry::application::event_loop::{ControlFlow, EventLoop};
|
|
|
|
+use wry::application::window::Fullscreen;
|
|
|
|
+use wry::webview::WebViewBuilder;
|
|
use wry::{
|
|
use wry::{
|
|
application::window::{Window, WindowBuilder},
|
|
application::window::{Window, WindowBuilder},
|
|
webview::{RpcRequest, RpcResponse},
|
|
webview::{RpcRequest, RpcResponse},
|
|
@@ -57,15 +61,6 @@ impl<T: Properties + 'static> WebviewRenderer<T> {
|
|
user_builder: impl FnOnce(WindowBuilder) -> WindowBuilder,
|
|
user_builder: impl FnOnce(WindowBuilder) -> WindowBuilder,
|
|
redits: Option<Vec<DomEdit<'static>>>,
|
|
redits: Option<Vec<DomEdit<'static>>>,
|
|
) -> anyhow::Result<()> {
|
|
) -> anyhow::Result<()> {
|
|
- use wry::{
|
|
|
|
- application::{
|
|
|
|
- event::{Event, StartCause, WindowEvent},
|
|
|
|
- event_loop::{ControlFlow, EventLoop},
|
|
|
|
- window::WindowBuilder,
|
|
|
|
- },
|
|
|
|
- webview::WebViewBuilder,
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
let event_loop = EventLoop::new();
|
|
let event_loop = EventLoop::new();
|
|
|
|
|
|
let window = user_builder(WindowBuilder::new()).build(&event_loop)?;
|
|
let window = user_builder(WindowBuilder::new()).build(&event_loop)?;
|
|
@@ -78,7 +73,7 @@ impl<T: Properties + 'static> WebviewRenderer<T> {
|
|
|
|
|
|
let webview = WebViewBuilder::new(window)?
|
|
let webview = WebViewBuilder::new(window)?
|
|
.with_url(&format!("data:text/html,{}", HTML_CONTENT))?
|
|
.with_url(&format!("data:text/html,{}", HTML_CONTENT))?
|
|
- .with_rpc_handler(move |window: &Window, mut req: RpcRequest| {
|
|
|
|
|
|
+ .with_rpc_handler(move |_window: &Window, mut req: RpcRequest| {
|
|
match req.method.as_str() {
|
|
match req.method.as_str() {
|
|
"initiate" => {
|
|
"initiate" => {
|
|
let edits = if let Some(edits) = &redits {
|
|
let edits = if let Some(edits) = &redits {
|
|
@@ -144,45 +139,6 @@ impl<T: Properties + 'static> WebviewRenderer<T> {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
});
|
|
});
|
|
-
|
|
|
|
- // let mut view = web_view::builder()
|
|
|
|
- // .invoke_handler(|view, arg| {
|
|
|
|
- // let handle = view.handle();
|
|
|
|
- // sender
|
|
|
|
- // .send(InnerEvent::Initiate(handle))
|
|
|
|
- // .expect("should not fail");
|
|
|
|
-
|
|
|
|
- // Ok(())
|
|
|
|
- // })
|
|
|
|
- // .content(web_view::Content::Html(HTML_CONTENT))
|
|
|
|
- // .user_data(())
|
|
|
|
- // .title(title)
|
|
|
|
- // .size(width, height)
|
|
|
|
- // .resizable(resizable)
|
|
|
|
- // .debug(debug)
|
|
|
|
- // .frameless(frameless)
|
|
|
|
- // .visible(visible)
|
|
|
|
- // .min_size(min_width, min_height)
|
|
|
|
- // .build()
|
|
|
|
- // .unwrap();
|
|
|
|
- // loop {
|
|
|
|
- // view.step()
|
|
|
|
- // .expect("should not fail")
|
|
|
|
- // .expect("should not fail");
|
|
|
|
- // std::thread::sleep(std::time::Duration::from_millis(15));
|
|
|
|
-
|
|
|
|
- // if let Ok(event) = receiver.try_recv() {
|
|
|
|
- // if let InnerEvent::Initiate(handle) = event {
|
|
|
|
- // let editlist = ref_edits.clone();
|
|
|
|
- // handle
|
|
|
|
- // .dispatch(move |view| {
|
|
|
|
- // let escaped = escape(&editlist);
|
|
|
|
- // view.eval(&format!("EditListReceived({});", escaped))
|
|
|
|
- // })
|
|
|
|
- // .expect("Dispatch failed");
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
}
|
|
}
|
|
|
|
|
|
/// Create a new text-renderer instance from a functional component root.
|
|
/// Create a new text-renderer instance from a functional component root.
|
|
@@ -200,12 +156,12 @@ impl<T: Properties + 'static> WebviewRenderer<T> {
|
|
}
|
|
}
|
|
|
|
|
|
/// Pass new args to the root function
|
|
/// Pass new args to the root function
|
|
- pub fn update(&mut self, new_val: T) {
|
|
|
|
|
|
+ pub fn update(&mut self, _new_val: T) {
|
|
todo!()
|
|
todo!()
|
|
}
|
|
}
|
|
|
|
|
|
/// Modify the root function in place, forcing a re-render regardless if the props changed
|
|
/// Modify the root function in place, forcing a re-render regardless if the props changed
|
|
- pub fn update_mut(&mut self, modifier: impl Fn(&mut T)) {
|
|
|
|
|
|
+ pub fn update_mut(&mut self, _modifier: impl Fn(&mut T)) {
|
|
todo!()
|
|
todo!()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -221,15 +177,6 @@ struct MessageParameters {
|
|
}
|
|
}
|
|
|
|
|
|
fn HANDLER(window: &Window, mut req: RpcRequest) -> Option<RpcResponse> {
|
|
fn HANDLER(window: &Window, mut req: RpcRequest) -> Option<RpcResponse> {
|
|
- use wry::{
|
|
|
|
- application::{
|
|
|
|
- event::{Event, WindowEvent},
|
|
|
|
- event_loop::{ControlFlow, EventLoop},
|
|
|
|
- window::{Fullscreen, Window, WindowBuilder},
|
|
|
|
- },
|
|
|
|
- webview::{RpcRequest, RpcResponse, WebViewBuilder},
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
let mut response = None;
|
|
let mut response = None;
|
|
if &req.method == "fullscreen" {
|
|
if &req.method == "fullscreen" {
|
|
if let Some(params) = req.params.take() {
|
|
if let Some(params) = req.params.take() {
|
|
@@ -262,91 +209,3 @@ fn HANDLER(window: &Window, mut req: RpcRequest) -> Option<RpcResponse> {
|
|
|
|
|
|
response
|
|
response
|
|
}
|
|
}
|
|
-
|
|
|
|
-pub struct DioxusWebviewBuilder<'a> {
|
|
|
|
- pub(crate) title: &'a str,
|
|
|
|
- pub(crate) width: i32,
|
|
|
|
- pub(crate) height: i32,
|
|
|
|
- pub(crate) resizable: bool,
|
|
|
|
- pub(crate) debug: bool,
|
|
|
|
- pub(crate) frameless: bool,
|
|
|
|
- pub(crate) visible: bool,
|
|
|
|
- pub(crate) min_width: i32,
|
|
|
|
- pub(crate) min_height: i32,
|
|
|
|
-}
|
|
|
|
-impl<'a> DioxusWebviewBuilder<'a> {
|
|
|
|
- fn new() -> Self {
|
|
|
|
- #[cfg(debug_assertions)]
|
|
|
|
- let debug = true;
|
|
|
|
- #[cfg(not(debug_assertions))]
|
|
|
|
- let debug = false;
|
|
|
|
-
|
|
|
|
- DioxusWebviewBuilder {
|
|
|
|
- title: "Application",
|
|
|
|
- width: 800,
|
|
|
|
- height: 600,
|
|
|
|
- resizable: true,
|
|
|
|
- debug,
|
|
|
|
- frameless: false,
|
|
|
|
- visible: true,
|
|
|
|
- min_width: 300,
|
|
|
|
- min_height: 300,
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- /// Sets the title of the WebView window.
|
|
|
|
- ///
|
|
|
|
- /// Defaults to `"Application"`.
|
|
|
|
- pub fn title(mut self, title: &'a str) -> Self {
|
|
|
|
- self.title = title;
|
|
|
|
- self
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /// Sets the size of the WebView window.
|
|
|
|
- ///
|
|
|
|
- /// Defaults to 800 x 600.
|
|
|
|
- pub fn size(mut self, width: i32, height: i32) -> Self {
|
|
|
|
- self.width = width;
|
|
|
|
- self.height = height;
|
|
|
|
- self
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /// Sets the resizability of the WebView window. If set to false, the window cannot be resized.
|
|
|
|
- ///
|
|
|
|
- /// Defaults to `true`.
|
|
|
|
- pub fn resizable(mut self, resizable: bool) -> Self {
|
|
|
|
- self.resizable = resizable;
|
|
|
|
- self
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /// Enables or disables debug mode.
|
|
|
|
- ///
|
|
|
|
- /// Defaults to `true` for debug builds, `false` for release builds.
|
|
|
|
- pub fn debug(mut self, debug: bool) -> Self {
|
|
|
|
- self.debug = debug;
|
|
|
|
- self
|
|
|
|
- }
|
|
|
|
- /// The window crated will be frameless
|
|
|
|
- ///
|
|
|
|
- /// defaults to `false`
|
|
|
|
- pub fn frameless(mut self, frameless: bool) -> Self {
|
|
|
|
- self.frameless = frameless;
|
|
|
|
- self
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /// Set the visibility of the WebView window.
|
|
|
|
- ///
|
|
|
|
- /// defaults to `true`
|
|
|
|
- pub fn visible(mut self, visible: bool) -> Self {
|
|
|
|
- self.visible = visible;
|
|
|
|
- self
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /// Sets the minimum size of the WebView window.
|
|
|
|
- ///
|
|
|
|
- /// Defaults to 300 x 300.
|
|
|
|
- pub fn min_size(mut self, width: i32, height: i32) -> Self {
|
|
|
|
- self.min_width = width;
|
|
|
|
- self.min_height = height;
|
|
|
|
- self
|
|
|
|
- }
|
|
|
|
-}
|
|
|