diff options
author | 2019-11-25 15:00:53 +0100 | |
---|---|---|
committer | 2019-11-25 15:00:53 +0100 | |
commit | 84874ac5dc2dc787833bcebf37751735f4c4ab42 (patch) | |
tree | 50314f680cd8597cf30b89c0236842bec1d834a9 /src/settings.rs | |
parent | 862859142b50cf74a6fe423a4aa23fd63c152843 (diff) | |
parent | d70021fa68b556e20638f29e2e303f6d156afdb6 (diff) | |
download | iced-84874ac5dc2dc787833bcebf37751735f4c4ab42.tar.gz iced-84874ac5dc2dc787833bcebf37751735f4c4ab42.tar.bz2 iced-84874ac5dc2dc787833bcebf37751735f4c4ab42.zip |
Merge pull request #68 from hecrj/feature/application-settings
Allow `Application` configuration with `Settings`
Diffstat (limited to 'src/settings.rs')
-rw-r--r-- | src/settings.rs | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/settings.rs b/src/settings.rs new file mode 100644 index 00000000..2556c51b --- /dev/null +++ b/src/settings.rs @@ -0,0 +1,43 @@ +//! Configure your application. + +/// The settings of an application. +#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)] +pub struct Settings { + /// The [`Window`] settings. + /// + /// They will be ignored on the Web. + /// + /// [`Window`]: struct.Window.html + pub window: Window, +} + +/// The window settings of an application. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub struct Window { + /// The size of the window. + pub size: (u32, u32), + + /// Whether the window should be resizable or not. + pub resizable: bool, +} + +impl Default for Window { + fn default() -> Window { + Window { + size: (1024, 768), + resizable: true, + } + } +} + +#[cfg(not(target_arch = "wasm32"))] +impl From<Settings> for iced_winit::Settings { + fn from(settings: Settings) -> iced_winit::Settings { + iced_winit::Settings { + window: iced_winit::settings::Window { + size: settings.window.size, + resizable: settings.window.resizable, + }, + } + } +} |