summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/Cargo.toml1
-rw-r--r--core/src/keyboard/key.rs6
-rw-r--r--core/src/lib.rs2
-rw-r--r--core/src/renderer.rs19
-rw-r--r--core/src/settings.rs48
-rw-r--r--core/src/theme.rs47
-rw-r--r--core/src/theme/palette.rs155
-rw-r--r--core/src/time.rs25
-rw-r--r--core/src/widget/operation.rs199
-rw-r--r--core/src/widget/operation/focusable.rs35
-rw-r--r--core/src/widget/operation/scrollable.rs6
-rw-r--r--core/src/widget/operation/text_input.rs28
-rw-r--r--core/src/widget/text.rs10
-rw-r--r--core/src/window.rs4
-rw-r--r--core/src/window/direction.rs27
-rw-r--r--core/src/window/event.rs4
-rw-r--r--core/src/window/screenshot.rs108
-rw-r--r--core/src/window/settings.rs9
18 files changed, 624 insertions, 109 deletions
diff --git a/core/Cargo.toml b/core/Cargo.toml
index a1228909..a3bc6745 100644
--- a/core/Cargo.toml
+++ b/core/Cargo.toml
@@ -23,7 +23,6 @@ bytes.workspace = true
glam.workspace = true
log.workspace = true
num-traits.workspace = true
-once_cell.workspace = true
palette.workspace = true
rustc-hash.workspace = true
smol_str.workspace = true
diff --git a/core/src/keyboard/key.rs b/core/src/keyboard/key.rs
index 69a91902..47169d9a 100644
--- a/core/src/keyboard/key.rs
+++ b/core/src/keyboard/key.rs
@@ -32,6 +32,12 @@ impl Key {
}
}
+impl From<Named> for Key {
+ fn from(named: Named) -> Self {
+ Self::Named(named)
+ }
+}
+
/// A named key.
///
/// This is mostly the `NamedKey` type found in [`winit`].
diff --git a/core/src/lib.rs b/core/src/lib.rs
index df599f45..645f7a90 100644
--- a/core/src/lib.rs
+++ b/core/src/lib.rs
@@ -40,6 +40,7 @@ mod pixels;
mod point;
mod rectangle;
mod rotation;
+mod settings;
mod shadow;
mod shell;
mod size;
@@ -67,6 +68,7 @@ pub use point::Point;
pub use rectangle::Rectangle;
pub use renderer::Renderer;
pub use rotation::Rotation;
+pub use settings::Settings;
pub use shadow::Shadow;
pub use shell::Shell;
pub use size::Size;
diff --git a/core/src/renderer.rs b/core/src/renderer.rs
index 6684517f..68e070e8 100644
--- a/core/src/renderer.rs
+++ b/core/src/renderer.rs
@@ -3,7 +3,8 @@
mod null;
use crate::{
- Background, Border, Color, Rectangle, Shadow, Size, Transformation, Vector,
+ Background, Border, Color, Font, Pixels, Rectangle, Shadow, Size,
+ Transformation, Vector,
};
/// A component that can be used by widgets to draw themselves on a screen.
@@ -100,3 +101,19 @@ impl Default for Style {
}
}
}
+
+/// A headless renderer is a renderer that can render offscreen without
+/// a window nor a compositor.
+pub trait Headless {
+ /// Creates a new [`Headless`] renderer;
+ fn new(default_font: Font, default_text_size: Pixels) -> Self;
+
+ /// Draws offscreen into a screenshot, returning a collection of
+ /// bytes representing the rendered pixels in RGBA order.
+ fn screenshot(
+ &mut self,
+ size: Size<u32>,
+ scale_factor: f32,
+ background_color: Color,
+ ) -> Vec<u8>;
+}
diff --git a/core/src/settings.rs b/core/src/settings.rs
new file mode 100644
index 00000000..3189c8d1
--- /dev/null
+++ b/core/src/settings.rs
@@ -0,0 +1,48 @@
+//! Configure your application.
+use crate::{Font, Pixels};
+
+use std::borrow::Cow;
+
+/// The settings of an iced program.
+#[derive(Debug, Clone)]
+pub struct Settings {
+ /// 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 fonts to load on boot.
+ pub fonts: Vec<Cow<'static, [u8]>>,
+
+ /// The default [`Font`] to be used.
+ ///
+ /// By default, it uses [`Family::SansSerif`](crate::font::Family::SansSerif).
+ pub default_font: Font,
+
+ /// The text size that will be used by default.
+ ///
+ /// The default value is `16.0`.
+ pub default_text_size: Pixels,
+
+ /// If set to true, the renderer will try to perform antialiasing for some
+ /// primitives.
+ ///
+ /// Enabling it can produce a smoother result in some widgets, like the
+ /// `canvas` widget, at a performance cost.
+ ///
+ /// By default, it is disabled.
+ pub antialiasing: bool,
+}
+
+impl Default for Settings {
+ fn default() -> Self {
+ Self {
+ id: None,
+ fonts: Vec::new(),
+ default_font: Font::default(),
+ default_text_size: Pixels(16.0),
+ antialiasing: false,
+ }
+ }
+}
diff --git a/core/src/theme.rs b/core/src/theme.rs
index 6b2c04da..cc5b77df 100644
--- a/core/src/theme.rs
+++ b/core/src/theme.rs
@@ -3,6 +3,8 @@ pub mod palette;
pub use palette::Palette;
+use crate::Color;
+
use std::fmt;
use std::sync::Arc;
@@ -164,15 +166,18 @@ impl Default for Theme {
fn default() -> Self {
#[cfg(feature = "auto-detect-theme")]
{
- use once_cell::sync::Lazy;
+ use std::sync::LazyLock;
- static DEFAULT: Lazy<Theme> =
- Lazy::new(|| match dark_light::detect() {
+ static DEFAULT: LazyLock<Theme> = LazyLock::new(|| {
+ match dark_light::detect()
+ .unwrap_or(dark_light::Mode::Unspecified)
+ {
dark_light::Mode::Dark => Theme::Dark,
- dark_light::Mode::Light | dark_light::Mode::Default => {
+ dark_light::Mode::Light | dark_light::Mode::Unspecified => {
Theme::Light
}
- });
+ }
+ });
DEFAULT.clone()
}
@@ -246,3 +251,35 @@ impl fmt::Display for Custom {
write!(f, "{}", self.name)
}
}
+
+/// The base style of a [`Theme`].
+#[derive(Debug, Clone, Copy, PartialEq)]
+pub struct Style {
+ /// The background [`Color`] of the application.
+ pub background_color: Color,
+
+ /// The default text [`Color`] of the application.
+ pub text_color: Color,
+}
+
+/// The default blank style of a [`Theme`].
+pub trait Base {
+ /// Returns the default base [`Style`] of a [`Theme`].
+ fn base(&self) -> Style;
+}
+
+impl Base for Theme {
+ fn base(&self) -> Style {
+ default(self)
+ }
+}
+
+/// The default [`Style`] of a built-in [`Theme`].
+pub fn default(theme: &Theme) -> Style {
+ let palette = theme.extended_palette();
+
+ Style {
+ background_color: palette.background.base.color,
+ text_color: palette.background.base.text,
+ }
+}
diff --git a/core/src/theme/palette.rs b/core/src/theme/palette.rs
index e0ff397a..696c01d0 100644
--- a/core/src/theme/palette.rs
+++ b/core/src/theme/palette.rs
@@ -1,11 +1,12 @@
//! Define the colors of a theme.
use crate::{color, Color};
-use once_cell::sync::Lazy;
use palette::color_difference::Wcag21RelativeContrast;
use palette::rgb::Rgb;
use palette::{FromColor, Hsl, Mix};
+use std::sync::LazyLock;
+
/// A color palette.
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct Palette {
@@ -17,6 +18,8 @@ pub struct Palette {
pub primary: Color,
/// The success [`Color`] of the [`Palette`].
pub success: Color,
+ /// The warning [`Color`] of the [`Palette`].
+ pub warning: Color,
/// The danger [`Color`] of the [`Palette`].
pub danger: Color,
}
@@ -36,6 +39,11 @@ impl Palette {
0x66 as f32 / 255.0,
0x4F as f32 / 255.0,
),
+ warning: Color::from_rgb(
+ 0xFF as f32 / 255.0,
+ 0xC1 as f32 / 255.0,
+ 0x4E as f32 / 255.0,
+ ),
danger: Color::from_rgb(
0xC3 as f32 / 255.0,
0x42 as f32 / 255.0,
@@ -61,6 +69,11 @@ impl Palette {
0x66 as f32 / 255.0,
0x4F as f32 / 255.0,
),
+ warning: Color::from_rgb(
+ 0xFF as f32 / 255.0,
+ 0xC1 as f32 / 255.0,
+ 0x4E as f32 / 255.0,
+ ),
danger: Color::from_rgb(
0xC3 as f32 / 255.0,
0x42 as f32 / 255.0,
@@ -76,6 +89,7 @@ impl Palette {
text: color!(0xf8f8f2), // FOREGROUND
primary: color!(0xbd93f9), // PURPLE
success: color!(0x50fa7b), // GREEN
+ warning: color!(0xf1fa8c), // YELLOW
danger: color!(0xff5555), // RED
};
@@ -87,6 +101,7 @@ impl Palette {
text: color!(0xeceff4), // nord6
primary: color!(0x8fbcbb), // nord7
success: color!(0xa3be8c), // nord14
+ warning: color!(0xebcb8b), // nord13
danger: color!(0xbf616a), // nord11
};
@@ -98,6 +113,7 @@ impl Palette {
text: color!(0x657b83), // base00
primary: color!(0x2aa198), // cyan
success: color!(0x859900), // green
+ warning: color!(0xb58900), // yellow
danger: color!(0xdc322f), // red
};
@@ -109,6 +125,7 @@ impl Palette {
text: color!(0x839496), // base0
primary: color!(0x2aa198), // cyan
success: color!(0x859900), // green
+ warning: color!(0xb58900), // yellow
danger: color!(0xdc322f), // red
};
@@ -120,6 +137,7 @@ impl Palette {
text: color!(0x282828), // light FG0_29
primary: color!(0x458588), // light BLUE_4
success: color!(0x98971a), // light GREEN_2
+ warning: color!(0xd79921), // light YELLOW_3
danger: color!(0xcc241d), // light RED_1
};
@@ -131,6 +149,7 @@ impl Palette {
text: color!(0xfbf1c7), // dark FG0_29
primary: color!(0x458588), // dark BLUE_4
success: color!(0x98971a), // dark GREEN_2
+ warning: color!(0xd79921), // dark YELLOW_3
danger: color!(0xcc241d), // dark RED_1
};
@@ -142,6 +161,7 @@ impl Palette {
text: color!(0x4c4f69), // Text
primary: color!(0x1e66f5), // Blue
success: color!(0x40a02b), // Green
+ warning: color!(0xdf8e1d), // Yellow
danger: color!(0xd20f39), // Red
};
@@ -153,6 +173,7 @@ impl Palette {
text: color!(0xc6d0f5), // Text
primary: color!(0x8caaee), // Blue
success: color!(0xa6d189), // Green
+ warning: color!(0xe5c890), // Yellow
danger: color!(0xe78284), // Red
};
@@ -164,6 +185,7 @@ impl Palette {
text: color!(0xcad3f5), // Text
primary: color!(0x8aadf4), // Blue
success: color!(0xa6da95), // Green
+ warning: color!(0xeed49f), // Yellow
danger: color!(0xed8796), // Red
};
@@ -175,6 +197,7 @@ impl Palette {
text: color!(0xcdd6f4), // Text
primary: color!(0x89b4fa), // Blue
success: color!(0xa6e3a1), // Green
+ warning: color!(0xf9e2af), // Yellow
danger: color!(0xf38ba8), // Red
};
@@ -186,6 +209,7 @@ impl Palette {
text: color!(0x9aa5ce), // Text
primary: color!(0x2ac3de), // Blue
success: color!(0x9ece6a), // Green
+ warning: color!(0xe0af68), // Yellow
danger: color!(0xf7768e), // Red
};
@@ -197,6 +221,7 @@ impl Palette {
text: color!(0x9aa5ce), // Text
primary: color!(0x2ac3de), // Blue
success: color!(0x9ece6a), // Green
+ warning: color!(0xe0af68), // Yellow
danger: color!(0xf7768e), // Red
};
@@ -208,6 +233,7 @@ impl Palette {
text: color!(0x565a6e), // Text
primary: color!(0x166775), // Blue
success: color!(0x485e30), // Green
+ warning: color!(0x8f5e15), // Yellow
danger: color!(0x8c4351), // Red
};
@@ -219,6 +245,7 @@ impl Palette {
text: color!(0xCD7BA), // Fuji White
primary: color!(0x2D4F67), // Wave Blue 2
success: color!(0x76946A), // Autumn Green
+ warning: color!(0xff9e3b), // Ronin Yellow
danger: color!(0xC34043), // Autumn Red
};
@@ -230,6 +257,7 @@ impl Palette {
text: color!(0xc5c9c5), // Dragon White
primary: color!(0x223249), // Wave Blue 1
success: color!(0x8a9a7b), // Dragon Green 2
+ warning: color!(0xff9e3b), // Ronin Yellow
danger: color!(0xc4746e), // Dragon Red
};
@@ -241,6 +269,7 @@ impl Palette {
text: color!(0x545464), // Lotus Ink 1
primary: color!(0xc9cbd1), // Lotus Violet 3
success: color!(0x6f894e), // Lotus Green
+ warning: color!(0xe98a00), // Lotus Orange 2
danger: color!(0xc84053), // Lotus Red
};
@@ -252,6 +281,7 @@ impl Palette {
text: color!(0xbdbdbd), // Foreground
primary: color!(0x80a0ff), // Blue (normal)
success: color!(0x8cc85f), // Green (normal)
+ warning: color!(0xe3c78a), // Yellow (normal)
danger: color!(0xff5454), // Red (normal)
};
@@ -263,6 +293,7 @@ impl Palette {
text: color!(0xbdc1c6), // Foreground
primary: color!(0x82aaff), // Blue (normal)
success: color!(0xa1cd5e), // Green (normal)
+ warning: color!(0xe3d18a), // Yellow (normal)
danger: color!(0xfc514e), // Red (normal)
};
@@ -274,6 +305,7 @@ impl Palette {
text: color!(0xd0d0d0),
primary: color!(0x00b4ff),
success: color!(0x00c15a),
+ warning: color!(0xbe95ff), // Base 14
danger: color!(0xf62d0f),
};
@@ -285,6 +317,7 @@ impl Palette {
text: color!(0xfecdb2),
primary: color!(0xd1d1e0),
success: color!(0xb1b695),
+ warning: color!(0xf5d76e), // Honey
danger: color!(0xe06b75),
};
}
@@ -300,6 +333,8 @@ pub struct Extended {
pub secondary: Secondary,
/// The set of success colors.
pub success: Success,
+ /// The set of warning colors.
+ pub warning: Warning,
/// The set of danger colors.
pub danger: Danger,
/// Whether the palette is dark or not.
@@ -307,92 +342,92 @@ pub struct Extended {
}
/// The built-in light variant of an [`Extended`] palette.
-pub static EXTENDED_LIGHT: Lazy<Extended> =
- Lazy::new(|| Extended::generate(Palette::LIGHT));
+pub static EXTENDED_LIGHT: LazyLock<Extended> =
+ LazyLock::new(|| Extended::generate(Palette::LIGHT));
/// The built-in dark variant of an [`Extended`] palette.
-pub static EXTENDED_DARK: Lazy<Extended> =
- Lazy::new(|| Extended::generate(Palette::DARK));
+pub static EXTENDED_DARK: LazyLock<Extended> =
+ LazyLock::new(|| Extended::generate(Palette::DARK));
/// The built-in Dracula variant of an [`Extended`] palette.
-pub static EXTENDED_DRACULA: Lazy<Extended> =
- Lazy::new(|| Extended::generate(Palette::DRACULA));
+pub static EXTENDED_DRACULA: LazyLock<Extended> =
+ LazyLock::new(|| Extended::generate(Palette::DRACULA));
/// The built-in Nord variant of an [`Extended`] palette.
-pub static EXTENDED_NORD: Lazy<Extended> =
- Lazy::new(|| Extended::generate(Palette::NORD));
+pub static EXTENDED_NORD: LazyLock<Extended> =
+ LazyLock::new(|| Extended::generate(Palette::NORD));
/// The built-in Solarized Light variant of an [`Extended`] palette.
-pub static EXTENDED_SOLARIZED_LIGHT: Lazy<Extended> =
- Lazy::new(|| Extended::generate(Palette::SOLARIZED_LIGHT));
+pub static EXTENDED_SOLARIZED_LIGHT: LazyLock<Extended> =
+ LazyLock::new(|| Extended::generate(Palette::SOLARIZED_LIGHT));
/// The built-in Solarized Dark variant of an [`Extended`] palette.
-pub static EXTENDED_SOLARIZED_DARK: Lazy<Extended> =
- Lazy::new(|| Extended::generate(Palette::SOLARIZED_DARK));
+pub static EXTENDED_SOLARIZED_DARK: LazyLock<Extended> =
+ LazyLock::new(|| Extended::generate(Palette::SOLARIZED_DARK));
/// The built-in Gruvbox Light variant of an [`Extended`] palette.
-pub static EXTENDED_GRUVBOX_LIGHT: Lazy<Extended> =
- Lazy::new(|| Extended::generate(Palette::GRUVBOX_LIGHT));
+pub static EXTENDED_GRUVBOX_LIGHT: LazyLock<Extended> =
+ LazyLock::new(|| Extended::generate(Palette::GRUVBOX_LIGHT));
/// The built-in Gruvbox Dark variant of an [`Extended`] palette.
-pub static EXTENDED_GRUVBOX_DARK: Lazy<Extended> =
- Lazy::new(|| Extended::generate(Palette::GRUVBOX_DARK));
+pub static EXTENDED_GRUVBOX_DARK: LazyLock<Extended> =
+ LazyLock::new(|| Extended::generate(Palette::GRUVBOX_DARK));
/// The built-in Catppuccin Latte variant of an [`Extended`] palette.
-pub static EXTENDED_CATPPUCCIN_LATTE: Lazy<Extended> =
- Lazy::new(|| Extended::generate(Palette::CATPPUCCIN_LATTE));
+pub static EXTENDED_CATPPUCCIN_LATTE: LazyLock<Extended> =
+ LazyLock::new(|| Extended::generate(Palette::CATPPUCCIN_LATTE));
/// The built-in Catppuccin Frappé variant of an [`Extended`] palette.
-pub static EXTENDED_CATPPUCCIN_FRAPPE: Lazy<Extended> =
- Lazy::new(|| Extended::generate(Palette::CATPPUCCIN_FRAPPE));
+pub static EXTENDED_CATPPUCCIN_FRAPPE: LazyLock<Extended> =
+ LazyLock::new(|| Extended::generate(Palette::CATPPUCCIN_FRAPPE));
/// The built-in Catppuccin Macchiato variant of an [`Extended`] palette.
-pub static EXTENDED_CATPPUCCIN_MACCHIATO: Lazy<Extended> =
- Lazy::new(|| Extended::generate(Palette::CATPPUCCIN_MACCHIATO));
+pub static EXTENDED_CATPPUCCIN_MACCHIATO: LazyLock<Extended> =
+ LazyLock::new(|| Extended::generate(Palette::CATPPUCCIN_MACCHIATO));
/// The built-in Catppuccin Mocha variant of an [`Extended`] palette.
-pub static EXTENDED_CATPPUCCIN_MOCHA: Lazy<Extended> =
- Lazy::new(|| Extended::generate(Palette::CATPPUCCIN_MOCHA));
+pub static EXTENDED_CATPPUCCIN_MOCHA: LazyLock<Extended> =
+ LazyLock::new(|| Extended::generate(Palette::CATPPUCCIN_MOCHA));
/// The built-in Tokyo Night variant of an [`Extended`] palette.
-pub static EXTENDED_TOKYO_NIGHT: Lazy<Extended> =
- Lazy::new(|| Extended::generate(Palette::TOKYO_NIGHT));
+pub static EXTENDED_TOKYO_NIGHT: LazyLock<Extended> =
+ LazyLock::new(|| Extended::generate(Palette::TOKYO_NIGHT));
/// The built-in Tokyo Night Storm variant of an [`Extended`] palette.
-pub static EXTENDED_TOKYO_NIGHT_STORM: Lazy<Extended> =
- Lazy::new(|| Extended::generate(Palette::TOKYO_NIGHT_STORM));
+pub static EXTENDED_TOKYO_NIGHT_STORM: LazyLock<Extended> =
+ LazyLock::new(|| Extended::generate(Palette::TOKYO_NIGHT_STORM));
/// The built-in Tokyo Night variant of an [`Extended`] palette.
-pub static EXTENDED_TOKYO_NIGHT_LIGHT: Lazy<Extended> =
- Lazy::new(|| Extended::generate(Palette::TOKYO_NIGHT_LIGHT));
+pub static EXTENDED_TOKYO_NIGHT_LIGHT: LazyLock<Extended> =
+ LazyLock::new(|| Extended::generate(Palette::TOKYO_NIGHT_LIGHT));
/// The built-in Kanagawa Wave variant of an [`Extended`] palette.
-pub static EXTENDED_KANAGAWA_WAVE: Lazy<Extended> =
- Lazy::new(|| Extended::generate(Palette::KANAGAWA_WAVE));
+pub static EXTENDED_KANAGAWA_WAVE: LazyLock<Extended> =
+ LazyLock::new(|| Extended::generate(Palette::KANAGAWA_WAVE));
/// The built-in Kanagawa Dragon variant of an [`Extended`] palette.
-pub static EXTENDED_KANAGAWA_DRAGON: Lazy<Extended> =
- Lazy::new(|| Extended::generate(Palette::KANAGAWA_DRAGON));
+pub static EXTENDED_KANAGAWA_DRAGON: LazyLock<Extended> =
+ LazyLock::new(|| Extended::generate(Palette::KANAGAWA_DRAGON));
/// The built-in Kanagawa Lotus variant of an [`Extended`] palette.
-pub static EXTENDED_KANAGAWA_LOTUS: Lazy<Extended> =
- Lazy::new(|| Extended::generate(Palette::KANAGAWA_LOTUS));
+pub static EXTENDED_KANAGAWA_LOTUS: LazyLock<Extended> =
+ LazyLock::new(|| Extended::generate(Palette::KANAGAWA_LOTUS));
/// The built-in Moonfly variant of an [`Extended`] palette.
-pub static EXTENDED_MOONFLY: Lazy<Extended> =
- Lazy::new(|| Extended::generate(Palette::MOONFLY));
+pub static EXTENDED_MOONFLY: LazyLock<Extended> =
+ LazyLock::new(|| Extended::generate(Palette::MOONFLY));
/// The built-in Nightfly variant of an [`Extended`] palette.
-pub static EXTENDED_NIGHTFLY: Lazy<Extended> =
- Lazy::new(|| Extended::generate(Palette::NIGHTFLY));
+pub static EXTENDED_NIGHTFLY: LazyLock<Extended> =
+ LazyLock::new(|| Extended::generate(Palette::NIGHTFLY));
/// The built-in Oxocarbon variant of an [`Extended`] palette.
-pub static EXTENDED_OXOCARBON: Lazy<Extended> =
- Lazy::new(|| Extended::generate(Palette::OXOCARBON));
+pub static EXTENDED_OXOCARBON: LazyLock<Extended> =
+ LazyLock::new(|| Extended::generate(Palette::OXOCARBON));
/// The built-in Ferra variant of an [`Extended`] palette.
-pub static EXTENDED_FERRA: Lazy<Extended> =
- Lazy::new(|| Extended::generate(Palette::FERRA));
+pub static EXTENDED_FERRA: LazyLock<Extended> =
+ LazyLock::new(|| Extended::generate(Palette::FERRA));
impl Extended {
/// Generates an [`Extended`] palette from a simple [`Palette`].
@@ -410,6 +445,11 @@ impl Extended {
palette.background,
palette.text,
),
+ warning: Warning::generate(
+ palette.warning,
+ palette.background,
+ palette.text,
+ ),
danger: Danger::generate(
palette.danger,
palette.background,
@@ -545,6 +585,31 @@ impl Success {
}
}
+/// A set of warning colors.
+#[derive(Debug, Clone, Copy, PartialEq)]
+pub struct Warning {
+ /// The base warning color.
+ pub base: Pair,
+ /// A weaker version of the base warning color.
+ pub weak: Pair,
+ /// A stronger version of the base warning color.
+ pub strong: Pair,
+}
+
+impl Warning {
+ /// Generates a set of [`Warning`] colors from the base, background, and text colors.
+ pub fn generate(base: Color, background: Color, text: Color) -> Self {
+ let weak = mix(base, background, 0.4);
+ let strong = deviate(base, 0.1);
+
+ Self {
+ base: Pair::new(base, text),
+ weak: Pair::new(weak, text),
+ strong: Pair::new(strong, text),
+ }
+ }
+}
+
/// A set of danger colors.
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct Danger {
diff --git a/core/src/time.rs b/core/src/time.rs
index dcfe4e41..c6e30444 100644
--- a/core/src/time.rs
+++ b/core/src/time.rs
@@ -2,3 +2,28 @@
pub use web_time::Duration;
pub use web_time::Instant;
+
+/// Creates a [`Duration`] representing the given amount of milliseconds.
+pub fn milliseconds(milliseconds: u64) -> Duration {
+ Duration::from_millis(milliseconds)
+}
+
+/// Creates a [`Duration`] representing the given amount of seconds.
+pub fn seconds(seconds: u64) -> Duration {
+ Duration::from_secs(seconds)
+}
+
+/// Creates a [`Duration`] representing the given amount of minutes.
+pub fn minutes(minutes: u64) -> Duration {
+ seconds(minutes * 60)
+}
+
+/// Creates a [`Duration`] representing the given amount of hours.
+pub fn hours(hours: u64) -> Duration {
+ minutes(hours * 60)
+}
+
+/// Creates a [`Duration`] representing the given amount of days.
+pub fn days(days: u64) -> Duration {
+ hours(days * 24)
+}
diff --git a/core/src/widget/operation.rs b/core/src/widget/operation.rs
index 6bdb27f6..8fc627bf 100644
--- a/core/src/widget/operation.rs
+++ b/core/src/widget/operation.rs
@@ -30,24 +30,45 @@ pub trait Operation<T = ()>: Send {
);
/// Operates on a widget that can be focused.
- fn focusable(&mut self, _state: &mut dyn Focusable, _id: Option<&Id>) {}
+ fn focusable(
+ &mut self,
+ _id: Option<&Id>,
+ _bounds: Rectangle,
+ _state: &mut dyn Focusable,
+ ) {
+ }
/// Operates on a widget that can be scrolled.
fn scrollable(
&mut self,
- _state: &mut dyn Scrollable,
_id: Option<&Id>,
_bounds: Rectangle,
_content_bounds: Rectangle,
_translation: Vector,
+ _state: &mut dyn Scrollable,
) {
}
/// Operates on a widget that has text input.
- fn text_input(&mut self, _state: &mut dyn TextInput, _id: Option<&Id>) {}
+ fn text_input(
+ &mut self,
+ _id: Option<&Id>,
+ _bounds: Rectangle,
+ _state: &mut dyn TextInput,
+ ) {
+ }
+
+ /// Operates on a widget that contains some text.
+ fn text(&mut self, _id: Option<&Id>, _bounds: Rectangle, _text: &str) {}
/// Operates on a custom widget with some state.
- fn custom(&mut self, _state: &mut dyn Any, _id: Option<&Id>) {}
+ fn custom(
+ &mut self,
+ _id: Option<&Id>,
+ _bounds: Rectangle,
+ _state: &mut dyn Any,
+ ) {
+ }
/// Finishes the [`Operation`] and returns its [`Outcome`].
fn finish(&self) -> Outcome<T> {
@@ -68,33 +89,52 @@ where
self.as_mut().container(id, bounds, operate_on_children);
}
- fn focusable(&mut self, state: &mut dyn Focusable, id: Option<&Id>) {
- self.as_mut().focusable(state, id);
+ fn focusable(
+ &mut self,
+ id: Option<&Id>,
+ bounds: Rectangle,
+ state: &mut dyn Focusable,
+ ) {
+ self.as_mut().focusable(id, bounds, state);
}
fn scrollable(
&mut self,
- state: &mut dyn Scrollable,
id: Option<&Id>,
bounds: Rectangle,
content_bounds: Rectangle,
translation: Vector,
+ state: &mut dyn Scrollable,
) {
self.as_mut().scrollable(
- state,
id,
bounds,
content_bounds,
translation,
+ state,
);
}
- fn text_input(&mut self, state: &mut dyn TextInput, id: Option<&Id>) {
- self.as_mut().text_input(state, id);
+ fn text_input(
+ &mut self,
+ id: Option<&Id>,
+ bounds: Rectangle,
+ state: &mut dyn TextInput,
+ ) {
+ self.as_mut().text_input(id, bounds, state);
+ }
+
+ fn text(&mut self, id: Option<&Id>, bounds: Rectangle, text: &str) {
+ self.as_mut().text(id, bounds, text);
}
- fn custom(&mut self, state: &mut dyn Any, id: Option<&Id>) {
- self.as_mut().custom(state, id);
+ fn custom(
+ &mut self,
+ id: Option<&Id>,
+ bounds: Rectangle,
+ state: &mut dyn Any,
+ ) {
+ self.as_mut().custom(id, bounds, state);
}
fn finish(&self) -> Outcome<O> {
@@ -150,33 +190,52 @@ where
});
}
- fn focusable(&mut self, state: &mut dyn Focusable, id: Option<&Id>) {
- self.operation.focusable(state, id);
+ fn focusable(
+ &mut self,
+ id: Option<&Id>,
+ bounds: Rectangle,
+ state: &mut dyn Focusable,
+ ) {
+ self.operation.focusable(id, bounds, state);
}
fn scrollable(
&mut self,
- state: &mut dyn Scrollable,
id: Option<&Id>,
bounds: Rectangle,
content_bounds: Rectangle,
translation: Vector,
+ state: &mut dyn Scrollable,
) {
self.operation.scrollable(
- state,
id,
bounds,
content_bounds,
translation,
+ state,
);
}
- fn text_input(&mut self, state: &mut dyn TextInput, id: Option<&Id>) {
- self.operation.text_input(state, id);
+ fn text_input(
+ &mut self,
+ id: Option<&Id>,
+ bounds: Rectangle,
+ state: &mut dyn TextInput,
+ ) {
+ self.operation.text_input(id, bounds, state);
}
- fn custom(&mut self, state: &mut dyn Any, id: Option<&Id>) {
- self.operation.custom(state, id);
+ fn text(&mut self, id: Option<&Id>, bounds: Rectangle, text: &str) {
+ self.operation.text(id, bounds, text);
+ }
+
+ fn custom(
+ &mut self,
+ id: Option<&Id>,
+ bounds: Rectangle,
+ state: &mut dyn Any,
+ ) {
+ self.operation.custom(id, bounds, state);
}
fn finish(&self) -> Outcome<O> {
@@ -234,39 +293,55 @@ where
fn scrollable(
&mut self,
- state: &mut dyn Scrollable,
id: Option<&Id>,
bounds: Rectangle,
content_bounds: Rectangle,
translation: Vector,
+ state: &mut dyn Scrollable,
) {
self.operation.scrollable(
- state,
id,
bounds,
content_bounds,
translation,
+ state,
);
}
fn focusable(
&mut self,
- state: &mut dyn Focusable,
id: Option<&Id>,
+ bounds: Rectangle,
+ state: &mut dyn Focusable,
) {
- self.operation.focusable(state, id);
+ self.operation.focusable(id, bounds, state);
}
fn text_input(
&mut self,
+ id: Option<&Id>,
+ bounds: Rectangle,
state: &mut dyn TextInput,
+ ) {
+ self.operation.text_input(id, bounds, state);
+ }
+
+ fn text(
+ &mut self,
id: Option<&Id>,
+ bounds: Rectangle,
+ text: &str,
) {
- self.operation.text_input(state, id);
+ self.operation.text(id, bounds, text);
}
- fn custom(&mut self, state: &mut dyn Any, id: Option<&Id>) {
- self.operation.custom(state, id);
+ fn custom(
+ &mut self,
+ id: Option<&Id>,
+ bounds: Rectangle,
+ state: &mut dyn Any,
+ ) {
+ self.operation.custom(id, bounds, state);
}
}
@@ -275,33 +350,52 @@ where
MapRef { operation }.container(id, bounds, operate_on_children);
}
- fn focusable(&mut self, state: &mut dyn Focusable, id: Option<&Id>) {
- self.operation.focusable(state, id);
+ fn focusable(
+ &mut self,
+ id: Option<&Id>,
+ bounds: Rectangle,
+ state: &mut dyn Focusable,
+ ) {
+ self.operation.focusable(id, bounds, state);
}
fn scrollable(
&mut self,
- state: &mut dyn Scrollable,
id: Option<&Id>,
bounds: Rectangle,
content_bounds: Rectangle,
translation: Vector,
+ state: &mut dyn Scrollable,
) {
self.operation.scrollable(
- state,
id,
bounds,
content_bounds,
translation,
+ state,
);
}
- fn text_input(&mut self, state: &mut dyn TextInput, id: Option<&Id>) {
- self.operation.text_input(state, id);
+ fn text_input(
+ &mut self,
+ id: Option<&Id>,
+ bounds: Rectangle,
+ state: &mut dyn TextInput,
+ ) {
+ self.operation.text_input(id, bounds, state);
+ }
+
+ fn text(&mut self, id: Option<&Id>, bounds: Rectangle, text: &str) {
+ self.operation.text(id, bounds, text);
}
- fn custom(&mut self, state: &mut dyn Any, id: Option<&Id>) {
- self.operation.custom(state, id);
+ fn custom(
+ &mut self,
+ id: Option<&Id>,
+ bounds: Rectangle,
+ state: &mut dyn Any,
+ ) {
+ self.operation.custom(id, bounds, state);
}
fn finish(&self) -> Outcome<B> {
@@ -361,33 +455,52 @@ where
});
}
- fn focusable(&mut self, state: &mut dyn Focusable, id: Option<&Id>) {
- self.operation.focusable(state, id);
+ fn focusable(
+ &mut self,
+ id: Option<&Id>,
+ bounds: Rectangle,
+ state: &mut dyn Focusable,
+ ) {
+ self.operation.focusable(id, bounds, state);
}
fn scrollable(
&mut self,
- state: &mut dyn Scrollable,
id: Option<&Id>,
bounds: Rectangle,
content_bounds: Rectangle,
translation: crate::Vector,
+ state: &mut dyn Scrollable,
) {
self.operation.scrollable(
- state,
id,
bounds,
content_bounds,
translation,
+ state,
);
}
- fn text_input(&mut self, state: &mut dyn TextInput, id: Option<&Id>) {
- self.operation.text_input(state, id);
+ fn text_input(
+ &mut self,
+ id: Option<&Id>,
+ bounds: Rectangle,
+ state: &mut dyn TextInput,
+ ) {
+ self.operation.text_input(id, bounds, state);
}
- fn custom(&mut self, state: &mut dyn std::any::Any, id: Option<&Id>) {
- self.operation.custom(state, id);
+ fn text(&mut self, id: Option<&Id>, bounds: Rectangle, text: &str) {
+ self.operation.text(id, bounds, text);
+ }
+
+ fn custom(
+ &mut self,
+ id: Option<&Id>,
+ bounds: Rectangle,
+ state: &mut dyn Any,
+ ) {
+ self.operation.custom(id, bounds, state);
}
fn finish(&self) -> Outcome<B> {
diff --git a/core/src/widget/operation/focusable.rs b/core/src/widget/operation/focusable.rs
index 867c682e..8f66e575 100644
--- a/core/src/widget/operation/focusable.rs
+++ b/core/src/widget/operation/focusable.rs
@@ -32,7 +32,12 @@ pub fn focus<T>(target: Id) -> impl Operation<T> {
}
impl<T> Operation<T> for Focus {
- fn focusable(&mut self, state: &mut dyn Focusable, id: Option<&Id>) {
+ fn focusable(
+ &mut self,
+ id: Option<&Id>,
+ _bounds: Rectangle,
+ state: &mut dyn Focusable,
+ ) {
match id {
Some(id) if id == &self.target => {
state.focus();
@@ -64,7 +69,12 @@ pub fn count() -> impl Operation<Count> {
}
impl Operation<Count> for CountFocusable {
- fn focusable(&mut self, state: &mut dyn Focusable, _id: Option<&Id>) {
+ fn focusable(
+ &mut self,
+ _id: Option<&Id>,
+ _bounds: Rectangle,
+ state: &mut dyn Focusable,
+ ) {
if state.is_focused() {
self.count.focused = Some(self.count.total);
}
@@ -104,7 +114,12 @@ where
}
impl<T> Operation<T> for FocusPrevious {
- fn focusable(&mut self, state: &mut dyn Focusable, _id: Option<&Id>) {
+ fn focusable(
+ &mut self,
+ _id: Option<&Id>,
+ _bounds: Rectangle,
+ state: &mut dyn Focusable,
+ ) {
if self.count.total == 0 {
return;
}
@@ -147,7 +162,12 @@ where
}
impl<T> Operation<T> for FocusNext {
- fn focusable(&mut self, state: &mut dyn Focusable, _id: Option<&Id>) {
+ fn focusable(
+ &mut self,
+ _id: Option<&Id>,
+ _bounds: Rectangle,
+ state: &mut dyn Focusable,
+ ) {
match self.count.focused {
None if self.current == 0 => state.focus(),
Some(focused) if focused == self.current => state.unfocus(),
@@ -179,7 +199,12 @@ pub fn find_focused() -> impl Operation<Id> {
}
impl Operation<Id> for FindFocused {
- fn focusable(&mut self, state: &mut dyn Focusable, id: Option<&Id>) {
+ fn focusable(
+ &mut self,
+ id: Option<&Id>,
+ _bounds: Rectangle,
+ state: &mut dyn Focusable,
+ ) {
if state.is_focused() && id.is_some() {
self.focused = id.cloned();
}
diff --git a/core/src/widget/operation/scrollable.rs b/core/src/widget/operation/scrollable.rs
index c2fecf56..7c78c087 100644
--- a/core/src/widget/operation/scrollable.rs
+++ b/core/src/widget/operation/scrollable.rs
@@ -39,11 +39,11 @@ pub fn snap_to<T>(target: Id, offset: RelativeOffset) -> impl Operation<T> {
fn scrollable(
&mut self,
- state: &mut dyn Scrollable,
id: Option<&Id>,
_bounds: Rectangle,
_content_bounds: Rectangle,
_translation: Vector,
+ state: &mut dyn Scrollable,
) {
if Some(&self.target) == id {
state.snap_to(self.offset);
@@ -74,11 +74,11 @@ pub fn scroll_to<T>(target: Id, offset: AbsoluteOffset) -> impl Operation<T> {
fn scrollable(
&mut self,
- state: &mut dyn Scrollable,
id: Option<&Id>,
_bounds: Rectangle,
_content_bounds: Rectangle,
_translation: Vector,
+ state: &mut dyn Scrollable,
) {
if Some(&self.target) == id {
state.scroll_to(self.offset);
@@ -109,11 +109,11 @@ pub fn scroll_by<T>(target: Id, offset: AbsoluteOffset) -> impl Operation<T> {
fn scrollable(
&mut self,
- state: &mut dyn Scrollable,
id: Option<&Id>,
bounds: Rectangle,
content_bounds: Rectangle,
_translation: Vector,
+ state: &mut dyn Scrollable,
) {
if Some(&self.target) == id {
state.scroll_by(self.offset, bounds, content_bounds);
diff --git a/core/src/widget/operation/text_input.rs b/core/src/widget/operation/text_input.rs
index 41731d4c..a46f1a2d 100644
--- a/core/src/widget/operation/text_input.rs
+++ b/core/src/widget/operation/text_input.rs
@@ -23,7 +23,12 @@ pub fn move_cursor_to_front<T>(target: Id) -> impl Operation<T> {
}
impl<T> Operation<T> for MoveCursor {
- fn text_input(&mut self, state: &mut dyn TextInput, id: Option<&Id>) {
+ fn text_input(
+ &mut self,
+ id: Option<&Id>,
+ _bounds: Rectangle,
+ state: &mut dyn TextInput,
+ ) {
match id {
Some(id) if id == &self.target => {
state.move_cursor_to_front();
@@ -53,7 +58,12 @@ pub fn move_cursor_to_end<T>(target: Id) -> impl Operation<T> {
}
impl<T> Operation<T> for MoveCursor {
- fn text_input(&mut self, state: &mut dyn TextInput, id: Option<&Id>) {
+ fn text_input(
+ &mut self,
+ id: Option<&Id>,
+ _bounds: Rectangle,
+ state: &mut dyn TextInput,
+ ) {
match id {
Some(id) if id == &self.target => {
state.move_cursor_to_end();
@@ -84,7 +94,12 @@ pub fn move_cursor_to<T>(target: Id, position: usize) -> impl Operation<T> {
}
impl<T> Operation<T> for MoveCursor {
- fn text_input(&mut self, state: &mut dyn TextInput, id: Option<&Id>) {
+ fn text_input(
+ &mut self,
+ id: Option<&Id>,
+ _bounds: Rectangle,
+ state: &mut dyn TextInput,
+ ) {
match id {
Some(id) if id == &self.target => {
state.move_cursor_to(self.position);
@@ -113,7 +128,12 @@ pub fn select_all<T>(target: Id) -> impl Operation<T> {
}
impl<T> Operation<T> for MoveCursor {
- fn text_input(&mut self, state: &mut dyn TextInput, id: Option<&Id>) {
+ fn text_input(
+ &mut self,
+ id: Option<&Id>,
+ _bounds: Rectangle,
+ state: &mut dyn TextInput,
+ ) {
match id {
Some(id) if id == &self.target => {
state.select_all();
diff --git a/core/src/widget/text.rs b/core/src/widget/text.rs
index d3d1cffd..c7ec3c8b 100644
--- a/core/src/widget/text.rs
+++ b/core/src/widget/text.rs
@@ -267,6 +267,16 @@ where
draw(renderer, defaults, layout, state.0.raw(), style, viewport);
}
+
+ fn operate(
+ &self,
+ _state: &mut Tree,
+ layout: Layout<'_>,
+ _renderer: &Renderer,
+ operation: &mut dyn super::Operation,
+ ) {
+ operation.text(None, layout.bounds(), &self.fragment);
+ }
}
/// Produces the [`layout::Node`] of a [`Text`] widget.
diff --git a/core/src/window.rs b/core/src/window.rs
index 448ffc45..d0e741d8 100644
--- a/core/src/window.rs
+++ b/core/src/window.rs
@@ -1,7 +1,9 @@
//! Build window-based GUI applications.
pub mod icon;
+pub mod screenshot;
pub mod settings;
+mod direction;
mod event;
mod id;
mod level;
@@ -10,6 +12,7 @@ mod position;
mod redraw_request;
mod user_attention;
+pub use direction::Direction;
pub use event::Event;
pub use icon::Icon;
pub use id::Id;
@@ -17,5 +20,6 @@ pub use level::Level;
pub use mode::Mode;
pub use position::Position;
pub use redraw_request::RedrawRequest;
+pub use screenshot::Screenshot;
pub use settings::Settings;
pub use user_attention::UserAttention;
diff --git a/core/src/window/direction.rs b/core/src/window/direction.rs
new file mode 100644
index 00000000..b757961e
--- /dev/null
+++ b/core/src/window/direction.rs
@@ -0,0 +1,27 @@
+/// The cardinal directions relative to the center of a window.
+#[derive(Debug, Clone, Copy)]
+pub enum Direction {
+ /// Points to the top edge of a window.
+ North,
+
+ /// Points to the bottom edge of a window.
+ South,
+
+ /// Points to the right edge of a window.
+ East,
+
+ /// Points to the left edge of a window.
+ West,
+
+ /// Points to the top-right corner of a window.
+ NorthEast,
+
+ /// Points to the top-left corner of a window.
+ NorthWest,
+
+ /// Points to the bottom-right corner of a window.
+ SouthEast,
+
+ /// Points to the bottom-left corner of a window.
+ SouthWest,
+}
diff --git a/core/src/window/event.rs b/core/src/window/event.rs
index 4e2751ee..45d29179 100644
--- a/core/src/window/event.rs
+++ b/core/src/window/event.rs
@@ -9,8 +9,8 @@ pub enum Event {
/// A window was opened.
Opened {
/// The position of the opened window. This is relative to the top-left corner of the desktop
- /// the window is on, including virtual desktops. Refers to window's "inner" position,
- /// or the client area, in logical pixels.
+ /// the window is on, including virtual desktops. Refers to window's "outer" position,
+ /// or the window area, in logical pixels.
///
/// **Note**: Not available in Wayland.
position: Option<Point>,
diff --git a/core/src/window/screenshot.rs b/core/src/window/screenshot.rs
new file mode 100644
index 00000000..424168bb
--- /dev/null
+++ b/core/src/window/screenshot.rs
@@ -0,0 +1,108 @@
+//! Take screenshots of a window.
+use crate::{Rectangle, Size};
+
+use bytes::Bytes;
+use std::fmt::{Debug, Formatter};
+
+/// Data of a screenshot, captured with `window::screenshot()`.
+///
+/// The `bytes` of this screenshot will always be ordered as `RGBA` in the `sRGB` color space.
+#[derive(Clone)]
+pub struct Screenshot {
+ /// The bytes of the [`Screenshot`].
+ pub bytes: Bytes,
+ /// The size of the [`Screenshot`] in physical pixels.
+ pub size: Size<u32>,
+ /// The scale factor of the [`Screenshot`]. This can be useful when converting between widget
+ /// bounds (which are in logical pixels) to crop screenshots.
+ pub scale_factor: f64,
+}
+
+impl Debug for Screenshot {
+ fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+ write!(
+ f,
+ "Screenshot: {{ \n bytes: {}\n scale: {}\n size: {:?} }}",
+ self.bytes.len(),
+ self.scale_factor,
+ self.size
+ )
+ }
+}
+
+impl Screenshot {
+ /// Creates a new [`Screenshot`].
+ pub fn new(
+ bytes: impl Into<Bytes>,
+ size: Size<u32>,
+ scale_factor: f64,
+ ) -> Self {
+ Self {
+ bytes: bytes.into(),
+ size,
+ scale_factor,
+ }
+ }
+
+ /// Crops a [`Screenshot`] to the provided `region`. This will always be relative to the
+ /// top-left corner of the [`Screenshot`].
+ pub fn crop(&self, region: Rectangle<u32>) -> Result<Self, CropError> {
+ if region.width == 0 || region.height == 0 {
+ return Err(CropError::Zero);
+ }
+
+ if region.x + region.width > self.size.width
+ || region.y + region.height > self.size.height
+ {
+ return Err(CropError::OutOfBounds);
+ }
+
+ // Image is always RGBA8 = 4 bytes per pixel
+ const PIXEL_SIZE: usize = 4;
+
+ let bytes_per_row = self.size.width as usize * PIXEL_SIZE;
+ let row_range = region.y as usize..(region.y + region.height) as usize;
+ let column_range = region.x as usize * PIXEL_SIZE
+ ..(region.x + region.width) as usize * PIXEL_SIZE;
+
+ let chopped = self.bytes.chunks(bytes_per_row).enumerate().fold(
+ vec![],
+ |mut acc, (row, bytes)| {
+ if row_range.contains(&row) {
+ acc.extend(&bytes[column_range.clone()]);
+ }
+
+ acc
+ },
+ );
+
+ Ok(Self {
+ bytes: Bytes::from(chopped),
+ size: Size::new(region.width, region.height),
+ scale_factor: self.scale_factor,
+ })
+ }
+}
+
+impl AsRef<[u8]> for Screenshot {
+ fn as_ref(&self) -> &[u8] {
+ &self.bytes
+ }
+}
+
+impl From<Screenshot> for Bytes {
+ fn from(screenshot: Screenshot) -> Self {
+ screenshot.bytes
+ }
+}
+
+#[derive(Debug, thiserror::Error)]
+/// Errors that can occur when cropping a [`Screenshot`].
+pub enum CropError {
+ #[error("The cropped region is out of bounds.")]
+ /// The cropped region's size is out of bounds.
+ OutOfBounds,
+ #[error("The cropped region is not visible.")]
+ /// The cropped region's size is zero.
+ Zero,
+}
diff --git a/core/src/window/settings.rs b/core/src/window/settings.rs
index fbbf86ab..9432eaaa 100644
--- a/core/src/window/settings.rs
+++ b/core/src/window/settings.rs
@@ -28,12 +28,19 @@ use crate::window::{Icon, Level, Position};
use crate::Size;
pub use platform::PlatformSpecific;
+
/// The window settings of an application.
#[derive(Debug, Clone)]
pub struct Settings {
/// The initial logical dimensions of the window.
pub size: Size,
+ /// Whether the window should start maximized.
+ pub maximized: bool,
+
+ /// Whether the window should start fullscreen.
+ pub fullscreen: bool,
+
/// The initial position of the window.
pub position: Position,
@@ -79,6 +86,8 @@ impl Default for Settings {
fn default() -> Self {
Self {
size: Size::new(1024.0, 768.0),
+ maximized: false,
+ fullscreen: false,
position: Position::default(),
min_size: None,
max_size: None,