com.badlogic.gdx.scenes.scene2d.ui.ScrollPane Java Examples
The following examples show how to use
com.badlogic.gdx.scenes.scene2d.ui.ScrollPane.
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: ScrollInventoryActor.java From Cubes with MIT License | 6 votes |
public ScrollInventoryActor(Inventory inventory, int slots) { defaults().space(4f); add(new Label(inventory.getDisplayName(), new LabelStyle(Fonts.hud, Color.WHITE))); row(); inner = new Table(); inner.defaults().space(4f); for (int i = 0; i < inventory.itemStacks.length; i++) { SlotActor slotActor = new SlotActor(inventory, i); inner.add(slotActor); if ((i + 1) % inventory.width == 0) { inner.row(); } } inner.pack(); scrollPane = new ScrollPane(inner); scrollPane.setScrollingDisabled(true, false); add(scrollPane).height(slots * CALIBRATION_PER_ROW).fill(); row(); pack(); }
Example #2
Source File: MainScreen.java From gdx-skineditor with Apache License 2.0 | 6 votes |
public MainScreen(SkinEditorGame game) { this.game = game; barMenu = new MenuBar(game); barWidgets = new WidgetsBar(game); panePreview = new PreviewPane(game); paneOptions = new OptionsPane(game); stage = new Stage(new ScreenViewport()); Table table = new Table(); table.setFillParent(true); table.top().left().add(barMenu).expandX().fillX().colspan(2).row(); table.top().left().add(barWidgets).expandX().fillX().colspan(2).row(); table.top().left().add(paneOptions).width(420).left().fill().expandY(); ScrollPane scrollPane = new ScrollPane(panePreview); table.add(scrollPane).fill().expand(); stage.addActor(table); barWidgets.initializeButtons(); }
Example #3
Source File: CCScrollView.java From cocos-ui-libgdx with Apache License 2.0 | 6 votes |
@Override public Group groupChildrenParse(CocoStudioUIEditor editor, ObjectData widget, Group parent, Actor actor) { ScrollPane scrollPane = (ScrollPane) actor; Table table = new Table(); for (ObjectData childrenWidget : widget.getChildren()) { Actor childrenActor = editor.parseWidget(table, childrenWidget); if (childrenActor == null) { continue; } table.setSize(Math.max(table.getWidth(), childrenActor.getRight()), Math.max(table.getHeight(), childrenActor.getTop())); table.addActor(childrenActor); } sort(widget, table); // scrollPane.setWidget(table); return scrollPane; }
Example #4
Source File: SemaphoreGuardTest.java From gdx-ai with Apache License 2.0 | 6 votes |
@Override public Actor createActor (Skin skin) { // Create the semaphore NonBlockingSemaphoreRepository.clear(); NonBlockingSemaphoreRepository.addSemaphore("dogSemaphore", 1); Reader reader = null; try { // Parse Buddy's tree reader = Gdx.files.internal("data/dogSemaphore.tree").reader(); BehaviorTreeParser<Dog> parser = new BehaviorTreeParser<Dog>(BehaviorTreeParser.DEBUG_HIGH); BehaviorTree<Dog> buddyTree = parser.parse(reader, new Dog("Buddy")); // Clone Buddy's tree for Snoopy BehaviorTree<Dog> snoopyTree = (BehaviorTree<Dog>)buddyTree.cloneTask(); snoopyTree.setObject(new Dog("Snoopy")); // Create split pane BehaviorTreeViewer<?> buddyTreeViewer = createTreeViewer(buddyTree.getObject().name, buddyTree, false, skin); BehaviorTreeViewer<?> snoopyTreeViewer = createTreeViewer(snoopyTree.getObject().name, snoopyTree, false, skin); return new SplitPane(new ScrollPane(buddyTreeViewer, skin), new ScrollPane(snoopyTreeViewer, skin), true, skin, "default-horizontal"); } finally { StreamUtils.closeQuietly(reader); } }
Example #5
Source File: PathFinderTests.java From gdx-ai with Apache License 2.0 | 6 votes |
protected CollapsableWindow addBehaviorSelectionWindow (String title, List<String> testList, float x, float y) { CollapsableWindow window = new CollapsableWindow(title, skin); window.row(); ScrollPane pane = new ScrollPane(testList, skin); pane.setFadeScrollBars(false); pane.setScrollX(0); pane.setScrollY(0); window.add(pane); window.pack(); window.pack(); if (window.getHeight() > stage.getHeight()) { window.setHeight(stage.getHeight()); } window.setX(x < 0 ? stage.getWidth() - (window.getWidth() - (x + 1)) : x); window.setY(y < 0 ? stage.getHeight() - (window.getHeight() - (y + 1)) : y); window.layout(); window.collapse(); stage.addActor(window); return window; }
Example #6
Source File: MessageTests.java From gdx-ai with Apache License 2.0 | 6 votes |
protected CollapsableWindow addTestSelectionWindow (String title, List<String> testList, float x, float y) { CollapsableWindow window = new CollapsableWindow(title, skin); window.row(); ScrollPane pane = new ScrollPane(testList, skin); pane.setFadeScrollBars(false); pane.setScrollX(0); pane.setScrollY(0); window.add(pane); window.pack(); window.pack(); if (window.getHeight() > stage.getHeight()) { window.setHeight(stage.getHeight()); } window.setX(x < 0 ? stage.getWidth() - (window.getWidth() - (x + 1)) : x); window.setY(y < 0 ? stage.getHeight() - (window.getHeight() - (y + 1)) : y); window.layout(); window.collapse(); stage.addActor(window); return window; }
Example #7
Source File: ParseTreeTest.java From gdx-ai with Apache License 2.0 | 5 votes |
@Override public Actor createActor (Skin skin) { Reader reader = null; try { reader = Gdx.files.internal("data/dog.tree").reader(); BehaviorTreeParser<Dog> parser = new BehaviorTreeParser<Dog>(BehaviorTreeParser.DEBUG_HIGH); BehaviorTree<Dog> tree = parser.parse(reader, new Dog("Buddy")); treeViewer = createTreeViewer(tree.getObject().name, tree, true, skin); return new ScrollPane(treeViewer, skin); } finally { StreamUtils.closeQuietly(reader); } }
Example #8
Source File: LogMenu.java From Cubes with MIT License | 5 votes |
public LogMenu() { label = new Label("", new LabelStyle(Fonts.smallHUD, Color.BLACK)); label.setWrap(true); Drawable background = new TextureRegionDrawable(Assets.getTextureRegion("core:hud/LogBackground.png")); scrollPane = new ScrollPane(label, new ScrollPaneStyle(background, null, null, null, null)); scrollPane.setScrollingDisabled(true, false); back = MenuTools.getBackButton(this); stage.addActor(scrollPane); stage.addActor(back); refresh(); }
Example #9
Source File: FileChooser.java From gdx-soundboard with MIT License | 5 votes |
@Override public Dialog show(Stage stage, Action action) { final Table content = getContentTable(); content.add(fileListLabel).top().left().expandX().fillX().row(); content.add(new ScrollPane(fileList, skin)).size(300, 150).fill().expand().row(); if (fileNameEnabled) { content.add(fileNameLabel).fillX().expandX().row(); content.add(fileNameInput).fillX().expandX().row(); stage.setKeyboardFocus(fileNameInput); } if (newFolderEnabled) { content.add(newFolderButton).fillX().expandX().row(); } if(directoryBrowsingEnabled){ fileList.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { final FileListItem selected = fileList.getSelected(); if (selected.file.isDirectory()) { changeDirectory(selected.file); } } }); } this.stage = stage; changeDirectory(baseDir); return super.show(stage, action); }
Example #10
Source File: TextInputPanel.java From bladecoder-adventure-engine with Apache License 2.0 | 5 votes |
TextInputPanel(Skin skin, String title, String desc, boolean mandatory, String defaultValue) { input = new TextArea("", skin) { @Override public float getPrefHeight () { calculateOffsets(); float prefHeight = Math.max(prefRows, getLines()) * textHeight; if (getStyle().background != null) { prefHeight = Math.max(prefHeight + getStyle().background.getBottomHeight() + getStyle().background.getTopHeight(), getStyle().background.getMinHeight()); } return prefHeight; } @Override public void moveCursorLine (int line) { super.moveCursorLine(line); scroll.setScrollPercentY((line)/(float)input.getLines()); } }; input.setPrefRows(prefRows); scroll = new ScrollPane(input, skin); scroll.setFadeScrollBars(false); init(skin, title, desc, scroll, mandatory, defaultValue); getCell(scroll).maxHeight(input.getStyle().font.getLineHeight() * prefRows + input.getStyle().background.getBottomHeight() + input.getStyle().background.getTopHeight()); }
Example #11
Source File: EditDialog.java From bladecoder-adventure-engine with Apache License 2.0 | 5 votes |
public EditDialog(String title, Skin skin) { super(title, skin); this.skin = skin; setResizable(false); setKeepWithinStage(false); infoLbl = new Label("", skin); infoLbl.setWrap(true); centerPanel = new Table(skin); infoCell = getContentTable().add((Widget) infoLbl).prefWidth(200).height(Gdx.graphics.getHeight() * 0.5f); getContentTable().add(new ScrollPane(centerPanel, skin)).maxHeight(Gdx.graphics.getHeight() * 0.8f) .maxWidth(Gdx.graphics.getWidth() * 0.7f).minHeight(Gdx.graphics.getHeight() * 0.5f) .minWidth(Gdx.graphics.getWidth() * 0.5f); getContentTable().setHeight(Gdx.graphics.getHeight() * 0.7f); centerPanel.addListener(new InputListener() { @Override public void enter(InputEvent event, float x, float y, int pointer, com.badlogic.gdx.scenes.scene2d.Actor fromActor) { // EditorLogger.debug("ENTER - X: " + x + " Y: " + y); getStage().setScrollFocus(centerPanel); } }); button("OK", true); button("Cancel", false); // DISABLE the enter key because conflicts when newline in TextFields // key(Keys.ENTER, true); key(Keys.ESCAPE, false); padBottom(10); padLeft(10); padRight(10); }
Example #12
Source File: SteeringBehaviorsTest.java From gdx-ai with Apache License 2.0 | 5 votes |
private CollapsableWindow addTestSelectionWindow (String title, String[] tabTitles, Array<List<String>> tabLists, float x, float y) { if (tabTitles.length != tabLists.size) throw new IllegalArgumentException("tabTitles and tabList must have the same size."); CollapsableWindow window = new CollapsableWindow(title, skin); window.row(); TabbedPane tabbedPane = new TabbedPane(skin); for (int i = 0; i < tabLists.size; i++) { ScrollPane pane = new ScrollPane(tabLists.get(i), skin); pane.setFadeScrollBars(false); pane.setScrollX(0); pane.setScrollY(0); tabbedPane.addTab(" " + tabTitles[i] + " ", pane); } window.add(tabbedPane); window.pack(); window.pack(); if (window.getHeight() > stage.getHeight()) { window.setHeight(stage.getHeight()); } window.setX(x < 0 ? stage.getWidth() - (window.getWidth() - (x + 1)) : x); window.setY(y < 0 ? stage.getHeight() - (window.getHeight() - (y + 1)) : y); window.layout(); window.collapse(); stage.addActor(window); return window; }
Example #13
Source File: BehaviorTreeTests.java From gdx-ai with Apache License 2.0 | 5 votes |
public MainScreen() { Gdx.gl.glClearColor(.3f, .3f, .3f, 1); skin = new Skin(Gdx.files.internal("data/uiskin.json")); stage = new Stage(new ScreenViewport()); stage.setDebugAll(DEBUG_STAGE); // Create split pane List<String> testList = createTestList(); ScrollPane leftScrollPane = new ScrollPane(testList, skin); splitPane = new SplitPane(leftScrollPane, null, false, skin, "default-horizontal"); splitPane.setSplitAmount(Math.min((testList.getPrefWidth() + 10) / stage.getWidth(), splitPane.getSplitAmount())); // Create layout Table t = new Table(skin); t.setFillParent(true); t.add(splitPane).colspan(3).grow(); t.row(); t.add(pauseButton = new PauseButton(skin)).width(90).left(); t.add(new FpsLabel("FPS: ", skin)).left(); t.add(testDescriptionLabel = new Label("", skin)).left(); stage.addActor(t); // Set selected test changeTest(0); }
Example #14
Source File: ScrollableTextArea.java From vis-ui with Apache License 2.0 | 5 votes |
/** * Creates scroll pane for this scrolling text area with best possible default settings. Note that text area * can belong to only one scroll pane, calling this multiple times will break previously created scroll pane. * The scroll pane should be embedded in container with fixed size or optionally grow property. * @return newly created scroll pane which can be added directly to container. */ public ScrollPane createCompatibleScrollPane () { VisScrollPane scrollPane = new VisScrollPane(this); scrollPane.setOverscroll(false, false); scrollPane.setFlickScroll(false); scrollPane.setFadeScrollBars(false); scrollPane.setScrollbarsOnTop(true); scrollPane.setScrollingDisabled(true, false); return scrollPane; }
Example #15
Source File: ScrollableTextArea.java From vis-ui with Apache License 2.0 | 5 votes |
private void updateScrollPosition () { if (cullingArea == null || getParent() instanceof ScrollPane == false) return; ScrollPane scrollPane = (ScrollPane) getParent(); if (cullingArea.contains(getCursorX(), cullingArea.y) == false) { scrollPane.setScrollPercentX(getCursorX() / getWidth()); } if (cullingArea.contains(cullingArea.x, (getHeight() - getCursorY())) == false) { scrollPane.setScrollPercentY(getCursorY() / getHeight()); } }
Example #16
Source File: ScrollableTextArea.java From vis-ui with Apache License 2.0 | 5 votes |
@Override protected void setParent (Group parent) { super.setParent(parent); if (parent instanceof ScrollPane) { calculateOffsets(); } }
Example #17
Source File: SystemProfilerGUI.java From riiablo with Apache License 2.0 | 5 votes |
public void initialize() { Table graphTable = new Table(); Table graphLabels = new Table(); for (int i = 32; i >= 0; i /= 2) { graphLabels.add(label(Integer.toString(i), skin)).expandY().center().row(); if (i == 0) break; } graphTable.add(graphLabels).expandY().fillY(); graphTable.add(graph = new Graph()).expand().fill(); profilerLabels = new Table(); profilerLabels.add().expandX().fillX(); profilerLabels.add(label("max", skin, Align.right)).minWidth(MIN_LABEL_WIDTH); profilerLabels.add(label("lmax", skin, Align.right)).minWidth(MIN_LABEL_WIDTH); profilerLabels.add(label("avg", skin, Align.right)).minWidth(MIN_LABEL_WIDTH); for (SystemProfiler profiler : profilers.get()) { rows.add(new ProfilerRow(profiler, skin)); } profilersTable = new Table(); // basic once so we can get all profilers and can pack nicely act(0); ScrollPane pane = new ScrollPane(profilersTable); pane.setScrollingDisabled(true, false); add(graphTable).expand().fill(); add(pane).fillX().pad(0, 10, 10, 10).top() .prefWidth(MIN_LABEL_WIDTH * 7).minWidth(0); pack(); }
Example #18
Source File: IncludeSubtreeTest.java From gdx-ai with Apache License 2.0 | 5 votes |
@Override public Actor createActor (Skin skin) { BehaviorTreeLibraryManager libraryManager = BehaviorTreeLibraryManager.getInstance(); libraryManager.setLibrary(new BehaviorTreeLibrary(BehaviorTreeParser.DEBUG_HIGH)); String name = lazy ? "data/dogIncludeLazy.tree" : "data/dogInclude.tree"; BehaviorTree<Dog> tree = libraryManager.createBehaviorTree(name, new Dog("Buddy")); BehaviorTreeViewer<?> treeViewer = createTreeViewer(tree.getObject().name, tree, true, skin); return new ScrollPane(treeViewer, skin); }
Example #19
Source File: Scene2dUtils.java From gdx-texture-packer-gui with Apache License 2.0 | 5 votes |
/** * @param scrollPane widget will be scrolled * @param list must be child of scrollPane */ public static void scrollDownToSelectedListItem(ScrollPane scrollPane, List list) { if (list.getSelectedIndex() == -1) return; float y = list.getHeight() - (list.getSelectedIndex() * list.getItemHeight()) - list.getItemHeight(); float height = list.getItemHeight(); scrollPane.scrollTo(0, y, 0, height); }
Example #20
Source File: ProgrammaticallyCreatedTreeTest.java From gdx-ai with Apache License 2.0 | 5 votes |
@Override public Actor createActor (Skin skin) { BehaviorTreeLibraryManager libraryManager = BehaviorTreeLibraryManager.getInstance(); BehaviorTreeLibrary library = new BehaviorTreeLibrary(BehaviorTreeParser.DEBUG_HIGH); registerDogBehavior(library); libraryManager.setLibrary(library); BehaviorTree<Dog> tree = libraryManager.createBehaviorTree("dog", new Dog("Buddy")); BehaviorTreeViewer<?> treeViewer = createTreeViewer(tree.getObject().name, tree, true, skin); return new ScrollPane(treeViewer, skin); }
Example #21
Source File: CraftingScreen.java From TerraLegion with MIT License | 5 votes |
@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 #22
Source File: NinePatchEditorDialog.java From gdx-skineditor with Apache License 2.0 | 5 votes |
/** * */ private void refreshImage() { float newX = imgWidth * currentZoom; float newY = imgHeight * currentZoom; image.setSize(newX, newY); cellImage.width(newX).height(newY); tableEditor.setWidth(newX); tableEditor.setHeight(newY); ScrollPane sp = (ScrollPane) tableEditor.getParent(); sp.layout(); }
Example #23
Source File: InvitesWindow.java From dice-heroes with GNU General Public License v3.0 | 5 votes |
@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); }
Example #24
Source File: CreatureQueueWindow.java From dice-heroes with GNU General Public License v3.0 | 5 votes |
@Override protected void initialize() { creaturesList.defaults().pad(2); 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); }
Example #25
Source File: PropertyPanelContainer.java From talos with Apache License 2.0 | 5 votes |
public PropertyPanelContainer(Skin skin) { setSkin(skin); container = new Table(); fakeContainer = new Table(); scrollPane = new ScrollPane(fakeContainer); add(scrollPane).grow(); fakeContainer.add(container).growX().row(); fakeContainer.add().expandY(); }
Example #26
Source File: UIUtils.java From uracer-kotd with Apache License 2.0 | 4 votes |
public static ScrollPane newScrollPane () { ScrollPane pane = new ScrollPane(null, Art.scrSkin); return pane; }
Example #27
Source File: EditActionDialog.java From bladecoder-adventure-engine with Apache License 2.0 | 4 votes |
private void setAction() { String id = actionPanel.getText(); getCenterPanel().clear(); addInputPanel(actionPanel); Action tmp = null; tmp = ActionDetector.create(id, null); String info = ActionUtils.getInfo(tmp.getClass()); if(ActionUtils.isDeprecated(tmp.getClass())) info = "[RED]DEPRECATED[]\n" + info; setInfo(info); if (e == null || tmp == null || !(e.getClass().getName().equals(tmp.getClass().getName()))) e = tmp; if (e != null) { Param[] params = ActionUtils.getParams(e); i = new InputPanel[params.length]; for (int j = 0; j < params.length; j++) { if (params[j].options instanceof Enum[]) { i[j] = InputPanelFactory.createInputPanel(getSkin(), params[j].name, params[j].desc, params[j].type, params[j].mandatory, params[j].defaultValue, (Enum[]) params[j].options); } else { i[j] = InputPanelFactory.createInputPanel(getSkin(), params[j].name, params[j].desc, params[j].type, params[j].mandatory, params[j].defaultValue, (String[]) params[j].options); } addInputPanel(i[j]); if ((i[j].getField() instanceof TextField && params[j].name.toLowerCase().endsWith("text")) || i[j].getField() instanceof ScrollPane) { i[j].getCell(i[j].getField()).fillX(); } } } else { i = new InputPanel[0]; } }
Example #28
Source File: TestTextAreaAndScroll.java From vis-ui with Apache License 2.0 | 4 votes |
private void addNormalWidgets () { Skin skin = VisUI.getSkin(); TextArea textArea = new TextArea("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec iaculis odio.", skin); textArea.setPrefRows(5); // --- VisTable table = new VisTable(); for (int i = 0; i < 20; i++) table.add(new Label("Label #" + (i + 1), skin)).expand().fill().row(); ScrollPane scrollPane = new ScrollPane(table, skin, "list"); scrollPane.setFlickScroll(false); scrollPane.setFadeScrollBars(false); // --- add(textArea).row(); add(scrollPane).spaceTop(8).fillX().expandX().row(); }
Example #29
Source File: ListViewStyle.java From vis-ui with Apache License 2.0 | 4 votes |
public ListViewStyle (ListViewStyle style) { if (style.scrollPaneStyle != null) this.scrollPaneStyle = new ScrollPane.ScrollPaneStyle(style.scrollPaneStyle); }
Example #30
Source File: ScrollableTextArea.java From vis-ui with Apache License 2.0 | 4 votes |
void updateScrollLayout () { invalidateHierarchy(); layout(); if (getParent() instanceof ScrollPane) ((ScrollPane) getParent()).layout(); updateScrollPosition(); }