Search in sources :

Example 21 with MenuItem

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

the class SceneEditorAddon method buildMenu.

@Override
public void buildMenu(MenuBar menuBar) {
    Menu mainMenu = new Menu("Scene Editor");
    MenuItem newProject = new MenuItem("New Project");
    mainMenu.addItem(newProject);
    MenuItem openProject = new MenuItem("Open Project");
    mainMenu.addItem(openProject);
    mainMenu.addSeparator();
    MenuItem projectSettings = new MenuItem("Project Settings");
    mainMenu.addItem(projectSettings);
    newProject.addListener(new ClickListener() {

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

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

        @Override
        public void clicked(InputEvent event, float x, float y) {
            super.clicked(event, x, y);
            if (TalosMain.Instance().ProjectController().getProject() == SE) {
                showSettingsDialog();
            }
        }
    });
    menuBar.addMenu(mainMenu);
}
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 22 with MenuItem

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

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

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

Example 25 with MenuItem

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

the class DirsSuggestionPopup method createRecentDirSuggestions.

private int createRecentDirSuggestions(Array<FileHandle> files, float width) {
    clearChildren();
    int suggestions = 0;
    for (final FileHandle file : files) {
        if (file.exists() == false)
            continue;
        MenuItem item = createMenuItem(file.path());
        item.getLabel().setEllipsis(true);
        item.getLabelCell().width(width - 20);
        addItem(item);
        item.addListener(new ChangeListener() {

            @Override
            public void changed(ChangeEvent event, Actor actor) {
                chooser.setDirectory(file, FileChooser.HistoryPolicy.ADD);
            }
        });
        suggestions++;
        if (suggestions == MAX_SUGGESTIONS) {
            break;
        }
    }
    return suggestions;
}
Also used : FileHandle(com.badlogic.gdx.files.FileHandle) Actor(com.badlogic.gdx.scenes.scene2d.Actor) MenuItem(com.kotcrab.vis.ui.widget.MenuItem) ChangeListener(com.badlogic.gdx.scenes.scene2d.utils.ChangeListener)

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