egui icon indicating copy to clipboard operation
egui copied to clipboard

Horizontal and vertical splitter

Open feelingnothing opened this issue 3 years ago • 4 comments

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

feelingnothing avatar Dec 10 '21 07:12 feelingnothing

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| {
    …
});

emilk avatar Dec 28 '21 16:12 emilk

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:

LordMZTE avatar Dec 31 '21 15:12 LordMZTE

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.

emilk avatar Apr 16 '22 19:04 emilk

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.

Timmmm avatar Jan 07 '23 22:01 Timmmm

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.

mkalte666 avatar Nov 14 '23 09:11 mkalte666

what's the status of this?

ilyas-taouaou avatar Feb 19 '24 23:02 ilyas-taouaou