Search in sources :

Example 11 with UIButton

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));
}
Also used : UILabel(org.terasology.rendering.nui.widgets.UILabel) Input(org.terasology.input.Input) UIButton(org.terasology.rendering.nui.widgets.UIButton) RowLayout(org.terasology.rendering.nui.layouts.RowLayout) BindsConfig(org.terasology.config.BindsConfig)

Example 12 with UIButton

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);
    }
}
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

UIButton (org.terasology.rendering.nui.widgets.UIButton)12 UILabel (org.terasology.rendering.nui.widgets.UILabel)8 ReadOnlyBinding (org.terasology.rendering.nui.databinding.ReadOnlyBinding)4 UIText (org.terasology.rendering.nui.widgets.UIText)4 ResourceUrn (org.terasology.assets.ResourceUrn)3 Component (java.awt.Component)2 File (java.io.File)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 JDialog (javax.swing.JDialog)2 JFileChooser (javax.swing.JFileChooser)2 LookAndFeel (javax.swing.LookAndFeel)2 UnsupportedLookAndFeelException (javax.swing.UnsupportedLookAndFeelException)2 FileNameExtensionFilter (javax.swing.filechooser.FileNameExtensionFilter)2 AssetDataFile (org.terasology.assets.format.AssetDataFile)2 ServerInfo (org.terasology.config.ServerInfo)2 DependencyResolver (org.terasology.module.DependencyResolver)2 Module (org.terasology.module.Module)2 Canvas (org.terasology.rendering.nui.Canvas)2 NUIEditorMenuTreeBuilder (org.terasology.rendering.nui.editor.utils.NUIEditorMenuTreeBuilder)2