From c96492b95660640eb2dd66a77c96ad32d5d5b0ae Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 16 Jan 2020 05:54:22 +0100 Subject: Expose `window::Mode` in `iced` Although the Fullscreen API in the Web platform has some limitations, it is still useful to be able to support fullscreen on the native side. --- src/application.rs | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'src/application.rs') diff --git a/src/application.rs b/src/application.rs index 5ea64ba8..b940cc17 100644 --- a/src/application.rs +++ b/src/application.rs @@ -1,4 +1,4 @@ -use crate::{Command, Element, Settings, Subscription}; +use crate::{window, Command, Element, Settings, Subscription}; /// An interactive cross-platform application. /// @@ -138,6 +138,20 @@ pub trait Application: Sized { /// [`Application`]: trait.Application.html fn view(&mut self) -> Element<'_, Self::Message>; + /// Returns the current [`Application`] mode. + /// + /// The runtime will automatically transition your application if a new mode + /// is returned. + /// + /// Currently, the mode only has an effect in native platforms. + /// + /// By default, an application will run in windowed mode. + /// + /// [`Application`]: trait.Application.html + fn mode(&self) -> window::Mode { + window::Mode::Windowed + } + /// Runs the [`Application`]. /// /// This method will take control of the current thread and __will NOT @@ -183,6 +197,13 @@ where self.0.title() } + fn mode(&self) -> iced_winit::Mode { + match self.0.mode() { + window::Mode::Windowed => iced_winit::Mode::Windowed, + window::Mode::Fullscreen => iced_winit::Mode::Fullscreen, + } + } + fn update(&mut self, message: Self::Message) -> Command { self.0.update(message) } -- cgit