egui
egui copied to clipboard
Horizontal and vertical splitter
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
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| {
…
});
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:
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.
This would be nice. A few things to consider:
- Sometimes you don't want them to scale proportionally (e.g. think about resizing a Blender window) so it should be configurable.
- If you want three panes and your UI library only supports two pane splitters, you have to nest them. But this often leads to weird behaviour. It would be good if it supported an arbitrary number of panes.
- If you want four panes (two up two down) then again you might be forced to have a horizontal splitter with a vertical splitter in each of its panes. But this doesn't give you a four-way splitter because a) the two vertical splitters can get out of sync, and b) normally you can click and drag the middle point where the splitters cross and it will move both splitters at once.
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.
what's the status of this?