/** * Returns this element's y offset relative to its parent. */ public float y () { return layer.ty(); }
closeOnHide(paint.connect(new Slot<Clock>() { public void onEmit (Clock clock) { // bind the pos of our stack screen to the position of our top space screen if (_top != null) { layer.setTx(_top.layer.tx()); layer.setTy(_top.layer.ty()); } }})); return new Group(AxisLayout.vertical());
/** Returns whether or not an untransition gesture may be initiated via {@code dir}. * * <p>By default this requires that the screen be at its origin in x or y depending on the * orientation of {@code dir}. If a screen uses a {@code Flicker} to scroll vertically, * this will automatically do the right thing. If there are other circumstances in which a * screen wishes to prevent the user from initiating an untransition gesture, this is the * place to put 'em. */ public boolean canUntrans (Dir dir) { if (dir.horizComp() != 0) return layer.tx() == 0; if (dir.vertComp() != 0) return layer.ty() == 0; return true; }
protected void outline (Surface surf, GroupLayer gl) { drawRect(surf, gl.tx() - gl.originX(), gl.ty() - gl.originY(), gl.width(), gl.height()); } protected void drawRect(Surface surf, float x, float y, float w, float h) {
/** * Does whatever this element needs to validate itself. This may involve recomputing * visualizations, or laying out children, or anything else. */ protected void validate () { if (!isSet(Flag.VALID)) { // prior to laying ourselves out, ensure that our visual boundaries fall on physical // pixels; this avoids rendering artifacts on devices where the scale factor between // virtual and physical pixels is non-integral Root root = root(); if (root != null) { Scale scale = root.iface.plat.graphics().scale(); float x = layer.tx(), y = layer.ty(); float rx = scale.roundToNearestPixel(x), ry = scale.roundToNearestPixel(y); float rr = scale.roundToNearestPixel(x + _size.width); float rb = scale.roundToNearestPixel(y + _size.height); layer.setTranslation(rx, ry); _size.setSize(rr-rx, rb-ry); } // now that our boundaries are adjusted, we can layout our children (if any) layout(); set(Flag.VALID, true); wasValidated(); } }
@Override public void init (Platform plat, Screen oscreen, Screen nscreen) { super.init(plat, oscreen, nscreen); switch (_dir) { case UP: _odx = _originX; _ody = _originY-oscreen.size().height(); _nsx = _originX; _nsy = _originY+nscreen.size().height(); break; case DOWN: _odx = _originX; _ody = _originY+oscreen.size().height(); _nsx = _originX; _nsy = _originY-nscreen.size().height(); break; case LEFT: default: _odx = _originX-oscreen.size().width(); _ody = _originY; _nsx = _originX+nscreen.size().width(); _nsy = _originY; break; case RIGHT: _odx = _originX+oscreen.size().width(); _ody = _originY; _nsx = _originX-nscreen.size().width(); _nsy = _originY; break; } _osx = oscreen.layer.tx(); _osy = oscreen.layer.ty(); nscreen.layer.setTranslation(_nsx, _nsy); }
game.rootLayer.addAt(touch.layer, x, y); y = mouse.layer.ty(); x += touch.layer.width() + 5;