protected void updateVisibility (int fromPage, int toPage) { int itemIdx = fromPage * itemsPerPage, size = _items.size(); for (int pp = fromPage; pp <= toPage; ++pp) { boolean vis = pp == _page.get(); for (int ii = 0; ii < itemsPerPage; ii++) { if (itemIdx >= size) break; _items.get(itemIdx++).setVisible(vis); } } }
@Override public void onEmit () { Tabs.Tab tab = tabs.selected.get(); if (tab != null) { tab.setVisible(false); } } }).setEnabled(false);
protected void setValueFromPointer (float x) { Range r = range.get(); float width = _thumbRange; x = Math.min(width, x - _thumbLeft); float pos = Math.max(x, 0) / width * r.range; if (_increment != null) { float i = _increment; pos = i * Math.round(pos / i); } value.update(r.min + pos); }
@Override public Dimension computeSize (float hintX, float hintY) { Texture tex = _texture.get(); return tex == null ? new Dimension(0, 0) : new Dimension( tex.displayWidth, tex.displayHeight); } };
@Override public void onStart (Pointer.Interaction iact) { if (!enabled.get()) return; _vel = 0; _maxDelta = 0; _minFlickExceeded = false; _origPos = position; _start = _prev = _cur = getPosition(iact.event); _prevStamp = 0; _curStamp = iact.event.time; setState(DRAGGING); }
public boolean merge (String name, String data) { T svalue = codec.decode(data, defval); T nvalue = resolver.resolve(value.get(), svalue); value.update(nvalue); return nvalue.equals(svalue); } public void update (String name, String data) {
/** * Sets the current page. Items on the page are shown. All others are hidden. */ public PagedMenu setPage (int page) { int oldPage = _page.get(); if (page != oldPage) { _page.update(page); updateVisibility(oldPage, oldPage); updateVisibility(page, page); } return this; }
public void update () { _vlayout = _game.plat.graphics().layoutText(String.valueOf(value.get()), _fmt); _size.setSize(llayout.size.width() + GAP + _vlayout.size.width(), Math.max(llayout.size.height(), _vlayout.size.height())); } public float labelWidth () { return llayout.size.width(); }
protected Sound prepareSound () { if (sound == null) { sound = loadSound(path()); sound.prepare(); } sound.setVolume(volume.get() * _volume); return sound; }
@Override public Root setSize (float width, float height) { super.setSize(width, height); // update the image to the new size, if it's changed Texture old = _texture.get(); if (old == null || old.displayWidth != width || old.displayHeight != height) { _texture.update(iface.plat.graphics().createTexture(width, height, textureConfig())); } return this; }
@Override protected void wasAdded () { super.wasAdded(); // if we don't have a selected tab, select the first one that's visible if (selected.get() == null) { for (int ii = 0; ii < tabCount(); ii++) { if (tabAt(ii).isVisible()) { selected.update(tabAt(ii)); break; } } } }
@Override protected void paintImpl (Surface surface) { IDimension size = group.size(); position.point.get().resolve(size, pt); surface.saveTx(); surface.setFillColor(Colors.BLACK); surface.fillRect(pt.x - 2, pt.y - 2, 5, 5); surface.restoreTx(); } }.setDepth(1));
@Override public void layout () { super.layout(); Texture texture = _texture.get(); TextureSurface surf = new TextureSurface(iface.plat.graphics(), _defaultBatch, texture); surf.begin().clear(); layer.paint(surf); surf.end().close(); }
@Override public void onEmit (Button event) { Style.HAlign[] values = Style.HAlign.values(); Style.HAlign next = values[ (Style.HAlign.valueOf(halign.text.get()).ordinal() + 1) % values.length]; halign.text.update(next.name()); col = new ExposedColumn(next, col.isStretch(), col.weight(), col.minWidth()); } });