Search in sources :

Example 1 with OwnScrollPane

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

the class ObjectsComponent method initialize.

@Override
public void initialize() {
    float contentWidth = ControlsWindow.getContentWidth();
    searchBox = new OwnTextField("", skin);
    searchBox.setName("search box");
    searchBox.setWidth(contentWidth);
    searchBox.setMessageText(I18n.txt("gui.objects.search"));
    searchBox.addListener(event -> {
        if (event instanceof InputEvent) {
            InputEvent ie = (InputEvent) event;
            if (ie.getType() == Type.keyUp && !searchBox.getText().isEmpty()) {
                String text = searchBox.getText().toLowerCase().trim();
                if (sg.containsNode(text)) {
                    SceneGraphNode node = sg.getNode(text);
                    if (node instanceof IFocus) {
                        IFocus focus = (IFocus) node;
                        boolean timeOverflow = focus.isCoordinatesTimeOverflow();
                        boolean ctOn = GaiaSky.instance.isOn(focus.getCt());
                        if (!timeOverflow && ctOn) {
                            GaiaSky.postRunnable(() -> {
                                EventManager.publish(Event.CAMERA_MODE_CMD, this, CameraMode.FOCUS_MODE, true);
                                EventManager.publish(Event.FOCUS_CHANGE_CMD, this, focus, true);
                            });
                        } else if (timeOverflow) {
                            info(I18n.txt("gui.objects.search.timerange.1", text), I18n.txt("gui.objects.search.timerange.2"));
                        } else {
                            info(I18n.txt("gui.objects.search.invisible.1", text), I18n.txt("gui.objects.search.invisible.2", focus.getCt().toString()));
                        }
                    }
                } else {
                    info(null, null);
                }
                if (GaiaSky.instance.getICamera() instanceof NaturalCamera)
                    ((NaturalCamera) GaiaSky.instance.getICamera()).getCurrentMouseKbdListener().removePressedKey(ie.getKeyCode());
                if (ie.getKeyCode() == Keys.ESCAPE) {
                    // Lose focus
                    stage.setKeyboardFocus(null);
                }
            } else if (ie.getType() == Type.keyDown) {
                if (ie.getKeyCode() == Keys.CONTROL_LEFT || ie.getKeyCode() == Keys.CONTROL_RIGHT) {
                    // Lose focus
                    stage.setKeyboardFocus(null);
                }
            }
            return true;
        }
        return false;
    });
    // Info message
    infoTable = new Table(skin);
    infoCell1 = infoTable.add();
    infoTable.row();
    infoCell2 = infoTable.add();
    infoMessage1 = new OwnLabel("", skin, "default-blue");
    infoMessage2 = new OwnLabel("", skin, "default-blue");
    /*
         * OBJECTS
         */
    final com.badlogic.gdx.scenes.scene2d.ui.List<String> focusList = new com.badlogic.gdx.scenes.scene2d.ui.List<>(skin);
    focusList.setName("objects list");
    Array<IFocus> focusableObjects = sg.getFocusableObjects();
    Array<String> names = new Array<>(false, focusableObjects.size);
    for (IFocus focus : focusableObjects) {
        // Omit stars with no proper names
        if (focus.getName() != null && !GlobalResources.isNumeric(focus.getName())) {
            names.add(focus.getName());
        }
    }
    names.sort();
    SceneGraphNode sol = sg.getNode("Sun");
    if (sol != null) {
        Array<IFocus> solChildren = new Array<>();
        sol.addFocusableObjects(solChildren);
        solChildren.sort(new CelestialBodyComparator());
        for (IFocus cb : solChildren) names.insert(0, cb.getName());
    }
    focusList.setItems(names);
    // 
    focusList.pack();
    focusList.addListener(event -> {
        if (event instanceof ChangeEvent) {
            ChangeEvent ce = (ChangeEvent) event;
            Actor actor = ce.getTarget();
            @SuppressWarnings("unchecked") final String text = ((com.badlogic.gdx.scenes.scene2d.ui.List<String>) actor).getSelected().toLowerCase().trim();
            if (sg.containsNode(text)) {
                SceneGraphNode node = sg.getNode(text);
                if (node instanceof IFocus) {
                    IFocus focus = (IFocus) node;
                    boolean timeOverflow = focus.isCoordinatesTimeOverflow();
                    boolean ctOn = GaiaSky.instance.isOn(focus.getCt());
                    if (!timeOverflow && ctOn) {
                        GaiaSky.postRunnable(() -> {
                            EventManager.publish(Event.CAMERA_MODE_CMD, this, CameraMode.FOCUS_MODE, true);
                            EventManager.publish(Event.FOCUS_CHANGE_CMD, this, focus, true);
                        });
                    } else if (timeOverflow) {
                        info(I18n.txt("gui.objects.search.timerange.1", text), I18n.txt("gui.objects.search.timerange.2"));
                    } else {
                        info(I18n.txt("gui.objects.search.invisible.1", text), I18n.txt("gui.objects.search.invisible.2", focus.getCt().toString()));
                    }
                }
            } else {
                info(null, null);
            }
            return true;
        }
        return false;
    });
    objectsList = focusList;
    focusListScrollPane = new OwnScrollPane(objectsList, skin, "minimalist-nobg");
    focusListScrollPane.setName("objects list scroll");
    focusListScrollPane.setFadeScrollBars(false);
    focusListScrollPane.setScrollingDisabled(true, false);
    focusListScrollPane.setHeight(160f);
    focusListScrollPane.setWidth(contentWidth);
    /*
         * ADD TO CONTENT
         */
    VerticalGroup objectsGroup = new VerticalGroup().align(Align.left).columnAlign(Align.left).space(pad12);
    objectsGroup.addActor(searchBox);
    if (focusListScrollPane != null) {
        objectsGroup.addActor(focusListScrollPane);
    }
    objectsGroup.addActor(infoTable);
    component = objectsGroup;
}
Also used : SceneGraphNode(gaiasky.scenegraph.SceneGraphNode) CelestialBodyComparator(gaiasky.util.comp.CelestialBodyComparator) OwnScrollPane(gaiasky.util.scene2d.OwnScrollPane) com.badlogic.gdx.scenes.scene2d.ui(com.badlogic.gdx.scenes.scene2d.ui) Actor(com.badlogic.gdx.scenes.scene2d.Actor) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) OwnTextField(gaiasky.util.scene2d.OwnTextField) IFocus(gaiasky.scenegraph.IFocus) Array(com.badlogic.gdx.utils.Array) ChangeEvent(com.badlogic.gdx.scenes.scene2d.utils.ChangeListener.ChangeEvent) NaturalCamera(gaiasky.scenegraph.camera.NaturalCamera) OwnLabel(gaiasky.util.scene2d.OwnLabel)

