/** * Automatically connects {@code onPaint} to {@code paint} when {@code layer} is added to a scene * graph, and disconnects it when {@code layer} is removed. */ public static void bind (Layer layer, final Signal<Clock> paint, final Slot<Clock> onPaint) { layer.state.connectNotify(new Slot<Layer.State>() { public void onEmit (Layer.State state) { _pcon = Closeable.Util.close(_pcon); if (state == Layer.State.ADDED) _pcon = paint.connect(onPaint); } private Closeable _pcon = Closeable.Util.NOOP; }); }
/** * Automatically connects {@code onUpdate} to {@code update}, and {@code onPaint} to {@code * paint} when {@code layer} is added to a scene graph, and disconnects them when {@code layer} * is removed. */ public static void bind (Layer layer, final Signal<Clock> update, final Slot<Clock> onUpdate, final Signal<Clock> paint, final Slot<Clock> onPaint) { layer.state.connectNotify(new Slot<Layer.State>() { public void onEmit (Layer.State state) { _pcon = Closeable.Util.close(_pcon); _ucon = Closeable.Util.close(_ucon); if (state == Layer.State.ADDED) { _ucon = update.connect(onUpdate); _pcon = paint.connect(onPaint); } } private Closeable _ucon = Closeable.Util.NOOP, _pcon = Closeable.Util.NOOP; }); }
public Closeable connect () { return iconV.connectNotify(icon.slot()); } @Override public String toString () {
public Closeable connect () { return iconV.connectNotify(icon.slot()); } @Override public String toString () {
/** Convenience method to {@link ValueView#connectNotify} {@code slot} to {@link #isComplete}. * This is useful for binding the disabled state of UI elements to this future's completeness * (i.e. disabled while the future is incomplete, then reenabled when it is completed). * @return this future for chaining. */ public RFuture<T> bindComplete (SignalView.Listener<Boolean> slot) { isComplete().connectNotify(slot); return this; }
/** Convenience method to {@link ValueView#connectNotify} {@code slot} to {@link #isComplete}. * This is useful for binding the disabled state of UI elements to this future's completeness * (i.e. disabled while the future is incomplete, then reenabled when it is completed). * @return this future for chaining. */ public RFuture<T> bindComplete (SignalView.Listener<Boolean> slot) { isComplete().connectNotify(slot); return this; }
public Closeable connect () { return isVisibleV.connectNotify(visibleSlot()); } @Override public String toString () {
public Closeable connect () { return textV.connectNotify(text.slot()); } @Override public String toString () {
@Override public Closeable connect () { return isEnabledV.connectNotify(enabledSlot()); } @Override public String toString () {
/** Called when this screen will potentially be shown. * Should create main UI and prepare it for display. */ public void wake () { _flags |= AWAKE; closeOnSleep(_game.plat.graphics().deviceOrient.connectNotify( new Slot<Graphics.Orientation>() { public void onEmit (Graphics.Orientation orient) { _sizeValue.updateForce(size()); } })); }
public Closeable connect () { return textV.map(Functions.TO_STRING).connectNotify(text.slot()); } @Override public String toString () {
/** Called when a screen becomes the top screen, and is therefore made visible. */ public void wasShown () { closeOnHide(game().update.connect(update.slot())); closeOnHide(game().paint.connect(paint.slot())); closeOnHide(game().plat.graphics().deviceOrient.connectNotify( new Slot<Graphics.Orientation>() { public void onEmit (Graphics.Orientation orient) { _sizeValue.updateForce(size()); } })); }
root.addStyles(Style.BACKGROUND.is( Background.bordered(0xFFCCCCCC, 0xFF99CCFF, 5).inset(5, 10))); sizeValue().connectNotify(new Slot<IDimension>() { public void onEmit (IDimension size) { root.setSize(size);
@Override public void wasAdded () { super.wasAdded(); final Root root = iface.createRoot( AxisLayout.vertical().gap(0).offStretch(), stylesheet(), layer); root.addStyles(Style.BACKGROUND.is(background()), Style.VALIGN.top); sizeValue().connectNotify(new Slot<IDimension>() { public void onEmit (IDimension size) { root.setSize(size); } }); Background bg = Background.solid(0xFFCC99FF).inset(0, 0, 5, 0); root.add(new Group(AxisLayout.horizontal(), Style.HALIGN.left, Style.BACKGROUND.is(bg)).add( this.back = new Button("Back"), new Label(title()).addStyles(Style.FONT.is(TITLE_FONT), Style.HALIGN.center). setConstraint(AxisLayout.stretched()))); if (subtitle() != null) root.add(new Label(subtitle())); Group iface = createIface(root); if (iface != null) root.add(iface.setConstraint(AxisLayout.stretched())); }
toggle3.selected().map(new Function<Boolean,String>() { public String apply (Boolean selected) { return selected ? "Enabled" : "Disabled"; } }).connectNotify(disabled.text.slot());