/** Returns the z-index of this actor. * @see #setZIndex(int) */ public int getZIndex () { Group parent = this.parent; if (parent == null) return -1; return parent.children.indexOf(this, true); }
/** Returns the z-index of this actor. * @see #setZIndex(int) */ public int getZIndex () { Group parent = this.parent; if (parent == null) return -1; return parent.children.indexOf(this, true); }
/** Swaps two actors. Returns false if the swap did not occur because the actors are not children of this group. */ public boolean swapActor (Actor first, Actor second) { int firstIndex = children.indexOf(first, true); int secondIndex = children.indexOf(second, true); if (firstIndex == -1 || secondIndex == -1) return false; children.swap(firstIndex, secondIndex); return true; }
/** Swaps two actors. Returns false if the swap did not occur because the actors are not children of this group. */ public boolean swapActor (Actor first, Actor second) { int firstIndex = children.indexOf(first, true); int secondIndex = children.indexOf(second, true); if (firstIndex == -1 || secondIndex == -1) return false; children.swap(firstIndex, secondIndex); return true; }
/** Adds an actor as a child of this group immediately before another child actor, removing it from its previous parent. If the * actor is already a child of this group, no changes are made. */ public void addActorBefore (Actor actorBefore, Actor actor) { if (actor.parent != null) { if (actor.parent == this) return; actor.parent.removeActor(actor, false); } int index = children.indexOf(actorBefore, true); children.insert(index, actor); actor.setParent(this); actor.setStage(getStage()); childrenChanged(); }
/** Adds an actor as a child of this group immediately before another child actor, removing it from its previous parent. If the * actor is already a child of this group, no changes are made. */ public void addActorBefore (Actor actorBefore, Actor actor) { if (actor.parent != null) { if (actor.parent == this) return; actor.parent.removeActor(actor, false); } int index = children.indexOf(actorBefore, true); children.insert(index, actor); actor.setParent(this); actor.setStage(getStage()); childrenChanged(); }
/** Adds an actor as a child of this group immediately after another child actor, removing it from its previous parent. If the * actor is already a child of this group, no changes are made. */ public void addActorAfter (Actor actorAfter, Actor actor) { if (actor.parent != null) { if (actor.parent == this) return; actor.parent.removeActor(actor, false); } int index = children.indexOf(actorAfter, true); if (index == children.size) children.add(actor); else children.insert(index + 1, actor); actor.setParent(this); actor.setStage(getStage()); childrenChanged(); }
/** Adds an actor as a child of this group immediately after another child actor, removing it from its previous parent. If the * actor is already a child of this group, no changes are made. */ public void addActorAfter (Actor actorAfter, Actor actor) { if (actor.parent != null) { if (actor.parent == this) return; actor.parent.removeActor(actor, false); } int index = children.indexOf(actorAfter, true); if (index == children.size) children.add(actor); else children.insert(index + 1, actor); actor.setParent(this); actor.setStage(getStage()); childrenChanged(); }
/** Returns the z-index of this actor. * @see #setZIndex(int) */ public int getZIndex () { Group parent = this.parent; if (parent == null) return -1; return parent.children.indexOf(this, true); }
/** Swaps two actors. Returns false if the swap did not occur because the actors are not children of this group. */ public boolean swapActor (Actor first, Actor second) { int firstIndex = children.indexOf(first, true); int secondIndex = children.indexOf(second, true); if (firstIndex == -1 || secondIndex == -1) return false; children.swap(firstIndex, secondIndex); return true; }
@Override protected void setParent(Group parent) { super.setParent(parent); if (parent != null) { int index = parent.getChildren().indexOf(this, true); parent.addActorAt(index, shadowLabel); } }
private void selectNextItem() { SnapshotArray<Actor> children = getChildren(); if (children.size == 0) return; int startIndex = activeItem == null ? 0 : children.indexOf(activeItem, true) + 1; for (int i = startIndex;; i++) { if (i >= children.size) i = 0; Actor actor = children.get(i); if (actor instanceof MenuItem && ((MenuItem) actor).isDisabled() == false) { setActiveItem((MenuItem) actor, true); break; } } }
private void selectPreviousItem() { SnapshotArray<Actor> children = getChildren(); if (children.size == 0) return; int startIndex = children.indexOf(activeItem, true) - 1; for (int i = startIndex;; i--) { if (i == -1) i = children.size - 1; Actor actor = children.get(i); if (actor instanceof MenuItem && ((MenuItem) actor).isDisabled() == false) { setActiveItem((MenuItem) actor, true); break; } } }
private void selectNextItem () { SnapshotArray<Actor> children = getChildren(); if (!hasSelectableMenuItems()) return; int startIndex = activeItem == null ? 0 : children.indexOf(activeItem, true) + 1; for (int i = startIndex; ; i++) { if (i >= children.size) i = 0; Actor actor = children.get(i); if (actor instanceof MenuItem && ((MenuItem) actor).isDisabled() == false) { setActiveItem((MenuItem) actor, true); break; } } }
private void selectPreviousItem () { SnapshotArray<Actor> children = getChildren(); if (!hasSelectableMenuItems()) return; int startIndex = activeItem == null ? children.size - 1 : children.indexOf(activeItem, true) - 1; for (int i = startIndex; ; i--) { if (i <= -1) i = children.size - 1; Actor actor = children.get(i); if (actor instanceof MenuItem && ((MenuItem) actor).isDisabled() == false) { setActiveItem((MenuItem) actor, true); break; } } }
/** Adds an actor as a child of this group immediately before another child actor, removing it from its previous parent. If the * actor is already a child of this group, no changes are made. */ public void addActorBefore (Actor actorBefore, Actor actor) { if (actor.parent != null) { if (actor.parent == this) return; actor.parent.removeActor(actor, false); } int index = children.indexOf(actorBefore, true); children.insert(index, actor); actor.setParent(this); actor.setStage(getStage()); childrenChanged(); }
/** Adds an actor as a child of this group immediately after another child actor, removing it from its previous parent. If the * actor is already a child of this group, no changes are made. */ public void addActorAfter (Actor actorAfter, Actor actor) { if (actor.parent != null) { if (actor.parent == this) return; actor.parent.removeActor(actor, false); } int index = children.indexOf(actorAfter, true); if (index == children.size) children.add(actor); else children.insert(index + 1, actor); actor.setParent(this); actor.setStage(getStage()); childrenChanged(); }
public boolean replaceChildWith(Actor actorToRemove, Actor actorToInsert) { int index = getChildren().indexOf(actorToRemove, false); if (index == -1) return false; actorToInsert.setPosition(actorToRemove.getX(), actorToRemove.getY()); actorToInsert.setUserObject(actorToRemove.getUserObject()); removeActor(actorToRemove, false); addActorAt(index, actorToInsert); return true; } }