Example usage for com.badlogic.gdx.scenes.scene2d.ui ScrollPane ScrollPane

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

Introduction

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

Prototype

public ScrollPane(Actor widget) 

Source Link

Usage

From source file:com.stercore.code.net.dermetfan.utils.libgdx.scene2d.ui.ListFileChooser.java

License:Apache License

/** Override this if you want to adjust all the Widgets. Be careful though! */
protected void buildWidgets() {
    addListener(keyControlsListener);/* ww  w.  j a v a2  s. com*/

    (pathField = new TextField(directory.path(), style.pathFieldStyle)).setTextFieldListener(pathFieldListener);
    contents = new List<>(style.contentsStyle);
    contents.setItems(directory.name());
    contents.addListener(contentsListener);

    (chooseButton = Scene2DUtils.newButton(style.chooseButtonStyle, "select"))
            .addListener(chooseButtonListener);
    (openButton = Scene2DUtils.newButton(style.openButtonStyle, "open")).addListener(openButtonListener);
    (cancelButton = Scene2DUtils.newButton(style.cancelButtonStyle, "cancel"))
            .addListener(cancelButtonListener);
    (backButton = Scene2DUtils.newButton(style.backButtonStyle, "back")).addListener(backButtonListener);
    (parentButton = Scene2DUtils.newButton(style.parentButtonStyle, "up")).addListener(parentButtonListener);

    contentsPane = style.contentsPaneStyle == null ? new ScrollPane(contents)
            : new ScrollPane(contents, style.contentsPaneStyle);

    setBackground(style.background);
}

From source file:com.util.screens.CreditScreen.java

public CreditScreen(EngineGameStart game) {
    _game = game;/* w w w  .j a v  a  2  s  .  co  m*/
    _stage = new Stage();
    Gdx.input.setInputProcessor(_stage);

    //Get text
    FileHandle file = Gdx.files.internal(CREDITS_PATH);
    String textString = file.readString();

    Label text = new Label(textString, Utility.STATUSUI_SKIN, "credits");
    text.setAlignment(Align.top | Align.center);
    text.setWrap(true);

    _scrollPane = new ScrollPane(text);
    _scrollPane.addListener(new ClickListener() {
        @Override
        public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            return true;
        }

        @Override
        public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
            _scrollPane.setScrollY(0);
            _scrollPane.updateVisualScroll();
            _game.setScreen(_game.getScreenType(EngineGameStart.ScreenType.MainMenu));
        }
    });

    Table table = new Table();
    table.center();
    table.setFillParent(true);
    table.defaults().width(Gdx.graphics.getWidth());
    table.add(_scrollPane);

    _stage.addActor(table);
}

From source file:com.v5ent.game.screens.CreditScreen.java

public CreditScreen(MyRpgGame game) {
    _game = game;/*from   w  ww  . j a  v a 2 s. c o  m*/
    _stage = new Stage();
    Gdx.input.setInputProcessor(_stage);

    //Get text
    FileHandle file = Gdx.files.internal(CREDITS_PATH);
    String textString = file.readString();

    Label text = new Label(textString, Utility.STATUSUI_SKIN, "credits");
    text.setAlignment(Align.top | Align.center);
    text.setWrap(true);

    _scrollPane = new ScrollPane(text);
    _scrollPane.addListener(new ClickListener() {
        @Override
        public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            return true;
        }

        @Override
        public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
            _scrollPane.setScrollY(0);
            _scrollPane.updateVisualScroll();
            _game.setScreen(_game.getScreenType(MyRpgGame.ScreenType.MainMenu));
        }
    });

    Table table = new Table();
    table.center();
    table.setFillParent(true);
    table.defaults().width(Gdx.graphics.getWidth());
    table.add(_scrollPane);

    _stage.addActor(table);
}

From source file:com.vlaaad.dice.services.AchievementsWindow.java

License:Open Source License

@Override
protected void initialize() {
    Table content = new Table(Config.skin);
    content.setBackground("ui-creature-info-background");
    content.add(new LocLabel("ui-achievements")).row();
    Array<Achievement> sorted = new Array<Achievement>();
    for (Achievement achievement : Config.achievements) {
        sorted.add(achievement);/*from   ww  w.j av  a2  s . co m*/
    }
    sorted.sort(Achievement.COMPARATOR);
    Table list = new Table();
    for (Achievement achievement : sorted) {
        list.add(new AchievementDescriptionView(achievement)).row();
    }

    content.add(new ScrollPane(list)).height(100);
    table.add(content);
}

From source file:com.vlaaad.dice.services.ui.InvitesWindow.java

License:Open Source License

@Override
protected void initialize() {
    Table content = new Table(Config.skin);
    content.setTouchable(Touchable.enabled);
    content.setBackground("ui-store-window-background");
    content.add(new ScrollPane(list)).size(100, 100);

    table.add(content);/*from  www .j  a  v  a2s .  c  o  m*/
}

From source file:com.vlaaad.dice.ui.components.ScaleSelector.java

License:Open Source License

public ScaleSelector(int min, int max, int current) {
    this.min = min;
    scales = new int[max - min + 1];
    for (int i = min; i <= max; i++) {
        scales[i - min] = i;//from   w  ww  .ja v a 2 s .  c o  m
    }
    scalePane = new ScrollPane(createPaneContent(min, max));
    add(left);
    add(scalePane).width(30);
    add(right);
    scalePane.setTouchable(Touchable.disabled);
    invalidate();
    validate();
    show(current);
    left.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            scroll(-1);
        }
    });
    right.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            scroll(1);
        }
    });
}

