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

Grid layout for windows #4550

Closed
andreamancuso opened this issue May 27, 2024 · 3 comments
Closed

Grid layout for windows #4550

andreamancuso opened this issue May 27, 2024 · 3 comments

Comments

@andreamancuso
Copy link

I am not 100% convinced this currently achievable in egui: https://github.com/react-grid-layout/react-grid-layout

If it is, could you please point me to a demo/example code?

If not, are there plans to build something along these lines?

I am aware of https://github.com/Adanos020/egui_dock https://github.com/rerun-io/egui_tiles and rerun-io/egui_tiles#30 but they don't quite seem to support the react-grid-layout use case(s)

Thanks!

@YgorSouza
Copy link
Contributor

I have a feeling this would fall under the non-goals:

Advanced and flexible layouts (that's fundamentally incompatible with immediate mode)

But I'm not sure. In any case, egui_dock and egui_tiles are indeed the closest we have to that at the moment.

@andreamancuso
Copy link
Author

Thanks for confirming!

I see the official egui online demo includes a button for reorganising the currently open windows so they are redistributed evenly across the available space. Are there other "strategies" documented anywhere?

@YgorSouza
Copy link
Contributor

The code run when you click on this button is this:

if ui.button("Organize windows").clicked() {
ui.ctx().memory_mut(|mem| mem.reset_areas());
}

/// Forget window positions, sizes etc.
/// Can be used to auto-layout windows.
pub fn reset_areas(&mut self) {
for area in self.areas.values_mut() {
*area = Default::default();
}
}

So it just forgets the previous data about all the windows, and because they already look for empty space when determining their initial position, this has the effect of "organizing" them.

Actually, there is also egui_dnd which allows you to reorder list items by dragging them, and includes some animations as they move to their new positions. It's still not the same as a flexible layout, though. I don't know if there is anything that gets closer, but you can look in https://github.com/emilk/egui/wiki/3rd-party-egui-crates

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants