diff --git a/src/stremio_app/stremio_app.rs b/src/stremio_app/stremio_app.rs index 05e6c0e..baf5188 100644 --- a/src/stremio_app/stremio_app.rs +++ b/src/stremio_app/stremio_app.rs @@ -1,3 +1,4 @@ +use std::cmp; use native_windows_derive::NwgUi; use native_windows_gui as nwg; @@ -7,7 +8,7 @@ use crate::stremio_app::stremio_player::Player; #[derive(Default, NwgUi)] pub struct StremioApp { #[nwg_control(title: "Stremio", flags: "MAIN_WINDOW|VISIBLE")] - #[nwg_events( OnWindowClose: [StremioApp::quit] )] + #[nwg_events( OnWindowClose: [StremioApp::on_quit], OnInit: [StremioApp::on_init] )] window: nwg::Window, #[nwg_partial(parent: window)] webview: WebView, @@ -16,7 +17,16 @@ pub struct StremioApp { } impl StremioApp { - fn quit(&self) { + fn on_init(&self) { + let small_side = cmp::min(nwg::Monitor::width(), nwg::Monitor::height()) * 70 / 100; + let dimensions = (small_side * 16 / 9, small_side); + let [total_width, total_height] = [nwg::Monitor::width(), nwg::Monitor::height()]; + let x = (total_width-dimensions.0)/2; + let y = (total_height-dimensions.1)/2; + self.window.set_size(dimensions.0 as u32, dimensions.1 as u32); + self.window.set_position(x, y); + } + fn on_quit(&self) { nwg::stop_thread_dispatch(); } }