Search in sources :

Example 6 with PopupMenu

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

the class TestApplication method createSubMenu.

private PopupMenu createSubMenu() {
    PopupMenu menu = new PopupMenu();
    menu.addItem(new MenuItem("submenuitem #1"));
    menu.addItem(new MenuItem("submenuitem #2"));
    menu.addSeparator();
    menu.addItem(new MenuItem("submenuitem #3"));
    menu.addItem(new MenuItem("submenuitem #4"));
    return menu;
}
Also used : MenuItem(com.kotcrab.vis.ui.widget.MenuItem) PopupMenu(com.kotcrab.vis.ui.widget.PopupMenu)

Example 7 with PopupMenu

use of com.kotcrab.vis.ui.widget.PopupMenu in project talos by rockbite.

the class NodeGroup method init.

public void init(Skin skin) {
    this.skin = skin;
    frameImage = new Image(skin.getDrawable("group_frame"));
    frameImage.setColor(44 / 255f, 140 / 255f, 209 / 255f, 1f);
    addActor(frameImage);
    topHit = new Actor();
    topHit.setTouchable(Touchable.enabled);
    addActor(topHit);
    title = new EditableLabel("GROUP NAME", skin);
    addActor(title);
    settings = new ImageButton(skin, "settings");
    settings.setSize(25, 25);
    addActor(settings);
    settings.addListener(new ClickListener() {

        @Override
        public void clicked(InputEvent event, float x, float y) {
            final Vector2 vec = new Vector2(Gdx.input.getX(), Gdx.input.getY());
            (TalosMain.Instance().UIStage().getStage().getViewport()).unproject(vec);
            settingsPopup.showMenu(TalosMain.Instance().UIStage().getStage(), vec.x, vec.y);
        }
    });
    settingsPopup = new PopupMenu();
    MenuItem changeColorMenuItem = new MenuItem("Change Color");
    MenuItem ungroupMenuItem = new MenuItem("Ungroup");
    settingsPopup.addItem(changeColorMenuItem);
    settingsPopup.addItem(ungroupMenuItem);
    changeColorMenuItem.addListener(new ClickListener() {

        @Override
        public void clicked(InputEvent event, float x, float y) {
            TalosMain.Instance().UIStage().showColorPicker(new ColorPickerAdapter() {

                @Override
                public void changed(Color newColor) {
                    super.changed(newColor);
                    frameImage.setColor(newColor);
                }
            });
        }
    });
    ungroupMenuItem.addListener(new ClickListener() {

        @Override
        public void clicked(InputEvent event, float x, float y) {
            super.clicked(event, x, y);
            nodeBoard.removeGroup(NodeGroup.this);
        }
    });
    topHit.addListener(new ClickListener() {

        Vector2 tmp = new Vector2();

        Vector2 pos = new Vector2();

        Vector2 diff = new Vector2();

        @Override
        public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            pos.set(x, y);
            topHit.localToStageCoordinates(pos);
            nodeBoard.setSelectedNodes(nodes);
            return true;
        }

        @Override
        public void touchDragged(InputEvent event, float x, float y, int pointer) {
            tmp.set(x, y);
            topHit.localToStageCoordinates(tmp);
            diff.set(tmp).sub(pos);
            moveGroupBy(diff.x, diff.y);
            pos.set(tmp);
            super.touchDragged(event, x, y, pointer);
        }

        @Override
        public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
            event.cancel();
        }
    });
    setTouchable(Touchable.childrenOnly);
    frameImage.setTouchable(Touchable.disabled);
}
Also used : Color(com.badlogic.gdx.graphics.Color) MenuItem(com.kotcrab.vis.ui.widget.MenuItem) Image(com.badlogic.gdx.scenes.scene2d.ui.Image) EditableLabel(com.talosvfx.talos.editor.widgets.ui.EditableLabel) ImageButton(com.badlogic.gdx.scenes.scene2d.ui.ImageButton) Vector2(com.badlogic.gdx.math.Vector2) Actor(com.badlogic.gdx.scenes.scene2d.Actor) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) ColorPickerAdapter(com.kotcrab.vis.ui.widget.color.ColorPickerAdapter) ClickListener(com.badlogic.gdx.scenes.scene2d.utils.ClickListener) PopupMenu(com.kotcrab.vis.ui.widget.PopupMenu)

Example 8 with PopupMenu

use of com.kotcrab.vis.ui.widget.PopupMenu in project talos by rockbite.

