Skip to content

Add Panel to replace SidePanel and TopBottomPanel#5659

Merged
emilk merged 30 commits intoemilk:mainfrom
sharky98:common-panels
Nov 18, 2025
Merged

Add Panel to replace SidePanel and TopBottomPanel#5659
emilk merged 30 commits intoemilk:mainfrom
sharky98:common-panels

Conversation

@sharky98
Copy link
Copy Markdown
Contributor

@sharky98 sharky98 commented Jan 30, 2025

This combines SidePanel and TopBottomPanel into a single Panel.

The old types are still there as type aliases, but are deprecated.

.min_width(…) etc are now called .min_size(…) etc.

Again, the old names are still there, but deprecated.

(edited by @emilk)

Merged the sides.
Merged the panel options.

Started panel shows
…move TopBottomSide

NOTE: Non-working commit
following those steps:
1. Rename `egui::SidePanel` with `egui::Panel`.
2. Rename `width` with `size` in all chained methods.
    - `default_width()` to `default_size()`
    - `min_width()` to `min_size()`
    - `max_width()` to `max_size()`
    - `width_range()` to `size_range()`
    - `exact_width()` to `exact_size()`

if using `Panel::new()`, replace
- `Side::Left` with `Side::Vertical(VerticalSide::Left)`
- `Side::Right` with `Side::Vertical(VerticalSide::Right)`

NOTE: Non-working commit
…pBottomPanel when both SidePanel and TopBottomPanel were mentioned.

following those steps:
1. Rename `egui::TopBottomPanel` with `egui::Panel`.
2. Rename `height` with `size` in all chained methods.
    - `default_height()` to `default_size()`
    - `min_height()` to `min_size()`
    - `max_height()` to `max_size()`
    - `height_range()` to `size_range()`
    - `exact_height()` to `exact_size()`

if using `Panel::new()`, replace
- `TopBottomSide::Top` with `Side::Horizontal(HorizontalSide::Top)`
- `TopBottomSide::Bottom` with `Side::Horizontal(HorizontalSide::Bottom)`

NOTE: Non-working commit
- replace switch fn with closures in some places.
- integrate the switch fn inside the main switch.
- make sure lifetime are defined for PanelSizer.
- remove some `mut`, `&`, and `*` where they superfluous.
- wrongly called `ctx()` when it was a variable 🤦.
- cannot use `impl Trait` in a variable declaration type.
@sharky98
Copy link
Copy Markdown
Contributor Author

Locally, all the tests passed (except those regarding git lfs and some images that the delta has nothing to do with my change (more or less text, etc.). The panel demo in egui_demo_app works as before. I did not saw anything different.

@sharky98 sharky98 marked this pull request as ready for review February 11, 2025 15:21
Copy link
Copy Markdown
Collaborator

@lucasmerlin lucasmerlin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, I think this makes sense. Also, having one struct is definitely the better approch (instead of introducing a trait, as you suggested in your issue)

@github-actions
Copy link
Copy Markdown

github-actions bot commented Feb 18, 2025

Preview available at https://egui-pr-preview.github.io/pr/5659-common-panels
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

Copy link
Copy Markdown
Owner

@emilk emilk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! Let's remove the .unwrap()s, add #[deprecated aliases for backwards compatibility/migration, and then test thoroughly :)

@emilk emilk marked this pull request as draft April 22, 2025 09:55
@emilk emilk changed the title Common panels Add Panel to replace SidePanel and TopBottomPanel Nov 16, 2025
@emilk emilk added the egui label Nov 16, 2025
@emilk emilk requested a review from lucasmerlin November 16, 2025 23:43
@emilk emilk marked this pull request as ready for review November 16, 2025 23:44
@emilk emilk merged commit 5b6a019 into emilk:main Nov 18, 2025
25 of 26 checks passed
Masterchef365 pushed a commit to Masterchef365/egui that referenced this pull request Apr 3, 2026
This combines `SidePanel` and `TopBottomPanel` into a single `Panel`.

The old types are still there as type aliases, but are deprecated.

`.min_width(…)` etc are now called `.min_size(…)` etc.

Again, the old names are still there, but deprecated.

(edited by @emilk)

---------

Co-authored-by: Emil Ernerfeldt <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants