Search in sources :

Example 1 with StripeMenuBar

use of com.ray3k.stripe.StripeMenuBar 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

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