Example 2 with OwnScrollPane

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

the class ReleaseNotesWindow method build.

@Override
protected void build() {
    float taWidth = 1300f;
    float taHeight = 900f;
    try {
        String releaseNotes = Files.readString(releaseNotesFile).trim();
        OwnLabel title = new OwnLabel(Settings.getApplicationTitle(false) + "   " + Settings.settings.version.version, skin, "header");
        content.add(title).left().pad(pad10).padBottom(pad20).row();
        OwnTextArea releaseNotesText = new OwnTextArea(releaseNotes, skin, "disabled-nobg");
        releaseNotesText.setDisabled(true);
        releaseNotesText.setPrefRows(30);
        releaseNotesText.setWidth(taWidth - 15f);
        float fontHeight = releaseNotesText.getStyle().font.getLineHeight();
        releaseNotesText.offsets();
        releaseNotesText.setHeight((releaseNotesText.getLines() + 3) * fontHeight);
        releaseNotesText.clearListeners();
        OwnScrollPane scroll = new OwnScrollPane(releaseNotesText, skin, "default-nobg");
        scroll.setWidth(taWidth);
        scroll.setHeight(taHeight);
        scroll.setForceScroll(false, true);
        scroll.setSmoothScrolling(false);
        scroll.setFadeScrollBars(false);
        content.add(scroll).center().pad(pad10);
        content.pack();
    } catch (IOException e) {
        // Show error
        OwnLabel error = new OwnLabel(I18n.txt("error.file.read", releaseNotesFile.toString()), skin);
        content.add(error).center();
    }
}
Also used : OwnScrollPane(gaiasky.util.scene2d.OwnScrollPane) OwnLabel(gaiasky.util.scene2d.OwnLabel) IOException(java.io.IOException) OwnTextArea(gaiasky.util.scene2d.OwnTextArea)

