/** * Adds a child layer to a group and returns the child. */ public static <T extends Layer> T addChild (GroupLayer parent, T child) { parent.add(child); return child; }
return action(new Runnable() { public void run () { parent.add(child); }}); }
/** * Creates a new group with the given children. */ public static GroupLayer group (Layer... children) { GroupLayer gl = new GroupLayer(); for (Layer l : children) gl.add(l); return gl; }
/** * Adds the supplied layer to this group layer, adjusting its translation (relative to this group * layer) to the supplied values. * * <p>This is equivalent to: {@code add(child.setTranslation(tx, ty))}. */ public void addAt(Layer child, float tx, float ty) { add(child.setTranslation(tx, ty)); }
/** * Creates a root element with the specified layout and stylesheet and adds its layer to the * specified parent. */ public Root createRoot (Layout layout, Stylesheet sheet, GroupLayer parent) { Root root = createRoot(layout, sheet); parent.add(root.layer); return root; }
protected Movie (Symbol symbol) { _symbol = symbol; _animators = new LayerAnimator[symbol.layers.size()]; for (int ii = 0, ll = _animators.length; ii < ll; ++ii) { LayerAnimator animator = new LayerAnimator(symbol.layers.get(ii)); _animators[ii] = animator; _root.add(animator.content); } setFrame(1, 0); }
protected void setCurrent (Instance current) { if (_current != current) { _current = current; GroupLayer group = (GroupLayer)content; group.removeAll(); group.add(current.layer()); } }
/** Creates a button with the supplied up and down images. */ public ImageButton (TileSource up, TileSource down) { layer.add(_ilayer); setUp(up); setDown(down); }
/** * Starts a flipbook animation in a new image layer which is created and added to {@code box}. * When the flipbook animation is complete, the newly created image layer will not be disposed * automatically. This allows the animation to be repeated, if desired. The caller must dispose * eventually the image layer, or more likely, dispose {@code box} which will cause the created * image layer to be disposed. */ public Animation.Flip flipbook (GroupLayer box, Flipbook book) { ImageLayer image = new ImageLayer(); box.add(image); return flipbook(image, book); }
@Override public void addTo (GroupLayer parent, float x, float y, float depthAdjust) { _layer.setDepth(BACKGROUND_DEPTH + depthAdjust); _layer.transform().translate(x, y); // adjust any existing transform parent.add(_layer); } @Override public void close () {
protected void update (Texture tex) { if (tex == null) { // we should never be going back to null but handle it anyway if (_ilayer != null) _ilayer.close(); _ilayer = null; return; } if (_ilayer == null) layer.add(_ilayer = new ImageLayer()); _ilayer.setTile(tex); }
/** * Adds {@code child} to this group layer, positioning it such that its center is at ({@code tx}, * {@code tx}). The layer must report a non-zero size, thus this will not work on an unclipped * group layer. * * <p>This is equivalent to: {@code add(child.setTranslation(tx - child.width()/2, * ty - child.height()/2))}. */ public void addCenterAt (Layer child, float tx, float ty) { add(child.setTranslation(tx - child.width()/2, ty - child.height()/2)); }
/** * Adds {@code child} to this group layer, adjusting its translation (relative to this group * layer) to {@code floor(tx), floor(ty)}. This is useful for adding layers which display text a * text can become blurry if it is positioned on sub-pixel boundaries. */ public void addFloorAt (Layer child, float tx, float ty) { add(child.setTranslation(MathUtil.ifloor(tx), MathUtil.ifloor(ty))); }
public void check (boolean awake) { if (screen.awake() != awake) { if (awake) { _rootLayer.add(screen.layer); screen.wake(); } else { _rootLayer.remove(screen.layer); screen.sleep(); } } }
protected void didAdd (Element<?> child) { layer.add(child.layer); child.wasParented(this); // bar n-child from being added twice if (isAdded() && !child.willAdd()) { child.set(Flag.IS_ADDING, true); child.wasAdded(); } }
@Override protected void layout (LayoutData ldata, float left, float top, float width, float height) { // set the bars and element buffer first so the ScrollLayout can use them _elementBuffer = resolveStyle(ELEMENT_BUFFER); updateBars(((BarsLayoutData)ldata).barType); super.layout(ldata, left, top, width, height); if (_bars != null) layer.add(_bars.layer().setDepth(1).setTranslation(left, top)); }
/** 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; }
/** * Removes {@code layer} from its current parent and adds it to {@code target}, modifying its * transform in the process so that it stays in the same position on the screen. */ public static void reparent (Layer layer, GroupLayer target) { Point pos = new Point(layer.tx(), layer.ty()); LayerUtil.layerToScreen(layer.parent(), pos, pos); target.add(layer); LayerUtil.screenToLayer(layer.parent(), pos, pos); layer.setTranslation(pos.x, pos.y); }
public void onEmit (Library lib) { final Movie movie = lib.createMovie("walk"); movie.layer().setTranslation(size().width()/2, 300); main.layer.add(movie.layer()); closeOnHide(paint.connect(new Slot<Clock>() { public void onEmit (Clock clock) { movie.paint(clock); } })); } });