@Override protected void makeComplete () { _layer.setTranslation(_startX, _startY); }
@Override public void close () { _layer.close(); } protected Layer _layer;
/** * Like {@link #hitTest} except that it ignores a configured {@link HitTester}. This allows one * to configure a hit tester which checks custom properties and then falls back on the default * hit testing implementation. */ public Layer hitTestDefault(Point p) { return (p.x >= 0 && p.y >= 0 && p.x < width() && p.y < height()) ? this : null; }
/** Performs the recursion for {@link #layerUnderPoint(Layer,float,float)}. */ protected static Layer layerUnderPoint (Layer layer, Point pt) { float x = pt.x, y = pt.y; if (layer instanceof GroupLayer) { GroupLayer gl = (GroupLayer)layer; for (int ii = gl.children()-1; ii >= 0; ii--) { Layer child = gl.childAt(ii); if (!child.visible()) continue; // ignore invisible children try { // transform the point into the child's coordinate system child.transform().inverseTransform(pt.set(x, y), pt); pt.x += child.originX(); pt.y += child.originY(); Layer l = layerUnderPoint(child, pt); if (l != null) return l; } catch (NoninvertibleTransformException nte) { continue; } } } if (x >= 0 && x < layer.width() && y >= 0 && y < layer.height()) { return layer; } return null; }
/** * 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)); }
/** * Renders this layer to {@code surf}, including its children. */ public final void paint (Surface surf) { if (!visible()) return; int otint = surf.combineTint(tint); QuadBatch obatch = surf.pushBatch(batch); surf.concatenate(transform(), originX(), originY()); try { paintImpl(surf); if (DEBUG_RECTS) { drawDebugRect(surf); } } finally { surf.popBatch(obatch); surf.setTint(otint); } }
@Override public Layer hitTestDefault(Point point) { float x = point.x, y = point.y; boolean sawInteractiveChild = false; // we check back to front as children are ordered "lowest" first for (int ii = children.size()-1; ii >= 0; ii--) { Layer child = children.get(ii); if (!child.interactive()) continue; // ignore non-interactive children sawInteractiveChild = true; // note that we saw an interactive child if (!child.visible()) continue; // ignore invisible children try { // transform the point into the child's coordinate system child.transform().inverseTransform(point.set(x, y), point); point.x += child.originX(); point.y += child.originY(); Layer l = child.hitTest(point); if (l != null) return l; } catch (NoninvertibleTransformException nte) { // Degenerate transform means no hit continue; } } // if we saw no interactive children and we don't have listeners registered directly on this // group, clear our own interactive flag; this lazily deactivates this group after its // interactive children have been deactivated or removed if (!sawInteractiveChild && !hasEventListeners()) setInteractive(false); return super.hitTestDefault(point); }
/** Returns the y-component of the layer's origin. */ public float originY () { if (isSet(Flag.ODIRTY)) { float height = height(); if (height > 0) { this.originX = origin.ox(width()); this.originY = origin.oy(height); setFlag(Flag.ODIRTY, false); } } return originY; } /** Writes this layer's origin into {@code into}.
/** * Converts the supplied point from coordinates relative to the specified * child layer to coordinates relative to the specified parent layer. The * results are stored into {@code into}, which is returned for convenience. */ public static Point layerToParent(Layer layer, Layer parent, XY point, Point into) { into.set(point); while (layer != parent) { if (layer == null) { throw new IllegalArgumentException( "Failed to find parent, perhaps you passed parent, layer instead of " + "layer, parent?"); } into.x -= layer.originX(); into.y -= layer.originY(); layer.transform().transform(into, into); layer = layer.parent(); } return into; }
/** * Returns the layer hit by (screen) position {@code p} (or null) in the scene graph rooted at * {@code root}, using {@link Layer#hitTest}. Note that {@code p} is mutated by this call. */ public static Layer getHitLayer (Layer root, Point p) { root.transform().inverseTransform(p, p); p.x += root.originX(); p.y += root.originY(); return root.hitTest(p); }
/** * 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); }
/** * Converts the supplied point from coordinates relative to its parent * to coordinates relative to the specified layer. The results are stored * into {@code into}, which is returned for convenience. */ public static Point parentToLayer(Layer layer, XY point, Point into) { layer.transform().inverseTransform(into.set(point), into); into.x += layer.originX(); into.y += layer.originY(); return into; }
@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)); }
protected Layer createWhiteBackground() { Layer bg = new Layer() { protected void paintImpl (Surface surf) { surf.setFillColor(0xFFFFFFFF).fillRect( 0, 0, graphics.viewSize.width(), graphics.viewSize.height()); } }; bg.setDepth(Float.NEGATIVE_INFINITY); // render behind everything return bg; } }
tripleplay.flump.Symbol currSymbol = kf.symbol(); boolean visible = currSymbol != null && kf.visible; content.setVisible(visible); float m10 = -sinX * scaleY; float m11 = cosX * scaleY; content.transform().setTransform(m00, m01, m10, m11, locX, locY); content.setOrigin(kf.pivot.x(), kf.pivot.y()); content.setAlpha(alpha);