Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eframe MacOS: Support fullsize content (no titlebar, but window controls) #2049

Merged
merged 5 commits into from
Sep 16, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions crates/eframe/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
emilk marked this conversation as resolved.
Show resolved Hide resolved
* 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.
Expand Down
8 changes: 8 additions & 0 deletions crates/eframe/src/epi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
emilk marked this conversation as resolved.
Show resolved Hide resolved
pub fullsize_content: bool,

/// On Windows: enable drag and drop support. Drag and drop can
/// not be disabled on other platforms.
///
Expand Down Expand Up @@ -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,
Expand Down
13 changes: 13 additions & 0 deletions crates/eframe/src/native/epi_integration.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
use winit::event_loop::EventLoopWindowTarget;

#[cfg(target_os = "macos")]
use winit::platform::macos::WindowBuilderExtMacOS;
emilk marked this conversation as resolved.
Show resolved Hide resolved

use egui_winit::{native_pixels_per_point, EventResponse, WindowSettings};

use crate::{epi, Theme, WindowInfo};
Expand Down Expand Up @@ -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,
Expand All @@ -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));
}
Expand Down