Example usage for com.badlogic.gdx.scenes.scene2d.ui SplitPane setSplitAmount

List of usage examples for com.badlogic.gdx.scenes.scene2d.ui SplitPane setSplitAmount

Introduction

In this page you can find the example usage for com.badlogic.gdx.scenes.scene2d.ui SplitPane setSplitAmount.

Prototype

public void setSplitAmount(float split) 

Source Link

Usage

From source file:at.hid.tabletopsimulator.screens.About.java

License:Apache License

@Override
public void show() {
    TableTopSimulator.debug(this.getClass().toString(), "creating About screen");
    stage = new Stage(new ExtendViewport(Gdx.graphics.getWidth(), Gdx.graphics.getHeight()));

    Gdx.input.setInputProcessor(stage);// w w w. j a v a2 s .  c o  m

    // creating skin
    TableTopSimulator.debug(this.getClass().toString(), "creating skin");
    skin = TableTopSimulator.assets.get("ui/gui.json", Skin.class);

    table = new Table(skin);
    //      table.setFillParent(true);
    //      table.setBounds(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());

    // creating heading
    TableTopSimulator.debug(this.getClass().toString(), "creating heading");
    Label lblHeading = new Label(TableTopSimulator.getLangBundle().format("About.lblHeading.text"), skin);

    final Label lblContent = new Label("http://libgdx.badlogicgames.com/\r\n" + "\r\n"
            + "libGDX is licensed under the Apache 2 License,\r\n"
            + "meaning you can use it free of charge, without strings attached in commercial and non-commercial projects.\r\n"
            + "We love to get (non-mandatory) credit in case you release a game or app using libgdx!", skin,
            "content");

    // creating list

    final List<String> listAbout = new List<String>(skin, "content");
    ArrayList<String> newItems = new ArrayList<String>();
    newItems.add("libgdx");
    newItems.add("libgdx-utils");
    newItems.add("flare gameart");
    String[] data = new String[newItems.size()];
    listAbout.setItems(newItems.toArray(data));
    listAbout.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            if (listAbout.getSelected().equals("libgdx")) {
                lblContent.clear();
                lblContent.setText("http://libgdx.badlogicgames.com/\r\n" + "\r\n"
                        + "libGDX is licensed under the Apache 2 License,\r\n"
                        + "meaning you can use it free of charge, without strings attached in commercial and non-commercial projects.\r\n"
                        + "We love to get (non-mandatory) credit in case you release a game or app using libgdx!");
            } else if (listAbout.getSelected().equals("libgdx-utils")) {
                lblContent.clear();
                lblContent.setText("https://bitbucket.org/dermetfan/libgdx-utils/wiki/Home\r\n" + "\r\n"
                        + "/* Copyright (c) 2014 PixelScientists\r\n" + "*\r\n" + "* The MIT License (MIT)\r\n"
                        + "*\r\n"
                        + "* Permission is hereby granted, free of charge, to any person obtaining a copy of\r\n"
                        + "* this software and associated documentation files (the \"Software\"), to deal in\r\n"
                        + "* the Software without restriction, including without limitation the rights to\r\n"
                        + "* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\r\n"
                        + "* the Software, and to permit persons to whom the Software is furnished to do so,\r\n"
                        + "* subject to the following conditions:\r\n" + "*\r\n"
                        + "* The above copyright notice and this permission notice shall be included in all\r\n"
                        + "* copies or substantial portions of the Software.\r\n" + "*\r\n"
                        + "* THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\n"
                        + "* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\r\n"
                        + "* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\r\n"
                        + "* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\r\n"
                        + "* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r\n"
                        + "* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r\n"
                        + "*/");
            } else if (listAbout.getSelected().equals("flare gameart")) {
                lblContent.clear();
                lblContent.setText("https://github.com/clintbellanger/flare-game\r\n" + "\r\n"
                        + "Flare (the game) is Copyright 2010-2013 Clint Bellanger. Contributors retain copyrights to their original contributions.\r\n"
                        + "\r\n" + "The Flare Engine is released under GPL version 3 or later.\r\n" + "\r\n"
                        + "All of Flare's art and data files are released under CC-BY-SA 3.0. Later versions are permitted.\r\n"
                        + "\r\n"
                        + "The Liberation Sans fonts version 2 are released under the SIL Open Font License, Version 1.1.\r\n"
                        + "\r\n"
                        + "The GNU Unifont font is released under GPL v2, with the exception that embedding the font in a document does not in itself bind that document to the terms of the GPL.");
            }
        }
    });

    // creating buttons
    TableTopSimulator.debug(this.getClass().toString(), "creating buttons");
    TextButton btnBack = new TextButton(TableTopSimulator.getLangBundle().format("About.btnBack.text"), skin);
    btnBack.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            TableTopSimulator.debug(this.getClass().toString(), "switching to Options screen");
            ((Game) Gdx.app.getApplicationListener()).setScreen(new Options());
            dispose();
        }
    });
    btnBack.pad(10);

    ScrollPane spAboutList = new ScrollPane(null, skin);
    ScrollPane spAboutContent = new ScrollPane(null, skin);

    SplitPane splitAbout = new SplitPane(spAboutList, spAboutContent, false, skin);
    splitAbout.setSplitAmount(0.2f);

    spAboutList.setWidget(listAbout);
    spAboutContent.setWidget(lblContent);

    // building ui
    TableTopSimulator.debug(this.getClass().toString(), "building ui");
    table.add(lblHeading).spaceBottom(100).row();
    table.add(splitAbout).spaceBottom(15).width(1200).row();
    table.add(btnBack).spaceBottom(15).row();
    if (TableTopSimulator.DEBUG) {
        table.debug(); // draw debug lines 
        splitAbout.debug(); // draw debug lines 
    }
    stage.addActor(table);
}

