コード例 #1
0
ファイル: DragPane.java プロジェクト: piotr-j/VisEditor
 @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;
 }
コード例 #2
0
ファイル: Dialog.java プロジェクト: CHN-FrankCheng/libgdx
  /** Hides the dialog with the given action and then removes it from the stage. */
  public void hide(Action action) {
    Stage stage = getStage();
    if (stage != null) {
      removeListener(focusListener);
      if (previousKeyboardFocus != null && previousKeyboardFocus.getStage() == null)
        previousKeyboardFocus = null;
      Actor actor = stage.getKeyboardFocus();
      if (actor == null || actor.isDescendantOf(this))
        stage.setKeyboardFocus(previousKeyboardFocus);

      if (previousScrollFocus != null && previousScrollFocus.getStage() == null)
        previousScrollFocus = null;
      actor = stage.getScrollFocus();
      if (actor == null || actor.isDescendantOf(this)) stage.setScrollFocus(previousScrollFocus);
    }
    if (action != null) {
      addCaptureListener(ignoreTouchDown);
      addAction(
          sequence(action, Actions.removeListener(ignoreTouchDown, true), Actions.removeActor()));
    } else remove();
  }
コード例 #3
0
ファイル: DragPane.java プロジェクト: piotr-j/VisEditor
 /**
  * Removes an actor from this group. If the actor will not be used again and has actions, they
  * should be {@link Actor#clearActions() cleared} so the actions will be returned to their {@link
  * Action#setPool(com.badlogic.gdx.utils.Pool) pool}, if any. This is not done automatically.
  *
  * <p>Note that the direct parent of {@link DragPane}'s children is the internal pane's group
  * accessible through {@link #getGroup()} - and since this removal method is overridden and
  * extended, pane's children should be deleted with {@code dragPane.removeActor(child, true)}
  * rather than {@link Actor#remove()} method.
  *
  * @param unfocus if true, {@link Stage#unfocus(Actor)} is called.
  * @param actor will be removed, if present in the internal {@link WidgetGroup}.
  * @return true if the actor was removed from this group.
  */
 @Override
 public boolean removeActor(final Actor actor, final boolean unfocus) {
   if (getActor().getChildren().contains(actor, true)) {
     // Stage input focus causes problems, as touchUp is called in Draggable. Reproducing input
     // unfocus after stage removed.
     Stage stage = actor.getStage();
     getActor().removeActor(actor, false); // Stage is cleared.
     if (unfocus && stage != null) {
       stage.unfocus(actor);
     }
     return true;
   }
   return false;
 }