Example usage for com.badlogic.gdx.scenes.scene2d.ui Cell row

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

Introduction

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

Prototype

public Cell<T> row() 

Source Link

Usage

From source file:com.gdx.extension.ui.slide.SlideShow.java

License:Apache License

public SlideShow(boolean isVertical, Skin skin, String styleName) {
    super(skin);/*from w w  w  . j a  v a2  s.c  om*/

    setStyle(skin.get(styleName, SlideShowStyle.class));

    this.isVertical = isVertical;

    content = (isVertical) ? new VerticalGroup() : new HorizontalGroup();

    ScrollPaneStyle _scrollStyle = new ScrollPaneStyle();
    contentScroll = new ScrollPane(content, _scrollStyle);
    contentScroll.setScrollingDisabled(isVertical, !isVertical);
    contentScroll.setOverscroll(false, false);

    setBackground(style.background);

    previousScrollButton = new ImageButton(getStyle().previousScroll);
    previousScrollButtonCell = add(previousScrollButton);
    if (isVertical)
        previousScrollButtonCell.row();
    Cell<ScrollPane> _contentCell = add(contentScroll);
    if (isVertical)
        _contentCell.row();
    nextScrollButton = new ImageButton(getStyle().nextScroll);
    nextScrollButtonCell = add(nextScrollButton);

    previousScrollButton.addListener(new ClickListener() {

        @Override
        public void clicked(InputEvent event, float x, float y) {
            if (SlideShow.this.isVertical)
                contentScroll.setScrollPercentY(contentScroll.getScrollPercentY() - 0.1f);
            else
                contentScroll.setScrollPercentX(contentScroll.getScrollPercentX() - 0.1f);
        }

    });
    nextScrollButton.addListener(new ClickListener() {

        @Override
        public void clicked(InputEvent event, float x, float y) {
            if (SlideShow.this.isVertical)
                contentScroll.setScrollPercentY(contentScroll.getScrollPercentY() + 0.1f);
            else
                contentScroll.setScrollPercentX(contentScroll.getScrollPercentX() + 0.1f);
        }

    });
}

From source file:com.vlaaad.dice.game.tutorial.ui.windows.TutorialMessageWindow.java

License:Open Source License

@Override
protected void initialize() {
    Table table = new Table(Config.skin);
    table.setBackground(Config.skin.getDrawable("ui-tutorial-window-background"));

    label = new LocLabel("", DieMessageWindow.ACTIVE);
    label.setWrap(true);/*from w ww  . j  a  v a  2  s .c om*/
    label.setAlignment(Align.center);

    table.setTouchable(Touchable.disabled);

    Label tapToContinue = new LocLabel("tap-to-continue", DieMessageWindow.INACTIVE);
    tapToContinue.setWrap(true);
    tapToContinue.setAlignment(Align.center);

    if (image != null) {
        image.setTouchable(Touchable.disabled);
        table.add(image).padTop(-15 - dy).row();
    }
    final Cell<LocLabel> cell = table.add(label).width(100);
    if (forceLabelHeight)
        cell.height(labelHeight);
    cell.row();
    table.add(new Image(Config.skin, "ui-tutorial-window-line")).padTop(4).row();
    table.add(tapToContinue).width(80).row();

    this.table.add(table);
}

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

License:Open Source License

@Override
protected void doShow(final UserData userData) {
    final Table items = new Table();
    final ScrollPane pane = new ScrollPane(items, new ScrollPane.ScrollPaneStyle()) {

        @Override//w w w. j a  v  a  2 s . co m
        public void layout() {
            float w = items.getPrefWidth();
            float h = Math.min(getParent().getHeight(), items.getPrefHeight());
            if (w != getWidth() || h != getHeight()) {
                setSize(w, h);
                invalidateHierarchy();
            }
            super.layout();
        }
    };
    pane.setTouchable(Touchable.childrenOnly);
    pane.setOverscroll(false, false);
    pane.setCancelTouchFocus(false);
    pane.addListener(new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {
            pane.layout();
            pane.layout();
            items.layout();
            if (actor instanceof Layout)
                ((Layout) actor).layout();
            pane.layout();
            pane.layout();
            pane.scrollTo(actor.getX(), actor.getY(), actor.getWidth(), actor.getHeight() + 100);
        }
    });

    Iterable<Die> dice = userData.dice();
    int i = 1;
    int count = userData.diceCount();
    for (Die die : dice) {
        DiePane diePane = new DiePane(die, userData, diceWindowGroup);
        table.add(diePane);
        diePane.setWidth(0);
        diePane.pack();
        diePane.setWidth(ViewController.CELL_SIZE * 6.6f);
        Cell cell = items.add(diePane).fillX().maxWidth(ViewController.CELL_SIZE * 6.6f);
        if (i != count) {
            cell.padBottom(-1);
        }
        cell.row();
        map.put(die, diePane);
        diePane.info.addListener(createMinimizeListener(die, dice));
        i++;
    }
    items.pack();
    table.add(pane).width(items.getPrefWidth());//.size(items.getPrefWidth(), 200);
}

From source file:de.bitbrain.craft.ui.widgets.RecipeWidget.java

License:Open Source License

private Actor generateMaterials(Item item) {
    materialSet.clear();//  w  w  w  . ja  va 2s  .co  m
    Table table = new Table();
    addCaption(Bundles.MATERIALS, table);
    Table materialTable = new Table();
    table.add(materialTable);
    ItemBag materials = api.findIngredients(item);
    materialTable.setWidth(500f);
    int index = 0;
    for (Entry<Item, Integer> entry : materials) {
        int amount = api.getItemAmount(entry.getKey());
        IconWidget widget = new IconWidget(entry.getKey(), amount);
        materialSet.put(entry.getKey(), widget);
        widget.setHandle(new MaterialIconHandle(entry.getValue()));
        widget.setWidth(Sizes.MATERIAL_ICON);
        widget.setHeight(Sizes.MATERIAL_ICON);
        Tooltip.create(widget).text(Bundles.items.get(entry.getKey().getId().toString()));
        Cell<IconWidget> cell = materialTable.add(widget);
        if (index > 0 && index % 2 == 0) {
            cell.row();
        }
        index++;
    }
    return table;
}