You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.6 KiB

2 years ago
  1. fn main() -> wry::Result<()> {
  2. use wry::{
  3. application::{
  4. event::{Event, StartCause, WindowEvent},
  5. event_loop::{ControlFlow, EventLoop},
  6. window::WindowBuilder,
  7. },
  8. webview::WebViewBuilder,
  9. };
  10. let event_loop = EventLoop::new();
  11. let window = WindowBuilder::new()
  12. .with_title("Progrium Test")
  13. .with_decorations(false)
  14. .with_transparent(true)
  15. .build(&event_loop)?;
  16. let _webview = WebViewBuilder::new(window)?
  17. .with_transparent(true)
  18. //.with_url("https://progrium.com")?
  19. .with_url(
  20. r#"data:text/html,
  21. <!doctype html>
  22. <html>
  23. <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>
  24. <script>
  25. window.onload = function() {
  26. document.body.innerHTML = `<div style="padding: 30px">Transparency Test<br><br>${navigator.userAgent}</div>`;
  27. };
  28. </script>
  29. </html>"#,
  30. )?
  31. .build()?;
  32. event_loop.run(move |event, _, control_flow| {
  33. *control_flow = ControlFlow::Wait;
  34. match event {
  35. Event::NewEvents(StartCause::Init) => println!("Started"),
  36. Event::WindowEvent {
  37. event: WindowEvent::CloseRequested,
  38. ..
  39. } => *control_flow = ControlFlow::Exit,
  40. _ => (),
  41. }
  42. });
  43. }