feat: add window api
This commit is contained in:
1 parent
01435d6aff
commit
81ea7a1428
2 files changed
+37
No files matched your search
@@ -48,6 +48,10 @@ impl DesktopContext {
|
|||||||
let _ = self.proxy.send_event(UserWindowEvent::Maximize(maximized));
|
let _ = self.proxy.send_event(UserWindowEvent::Maximize(maximized));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn visible(&self, visible: bool) {
|
||||||
|
let _ = self.proxy.send_event(UserWindowEvent::Visible(visible));
|
||||||
|
}
|
||||||
|
|
||||||
/// close window
|
/// close window
|
||||||
pub fn close(&self) {
|
pub fn close(&self) {
|
||||||
let _ = self.proxy.send_event(UserWindowEvent::CloseWindow);
|
let _ = self.proxy.send_event(UserWindowEvent::CloseWindow);
|
||||||
@@ -63,6 +67,16 @@ impl DesktopContext {
|
|||||||
let _ = self.proxy.send_event(UserWindowEvent::Resizable(resizable));
|
let _ = self.proxy.send_event(UserWindowEvent::Resizable(resizable));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn always_on_top(&self, top: bool) {
|
||||||
|
let _ = self.proxy.send_event(UserWindowEvent::AlwaysOnTop(top));
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn cursor_visible(&self, visible: bool) {
|
||||||
|
let _ = self
|
||||||
|
.proxy
|
||||||
|
.send_event(UserWindowEvent::CursorVisible(visible));
|
||||||
|
}
|
||||||
|
|
||||||
/// set window title
|
/// set window title
|
||||||
pub fn set_title(&self, title: &str) {
|
pub fn set_title(&self, title: &str) {
|
||||||
let _ = self
|
let _ = self
|
||||||
|
|||||||
@@ -299,6 +299,12 @@ pub fn launch_with_props<P: 'static + Send>(
|
|||||||
// close window
|
// close window
|
||||||
*control_flow = ControlFlow::Exit;
|
*control_flow = ControlFlow::Exit;
|
||||||
}
|
}
|
||||||
|
UserWindowEvent::Visible(state) => {
|
||||||
|
for webview in desktop.webviews.values() {
|
||||||
|
let window = webview.window();
|
||||||
|
window.set_visible(state);
|
||||||
|
}
|
||||||
|
}
|
||||||
UserWindowEvent::Minimize(state) => {
|
UserWindowEvent::Minimize(state) => {
|
||||||
// this loop just run once, because dioxus-desktop is unsupport multi-window.
|
// this loop just run once, because dioxus-desktop is unsupport multi-window.
|
||||||
for webview in desktop.webviews.values() {
|
for webview in desktop.webviews.values() {
|
||||||
@@ -333,6 +339,19 @@ pub fn launch_with_props<P: 'static + Send>(
|
|||||||
window.set_resizable(state);
|
window.set_resizable(state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
UserWindowEvent::AlwaysOnTop(state) => {
|
||||||
|
for webview in desktop.webviews.values() {
|
||||||
|
let window = webview.window();
|
||||||
|
window.set_always_on_top(state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
UserWindowEvent::CursorVisible(state) => {
|
||||||
|
for webview in desktop.webviews.values() {
|
||||||
|
let window = webview.window();
|
||||||
|
window.set_cursor_visible(state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
UserWindowEvent::SetTitle(content) => {
|
UserWindowEvent::SetTitle(content) => {
|
||||||
for webview in desktop.webviews.values() {
|
for webview in desktop.webviews.values() {
|
||||||
@@ -363,11 +382,15 @@ pub enum UserWindowEvent {
|
|||||||
DragWindow,
|
DragWindow,
|
||||||
CloseWindow,
|
CloseWindow,
|
||||||
FocusWindow,
|
FocusWindow,
|
||||||
|
Visible(bool),
|
||||||
Minimize(bool),
|
Minimize(bool),
|
||||||
Maximize(bool),
|
Maximize(bool),
|
||||||
Resizable(bool),
|
Resizable(bool),
|
||||||
|
AlwaysOnTop(bool),
|
||||||
Fullscreen(Box<Option<Fullscreen>>),
|
Fullscreen(Box<Option<Fullscreen>>),
|
||||||
|
|
||||||
|
CursorVisible(bool),
|
||||||
|
|
||||||
SetTitle(String),
|
SetTitle(String),
|
||||||
SetDecorations(bool),
|
SetDecorations(bool),
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user