コード例 #1
0
ファイル: DragPane.java プロジェクト: piotr-j/VisEditor
 /**
  * @param actor is being dragged.
  * @param dragPane is under the actor. Stores a {@link GridGroup} or unknown group.
  * @param directPaneChild actor under the cursor.
  * @return true if actor was accepted by the group.
  */
 protected boolean addToOtherGroup(
     final Actor actor, final DragPane dragPane, final Actor directPaneChild) {
   final Array<Actor> children = dragPane.getChildren();
   final int indexOfDirectChild = children.indexOf(directPaneChild, true);
   final int indexOfDraggedActor = children.indexOf(actor, true);
   if (indexOfDraggedActor >= 0) { // Dragging own actor.
     if (indexOfDraggedActor > indexOfDirectChild) { // Dropped after current position.
       dragPane.addActorBefore(directPaneChild, actor);
     } else { // Dropped before current position.
       dragPane.addActorAfter(directPaneChild, actor);
     }
   } else if (indexOfDirectChild == children.size - 1) { // Dragged into last element.
     if (DRAG_POSITION.y < directPaneChild.getHeight() / 2f
         || DRAG_POSITION.x > directPaneChild.getWidth() / 2f) {
       // Adding last:																																	// last:
       dragPane.addActor(actor);
     } else {
       dragPane.addActorBefore(directPaneChild, actor);
     }
   } else if (indexOfDirectChild == 0) { // Dragged into first element.
     if (DRAG_POSITION.y < directPaneChild.getHeight() / 2f
         || DRAG_POSITION.x > directPaneChild.getWidth() / 2f) {
       dragPane.addActorAfter(directPaneChild, actor);
     } else { // Adding first:
       dragPane.addActorBefore(directPaneChild, actor);
     }
   } else { // Replacing hovered actor:
     dragPane.addActorBefore(directPaneChild, actor);
   }
   return APPROVE;
 }
コード例 #2
0
ファイル: DragPane.java プロジェクト: piotr-j/VisEditor
 /**
  * @param actor is being dragged.
  * @param dragPane is under the actor. Stores a {@link VerticalGroup}.
  * @param directPaneChild actor under the cursor.
  * @return true if actor was accepted by the group.
  */
 protected boolean addToVerticalGroup(
     final Actor actor, final DragPane dragPane, final Actor directPaneChild) {
   final Array<Actor> children = dragPane.getChildren();
   final int indexOfDraggedActor = children.indexOf(actor, true);
   if (indexOfDraggedActor >= 0) {
     final int indexOfDirectChild = children.indexOf(directPaneChild, true);
     if (indexOfDirectChild > indexOfDraggedActor) {
       dragPane.addActorAfter(directPaneChild, actor);
     } else {
       dragPane.addActorBefore(directPaneChild, actor);
     }
   } else if (DRAG_POSITION.y < directPaneChild.getHeight() / 2f) { // Y inverted.
     dragPane.addActorAfter(directPaneChild, actor);
   } else {
     dragPane.addActorBefore(directPaneChild, actor);
   }
   return APPROVE;
 }
コード例 #3
0
ファイル: DragPane.java プロジェクト: piotr-j/VisEditor
 @Override
 public boolean accept(final DragPane dragPane, final Actor actor) {
   return dragPane.contains(actor) || dragPane.getChildren().size < max;
 }