feat: add window api
This commit is contained in:
1 parent
f28fb7165a
commit
01435d6aff
2 files changed
+21
-12
No files matched your search
@@ -71,8 +71,10 @@ impl DesktopContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// hide the menu
|
/// hide the menu
|
||||||
pub fn hide_menu(&self) {
|
pub fn set_decorations(&self, decoration: bool) {
|
||||||
let _ = self.proxy.send_event(UserWindowEvent::HideMenu);
|
let _ = self
|
||||||
|
.proxy
|
||||||
|
.send_event(UserWindowEvent::SetDecorations(decoration));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+17
-10
@@ -72,7 +72,7 @@ use tao::{
|
|||||||
pub use wry;
|
pub use wry;
|
||||||
pub use wry::application as tao;
|
pub use wry::application as tao;
|
||||||
use wry::{
|
use wry::{
|
||||||
application::event_loop::EventLoopProxy,
|
application::{event_loop::EventLoopProxy, window::Fullscreen},
|
||||||
webview::RpcRequest,
|
webview::RpcRequest,
|
||||||
webview::{WebView, WebViewBuilder},
|
webview::{WebView, WebViewBuilder},
|
||||||
};
|
};
|
||||||
@@ -315,12 +315,24 @@ pub fn launch_with_props<P: 'static + Send>(
|
|||||||
window.set_maximized(state);
|
window.set_maximized(state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
UserWindowEvent::Fullscreen(fullscreen) => {
|
||||||
|
for webview in desktop.webviews.values() {
|
||||||
|
let window = webview.window();
|
||||||
|
window.set_fullscreen(*fullscreen.clone());
|
||||||
|
}
|
||||||
|
}
|
||||||
UserWindowEvent::FocusWindow => {
|
UserWindowEvent::FocusWindow => {
|
||||||
for webview in desktop.webviews.values() {
|
for webview in desktop.webviews.values() {
|
||||||
let window = webview.window();
|
let window = webview.window();
|
||||||
window.set_focus();
|
window.set_focus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
UserWindowEvent::Resizable(state) => {
|
||||||
|
for webview in desktop.webviews.values() {
|
||||||
|
let window = webview.window();
|
||||||
|
window.set_resizable(state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
UserWindowEvent::SetTitle(content) => {
|
UserWindowEvent::SetTitle(content) => {
|
||||||
for webview in desktop.webviews.values() {
|
for webview in desktop.webviews.values() {
|
||||||
@@ -328,16 +340,10 @@ pub fn launch_with_props<P: 'static + Send>(
|
|||||||
window.set_title(&content);
|
window.set_title(&content);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
UserWindowEvent::Resizable(state) => {
|
UserWindowEvent::SetDecorations(state) => {
|
||||||
for webview in desktop.webviews.values() {
|
for webview in desktop.webviews.values() {
|
||||||
let window = webview.window();
|
let window = webview.window();
|
||||||
window.set_resizable(state);
|
window.set_decorations(state);
|
||||||
}
|
|
||||||
}
|
|
||||||
UserWindowEvent::HideMenu => {
|
|
||||||
for webview in desktop.webviews.values() {
|
|
||||||
let window = webview.window();
|
|
||||||
window.hide_menu();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -360,9 +366,10 @@ pub enum UserWindowEvent {
|
|||||||
Minimize(bool),
|
Minimize(bool),
|
||||||
Maximize(bool),
|
Maximize(bool),
|
||||||
Resizable(bool),
|
Resizable(bool),
|
||||||
|
Fullscreen(Box<Option<Fullscreen>>),
|
||||||
|
|
||||||
SetTitle(String),
|
SetTitle(String),
|
||||||
HideMenu,
|
SetDecorations(bool),
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct DesktopController {
|
pub struct DesktopController {
|
||||||
|
|||||||
Reference in new issue
Block a user