Search in sources :

Example 1 with MigLayout

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);
    }
}
Also used : UILabel(org.terasology.rendering.nui.widgets.UILabel) UIButton(org.terasology.rendering.nui.widgets.UIButton) MigLayout(org.terasology.rendering.nui.layouts.miglayout.MigLayout)

Aggregations

MigLayout (org.terasology.rendering.nui.layouts.miglayout.MigLayout)1 UIButton (org.terasology.rendering.nui.widgets.UIButton)1 UILabel (org.terasology.rendering.nui.widgets.UILabel)1