Skip to content

Atom support for egui::Window Titlebar#8154

Merged
lucasmerlin merged 21 commits into
mainfrom
lucas/window-title-atom
May 13, 2026
Merged

Atom support for egui::Window Titlebar#8154
lucasmerlin merged 21 commits into
mainfrom
lucas/window-title-atom

Conversation

@lucasmerlin
Copy link
Copy Markdown
Collaborator

@lucasmerlin lucasmerlin commented May 12, 2026

The resize fix allows use to really simplify how the Window Titlebar is rendered. Previously it was using some complex flow to calculate and allocate the height first and then render it later once we knew the windows final width.

Since now windows can't shrink past their minimum content widths, I can just show the titlebar inline with the regular content, just outside of the Resize container so that it is always visible.

This does change what the size of a window means. Before, size was just the size of the contents, while now size (e.g. via min_height) will include the Frames margin and outline, title bar and the contents.
Also, the window label now truncates as you shrink the window (meaning windows can now be smaller than their label allows).

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 12, 2026

Preview available at https://egui-pr-preview.github.io/pr/8154-lucaswindow-title-atom
Note that it might take a couple seconds for the update to show up after the preview_build workflow has completed.

View snapshot changes at kitdiff

@lucasmerlin lucasmerlin changed the base branch from main to lucas/min-resize-fix May 12, 2026 09:46
@lucasmerlin lucasmerlin marked this pull request as ready for review May 12, 2026 11:09
@lucasmerlin lucasmerlin marked this pull request as draft May 12, 2026 11:12
@lucasmerlin
Copy link
Copy Markdown
Collaborator Author

Clarify what size now means (does it include the frame / margins?).

Base automatically changed from lucas/min-resize-fix to main May 12, 2026 11:57
# Conflicts:
#	crates/egui/src/containers/resize.rs
#	crates/egui_kittest/tests/regression_tests.rs
@lucasmerlin lucasmerlin marked this pull request as ready for review May 12, 2026 12:29
@lucasmerlin lucasmerlin marked this pull request as draft May 12, 2026 12:29
@lucasmerlin lucasmerlin marked this pull request as draft May 12, 2026 12:29
@lucasmerlin lucasmerlin added feature New feature or request egui labels May 12, 2026
lucasmerlin and others added 6 commits May 13, 2026 09:37
- Reorder `use super::{...}` to satisfy rustfmt.
- Allow `clippy::too_many_arguments` / `clippy::fn_params_excessive_bools`
  on `title_ui` (already over the threshold).
- Pass `&child_ui` instead of `&mut child_ui` to `CollapsingState::toggle`.
The `IntoAtoms` upgrade lives on `lucas/small-button-atom` and will be
PR'd separately. Drop it here so the two PRs don't overlap.
@lucasmerlin lucasmerlin marked this pull request as ready for review May 13, 2026 09:34
Comment thread crates/egui_kittest/tests/regression_tests.rs
Comment thread crates/egui/src/containers/window.rs Outdated
Comment thread crates/egui_demo_lib/tests/snapshots/demos/Screenshot.png
Comment thread crates/egui_demo_lib/tests/snapshots/demos/Scrolling.png
@lucasmerlin
Copy link
Copy Markdown
Collaborator Author

outer margins too?

Yeah. I could make it exclude outer margins, but it makes the positioning code a bit more complex and I think it's generally weird to have an outer margin on windows? So I decided to keep it like this. (But I've updated the test to check outer margin behavior).

@lucasmerlin lucasmerlin requested a review from emilk May 13, 2026 11:52
@emilk
Copy link
Copy Markdown
Owner

emilk commented May 13, 2026

The vertical spacing has changed in a lot of the screenshots 🤔 Seems like the title bar has grown or shrunk by a fraction of a pixel. I wonder why 🤔

For instance: check the Grid Test.png

Not necessarily worse; just different 🤷

@lucasmerlin
Copy link
Copy Markdown
Collaborator Author

lucasmerlin commented May 13, 2026

Ah the cursor isn't pixel aligned:

[crates/egui/src/containers/window.rs:580:33] ui.cursor() = [[672.0 104.7] - [995.8 inf]]

I'll try to find the root of this or add some rounding

Edit: Ah I think this is fine actually, at least we do call gui_round on the allocated rect, so I think it's fine?

@lucasmerlin lucasmerlin merged commit e204717 into main May 13, 2026
46 checks passed
@lucasmerlin lucasmerlin deleted the lucas/window-title-atom branch May 13, 2026 13:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

egui feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants