Search in sources :

Example 1 with MenuItem

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

the class NodeEditorDialog method findOrCreatePopupMenu.

private PopupMenu findOrCreatePopupMenu(PopupMenu popupMenu, String[] menuSplit, int startIndex) {
    for (Actor child : popupMenu.getChildren()) {
        MenuItem childMenuItem = (MenuItem) child;
        if (childMenuItem.getLabel().getText().toString().equals(menuSplit[startIndex]) && childMenuItem.getSubMenu() != null) {
            if (startIndex + 1 < menuSplit.length) {
                return findOrCreatePopupMenu(childMenuItem.getSubMenu(), menuSplit, startIndex + 1);
            } else {
                return childMenuItem.getSubMenu();
            }
        }
    }
    PopupMenu createdPopup = new H2DPopupMenu();
    MenuItem createdMenuItem = new MenuItem(menuSplit[startIndex]);
    createdMenuItem.setSubMenu(createdPopup);
    popupMenu.addItem(createdMenuItem);
    if (startIndex + 1 < menuSplit.length) {
        return findOrCreatePopupMenu(createdPopup, menuSplit, startIndex + 1);
    } else {
        return createdPopup;
    }
}
Also used : Actor(com.badlogic.gdx.scenes.scene2d.Actor) H2DPopupMenu(games.rednblack.h2d.common.view.ui.widget.H2DPopupMenu) MenuItem(com.kotcrab.vis.ui.widget.MenuItem) H2DPopupMenu(games.rednblack.h2d.common.view.ui.widget.H2DPopupMenu) PopupMenu(com.kotcrab.vis.ui.widget.PopupMenu)

Example 2 with MenuItem

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

the class UIDropDownMenu method initView.

private void initView() {
    clear();
    for (int i = 0; i < currentActionList.size; i++) {
        String itemName = actionNames.get(currentActionList.get(i));
        MenuItem menuItem = new MenuItem(itemName, new MenuItemListener(ITEM_CLICKED, currentActionList.get(i)));
        addItem(menuItem);
    }
}
Also used : MenuItem(com.kotcrab.vis.ui.widget.MenuItem) MenuItemListener(games.rednblack.editor.event.MenuItemListener)

Example 3 with MenuItem

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

the class FileMenu method reInitRecent.

public void reInitRecent(ArrayList<String> paths) {
    if (recentProjectsMenuItems == null || recentProjectsPopupMenu == null)
        return;
    if (recentProjectsMenuItems.size != 0) {
        recentProjectsMenuItems.clear();
    }
    if (recentProjectsPopupMenu.hasChildren()) {
        recentProjectsPopupMenu.remove();
        recentProjectsPopupMenu.clearChildren();
    }
    addRecent(paths);
    if (paths.size() > 0) {
        recentProjectsPopupMenu.addSeparator();
    }
    MenuItem menuItem = new MenuItem("Clear history", new MenuItemListener(CLEAR_RECENT, null, FILE_MENU));
    recentProjectsMenuItems.add(menuItem);
    recentProjectsPopupMenu.addItem(menuItem);
    remove();
}
Also used : MenuItem(com.kotcrab.vis.ui.widget.MenuItem) MenuItemListener(games.rednblack.editor.event.MenuItemListener)

Example 4 with MenuItem

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

the class HyperLap2DMenuBar method addMenuItem.

public void addMenuItem(String menu, String subMenuName, String notificationName) {
    if (menu.equals(MenuAPI.FILE_MENU)) {
        fileMenu.addSeparator();
        fileMenu.addItem(new MenuItem(subMenuName, new MenuItemListener(notificationName, null, menu)));
    }
    if (menu.equals(MenuAPI.EDIT_MENU)) {
        editMenu.addSeparator();
        editMenu.addItem(new MenuItem(subMenuName, new MenuItemListener(notificationName, null, menu)));
    }
    if (menu.equals(MenuAPI.RESOURCE_MENU)) {
        resourcesMenu.addSeparator();
        resourcesMenu.addItem(new MenuItem(subMenuName, new MenuItemListener(notificationName, null, menu)));
    }
    if (menu.equals(MenuAPI.WINDOW_MENU)) {
        windowMenu.addSeparator();
        windowMenu.addItem(new MenuItem(subMenuName, new MenuItemListener(notificationName, null, menu)));
    }
    if (menu.equals(MenuAPI.HELP_MENU)) {
        helpMenu.addSeparator();
        helpMenu.addItem(new MenuItem(subMenuName, new MenuItemListener(notificationName, null, menu)));
    }
}
Also used : MenuItem(com.kotcrab.vis.ui.widget.MenuItem) MenuItemListener(games.rednblack.editor.event.MenuItemListener)

Example 5 with MenuItem

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

the class StickyNoteActor method showPopupMenu.

private void showPopupMenu() {
    H2DPopupMenu popupMenu = new H2DPopupMenu();
    MenuItem rename = new MenuItem("Remove note");
    rename.addListener(new ClickListener(Input.Buttons.LEFT) {

        @Override
        public void clicked(InputEvent event, float x, float y) {
            facade.sendNotification(MsgAPI.ACTION_REMOVE_STICKY_NOTE, id);
        }
    });
    popupMenu.addItem(rename);
    MenuItem changeColor = new MenuItem("Change color");
    changeColor.addListener(new ClickListener(Input.Buttons.LEFT) {

        boolean init = false;

        @Override
        public void clicked(InputEvent event, float x, float y) {
            ColorPicker picker = new HyperLapColorPicker(new ColorPickerAdapter() {

                @Override
                public void finished(Color newColor) {
                    setColor(newColor);
                    StickyNoteVO payload = ModifyStickyNoteCommand.payload(StickyNoteActor.this);
                    facade.sendNotification(MsgAPI.ACTION_MODIFY_STICKY_NOTE, payload);
                }

                @Override
                public void changed(Color newColor) {
                    if (init)
                        setColor(newColor);
                }
            });
            init = true;
            picker.setColor(getColor());
            Sandbox.getInstance().getUIStage().addActor(picker.fadeIn());
        }
    });
    popupMenu.addItem(changeColor);
    Sandbox sandbox = Sandbox.getInstance();
    UIStage uiStage = sandbox.getUIStage();
    popupMenu.showMenu(Sandbox.getInstance().getUIStage(), sandbox.getInputX(), uiStage.getHeight() - sandbox.getInputY());
}
Also used : UIStage(games.rednblack.editor.view.stage.UIStage) HyperLapColorPicker(games.rednblack.h2d.common.view.ui.widget.HyperLapColorPicker) ColorPicker(com.kotcrab.vis.ui.widget.color.ColorPicker) Color(com.badlogic.gdx.graphics.Color) H2DPopupMenu(games.rednblack.h2d.common.view.ui.widget.H2DPopupMenu) MenuItem(com.kotcrab.vis.ui.widget.MenuItem) Sandbox(games.rednblack.editor.view.stage.Sandbox) StickyNoteVO(games.rednblack.editor.renderer.data.StickyNoteVO) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) ColorPickerAdapter(com.kotcrab.vis.ui.widget.color.ColorPickerAdapter) ClickListener(com.badlogic.gdx.scenes.scene2d.utils.ClickListener) HyperLapColorPicker(games.rednblack.h2d.common.view.ui.widget.HyperLapColorPicker)

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