I'm working on a graph with parent sub-graphs containing children. The parent sub-graph has a Figure with a StackLayout containing a FreeformViewport with a FreeformLayer, just like the Circuit in the Logic diagram example.
I have overridden the DragTracker returned by AbstractGraphicalEditPart#getDragTracker(Request) to always return true for DragEditPartsTracker#isMove() to disable support for orphaning (I'm open to a better way if there is one.)
When I move a child beyond the visible top-left corner of the parent, it disappears from view and I have to scroll the FreeformViewport to see the child again. Instead, I would like the parent to expand so that all the children are always visible and I never have to scroll the viewport. Is there a way to do this?
Was able to get this to work. It took a while to figure it out, but here's what I did:
Stopped using Freeform viewport for the sub-graph figures. The sub-graph figure will fit the bounds of its children so it doesn't need to scroll.
Extended the XYLayout used for containers that may contain a sub-graph and did the following:
Delegate the retrieval of the constraint to the sub-graph figure. The sub-graph figure returns a rectangle that fits the bounds of its children in its parent's coordinates.
Delegate the setting of constraints to the sub-graph figure so that it can update the constraints of its children when the sub-graph is moved.
Overrode layout() to invalidate and validate the children of a sub-graph before performing the layout. This ensures that the sub-graph will have up-to-date information when calculating its bounds.
Overrode primTranslate(dx,dy) to only change the location of the sub-graph's bounds. This way the children aren't moved when the sub-graph's bounds are changed to fit its contents. This couples the layout with the sub-graph figure, which I'm not too fond of; I'm not sure if there's another way.
My solution isn't perfect but is reasonably clean.