From source file:com.vlaaad.dice.ui.windows.PotionsWindow.java

License:Open Source License

@Override
protected void initialize() {
    Table content = new Table(Config.skin);
    content.setBackground("ui-creature-info-background");
    content.setTouchable(Touchable.enabled);
    content.defaults().pad(2);/*  w w w.  j a  v  a  2 s  .  co m*/
    Array<Ability> potions = new Array<Ability>();
    for (Ability ability : Config.abilities.byType(Ability.Type.potion)) {
        potions.add(ability);
    }
    potions.sort(Ability.COST_COMPARATOR);

    potionsList = new Table();
    Image selection = new Image(Config.skin.getDrawable("selection/turn"));
    potionsList.addActor(selection);

    potionName = new LocLabel("");
    potionDescription = new LocLabel("");
    potionDescription.setAlignment(Align.center | Align.top);
    potionDescription.setWrap(true);

    ingredientsTable = new Table(Config.skin);
    ingredientsTable.defaults().pad(2);

    Table viewRow = new Table();
    potionsList.add(viewRow).row();
    viewRow.defaults().pad(2);
    int i = 0;
    ActorGestureListener l = null;
    for (Ability ability : potions) {
        AbilityIconCounter icon = new AbilityIconCounter(ability, 0);
        icon.image.setOrigin(icon.image.getWidth() / 2, icon.image.getHeight() / 2);
        potionIcons.put(ability, icon);
        ActorGestureListener listener = createPotionTapListener(icon, ability, selection, potionsList,
                potionName, potionDescription, ingredientsTable);
        if (l == null) {
            l = listener;
        }
        iconListeners.put(ability, listener);
        icon.addListener(listener);
        i++;
        viewRow.add(icon);
        if (i % 5 == 0) {
            viewRow = new Table();
            viewRow.defaults().pad(2);
            potionsList.add(viewRow).row();
        }
    }

    craftingPane = new CraftingPane(3, potions);

    Table craftTable = new Table(Config.skin);
    craftTable.setBackground("ui-craft-content");
    craftTable.defaults().pad(4);
    craftTable.add(craftingPane).row();
    craftTable.add(ingredientsContainer).row();

    content.add(potionsList).row();
    content.add(new Tile("ui-creature-info-line")).size(80, 1).row();
    content.add(potionName).row();
    content.add(ingredientsTable).padTop(5).padBottom(1).row();
    content.add(potionDescription).size(130, 48).row();
    content.add(craftTable).expandX().fillX().pad(-2).row();

    Container contentContainer = new Container(content);
    contentContainer.width(content.getPrefWidth());
    scrollPane = new ScrollPane(contentContainer);
    scrollPane.setOverscroll(false, false);
    scrollPane.setCancelTouchFocus(false);
    table.add(scrollPane).width(contentContainer.getMaxWidth());

    if (l != null) {
        table.invalidate();
        table.validate();
        l.tap(null, 0, 0, 0, 0);
    }
}

From source file:de.bitbrain.craft.screens.IngameScreen.java

License:Open Source License

private ScrollPane generateScrollPane(Actor actor) {
    ScrollPane pane = new ScrollPane(actor);
    pane.setCancelTouchFocus(false);/* w  w w .j a  va2 s.  c  om*/
    pane.setScrollingDisabled(true, false);
    return pane;
}

From source file:de.cubicvoxel.openspacebox.ingame.ui.logbook.PlayerLogBook.java

License:Open Source License

public PlayerLogBook(ResourceBundles resourceBundles, GameControllers gameControllers, OsbGui stage) {
    super(ResourceBundles.getInstance().getIngameHud().get("playerLogBook"), stage);
    setModal(true);//from w  w w .  j  a va  2  s  .c om

    final FactionLogView factionLogView = new FactionLogView(resourceBundles, gameControllers);
    factionLogView.loadFactionLog(CommonFactions.PLAYER_FACTION.getFactionLog());

    final ScrollPane scrollPane = new ScrollPane(factionLogView);
    scrollPane.setScrollingDisabled(true, false);
    add(scrollPane).fill().expand();

}

From source file:de.fgerbig.spacepeng.screens.CreditsScreen.java

License:Open Source License

@Override
public void show() {
    super.show();

    // retrieve the default table actor
    Table table = super.getTable();
    table.setSkin(game.getSkin());/*from w  ww. j ava2 s  .  c  o  m*/

    Label label = new Label("Credits", game.getSkin());
    label.setStyle(labelStyle_Heading);
    table.add(label).spaceBottom(25);
    table.row();

    Label creditsText = new Label(CREDITS, game.getSkin());
    Label.LabelStyle labelStyle = creditsText.getStyle();
    labelStyle.font = game.getFont();
    creditsText.setStyle(labelStyle);
    creditsText.setAlignment(Align.center);
    ScrollPane scrollPane = new ScrollPane(creditsText);
    table.add(scrollPane).size(CREDITS_WIDTH, CREDITS_HEIGHT).spaceBottom(25);
    table.row();

    // register the back button
    TextButton backButton = new TextButton("Back", game.getSkin());
    backButton.setStyle(textButtonStyle_Default);
    backButton.addListener(new DefaultInputListener() {
        @Override
        public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
            super.touchUp(event, x, y, pointer, button);
            SpacePeng.soundManager.play(SoundKey.CLICK);
            game.setScreen(new MenuScreen(game));
        }
    });
    table.row();
    table.add(backButton).size(BUTTON_WIDTH, BUTTON_HEIGHT).colspan(3);
}