Search in sources :

Example 6 with DialogListener

use of com.ray3k.skincomposer.dialog.DialogListener in project skin-composer by raeleus.

the class ImageTextButtonListeners method imageTextButtonColorListener.

public static EventListener imageTextButtonColorListener(final DialogSceneComposerEvents events, SimActor simActor) {
    var simImageTextButton = (DialogSceneComposerModel.SimImageTextButton) simActor;
    var popTableClickListener = new PopTableClickListener(skin) {

        {
            getPopTable().key(Keys.ESCAPE, popTable::hide);
        }

        @Override
        public void clicked(InputEvent event, float x, float y) {
            super.clicked(event, x, y);
            update();
        }

        public void update() {
            var popTable = getPopTable();
            popTable.clearChildren();
            var label = new Label("Color:", skin, "scene-label-colored");
            popTable.add(label);
            popTable.row();
            var imageButton = new ImageButton(skin, "scene-color");
            imageButton.getImage().setColor(simImageTextButton.color == null ? Color.WHITE : simImageTextButton.color.color);
            popTable.add(imageButton).minWidth(100);
            imageButton.addListener(handListener);
            imageButton.addListener(new TextTooltip("Select the color of the button.", tooltipManager, skin, "scene"));
            imageButton.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    popTable.hide();
                    dialogFactory.showDialogColors(new StyleProperty(), (colorData, pressedCancel) -> {
                        if (!pressedCancel) {
                            events.imageTextButtonColor(colorData);
                        }
                    }, new DialogListener() {

                        @Override
                        public void opened() {
                        }

                        @Override
                        public void closed() {
                        }
                    });
                }
            });
            popTable.row();
            label = new Label(simImageTextButton.color == null ? "white" : simImageTextButton.color.getName(), skin, "scene-label-colored");
            popTable.add(label);
        }
    };
    popTableClickListener.update();
    return popTableClickListener;
}
Also used : InputListener(com.badlogic.gdx.scenes.scene2d.InputListener) PopTableClickListener(com.ray3k.stripe.PopTableClickListener) com.badlogic.gdx.scenes.scene2d.ui(com.badlogic.gdx.scenes.scene2d.ui) DialogSceneComposer(com.ray3k.skincomposer.dialog.scenecomposer.DialogSceneComposer) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) DialogListener(com.ray3k.skincomposer.dialog.DialogListener) TEXT_FIELD_WIDTH(com.ray3k.skincomposer.dialog.scenecomposer.menulisteners.ListenersUtils.TEXT_FIELD_WIDTH) Spinner(com.ray3k.stripe.Spinner) Color(com.badlogic.gdx.graphics.Color) Actor(com.badlogic.gdx.scenes.scene2d.Actor) DialogSceneComposerEvents(com.ray3k.skincomposer.dialog.scenecomposer.DialogSceneComposerEvents) DialogSceneComposerModel(com.ray3k.skincomposer.dialog.scenecomposer.DialogSceneComposerModel) SimActor(com.ray3k.skincomposer.dialog.scenecomposer.DialogSceneComposerModel.SimActor) ChangeListener(com.badlogic.gdx.scenes.scene2d.utils.ChangeListener) Keys(com.badlogic.gdx.Input.Keys) Main(com.ray3k.skincomposer.Main) Input(com.badlogic.gdx.Input) StyleData(com.ray3k.skincomposer.data.StyleData) StyleSelectorPopTable(com.ray3k.skincomposer.dialog.scenecomposer.StyleSelectorPopTable) EventListener(com.badlogic.gdx.scenes.scene2d.EventListener) StyleProperty(com.ray3k.skincomposer.data.StyleProperty) StyleProperty(com.ray3k.skincomposer.data.StyleProperty) PopTableClickListener(com.ray3k.stripe.PopTableClickListener) DialogListener(com.ray3k.skincomposer.dialog.DialogListener) Actor(com.badlogic.gdx.scenes.scene2d.Actor) SimActor(com.ray3k.skincomposer.dialog.scenecomposer.DialogSceneComposerModel.SimActor) ChangeListener(com.badlogic.gdx.scenes.scene2d.utils.ChangeListener) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent)

Example 7 with DialogListener

use of com.ray3k.skincomposer.dialog.DialogListener in project skin-composer by raeleus.

the class Main method initDefaults.

