/** * Converts the supplied point from coordinates relative to the specified * layer to screen coordinates. */ public static Point layerToScreen(Layer layer, float x, float y) { Point into = new Point(x, y); return layerToScreen(layer, into, into); }
/** * Transforms a point from one Layer's coordinate system to another's. */ public static Point transform (IPoint p, Layer from, Layer to, Point result) { LayerUtil.layerToScreen(from, p, result); LayerUtil.screenToLayer(to, result, result); return result; }
/** * Optionally confines the menu area to the given element. By default the menu is confined * by the host's screen area (see {@link MenuHost#getScreenArea()}). */ public Pop inElement (Element<?> elem) { Point tl = LayerUtil.layerToScreen(elem.layer, 0, 0); Point br = LayerUtil.layerToScreen( elem.layer, elem.size().width(), elem.size().height()); bounds = new Rectangle(tl.x(), tl.y(), br.x() - tl.x(), br.y() - tl.y()); return this; }
/** Finds the screen coordinates of the point, using the given element as the box. */ public Point resolve (Element<?> elem, Point dest) { LayerUtil.layerToScreen(elem.layer, dest.set(0, 0), dest); return resolve(dest.x, dest.y, elem.size().width(), elem.size().height(), dest); }
protected Rectangle getNativeFieldBounds () { Insets insets = resolveStyle(Style.BACKGROUND).insets; Point screenCoords = LayerUtil.layerToScreen(layer, insets.left(), insets.top()); return new Rectangle(screenCoords.x, screenCoords.y, _size.width - insets.width(), _size.height - insets.height()); }
/** * 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); }
@Override protected void init () { // TODO: compute the location of the center of the box in screen coordinates, place // the eye there in [0, 1] coords Graphics gfx = _ocontents.root().iface.plat.graphics(); Point eye = LayerUtil.layerToScreen( _ocontents.layer, _ocontents.size().width()/2, _ocontents.size().height()/2); eye.x /= gfx.viewSize.width(); eye.y /= gfx.viewSize.height(); _obatch = new RotateYBatch(gfx.gl, eye.x, eye.y, 1); _nbatch = new RotateYBatch(gfx.gl, eye.x, eye.y, 1); _ocontents.layer.setBatch(_obatch); _ncontents.layer.setBatch(_nbatch); } @Override protected void update (float pct) {