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)));
  }
  public DeleteMultipleFilesTab(ModuleInjector injector, Array<FileItem> items) {
    super(false, true);
    this.injector = injector;
    this.items = items;
    injector.injectModules(this);

    table = new VisTable();
    table.setBackground(VisUI.getSkin().getDrawable("window-bg"));
    table.defaults().left();

    usagesTable = new VisTable(true);
    rebuildUsagesTable();

    VisScrollPane scrollPane = new VisScrollPane(usagesTable);
    scrollPane.setFadeScrollBars(false);

    table.add(scrollPane).expandX().fillX().pad(3).row();
    table.add().expand().fill().row();
    table.addSeparator();
    table.add(createButtonPane()).pad(3);
  }
示例#3
0
  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);
  }