Detachable free-floating panes in `PaneGrid`

Hello,

I’d like to know what would be the most idiomatic approach to implement something like a multi document interface in iced.

Something like this:
image

The closest examples I can find are toast and pane_grid.

The toast example looks almost exactly how I want it. I need to have main app stuff in the background with several tool windows freely floating on top. Unfortunately, toast does not support dragging the toasts around.

The pane_grid example allows dragging panes but only for reordering.

So I am wondering, can I mix the two somehow? I’m not sure how to approach it and where to handle drag events.

Ok, I’ve reworked my UI using PaneGrid.

Everything looks nice so far

However, it would be super convenient, if we’d have a command that would allow the user to detach a pane from the grid and convert it to a free-floating one. Something like this:

For example, it would be possible to operate with the map on a maximized pane while still being able to use some selected panes.

I’ve skimmed through the PaneGrid implementation and my thoughts are the following:

  1. We can alter pane_grid::State to handle detached panes independently by adding a new field, something like detached: Vec<(Pane, Point, Size)>.

  2. When a pane gets detached it’s removed from the internal layout, but remains in panes.

  3. When in detached mode, a pane can be resized and dragged around within a grid boundaries, but it would not respond to drop events. It’s just an overlay sitting on top of everything else.

  4. When attached back, a pane can either be put into the grid by splitting existing one, or just start responding to edge and drop events, to be inserted into the grid the next time the pane is dragged & dropped.

@hecrj, so my questions are:

  1. Are there any immediately obvious limitations of such a design?

  2. How and where to handle an overlay layout? Currently, when a pane gets dragged it just uses its in-grid layout. But when detached it would no longer have one. So we should handle size and position independently. Initially I thought it would be easy to inherit existing layout during detach, but the detach logic should be part of pane_grid::State whereas layout info is in PaneGrid and accessible only during redraw.