Search in sources :

Example 1 with KeyboardShortcut

use of com.ray3k.stripe.StripeMenuBar.KeyboardShortcut in project skin-composer by raeleus.

the class RootTable method addFileMenu.

private void addFileMenu() {
    Table table = new Table();
    table.defaults().padRight(2.0f);
    add(table).growX().padTop(2.0f);
    var bar = new StripeMenuBar(stage, getSkin(), "main");
    table.add(bar).growX();
    String modifier;
    KeyboardShortcut saveAsKeyboardShortcut;
    if (Utils.isMac()) {
        modifier = "⌘";
        saveAsKeyboardShortcut = new KeyboardShortcut("⌘+Shift+Option+S", Keys.S, Keys.CONTROL_LEFT, Keys.ALT_LEFT, Keys.SHIFT_LEFT);
    } else {
        modifier = "Ctrl";
        saveAsKeyboardShortcut = new KeyboardShortcut("Ctrl+Alt+S", Keys.S, Keys.CONTROL_LEFT, Keys.ALT_LEFT);
    }
    bar.menu("File", handListener).item("New", new KeyboardShortcut(modifier + "+N", Keys.N, Keys.CONTROL_LEFT), handListener, new MenuBarListener(RootTableEnum.NEW)).item("Open...", new KeyboardShortcut(modifier + "+O", Keys.O, Keys.CONTROL_LEFT), handListener, new MenuBarListener(RootTableEnum.OPEN)).menu("Recent Files", handListener).parent().item("Save", new KeyboardShortcut(modifier + "+S", Keys.S, Keys.CONTROL_LEFT), handListener, new MenuBarListener(RootTableEnum.SAVE)).item("Save As...", saveAsKeyboardShortcut, handListener, new MenuBarListener(RootTableEnum.SAVE_AS)).item("Welcome Screen...", handListener, new MenuBarListener(RootTableEnum.WELCOME)).item("Import...", handListener, new MenuBarListener(RootTableEnum.IMPORT)).item("Export...", new KeyboardShortcut(modifier + "+E", Keys.E, Keys.CONTROL_LEFT), handListener, new MenuBarListener(RootTableEnum.EXPORT)).item("Exit", handListener, new MenuBarListener(RootTableEnum.EXIT));
    bar.menu("Edit", handListener).item("Undo", new KeyboardShortcut(modifier + "+Z", Keys.Z, Keys.CONTROL_LEFT), handListener, new MenuBarListener(RootTableEnum.UNDO)).item("Redo", new KeyboardShortcut(modifier + "+Y", Keys.Y, Keys.CONTROL_LEFT), handListener, new MenuBarListener(RootTableEnum.REDO));
    bar.menu("Project", handListener).item("Settings", handListener, new MenuBarListener(RootTableEnum.SETTINGS)).item("Colors...", handListener, new MenuBarListener(RootTableEnum.COLORS)).item("Fonts...", handListener, new MenuBarListener(RootTableEnum.FONTS)).item("Drawables...", handListener, new MenuBarListener(RootTableEnum.DRAWABLES)).item("Refresh Atlas", new KeyboardShortcut("F5", Keys.F5), handListener, new MenuBarListener(RootTableEnum.REFRESH_ATLAS)).item("Scene Composer...", new MenuBarListener(RootTableEnum.SCENE_COMPOSER), handListener, new MenuBarListener(RootTableEnum.SCENE_COMPOSER));
    bar.menu("Help", handListener).item("About...", handListener, new MenuBarListener(RootTableEnum.ABOUT));
    recentFilesMenu = bar.findMenu("File").findMenu("Recent Files");
    updateRecentFiles();
    undoButton = bar.findMenu("Edit").findButton("Undo");
    undoButton.setDisabled(true);
    redoButton = bar.findMenu("Edit").findButton("Redo");
    redoButton.setDisabled(true);
    Button button = new Button(getSkin(), "download");
    button.setName("downloadButton");
    table.add(button);
    button.addListener(new TextTooltip("Update Available", tooltipManager, getSkin()));
    button.addListener(handListener);
    button.addListener(new ChangeListener() {

        @Override
        public void changed(ChangeListener.ChangeEvent event, Actor actor) {
            fire(new RootTableEvent(RootTableEnum.DOWNLOAD_UPDATE));
        }
    });
    button.setVisible(false);
}
Also used : KeyboardShortcut(com.ray3k.stripe.StripeMenuBar.KeyboardShortcut) ChangeListener(com.badlogic.gdx.scenes.scene2d.utils.ChangeListener)

Example 2 with KeyboardShortcut

use of com.ray3k.stripe.StripeMenuBar.KeyboardShortcut in project skin-composer by raeleus.

the class DialogSceneComposer method populate.

