/** Create a selector with a null initial selection. */ public Selector () { selected.connect(new ValueView.Listener<Element<?>> () { @Override public void onChange (Element<?> selected, Element<?> deselected) { if (deselected != null) get(deselected).update(false); if (selected != null) get(selected).update(true); } }); }
/** Creates a sound board which will play sounds via {@code plat} and connect to {@code paint} * to receive per-frame updates. */ public SoundBoard (Platform plat, Signal<Clock> paint) { this.plat = plat; paint.connect(new Slot<Clock>() { public void onEmit (Clock clock) { update(clock.dt); } }); volume.connect(new Slot<Float>() { @Override public void onEmit (Float volume) { for (LoopImpl active : _active) active.updateVolume(volume); }}); muted.connect(new Slot<Boolean>() { @Override public void onEmit (Boolean muted) { for (LoopImpl active : _active) active.fadeForMute(muted); }}); }
protected CheckBox (char checkChar, Icon checkIcon) { _checkStr = String.valueOf(checkChar); _checkIcon = checkIcon; selected().connect(new Slot<Boolean> () { @Override public void onEmit (Boolean checked) { updateCheckViz(checked); } }); }
public Toggle (T owner) { super(owner); selected.connect(selectedDidChange()); }
public Slider (float value, float min, float max) { this.value = Value.create(value); range = Value.create(new Range(min, max)); // update our display if the slider value is changed externally UnitSlot updateThumb = new UnitSlot () { @Override public void onEmit () { updateThumb(); }}; this.value.connect(updateThumb); range.connect(updateThumb); }
/** * Creates a new menu item with the given label and icon. */ public MenuItem (String label, Icon icon) { this.text.update(label); this.text.connect(textDidChange()); // update after connect so we trigger iconDidChange, in case our icon is a not-ready-image this.icon.connect(iconDidChange()); this.icon.update(icon); }
/** Creates a label with the supplied text and icon. */ public Label (String text, Icon icon) { this.text.update(text); this.text.connect(textDidChange()); // update after connect so we trigger iconDidChange, in case our icon is a not-ready-image this.icon.connect(iconDidChange()); this.icon.update(icon); }
/** * Exposes the specified property as a {@link Value}. The supplied default value will be used * if the property has no current value. Updates to the value will be written back to the * storage system. Note that each call to this method yields a new {@link Value} and those * values will not coordinate with one another, so the caller must be sure to only call this * method once for a given property and share that value properly. */ public <E extends Enum<E>> Value<E> valueFor (final String key, E defval) { Value<E> value = Value.create(get(key, defval)); value.connect(new Slot<E>() { @Override public void onEmit (E value) { set(key, value); } }); return value; }
/** * Exposes the specified property as a {@link Value}. The supplied default value will be used * if the property has no current value. Updates to the value will be written back to the * storage system. Note that each call to this method yields a new {@link Value} and those * values will not coordinate with one another, so the caller must be sure to only call this * method once for a given property and share that value properly. */ public Value<String> valueFor (final String key, String defval) { Value<String> value = Value.create(get(key, defval)); value.connect(new Slot<String>() { @Override public void onEmit (String value) { set(key, value); } }); return value; }
/** * Exposes the specified property as a {@link Value}. The supplied default value will be used * if the property has no current value. Updates to the value will be written back to the * storage system. Note that each call to this method yields a new {@link Value} and those * values will not coordinate with one another, so the caller must be sure to only call this * method once for a given property and share that value properly. */ public Value<Long> valueFor (final String key, long defval) { Value<Long> value = Value.create(get(key, defval)); value.connect(new Slot<Long>() { @Override public void onEmit (Long value) { set(key, value); } }); return value; }
/** * Exposes the specified property as a {@link Value}. The supplied default value will be used * if the property has no current value. Updates to the value will be written back to the * storage system. Note that each call to this method yields a new {@link Value} and those * values will not coordinate with one another, so the caller must be sure to only call this * method once for a given property and share that value properly. */ public Value<Double> valueFor (final String key, double defval) { Value<Double> value = Value.create(get(key, defval)); value.connect(new Slot<Double>() { @Override public void onEmit (Double value) { set(key, value); } }); return value; }
/** * Exposes the specified property as a {@link Value}. The supplied default value will be used * if the property has no current value. Updates to the value will be written back to the * storage system. Note that each call to this method yields a new {@link Value} and those * values will not coordinate with one another, so the caller must be sure to only call this * method once for a given property and share that value properly. */ public Value<Boolean> valueFor (final String key, boolean defval) { Value<Boolean> value = Value.create(get(key, defval)); value.connect(new Slot<Boolean>() { @Override public void onEmit (Boolean value) { set(key, value); } }); return value; }
public BoxPointWidget (String label) { setLayout(AxisLayout.vertical()); initChildren(new Label(label), new Group(AxisLayout.horizontal()).add(new Label("N:"), nx, ny), new Group(AxisLayout.horizontal()).add(new Label("O:"), ox, oy)); UnitSlot update = new UnitSlot() { @Override public void onEmit () { point.update(new BoxPoint( nx.value.get(), ny.value.get(), ox.value.get(), oy.value.get())); } }; nx.value.connect(update); ny.value.connect(update); ox.value.connect(update); oy.value.connect(update); addStyles(Style.BACKGROUND.is(Background.solid(Colors.LIGHT_GRAY))); }
ColumnEditor () { super(new FlowLayout()); add(slider("Weight:", weight), slider("Min Width:", minWidth), stretch, halign); stretch.selected().update(col.isStretch()); weight.value.connect(new Slot<Float>() { @Override public void onEmit (Float event) { col = new ExposedColumn(col.halign(), col.isStretch(), event, col.minWidth()); } }); minWidth.value.connect(new Slot<Float>() { @Override public void onEmit (Float event) { col = new ExposedColumn(col.halign(), col.isStretch(), col.weight(), event); } }); stretch.selected().connect(new Slot<Boolean>() { @Override public void onEmit (Boolean event) { col = new ExposedColumn(col.halign(), event, col.weight(), col.minWidth()); } }); halign.clicked().connect(new Slot<Button>() { @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()); } }); } }
protected Group hookup (String name, Selector sel) { final Label label = new Label(); sel.selected.connect(new Slot<Element<?>>() { @Override public void onEmit (Element<?> event) { update(label, (ToggleButton)event); } }); update(label, (ToggleButton)sel.selected.get()); return new Group(AxisLayout.horizontal()).add(new Label(name), label); }
public Field (String initialText, Styles styles) { setStyles(styles); text = Value.create(""); _finishedEditing = Signal.create(); if (hasNative()) { _finishedEditing.connect(new Slot<Boolean>() { @Override public void onEmit (Boolean event) { if (!_fullTimeNative) updateMode(false); } }); } this.text.update(initialText); this.text.connect(textDidChange()); }
@Override public Menu createMenu () { final PagedMenu menu = new PagedMenu(AxisLayout.vertical(), 32); final Slider slider = new Slider().setIncrement(1); slider.value.connect(new Slot<Float>() { @Override public void onEmit (Float val) { menu.setPage(FloatMath.round(val));