summaryrefslogtreecommitdiffstats
path: root/src/settings.rs
diff options
context:
space:
mode:
authorLibravatar hatoo <hato2000@gmail.com>2019-12-01 14:55:05 +0900
committerLibravatar hatoo <hato2000@gmail.com>2019-12-01 14:55:05 +0900
commita33f49ff4b1c11e467ec492a96e1e05e4d32d6aa (patch)
tree74b63593e76ebf2171365b7cdc39cd6c00921c45 /src/settings.rs
parent5077f1dc6a6aca5ab84dd89296fb70489393cf57 (diff)
downloadiced-a33f49ff4b1c11e467ec492a96e1e05e4d32d6aa.tar.gz
iced-a33f49ff4b1c11e467ec492a96e1e05e4d32d6aa.tar.bz2
iced-a33f49ff4b1c11e467ec492a96e1e05e4d32d6aa.zip
Remove platform-specific logic from iced
Make Window.platform_specific use iced_winit::settings::PlatformSpecific
Diffstat (limited to 'src/settings.rs')
-rw-r--r--src/settings.rs53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/settings.rs b/src/settings.rs
new file mode 100644
index 00000000..a5820d87
--- /dev/null
+++ b/src/settings.rs
@@ -0,0 +1,53 @@
+//! Configure your application.
+
+/// The settings of an application.
+#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
+pub struct Settings {
+ /// The [`Window`] settings.
+ ///
+ /// They will be ignored on the Web.
+ ///
+ /// [`Window`]: struct.Window.html
+ pub window: Window,
+}
+
+/// The window settings of an application.
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+pub struct Window {
+ /// The size of the window.
+ pub size: (u32, u32),
+
+ /// Whether the window should be resizable or not.
+ pub resizable: bool,
+
+ /// Whether the window should have a border, a title bar, etc.
+ pub decorations: bool,
+
+ /// Platform specific Setting.
+ pub platform_specific: iced_winit::settings::PlatformSpecific,
+}
+
+impl Default for Window {
+ fn default() -> Window {
+ Window {
+ size: (1024, 768),
+ resizable: true,
+ decorations: true,
+ platform_specific: Default::default(),
+ }
+ }
+}
+
+#[cfg(not(target_arch = "wasm32"))]
+impl From<Settings> for iced_winit::Settings {
+ fn from(settings: Settings) -> iced_winit::Settings {
+ iced_winit::Settings {
+ window: iced_winit::settings::Window {
+ size: settings.window.size,
+ resizable: settings.window.resizable,
+ decorations: settings.window.decorations,
+ platform_specific: settings.window.platform_specific,
+ },
+ }
+ }
+}