Allow passing external state to Application::new

This commit is contained in:
Héctor Ramón Jiménez 2020-03-30 18:00:15 +02:00
parent 6e9ab1cd6f
commit c4c5216e3b
13 changed files with 103 additions and 60 deletions

View file

@ -3,7 +3,7 @@ use crate::window;
/// The settings of an application.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub struct Settings {
pub struct Settings<Flags> {
/// The window settings.
///
/// They will be ignored on the Web.
@ -11,6 +11,11 @@ pub struct Settings {
/// [`Window`]: struct.Window.html
pub window: window::Settings,
/// The data needed to initialize an [`Application`].
///
/// [`Application`]: trait.Application.html
pub flags: Flags,
/// The bytes of the font that will be used by default.
///
/// If `None` is provided, a default system font will be chosen.
@ -28,8 +33,8 @@ pub struct Settings {
}
#[cfg(not(target_arch = "wasm32"))]
impl From<Settings> for iced_winit::Settings {
fn from(settings: Settings) -> iced_winit::Settings {
impl<Flags> From<Settings<Flags>> for iced_winit::Settings<Flags> {
fn from(settings: Settings<Flags>) -> iced_winit::Settings<Flags> {
iced_winit::Settings {
window: iced_winit::settings::Window {
size: settings.window.size,
@ -37,6 +42,7 @@ impl From<Settings> for iced_winit::Settings {
decorations: settings.window.decorations,
platform_specific: Default::default(),
},
flags: settings.flags,
}
}
}