[libgdx] Drag and drop with scene2d tree

I’m working an an editor for our game. A main component of the editor is a tree, that displays nodes.

The editor must be able to reorder nodes in the tree or move entire branches onto a different parent node. To do this I see two possibilities:

  1. Implement it with drag and drop, so the user can just drag a node and move it to the appropriate position.
  2. Add up/down buttons to the nodes for reordering and add a new button to change the parent of a selected node.

While I would want to do it with drag and drop, I don’t want to spend too much time on this (we need to concentrate on the game itself, this would simply be a nice to have). Does the scene2d tree actor support drag or can someone point me into the direction on how to do it, so I can see if it is too much effort to do?

I have seen that LibGDX has a DragAndDrop class. From what I see in the DragAndDrop test ( https://github.com/libgdx/libgdx/blob/master/tests/gdx-tests/src/com/badlogic/gdx/tests/DragAndDropTest.java ) I could do something like this:

  • Create empty nodes (drop target) around normal nodes in the tree. These are used to preview where the node will be inserted to. (I created an image to illustrate this http://imgur.com/rcXDcOi . The red lines represent those drop target nodes).
  • When a node is dragged, remove it temporary from the tree (or hide it).
  • When the drag is released, a check needs to be made if the target is a valid position. If so then move the node to that position. If the position is invalid, the node is put back at the original place.
  • When moved, some drop targets need to be added / removed.

Am I completely on the wrong track, or would this be the way to go?