mirror of
https://github.com/Stremio/stremio-shell-ng.git
synced 2026-05-17 18:21:59 +00:00
Better splash
This commit is contained in:
parent
cf80d6f1bb
commit
f303b094aa
1 changed files with 12 additions and 4 deletions
|
|
@ -57,7 +57,9 @@ pub struct MainWindow {
|
||||||
pub player: Player,
|
pub player: Player,
|
||||||
#[nwg_resource(size: Some((300,300)), source_embed: Some(&data.embed), source_embed_str: Some("SPLASHIMAGE"))]
|
#[nwg_resource(size: Some((300,300)), source_embed: Some(&data.embed), source_embed_str: Some("SPLASHIMAGE"))]
|
||||||
pub splash_image: nwg::Icon,
|
pub splash_image: nwg::Icon,
|
||||||
#[nwg_control(icon: Some(&data.splash_image))]
|
#[nwg_control(parent: window, background_color: Some(Self::BG_COLOR))]
|
||||||
|
pub splash_frame: nwg::ImageFrame,
|
||||||
|
#[nwg_control(parent: splash_frame, background_color: Some(Self::BG_COLOR), icon: Some(&data.splash_image))]
|
||||||
pub splash: nwg::ImageFrame,
|
pub splash: nwg::ImageFrame,
|
||||||
#[nwg_control]
|
#[nwg_control]
|
||||||
#[nwg_events(OnNotice: [Self::on_toggle_fullscreen_notice] )]
|
#[nwg_events(OnNotice: [Self::on_toggle_fullscreen_notice] )]
|
||||||
|
|
@ -71,6 +73,7 @@ pub struct MainWindow {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MainWindow {
|
impl MainWindow {
|
||||||
|
const BG_COLOR: [u8; 3] = [27, 17, 38];
|
||||||
const MIN_WIDTH: i32 = 1000;
|
const MIN_WIDTH: i32 = 1000;
|
||||||
const MIN_HEIGHT: i32 = 600;
|
const MIN_HEIGHT: i32 = 600;
|
||||||
fn on_init(&self) {
|
fn on_init(&self) {
|
||||||
|
|
@ -195,8 +198,13 @@ impl MainWindow {
|
||||||
data.set_min_size(Self::MIN_WIDTH, Self::MIN_HEIGHT);
|
data.set_min_size(Self::MIN_WIDTH, Self::MIN_HEIGHT);
|
||||||
}
|
}
|
||||||
fn on_paint(&self) {
|
fn on_paint(&self) {
|
||||||
let (w, h) = self.window.size();
|
if self.splash_frame.visible() {
|
||||||
self.splash.set_size(w, h);
|
let (w, h) = self.window.size();
|
||||||
|
let s = cmp::min(w, h);
|
||||||
|
self.splash_frame.set_size(w, h);
|
||||||
|
self.splash.set_size(s, s);
|
||||||
|
self.splash.set_position(w as i32 / 2 - s as i32 / 2, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
fn on_toggle_fullscreen_notice(&self) {
|
fn on_toggle_fullscreen_notice(&self) {
|
||||||
println!("full screen toggle requested");
|
println!("full screen toggle requested");
|
||||||
|
|
@ -205,7 +213,7 @@ impl MainWindow {
|
||||||
self.on_quit();
|
self.on_quit();
|
||||||
}
|
}
|
||||||
fn on_hide_splash_notice(&self) {
|
fn on_hide_splash_notice(&self) {
|
||||||
self.splash.set_visible(false);
|
self.splash_frame.set_visible(false);
|
||||||
}
|
}
|
||||||
fn on_quit(&self) {
|
fn on_quit(&self) {
|
||||||
nwg::stop_thread_dispatch();
|
nwg::stop_thread_dispatch();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue