List of usage examples for com.badlogic.gdx.scenes.scene2d.ui ButtonGroup ButtonGroup
public ButtonGroup()
From source file:com.bladecoder.engineeditor.scneditor.ScnEditor.java
License:Apache License
public ScnEditor(Skin skin) { super(skin);//from ww w .j a v a 2 s . com scnWidget = new ScnWidget(skin); testButton = new TextButton("Test", skin); buttonGroup = new ButtonGroup<Button>(); buttonGroup.setMaxCheckCount(1); buttonGroup.setMinCheckCount(0); buttonGroup.setUncheckLast(true); walkZoneButton = new TextButton(CREATE_WALK_ZONE_TEXT, skin); toolsButton = new TextButton("Tools", skin); viewButton = new TextButton("View", skin); buttonGroup.add(toolsButton); buttonGroup.add(viewButton); viewWindow = new ViewWindow(skin, scnWidget); toolsWindow = new ToolsWindow(skin, scnWidget); add(scnWidget).expand().fill(); row(); Table bottomTable = new Table(skin); bottomTable.left(); add(bottomTable).fill(); bottomTable.add(viewButton); bottomTable.add(toolsButton); bottomTable.add(testButton); bottomTable.add(walkZoneButton).right().expandX(); walkZoneButton.addListener(new ChangeListener() { @Override public void changed(ChangeEvent event, Actor actor) { if (scnWidget.getScene().getPolygonalNavGraph() == null) { float[] verts = new float[8]; float width = scnWidget.getScene().getCamera().getScrollingWidth(); float height = scnWidget.getScene().getCamera().getScrollingHeight(); verts[3] = height; verts[4] = width; verts[5] = height; verts[6] = width; Polygon poly = new Polygon(verts); PolygonalNavGraph pf = new PolygonalNavGraph(); pf.setWalkZone(poly); scnWidget.getScene().setPolygonalNavGraph(pf); Ctx.project.setModified(); walkZoneButton.setText(DELETE_WALK_ZONE_TEXT); viewWindow.showWalkZone(); } else { new Dialog("Delete Walk Zone", getSkin()) { protected void result(Object object) { if (((Boolean) object).booleanValue()) { walkZoneButton.setText(CREATE_WALK_ZONE_TEXT); scnWidget.getScene().setPolygonalNavGraph(null); Ctx.project.setModified(); } } }.text("Are you sure you want to delete the Walk Zone?").button("Yes", true).button("No", false) .key(Keys.ENTER, true).key(Keys.ESCAPE, false).show(getStage()); } event.cancel(); } }); toolsButton.addListener(new ChangeListener() { @Override public void changed(ChangeEvent event, com.badlogic.gdx.scenes.scene2d.Actor actor) { if (toolsButton.isChecked()) { scnWidget.getParent().addActor(toolsWindow); toolsWindow.setPosition(getScnWidget().getX() + 5, getScnWidget().getY() + 5); toolsWindow.invalidate(); } else { scnWidget.getParent().removeActor(toolsWindow); } } }); viewButton.addListener(new ChangeListener() { @Override public void changed(ChangeEvent event, com.badlogic.gdx.scenes.scene2d.Actor actor) { if (viewButton.isChecked()) { scnWidget.getParent().addActor(viewWindow); viewWindow.setPosition(getScnWidget().getX() + 5, getScnWidget().getY() + 5); viewWindow.invalidate(); } else { scnWidget.getParent().removeActor(viewWindow); } } }); testButton.addListener(new ChangeListener() { @Override public void changed(ChangeEvent event, com.badlogic.gdx.scenes.scene2d.Actor actor) { test(); event.cancel(); } }); Ctx.project.addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent e) { EditorLogger.debug("ScnWidget Listener: " + e.getPropertyName()); if (e.getPropertyName().equals(Project.NOTIFY_SCENE_SELECTED)) { if (Ctx.project.getSelectedScene() == null) return; if (Ctx.project.getSelectedScene().getPolygonalNavGraph() != null) { walkZoneButton.setText(DELETE_WALK_ZONE_TEXT); } else { walkZoneButton.setText(CREATE_WALK_ZONE_TEXT); } } } }); }
From source file:com.bladecoder.engineeditor.ui.components.ScopePanel.java
License:Apache License
public ScopePanel(Skin skin) { super(skin);//from w w w . j a va 2s .c o m this.skin = skin; buttonGroup = new ButtonGroup<TextButton>(); hPanel = new HorizontalGroup(); buttonGroup.setMaxCheckCount(1); buttonGroup.setMinCheckCount(1); buttonGroup.setUncheckLast(true); hPanel.addActor(new Label("Scope: ", skin)); addButton(WORLD_SCOPE); addButton(SCENE_SCOPE); addButton(ACTOR_SCOPE); add(hPanel).expandX().fillX().center(); buttonGroup.getButtons().get(2).setChecked(true); }
From source file:com.bladecoder.engineeditor.ui.components.TabPanel.java
License:Apache License
public TabPanel(Skin skin) { super(skin);/*from w w w . j av a 2 s . com*/ this.skin = skin; buttonGroup = new ButtonGroup<Button>(); header = new HorizontalGroup(); body = new Container<Actor>(); tabs = new ArrayList<Tab>(); buttonGroup.setMaxCheckCount(1); buttonGroup.setMinCheckCount(1); buttonGroup.setUncheckLast(true); add(header).expandX().fillX().left(); row(); add(body).expand().fill(); body.fill(); }
From source file:com.gdx.extension.ui.tab.TabPane.java
License:Apache License
/** * Create a {@link TabPane} with the specified style. * /*from w ww.j a v a 2 s . c om*/ * @param isHorizontal set tabs * @param skin the skin to use for style * @param styleName the name of the style to use */ public TabPane(TabPosition tabPos, Skin skin, String styleName) { super(skin); tabs = new Array<Tab>(); setStyle(skin.get(styleName, TabPaneStyle.class)); buttonGroup = new ButtonGroup(); if (tabPos == TabPosition.TOP || tabPos == TabPosition.BOTTOM) { tabGroup = new HorizontalGroup(); } else { tabGroup = new VerticalGroup().fill(); } container = new Container<TabContainer>(); container.fill(); this.left().top(); if (tabPos == TabPosition.TOP) { addTabs(tabPos); this.row(); addBody(); } else if (tabPos == TabPosition.BOTTOM) { addBody(); this.row(); addTabs(tabPos); } else if (tabPos == TabPosition.LEFT) { addTabs(tabPos); addBody(); } else if (tabPos == TabPosition.RIGHT) { addBody(); addTabs(tabPos); } }
From source file:com.github.fauu.helix.editor.ui.HEToolbox.java
License:Open Source License
public HEToolbox() { super(true);/*from ww w. ja va 2 s . c o m*/ ButtonGroup<Button> toolButtons = new ButtonGroup<>(); for (final ToolType type : ToolType.values()) { Button button = new VisTextButton(type.toString(), "toggle"); button.addListener(new ChangeListener() { @Override public void changed(ChangeEvent event, Actor actor) { if (((Button) actor).isChecked()) { HelixEditor.getInstance().getToolbarState().setActiveTool(type); } } }); toolButtons.add(button); add(button).padBottom(-8); row(); } }
From source file:com.kotcrab.vis.editor.module.editor.ToolbarModule.java
License:Apache License
public ToolbarModule() { toolsGroup = new ButtonGroup<>(); table = new VisTable(false); table.defaults().pad(4, 0, 4, 3);/*w w w .ja v a 2 s .com*/ table.setBackground(VisUI.getSkin().getDrawable("button")); table.add(new ToolbarButtonBuilder().icon(Icons.SAVE) .text("Save (" + OsUtils.getShortcutFor(Keys.CONTROL_LEFT, Keys.S) + ")") .eventToolbar(ToolbarEventType.FILE_SAVE).policy(ControllerPolicy.SAVABLE).build()); table.addSeparator(true); table.add(new ToolbarButtonBuilder().icon(Icons.TOOL_MOVE).text("Select and move entities (F1)") .eventTool(SelectionTool.TOOL_ID).build()); table.add(new ToolbarButtonBuilder().icon(Icons.TOOL_ROTATE).text("Rotate entities (F2)") .eventTool(RotateTool.TOOL_ID).build()); table.add(new ToolbarButtonBuilder().icon(Icons.TOOL_SCALE).text("Scale entities (F3)") .eventTool(ScaleTool.TOOL_ID).build()); table.add(new ToolbarButtonBuilder().icon(Icons.POLYGON).text("Edit polygons (F4)") .eventTool(PolygonTool.TOOL_ID).build()); table.addSeparator(true); table.add(new ToolbarButtonBuilder().icon(Icons.SETTINGS_VIEW).text("Enable grid snapping (%)") .eventToolbar(ToolbarEventType.GRID_SNAP_SETTING_CHANGED).toggle().build()); table.add().expand().fill(); savableScope.forEach(button -> button.setDisabled(true)); sceneScope.forEach(button -> button.setDisabled(true)); }
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);//from w w w .ja v a 2 s .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.Roguelike3D.Graphics.Screens.RecipeScreen.java
License:Open Source License
private ScrollPane getRecipeList() { Table rlist = new Table(); bg = new ButtonGroup(); recipeButtons = new ArrayList<RecipeButton>(); boolean test = true; for (Recipe r : recipes) { RecipeButton rb = new RecipeButton(skin, r, bg); recipeButtons.add(rb);/*from ww w .ja va 2 s . c o m*/ if (test) { test = false; rb.toggle(); } rlist.add(rb).width(200).height(30).padBottom(10); rlist.row(); } ScrollPane scroll = new ScrollPane(rlist, skin); scroll.setColor(0, 0, 0, 1.0f); scroll.setScrollingDisabled(true, false); return scroll; }
From source file:com.lyeeedar.Roguelike3D.Graphics.Screens.RecipeScreen.java
License:Open Source License
private void createCraftingRightView() { right.clear();/*from w w w .j a va 2 s .c om*/ bg = new ButtonGroup(); Table t = new Table(); for (Component c : GameStats.getAllComponents()) { // Check valid type if (!chosenRecipe.checkComponent(c, selected.reference)) continue; // Check amounts int usedAmount = 0; for (CraftButton cb : craftButtons) { if (cb.component != null && cb.component.toString().equals(c.toString())) { usedAmount += chosenRecipe.getComponentAmount(cb.reference); } } boolean check = false; if (selected.component != null && selected.component.toString().equals(c.toString())) check = true; else if (usedAmount + chosenRecipe.getComponentAmount(selected.reference) > c.amount) continue; // Valid! ComponentButton cb = new ComponentButton(skin, c, bg); t.add(cb); t.row(); if (check) cb.cbox.toggle(); } ScrollPane scroll = new ScrollPane(t, skin); scroll.setColor(0, 0, 0, 1.0f); scroll.setScrollingDisabled(true, false); right.add(scroll); }
From source file:com.mbrlabs.mundus.editor.ui.widgets.RadioButtonGroup.java
License:Apache License
public RadioButtonGroup() { super(); buttonGroup = new ButtonGroup<>(); buttonGroup.setMaxCheckCount(1); buttonGroup.setMinCheckCount(1); pad(5); }