Moving elements inside parents wrong

The elements that are moved after added to the parent are moving relatively to the SW corner of the parent, when at the moment they are added they are positioned relatively to the NW corner using their initial position.
This fails using “setPosition” methods and also “moveTo” method of a child element.

You move it wrong then. Probably like getLocalTranslation().set() which… is wrong :slight_smile: Use setLocalTranslation(getLocalTranslation.set()) if you don’t have your own temp variable.

Well, I’m using the default Element::setPosition(float x, float y) method. The problem is that AFTER the element is attached to any parent element then this method (and also moveTo method) moves the element relatively to parent SW corner instead of NW corner.

To explain it more deeply:

  1. I create a “child” Element with a position (for example 20, 20)
  2. I use the “parent” Element addChild method to add the child to it.
    At this point everything is ok - the “child” is displayed 20 pixels from the NW corner of the “parent”
  3. Then i call child.setPosition(20, 20) or child.moveTo(20,20).
    And there is a problem because the element is now 20 pixels from the SW corner.

Ah, didn’t realize its specific to tonegodui, sorry.

This a known issue, but unfortunatly chris is indisposed for now.

Basically, node position works from the SW corner…and chris has only invert the position in the addChild method…so it will work from NW corner in the constructor (and by extension in the addChild method) but not in the setposition method…where there is no inversion and where node works as usual from SW corner.

[java]public void addChild(Element child) {
child.elementParent = this;

            if (!child.getInitialized()) {
                   <strong> child.setY(this.getHeight()-child.getHeight()-child.getY())</strong>;[/java]

setPosition call this method to update the node position:
[java]private void updateNodeLocation() {
this.setLocalTranslation(position.x, position.y, this.getLocalTranslation().getZ());

Wait until chris either back, i believe your request is already in the gui issue list. For now just remember constructor => NW…setPosition => SW.