Search in sources :

Example 1 with AlphaMarquee

use of blue.components.AlphaMarquee in project blue by kunstmusik.

the class MultiLineMoveMouseListener method mousePressed.

@Override
public void mousePressed(MouseEvent e) {
    if (!isMultiLineMode()) {
        return;
    }
    AlphaMarquee marquee = scoreTC.getMarquee();
    Point p = SwingUtilities.convertPoint(scoreTC.getScorePanel(), e.getPoint(), marquee);
    if (!marquee.isVisible() || !marquee.contains(p)) {
        return;
    }
    e.consume();
    RealtimeRenderManager.getInstance().stopAuditioning();
    timeState = scoreTC.getTimeState();
    startX = e.getX();
    minTranslation = -selection.getStartTime();
    Collection<? extends ScoreObject> selectedObjects = ScoreController.getInstance().getSelectedScoreObjects();
    selectedScoreObjects = selectedObjects.toArray(new ScoreObject[0]);
    startTimes = new double[selectedScoreObjects.length];
    for (int i = 0; i < selectedScoreObjects.length; i++) {
        ScoreObject sObj = selectedScoreObjects[i];
        startTimes[i] = sObj.getStartTime();
        minTranslation = Math.max(minTranslation, -startTimes[i]);
    }
    selection.startTranslation();
}
Also used : ScoreObject(blue.score.ScoreObject) Point(java.awt.Point) AlphaMarquee(blue.components.AlphaMarquee) Point(java.awt.Point)

Example 2 with AlphaMarquee

use of blue.components.AlphaMarquee in project blue by kunstmusik.

the class MultiLineMoveMouseListener method mouseDragged.

@Override
public void mouseDragged(MouseEvent e) {
    if (!isMultiLineMode()) {
        return;
    }
    e.consume();
    AlphaMarquee marquee = scoreTC.getMarquee();
    if (SwingUtilities.isLeftMouseButton(e)) {
        int x = e.getX();
        int diffX = x - startX;
        double translation = diffX / (double) timeState.getPixelSecond();
        if (timeState.isSnapEnabled() && !e.isControlDown()) {
            double newTime = ScoreUtilities.getSnapValueMove(-minTranslation + translation, timeState.getSnapValue());
            translation = newTime + minTranslation;
        }
        translation = Math.max(translation, minTranslation);
        selection.updateTranslation(translation);
        int marqueeX = (int) ((marquee.startTime + translation) * timeState.getPixelSecond());
        marquee.setLocation(marqueeX, marquee.getY());
        for (int i = 0; i < selectedScoreObjects.length; i++) {
            ScoreObject sObj = selectedScoreObjects[i];
            sObj.setStartTime(startTimes[i] + translation);
        }
    }
    checkScroll(e);
}
Also used : ScoreObject(blue.score.ScoreObject) AlphaMarquee(blue.components.AlphaMarquee) Point(java.awt.Point)

Example 3 with AlphaMarquee

use of blue.components.AlphaMarquee in project blue by kunstmusik.

the class MultiLineMoveMouseListener method mouseReleased.

@Override
public void mouseReleased(MouseEvent e) {
    e.consume();
    if (SwingUtilities.isLeftMouseButton(e)) {
        AlphaMarquee marquee = scoreTC.getMarquee();
        marquee.startTime += selection.getTranslationTime();
        marquee.endTime += selection.getTranslationTime();
        selection.endTranslation();
    }
    timeState = null;
}
Also used : AlphaMarquee(blue.components.AlphaMarquee)

Example 4 with AlphaMarquee

use of blue.components.AlphaMarquee in project blue by kunstmusik.

the class MultiLineSelectionMouseProcessor method mousePressed.