private void populate() {
    getCell(getButtonTable()).space(0);
    var root = getContentTable();
    getCell(root).space(0);
    root.clear();
    root.defaults().reset();
    var table = new Table();
    table.setBackground(skin.getDrawable("scene-title-bar-ten"));
    root.add(table).growX();
    var label = new Label("Scene Composer", skin, "scene-title");
    table.add(label);
    root.row();
    var bar = new StripeMenuBar(stage, skin);
    root.add(bar).growX();
    bar.menu("File", handListener).item("Save", new KeyboardShortcut("Ctrl+S", Keys.S, Keys.CONTROL_LEFT), handListener, new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {
            mainListener.saveFile(null);
        }
    }).item("Save as...", new KeyboardShortcut("Ctrl+Shift+S", Keys.S, Keys.CONTROL_LEFT, Keys.SHIFT_LEFT), handListener, new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {
            mainListener.saveAsFile(null);
        }
    }).item("Import", handListener, new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {
            var file = desktopWorker.openDialog("Import JSON...", projectData.getLastSceneComposerJson(), new String[] { "*.json" }, "JSON Files (*.json)");
            if (file != null) {
                events.importTemplate(new FileHandle(file));
            }
        }
    }).item("Export", new KeyboardShortcut("Ctrl+E", Keys.E, Keys.CONTROL_LEFT), handListener, new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {
            showExportDialog();
        }
    }).item("Settings", handListener, new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {
            showSettingsDialog();
        }
    }).item("Quit", handListener, new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {
            events.menuQuit();
        }
    });
    bar.menu("Scene", handListener).item("Find by name...", new KeyboardShortcut("Ctrl+F", Keys.F, Keys.CONTROL_LEFT), handListener, new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {
            events.menuFind();
        }
    }).item("Clear", handListener, new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {
            events.menuClear();
        }
    }).item("Undo", new KeyboardShortcut("Ctrl+Z", Keys.Z, Keys.CONTROL_LEFT), handListener, new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {
            events.menuUndo();
        }
    }).item("Redo", new KeyboardShortcut("Ctrl+R", Keys.R, Keys.CONTROL_LEFT), handListener, new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {
            events.menuRedo();
        }
    });
    bar.menu("View", handListener).item("Live", handListener, new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {
            events.menuView(View.LIVE);
        }
    }).item("Edit", handListener, new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {
            events.menuView(View.EDIT);
        }
    }).item("Outline", handListener, new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {
            events.menuView(View.OUTLINE);
        }
    });
    var textButton = bar.findMenu("View").findButton("Live");
    textButton.clearChildren();
    liveImage = new Image(skin, "scene-menu-radio-invisible");
    textButton.add(liveImage).space(10);
    textButton.add(textButton.getLabel()).expandX().left();
    textButton = bar.findMenu("View").findButton("Edit");
    textButton.clearChildren();
    editImage = new Image(skin, "scene-menu-radio-invisible");
    textButton.add(editImage).space(10);
    textButton.add(textButton.getLabel()).expandX().left();
    textButton = bar.findMenu("View").findButton("Outline");
    textButton.clearChildren();
    outlineImage = new Image(skin, "scene-menu-radio-invisible");
    textButton.add(outlineImage).space(10);
    textButton.add(textButton.getLabel()).expandX().left();
    updateMenuView();
    bar.item("?", handListener, new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {
            events.menuHelp();
        }
    });
    undoButton = bar.findMenu("Scene").findButton("Undo");
    undoTooltip = new TextTooltip("", tooltipManager, skin, "scene");
    redoButton = bar.findMenu("Scene").findButton("Redo");
    redoTooltip = new TextTooltip("", tooltipManager, skin, "scene");
    bar.findCell("?").expandX().right();
    root.row();
    previewTable = new Table();
    previewTable.setTouchable(Touchable.enabled);
    previewTable.setBackground(skin.getDrawable("white"));
    if (rootActor.backgroundColor != null)
        previewTable.setColor(rootActor.backgroundColor.color);
    previewTable.add(model.preview).grow().minSize(0).prefSize(0);
    var bottom = new Table() {

        @Override
        public float getMinHeight() {
            return 0;
        }
    };
    bottom.setTouchable(Touchable.enabled);
    bottom.setBackground(skin.getDrawable("scene-bg"));
    var splitPane = new SplitPane(previewTable, bottom, true, skin, "scene-vertical");
    splitPane.setMinSplitAmount(0);
    root.add(splitPane).grow();
    splitPane.addListener(verticalResizeArrowListener);
    table = new Table();
    table.setClip(true);
    bottom.add(table).growX().minHeight(0);
    propertiesLabel = new Label("Properties", skin, "scene-title-colored");
    table.add(propertiesLabel);
    bottom.row();
    table = new Table();
    propertiesTable = table;
    var scrollPane = new ScrollPane(table, skin, "scene");
    scrollPane.setName("scroll-properties");
    scrollPane.setFlickScroll(false);
    scrollPane.setFadeScrollBars(false);
    scrollPane.setForceScroll(false, true);
    bottom.add(scrollPane).grow();
    scrollPane.addListener(scrollFocusListener);
    populateProperties();
    bottom.row();
    var image = new Image(skin, "scene-path-border");
    bottom.add(image).growX();
    bottom.row();
    table = new Table();
    pathTable = table;
    scrollPane = new ScrollPane(table, skin, "scene");
    bottom.add(scrollPane).growX().minHeight(0).space(3);
    populatePath();
    updateMenuUndoRedo();
    model.updatePreview();
}
Also used : PopTable(com.ray3k.stripe.PopTable) FileHandle(com.badlogic.gdx.files.FileHandle) StripeMenuBar(com.ray3k.stripe.StripeMenuBar) KeyboardShortcut(com.ray3k.stripe.StripeMenuBar.KeyboardShortcut) ChangeListener(com.badlogic.gdx.scenes.scene2d.utils.ChangeListener)

Aggregations

ChangeListener (com.badlogic.gdx.scenes.scene2d.utils.ChangeListener)2 KeyboardShortcut (com.ray3k.stripe.StripeMenuBar.KeyboardShortcut)2 FileHandle (com.badlogic.gdx.files.FileHandle)1 PopTable (com.ray3k.stripe.PopTable)1 StripeMenuBar (com.ray3k.stripe.StripeMenuBar)1