private void initDefaults() {
    if (Utils.isMac())
        System.setProperty("java.awt.headless", "true");
    skin.getFont("font").getData().markupEnabled = true;
    // copy defaults.json to temp folder if it doesn't exist
    var fileHandle = appFolder.child("texturepacker/atlas-export-settings.json");
    if (!fileHandle.exists()) {
        Gdx.files.internal("atlas-export-settings.json").copyTo(fileHandle);
    }
    // copy atlas settings for preview to temp folder if it doesn't exist
    fileHandle = appFolder.child("texturepacker/atlas-internal-settings.json");
    if (!fileHandle.exists()) {
        Gdx.files.internal("atlas-internal-settings.json").copyTo(fileHandle);
    }
    // copy white-pixel.png for pixel drawables
    fileHandle = appFolder.child("texturepacker/white-pixel.png");
    if (!fileHandle.exists()) {
        Gdx.files.internal("white-pixel.png").copyTo(fileHandle);
    }
    // copy preview fonts to preview fonts folder if they do not exist
    fileHandle = appFolder.child("preview fonts/IBMPlexSerif-Medium.ttf");
    if (!fileHandle.exists()) {
        Gdx.files.internal("preview fonts/IBMPlexSerif-Medium.ttf").copyTo(fileHandle);
    }
    fileHandle = appFolder.child("preview fonts/Pacifico-Regular.ttf");
    if (!fileHandle.exists()) {
        Gdx.files.internal("preview fonts/Pacifico-Regular.ttf").copyTo(fileHandle);
    }
    fileHandle = appFolder.child("preview fonts/PressStart2P-Regular.ttf");
    if (!fileHandle.exists()) {
        Gdx.files.internal("preview fonts/PressStart2P-Regular.ttf").copyTo(fileHandle);
    }
    fileHandle = appFolder.child("preview fonts/SourceSansPro-Regular.ttf");
    if (!fileHandle.exists()) {
        Gdx.files.internal("preview fonts/SourceSansPro-Regular.ttf").copyTo(fileHandle);
    }
    ibeamListener = new IbeamListener();
    dialogFactory = new DialogFactory();
    projectData = new ProjectData();
    projectData.randomizeId();
    projectData.setMaxUndos(30);
    atlasData = projectData.getAtlasData();
    jsonData = projectData.getJsonData();
    newVersion = VERSION;
    if (projectData.isCheckingForUpdates()) {
        checkForUpdates(this);
    }
    undoableManager = new UndoableManager(this);
    desktopWorker.attachLogListener();
    desktopWorker.setCloseListener(() -> {
        dialogFactory.showCloseDialog(new DialogListener() {

            @Override
            public void opened() {
                desktopWorker.removeFilesDroppedListener(rootTable.getFilesDroppedListener());
            }

            @Override
            public void closed() {
                desktopWorker.addFilesDroppedListener(rootTable.getFilesDroppedListener());
            }
        });
        return false;
    });
    loadingAnimation = skin.get("loading-animation", TenPatchDrawable.class);
    loadingAnimation2 = skin.get("loading-animation2", TenPatchDrawable.class);
    projectData.getAtlasData().clearTempData();
    handListener = new HandListener();
    scrollFocusListener = new ScrollFocusListener(stage);
    verticalResizeArrowListener = new ResizeArrowListener(true);
    horizontalResizeArrowListener = new ResizeArrowListener(false);
    tooltipManager = new TooltipManager();
    tooltipManager.animations = false;
    tooltipManager.initialTime = .4f;
    tooltipManager.resetTime = 0.0f;
    tooltipManager.subsequentTime = 0.0f;
    tooltipManager.hideAll();
    tooltipManager.instant();
}
Also used : ScrollFocusListener(com.ray3k.stripe.ScrollFocusListener) DialogFactory(com.ray3k.skincomposer.dialog.DialogFactory) DialogListener(com.ray3k.skincomposer.dialog.DialogListener) ProjectData(com.ray3k.skincomposer.data.ProjectData) TenPatchDrawable(com.ray3k.tenpatch.TenPatchDrawable)

Example 8 with DialogListener

use of com.ray3k.skincomposer.dialog.DialogListener in project skin-composer by raeleus.

the class ButtonListeners method buttonColorListener.

