summaryrefslogtreecommitdiffstats
path: root/src/settings.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/settings.rs')
-rw-r--r--src/settings.rs36
1 files changed, 31 insertions, 5 deletions
diff --git a/src/settings.rs b/src/settings.rs
index c82a1354..d726dc4f 100644
--- a/src/settings.rs
+++ b/src/settings.rs
@@ -4,12 +4,18 @@ 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.
pub window: window::Settings,
- /// The data needed to initialize an [`Application`].
+ /// The data needed to initialize the [`Application`].
///
/// [`Application`]: crate::Application
pub flags: Flags,
@@ -25,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,6 +47,12 @@ pub struct Settings<Flags> {
///
/// [`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> {
@@ -46,10 +64,13 @@ impl<Flags> Settings<Flags> {
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,
}
}
}
@@ -60,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,
}
}
}
@@ -73,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,
}
}
}