Преглед изворни кода

Merge pull request #674 from sdwoodbury/feat/resize-window

Jon Kelley пре 2 година
родитељ
комит
4554c06d64
1 измењених фајлова са 8 додато и 0 уклоњено
  1. 8 0
      packages/desktop/src/desktop_context.rs

+ 8 - 0
packages/desktop/src/desktop_context.rs

@@ -7,6 +7,7 @@ use serde_json::Value;
 use std::future::Future;
 use std::future::IntoFuture;
 use std::pin::Pin;
+use wry::application::dpi::LogicalSize;
 use wry::application::event_loop::ControlFlow;
 use wry::application::event_loop::EventLoopProxy;
 #[cfg(target_os = "ios")]
@@ -136,6 +137,11 @@ impl DesktopContext {
         let _ = self.proxy.send_event(SetZoomLevel(scale_factor));
     }
 
+    /// modifies the inner size of the window
+    pub fn set_inner_size(&self, logical_size: LogicalSize<f64>) {
+        let _ = self.proxy.send_event(SetInnerSize(logical_size));
+    }
+
     /// launch print modal
     pub fn print(&self) {
         let _ = self.proxy.send_event(Print);
@@ -193,6 +199,7 @@ pub enum UserWindowEvent {
     SetDecorations(bool),
 
     SetZoomLevel(f64),
+    SetInnerSize(LogicalSize<f64>),
 
     Print,
     DevTool,
@@ -265,6 +272,7 @@ impl DesktopController {
             SetDecorations(state) => window.set_decorations(state),
 
             SetZoomLevel(scale_factor) => webview.zoom(scale_factor),
+            SetInnerSize(logical_size) => window.set_inner_size(logical_size),
 
             Print => {
                 if let Err(e) = webview.print() {