public static EventListener buttonColorListener(final DialogSceneComposerEvents events, SimActor simActor) {
    var simButton = (DialogSceneComposerModel.SimButton) simActor;
    var popTableClickListener = new PopTableClickListener(skin) {

        {
            getPopTable().key(Keys.ESCAPE, popTable::hide);
        }

        @Override
        public void clicked(InputEvent event, float x, float y) {
            super.clicked(event, x, y);
            update();
        }

        public void update() {
            var popTable = getPopTable();
            popTable.clearChildren();
            var label = new Label("Color:", skin, "scene-label-colored");
            popTable.add(label);
            popTable.row();
            var imageButton = new ImageButton(skin, "scene-color");
            imageButton.getImage().setColor(simButton.color == null ? Color.WHITE : simButton.color.color);
            popTable.add(imageButton).minWidth(100);
            imageButton.addListener(handListener);
            imageButton.addListener(new TextTooltip("Select the color of the button.", tooltipManager, skin, "scene"));
            imageButton.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    popTable.hide();
                    dialogFactory.showDialogColors(new StyleProperty(), (colorData, pressedCancel) -> {
                        if (!pressedCancel) {
                            events.buttonColor(colorData);
                        }
                    }, new DialogListener() {

                        @Override
                        public void opened() {
                        }

                        @Override
                        public void closed() {
                        }
                    });
                }
            });
            popTable.row();
            label = new Label(simButton.color == null ? "white" : simButton.color.getName(), skin, "scene-label-colored");
            popTable.add(label);
        }
    };
    popTableClickListener.update();
    return popTableClickListener;
}
Also used : InputListener(com.badlogic.gdx.scenes.scene2d.InputListener) PopTableClickListener(com.ray3k.stripe.PopTableClickListener) com.badlogic.gdx.scenes.scene2d.ui(com.badlogic.gdx.scenes.scene2d.ui) DialogSceneComposer(com.ray3k.skincomposer.dialog.scenecomposer.DialogSceneComposer) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) DialogListener(com.ray3k.skincomposer.dialog.DialogListener) TEXT_FIELD_WIDTH(com.ray3k.skincomposer.dialog.scenecomposer.menulisteners.ListenersUtils.TEXT_FIELD_WIDTH) Spinner(com.ray3k.stripe.Spinner) Color(com.badlogic.gdx.graphics.Color) Actor(com.badlogic.gdx.scenes.scene2d.Actor) DialogSceneComposerEvents(com.ray3k.skincomposer.dialog.scenecomposer.DialogSceneComposerEvents) DialogSceneComposerModel(com.ray3k.skincomposer.dialog.scenecomposer.DialogSceneComposerModel) SimActor(com.ray3k.skincomposer.dialog.scenecomposer.DialogSceneComposerModel.SimActor) ChangeListener(com.badlogic.gdx.scenes.scene2d.utils.ChangeListener) Keys(com.badlogic.gdx.Input.Keys) Main(com.ray3k.skincomposer.Main) Input(com.badlogic.gdx.Input) StyleData(com.ray3k.skincomposer.data.StyleData) StyleSelectorPopTable(com.ray3k.skincomposer.dialog.scenecomposer.StyleSelectorPopTable) EventListener(com.badlogic.gdx.scenes.scene2d.EventListener) StyleProperty(com.ray3k.skincomposer.data.StyleProperty) StyleProperty(com.ray3k.skincomposer.data.StyleProperty) PopTableClickListener(com.ray3k.stripe.PopTableClickListener) DialogListener(com.ray3k.skincomposer.dialog.DialogListener) Actor(com.badlogic.gdx.scenes.scene2d.Actor) SimActor(com.ray3k.skincomposer.dialog.scenecomposer.DialogSceneComposerModel.SimActor) ChangeListener(com.badlogic.gdx.scenes.scene2d.utils.ChangeListener) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent)

Example 9 with DialogListener

use of com.ray3k.skincomposer.dialog.DialogListener in project skin-composer by raeleus.

the class CheckBoxListeners method checkBoxColorListener.

