/** * Removes all child layers from this group. */ public void removeAll() { while (!children.isEmpty()) remove(children.size()-1); }
/** * Removes a layer from the group. */ public void remove(Layer child) { int index = findChild(child, child.depth()); if (index < 0) { throw new UnsupportedOperationException( "Could not remove Layer because it is not a child of the GroupLayer " + "[group=" + this + ", layer=" + child + "]"); } remove(index); }
/** * Disposes this layer, removing it from its parent layer. Any resources associated with this * layer are freed, and it cannot be reused after being disposed. Disposing a layer that has * children will dispose them as well. */ @Override public void close() { if (parent != null) parent.remove(this); setState(State.DISPOSED); setBatch(null); }
@Override protected void wasRemoved (Entity entity, int index) { super.wasRemoved(entity, index); stage.remove(sprite.get(entity.id)); }
protected void hide (Screen screen) { _rootLayer.remove(screen.layer); try { screen.wasHidden(); } catch (RuntimeException e) { handleError(e); } }
/** * Removes the supplied root element from this interface, iff it's currently added. If the * root's layer has a parent, the layer will be removed from the parent as well. This leaves * the Root's layer in existence, so it may be used again. If you're done with the Root and all * of the elements inside of it, call {@link #disposeRoot} to free its resources. * * @return true if the root was removed, false if it was not currently added. */ public boolean removeRoot (Root root) { if (!_roots.remove(root)) return false; root.wasRemoved(); if (root.layer.parent() != null) root.layer.parent().remove(root.layer); return true; }
public void check (boolean awake) { if (screen.awake() != awake) { if (awake) { _rootLayer.add(screen.layer); screen.wake(); } else { _rootLayer.remove(screen.layer); screen.sleep(); } } }
/** Replace the currently active movie. */ protected Movie setCurrent (Movie current) { if (movie() != null) { _root.remove(movie().layer()); } _root.add(current.layer()); movie.update(current); return current; }
/** * Adds a layer to the bottom of the group. Because the {@link Layer} hierarchy is a tree, if * {@code child} is already a child of another {@link GroupLayer}, it will be removed before * being added to this {@link GroupLayer}. */ public void add(Layer child) { // optimization if we're requested to add a child that's already added GroupLayer parent = child.parent(); if (parent == this) return; // if this child has equal or greater depth to the last child, we can append directly and avoid // a log(N) search; this is helpful when all children have the same depth int count = children.size(), index; if (count == 0 || children.get(count-1).depth() <= child.depth()) index = count; // otherwise find the appropriate insertion point via binary search else index = findInsertion(child.depth()); // remove the child from any existing parent, preventing multiple parents if (parent != null) parent.remove(child); children.add(index, child); child.setParent(this); if (state.get() == State.ADDED) child.onAdd(); // if this child is active, we need to become active if (child.interactive()) setInteractive(true); }
protected void didRemove (Element<?> child, boolean dispose) { if (dispose) child.set(Flag.WILL_DISPOSE, true); layer.remove(child.layer); boolean needsRemove = child.willRemove(); // early removal of a scheduled n-child child.wasUnparented(); if (isAdded() || needsRemove) { child.set(Flag.IS_REMOVING, true); child.wasRemoved(); } if (dispose) child.layer.close(); }