-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[Feature] Enhance PaneGrid to split panes by drag & drop #1856
Conversation
This is great! Love the simple implementation. Stretch goal or follow-up: It'd be super cool if we could also drop on the "splits" between nodes to place the source pane between the two target nodes on either side of the split. I think that'd round out this pane grid implementation very nicely! Open question for behavior when dropping on a split: How do the nodes get resized to "distribute" across the one source and 2 target nodes? I'd assume they keep the same ratio of their current width / total width of all 3 nodes * available width. |
Thanks! 🙌
That's interesting. I've tried to find some good examples that implement something like that, so I could have a better understanding on how that would "feel", but didn't find any. Usually apps just allow the user to place a pane either on the left side of a pane (if on the right side of the split) or vice-versa. Check out VS Code or https://golden-layout.com/ for example. This way also avoids having to figure out how to handle the ratio of their width/height and leave that entirely to the user. Do you know any example that does that? |
I do not. I just had the thought when watching your video. In the 2x2 grid, it seemed like it'd be nice to drag to the top right pane over the bottom middle split and end up with 3 evenly distributed panes on the bottom. However now that I'm thinking about this more, I don't think it'd always work that intuitively for 2 reasons:
So it's hard to say how useful this would actually be in practice without implementation or another example to reference. |
Exactly, that might introduce a lot of complexity or weird behaviour to the user itself. Anyway, I think this can be enhanced even more by being able to drag & drop at the edges of the whole grid in order to create a new row at top/bottom or new column at left/right side of the grid with the dragged pane. Gonna add that here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks fantastic! Just an idea!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fantastic! 🎉
Thanks 🙇
Summary
Previously, dropping a pane onto another would just swap them. This leads users of
PaneGrid
needing to manually create splits first and then swap panes (and most probably closing unnecessary ones) in order to change the layout of the grid.This change adds functionality to
PaneGrid
in order to be able to split a pane with another by simply dragging and dropping the pane in a certain region of the target pane.Implementation
Introduced
Region
parameter topane_grid::DragEvent::Dropped
that is the target pane area (top, left, bottom, right, center) where the dragged pane is hovering on. Panes were divided in thirds. Left and right sides have priority over top and bottom.Users of
PaneGrid
can callpane_grid::State::split_with(target, pane, region)
in order to split the target with a given pane on a given region of the target.The
Region
of the hovered target dropping area is highlighted with a givenstyle
in order for users to easily see how the panes will be displayed.Demo
pane_grid.mov