Example 3 with OwnScrollPane

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

the class WikiInfoWindow method build.

@Override
protected void build() {
    /* 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).row();
    linkCell = content.add();
    getTitleTable().align(Align.left);
    pack();
}
Also used : OwnScrollPane(gaiasky.util.scene2d.OwnScrollPane) Table(com.badlogic.gdx.scenes.scene2d.ui.Table)

Example 4 with OwnScrollPane

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

the class MemInfoWindow method build.

@Override
protected void build() {
    float pad = 8f;
    float taWidth = 1200f;
    StringBuilder memInfoStr = new StringBuilder();
    for (MemoryPoolMXBean mpBean : ManagementFactory.getMemoryPoolMXBeans()) {
        memInfoStr.append(I18n.txt("gui.help.name")).append(": ").append(mpBean.getName()).append(": ").append(mpBean.getUsage()).append("\n");
    }
    OwnTextArea memInfo = new OwnTextArea(memInfoStr.toString(), skin, "disabled-nobg");
    memInfo.setDisabled(true);
    memInfo.setPrefRows(13);
    memInfo.setWidth(taWidth - 15f);
    float fontHeight = memInfo.getStyle().font.getLineHeight();
    memInfo.offsets();
    memInfo.setHeight((memInfo.getLines() + 3) * fontHeight);
    memInfo.clearListeners();
    OwnScrollPane memInfoScroll = new OwnScrollPane(memInfo, skin, "minimalist-nobg");
    memInfoScroll.setWidth(taWidth);
    memInfoScroll.setForceScroll(false, false);
    memInfoScroll.setSmoothScrolling(true);
    memInfoScroll.setFadeScrollBars(false);
    content.add(memInfoScroll).padBottom(pad).row();
}
Also used : OwnScrollPane(gaiasky.util.scene2d.OwnScrollPane) MemoryPoolMXBean(java.lang.management.MemoryPoolMXBean) OwnTextArea(gaiasky.util.scene2d.OwnTextArea)

Example 5 with OwnScrollPane

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

the class LocationLogComponent method initialize.

@Override
public void initialize() {
    final float contentWidth = ControlsWindow.getContentWidth();
    locations = new VerticalGroup().align(Align.topLeft).columnAlign(Align.left).space(pad8);
    /*
         * ADD TO CONTENT
         */
    ScrollPane scrollPane = new OwnScrollPane(locations, skin, "minimalist-nobg");
    scrollPane.setName("bookmarks scroll");
    scrollPane.setFadeScrollBars(false);
    scrollPane.setScrollingDisabled(true, false);
    scrollPane.setHeight(260f);
    scrollPane.setWidth(contentWidth);
    VerticalGroup locationGroup = new VerticalGroup().align(Align.left).columnAlign(Align.left).space(pad12);
    locationGroup.addActor(scrollPane);
    component = locationGroup;
    refresh();
}
Also used : OwnScrollPane(gaiasky.util.scene2d.OwnScrollPane) OwnScrollPane(gaiasky.util.scene2d.OwnScrollPane)

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