use Mode::Hidden instead
This commit is contained in:
parent
6f6f1d82e8
commit
84c0c9bc7a
@ -55,7 +55,6 @@ where
|
|||||||
let builder = settings.window.into_builder(
|
let builder = settings.window.into_builder(
|
||||||
&application.title(),
|
&application.title(),
|
||||||
application.mode(),
|
application.mode(),
|
||||||
application.visible(),
|
|
||||||
event_loop.primary_monitor(),
|
event_loop.primary_monitor(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -191,13 +191,6 @@ pub trait Application: Sized {
|
|||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns whether the [`Application`] should be visible or not
|
|
||||||
///
|
|
||||||
/// By default, it returns `true`.
|
|
||||||
fn visible(&self) -> bool {
|
|
||||||
true
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Runs the [`Application`].
|
/// Runs the [`Application`].
|
||||||
///
|
///
|
||||||
/// On native platforms, this method will take control of the current thread
|
/// On native platforms, this method will take control of the current thread
|
||||||
@ -284,6 +277,7 @@ where
|
|||||||
match self.0.mode() {
|
match self.0.mode() {
|
||||||
window::Mode::Windowed => iced_winit::Mode::Windowed,
|
window::Mode::Windowed => iced_winit::Mode::Windowed,
|
||||||
window::Mode::Fullscreen => iced_winit::Mode::Fullscreen,
|
window::Mode::Fullscreen => iced_winit::Mode::Fullscreen,
|
||||||
|
window::Mode::Hidden => iced_winit::Mode::Hidden,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -302,10 +296,6 @@ where
|
|||||||
fn should_exit(&self) -> bool {
|
fn should_exit(&self) -> bool {
|
||||||
self.0.should_exit()
|
self.0.should_exit()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visible(&self) -> bool {
|
|
||||||
self.0.visible()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(target_arch = "wasm32")]
|
||||||
|
@ -6,4 +6,7 @@ pub enum Mode {
|
|||||||
|
|
||||||
/// The application takes the whole screen of its current monitor.
|
/// The application takes the whole screen of its current monitor.
|
||||||
Fullscreen,
|
Fullscreen,
|
||||||
|
|
||||||
|
/// The application is hidden
|
||||||
|
Hidden,
|
||||||
}
|
}
|
||||||
|
@ -98,13 +98,6 @@ pub trait Application: Program<Clipboard = Clipboard> {
|
|||||||
fn should_exit(&self) -> bool {
|
fn should_exit(&self) -> bool {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns whether the [`Application`] should be visible or not
|
|
||||||
///
|
|
||||||
/// By default, it returns `true`.
|
|
||||||
fn visible(&self) -> bool {
|
|
||||||
true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Runs an [`Application`] with an executor, compositor, and the provided
|
/// Runs an [`Application`] with an executor, compositor, and the provided
|
||||||
@ -152,7 +145,6 @@ where
|
|||||||
.into_builder(
|
.into_builder(
|
||||||
&application.title(),
|
&application.title(),
|
||||||
application.mode(),
|
application.mode(),
|
||||||
application.visible(),
|
|
||||||
event_loop.primary_monitor(),
|
event_loop.primary_monitor(),
|
||||||
)
|
)
|
||||||
.build(&event_loop)
|
.build(&event_loop)
|
||||||
|
@ -12,7 +12,6 @@ pub struct State<A: Application> {
|
|||||||
mode: Mode,
|
mode: Mode,
|
||||||
background_color: Color,
|
background_color: Color,
|
||||||
scale_factor: f64,
|
scale_factor: f64,
|
||||||
visible: bool,
|
|
||||||
viewport: Viewport,
|
viewport: Viewport,
|
||||||
viewport_version: usize,
|
viewport_version: usize,
|
||||||
cursor_position: winit::dpi::PhysicalPosition<f64>,
|
cursor_position: winit::dpi::PhysicalPosition<f64>,
|
||||||
@ -27,7 +26,6 @@ impl<A: Application> State<A> {
|
|||||||
let mode = application.mode();
|
let mode = application.mode();
|
||||||
let background_color = application.background_color();
|
let background_color = application.background_color();
|
||||||
let scale_factor = application.scale_factor();
|
let scale_factor = application.scale_factor();
|
||||||
let visible = application.visible();
|
|
||||||
|
|
||||||
let viewport = {
|
let viewport = {
|
||||||
let physical_size = window.inner_size();
|
let physical_size = window.inner_size();
|
||||||
@ -43,7 +41,6 @@ impl<A: Application> State<A> {
|
|||||||
mode,
|
mode,
|
||||||
background_color,
|
background_color,
|
||||||
scale_factor,
|
scale_factor,
|
||||||
visible,
|
|
||||||
viewport,
|
viewport,
|
||||||
viewport_version: 0,
|
viewport_version: 0,
|
||||||
// TODO: Encode cursor availability in the type-system
|
// TODO: Encode cursor availability in the type-system
|
||||||
@ -185,6 +182,8 @@ impl<A: Application> State<A> {
|
|||||||
new_mode,
|
new_mode,
|
||||||
));
|
));
|
||||||
|
|
||||||
|
window.set_visible(conversion::visible(new_mode));
|
||||||
|
|
||||||
self.mode = new_mode;
|
self.mode = new_mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -204,14 +203,5 @@ impl<A: Application> State<A> {
|
|||||||
|
|
||||||
self.scale_factor = new_scale_factor;
|
self.scale_factor = new_scale_factor;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update window visibility
|
|
||||||
let new_visible = application.visible();
|
|
||||||
|
|
||||||
if self.visible != new_visible {
|
|
||||||
window.set_visible(new_visible);
|
|
||||||
|
|
||||||
self.visible = new_visible;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -141,13 +141,21 @@ pub fn fullscreen(
|
|||||||
mode: Mode,
|
mode: Mode,
|
||||||
) -> Option<winit::window::Fullscreen> {
|
) -> Option<winit::window::Fullscreen> {
|
||||||
match mode {
|
match mode {
|
||||||
Mode::Windowed => None,
|
Mode::Windowed | Mode::Hidden => None,
|
||||||
Mode::Fullscreen => {
|
Mode::Fullscreen => {
|
||||||
Some(winit::window::Fullscreen::Borderless(monitor))
|
Some(winit::window::Fullscreen::Borderless(monitor))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Converts a [`Mode`] to a visibility flag.
|
||||||
|
pub fn visible(mode: Mode) -> bool {
|
||||||
|
match mode {
|
||||||
|
Mode::Windowed | Mode::Fullscreen => true,
|
||||||
|
Mode::Hidden => false,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Converts a `MouseCursor` from [`iced_native`] to a [`winit`] cursor icon.
|
/// Converts a `MouseCursor` from [`iced_native`] to a [`winit`] cursor icon.
|
||||||
///
|
///
|
||||||
/// [`winit`]: https://github.com/rust-windowing/winit
|
/// [`winit`]: https://github.com/rust-windowing/winit
|
||||||
|
@ -6,4 +6,7 @@ pub enum Mode {
|
|||||||
|
|
||||||
/// The application takes the whole screen of its current monitor.
|
/// The application takes the whole screen of its current monitor.
|
||||||
Fullscreen,
|
Fullscreen,
|
||||||
|
|
||||||
|
/// The application is hidden
|
||||||
|
Hidden,
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,6 @@ impl Window {
|
|||||||
self,
|
self,
|
||||||
title: &str,
|
title: &str,
|
||||||
mode: Mode,
|
mode: Mode,
|
||||||
visible: bool,
|
|
||||||
primary_monitor: Option<MonitorHandle>,
|
primary_monitor: Option<MonitorHandle>,
|
||||||
) -> WindowBuilder {
|
) -> WindowBuilder {
|
||||||
let mut window_builder = WindowBuilder::new();
|
let mut window_builder = WindowBuilder::new();
|
||||||
@ -82,7 +81,7 @@ impl Window {
|
|||||||
.with_window_icon(self.icon)
|
.with_window_icon(self.icon)
|
||||||
.with_always_on_top(self.always_on_top)
|
.with_always_on_top(self.always_on_top)
|
||||||
.with_fullscreen(conversion::fullscreen(primary_monitor, mode))
|
.with_fullscreen(conversion::fullscreen(primary_monitor, mode))
|
||||||
.with_visible(visible);
|
.with_visible(conversion::visible(mode));
|
||||||
|
|
||||||
if let Some((width, height)) = self.min_size {
|
if let Some((width, height)) = self.min_size {
|
||||||
window_builder = window_builder
|
window_builder = window_builder
|
||||||
|
Loading…
Reference in New Issue
Block a user