overlay.rs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. use dioxus::prelude::*;
  2. use dioxus_desktop::{tao::dpi::PhysicalPosition, LogicalSize, WindowBuilder};
  3. fn main() {
  4. LaunchBuilder::new().with_cfg(make_config());
  5. }
  6. fn app() -> Element {
  7. rsx! {
  8. div {
  9. width: "100%",
  10. height: "100%",
  11. background_color: "red",
  12. border: "1px solid black",
  13. div {
  14. width: "100%",
  15. height: "10px",
  16. background_color: "black",
  17. onmousedown: move |_| dioxus_desktop::window().drag(),
  18. }
  19. "This is an overlay!"
  20. }
  21. }
  22. }
  23. fn make_config() -> dioxus_desktop::Config {
  24. dioxus_desktop::Config::default()
  25. .with_window(make_window())
  26. .with_custom_head(
  27. r#"
  28. <style type="text/css">
  29. html, body {
  30. height: 100px;
  31. margin: 0;
  32. overscroll-behavior-y: none;
  33. overscroll-behavior-x: none;
  34. overflow: hidden;
  35. }
  36. #main, #bodywrap {
  37. height: 100%;
  38. margin: 0;
  39. overscroll-behavior-x: none;
  40. overscroll-behavior-y: none;
  41. }
  42. </style>
  43. "#
  44. .to_owned(),
  45. )
  46. }
  47. fn make_window() -> WindowBuilder {
  48. WindowBuilder::new()
  49. .with_transparent(true)
  50. .with_decorations(false)
  51. .with_resizable(false)
  52. .with_always_on_top(true)
  53. .with_position(PhysicalPosition::new(0, 0))
  54. .with_max_inner_size(LogicalSize::new(100000, 50))
  55. }