MacOS: Support fullsize content (no titlebar, but window controls) (#2049)
Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
This commit is contained in:
parent
0605bcfca7
commit
c4117066cf
3 changed files with 22 additions and 0 deletions
|
@ -5,6 +5,7 @@ NOTE: [`egui-winit`](../egui-winit/CHANGELOG.md), [`egui_glium`](../egui_glium/C
|
||||||
|
|
||||||
|
|
||||||
## Unreleased
|
## Unreleased
|
||||||
|
* Added `NativeOptions::fullsize_content` option on Mac to build titlebar-less windows with floating window controls ([#2049](https://github.com/emilk/egui/pull/2049)).
|
||||||
* Added `NativeOptions::event_loop_builder` hook for apps to change platform specific event loop options ([#1952](https://github.com/emilk/egui/pull/1952)).
|
* Added `NativeOptions::event_loop_builder` hook for apps to change platform specific event loop options ([#1952](https://github.com/emilk/egui/pull/1952)).
|
||||||
* Enabled deferred render state initialization to support Android ([#1952](https://github.com/emilk/egui/pull/1952)).
|
* Enabled deferred render state initialization to support Android ([#1952](https://github.com/emilk/egui/pull/1952)).
|
||||||
* Allow empty textures with the glow renderer.
|
* Allow empty textures with the glow renderer.
|
||||||
|
|
|
@ -223,6 +223,13 @@ pub struct NativeOptions {
|
||||||
/// Default: `false`.
|
/// Default: `false`.
|
||||||
pub fullscreen: bool,
|
pub fullscreen: bool,
|
||||||
|
|
||||||
|
/// On Mac: the window doesn't have a titlebar, but floating window buttons.
|
||||||
|
///
|
||||||
|
/// See [winit's documentation][with_fullsize_content_view] for information on Mac-specific options.
|
||||||
|
///
|
||||||
|
/// [with_fullsize_content_view]: https://docs.rs/winit/latest/x86_64-apple-darwin/winit/platform/macos/trait.WindowBuilderExtMacOS.html#tymethod.with_fullsize_content_view
|
||||||
|
pub fullsize_content: bool,
|
||||||
|
|
||||||
/// On Windows: enable drag and drop support. Drag and drop can
|
/// On Windows: enable drag and drop support. Drag and drop can
|
||||||
/// not be disabled on other platforms.
|
/// not be disabled on other platforms.
|
||||||
///
|
///
|
||||||
|
@ -361,6 +368,7 @@ impl Default for NativeOptions {
|
||||||
maximized: false,
|
maximized: false,
|
||||||
decorated: true,
|
decorated: true,
|
||||||
fullscreen: false,
|
fullscreen: false,
|
||||||
|
fullsize_content: false,
|
||||||
drag_and_drop_support: true,
|
drag_and_drop_support: true,
|
||||||
icon_data: None,
|
icon_data: None,
|
||||||
initial_window_pos: None,
|
initial_window_pos: None,
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
use winit::event_loop::EventLoopWindowTarget;
|
use winit::event_loop::EventLoopWindowTarget;
|
||||||
|
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
|
use winit::platform::macos::WindowBuilderExtMacOS as _;
|
||||||
|
|
||||||
use egui_winit::{native_pixels_per_point, EventResponse, WindowSettings};
|
use egui_winit::{native_pixels_per_point, EventResponse, WindowSettings};
|
||||||
|
|
||||||
use crate::{epi, Theme, WindowInfo};
|
use crate::{epi, Theme, WindowInfo};
|
||||||
|
@ -41,6 +44,8 @@ pub fn window_builder(
|
||||||
maximized,
|
maximized,
|
||||||
decorated,
|
decorated,
|
||||||
fullscreen,
|
fullscreen,
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
|
fullsize_content,
|
||||||
drag_and_drop_support,
|
drag_and_drop_support,
|
||||||
icon_data,
|
icon_data,
|
||||||
initial_window_pos,
|
initial_window_pos,
|
||||||
|
@ -63,6 +68,14 @@ pub fn window_builder(
|
||||||
.with_transparent(*transparent)
|
.with_transparent(*transparent)
|
||||||
.with_window_icon(window_icon);
|
.with_window_icon(window_icon);
|
||||||
|
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
|
if *fullsize_content {
|
||||||
|
window_builder = window_builder
|
||||||
|
.with_title_hidden(true)
|
||||||
|
.with_titlebar_transparent(true)
|
||||||
|
.with_fullsize_content_view(true);
|
||||||
|
}
|
||||||
|
|
||||||
if let Some(min_size) = *min_window_size {
|
if let Some(min_size) = *min_window_size {
|
||||||
window_builder = window_builder.with_min_inner_size(points_to_size(min_size));
|
window_builder = window_builder.with_min_inner_size(points_to_size(min_size));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue