Commit 8653b566 authored by legoc's avatar legoc
Browse files

Reviewed menus for selection

parent 1e897d19
......@@ -5,7 +5,6 @@ import java.nio.file.Files;
import java.nio.file.Path;
import java.text.DecimalFormat;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Optional;
import java.util.logging.Logger;
......@@ -107,8 +106,8 @@ public class EditorMenuBar extends MenuBar {
/** Walls visibility. */
private boolean showWalls;
/** Select focus. If it is true, only the selection is visible. */
private boolean focusSelection;
/** Show type. */
private Component.ShowType showType;
/** Currently displayed configuration. */
private String activeConfiguration;
......@@ -134,7 +133,7 @@ public class EditorMenuBar extends MenuBar {
this.showAxes = true;
this.showSystem = true;
this.showWalls = true;
this.focusSelection = false;
this.showType = Component.ShowType.ALL;
this.activeConfiguration = null;
this.activeLod = 0;
this.subdividedChilds = new LinkedList<>();
......@@ -1613,58 +1612,37 @@ public class EditorMenuBar extends MenuBar {
statsItem);
this.selection = new Menu("Selection");
MenuItem selectAllItem = new MenuItem("Select all");
selectAllItem.setAccelerator(new KeyCodeCombination(KeyCode.A));
selectAllItem.setOnAction(new EventHandler<ActionEvent>() {
MenuItem allItem = new MenuItem("Show all");
allItem.setAccelerator(new KeyCodeCombination(KeyCode.A));
allItem.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
if (Nomad3DEditor.getInstance().getModel() == null || activeConfiguration == null) {
return;
}
if (Nomad3DEditor.getInstance().getModel().getSelection().isEmpty()) {
Nomad3DEditor.getInstance().getModel().selectAll();
} else {
Nomad3DEditor.getInstance().getModel().clearSelection();
}
showType = Component.ShowType.ALL;
updateFocus();
}
});
MenuItem showSelectionItem = new MenuItem("Show selection");
showSelectionItem.setAccelerator(new KeyCodeCombination(KeyCode.G));
showSelectionItem.setOnAction(new EventHandler<ActionEvent>() {
MenuItem onlySelectionItem = new MenuItem("Show only selection");
onlySelectionItem.setAccelerator(new KeyCodeCombination(KeyCode.S));
onlySelectionItem.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
if (Nomad3DEditor.getInstance().getModel() == null || activeConfiguration == null) {
return;
}
for (Component comp : Nomad3DEditor.getInstance().getModel().getSelection()) {
comp.setVisible(true, activeConfiguration, false);
}
showType = Component.ShowType.SELECTION;
updateFocus();
}
});
MenuItem hideSelectionItem = new MenuItem("Hide selection");
hideSelectionItem.setAccelerator(new KeyCodeCombination(KeyCode.H));
MenuItem hideSelectionItem = new MenuItem("Show only non selection");
hideSelectionItem.setAccelerator(new KeyCodeCombination(KeyCode.N));
hideSelectionItem.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
if (Nomad3DEditor.getInstance().getModel() == null || activeConfiguration == null) {
return;
}
for (Component comp : Nomad3DEditor.getInstance().getModel().getSelection()) {
comp.setVisible(false, activeConfiguration, false);
}
}
});
CheckMenuItem focusSelectionItem = new CheckMenuItem("Focus on selection");
focusSelectionItem.setAccelerator(new KeyCodeCombination(KeyCode.F));
focusSelectionItem.setSelected(this.focusSelection);
focusSelectionItem.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
focusSelection = focusSelectionItem.isSelected();
showType = Component.ShowType.NON_SELECTION;
updateFocus();
}
});
MenuItem markWallItem = new MenuItem("Mark selection as walls");
markWallItem.setAccelerator(new KeyCodeCombination(KeyCode.W));
markWallItem.setOnAction(new EventHandler<ActionEvent>() {
......@@ -1699,9 +1677,8 @@ public class EditorMenuBar extends MenuBar {
}
Nomad3DEditor.getInstance().getModel().clearSelection();
});
this.selection.getItems().addAll(selectAllItem,
new SeparatorMenuItem(),
showSelectionItem, hideSelectionItem, focusSelectionItem,
this.selection.getItems().addAll(
allItem, onlySelectionItem, hideSelectionItem,
new SeparatorMenuItem(),
showSelectionInConfig, hideInConfigItem,
new SeparatorMenuItem(),
......@@ -1978,8 +1955,8 @@ public class EditorMenuBar extends MenuBar {
if (!modelLoaded()) {
return;
}
Nomad3DEditor.getInstance().getModel().getRoot().focusSelection(Nomad3DEditor.getInstance().getModel().getSelection(), focusSelection, activeConfiguration, true);
Nomad3DEditor.getInstance().getModel().getRoot().focusSelection(Nomad3DEditor.getInstance().getModel().getSelection(), showType, activeConfiguration, true);
updateWalls();
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment