Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Howto move/resize parent figure when child is moved
Howto move/resize parent figure when child is moved [message #653004] Mon, 07 February 2011 22:29 Go to next message
Bryan Mising name is currently offline Bryan Mising nameFriend
Messages: 3
Registered: February 2011
Junior Member
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?

Example: http://imgur.com/a/70JHW#2wO4h

Re: Howto move/resize parent figure when child is moved [message #654681 is a reply to message #653004] Wed, 16 February 2011 16:24 Go to previous message
Bryan Mising name is currently offline Bryan Mising nameFriend
Messages: 3
Registered: February 2011
Junior Member
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.
Previous Topic:Performance issue on redundant painting of fully covered figures
Next Topic:Search field in Draw2d/GEF
Goto Forum:
  


Current Time: Thu Apr 18 23:13:17 GMT 2024

Powered by FUDForum. Page generated in 0.02033 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top