List of usage examples for com.badlogic.gdx.scenes.scene2d Actor isDescendantOf
public boolean isDescendantOf(Actor actor)
From source file:com.aia.hichef.ui.n.MyDialog.java
License:Apache License
private void initialize() { setModal(true);//from w ww. ja va2 s .c o m defaults().space(6); add(contentTable = new Table(skin)).expand().fill(); row(); add(buttonTable = new Table(skin)); contentTable.defaults().space(6); buttonTable.defaults().space(6); buttonTable.addListener(new ChangeListener() { public void changed(ChangeEvent event, Actor actor) { if (!values.containsKey(actor)) return; while (actor.getParent() != buttonTable) actor = actor.getParent(); result(values.get(actor)); if (!cancelHide) hide(); cancelHide = false; } }); addListener(new FocusListener() { public void keyboardFocusChanged(FocusEvent event, Actor actor, boolean focused) { if (!focused) focusChanged(event); } public void scrollFocusChanged(FocusEvent event, Actor actor, boolean focused) { if (!focused) focusChanged(event); } private void focusChanged(FocusEvent event) { Stage stage = getStage(); if (isModal() && stage != null && stage.getRoot().getChildren().size > 0 && stage.getRoot().getChildren().peek() == MyDialog.this) { // Dialog // is // top // most // actor. Actor newFocusedActor = event.getRelatedActor(); if (newFocusedActor != null && !newFocusedActor.isDescendantOf(MyDialog.this)) event.cancel(); } } }); }
From source file:com.aia.hichef.ui.n.MyDialog.java
License:Apache License
/** {@link #pack() Packs} the dialog and adds it to the stage, centered. */ public MyDialog show(Stage stage) { clearActions();/* w w w .j a va 2s.co m*/ removeCaptureListener(ignoreTouchDown); previousKeyboardFocus = null; Actor actor = stage.getKeyboardFocus(); if (actor != null && !actor.isDescendantOf(this)) previousKeyboardFocus = actor; previousScrollFocus = null; actor = stage.getScrollFocus(); if (actor != null && !actor.isDescendantOf(this)) previousScrollFocus = actor; pack(); setPosition(Math.round((stage.getWidth() - getWidth()) / 2), Math.round((stage.getHeight() - getHeight()) / 2)); stage.addActor(this); stage.setKeyboardFocus(this); stage.setScrollFocus(this); if (fadeDuration > 0) { getColor().a = 0; addAction(Actions.fadeIn(fadeDuration, Interpolation.fade)); } return this; }
From source file:com.aia.hichef.ui.n.MyDialog.java
License:Apache License
/** * Hides the dialog. Called automatically when a button is clicked. The * default implementation fades out the dialog over {@link #fadeDuration} * seconds and then removes it from the stage. *///w ww .j av a 2s.co m public void hide() { Stage stage = getStage(); if (stage != null) { 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 (fadeDuration > 0) { addCaptureListener(ignoreTouchDown); addAction(sequence(fadeOut(fadeDuration, Interpolation.fade), Actions.removeListener(ignoreTouchDown, true), Actions.removeActor())); } else remove(); }
From source file:com.coder5560.game.ui.MyDialog.java
License:Apache License
private void initialize() { setModal(true);/*from w w w . ja v a2s . co m*/ back2 = new Image(new NinePatchDrawable( new NinePatch(new NinePatch(Assets.instance.getRegion("ninepatch2"), 4, 4, 4, 4), new Color(240 / 255f, 240 / 255f, 240 / 255f, 1)))); addActor(back2); defaults().space(6); add(contentTable = new Table(skin)).expand().fill(); row(); add(buttonTable = new Table(skin)); contentTable.defaults().space(6); buttonTable.defaults().space(6); buttonTable.addListener(new ChangeListener() { public void changed(ChangeEvent event, Actor actor) { if (!values.containsKey(actor)) return; while (actor.getParent() != buttonTable) actor = actor.getParent(); result(values.get(actor)); if (!cancelHide) hide(); cancelHide = false; } }); addListener(new FocusListener() { public void keyboardFocusChanged(FocusEvent event, Actor actor, boolean focused) { if (!focused) focusChanged(event); } public void scrollFocusChanged(FocusEvent event, Actor actor, boolean focused) { if (!focused) focusChanged(event); } private void focusChanged(FocusEvent event) { Stage stage = getStage(); if (isModal() && stage != null && stage.getRoot().getChildren().size > 0 && stage.getRoot().getChildren().peek() == MyDialog.this) { // Dialog // is // top // most // actor. Actor newFocusedActor = event.getRelatedActor(); if (newFocusedActor != null && !newFocusedActor.isDescendantOf(MyDialog.this)) event.cancel(); } } }); }
From source file:com.kotcrab.vis.ui.widget.internal.SplitPaneCursorManager.java
License:Apache License
@Override public void exit(InputEvent event, float x, float y, int pointer, Actor toActor) { super.exit(event, x, y, pointer, toActor); if (pointer == -1 && (toActor == null || toActor.isDescendantOf(owner) == false)) { clearCustomCursor();//from w w w . ja v a2 s. c o m } }
From source file:com.vlaaad.common.tutorial.tasks.ArrowForceClick.java
License:Open Source License
protected void addListener(final Stage stage, final Actor target, final Image arrow, final Table message, final Callback callback) { stage.addCaptureListener(new InputListener() { @Override/*from www . j a v a 2 s.c om*/ public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { Actor result = stage.hit(event.getStageX(), event.getStageY(), true); if (!result.isDescendantOf(target)) { event.cancel(); return false; } return true; } @Override public void touchUp(InputEvent event, float x, float y, int pointer, int button) { Actor result = stage.hit(event.getStageX(), event.getStageY(), true); if (!result.isDescendantOf(target)) { event.cancel(); return; } stage.removeCaptureListener(this); arrow.remove(); message.remove(); callback.taskEnded(); } }); }
From source file:com.vlaaad.common.tutorial.tasks.ForceClickActor.java
License:Open Source License
@Override public final void start(final Callback callback) { final Actor target = getTargetActor(); stage = target.getStage();// w w w . j av a2 s . c o m if (stage == null) throw new IllegalStateException("actor not on stage!"); listener = new InputListener() { @Override public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { if (!event.getTarget().isDescendantOf(target)) { event.cancel(); return false; } return true; } @Override public void touchUp(InputEvent event, float x, float y, int pointer, int button) { Actor result = stage.hit(event.getStageX(), event.getStageY(), true); if (result == null || !result.isDescendantOf(target)) { event.cancel(); return; } stage.removeCaptureListener(this); callback.taskEnded(); } }; stage.addCaptureListener(listener); }
From source file:com.vlaaad.common.tutorial.tasks.WaitClickActor.java
License:Open Source License
@Override public final void start(final Callback callback) { final Actor target = getTargetActor(); stage = target.getStage();/*from w w w. j a va 2s . c o m*/ if (stage == null) throw new IllegalStateException("actor not on stage!"); listener = new InputListener() { @Override public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { return event.getTarget().isDescendantOf(target); } @Override public void touchUp(InputEvent event, float x, float y, int pointer, int button) { Actor result = stage.hit(event.getStageX(), event.getStageY(), true); if (result == null || !result.isDescendantOf(target)) { return; } stage.removeCaptureListener(this); callback.taskEnded(); } }; stage.addCaptureListener(listener); }
From source file:es.eucm.ead.editor.view.builders.scene.groupeditor.inputstatemachine.InputState.java
License:Open Source License
protected boolean isTouchCancelled(InputEvent event, float x, float y) { Actor actor = event.getTarget();//from w ww . java 2 s . c om Actor hit = actor.hit(x, y, true); return !(hit == actor || (hit != null && hit.isDescendantOf(actor))); }
From source file:es.eucm.ead.editor.view.listeners.GestureListener.java
License:Open Source License
public boolean isOver(Actor actor, float x, float y) { Actor hit = actor.hit(x, y, true); return !(hit == null || !hit.isDescendantOf(actor)) || inTapSquare(x, y); }