summaryrefslogtreecommitdiffstats
path: root/src/settings.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/settings.rs')
-rw-r--r--src/settings.rs46
1 files changed, 35 insertions, 11 deletions
diff --git a/src/settings.rs b/src/settings.rs
index 40b1b1ea..d726dc4f 100644
--- a/src/settings.rs
+++ b/src/settings.rs
@@ -4,16 +4,20 @@ use crate::window;
/// The settings of an application.
#[derive(Debug, Clone)]
pub struct Settings<Flags> {
+ /// The identifier of the application.
+ ///
+ /// If provided, this identifier may be used to identify the application or
+ /// communicate with it through the windowing system.
+ pub id: Option<String>,
+
/// The window settings.
///
/// They will be ignored on the Web.
- ///
- /// [`Window`]: struct.Window.html
pub window: window::Settings,
- /// The data needed to initialize an [`Application`].
+ /// The data needed to initialize the [`Application`].
///
- /// [`Application`]: ../trait.Application.html
+ /// [`Application`]: crate::Application
pub flags: Flags,
/// The bytes of the font that will be used by default.
@@ -27,6 +31,12 @@ pub struct Settings<Flags> {
/// The default value is 20.
pub default_text_size: u16,
+ /// If enabled, spread text workload in multiple threads when multiple cores
+ /// are available.
+ ///
+ /// By default, it is disabled.
+ pub text_multithreading: bool,
+
/// If set to true, the renderer will try to perform antialiasing for some
/// primitives.
///
@@ -35,23 +45,32 @@ pub struct Settings<Flags> {
///
/// By default, it is disabled.
///
- /// [`Canvas`]: ../widget/canvas/struct.Canvas.html
+ /// [`Canvas`]: crate::widget::Canvas
pub antialiasing: bool,
+
+ /// Whether the [`Application`] should exit when the user requests the
+ /// window to close (e.g. the user presses the close button).
+ ///
+ /// By default, it is enabled.
+ pub exit_on_close_request: bool,
}
impl<Flags> Settings<Flags> {
- /// Initialize application settings using the given data.
+ /// Initialize [`Application`] settings using the given data.
///
- /// [`Application`]: ../trait.Application.html
+ /// [`Application`]: crate::Application
pub fn with_flags(flags: Flags) -> Self {
let default_settings = Settings::<()>::default();
Self {
flags,
- antialiasing: default_settings.antialiasing,
+ id: default_settings.id,
+ window: default_settings.window,
default_font: default_settings.default_font,
default_text_size: default_settings.default_text_size,
- window: default_settings.window,
+ text_multithreading: default_settings.text_multithreading,
+ antialiasing: default_settings.antialiasing,
+ exit_on_close_request: default_settings.exit_on_close_request,
}
}
}
@@ -62,11 +81,14 @@ where
{
fn default() -> Self {
Self {
+ id: None,
+ window: Default::default(),
flags: Default::default(),
- antialiasing: Default::default(),
default_font: Default::default(),
default_text_size: 20,
- window: Default::default(),
+ text_multithreading: false,
+ antialiasing: false,
+ exit_on_close_request: true,
}
}
}
@@ -75,8 +97,10 @@ where
impl<Flags> From<Settings<Flags>> for iced_winit::Settings<Flags> {
fn from(settings: Settings<Flags>) -> iced_winit::Settings<Flags> {
iced_winit::Settings {
+ id: settings.id,
window: settings.window.into(),
flags: settings.flags,
+ exit_on_close_request: settings.exit_on_close_request,
}
}
}