Beispiel #1
0
 @Override
 public boolean onEnd(
     final Draggable draggable, final Actor actor, final float stageX, final float stageY) {
   if (actor == null || actor.getStage() == null) {
     return CANCEL;
   }
   final Actor overActor = actor.getStage().hit(stageX, stageY, true);
   if (overActor == null || overActor == actor) {
     return CANCEL;
   } else if (overActor.isAscendantOf(actor)) {
     final DragPane dragPane = getDragPane(actor);
     if (dragPane != null && dragPane.isFloating()) {
       DRAG_POSITION.set(stageX, stageY);
       return addToFloatingGroup(draggable, actor, dragPane);
     }
     return CANCEL;
   }
   DRAG_POSITION.set(stageX, stageY);
   if (overActor instanceof DragPane) {
     return addDirectlyToPane(draggable, actor, (DragPane) overActor);
   }
   final DragPane dragPane = getDragPane(overActor);
   if (accept(actor, dragPane)) {
     return addActor(draggable, actor, overActor, dragPane);
   }
   return CANCEL;
 }
Beispiel #2
0
 /**
  * @param draggable is attached to the actor.
  * @param actor dragged actor.
  * @param dragPane is directly under the dragged actor. If accepts the actor, it should be added
  *     to its content.
  * @return true if actor was accepted.
  */
 protected boolean addDirectlyToPane(
     final Draggable draggable, final Actor actor, final DragPane dragPane) {
   if (accept(actor, dragPane)) {
     if (dragPane.isFloating()) {
       return addToFloatingGroup(draggable, actor, dragPane);
     }
     // Dragged directly to a pane. Assuming no padding, adding last:
     dragPane.addActor(actor);
     return APPROVE;
   }
   return CANCEL;
 }
Beispiel #3
0
 /**
  * @param draggable is attached to the actor.
  * @param actor is being dragged.
  * @param overActor is directly under the dragged actor.
  * @param dragPane contains the actor under dragged widget.
  * @return true if actor is accepted and added to the group.
  */
 protected boolean addActor(
     final Draggable draggable,
     final Actor actor,
     final Actor overActor,
     final DragPane dragPane) {
   final Actor directPaneChild = getActorInDragPane(overActor, dragPane);
   directPaneChild.stageToLocalCoordinates(DRAG_POSITION);
   if (dragPane.isVertical() || dragPane.isVerticalFlow()) {
     return addToVerticalGroup(actor, dragPane, directPaneChild);
   } else if (dragPane.isHorizontal() || dragPane.isHorizontalFlow()) {
     return addToHorizontalGroup(actor, dragPane, directPaneChild);
   } else if (dragPane.isFloating()) {
     return addToFloatingGroup(draggable, actor, dragPane);
   } // This is the default behavior for grid and unknown groups:
   return addToOtherGroup(actor, dragPane, directPaneChild);
 }