List of usage examples for com.badlogic.gdx.scenes.scene2d.ui ScrollPane ScrollPane
public ScrollPane(Actor widget, ScrollPaneStyle style)
From source file:com.uwsoft.editor.gdx.ui.dialogs.EditAnimationDialog.java
License:Apache License
public void renderMainList() { item.updateDataVO();// w w w . ja va2 s.c o m listContainer.clear(); float itmHeight = 25; int cnt = animations.size(); wrapper.setHeight(itmHeight * cnt); scroll = new ScrollPane(wrapper, uiStage.textureManager.editorSkin); scroll.setWidth(topWrapper.getWidth()); scroll.setHeight(maxHeight); scroll.setFlickScroll(false); scroll.addListener(new InputListener() { public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { event.stop(); return true; } }); if (topWrapper.findActor("scroll") != null) { topWrapper.findActor("scroll").remove(); } topWrapper.addActor(scroll); if (itmHeight * cnt < maxHeight - 10) { listContainer.setHeight(maxHeight - 10); } else { listContainer.setHeight(itmHeight * cnt); } int iterator = 0; for (Map.Entry<String, SpriteAnimation.Animation> entry : animations.entrySet()) { final String name = entry.getKey(); SpriteAnimation.Animation value = entry.getValue(); final CompositeItem itm = stage.sceneLoader.getLibraryAsActor("animationValueControl"); itm.getLabelById("name") .setText("\"" + name + "\" frames: " + value.startFrame + " - " + value.endFrame); listContainer.addActor(itm); itm.setX(2); itm.setY(listContainer.getHeight() - (itm.getHeight() + 3) * (iterator + 1)); iterator++; itm.getTextButtonById("deleteBtn").addListener(new ClickListener() { public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { return true; } public void touchUp(InputEvent event, float x, float y, int pointer, int button) { animations.remove(name); renderMainList(); } }); } uiStage.updateCurrentItemState(); }
From source file:com.uwsoft.editor.gdx.ui.LibraryList.java
License:Apache License
public LibraryList(final UIStage s, float width, float height) { stage = s;/*from w ww.j a v a 2 s . co m*/ libraryItems = new ArrayList<>(); this.setWidth(width); this.setHeight(height); final Table container = new Table(); Table table = new Table(); listContainer = new Group(); container.setX(0); container.setY(0); container.setWidth(getWidth() - 1); container.setHeight(getHeight() - 20); listContainer.setWidth(getWidth() - 20); listContainer.setHeight(getHeight() - 25); final ScrollPane scroll = new ScrollPane(table, s.textureManager.editorSkin); container.add(scroll).colspan(4).width(getWidth()); container.row(); scroll.addListener(new InputListener() { public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { event.stop(); return true; } }); scroll.setHeight(getHeight() - 20); scroll.setY(0); scroll.setFlickScroll(false); items = s.getSandbox().sceneControl.getCurrentSceneVO().libraryItems; Label dummyTst = new Label("dummy", s.textureManager.editorSkin); if (items.size() * dummyTst.getHeight() > listContainer.getHeight()) { listContainer.setHeight(items.size() * (dummyTst.getHeight() + 2)); } drawItems(); table.add(listContainer); table.row(); addActor(container); }
From source file:com.uwsoft.editor.gdx.ui.ParticleList.java
License:Apache License
public ParticleList(final UIStage s, float width, float height) { this.setWidth(width); this.setHeight(height); final Table container = new Table(); Table table = new Table(); container.setX(0);//from w ww . jav a2 s . c o m container.setY(0); container.setWidth(getWidth() - 1); container.setHeight(getHeight() - 20); final ScrollPane scroll = new ScrollPane(table, s.textureManager.editorSkin); container.add(scroll).colspan(4).width(getWidth()); container.row(); scroll.addListener(new InputListener() { public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { event.stop(); return true; } }); scroll.setHeight(getHeight() - 20); scroll.setFlickScroll(false); // change to particle list HashMap<String, ParticleEffect> particles = s.textureManager.getProjectParticleList(); if (particles == null) return; int i = 0; for (String key : particles.keySet()) { final ParticleThumbnailBox thumb = new ParticleThumbnailBox(s, key); final String pname = key; table.add(thumb).pad(3); if ((i - 7) % 4 == 0) { table.row(); } i++; } addActor(container); }
From source file:com.uwsoft.editor.gdx.ui.UIItemsBox.java
License:Apache License
public void initContent() { for (int i = 0; i < this.getChildren().size; i++) { if (this.getChildren().get(i).getName() != null && this.getChildren().get(i).getName().equals("treeTable")) { this.getChildren().get(i).remove(); break; }//w w w . ja va 2 s . c om } skin = stage.textureManager.editorSkin; tree = new Tree(skin); CompositeItem sceneItems = stage.getSandbox().getCurrentScene(); Node root = addTree(sceneItems, stage.getCompositePanel().isRootScene()); for (int i = 0; i < sceneItems.getItems().size(); i++) { if (sceneItems.getItems().get(i).isComposite()) { innerComposite(sceneItems.getItems().get(i), root); } else { addTree(sceneItems.getItems().get(i), root); } } //expand root if (root != null && root.getChildren() != null && root.getChildren().size > 0 && root.getChildren().get(0) != null) { root.getChildren().get(0).expandTo(); } Table scrolltable = new Table(); scrolltable.padBottom(20); scrolltable.add(tree).fill().expand(); final ScrollPane scroller = new ScrollPane(scrolltable, skin); scroller.setFlickScroll(false); final Table table = new Table(); table.setFillParent(true); table.padTop(10); table.add(scroller).fill().expand(); table.setName("treeTable"); addActor(table); tree.addListener(new ChangeListener() { @Override public void changed(ChangeEvent event, Actor actor) { Array<Node> selectedNodes = tree.getSelection().toArray(); for (int i = 0; i < selectedNodes.size; i++) { System.out.println(); IBaseItem baseItem = (IBaseItem) selectedNodes.get(i).getObject(); IBaseItem item = getCurrentSceneItem(stage.getSandbox().getCurrentScene(), baseItem); if (item != null) { addSelectionAction(item); } } } }); }
From source file:com.vlaaad.dice.ui.windows.CreatureQueueWindow.java
License:Open Source License
@Override protected void initialize() { creaturesList.defaults().pad(2);/*from w ww .j av a2 s. c om*/ creaturesList.padTop(12); Image left = new Image(Config.skin, "ui-creature-queue-gradient-left"); left.setScaling(Scaling.stretchY); left.setAlign(Align.left); left.setTouchable(Touchable.disabled); Image right = new Image(Config.skin, "ui-creature-queue-gradient-right"); right.setScaling(Scaling.stretchY); right.setAlign(Align.right); right.setTouchable(Touchable.disabled); Stack stack = new Stack(); stack.add(new ScrollPane(creaturesList, new ScrollPane.ScrollPaneStyle())); stack.add(left); stack.add(right); Table content = new Table(Config.skin); content.setTouchable(Touchable.enabled); content.setBackground("ui-inventory-ability-window-background"); content.defaults().pad(2); content.add(new LocLabel("ui-turns-order")).row(); content.add(new Image(Config.skin, "ui-creature-info-line")).width(100).row(); content.add(stack).maxWidth(table.getStage().getWidth() - 45).padRight(4).padLeft(4).row(); table.add(content); }
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/*from w w w . jav a 2s .c om*/ 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:cs383.team1.input.ui.SubEquip.java
public SubEquip(Skin sk, MenuEquip m) { skin = sk;//from ww w.j ava2 s. c o m subT = new Table(); menu = m; subSP = new ScrollPane(subT, skin); subSP.setFadeScrollBars(false); subSP.setScrollingDisabled(true, false); subSP.setOverscroll(false, false); updateItems(); }
From source file:de.cwclan.gdxtest.core.screens.LevelMenu.java
@Override public void show() { stage = new Stage(); Gdx.input.setInputProcessor(stage);/*from w w w .ja va 2s . com*/ skin = new Skin(Gdx.files.internal("ui/menuSkin.json"), new TextureAtlas("ui/atlas.pack")); List list = new List(new String[] { "de.cwclan.gdxtest.core.games.CarGame", "de.cwclan.gdxtest.core.games.JumperGame", "de.cwclan.gdxtest.core.games.TiledGame" }, skin); list.setSelectedIndex(0); ScrollPane scrollPane = new ScrollPane(list, skin); scrollPane.setWidth(30); TextButton playButton = new TextButton("Druf da", skin); playButton.pad(5); playButton.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { try { Class<? extends Screen> clazz = (Class<? extends Screen>) Class.forName(list.getSelection()); Screen screen = clazz.newInstance(); ((Game) Gdx.app.getApplicationListener()).setScreen(screen); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException ex) { System.err.println(ex.getMessage()); } } }); TextButton backButton = new TextButton("zurck", skin, "small"); backButton.pad(5); backButton.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { ((Game) Gdx.app.getApplicationListener()).setScreen(new MainMenu()); } }); table = new Table(skin); table.setFillParent(true); table.debug(); table.setFillParent(true); table.add("Select Level", "big").colspan(3).expandX().spaceBottom(50).row(); table.add(scrollPane).uniformX().left().expandY(); table.add(playButton).uniformX(); table.add(backButton).uniformY().bottom().right(); stage.addActor(table); }
From source file:de.longri.cachebox3.develop.tools.skin_editor.actors.OptionsPane.java
License:Apache License
/** * *//*from w w w .ja v a 2 s . c om*/ public OptionsPane(final SkinEditorGame game, PreviewPane previewPane) { super(); //this.setDebug(true); this.game = game; this.previewPane = previewPane; left(); top(); setBackground(game.skin.getDrawable("default-pane")); styleLabelCell = add(new Label("Styles", game.skin, "title")).pad(5); styleLabelCell.row(); styleLabelCellPrefHeight = styleLabelCell.getPrefHeight(); listStyles = new List<String>(game.skin, "dimmed"); listStyles.setItems(listItems); ScrollPane styleScrollPane = new ScrollPane(listStyles, game.skin); styleScrollPane.setFlickScroll(false); styleScrollPane.setFadeScrollBars(false); styleScrollPane.setScrollbarsOnTop(true); styleScrollPane.setScrollBarPositions(false, true); styleScrollPane.setScrollingDisabled(true, false); styleCell = add(styleScrollPane).height(200).expandX().fillX().pad(5); styleCell.row(); // Add buttons Table tableStylesButtons = new Table(); TextButton buttonNewStyle = new TextButton("New Style", game.skin); TextButton buttonDeleteStyle = new TextButton("Delete Style", game.skin); tableStylesButtons.add(buttonNewStyle).pad(5); tableStylesButtons.add(buttonDeleteStyle).pad(5); styleButtonCell = add(tableStylesButtons); styleButtonCell.row(); styleButtonCellPrefHeight = styleButtonCell.getPrefHeight(); // Callbacks listStyles.addListener(new ChangeListener() { @Override public void changed(ChangeEvent event, Actor actor) { String key = (String) listStyles.getSelected(); if (key != null) { Gdx.app.log("OptionsPane", "Selected style: " + key); currentStyle = styles.get(key); updateTableFields(key); } } }); buttonNewStyle.addListener(new ChangeListener() { @Override public void changed(ChangeEvent event, Actor actor) { createNewStyle(); } }); buttonDeleteStyle.addListener(new ChangeListener() { @Override public void changed(ChangeEvent event, Actor actor) { showDeleteDialog(); } }); // Initialize table add(new Label("Fields", game.skin, "title")).pad(5).padTop(10).row(); tableFields = new Table(game.skin); tableFields.setBackground(game.skin.getDrawable("dialogDim")); tableFields.left().top(); ScrollPane scroll2 = new ScrollPane(tableFields, game.skin); scroll2.setFlickScroll(false); scroll2.setFadeScrollBars(false); scroll2.setScrollbarsOnTop(true); scroll2.setScrollBarPositions(false, true); scroll2.setScrollingDisabled(true, false); add(scroll2).pad(5).expand().fill(); this.layout(); }
From source file:de.longri.cachebox3.develop.tools.skin_editor.ColorPickerDialog.java
License:Apache License
/** * *//*from w w w. ja va 2 s.com*/ public ColorPickerDialog(final SkinEditorGame game, final Field field) { super("Color Picker", game.skin); this.game = game; this.field = field; tableColors = new Table(game.skin); tableColors.left().top().pad(5); tableColors.defaults().pad(5); colors = game.skinProject.getAll(SkinColor.class); updateTable(); TextButton buttonNewColor = new TextButton("New Color", game.skin); buttonNewColor.addListener(new ChangeListener() { @Override public void changed(ChangeEvent event, Actor actor) { // Need to steal focus first with this hack (Thanks to Z-Man) Frame frame = new Frame(); frame.setUndecorated(true); frame.setOpacity(0); frame.setLocationRelativeTo(null); frame.setVisible(true); frame.toFront(); frame.setVisible(false); frame.dispose(); // Call swing color picker java.awt.Color color = JColorChooser.showDialog(null, "Pick your color", java.awt.Color.WHITE); if (color != null) { String colorName = JOptionPane.showInputDialog("Name your color"); if ((colorName != null) && (colorName.isEmpty() == false)) { // Verify if the color name is already in use if (colors.containsKey(colorName) == true) { game.showMsgDlg("Error", "Color name already in use!", game.screenMain.stage); } else { // Add the color (asuming RGBA) float[] components = color.getComponents(null); SkinColor newColor = new SkinColor(components[0], components[1], components[2], components[3]); newColor.skinName = colorName; colors.put(colorName, newColor); game.screenMain.saveToSkin(); // update table updateTable(); } } } } }); TextButton buttonNoColor = new TextButton("Empty Color", game.skin); buttonNoColor.addListener(new ChangeListener() { @Override public void changed(ChangeEvent event, Actor actor) { try { field.set(game.screenMain.paneOptions.currentStyle, null); } catch (Exception e) { e.printStackTrace(); } game.screenMain.saveToSkin(); hide(); game.screenMain.panePreview.refresh(); game.screenMain.paneOptions.updateSelectedTableFields(); } }); ScrollPane scrollPane = new ScrollPane(tableColors, game.skin); scrollPane.setFlickScroll(false); scrollPane.setFadeScrollBars(false); scrollPane.setScrollbarsOnTop(true); getContentTable().add(scrollPane).width(540).height(320).pad(20); getButtonTable().add(buttonNewColor); if (field != null) { getButtonTable().add(buttonNoColor); } getButtonTable().padBottom(15); button("Cancel", false); key(com.badlogic.gdx.Input.Keys.ESCAPE, false); }