-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
27 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,26 @@ | ||
use native_windows_derive::NwgPartial; | ||
use native_windows_gui as nwg; | ||
use std::cmp; | ||
|
||
#[derive(Default, NwgPartial)] | ||
pub struct SplashImage { | ||
#[nwg_resource] | ||
embed: nwg::EmbedResource, | ||
#[nwg_resource(size: Some((300,300)), source_embed: Some(&data.embed), source_embed_str: Some("SPLASHIMAGE"))] | ||
splash_image: nwg::Bitmap, | ||
#[nwg_control(background_color: Some(Self::BG_COLOR))] | ||
splash_frame: nwg::ImageFrame, | ||
#[nwg_control(parent: splash_frame, background_color: Some(Self::BG_COLOR), bitmap: Some(&data.splash_image))] | ||
splash: nwg::ImageFrame, | ||
} | ||
|
||
impl SplashImage { | ||
const BG_COLOR: [u8; 3] = [27, 17, 38]; | ||
pub fn resize(&self, size: (u32, u32)) { | ||
let (w, h) = 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); | ||
} | ||
pub fn visible(&self) -> bool { | ||
self.splash_frame.visible() | ||
} | ||
pub fn hide(&self) { | ||
self.splash_frame.set_visible(false); | ||
} | ||
} | ||
use crate::stremio_app::constants::{WINDOW_MIN_HEIGHT, WINDOW_MIN_WIDTH}; | ||
use native_windows_derive::NwgPartial; | ||
use native_windows_gui as nwg; | ||
|
||
#[derive(Default, NwgPartial)] | ||
pub struct SplashImage { | ||
#[nwg_resource] | ||
embed: nwg::EmbedResource, | ||
#[nwg_resource(size: Some((300,300)), source_embed: Some(&data.embed), source_embed_str: Some("SPLASHIMAGE"))] | ||
splash_image: nwg::Bitmap, | ||
#[nwg_layout(spacing: 0, min_size: [WINDOW_MIN_WIDTH as u32, WINDOW_MIN_HEIGHT as u32])] | ||
grid: nwg::GridLayout, | ||
#[nwg_control(background_color: Some(Self::BG_COLOR), bitmap: Some(&data.splash_image))] | ||
#[nwg_layout_item(layout: grid, col: 0, row: 0)] | ||
splash: nwg::ImageFrame, | ||
} | ||
|
||
impl SplashImage { | ||
const BG_COLOR: [u8; 3] = [27, 17, 38]; | ||
pub fn visible(&self) -> bool { | ||
self.splash.visible() | ||
} | ||
pub fn hide(&self) { | ||
self.splash.set_visible(false); | ||
} | ||
} |