public static EventListener checkBoxColorListener(final DialogSceneComposerEvents events, SimActor simActor) {
    var simCheckBox = (DialogSceneComposerModel.SimCheckBox) simActor;
    var popTableClickListener = new PopTableClickListener(skin) {

        {
            getPopTable().key(Keys.ESCAPE, popTable::hide);
        }

        @Override
        public void clicked(InputEvent event, float x, float y) {
            super.clicked(event, x, y);
            update();
        }

        public void update() {
            var popTable = getPopTable();
            popTable.clearChildren();
            var label = new Label("Color:", skin, "scene-label-colored");
            popTable.add(label);
            popTable.row();
            var imageButton = new ImageButton(skin, "scene-color");
            imageButton.getImage().setColor(simCheckBox.color == null ? Color.WHITE : simCheckBox.color.color);
            popTable.add(imageButton).minWidth(100);
            imageButton.addListener(handListener);
            imageButton.addListener(new TextTooltip("Select the color of the CheckBox.", tooltipManager, skin, "scene"));
            imageButton.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    popTable.hide();
                    dialogFactory.showDialogColors(new StyleProperty(), (colorData, pressedCancel) -> {
                        if (!pressedCancel) {
                            events.checkBoxColor(colorData);
                        }
                    }, new DialogListener() {

                        @Override
                        public void opened() {
                        }

                        @Override
                        public void closed() {
                        }
                    });
                }
            });
            popTable.row();
            label = new Label(simCheckBox.color == null ? "white" : simCheckBox.color.getName(), skin, "scene-label-colored");
            popTable.add(label);
        }
    };
    popTableClickListener.update();
    return popTableClickListener;
}
Also used : InputListener(com.badlogic.gdx.scenes.scene2d.InputListener) PopTableClickListener(com.ray3k.stripe.PopTableClickListener) com.badlogic.gdx.scenes.scene2d.ui(com.badlogic.gdx.scenes.scene2d.ui) DialogSceneComposer(com.ray3k.skincomposer.dialog.scenecomposer.DialogSceneComposer) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) DialogListener(com.ray3k.skincomposer.dialog.DialogListener) TEXT_FIELD_WIDTH(com.ray3k.skincomposer.dialog.scenecomposer.menulisteners.ListenersUtils.TEXT_FIELD_WIDTH) Spinner(com.ray3k.stripe.Spinner) Color(com.badlogic.gdx.graphics.Color) Actor(com.badlogic.gdx.scenes.scene2d.Actor) DialogSceneComposerEvents(com.ray3k.skincomposer.dialog.scenecomposer.DialogSceneComposerEvents) DialogSceneComposerModel(com.ray3k.skincomposer.dialog.scenecomposer.DialogSceneComposerModel) SimActor(com.ray3k.skincomposer.dialog.scenecomposer.DialogSceneComposerModel.SimActor) ChangeListener(com.badlogic.gdx.scenes.scene2d.utils.ChangeListener) Keys(com.badlogic.gdx.Input.Keys) Main(com.ray3k.skincomposer.Main) Input(com.badlogic.gdx.Input) StyleData(com.ray3k.skincomposer.data.StyleData) StyleSelectorPopTable(com.ray3k.skincomposer.dialog.scenecomposer.StyleSelectorPopTable) EventListener(com.badlogic.gdx.scenes.scene2d.EventListener) StyleProperty(com.ray3k.skincomposer.data.StyleProperty) StyleProperty(com.ray3k.skincomposer.data.StyleProperty) PopTableClickListener(com.ray3k.stripe.PopTableClickListener) DialogListener(com.ray3k.skincomposer.dialog.DialogListener) Actor(com.badlogic.gdx.scenes.scene2d.Actor) SimActor(com.ray3k.skincomposer.dialog.scenecomposer.DialogSceneComposerModel.SimActor) ChangeListener(com.badlogic.gdx.scenes.scene2d.utils.ChangeListener) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent)

Example 10 with DialogListener

use of com.ray3k.skincomposer.dialog.DialogListener in project skin-composer by raeleus.

the class DialogSceneComposer method showSettingsDialog.