From source file:com.bladecoder.engineeditor.Editor.java

License:Apache License

@Override
public void create() {
    skin = new Skin(Gdx.files.internal(SKIN));

    EditorLogger.setDebug();/*  w  ww  .j a va 2s .c om*/
    EditorLogger.debug("CREATE");
    Ctx.project = new Project();
    Message.init(skin);
    Ctx.assetManager = new EditorAssetManager();

    scnEditor = new ScnEditor(skin);
    scnEditor.setBackground("background");
    skin.getFont("default-font").getData().markupEnabled = true;

    /*** STAGE SETUP ***/
    stage = new Stage(new ScreenViewport());
    Gdx.input.setInputProcessor(stage);

    // RIGHT PANEL
    ScenePanel scenePanel = new ScenePanel(skin);
    ActorPanel actorPanel = new ActorPanel(skin);

    Table rightPanel = new Table(skin);
    rightPanel.top().left();
    rightPanel.add(actorPanel).expand().fill().left();
    rightPanel.setBackground("background");

    SplitPane splitPaneRight = new SplitPane(scnEditor, rightPanel, false, skin);

    splitPaneRight.setSplitAmount(0.75f);

    // LEFT PANEL
    ProjectPanel projectPanel = new ProjectPanel(skin);
    Image img = new Image(Ctx.assetManager.getIcon("title"));
    img.setScaling(Scaling.none);
    img.setAlign(Align.left);

    Table leftPanel = new Table(skin);
    leftPanel.top().left().padLeft(10);
    leftPanel.add(img).expand().fill().padBottom(20).padTop(20).padLeft(0).left();
    leftPanel.row();
    leftPanel.add(new ProjectToolbar(skin)).expandX().fill().left();
    leftPanel.row();
    leftPanel.add(projectPanel).expand().fill().left();
    leftPanel.row();
    leftPanel.add(scenePanel).expand().fill().left();
    leftPanel.setBackground("background");

    SplitPane splitPaneLeft = new SplitPane(leftPanel, splitPaneRight, false, skin);
    splitPaneLeft.setFillParent(true);
    splitPaneLeft.setSplitAmount(0.25f);
    stage.addActor(splitPaneLeft);

    // LOAD LAST OPEN PROJECT
    String lastProject = Ctx.project.getEditorConfig().getProperty(Project.LAST_PROJECT_PROP, "");

    if (!lastProject.isEmpty() && new File(lastProject).exists()) {
        try {
            EditorLogger.debug("Loading last project: " + lastProject);
            Ctx.project.loadProject(new File(lastProject));
        } catch (Exception e) {
            EditorLogger.debug("Error loading last project: " + e.getMessage());
            Ctx.project.closeProject();
            e.printStackTrace();
        }
    }

    stage.setScrollFocus(scnEditor.getScnWidget());
    stage.setKeyboardFocus(scnEditor.getScnWidget());

    TooltipManager.getInstance().instant();
}