emilk / egui

egui: an easy-to-use immediate mode GUI in Rust that runs on both web and native
https://www.egui.rs/
Apache License 2.0
21.94k stars 1.58k forks source link

Horizontal and vertical splitter #944

Open feelingnothing opened 2 years ago

feelingnothing commented 2 years ago

Splits frame in half with access to each frame by two lambdas for each half

Is your feature request related to a problem? Please describe.

Not being able to place elements in one line with different directions

Describe the solution you'd like

Horizontal and vertical splitter that splits frame in half

Describe alternatives you've considered

-

Additional context

Couldn't think of a way to split by n times with access to different frames at once, there is a way to make a different function for each n way split, but it would be messy for sure

emilk commented 2 years ago

This should be relatively easy to implement if anyone wants to take a stab at it. An interface like this should work pretty well:

egui::VerticalSplitter::new().show(ui, |left_ui, right_ui| {
    …
});
LordMZTE commented 2 years ago

Wouldn't it be nicer to have the same struct do both vertical and horizontal splitting, so egui::Splitter::horizontal() or egui::Splitter::vertical()? Once we get the API down, I'd definetely like to have a go at implementing it :smile:

emilk commented 2 years ago

Just a note: I think the split position should be stored in fraction (e.g. 40%) so when resizing the outer container, the splitter stays at the same relative position.

Timmmm commented 1 year ago

This would be nice. A few things to consider:

mkalte666 commented 10 months ago

I see the issues with this (i dearly hope i wont need multiple splits x.x), but if anyone just needs a quick and dirty two pane splitter, until this ends up in egui in a proper and nicely done way, you can use this in your project

https://gist.github.com/mkalte666/f9a982be0ac0276080d3434ab9ea4655

Giving this out as public domain, CC0, no warranty, etc etc. Just hoping this will be useful to someone.

ilyas-taouaou commented 7 months ago

what's the status of this?