Search in sources :

Example 6 with OwnScrollPane

use of gaiasky.util.scene2d.OwnScrollPane in project gaiasky by langurmonkey.

the class GenericDialog method buildSuper.

public void buildSuper() {
    // BUTTONS
    buttonGroup = new HorizontalGroup();
    buttonGroup.space(pad5);
    if (acceptText != null) {
        acceptButton = new OwnTextButton(acceptText, skin, "default");
        acceptButton.setName("accept");
        acceptButton.addListener((event) -> {
            if (event instanceof ChangeEvent) {
                accept();
                if (acceptRunnable != null)
                    acceptRunnable.run();
                me.hide();
                return true;
            }
            return false;
        });
        buttonGroup.addActor(acceptButton);
    }
    if (cancelText != null) {
        cancelButton = new OwnTextButton(cancelText, skin, "default");
        cancelButton.setName("cancel");
        cancelButton.addListener((event) -> {
            if (event instanceof ChangeEvent) {
                cancel();
                if (cancelRunnable != null)
                    cancelRunnable.run();
                me.hide();
                return true;
            }
            return false;
        });
        buttonGroup.addActor(cancelButton);
    }
    recalculateButtonSize();
    add(content).left().pad(pad10).row();
    add(bottom).expandY().bottom().right().padRight(pad10).row();
    add(buttonGroup).pad(pad10).bottom().right();
    getTitleTable().align(Align.left);
    // Align top left
    align(Align.top | Align.left);
    pack();
    // Add keys for ESC, ENTER and TAB
    me.addListener(event -> {
        if (event instanceof InputEvent) {
            InputEvent ievent = (InputEvent) event;
            if (ievent.getType() == Type.keyUp) {
                int key = ievent.getKeyCode();
                switch(key) {
                    case Keys.ESCAPE:
                        if (escExit) {
                            // Exit
                            cancel();
                            if (cancelRunnable != null)
                                cancelRunnable.run();
                            me.hide();
                        }
                        // Do not propagate to parents
                        event.stop();
                        return true;
                    case Keys.ENTER:
                        if (enterExit) {
                            // Exit
                            accept();
                            if (acceptRunnable != null)
                                acceptRunnable.run();
                            me.hide();
                        }
                        // Do not propagate to parents
                        event.stop();
                        return true;
                    case Keys.TAB:
                        return true;
                    default:
                        // Nothing
                        break;
                }
            }
        }
        return false;
    });
    // CAPTURE SCROLL FOCUS
    stage.addListener(event -> {
        if (event instanceof InputEvent) {
            InputEvent ie = (InputEvent) event;
            if (ie.getType() == Type.mouseMoved) {
                for (OwnScrollPane scroll : scrolls) {
                    if (ie.getTarget().isDescendantOf(scroll)) {
                        stage.setScrollFocus(scroll);
                    }
                }
            }
        }
        return false;
    });
    // Build actual content
    build();
    // Modal
    setModal(this.modal);
}
Also used : OwnScrollPane(gaiasky.util.scene2d.OwnScrollPane) OwnTextButton(gaiasky.util.scene2d.OwnTextButton) ChangeEvent(com.badlogic.gdx.scenes.scene2d.utils.ChangeListener.ChangeEvent) HorizontalGroup(com.badlogic.gdx.scenes.scene2d.ui.HorizontalGroup)

Example 7 with OwnScrollPane

use of gaiasky.util.scene2d.OwnScrollPane in project gaiasky by langurmonkey.

the class ArchiveViewWindow method build.

@Override
protected void build() {
    this.pad = 8f;
    /**
     * TABLE and SCROLL *
     */
    table = new Table(skin);
    table.pad(pad);
    scroll = new OwnScrollPane(table, skin, "minimalist-nobg");
    scroll.setFadeScrollBars(false);
    scroll.setScrollingDisabled(true, false);
    scroll.setOverscroll(false, false);
    scroll.setSmoothScrolling(true);
    content.add(scroll);
    getTitleTable().align(Align.left);
    pack();
}
Also used : OwnScrollPane(gaiasky.util.scene2d.OwnScrollPane) Table(com.badlogic.gdx.scenes.scene2d.ui.Table)

Aggregations

OwnScrollPane (gaiasky.util.scene2d.OwnScrollPane)7 Table (com.badlogic.gdx.scenes.scene2d.ui.Table)2 ChangeEvent (com.badlogic.gdx.scenes.scene2d.utils.ChangeListener.ChangeEvent)2 OwnLabel (gaiasky.util.scene2d.OwnLabel)2 OwnTextArea (gaiasky.util.scene2d.OwnTextArea)2 Actor (com.badlogic.gdx.scenes.scene2d.Actor)1 InputEvent (com.badlogic.gdx.scenes.scene2d.InputEvent)1 com.badlogic.gdx.scenes.scene2d.ui (com.badlogic.gdx.scenes.scene2d.ui)1 HorizontalGroup (com.badlogic.gdx.scenes.scene2d.ui.HorizontalGroup)1 Array (com.badlogic.gdx.utils.Array)1 IFocus (gaiasky.scenegraph.IFocus)1 SceneGraphNode (gaiasky.scenegraph.SceneGraphNode)1 NaturalCamera (gaiasky.scenegraph.camera.NaturalCamera)1 CelestialBodyComparator (gaiasky.util.comp.CelestialBodyComparator)1 OwnTextButton (gaiasky.util.scene2d.OwnTextButton)1 OwnTextField (gaiasky.util.scene2d.OwnTextField)1 IOException (java.io.IOException)1 MemoryPoolMXBean (java.lang.management.MemoryPoolMXBean)1