Java Code Examples for com.badlogic.gdx.scenes.scene2d.ui.ScrollPane#ScrollPaneStyle

The following examples show how to use com.badlogic.gdx.scenes.scene2d.ui.ScrollPane#ScrollPaneStyle . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CraftingScreen.java    From TerraLegion with MIT License 5 votes vote down vote up
@Override
public void create() {
	camera = new OrthoCamera();
	camera.resize();

	stageSb = new SpriteBatch();
	stage = new Stage(new StretchViewport(Settings.getWidth(), Settings.getHeight()), stageSb);

	//CATEGORY BUTTONS
	stage.addActor(toolCategoryBtn.getImageButton());
	stage.addActor(furnitureCategoryBtn.getImageButton());

	ScrollPane.ScrollPaneStyle paneStyle = new ScrollPane.ScrollPaneStyle();
	paneStyle.background = new TextureRegionDrawable(new TextureRegion(ResourceManager.getInstance().getTexture("invStageBg")));
	//paneStyle.vScrollKnob = new TextureRegionDrawable();
	//paneStyle.hScroll = paneStyle.hScrollKnob = paneStyle.vScroll = paneStyle.vScrollKnob;

	Table craftingContainer = CachePool.getTable();
	usedTablesCache.add(craftingContainer);
	float startX = (Settings.getWidth() / 2) - 255;
	craftingContainer.setBounds(startX, 0, 370, Settings.getHeight() - 61);

	craftingTable = CachePool.getTable();
	stage.addListener(new CraftingButtonClickListener(stage, craftingTable, craftingContainer.getX(), craftingContainer.getY()));
	usedTablesCache.add(craftingTable);

	pane = new ScrollPane(craftingTable, paneStyle);
	craftingContainer.add(pane).width(370).height(Settings.getHeight() - 61);
	craftingContainer.row();
	stage.addActor(craftingContainer);

	itemNameLabel = new Label("", ResourceManager.getInstance().getFont("font"), startX + 370 + 10, Settings.getHeight() - 61 - 35, false);
	itemInfoLabel = new MultilineLabel("", ResourceManager.getInstance().getFont("font"), startX + 370 + 10, Settings.getHeight() - 61 - 85, false);

	populateCraftableItems(toolCategoryBtn.getCategory());

	InputController.getInstance().addInputProcessor(stage);
}
 
Example 2
Source File: DiceWindow.java    From dice-heroes with GNU General Public License v3.0 4 votes vote down vote up
@Override protected void doShow(final UserData userData) {
    final Table items = new Table();
    final ScrollPane pane = new ScrollPane(items, new ScrollPane.ScrollPaneStyle()) {

        @Override 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);
}
 
Example 3
Source File: InventoryScreen.java    From TerraLegion with MIT License 4 votes vote down vote up
@Override
public void create() {
	camera = new OrthoCamera();
	camera.resize();

	stageSb = new SpriteBatch();
	stage = new Stage(new StretchViewport(Settings.getWidth(), Settings.getHeight()), stageSb);

	ScrollPane.ScrollPaneStyle paneStyle = new ScrollPane.ScrollPaneStyle();
	paneStyle.background = new TextureRegionDrawable(new TextureRegion(ResourceManager.getInstance().getTexture("invStageBg")));
	//paneStyle.vScrollKnob = new TextureRegionDrawable();
	//paneStyle.hScroll = paneStyle.hScrollKnob = paneStyle.vScroll = paneStyle.vScrollKnob;

	Table invContainer = CachePool.getTable();
	invContainer.setCullingArea(new Rectangle(0, 0, Settings.getWidth(), Settings.getHeight()));
	usedTablesCache.add(invContainer);

	float startX = (Settings.getWidth() / 2) - 255;
	invContainer.setBounds(startX, 0, 370, Settings.getHeight() - 61);

	table = CachePool.getTable();
	table.setCullingArea(new Rectangle(0, 0, Settings.getWidth(), Settings.getHeight()));
	table.addListener(new InventoryButtonClickListener(table));
	usedTablesCache.add(table);

	ScrollPane pane = new ScrollPane(table, paneStyle);
	pane.setCancelTouchFocus(false);
	pane.setCullingArea(new Rectangle(0, 0, Settings.getWidth(), Settings.getHeight()));

	invContainer.add(pane).width(370).height(Settings.getHeight() - 61);
	invContainer.row();
	stage.addActor(invContainer);

	itemNameLabel = new Label("", ResourceManager.getInstance().getFont("font"), startX + 370 + 10, Settings.getHeight() - 61 - 35, false);
	itemInfoLabel = new MultilineLabel("", ResourceManager.getInstance().getFont("font"), startX + 370 + 10, Settings.getHeight() - 61 - 85, false);

	for (int y = 0; y < inventory.getHeight(); y++) {
		for (int x = 0; x < inventory.getWidth(); x++) {

			ItemStack stack = inventory.getItemStack(x, y);
			ItemBox box = new ItemBox(stack, x, y, x + " " + y);
			InventoryDragListener dragListener = getDragListener(box);
			dragListener.setScrollPane(pane);
			dragListener.setTableHolder(table);
			dragListener.setInventory(inventory);
			box.addListener(dragListener);

			Cell<Table> cell = table.add((Table) box).width(60).height(60).padRight(10).padBottom(10);
			if (x == 0) {
				cell.padLeft(10);
			}
			if (y == 0) {
				cell.padTop(10);
			}
		}
		table.row();
	}
	InputController.getInstance().addInputProcessor(stage);
}
 
Example 4
Source File: ListViewStyle.java    From vis-ui with Apache License 2.0 4 votes vote down vote up
public ListViewStyle (ListViewStyle style) {
	if (style.scrollPaneStyle != null) this.scrollPaneStyle = new ScrollPane.ScrollPaneStyle(style.scrollPaneStyle);
}