From 13bdbe5ef751a1e250cbe73296a48e3915b26812 Mon Sep 17 00:00:00 2001 From: Paul Rouget Date: Fri, 16 Sep 2022 10:41:56 +0800 Subject: [PATCH 1/5] MacOS: Support fullsize content --- crates/eframe/CHANGELOG.md | 1 + crates/eframe/src/epi.rs | 8 ++++++++ crates/eframe/src/native/epi_integration.rs | 13 +++++++++++++ 3 files changed, 22 insertions(+) diff --git a/crates/eframe/CHANGELOG.md b/crates/eframe/CHANGELOG.md index 835a0656702..28f51048f50 100644 --- a/crates/eframe/CHANGELOG.md +++ b/crates/eframe/CHANGELOG.md @@ -5,6 +5,7 @@ NOTE: [`egui-winit`](../egui-winit/CHANGELOG.md), [`egui_glium`](../egui_glium/C ## Unreleased +* Added `NativeOptions::fullsize_content` option on Mac to build titlebar-less windows with floating window controls. * 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)). * Allow empty textures with the glow renderer. diff --git a/crates/eframe/src/epi.rs b/crates/eframe/src/epi.rs index 62aece053c7..0c3d8228adc 100644 --- a/crates/eframe/src/epi.rs +++ b/crates/eframe/src/epi.rs @@ -223,6 +223,13 @@ pub struct NativeOptions { /// Default: `false`. 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 /// not be disabled on other platforms. /// @@ -361,6 +368,7 @@ impl Default for NativeOptions { maximized: false, decorated: true, fullscreen: false, + fullsize_content: false, drag_and_drop_support: true, icon_data: None, initial_window_pos: None, diff --git a/crates/eframe/src/native/epi_integration.rs b/crates/eframe/src/native/epi_integration.rs index d0f4ea91b10..017b2b8e422 100644 --- a/crates/eframe/src/native/epi_integration.rs +++ b/crates/eframe/src/native/epi_integration.rs @@ -1,5 +1,8 @@ use winit::event_loop::EventLoopWindowTarget; +#[cfg(target_os = "macos")] +use winit::platform::macos::WindowBuilderExtMacOS; + use egui_winit::{native_pixels_per_point, EventResponse, WindowSettings}; use crate::{epi, Theme, WindowInfo}; @@ -41,6 +44,8 @@ pub fn window_builder( maximized, decorated, fullscreen, + #[cfg(target_os = "macos")] + fullsize_content, drag_and_drop_support, icon_data, initial_window_pos, @@ -63,6 +68,14 @@ pub fn window_builder( .with_transparent(*transparent) .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 { window_builder = window_builder.with_min_inner_size(points_to_size(min_size)); } From 233960c7d63ec87c8801699b341c3514a2b3261d Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Fri, 16 Sep 2022 13:22:29 +0200 Subject: [PATCH 2/5] use a direct doclink --- crates/eframe/src/epi.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/crates/eframe/src/epi.rs b/crates/eframe/src/epi.rs index 0c3d8228adc..f0503b28617 100644 --- a/crates/eframe/src/epi.rs +++ b/crates/eframe/src/epi.rs @@ -225,9 +225,7 @@ pub struct NativeOptions { /// 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 + /// See [`winit::platform::macos::WindowBuilderExtMacOS`] for more information about Mac-specific options. pub fullsize_content: bool, /// On Windows: enable drag and drop support. Drag and drop can From 8d7e3961e4c57f4609425a2b89967b2e5854e5c7 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Fri, 16 Sep 2022 13:22:37 +0200 Subject: [PATCH 3/5] import trait as _ --- crates/eframe/src/native/epi_integration.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/eframe/src/native/epi_integration.rs b/crates/eframe/src/native/epi_integration.rs index 017b2b8e422..dc6c596484d 100644 --- a/crates/eframe/src/native/epi_integration.rs +++ b/crates/eframe/src/native/epi_integration.rs @@ -1,7 +1,7 @@ use winit::event_loop::EventLoopWindowTarget; #[cfg(target_os = "macos")] -use winit::platform::macos::WindowBuilderExtMacOS; +use winit::platform::macos::WindowBuilderExtMacOS as _; use egui_winit::{native_pixels_per_point, EventResponse, WindowSettings}; From fa752d868ef6f004f032c8d32d6a7351012ccae1 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Fri, 16 Sep 2022 14:17:06 +0200 Subject: [PATCH 4/5] Revert "use a direct doclink" This reverts commit 233960c7d63ec87c8801699b341c3514a2b3261d. --- crates/eframe/src/epi.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/eframe/src/epi.rs b/crates/eframe/src/epi.rs index f0503b28617..0c3d8228adc 100644 --- a/crates/eframe/src/epi.rs +++ b/crates/eframe/src/epi.rs @@ -225,7 +225,9 @@ pub struct NativeOptions { /// On Mac: the window doesn't have a titlebar, but floating window buttons. /// - /// See [`winit::platform::macos::WindowBuilderExtMacOS`] for more information about Mac-specific options. + /// 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 From 4df7cb5e97933f20264476b0e5f2d424bdfb1e62 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Fri, 16 Sep 2022 14:30:55 +0200 Subject: [PATCH 5/5] Add link to PR in the changelog --- crates/eframe/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/eframe/CHANGELOG.md b/crates/eframe/CHANGELOG.md index 28f51048f50..a552dcab60e 100644 --- a/crates/eframe/CHANGELOG.md +++ b/crates/eframe/CHANGELOG.md @@ -5,7 +5,7 @@ NOTE: [`egui-winit`](../egui-winit/CHANGELOG.md), [`egui_glium`](../egui_glium/C ## Unreleased -* Added `NativeOptions::fullsize_content` option on Mac to build titlebar-less windows with floating window controls. +* 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)). * Enabled deferred render state initialization to support Android ([#1952](https://github.com/emilk/egui/pull/1952)). * Allow empty textures with the glow renderer.