Search in sources :

Example 11 with PopupMenu

use of com.kotcrab.vis.ui.widget.PopupMenu in project HyperLap2D by rednblackgames.

the class NodeEditorDialog method createGraphPopupMenu.

private H2DPopupMenu createGraphPopupMenu(final float popupX, final float popupY) {
    H2DPopupMenu popupMenu = new H2DPopupMenu();
    for (final GraphBoxProducer<ActionFieldType> producer : graphBoxProducers) {
        if (producer.isUnique())
            continue;
        String menuLocation = producer.getMenuLocation();
        if (menuLocation != null) {
            String[] menuSplit = menuLocation.split("/");
            PopupMenu targetMenu = findOrCreatePopupMenu(popupMenu, menuSplit, 0);
            final String title = producer.getName();
            MenuItem valueMenuItem = new MenuItem(title);
            valueMenuItem.addListener(new ClickListener(Input.Buttons.LEFT) {

                @Override
                public void clicked(InputEvent event, float x, float y) {
                    String id = UUID.randomUUID().toString().replace("-", "");
                    GraphBox<ActionFieldType> graphBox = producer.createDefault(skin, id);
                    graphContainer.addGraphBox(graphBox, title, true, popupX, popupY);
                }
            });
            targetMenu.addItem(valueMenuItem);
        }
    }
    return popupMenu;
}
Also used : ActionFieldType(games.rednblack.editor.graph.actions.ActionFieldType) H2DPopupMenu(games.rednblack.h2d.common.view.ui.widget.H2DPopupMenu) MenuItem(com.kotcrab.vis.ui.widget.MenuItem) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) ClickListener(com.badlogic.gdx.scenes.scene2d.utils.ClickListener) H2DPopupMenu(games.rednblack.h2d.common.view.ui.widget.H2DPopupMenu) PopupMenu(com.kotcrab.vis.ui.widget.PopupMenu)

Aggregations

MenuItem (com.kotcrab.vis.ui.widget.MenuItem)11 PopupMenu (com.kotcrab.vis.ui.widget.PopupMenu)11 InputEvent (com.badlogic.gdx.scenes.scene2d.InputEvent)6 ClickListener (com.badlogic.gdx.scenes.scene2d.utils.ClickListener)6 Vector2 (com.badlogic.gdx.math.Vector2)4 Actor (com.badlogic.gdx.scenes.scene2d.Actor)4 Array (com.badlogic.gdx.utils.Array)3 Color (com.badlogic.gdx.graphics.Color)2 ChangeListener (com.badlogic.gdx.scenes.scene2d.utils.ChangeListener)2 ColorPickerAdapter (com.kotcrab.vis.ui.widget.color.ColorPickerAdapter)2 EditableLabel (com.talosvfx.talos.editor.widgets.ui.EditableLabel)2 H2DPopupMenu (games.rednblack.h2d.common.view.ui.widget.H2DPopupMenu)2 FileHandle (com.badlogic.gdx.files.FileHandle)1 OrthographicCamera (com.badlogic.gdx.graphics.OrthographicCamera)1 Rectangle (com.badlogic.gdx.math.Rectangle)1 Image (com.badlogic.gdx.scenes.scene2d.ui.Image)1 ImageButton (com.badlogic.gdx.scenes.scene2d.ui.ImageButton)1 XmlReader (com.badlogic.gdx.utils.XmlReader)1 InputValidator (com.kotcrab.vis.ui.util.InputValidator)1 InputDialogListener (com.kotcrab.vis.ui.util.dialog.InputDialogListener)1