@Override
public void mousePressed(MouseEvent e) {
    if (!isMultiLineMode()) {
        return;
    }
    AlphaMarquee marquee = scoreTC.getMarquee();
    Point p = SwingUtilities.convertPoint(scoreTC.getScorePanel(), e.getPoint(), marquee);
    if (marquee.isVisible() && marquee.contains(p)) {
        return;
    }
    e.consume();
    RealtimeRenderManager.getInstance().stopAuditioning();
    timeState = scoreTC.getTimeState();
    SoundObjectView sObjView;
    ScorePath scorePath = ScoreController.getInstance().getScorePath();
    Layer layer = scorePath.getGlobalLayerForY(e.getY());
    if (layer == null || !(layer instanceof ScoreObjectLayer)) {
        marquee.setVisible(false);
        return;
    }
    startLayer = lastLayer = layer;
    allLayers = scorePath.getAllLayers();
    if (UiUtilities.isRightMouseButton(e)) {
    // showPopup(comp, e);
    } else if (SwingUtilities.isLeftMouseButton(e)) {
        startX = Math.max(e.getX(), 0);
        double startTime = startX / (double) timeState.getPixelSecond();
        if (timeState.isSnapEnabled()) {
            startTime = ScoreUtilities.getSnapValueStart(startTime, timeState.getSnapValue());
            startX = (int) (startTime * timeState.getPixelSecond());
        }
        startTopBottom = getTopBottomForLayer(layer, scorePath.getScore());
        scoreTC.getMarquee().setStart(new Point(startX, startTopBottom[0]));
        scoreTC.getMarquee().setVisible(true);
        ScoreController.getInstance().setSelectedScoreObjects(null);
        selection.reset();
        selection.startSelection(startTime, startTime);
    }
}
Also used : ScorePath(blue.ui.core.score.ScorePath) ScoreObjectLayer(blue.score.layers.ScoreObjectLayer) Point(java.awt.Point) AlphaMarquee(blue.components.AlphaMarquee) Layer(blue.score.layers.Layer) ScoreObjectLayer(blue.score.layers.ScoreObjectLayer)

Example 5 with AlphaMarquee

use of blue.components.AlphaMarquee in project blue by kunstmusik.

the class MultiLineSelectionMouseProcessor method mouseDragged.

@Override
public void mouseDragged(MouseEvent e) {
    if (!isMultiLineMode()) {
        return;
    }
    e.consume();
    AlphaMarquee marquee = scoreTC.getMarquee();
    if (SwingUtilities.isLeftMouseButton(e)) {
        int x = Math.max(e.getX(), 0);
        double mouseDragTime = x / (double) timeState.getPixelSecond();
        if (timeState.isSnapEnabled()) {
            mouseDragTime = ScoreUtilities.getSnapValueMove(mouseDragTime, timeState.getSnapValue());
            x = (int) (mouseDragTime * timeState.getPixelSecond());
        }
        ScorePath scorePath = ScoreController.getInstance().getScorePath();
        Layer layer = scorePath.getGlobalLayerForY(e.getY());
        if (layer != null && (layer instanceof ScoreObjectLayer)) {
            lastLayer = layer;
        }
        // if (!(layer instanceof ScoreObjectLayer)) {
        // return;
        // }
        int[] topBottom = getTopBottomForLayer(lastLayer, scorePath.getScore());
        int leftX, rightX, topY, bottomY;
        int startLayerIndex, endLayerIndex;
        if (x < startX) {
            leftX = x;
            rightX = startX;
        } else {
            leftX = startX;
            rightX = x;
        }
        if (topBottom[0] < startTopBottom[0]) {
            topY = topBottom[0];
            bottomY = startTopBottom[1];
            startLayerIndex = allLayers.indexOf(lastLayer);
            endLayerIndex = allLayers.indexOf(startLayer);
        } else {
            topY = startTopBottom[0];
            bottomY = topBottom[1];
            startLayerIndex = allLayers.indexOf(startLayer);
            endLayerIndex = allLayers.indexOf(lastLayer);
        }
        leftX = Math.max(leftX, 0);
        topY = Math.max(topY, 0);
        marquee.setStart(new Point(leftX, topY));
        marquee.setDragPoint(new Point(rightX, bottomY));
        double start = leftX / (double) timeState.getPixelSecond();
        double end = rightX / (double) timeState.getPixelSecond();
        marquee.startTime = start;
        marquee.endTime = end;
        List<Layer> currentLayers = allLayers.subList(startLayerIndex, endLayerIndex + 1);
        selection.updateSelection(start, end, currentLayers);
    }
    checkScroll(e);
}
Also used : ScorePath(blue.ui.core.score.ScorePath) ScoreObjectLayer(blue.score.layers.ScoreObjectLayer) Point(java.awt.Point) AlphaMarquee(blue.components.AlphaMarquee) Layer(blue.score.layers.Layer) ScoreObjectLayer(blue.score.layers.ScoreObjectLayer) Point(java.awt.Point)

Aggregations

AlphaMarquee (blue.components.AlphaMarquee)5 Point (java.awt.Point)4 ScoreObject (blue.score.ScoreObject)2 Layer (blue.score.layers.Layer)2 ScoreObjectLayer (blue.score.layers.ScoreObjectLayer)2 ScorePath (blue.ui.core.score.ScorePath)2