the class UIStage method createModuleListPopup.

public PopupMenu createModuleListPopup() {
    OrthographicCamera cam = (OrthographicCamera) TalosMain.Instance().NodeStage().getStage().getCamera();
    Vector2 location = new Vector2(cam.position.x, cam.position.y);
    PopupMenu menu = new PopupMenu();
    Array<Class> temp = new Array<>();
    for (Class registeredModule : ParticleEmitterDescriptor.getRegisteredModules()) {
        temp.add(registeredModule);
    }
    temp.sort(new Comparator<Class>() {

        @Override
        public int compare(Class o1, Class o2) {
            return o1.getSimpleName().compareTo(o2.getSimpleName());
        }
    });
    for (final Class clazz : temp) {
        String className = clazz.getSimpleName();
        MenuItem menuItem = new MenuItem(className);
        menu.addItem(menuItem);
        final Vector2 finalLocation = location;
        menuItem.addListener(new ClickListener() {

            @Override
            public void clicked(InputEvent event, float x, float y) {
                TalosMain.Instance().NodeStage().moduleBoardWidget.createModule(clazz, finalLocation.x, finalLocation.y);
            }
        });
    }
    return menu;
}
Also used : OrthographicCamera(com.badlogic.gdx.graphics.OrthographicCamera) MenuItem(com.kotcrab.vis.ui.widget.MenuItem) Array(com.badlogic.gdx.utils.Array) Vector2(com.badlogic.gdx.math.Vector2) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) ClickListener(com.badlogic.gdx.scenes.scene2d.utils.ClickListener) PopupMenu(com.kotcrab.vis.ui.widget.PopupMenu)

Example 9 with PopupMenu

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

the class TestApplication method createTestsMenu.

private MenuItem createTestsMenu() {
    MenuItem item = new MenuItem("start test");
    PopupMenu menu = new PopupMenu();
    menu.addItem(new MenuItem("tabbed pane", new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {
            stage.addActor(new TestTabbedPane(false));
        }
    }));
    menu.addItem(new MenuItem("tabbed pane (vertical)", new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {
            stage.addActor(new TestTabbedPane(true));
        }
    }));
    menu.addItem(new MenuItem("flow groups", new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {
            stage.addActor(new TestFlowGroup());
        }
    }));
    menu.addItem(new MenuItem("button bar", new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {
            stage.addActor(new TestButtonBar());
        }
    }));
    menu.addItem(new MenuItem("list view", new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {
            stage.addActor(new TestListView());
        }
    }));
    menu.addItem(new MenuItem("toasts", new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {
            stage.addActor(new TestToasts(stage));
        }
    }));
    menu.addItem(new MenuItem("highlight textarea", new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {
            stage.addActor(new TestHighlightTextArea());
        }
    }));
    menu.addItem(new MenuItem("busybar", new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {
            stage.addActor(new TestBusyBar());
        }
    }));
    menu.addItem(new MenuItem("multisplitpane", new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {
            stage.addActor(new TestMultiSplitPane());
        }
    }));
    menu.addItem(new MenuItem("generate disabled image", new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {
            stage.addActor(new TestGenerateDisabledImage());
        }
    }));
    menu.addSeparator();
    menu.addItem(new MenuItem("test issue #131", new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {
            stage.addActor(new TestIssue131());
        }
    }));
    menu.addItem(new MenuItem("test issue #326", new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {
            stage.addActor(new TestIssue326());
        }
    }));
    item.setSubMenu(menu);
    return item;
}
Also used : MenuItem(com.kotcrab.vis.ui.widget.MenuItem) ChangeListener(com.badlogic.gdx.scenes.scene2d.utils.ChangeListener) PopupMenu(com.kotcrab.vis.ui.widget.PopupMenu)

Example 10 with PopupMenu

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

the class TestApplication method createDoubleNestedMenu.

private MenuItem createDoubleNestedMenu() {
    MenuItem doubleNestedMenuItem = new MenuItem("submenu nested x2");
    doubleNestedMenuItem.setSubMenu(createSubMenu());
    PopupMenu nestedMenu = new PopupMenu();
    nestedMenu.addItem(doubleNestedMenuItem);
    nestedMenu.addItem(new MenuItem("single nested"));
    MenuItem menuItem = new MenuItem("submenu nested");
    menuItem.setSubMenu(nestedMenu);
    return menuItem;
}
Also used : MenuItem(com.kotcrab.vis.ui.widget.MenuItem) 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