Programmatic Node movement including children?

46 views
Skip to first unread message

jles...@gmx.de

unread,
Apr 22, 2014, 7:13:14 AM4/22/14
to piccolo...@googlegroups.com
Hello Piccolos
I've got a question about moving Nodes around. When I do that interactively e.g. by dragging a node, Piccolo takes care about moving all the node's children respectively. However, if I move a Node programmatically by calling setX(), setY(), or setBounds(), the child nodes keep their positions unchanged. So currently I always add some code which adapts the childrens' positions as well.
But before I spread this pattern all over a more sophisticated application's code, I'd rather like to ask if there is already something around which applies a node movement recursively to all its children. I couldn't find any corresponding example or a method with a name which implies that kind of functionality.

Regards,
Jan

Lalit Pant

unread,
Apr 22, 2014, 10:18:00 PM4/22/14
to piccolo...@googlegroups.com
You can try setOffset(x, y) or translate(dx, dy). That affects the node's transform, so all child nodes will be similarly affected.

Cheers,
- Lalit

Michael Heuer

unread,
Apr 22, 2014, 10:41:46 PM4/22/14
to piccolo...@googlegroups.com
Good advice, Lalit.

This doc here explains some of the more non-obvious aspects of the
Piccolo2D library design

http://piccolo2d.org/learn/patterns.html

Pattern 9: Full Terminology and Pattern 10: Coordinate Systems in particular.

michael
> --
> You received this message because you are subscribed to the Google Groups
> "Piccolo2D Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to piccolo2d-use...@googlegroups.com.
> To post to this group, send email to piccolo...@googlegroups.com.
> Visit this group at http://groups.google.com/group/piccolo2d-users.
> For more options, visit https://groups.google.com/d/optout.

Mustafa Shujaie

unread,
Nov 19, 2014, 2:16:42 AM11/19/14
to piccolo...@googlegroups.com

I have a hierarchy of nodes in which I have to inform the children that their parent's bounds are changed so they have to update their bounds relative to their parents. While reading the setbounds source code I realized that there is a method named parentBoundsChanged which you can override so that the children nodes become aware of this change and can update their bounds to new position. I thought this may be helpful for you.

Reply all
Reply to author
Forward
0 new messages