List of usage examples for com.badlogic.gdx.utils Align bottom
int bottom
To view the source code for com.badlogic.gdx.utils Align bottom.
Click Source Link
From source file:com.agateau.pixelwheels.racescreen.HudContent.java
License:Open Source License
public HudContent(Assets assets, GameWorld gameWorld, Hud hud) { mAssets = assets;/*from ww w. j a v a 2 s. c om*/ mGameWorld = gameWorld; mHud = hud; Skin skin = assets.ui.skin; AnchorGroup root = hud.getRoot(); createPlayerLabels(root); mCountDownLabel = new Label("", skin, "hudCountDown"); mCountDownLabel.setAlignment(Align.bottom); root.addPositionRule(mCountDownLabel, Anchor.BOTTOM_CENTER, root, Anchor.CENTER); }
From source file:com.agateau.ui.UiBuilder.java
License:Apache License
private static int parseAlign(XmlReader.Element element) { String alignText = element.getAttribute("align", ""); if (alignText.isEmpty()) { return -1; }//from w ww. j ava 2s . c om if (alignText.equals("center")) { return Align.center; } else if (alignText.equals("centerLeft")) { return Align.left; } else if (alignText.equals("centerRight")) { return Align.right; } else if (alignText.equals("topLeft")) { return Align.topLeft; } else if (alignText.equals("topCenter")) { return Align.top; } else if (alignText.equals("topRight")) { return Align.topRight; } else if (alignText.equals("bottomLeft")) { return Align.bottomLeft; } else if (alignText.equals("bottomCenter")) { return Align.bottom; } else if (alignText.equals("bottomRight")) { return Align.bottomRight; } else { throw new RuntimeException("Unknown value of 'align': " + alignText); } }
From source file:com.crashinvaders.common.scene2d.HorizontalGroupExtended.java
License:Apache License
@Override public void layout() { float spacing = this.spacing, padBottom = this.padBottom; int align = this.align; boolean reverse = this.reverse, round = this.round; float groupHeight = getHeight() - padTop - padBottom; float x = !reverse ? padLeft : getWidth() - padRight + spacing; Array<Actor> children = getVisibleChildren(); for (int i = 0, n = children.size; i < n; i++) { Actor child = children.get(i);/*from www .j a va2 s . c o m*/ float width, height; if (child instanceof Layout) { Layout layout = (Layout) child; if (fill > 0) height = groupHeight * fill; else height = Math.min(layout.getPrefHeight(), groupHeight); height = Math.max(height, layout.getMinHeight()); float maxHeight = layout.getMaxHeight(); if (maxHeight > 0 && height > maxHeight) height = maxHeight; width = layout.getPrefWidth(); } else { width = child.getWidth(); height = child.getHeight(); if (fill > 0) height *= fill; } float y = padBottom; if ((align & Align.top) != 0) y += groupHeight - height; else if ((align & Align.bottom) == 0) // center y += (groupHeight - height) / 2; if (reverse) x -= (width + spacing); if (round) child.setBounds(Math.round(x), Math.round(y), Math.round(width), Math.round(height)); else child.setBounds(x, y, width, height); if (!reverse) x += (width + spacing); } }
From source file:com.crashinvaders.common.scene2d.HorizontalGroupExtended.java
License:Apache License
/** Sets {@link Align#top} and clears {@link Align#bottom} for the alignment of widgets within the horizontal group. */ public HorizontalGroupExtended top() { align |= Align.top;// w w w . j a v a2 s. co m align &= ~Align.bottom; return this; }
From source file:com.crashinvaders.common.scene2d.HorizontalGroupExtended.java
License:Apache License
/** Sets {@link Align#bottom} and clears {@link Align#top} for the alignment of widgets within the horizontal group. */ public HorizontalGroupExtended bottom() { align |= Align.bottom; align &= ~Align.top;/* w w w . j a v a 2 s . c o m*/ return this; }
From source file:com.crashinvaders.common.scene2d.visui.ToastManager.java
License:Apache License
private void updateToastsPositions() { boolean bottom = (alignment & Align.bottom) != 0; boolean left = (alignment & Align.left) != 0; float y = bottom ? screenPadding : root.getHeight() - screenPadding; for (Toast toast : toasts) { Table table = toast.getMainTable(); table.setPosition(left ? screenPadding : root.getWidth() - table.getWidth() - screenPadding, bottom ? y : y - table.getHeight()); y += (table.getHeight() + messagePadding) * (bottom ? 1 : -1); }//from w w w . ja v a 2s .c om }
From source file:com.kotcrab.vis.editor.module.scene.entitymanipulator.AlignmentToolsDialog.java
License:Apache License
public AlignmentToolsDialog(ModuleInjector injector) { injector.injectModules(this); setBackground(VisUI.getSkin().getDrawable("window-bg")); setTouchable(Touchable.enabled);/*from w w w . ja v a2 s .co m*/ setVisible(false); top().left(); defaults().left(); TableUtils.setSpacingDefaults(this); VisTable horizontalAlign = new VisTable(true); VisImageButton alignLeft = new VisImageButton(Icons.ALIGN_LEFT.drawable(), "Align entities at left edge"); VisImageButton alignRight = new VisImageButton(Icons.ALIGN_RIGHT.drawable(), "Align entities at right edge"); VisImageButton alignCenterX = new VisImageButton(Icons.ALIGN_CENTER_X.drawable(), "Center entities at x axis"); VisImageButton alignTop = new VisImageButton(Icons.ALIGN_BOTTOM.drawable(), "Align entities at top edge"); VisImageButton alignBottom = new VisImageButton(Icons.ALIGN_TOP.drawable(), "Align entities at bottom edge"); VisImageButton alignCenterY = new VisImageButton(Icons.ALIGN_CENTER_Y.drawable(), "Center entities at y axis"); VisImageButton closeButton = new VisImageButton("close-window"); horizontalAlign.add("Horizontal").width(70); horizontalAlign.add(alignLeft); horizontalAlign.add(alignRight); horizontalAlign.add(alignCenterX); VisTable verticalAlign = new VisTable(true); verticalAlign.add("Vertical").width(70); verticalAlign.add(alignTop); verticalAlign.add(alignBottom); verticalAlign.add(alignCenterY); add(new VisLabel("Alignment", Align.center)).expandX().fillX().top(); add(closeButton).right().row(); add(horizontalAlign).padLeft(3).colspan(2).row(); add(verticalAlign).padLeft(3).colspan(2); pack(); alignLeft.addListener(new VisChangeListener((event, actor) -> alignSelected(Align.left))); alignRight.addListener(new VisChangeListener((event, actor) -> alignSelected(Align.right))); alignCenterX.addListener(new VisChangeListener((event, actor) -> alignSelectedCenter(false))); alignTop.addListener(new VisChangeListener((event, actor) -> alignSelected(Align.top))); alignBottom.addListener(new VisChangeListener((event, actor) -> alignSelected(Align.bottom))); alignCenterY.addListener(new VisChangeListener((event, actor) -> alignSelectedCenter(true))); closeButton.addListener(new VisChangeListener((event, actor) -> setVisible(false))); }
From source file:com.kotcrab.vis.editor.module.scene.entitymanipulator.AlignmentToolsDialog.java
License:Apache License
private void alignSelected(int align) { ImmutableArray<EntityProxy> selectedEntities = entityManipulator.getSelectedEntities(); if (selectedEntities.size() == 0) return;/* w w w. j av a 2s.c om*/ UndoableActionGroup undoableGroup = new UndoableActionGroup("Change Alignment"); if (align == Align.left || align == Align.right) { float targetX = selectedEntities.get(0).getX(); for (EntityProxy proxy : selectedEntities) { if (align == Align.left) { if (proxy.getX() < targetX) targetX = proxy.getX(); } else { if (proxy.getX() > targetX) targetX = proxy.getX(); } } for (EntityProxy proxy : selectedEntities) { TransformEntityAction action = new TransformEntityAction(proxy); proxy.setX(targetX); action.saveNewData(proxy); undoableGroup.add(action); } } if (align == Align.top || align == Align.bottom) { float targetY = selectedEntities.get(0).getY(); for (EntityProxy proxy : selectedEntities) { if (align == Align.top) { if (proxy.getY() < targetY) targetY = proxy.getY(); } else { if (proxy.getY() > targetY) targetY = proxy.getY(); } } for (EntityProxy proxy : selectedEntities) { TransformEntityAction action = new TransformEntityAction(proxy); proxy.setY(targetY); action.saveNewData(proxy); undoableGroup.add(action); } } undoableGroup.finalizeGroup(); undoModule.add(undoableGroup); }
From source file:com.kotcrab.vis.ui.building.utilities.Alignment.java
License:Apache License
/** @return true for BOTTOM, BOTTOM_LEFT and BOTTOM_RIGHT. */ public boolean isAlignedWithBottom() { return (alignment & Align.bottom) != 0; }
From source file:com.kotcrab.vis.ui.util.ActorUtils.java
License:Apache License
/** * Makes sures that actor will be fully visible in stage. If it's necessary actor position will be changed to fit it * on screen.//from w ww . j a v a2 s . co m */ public static void keepWithinStage(Stage stage, Actor actor) { //taken from scene2d.ui Window Camera camera = stage.getCamera(); if (camera instanceof OrthographicCamera) { OrthographicCamera orthographicCamera = (OrthographicCamera) camera; float parentWidth = stage.getWidth(); float parentHeight = stage.getHeight(); if (actor.getX(Align.right) - camera.position.x > parentWidth / 2 / orthographicCamera.zoom) actor.setPosition(camera.position.x + parentWidth / 2 / orthographicCamera.zoom, actor.getY(Align.right), Align.right); if (actor.getX(Align.left) - camera.position.x < -parentWidth / 2 / orthographicCamera.zoom) actor.setPosition(camera.position.x - parentWidth / 2 / orthographicCamera.zoom, actor.getY(Align.left), Align.left); if (actor.getY(Align.top) - camera.position.y > parentHeight / 2 / orthographicCamera.zoom) actor.setPosition(actor.getX(Align.top), camera.position.y + parentHeight / 2 / orthographicCamera.zoom, Align.top); if (actor.getY(Align.bottom) - camera.position.y < -parentHeight / 2 / orthographicCamera.zoom) actor.setPosition(actor.getX(Align.bottom), camera.position.y - parentHeight / 2 / orthographicCamera.zoom, Align.bottom); } else if (actor.getParent() == stage.getRoot()) { float parentWidth = stage.getWidth(); float parentHeight = stage.getHeight(); if (actor.getX() < 0) actor.setX(0); if (actor.getRight() > parentWidth) actor.setX(parentWidth - actor.getWidth()); if (actor.getY() < 0) actor.setY(0); if (actor.getTop() > parentHeight) actor.setY(parentHeight - actor.getHeight()); } }