Browse Source

Initial commit

main
Dwayne Harris 2 years ago
commit
28f972eaae
  1. 1
      .gitignore
  2. 1569
      Cargo.lock
  3. 9
      Cargo.toml
  4. 47
      src/main.rs

1
.gitignore

@ -0,0 +1 @@
/target

1569
Cargo.lock
File diff suppressed because it is too large
View File

9
Cargo.toml

@ -0,0 +1,9 @@
[package]
name = "rust-web-view"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
wry = "0.12"

47
src/main.rs

@ -0,0 +1,47 @@
fn main() -> wry::Result<()> {
use wry::{
application::{
event::{Event, StartCause, WindowEvent},
event_loop::{ControlFlow, EventLoop},
window::WindowBuilder,
},
webview::WebViewBuilder,
};
let event_loop = EventLoop::new();
let window = WindowBuilder::new()
.with_title("Progrium Test")
.with_decorations(false)
.with_transparent(true)
.build(&event_loop)?;
let _webview = WebViewBuilder::new(window)?
.with_transparent(true)
//.with_url("https://progrium.com")?
.with_url(
r#"data:text/html,
<!doctype html>
<html>
<body style="font-family: -apple-system, BlinkMacSystemFont, avenir next, avenir, segoe ui, helvetica neue, helvetica, Ubuntu, roboto, noto, arial, sans-serif; background-color:rgba(87,87,87,0.5);"></body>
<script>
window.onload = function() {
document.body.innerHTML = `<div style="padding: 30px">Transparency Test<br><br>${navigator.userAgent}</div>`;
};
</script>
</html>"#,
)?
.build()?;
event_loop.run(move |event, _, control_flow| {
*control_flow = ControlFlow::Wait;
match event {
Event::NewEvents(StartCause::Init) => println!("Started"),
Event::WindowEvent {
event: WindowEvent::CloseRequested,
..
} => *control_flow = ControlFlow::Exit,
_ => (),
}
});
}
Loading…
Cancel
Save