2022-02-11 03:21:25 +00:00
|
|
|
use dioxus::prelude::*;
|
2024-01-15 21:06:05 +00:00
|
|
|
use dioxus_desktop::{window, Config, WindowBuilder};
|
2022-02-11 03:21:25 +00:00
|
|
|
|
|
|
|
fn main() {
|
2024-01-16 14:42:16 +00:00
|
|
|
LaunchBuilder::new(app)
|
|
|
|
.cfg(
|
|
|
|
Config::new().with_window(
|
|
|
|
WindowBuilder::new()
|
|
|
|
.with_title("Borderless Window")
|
|
|
|
.with_decorations(false),
|
|
|
|
),
|
2024-01-15 21:06:05 +00:00
|
|
|
)
|
2024-01-16 17:45:02 +00:00
|
|
|
.launch_desktop()
|
2022-02-11 03:21:25 +00:00
|
|
|
}
|
|
|
|
|
2024-01-14 04:51:37 +00:00
|
|
|
fn app() -> Element {
|
2024-01-16 07:24:59 +00:00
|
|
|
let mut fullscreen = use_signal(|| false);
|
|
|
|
let mut always_on_top = use_signal(|| false);
|
|
|
|
let mut decorations = use_signal(|| false);
|
2022-02-11 03:21:25 +00:00
|
|
|
|
2024-01-16 19:18:46 +00:00
|
|
|
rsx!(
|
2024-01-16 14:42:16 +00:00
|
|
|
link {
|
|
|
|
href: "https://unpkg.com/tailwindcss@^2/dist/tailwind.min.css",
|
|
|
|
rel: "stylesheet"
|
|
|
|
}
|
|
|
|
header {
|
|
|
|
class: "text-gray-400 bg-gray-900 body-font",
|
|
|
|
onmousedown: move |_| window().drag(),
|
2024-01-15 21:06:05 +00:00
|
|
|
div { class: "container mx-auto flex flex-wrap p-5 flex-col md:flex-row items-center",
|
2022-02-11 03:21:25 +00:00
|
|
|
a { class: "flex title-font font-medium items-center text-white mb-4 md:mb-0",
|
2024-01-16 14:42:16 +00:00
|
|
|
span { class: "ml-3 text-xl", "Dioxus" }
|
2022-02-11 03:21:25 +00:00
|
|
|
}
|
|
|
|
nav { class: "md:ml-auto flex flex-wrap items-center text-base justify-center" }
|
|
|
|
button {
|
|
|
|
class: "inline-flex items-center bg-gray-800 border-0 py-1 px-3 focus:outline-none hover:bg-gray-700 rounded text-base mt-4 md:mt-0",
|
2023-01-01 20:41:18 +00:00
|
|
|
onmousedown: |evt| evt.stop_propagation(),
|
2024-01-15 21:06:05 +00:00
|
|
|
onclick: move |_| window().set_minimized(true),
|
2022-02-11 03:21:25 +00:00
|
|
|
"Minimize"
|
|
|
|
}
|
|
|
|
button {
|
|
|
|
class: "inline-flex items-center bg-gray-800 border-0 py-1 px-3 focus:outline-none hover:bg-gray-700 rounded text-base mt-4 md:mt-0",
|
2023-01-01 20:41:18 +00:00
|
|
|
onmousedown: |evt| evt.stop_propagation(),
|
2022-02-11 03:21:25 +00:00
|
|
|
onclick: move |_| {
|
2024-01-16 05:12:44 +00:00
|
|
|
window().set_fullscreen(!fullscreen());
|
|
|
|
window().set_resizable(fullscreen());
|
2024-01-15 21:06:05 +00:00
|
|
|
fullscreen.toggle();
|
2022-02-11 03:21:25 +00:00
|
|
|
},
|
|
|
|
"Fullscreen"
|
|
|
|
}
|
|
|
|
button {
|
|
|
|
class: "inline-flex items-center bg-gray-800 border-0 py-1 px-3 focus:outline-none hover:bg-gray-700 rounded text-base mt-4 md:mt-0",
|
2023-01-01 20:41:18 +00:00
|
|
|
onmousedown: |evt| evt.stop_propagation(),
|
2024-01-15 21:06:05 +00:00
|
|
|
onclick: move |_| window().close(),
|
2022-02-11 03:21:25 +00:00
|
|
|
"Close"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
br {}
|
2024-01-16 14:42:16 +00:00
|
|
|
div { class: "container mx-auto",
|
|
|
|
div { class: "grid grid-cols-5",
|
2022-02-11 03:21:25 +00:00
|
|
|
div {
|
|
|
|
button {
|
|
|
|
class: "inline-flex items-center text-white bg-green-500 border-0 py-1 px-3 hover:bg-green-700 rounded",
|
2023-01-01 20:41:18 +00:00
|
|
|
onmousedown: |evt| evt.stop_propagation(),
|
2022-02-11 03:21:25 +00:00
|
|
|
onclick: move |_| {
|
2024-01-16 05:12:44 +00:00
|
|
|
window().set_always_on_top(!always_on_top());
|
2024-01-15 21:06:05 +00:00
|
|
|
always_on_top.toggle();
|
2022-02-11 03:21:25 +00:00
|
|
|
},
|
|
|
|
"Always On Top"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
div {
|
|
|
|
button {
|
|
|
|
class: "inline-flex items-center text-white bg-blue-500 border-0 py-1 px-3 hover:bg-green-700 rounded",
|
2023-01-01 20:41:18 +00:00
|
|
|
onmousedown: |evt| evt.stop_propagation(),
|
2022-02-11 03:21:25 +00:00
|
|
|
onclick: move |_| {
|
2024-01-16 05:12:44 +00:00
|
|
|
window().set_decorations(!decorations());
|
2024-01-15 21:06:05 +00:00
|
|
|
decorations.toggle();
|
2022-02-11 03:21:25 +00:00
|
|
|
},
|
|
|
|
"Set Decorations"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
div {
|
|
|
|
button {
|
|
|
|
class: "inline-flex items-center text-white bg-blue-500 border-0 py-1 px-3 hover:bg-green-700 rounded",
|
2023-01-01 20:41:18 +00:00
|
|
|
onmousedown: |evt| evt.stop_propagation(),
|
2024-01-15 21:06:05 +00:00
|
|
|
onclick: move |_| window().set_title("Dioxus Application"),
|
2022-02-11 03:21:25 +00:00
|
|
|
"Change Title"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2024-01-14 05:12:21 +00:00
|
|
|
)
|
2022-02-11 03:21:25 +00:00
|
|
|
}
|