public void updateView(Map<String, FrameRange> frameRangeMap) { createNewAnimationTable(); animationsList.clear(); for (Map.Entry<String, FrameRange> entry : frameRangeMap.entrySet()) { String animationName = entry.getKey(); FrameRange range = entry.getValue(); VisTable row = new VisTable(); VisImageButton trashBtn = new VisImageButton("trash-button"); row.add(StandardWidgetsFactory.createLabel(animationName)).width(120).left(); row.add(StandardWidgetsFactory.createLabel(range.startFrame + "")).width(50).left(); row.add(StandardWidgetsFactory.createLabel(range.endFrame + "")).width(50).left(); row.add(trashBtn).padLeft(10); row.row(); animationsList.add(row).left(); animationsList.row(); trashBtn.addListener( new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { facade.sendNotification(DELETE_BUTTON_PRESSED, animationName); } }); } invalidateHeight(); }
public LayerItem(Layer layer) { super(true); this.layer = layer; setTouchable(Touchable.enabled); eyeButton = new VisImageButton("default"); lockButton = new VisImageButton("default"); updateButtonsImages(); eyeButton.addListener( new VisChangeListener( (event, actor) -> undoModule.execute( new MonoUndoableAction() { @Override public String getActionName() { return "Hide/Show Layer"; } @Override public void doAction() { changeVisibility(); } }))); lockButton.addListener( new VisChangeListener( (event, actor) -> undoModule.execute( new MonoUndoableAction() { @Override public String getActionName() { return "Lock/Unlock Layer"; } @Override public void doAction() { changeLocked(); } }))); pad(3); add(eyeButton); add(lockButton); add(nameLabel = new VisLabel(layer.name)) .expandX() .fillX(); // TODO: show id in layers dialog, don't forget about updating it when layer was // moved addListener( new InputListener() { @Override public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { select(); return true; } }); }
private void selectedLayer(Layer layer) { scene.setActiveLayer(layer.id); layerUpButton.setDisabled(false); layerDownButton.setDisabled(false); ImmutableArray<Layer> layers = scene.getLayers(); int index = layers.indexOf(layer, true); if (index == 0) layerUpButton.setDisabled(true); if (index == layers.size() - 1) layerDownButton.setDisabled(true); }
public TagItem(String tag, TagItemListener listener) { this.listener = listener; tagLbl = new VisTextButton(tag, "tagBtn"); VisImageButton closeBtn = new VisImageButton("close-panel"); add(tagLbl).width(180); add(closeBtn).padLeft(5); closeBtn.addListener( new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { TagItem.this.remove(); listener.removed(tagLbl.getText().toString()); } }); }
public ComponentSelectDialog( EntityProperties properties, ComponentSelectDialogListener listener) { super(false); this.properties = properties; this.listener = listener; setBackground(VisUI.getSkin().getDrawable("tooltip-bg")); // TODO: [plugin] plugin entry point componentClasses.add(ShaderComponent.class); componentClasses.add(PolygonComponent.class); componentClasses.add(PhysicsPropertiesComponent.class); componentClasses.add(VariablesComponent.class); buttonStyle = new VisTextButtonStyle(VisUI.getSkin().get(VisTextButtonStyle.class)); scrollPaneTable = new VisTable(false); scrollPaneTable.top(); VisScrollPane scrollPane = new VisScrollPane(scrollPaneTable); scrollPane.setScrollingDisabled(false, true); scrollPane.setFlickScroll(false); scrollPane.setFadeScrollBars(false); VisImageButton closeButton = new VisImageButton("close"); add(new VisLabel("Select component")); add(closeButton).right().row(); addSeparator().colspan(2); add(scrollPane).colspan(2).expand().fill().padLeft(3).padRight(3); setSize(220, 200); closeButton.addListener(new VisChangeListener((event, actor) -> remove())); inputListener = new InputListener() { @Override public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) { if (contains(event.getStageX(), event.getStageY()) == false) { remove(); return true; } return false; } }; }
private void rebuildLayersTable() { deselectAll(); Array<Actor> actors = new Array<>(layersTable.getChildren()); layersTable.clearChildren(); for (Layer layer : scene.getLayers()) { LayerItem item = getItemForLayer(actors, layer); if (item == null) item = new LayerItem(layer); item.update(); layersTable.add(item).expandX().fillX().row(); if (layer == scene.getActiveLayer()) item.select(); } if (scene.getLayers().size() == 1) { layerDownButton.setDisabled(true); layerUpButton.setDisabled(true); layerRemoveButton.setDisabled(true); } else layerRemoveButton.setDisabled(false); }
public void deselect() { setBackground((Drawable) null); eyeButton.getStyle().over = BUTTON_STYLE.over; lockButton.getStyle().over = BUTTON_STYLE.over; eyeButton.getStyle().up = BUTTON_STYLE.up; lockButton.getStyle().up = BUTTON_STYLE.up; eyeButton.getStyle().down = BUTTON_STYLE.down; lockButton.getStyle().down = BUTTON_STYLE.down; }
public void select() { deselectAll(); eyeButton.getStyle().over = BUTTON_BLUE_STYLE.over; lockButton.getStyle().over = BUTTON_BLUE_STYLE.over; eyeButton.getStyle().up = BUTTON_BLUE_STYLE.up; lockButton.getStyle().up = BUTTON_BLUE_STYLE.up; eyeButton.getStyle().down = BUTTON_BLUE_STYLE.down; lockButton.getStyle().down = BUTTON_BLUE_STYLE.down; setBackground(SELECTION); selectedLayer(layer); }
public LayersDialog( SceneTab sceneTab, EntityEngineConfiguration engineConfig, ModuleInjector sceneMC) { super(true); this.sceneTab = sceneTab; this.scene = sceneTab.getScene(); sceneMC.injectModules(this); layerManipulatorManager = engineConfig.getManager(LayerManipulatorManager.class); setBackground(VisUI.getSkin().getDrawable("window-bg")); setTouchable(Touchable.enabled); VisImageButton layerAddButton = new VisImageButton(Icons.LAYER_ADD.drawable(), "Add new layer"); layerUpButton = new VisImageButton(Icons.LAYER_UP.drawable(), "Move layer up"); layerDownButton = new VisImageButton(Icons.LAYER_DOWN.drawable(), "Move layer down"); layerSettingsButton = new VisImageButton(Icons.SETTINGS.drawable(), "Show layer settings"); layerRemoveButton = new VisImageButton(Icons.LAYER_REMOVE.drawable(), "Delete layer"); layerUpButton.setGenerateDisabledImage(true); layerDownButton.setGenerateDisabledImage(true); layerRemoveButton.setGenerateDisabledImage(true); layerAddButton.addListener( new VisChangeListener( (event, actor) -> DialogUtils.showInputDialog( getStage(), "New Layer", "Name:", true, input -> scene.getLayerByName(input) == null, (DefaultInputDialogListener) input -> undoModule.execute(new LayerAddedAction(input))))); layerUpButton.addListener( new VisChangeListener((event, actor) -> undoModule.execute(new LayerMovedAction(true)))); layerDownButton.addListener( new VisChangeListener((event, actor) -> undoModule.execute(new LayerMovedAction(false)))); layerSettingsButton.addListener( new VisChangeListener( (event1, actor1) -> getStage().addActor(new LayerSettingsDialog(sceneMC, scene).fadeIn()))); layerRemoveButton.addListener( new VisChangeListener( (event, actor) -> DialogUtils.showOptionDialog( getStage(), "Delete Layer", "Are you sure you want to delete layer '" + scene.getActiveLayer().name + "'?", OptionDialogType.YES_NO, new OptionDialogAdapter() { @Override public void yes() { UndoableActionGroup layerRemovedGroup = new UndoableActionGroup("Delete Layer"); layerRemovedGroup.add( new EntitiesRemovedAction( sceneMC, sceneTab.getEntityEngine(), VisBagUtils.toSet( layerManipulatorManager.getEntitiesWithLayer( scene.getActiveLayerId())))); layerRemovedGroup.add(new LayerRemovedAction(scene.getActiveLayer())); layerRemovedGroup.finalizeGroup(); undoModule.execute(layerRemovedGroup); } }))); layersTable = new VisTable(); VisScrollPane layersScrollPane = new VisScrollPane(layersTable); layersScrollPane.setScrollingDisabled(true, false); layersScrollPane.setFadeScrollBars(false); top(); left(); defaults().left(); defaults().padLeft(5).padRight(5); add(new VisLabel("Layers")).center().row(); add(layersScrollPane).expandX().fillX().row(); addSeparator(); add(TableBuilder.build( layerAddButton, layerUpButton, layerDownButton, layerSettingsButton, layerRemoveButton)) .padBottom(8); addListener(new EventStopper()); rebuildLayersTable(); sceneObservable = nid -> { if (nid == EditorScene.LAYER_ADDED || nid == EditorScene.LAYER_INSERTED || nid == EditorScene.LAYER_REMOVED || nid == EditorScene.LAYERS_SORTED || nid == EditorScene.ACTIVE_LAYER_CHANGED || nid == EditorScene.LAYER_DATA_CHANGED) { rebuildLayersTable(); sceneTab.dirty(); } }; scene.addObservable(sceneObservable); }
private void updateButtonsImages() { eyeButton.getStyle().imageUp = layer.visible ? Icons.EYE.drawable() : Icons.EYE_DISABLED.drawable(); lockButton.getStyle().imageUp = layer.locked ? Icons.LOCKED.drawable() : Icons.UNLOCKED.drawable(); }
public AlignmentToolsDialog(ModuleInjector injector, Array<EntityProxy> selectedEntities) { injector.injectModules(this); this.selectedEntities = selectedEntities; setBackground(VisUI.getSkin().getDrawable("window-bg")); setTouchable(Touchable.enabled); setVisible(false); addListener(new EventStopper()); 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))); }