2019-11-25 14:17:13 +01:00
|
|
|
//! Configure your application.
|
2020-01-16 05:54:22 +01:00
|
|
|
use crate::window;
|
2019-11-25 14:17:13 +01:00
|
|
|
|
|
|
|
|
/// The settings of an application.
|
2020-01-09 18:31:07 +01:00
|
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
|
2020-03-30 18:00:15 +02:00
|
|
|
pub struct Settings<Flags> {
|
2020-01-16 05:54:22 +01:00
|
|
|
/// The window settings.
|
2019-11-25 14:17:13 +01:00
|
|
|
///
|
|
|
|
|
/// They will be ignored on the Web.
|
|
|
|
|
///
|
|
|
|
|
/// [`Window`]: struct.Window.html
|
2020-01-16 05:54:22 +01:00
|
|
|
pub window: window::Settings,
|
2019-12-29 12:29:47 +01:00
|
|
|
|
2020-03-30 18:00:15 +02:00
|
|
|
/// The data needed to initialize an [`Application`].
|
|
|
|
|
///
|
2020-04-01 04:35:24 +02:00
|
|
|
/// [`Application`]: ../trait.Application.html
|
2020-03-30 18:00:15 +02:00
|
|
|
pub flags: Flags,
|
|
|
|
|
|
2020-01-09 18:31:07 +01:00
|
|
|
/// The bytes of the font that will be used by default.
|
|
|
|
|
///
|
|
|
|
|
/// If `None` is provided, a default system font will be chosen.
|
2020-01-01 17:49:48 +01:00
|
|
|
// TODO: Add `name` for web compatibility
|
|
|
|
|
pub default_font: Option<&'static [u8]>,
|
2020-02-15 10:08:27 +01:00
|
|
|
|
2020-02-18 09:54:24 +01:00
|
|
|
/// If set to true, the renderer will try to perform antialiasing for some
|
2020-02-15 10:08:27 +01:00
|
|
|
/// primitives.
|
|
|
|
|
///
|
|
|
|
|
/// Enabling it can produce a smoother result in some widgets, like the
|
2020-04-01 04:35:24 +02:00
|
|
|
/// [`Canvas`], at a performance cost.
|
2020-02-15 10:08:27 +01:00
|
|
|
///
|
|
|
|
|
/// By default, it is disabled.
|
2020-04-01 04:35:24 +02:00
|
|
|
///
|
|
|
|
|
/// [`Canvas`]: ../widget/canvas/struct.Canvas.html
|
2020-02-18 09:54:24 +01:00
|
|
|
pub antialiasing: bool,
|
2019-12-29 12:29:47 +01:00
|
|
|
}
|
|
|
|
|
|
2019-11-25 14:17:13 +01:00
|
|
|
#[cfg(not(target_arch = "wasm32"))]
|
2020-03-30 18:00:15 +02:00
|
|
|
impl<Flags> From<Settings<Flags>> for iced_winit::Settings<Flags> {
|
|
|
|
|
fn from(settings: Settings<Flags>) -> iced_winit::Settings<Flags> {
|
2019-12-03 07:08:12 +01:00
|
|
|
iced_winit::Settings {
|
|
|
|
|
window: iced_winit::settings::Window {
|
|
|
|
|
size: settings.window.size,
|
|
|
|
|
resizable: settings.window.resizable,
|
|
|
|
|
decorations: settings.window.decorations,
|
|
|
|
|
platform_specific: Default::default(),
|
|
|
|
|
},
|
2020-03-30 18:00:15 +02:00
|
|
|
flags: settings.flags,
|
2019-12-03 07:08:12 +01:00
|
|
|
}
|
2019-11-25 14:17:13 +01:00
|
|
|
}
|
|
|
|
|
}
|