private void snapToWindowsX(int newX) { int width = (int) getWidth(); int newMaxX = newX + width; for (InGameWindow window : windows) { if (window == this) continue; int nodeMinX = (int) window.getLayoutX(); int nodeMaxX = (int) (window.getLayoutX() + window.getWidth()); if (between(newX, nodeMaxX - SNAP_SIZE, nodeMaxX + SNAP_SIZE)) { relocateX(nodeMaxX); break; } if (between(newMaxX, nodeMinX - SNAP_SIZE, nodeMinX + SNAP_SIZE)) { relocateX(nodeMinX - width); break; } } }
private void snapToWindowsY(int newY) { int height = (int) getHeight(); int newMaxY = newY + height; for (InGameWindow window : windows) { if (window == this) continue; int nodeMinY = (int) window.getLayoutY(); int nodeMaxY = (int) (window.getLayoutY() + window.getHeight()); if (between(newY, nodeMaxY - SNAP_SIZE, nodeMaxY + SNAP_SIZE)) { relocateY(nodeMaxY); break; } if (between(newMaxY, nodeMinY - SNAP_SIZE, nodeMinY + SNAP_SIZE)) { relocateY(nodeMinY - height); break; } } }
public final void relocateX(double x) { setLayoutX(x - getLayoutBounds().getMinX()); }
setCanMinimize(true); setCanClose(false); break; case CLOSE: setCanMinimize(false); setCanClose(true); break; case ALL: setCanMinimize(true); setCanClose(true); break; case NONE: setCanMinimize(false); setCanClose(false); break; default: appH = FXGL.getSettings().getHeight(); layoutXProperty().addListener(makeListenerX()); layoutYProperty().addListener(makeListenerY()); setTitle(title);
private ChangeListener<Number> makeListenerY() { return (observable, oldValue, newValue) -> { int newY = newValue.intValue(); int height = (int) getHeight(); int newMaxY = newY + height; if (snapToWindows) { snapToWindowsY(newY); } if (snapToScreen) { if (newY > 0 && newY <= SNAP_SIZE) { relocateY(0); } else if (newMaxY < appH && newMaxY >= appH - SNAP_SIZE) { relocateY(appH - (int)getHeight()); } } if (!canGoOffscreen) { keepOnScreenY(newY); } }; }
private ChangeListener<Number> makeListenerX() { return (observable, oldValue, newValue) -> { int newX = newValue.intValue(); int width = (int) getWidth(); int newMaxX = newX + width; if (snapToWindows) { snapToWindowsX(newX); } if (snapToScreen) { if (newX > 0 && newX <= SNAP_SIZE) { relocateX(0); } else if (newMaxX < appW && newMaxX >= appW - SNAP_SIZE) { relocateX(appW - width); } } if (!canGoOffscreen) { keepOnScreenX(newX); } }; }
public final void relocateY(double y) { setLayoutY(y - getLayoutBounds().getMinY()); }
public void openAddDialog() { UI ui = app.getAssetLoader().loadUI("dialog_add_entity.fxml", new DialogAddEntityController()); MDIWindow window = new InGameWindow("Add Entity", InGameWindow.WindowDecor.ALL); window.setPrefSize(350, 300); window.setContentPane(new Pane(ui.getRoot())); app.getGameScene().addUINode(window); }
public void openColorAdjustDialog() { if (uiColorAdjust == null) { uiColorAdjust = app.getAssetLoader().loadUI("dialog_color_adjust.fxml", new ColorAdjustController()); } MDIWindow window = new InGameWindow("Color Adjust", InGameWindow.WindowDecor.ALL); window.setPrefSize(380, 450); window.setContentPane(new Pane(uiColorAdjust.getRoot())); app.getGameScene().addUINode(window); }
public void openEditDialog() { UI ui = app.getAssetLoader().loadUI("dialog_edit_entity.fxml", new DialogEditEntityController()); MDIWindow window = new InGameWindow("Edit Entity", InGameWindow.WindowDecor.ALL); window.setPrefSize(380, 450); window.setContentPane(new Pane(ui.getRoot())); app.getGameScene().addUINode(window); }