Search in sources :

Example 11 with MenuItem

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

the class ShaderAddon method buildMenu.

@Override
public void buildMenu(MenuBar menuBar) {
    Menu menu = new Menu("Shader Graph");
    MenuItem newFile = new MenuItem("New Shader");
    menu.addItem(newFile);
    MenuItem openFile = new MenuItem("Open Shader");
    menu.addItem(openFile);
    MenuItem exportRaw = new MenuItem("Export RAW");
    menu.addItem(exportRaw);
    MenuItem exportPNG = new MenuItem("Export PNG");
    menu.addItem(exportPNG);
    MenuItem exportSequence = new MenuItem("Export Sequence");
    menu.addItem(exportSequence);
    newFile.addListener(new ClickListener() {

        @Override
        public void clicked(InputEvent event, float x, float y) {
            TalosMain.Instance().ProjectController().newProject(SHADER_PROJECT);
        }
    });
    openFile.addListener(new ClickListener() {

        @Override
        public void clicked(InputEvent event, float x, float y) {
            super.clicked(event, x, y);
            TalosMain.Instance().UIStage().openProjectAction(SHADER_PROJECT);
        }
    });
    exportRaw.addListener(new ClickListener() {

        @Override
        public void clicked(InputEvent event, float x, float y) {
            super.clicked(event, x, y);
            // export RAW logic
            TalosMain.Instance().UIStage().showSaveFileChooser(".frag", new FileChooserAdapter() {

                @Override
                public void selected(Array<FileHandle> files) {
                    String fragShader = ((ShaderNodeStage) (nodeStage)).getFragShader();
                    FileHandle file = files.get(0);
                    file.writeString(fragShader, false);
                }
            });
        }
    });
    exportPNG.addListener(new ClickListener() {

        @Override
        public void clicked(InputEvent event, float x, float y) {
            super.clicked(event, x, y);
            // export RAW logic
            TalosMain.Instance().UIStage().showSaveFileChooser(".png", new FileChooserAdapter() {

                @Override
                public void selected(Array<FileHandle> files) {
                    FileHandle file = files.get(0);
                    Pixmap pixmap = ((ShaderNodeStage) (nodeStage)).exportPixmap();
                    if (pixmap != null) {
                        PixmapIO.writePNG(file, pixmap);
                        pixmap.dispose();
                    }
                }
            });
        }
    });
    exportSequence.addListener(new ClickListener() {

        @Override
        public void clicked(InputEvent event, float x, float y) {
            super.clicked(event, x, y);
            TalosMain.Instance().UIStage().getStage().addActor(exportSequenceDialog.fadeIn());
        }
    });
    menuBar.addMenu(menu);
}
Also used : Array(com.badlogic.gdx.utils.Array) ShaderNodeStage(com.talosvfx.talos.editor.addons.shader.workspace.ShaderNodeStage) FileHandle(com.badlogic.gdx.files.FileHandle) FileChooserAdapter(com.kotcrab.vis.ui.widget.file.FileChooserAdapter) MenuItem(com.kotcrab.vis.ui.widget.MenuItem) Menu(com.kotcrab.vis.ui.widget.Menu) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) ClickListener(com.badlogic.gdx.scenes.scene2d.utils.ClickListener) Pixmap(com.badlogic.gdx.graphics.Pixmap)

Example 12 with MenuItem

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

the class UIStage method initExampleList.

public void initExampleList(PopupMenu examples) {
    FileHandle list = Gdx.files.internal("samples/list.xml");
    XmlReader xmlReader = new XmlReader();
    XmlReader.Element root = xmlReader.parse(list);
    Array<XmlReader.Element> samples = root.getChildrenByName("sample");
    for (XmlReader.Element sample : samples) {
        String name = sample.getAttribute("name");
        final String fileName = sample.getAttribute("file");
        MenuItem item = new MenuItem(name);
        examples.addItem(item);
        item.addListener(new ClickListener() {

            @Override
            public void clicked(InputEvent event, float x, float y) {
                super.clicked(event, x, y);
                // openProject(fileName);
                TalosMain.Instance().ProjectController().lastDirTrackingDisable();
                TalosMain.Instance().ProjectController().setProject(ProjectController.TLS);
                TalosMain.Instance().ProjectController().loadProject(Gdx.files.internal("samples/" + fileName));
                TalosMain.Instance().ProjectController().lastDirTrackingEnable();
                TalosMain.Instance().ProjectController().unbindFromFile();
            }
        });
    }
}
Also used : FileHandle(com.badlogic.gdx.files.FileHandle) MenuItem(com.kotcrab.vis.ui.widget.MenuItem) XmlReader(com.badlogic.gdx.utils.XmlReader) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) ClickListener(com.badlogic.gdx.scenes.scene2d.utils.ClickListener)

