use of org.terasology.rendering.nui.layouts.miglayout.MigLayout 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);
}
}