@Override // from interface IDimension public Dimension clone () { return new Dimension(this); }
/** * Creates a new value with a new dimension of the given width and height. */ public DimensionValue (float width, float height) { super(new Dimension(width, height)); }
@Override public IDimension screenSize () { return new Dimension(config.width, config.height); } @Override void setTitle (String title) {} // noop!
/** Calculates the size of the label, using the given width hint. */ public Dimension calcSize (float hintX) { return new Dimension(preferredSize(hintX, 0)); } }
/** Sets the estimated height for entries that are currently not in view. */ protected void setEstimatedHeight (float height) { _estimatedSize = new Dimension(1, height); _entriesGroup.invalidate(); }
/** * Updates the value to a new dimension of the given width and height. */ public void update (float width, float height) { update(new Dimension(width, height)); }
@Override // from interface IRectangle public Dimension size () { return size(new Dimension()); }
protected TextLayout (String text, TextFormat format, IRectangle bounds, float height) { this.text = text; this.format = format; this.bounds = bounds; // if the x position is positive, we need to include extra space in our full-width for it this.size = new Dimension(Math.max(bounds.x(), 0) + bounds.width(), height); }
protected TextLayout (String text, TextFormat format, IRectangle bounds, float height) { this.text = text; this.format = format; this.bounds = bounds; // if the x position is positive, we need to include extra space in our full-width for it this.size = new Dimension(Math.max(bounds.x(), 0) + bounds.width(), height); }
@Override public IDimension screenSize () { Rectangle db = plat.display().getBounds(); return new Dimension(db.width, db.height); }
/** * Constrains {@code elem} to the specified position and size. */ public static <T extends Element<?>> T at (T elem, float x, float y, float width, float height) { return at(elem, new Point(x, y), new Dimension(width, height)); }
public IDimension psize (AbsoluteLayout layout, Element<?> elem) { float fwidth = size.width(), fheight = size.height(); if (fwidth > 0 && fheight > 0) return size; // if either forced width or height is zero, use preferred size in that dimension IDimension psize = layout.preferredSize(elem, fwidth, fheight); if (fwidth > 0) return new Dimension(fwidth, psize.height()); else if (fheight > 0) return new Dimension(psize.width(), fheight); else return psize; }
/** * Constrains {@code elem} to the specified size and aligns it relative to the given position * using the given alignments. */ public static <T extends Element<?>> T at (T elem, float x, float y, float width, float height, HAlign halign, VAlign valign) { return at(elem, new Point(x, y), new Dimension(width, height), halign, valign); }
/** * Updates the value to a new dimension with the current height and the given width. */ public void updateWidth (float width) { update(new Dimension(width, get().height())); }
@Override public void onEmit () { widget.setConstraint(new AbsoluteLayout.Constraint( position.point.get(), origin.point.get(), new Dimension(width.value.get(), height.value.get()))); } };
/** * Updates the value to a new dimension with the current width and the given height. */ public void updateHeight (float height) { update(new Dimension(get().width(), height)); } }
@Override public Dimension computeSize (Container<?> elems, float hintX, float hintY) { // the content is always the 1st child, get the preferred size with extended hints assert elems.childCount() == 1 && elems.childAt(0) == content; _contentSize.setSize(preferredSize(elems.childAt(0), hrange.extendHint(hintX), vrange.extendHint(hintY))); return new Dimension(_contentSize); }
@Override public Dimension computeSize (Container<?> elems, float hintX, float hintY) { // report a size large enough to contain all of our elements Rectangle bounds = new Rectangle(); for (Element<?> elem : elems) { if (!elem.isVisible()) continue; Constraint c = constraint(elem); IDimension psize = c.psize(this, elem); bounds.add(new Rectangle(c.pos(0, 0, psize), psize)); } return new Dimension(bounds.width, bounds.height); }