Example 13 with MenuItem

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

the class BvBAddon method buildMenu.

@Override
public void buildMenu(MenuBar menuBar) {
    Menu bvbMenu = new Menu("Animations");
    MenuItem newBvbProject = new MenuItem("New Project");
    bvbMenu.addItem(newBvbProject);
    MenuItem openBvbProject = new MenuItem("Open Project");
    bvbMenu.addItem(openBvbProject);
    // TODO: add other menu items here
    newBvbProject.addListener(new ClickListener() {

        @Override
        public void clicked(InputEvent event, float x, float y) {
            super.clicked(event, x, y);
            TalosMain.Instance().ProjectController().newProject(BVB);
        }
    });
    openBvbProject.addListener(new ClickListener() {

        @Override
        public void clicked(InputEvent event, float x, float y) {
            super.clicked(event, x, y);
            TalosMain.Instance().UIStage().openProjectAction(BVB);
        }
    });
    menuBar.addMenu(bvbMenu);
}
Also used : MenuItem(com.kotcrab.vis.ui.widget.MenuItem) Menu(com.kotcrab.vis.ui.widget.Menu) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) ClickListener(com.badlogic.gdx.scenes.scene2d.utils.ClickListener)

Example 14 with MenuItem

use of com.kotcrab.vis.ui.widget.MenuItem 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 15 with MenuItem

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

the class TestApplication method createMenus.

private void createMenus() {
    Menu fileMenu = new Menu("File");
    Menu editMenu = new Menu("Edit");
    Menu windowMenu = new Menu("Window");
    Menu helpMenu = new Menu("Help");
    fileMenu.addItem(createTestsMenu());
    fileMenu.addItem(new MenuItem("menuitem #1"));
    fileMenu.addItem(new MenuItem("menuitem #2").setShortcut("f1"));
    fileMenu.addItem(new MenuItem("menuitem #3").setShortcut("f2"));
    fileMenu.addItem(new MenuItem("menuitem #4").setShortcut("alt + f4"));
    MenuItem subMenuItem = new MenuItem("submenu #1");
    subMenuItem.setShortcut("alt + insert");
    subMenuItem.setSubMenu(createSubMenu());
    fileMenu.addItem(subMenuItem);
    MenuItem subMenuItem2 = new MenuItem("submenu #2");
    subMenuItem2.setSubMenu(createSubMenu());
    fileMenu.addItem(subMenuItem2);
    MenuItem subMenuItem3 = new MenuItem("submenu disabled");
    subMenuItem3.setDisabled(true);
    subMenuItem3.setSubMenu(createSubMenu());
    fileMenu.addItem(subMenuItem3);
    // ---
    editMenu.addItem(new MenuItem("menuitem #5"));
    editMenu.addItem(new MenuItem("menuitem #6"));
    editMenu.addSeparator();
    editMenu.addItem(new MenuItem("menuitem #7"));
    editMenu.addItem(new MenuItem("menuitem #8"));
    editMenu.addItem(createDoubleNestedMenu());
    MenuItem disabledItem = new MenuItem("disabled menuitem");
    disabledItem.setDisabled(true);
    MenuItem disabledItem2 = new MenuItem("disabled menuitem shortcut").setShortcut("alt + f4");
    disabledItem2.setDisabled(true);
    editMenu.addItem(disabledItem);
    editMenu.addItem(disabledItem2);
    windowMenu.addItem(new MenuItem("menuitem #9"));
    windowMenu.addItem(new MenuItem("menuitem #10"));
    windowMenu.addItem(new MenuItem("menuitem #11"));
    windowMenu.addSeparator();
    windowMenu.addItem(new MenuItem("menuitem #12"));
    helpMenu.addItem(new MenuItem("about", new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {
            Dialogs.showOKDialog(stage, "about", "visui test application");
        }
    }));
    menuBar.addMenu(fileMenu);
    menuBar.addMenu(editMenu);
    menuBar.addMenu(windowMenu);
    menuBar.addMenu(helpMenu);
}
Also used : MenuItem(com.kotcrab.vis.ui.widget.MenuItem) ChangeListener(com.badlogic.gdx.scenes.scene2d.utils.ChangeListener) Menu(com.kotcrab.vis.ui.widget.Menu) PopupMenu(com.kotcrab.vis.ui.widget.PopupMenu)

Aggregations

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