public PopTable showSettingsDialog() {
    var root = new PopTable(skin);
    root.setHideOnUnfocus(true);
    root.setModal(true);
    root.setKeepSizedWithinStage(true);
    root.setKeepCenteredInWindow(true);
    root.pad(20);
    var label = new Label("Settings", skin, "scene-title-bg");
    label.setAlignment(Align.center);
    root.add(label).growX().padBottom(10);
    root.row();
    var table = new Table();
    root.add(table).growX();
    table.defaults().left().space(5);
    label = new Label("Package", skin, "scene-label-colored");
    table.add(label);
    var textField = new TextField(rootActor.packageString, skin, "scene");
    var keyboardFocus = textField;
    table.add(textField).width(300).uniformX();
    textField.addListener(ibeamListener);
    textField.addListener(new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {
            events.rootPackage(((TextField) actor).getText());
        }
    });
    table.row();
    label = new Label("Class", skin, "scene-label-colored");
    table.add(label);
    textField = new TextField(rootActor.classString, skin, "scene");
    table.add(textField).uniformX().fillX();
    textField.addListener(ibeamListener);
    textField.addListener(new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {
            events.rootClass(((TextField) actor).getText());
        }
    });
    table.row();
    label = new Label("Skin Path", skin, "scene-label-colored");
    table.add(label);
    textField = new TextField(rootActor.skinPath, skin, "scene");
    table.add(textField).uniformX().fillX();
    textField.addListener(ibeamListener);
    textField.addListener(new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {
            events.rootSkinPath(((TextField) actor).getText());
        }
    });
    table.row();
    label = new Label("Background Color", skin, "scene-label-colored");
    table.add(label);
    var imageButton = new ImageButton(new ImageButton.ImageButtonStyle(skin.get("scene-color", ImageButton.ImageButtonStyle.class)));
    imageButton.getImage().setColor(rootActor.backgroundColor == null ? Color.WHITE : rootActor.backgroundColor.color);
    table.add(imageButton).left();
    imageButton.addListener(handListener);
    imageButton.addListener(new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {
            dialogFactory.showDialogColors(new StyleProperty(), (colorData, pressedCancel) -> {
                if (!pressedCancel) {
                    events.rootBackgroundColor(colorData);
                    imageButton.getImage().setColor(colorData == null ? Color.WHITE : colorData.color);
                }
            }, new DialogListener() {

                @Override
                public void opened() {
                }

                @Override
                public void closed() {
                }
            });
        }
    });
    root.show(getStage());
    getStage().setKeyboardFocus(keyboardFocus);
    return root;
}
Also used : PopTable(com.ray3k.stripe.PopTable) FileHandle(com.badlogic.gdx.files.FileHandle) PopTableClickListener(com.ray3k.stripe.PopTableClickListener) ClickListener(com.badlogic.gdx.scenes.scene2d.utils.ClickListener) com.badlogic.gdx.scenes.scene2d.ui(com.badlogic.gdx.scenes.scene2d.ui) com.ray3k.skincomposer.dialog.scenecomposer.menulisteners(com.ray3k.skincomposer.dialog.scenecomposer.menulisteners) Array(com.badlogic.gdx.utils.Array) Cursor(com.badlogic.gdx.graphics.Cursor) DialogListener(com.ray3k.skincomposer.dialog.DialogListener) Gdx(com.badlogic.gdx.Gdx) Align(com.badlogic.gdx.utils.Align) Color(com.badlogic.gdx.graphics.Color) DialogSceneComposerModel(com.ray3k.skincomposer.dialog.scenecomposer.DialogSceneComposerModel) PopTable(com.ray3k.stripe.PopTable) ChangeListener(com.badlogic.gdx.scenes.scene2d.utils.ChangeListener) StripeMenuBar(com.ray3k.stripe.StripeMenuBar) KeyboardShortcut(com.ray3k.stripe.StripeMenuBar.KeyboardShortcut) Keys(com.badlogic.gdx.Input.Keys) Main(com.ray3k.skincomposer.Main) IntPair(com.ray3k.skincomposer.utils.IntPair) Input(com.badlogic.gdx.Input) com.badlogic.gdx.scenes.scene2d(com.badlogic.gdx.scenes.scene2d) StyleProperty(com.ray3k.skincomposer.data.StyleProperty) PopTable(com.ray3k.stripe.PopTable) StyleProperty(com.ray3k.skincomposer.data.StyleProperty) DialogListener(com.ray3k.skincomposer.dialog.DialogListener) ChangeListener(com.badlogic.gdx.scenes.scene2d.utils.ChangeListener)

Aggregations

DialogListener (com.ray3k.skincomposer.dialog.DialogListener)14 ChangeListener (com.badlogic.gdx.scenes.scene2d.utils.ChangeListener)10 PopTableClickListener (com.ray3k.stripe.PopTableClickListener)10 Input (com.badlogic.gdx.Input)9 Keys (com.badlogic.gdx.Input.Keys)9 Color (com.badlogic.gdx.graphics.Color)9 com.badlogic.gdx.scenes.scene2d.ui (com.badlogic.gdx.scenes.scene2d.ui)9 Main (com.ray3k.skincomposer.Main)9 StyleProperty (com.ray3k.skincomposer.data.StyleProperty)9 DialogSceneComposerModel (com.ray3k.skincomposer.dialog.scenecomposer.DialogSceneComposerModel)9 SimActor (com.ray3k.skincomposer.dialog.scenecomposer.DialogSceneComposerModel.SimActor)8 DialogSceneComposer (com.ray3k.skincomposer.dialog.scenecomposer.DialogSceneComposer)7 DialogSceneComposerEvents (com.ray3k.skincomposer.dialog.scenecomposer.DialogSceneComposerEvents)7 TEXT_FIELD_WIDTH (com.ray3k.skincomposer.dialog.scenecomposer.menulisteners.ListenersUtils.TEXT_FIELD_WIDTH)7 Actor (com.badlogic.gdx.scenes.scene2d.Actor)6 EventListener (com.badlogic.gdx.scenes.scene2d.EventListener)6 InputEvent (com.badlogic.gdx.scenes.scene2d.InputEvent)6 InputListener (com.badlogic.gdx.scenes.scene2d.InputListener)6 StyleData (com.ray3k.skincomposer.data.StyleData)6 StyleSelectorPopTable (com.ray3k.skincomposer.dialog.scenecomposer.StyleSelectorPopTable)6