/** Returns the tree this node is currently in, or null. */ public Tree getTree () { Group parent = actor.getParent(); if (!(parent instanceof Tree)) return null; return (Tree)parent; }
/** Returns the tree this node is currently in, or null. */ public Tree getTree () { Group parent = actor.getParent(); if (!(parent instanceof Tree)) return null; return (Tree)parent; }
/** Sets the actor in this cell and adds the actor to the cell's table. If null, removes any current actor. */ public <A extends Actor> Cell<A> setActor (A newActor) { if (actor != newActor) { if (actor != null && actor.getParent() == table) actor.remove(); actor = newActor; if (newActor != null) table.addActor(newActor); } return (Cell<A>)this; }
/** Sets the actor in this cell and adds the actor to the cell's table. If null, removes any current actor. */ public <A extends Actor> Cell<A> setActor (A newActor) { if (actor != newActor) { if (actor != null && actor.getParent() == table) actor.remove(); actor = newActor; if (newActor != null) table.addActor(newActor); } return (Cell<A>)this; }
public Actor hit (float x, float y, boolean touchable) { if (!isVisible()) return null; Actor hit = super.hit(x, y, touchable); if (hit == null && isModal && (!touchable || getTouchable() == Touchable.enabled)) return this; float height = getHeight(); if (hit == null || hit == this) return hit; if (y <= height && y >= height - getPadTop() && x >= 0 && x <= getWidth()) { // Hit the title bar, don't use the hit child if it is in the Window's table. Actor current = hit; while (current.getParent() != this) current = current.getParent(); if (getCell(current) != null) return this; } return hit; }
public Actor hit (float x, float y, boolean touchable) { if (!isVisible()) return null; Actor hit = super.hit(x, y, touchable); if (hit == null && isModal && (!touchable || getTouchable() == Touchable.enabled)) return this; float height = getHeight(); if (hit == null || hit == this) return hit; if (y <= height && y >= height - getPadTop() && x >= 0 && x <= getWidth()) { // Hit the title bar, don't use the hit child if it is in the Window's table. Actor current = hit; while (current.getParent() != this) current = current.getParent(); if (getCell(current) != null) return this; } return hit; }
/** @return May be null. */ private TextField findNextTextField (Array<Actor> actors, TextField best, Vector2 bestCoords, Vector2 currentCoords, boolean up) { for (int i = 0, n = actors.size; i < n; i++) { Actor actor = actors.get(i); if (actor instanceof TextField) { if (actor == this) continue; TextField textField = (TextField)actor; if (textField.isDisabled() || !textField.focusTraversal || !textField.ancestorsVisible()) continue; Vector2 actorCoords = actor.getParent().localToStageCoordinates(tmp3.set(actor.getX(), actor.getY())); boolean below = actorCoords.y != currentCoords.y && (actorCoords.y < currentCoords.y ^ up); boolean right = actorCoords.y == currentCoords.y && (actorCoords.x > currentCoords.x ^ up); if (!below && !right) continue; boolean better = best == null || (actorCoords.y != bestCoords.y && (actorCoords.y > bestCoords.y ^ up)); if (!better) better = actorCoords.y == bestCoords.y && (actorCoords.x < bestCoords.x ^ up); if (better) { best = (TextField)actor; bestCoords.set(actorCoords); } } else if (actor instanceof Group) best = findNextTextField(((Group)actor).getChildren(), best, bestCoords, currentCoords, up); } return best; }
/** @return May be null. */ private TextField findNextTextField (Array<Actor> actors, TextField best, Vector2 bestCoords, Vector2 currentCoords, boolean up) { for (int i = 0, n = actors.size; i < n; i++) { Actor actor = actors.get(i); if (actor instanceof TextField) { if (actor == this) continue; TextField textField = (TextField)actor; if (textField.isDisabled() || !textField.focusTraversal || !textField.ancestorsVisible()) continue; Vector2 actorCoords = actor.getParent().localToStageCoordinates(tmp3.set(actor.getX(), actor.getY())); boolean below = actorCoords.y != currentCoords.y && (actorCoords.y < currentCoords.y ^ up); boolean right = actorCoords.y == currentCoords.y && (actorCoords.x > currentCoords.x ^ up); if (!below && !right) continue; boolean better = best == null || (actorCoords.y != bestCoords.y && (actorCoords.y > bestCoords.y ^ up)); if (!better) better = actorCoords.y == bestCoords.y && (actorCoords.x < bestCoords.x ^ up); if (better) { best = (TextField)actor; bestCoords.set(actorCoords); } } else if (actor instanceof Group) best = findNextTextField(((Group)actor).getChildren(), best, bestCoords, currentCoords, up); } return best; }
private boolean isCulled () { // we start by setting the stage coordinates to this // actors coordinates which are relative to its parent // Group. float stageX = getX(); float stageY = getY(); // now we go up the hierarchy and add all the parents' // coordinates to this actors coordinates. Note that // this assumes that neither this actor nor any of its // parents are rotated or scaled! Actor parent = this.getParent(); while (parent != null) { stageX += parent.getX(); stageY += parent.getY(); parent = parent.getParent(); } // now we check if the rectangle of this actor in screen // coordinates is in the rectangle spanned by the camera's // view. This assumes that the camera has no zoom and is // not rotated! actorRect.set(stageX, stageY, getWidth(), getHeight()); camRect.set(camera.position.x - camera.viewportWidth / 2.0f, camera.position.y - camera.viewportHeight / 2.0f, camera.viewportWidth, camera.viewportHeight); visible = camRect.overlaps(actorRect); return !visible; } }
/** Returns the tree this node is currently in, or null. */ public Tree getTree () { Group parent = actor.getParent(); if (!(parent instanceof Tree)) return null; return (Tree)parent; }
/** * @param actor might be in the drag pane. * @return true if actor is added to the pane's internal group. */ public boolean contains (final Actor actor) { return actor.getParent() == getActor(); }
/** * Checks if actor is visible in stage acknowledging parent visibility. * If any parent returns false from isVisible then this method return false. * True is returned when this actor and all its parent are visible. */ private boolean isActorVisibleInStage (Actor actor) { if (actor == null) return true; if (actor.isVisible() == false) return false; return isActorVisibleInStage(actor.getParent()); }
private Window findModalWindow (Actor actor) { if (actor == null) return null; if (actor instanceof Window && ((Window) actor).isModal()) return (Window) actor; return findModalWindow(actor.getParent()); }
/** Sets the actor in this cell and adds the actor to the cell's table. If null, removes any current actor. */ public <A extends Actor> Cell<A> setActor (A newActor) { if (actor != newActor) { if (actor != null && actor.getParent() == table) actor.remove(); actor = newActor; if (newActor != null) table.addActor(newActor); } return (Cell<A>)this; }
public static float absoluteX(Actor actor){ float val = 0; val += actor.getX(); Actor parent = actor; while(true){ Actor _p = parent.getParent(); if(_p == null) break; val += parent.localToParentCoordinates(new Vector2(0,0)).x; parent = _p; } return val; }