Skip to content

Commit

Permalink
macOS ViewportBuilder tweaks (#3613)
Browse files Browse the repository at this point in the history
  • Loading branch information
emilk authored Nov 23, 2023
1 parent 85489dc commit a2b15b2
Show file tree
Hide file tree
Showing 6 changed files with 145 additions and 88 deletions.
3 changes: 3 additions & 0 deletions crates/eframe/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ NOTE: [`egui-winit`](../egui-winit/CHANGELOG.md), [`egui_glium`](../egui_glium/C
This file is updated upon each release.
Changes since the last release can be found by running the `scripts/generate_changelog.py` script.

## Unreleased
* `NativeOptions::fullsize_content` has been replaced with four settings: `ViewportBuilder::with_fullsize_content_view`, `with_title_shown`, `with_titlebar_shown`, `with_titlebar_buttons_shown`

## 0.23.0 - 2023-09-27
* Update MSRV to Rust 1.70.0 [#3310](https://github.com/emilk/egui/pull/3310)
* Update to puffin 0.16 [#3144](https://github.com/emilk/egui/pull/3144)
Expand Down
4 changes: 2 additions & 2 deletions crates/eframe/src/native/glow_integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1224,13 +1224,13 @@ fn initialize_or_update_viewport<'vp>(
viewport.class = class;
viewport.viewport_ui_cb = viewport_ui_cb;

let (delta_commands, recreate) = viewport.builder.patch(&builder);
let (delta_commands, recreate) = viewport.builder.patch(builder);

if recreate {
log::debug!(
"Recreating window for viewport {:?} ({:?})",
ids.this,
builder.title
viewport.builder.title
);
viewport.window = None;
viewport.egui_winit = None;
Expand Down
4 changes: 2 additions & 2 deletions crates/eframe/src/native/wgpu_integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1037,13 +1037,13 @@ fn initialize_or_update_viewport<'vp>(
viewport.ids.parent = ids.parent;
viewport.viewport_ui_cb = viewport_ui_cb;

let (delta_commands, recreate) = viewport.builder.patch(&builder);
let (delta_commands, recreate) = viewport.builder.patch(builder);

if recreate {
log::debug!(
"Recreating window for viewport {:?} ({:?})",
ids.this,
builder.title
viewport.builder.title
);
viewport.window = None;
viewport.egui_winit = None;
Expand Down
20 changes: 13 additions & 7 deletions crates/egui-winit/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1292,13 +1292,18 @@ pub fn create_winit_window_builder<T>(
maximize_button,
window_level,

// only handled on some platforms:
title_hidden: _title_hidden,
titlebar_transparent: _titlebar_transparent,
// macOS:
fullsize_content_view: _fullsize_content_view,
app_id: _app_id,
title_shown: _title_shown,
titlebar_buttons_shown: _titlebar_buttons_shown,
titlebar_shown: _titlebar_shown,

// Windows:
drag_and_drop: _drag_and_drop,

// wayland:
app_id: _app_id,

mouse_passthrough: _, // handled in `apply_viewport_builder_to_new_window`
} = viewport_builder;

Expand All @@ -1309,7 +1314,7 @@ pub fn create_winit_window_builder<T>(
.with_resizable(resizable.unwrap_or(true))
.with_visible(visible.unwrap_or(true))
.with_maximized(maximized.unwrap_or(false))
.with_window_level(match window_level {
.with_window_level(match window_level.unwrap_or_default() {
egui::viewport::WindowLevel::AlwaysOnBottom => WindowLevel::AlwaysOnBottom,
egui::viewport::WindowLevel::AlwaysOnTop => WindowLevel::AlwaysOnTop,
egui::viewport::WindowLevel::Normal => WindowLevel::Normal,
Expand Down Expand Up @@ -1383,8 +1388,9 @@ pub fn create_winit_window_builder<T>(
{
use winit::platform::macos::WindowBuilderExtMacOS as _;
window_builder = window_builder
.with_title_hidden(_title_hidden.unwrap_or(false))
.with_titlebar_transparent(_titlebar_transparent.unwrap_or(false))
.with_title_hidden(!_title_shown.unwrap_or(true))
.with_titlebar_buttons_hidden(!_titlebar_buttons_shown.unwrap_or(true))
.with_titlebar_transparent(!_titlebar_shown.unwrap_or(true))
.with_fullsize_content_view(_fullsize_content_view.unwrap_or(false));
}

Expand Down
Loading

0 comments on commit a2b15b2

Please sign in to comment.