Merge pull request #825 from tarkah/feat/window-visibility
add window visibility
This commit is contained in:
commit
4b8ba8309f
|
@ -277,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,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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,
|
||||||
}
|
}
|
||||||
|
|
|
@ -182,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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,
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,7 +80,8 @@ impl Window {
|
||||||
.with_transparent(self.transparent)
|
.with_transparent(self.transparent)
|
||||||
.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(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