Search in sources :

Example 6 with GridSettings

use of blue.orchestra.blueSynthBuilder.GridSettings in project blue by kunstmusik.

the class BSBEditPane method editBSBGraphicInterface.

public void editBSBGraphicInterface(BSBGraphicInterface bsbInterface) {
    if (this.bsbInterface != null) {
        GridSettings gridSettings = this.bsbInterface.getGridSettings();
        gridSettings.widthProperty().removeListener(gridListener);
        gridSettings.heightProperty().removeListener(gridListener);
        gridSettings.gridStyleProperty().removeListener(gridListener);
        this.bsbInterface.editEnabledProperty().removeListener(editEnabledListener);
    }
    gridCanvas.visibleProperty().unbind();
    this.bsbInterface = bsbInterface;
    selection.initialize(groupsList, bsbInterface.getGridSettings());
    if (bsbInterface != null) {
        GridSettings gridSettings = bsbInterface.getGridSettings();
        gridSettings.widthProperty().addListener(gridListener);
        gridSettings.heightProperty().addListener(gridListener);
        gridSettings.gridStyleProperty().addListener(gridListener);
        if (allowEditing) {
            gridCanvas.visibleProperty().bind(bsbInterface.editEnabledProperty());
            bsbInterface.editEnabledProperty().addListener(editEnabledListener);
        } else {
            gridCanvas.setVisible(false);
        }
        groupsList.setAll(bsbInterface.getRootGroup());
    } else {
        groupsList.clear();
    }
}
Also used : GridSettings(blue.orchestra.blueSynthBuilder.GridSettings)

Example 7 with GridSettings

use of blue.orchestra.blueSynthBuilder.GridSettings in project blue by kunstmusik.

the class BSBObjectViewHolder method resizeUp.

protected void resizeUp(MouseEvent evt) {
    Rectangle r = (Rectangle) evt.getSource();
    Point2D curPoint = r.localToParent(evt.getX(), evt.getY());
    curPoint = localToParent(curPoint);
    GridSettings grid = selection.getGridSettings();
    int diff = (int) (curPoint.getY() - mouseOrigin.getY());
    diff = Math.max((int) -originBounds.getMinY(), diff);
    int newHeight = (int) originBounds.getHeight() - diff;
    int newY = (int) originBounds.getMinY() + diff;
    if (grid.isSnapEnabled()) {
        double bottom = originBounds.getMaxY();
        double top = bottom - newHeight;
        int h = grid.getHeight();
        top = ((Math.round(top / h) * h));
        newHeight = (int) (bottom - top);
        newY = (int) top;
    }
    newHeight = Math.max(newHeight, rView.getWidgetMinimumHeight());
    newY = Math.min(newY, (int) (originBounds.getMaxY() - rView.getWidgetMinimumHeight()));
    if (newHeight != rView.getWidgetHeight()) {
        rView.setWidgetY(newY);
        rView.setWidgetHeight(newHeight);
    }
    evt.consume();
}
Also used : Point2D(javafx.geometry.Point2D) Rectangle(javafx.scene.shape.Rectangle) GridSettings(blue.orchestra.blueSynthBuilder.GridSettings)

Example 8 with GridSettings

use of blue.orchestra.blueSynthBuilder.GridSettings in project blue by kunstmusik.

the class BSBObjectViewHolder method resizeLeft.

protected void resizeLeft(MouseEvent evt) {
    Rectangle r = (Rectangle) evt.getSource();
    Point2D curPoint = r.localToParent(evt.getX(), evt.getY());
    curPoint = localToParent(curPoint);
    GridSettings grid = selection.getGridSettings();
    int diff = (int) (curPoint.getX() - mouseOrigin.getX());
    diff = Math.max((int) -originBounds.getMinX(), diff);
    int newWidth = (int) originBounds.getWidth() - diff;
    int newX = (int) originBounds.getMinX() + diff;
    if (grid.isSnapEnabled()) {
        double right = originBounds.getMaxX();
        double left = right - newWidth;
        int w = grid.getWidth();
        left = ((Math.round(left / w) * w));
        newWidth = (int) (right - left);
        newX = (int) left;
    }
    newWidth = Math.max(newWidth, rView.getWidgetMinimumWidth());
    newX = Math.min(newX, (int) (originBounds.getMaxX() - rView.getWidgetMinimumWidth()));
    if (newWidth != rView.getWidgetWidth()) {
        rView.setWidgetWidth(newWidth);
        rView.setWidgetX(newX);
    }
    evt.consume();
}
Also used : Point2D(javafx.geometry.Point2D) Rectangle(javafx.scene.shape.Rectangle) GridSettings(blue.orchestra.blueSynthBuilder.GridSettings)

Aggregations

GridSettings (blue.orchestra.blueSynthBuilder.GridSettings)8 Point2D (javafx.geometry.Point2D)4 Rectangle (javafx.scene.shape.Rectangle)4 BSBObject (blue.orchestra.blueSynthBuilder.BSBObject)2 GraphicsContext (javafx.scene.canvas.GraphicsContext)1