List of usage examples for com.badlogic.gdx.scenes.scene2d.ui Cell left
public Cell<T> left()
From source file:at.highstreeto.xnllayoutparser.element.CellParser.java
License:Apache License
@Override public Actor load(Element element, LayoutParserContext context) throws LayoutParseException { Table table = (Table) context.getActorByElement(element.getParent().getParent()); Element child = element.getChild(0); Actor actor = context.getParsers().getParserByElementName(child).load(child, context); Cell<?> cell = table.add(actor); if (element.getAttributes().containsKey("fill")) { if ("x".equals(element.getAttribute("fill"))) { cell.fillX();//w w w. jav a 2s. c o m } else if ("y".equals(element.getAttribute("fill"))) { cell.fillY(); } else if ("xy".equals(element.getAttribute("fill"))) { cell.fill(); } else { throw new LayoutParseException(); } } if (element.getAttributes().containsKey("expand")) { if ("x".equals(element.getAttribute("expand"))) { cell.expandX(); } else if ("y".equals(element.getAttribute("expand"))) { cell.expandY(); } else if ("xy".equals(element.getAttribute("expand"))) { cell.expand(); } else { throw new LayoutParseException(); } } // Combination of c (Center), t (Top), b (Bottom), l (Left), r (Right) if (element.getAttributes().containsKey("align")) { String[] parts = element.getAttribute("align").split(" "); for (String i : parts) { if ("c".equals(i)) { cell.center(); } else if ("t".equals(i)) { cell.top(); } else if ("b".equals(i)) { cell.bottom(); } else if ("l".equals(i)) { cell.left(); } else if ("r".equals(i)) { cell.right(); } } } // Padding - Format: Top Left Bottom Right if (element.getAttributes().containsKey("pad")) { String[] pads = element.getAttribute("pad").split(" "); if (pads.length == 4) { float top = Float.parseFloat(pads[0]); float right = Float.parseFloat(pads[1]); float bottom = Float.parseFloat(pads[2]); float left = Float.parseFloat(pads[3]); cell.pad(top, left, bottom, right); } else { throw new LayoutParseException(); } } if (element.getAttributes().containsKey("colspan")) { int colspan = Integer.parseInt(element.getAttribute("colspan")); cell.colspan(colspan); } return null; }
From source file:com.badlogic.gdx.ai.tests.utils.scene2d.TabbedPane.java
License:Apache License
private void initialize() { setTouchable(Touchable.enabled);/*ww w. j a va 2 s .c o m*/ tabTitleTable = new Table(); tabBodyStack = new Stack(); selectedIndex = -1; // Create 1st row Cell<?> leftCell = add(new Image(style.titleBegin)); Cell<?> midCell = add(tabTitleTable); Cell<?> rightCell = add(new Image(style.titleEnd)); switch (tabTitleAlign) { case Align.left: leftCell.width(((Image) leftCell.getActor()).getWidth()).bottom(); midCell.left(); rightCell.expandX().fillX().bottom(); break; case Align.right: leftCell.expandX().fillX().bottom(); midCell.right(); rightCell.width(((Image) rightCell.getActor()).getWidth()).bottom(); break; case Align.center: leftCell.expandX().fillX().bottom(); midCell.center(); rightCell.expandX().fillX().bottom(); break; default: throw new IllegalArgumentException("TabbedPane align must be one of left, center, right"); } // Create 2nd row row(); Table t = new Table(); t.setBackground(style.bodyBackground); t.add(tabBodyStack); add(t).colspan(3).expand().fill(); }
From source file:com.kotcrab.vis.ui.widget.tabbedpane.TabbedPane.java
License:Apache License
public TabbedPane(TabbedPaneStyle style, Sizes sizes) { this.style = style; this.sizes = sizes; listeners = new Array<TabbedPaneListener>(); sharedCloseActiveButtonStyle = VisUI.getSkin().get("close-active-tab", VisImageButtonStyle.class); group = new ButtonGroup<Button>(); mainTable = new TabbedPaneTable(this); tabsPane = new DragPane(style.vertical ? new VerticalFlowGroup() : new HorizontalFlowGroup()); configureDragPane(style);// www .j a v a2s. c om mainTable.setBackground(style.background); tabs = new Array<Tab>(); tabsButtonMap = new IdentityMap<Tab, TabButtonTable>(); Cell<DragPane> tabsPaneCell = mainTable.add(tabsPane); Cell<Image> separatorCell = null; if (style.vertical) { tabsPaneCell.top().growY().minSize(0, 0); } else { tabsPaneCell.left().growX().minSize(0, 0); } //note: if separatorBar height/width is not set explicitly it may sometimes disappear if (style.separatorBar != null) { if (style.vertical) { separatorCell = mainTable.add(new Image(style.separatorBar)).growY() .width(style.separatorBar.getMinWidth()); } else { mainTable.row(); separatorCell = mainTable.add(new Image(style.separatorBar)).growX() .height(style.separatorBar.getMinHeight()); } } else { //make sure that tab will fill available space even when there is no separatorBar image set if (style.vertical) { mainTable.add().growY(); } else { mainTable.add().growX(); } } mainTable.setPaneCells(tabsPaneCell, separatorCell); }
From source file:com.lyeeedar.UI.TabPanel.java
License:Apache License
private void initialize() { setTouchable(Touchable.enabled);/*from w w w . j av a2 s . c o m*/ tabTitleTable = new Table(); tabBodyStack = new Stack(); selectedIndex = -1; // Create 1st row Cell<?> leftCell = add(new Image(style.titleBegin)); Cell<?> midCell = add(tabTitleTable); Cell<?> rightCell = add(new Image(style.titleEnd)); switch (tabTitleAlign) { case Align.left: leftCell.width(leftCell.getActor().getWidth()).bottom(); midCell.left(); rightCell.expandX().fillX().bottom(); break; case Align.right: leftCell.expandX().fillX().bottom(); midCell.right(); rightCell.width(rightCell.getActor().getWidth()).bottom(); break; case Align.center: leftCell.expandX().fillX().bottom(); midCell.center(); rightCell.expandX().fillX().bottom(); break; default: throw new IllegalArgumentException("TabbedPane align must be one of left, center, right"); } // Create 2nd row row(); Table t = new Table(); t.setBackground(style.bodyBackground); t.add(tabBodyStack).expand().fill(); add(t).colspan(3).expand().fill(); }
From source file:Roguelike.UI.TabPanel.java
License:Apache License
private void initialize() { setTouchable(Touchable.enabled);// w ww . j ava2 s . co m tabTitleTable = new Table(); tabBodyStack = new Stack(); selectedIndex = -1; // Create 1st row Cell<?> leftCell = add(new Image(style.titleBegin)); Cell<?> midCell = add(tabTitleTable); Cell<?> rightCell = add(new Image(style.titleEnd)); switch (tabTitleAlign) { case Align.left: leftCell.width(((Image) leftCell.getActor()).getWidth()).bottom(); midCell.left(); rightCell.expandX().fillX().bottom(); break; case Align.right: leftCell.expandX().fillX().bottom(); midCell.right(); rightCell.width(((Image) rightCell.getActor()).getWidth()).bottom(); break; case Align.center: leftCell.expandX().fillX().bottom(); midCell.center(); rightCell.expandX().fillX().bottom(); break; default: throw new IllegalArgumentException("TabbedPane align must be one of left, center, right"); } // Create 2nd row row(); Table t = new Table(); t.setBackground(style.bodyBackground); t.add(tabBodyStack).expand().fill(); add(t).colspan(3).expand().fill(); }