use of org.terasology.rendering.nui.widgets.UIButton in project Terasology by MovingBlocks.
the class InputSettingsScreen method addInputBindRow.
private void addInputBindRow(SimpleUri uri, RegisterBindButton bind, ColumnLayout layout) {
BindsConfig bindConfig = bindsManager.getBindsConfig();
List<Input> binds = bindConfig.getBinds(uri);
UIButton primaryInputBind = new UIButton();
primaryInputBind.bindText(new BindingText(binds, 0));
primaryInputBind.subscribe(event -> {
ChangeBindingPopup popup = getManager().pushScreen(ChangeBindingPopup.ASSET_URI, ChangeBindingPopup.class);
popup.setBindingData(uri, bind, 0);
});
UIButton secondaryInputBind = new UIButton();
secondaryInputBind.bindText(new BindingText(binds, 1));
secondaryInputBind.subscribe(event -> {
ChangeBindingPopup popup = getManager().pushScreen(ChangeBindingPopup.ASSET_URI, ChangeBindingPopup.class);
popup.setBindingData(uri, bind, 1);
});
layout.addWidget(new RowLayout(new UILabel(translationSystem.translate(bind.description())), primaryInputBind, secondaryInputBind).setColumnRatios(0.4f).setHorizontalSpacing(horizontalSpacing));
}
use of org.terasology.rendering.nui.widgets.UIButton in project Terasology by MovingBlocks.
the class PropertyLayout method addProperties.
/**
* Adds a provider for properties to this layout. All properties appears in a list that may be collapsed/expanded.
* Initially the list is expanded.
*/
public void addProperties(String groupLabel, final Collection<Property<?, ?>> properties) {
if (properties.size() > 0) {
final UIButton expand = new UIButton("", "-");
expand.setTooltip("Click to collapse");
final UILabel headline = new UILabel(groupLabel);
final MigLayout layout = new MigLayout();
layout.setColConstraints("[min][fill]");
layout.setRowConstraints("[min]");
expand.subscribe(widget -> {
UIButton button = (UIButton) widget;
if ("-".equals(button.getText())) {
layout.clear();
invalidate();
button.setText("+");
button.setTooltip("Click to expand");
} else {
expand(properties, layout);
button.setText("-");
button.setTooltip("Click to collapse");
}
});
addWidget(expand, new CCHint("newline, w 45!, h 22!"));
addWidget(headline, new CCHint());
addWidget(layout, new CCHint("newline, spanx 2"));
expand(properties, layout);
}
}
Aggregations