mirror of
https://github.com/Stremio/stremio-shell-ng.git
synced 2026-03-11 17:15:49 +00:00
Fix conflicts and implement window centering
This commit is contained in:
commit
26bd7cb955
1 changed files with 12 additions and 2 deletions
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue