Search in sources :

Example 6 with ScorePath

use of blue.ui.core.score.ScorePath 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 7 with ScorePath

use of blue.ui.core.score.ScorePath 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)

Example 8 with ScorePath

use of blue.ui.core.score.ScorePath in project blue by kunstmusik.

the class NudgeUpAction method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    Collection<? extends ScoreObject> selected = ScoreController.getInstance().getSelectedScoreObjects();
    if (!selected.isEmpty()) {
        ScorePath path = ScoreController.getInstance().getScorePath();
        ScoreObject[] scoreObjects = selected.<ScoreObject>toArray(new ScoreObject[selected.size()]);
        List<Layer> layers = path.getAllLayers();
        int[] indexes = new int[selected.size()];
        for (int i = 0; i < scoreObjects.length; i++) {
            int index = path.getGlobalLayerIndexForScoreObject(scoreObjects[i]);
            if (index < 1) {
                return;
            }
            Layer layer = layers.get(index - 1);
            if (!layer.accepts(scoreObjects[i])) {
                return;
            }
            indexes[i] = index;
        }
        int len = scoreObjects.length;
        ScoreObjectLayer[] startLayers = new ScoreObjectLayer[len];
        ScoreObjectLayer[] endLayers = new ScoreObjectLayer[len];
        for (int i = 0; i < scoreObjects.length; i++) {
            startLayers[i] = (ScoreObjectLayer) layers.get(indexes[i]);
            endLayers[i] = (ScoreObjectLayer) layers.get(indexes[i] - 1);
            startLayers[i].remove(scoreObjects[i]);
            endLayers[i].add(scoreObjects[i]);
        }
        MoveScoreObjectsEdit edit = new MoveScoreObjectsEdit(scoreObjects, startLayers, endLayers, null, null);
        BlueUndoManager.setUndoManager("score");
        BlueUndoManager.addEdit(edit);
    }
}
Also used : MoveScoreObjectsEdit(blue.ui.core.score.undo.MoveScoreObjectsEdit) ScorePath(blue.ui.core.score.ScorePath) ScoreObjectLayer(blue.score.layers.ScoreObjectLayer) ScoreObject(blue.score.ScoreObject) Layer(blue.score.layers.Layer) ScoreObjectLayer(blue.score.layers.ScoreObjectLayer)

Example 9 with ScorePath

use of blue.ui.core.score.ScorePath in project blue by kunstmusik.

the class RepeatScoreObjectsAction method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    Collection<? extends ScoreObject> scoreObjects = ScoreController.getInstance().getSelectedScoreObjects();
    if (!scoreObjects.isEmpty()) {
        Object retVal = JOptionPane.showInputDialog(WindowManager.getDefault().getMainWindow(), "Enter number of times to repeat:", new Integer(1));
        if (retVal == null) {
            return;
        }
        int count = -1;
        try {
            count = Integer.parseInt((String) retVal);
        } catch (Exception exception) {
            JOptionPane.showMessageDialog(WindowManager.getDefault().getMainWindow(), "Entry must be an integer value.", "Error", JOptionPane.ERROR_MESSAGE);
            return;
        }
        if (count < 1) {
            JOptionPane.showMessageDialog(WindowManager.getDefault().getMainWindow(), "Value must be greater than 0.", "Error", JOptionPane.ERROR_MESSAGE);
            return;
        }
        ScorePath path = ScoreController.getInstance().getScorePath();
        AddScoreObjectEdit top = null;
        for (ScoreObject sObj : scoreObjects) {
            double start = sObj.getStartTime();
            ScoreObjectLayer layer = (ScoreObjectLayer) path.getLayerForScoreObject(sObj);
            for (int j = 0; j < count; j++) {
                ScoreObject temp = sObj.deepCopy();
                start += sObj.getSubjectiveDuration();
                temp.setStartTime(start);
                if (layer == null) {
                    JOptionPane.showMessageDialog(WindowManager.getDefault().getMainWindow(), "Could not find SoundLayer for SoundObject", "Error", JOptionPane.ERROR_MESSAGE);
                    return;
                }
                layer.add(temp);
                AddScoreObjectEdit edit = new AddScoreObjectEdit(layer, temp);
                if (top == null) {
                    top = edit;
                } else {
                    top.addSubEdit(edit);
                }
            }
        }
        BlueUndoManager.setUndoManager("score");
        BlueUndoManager.addEdit(top);
    }
}
Also used : ScorePath(blue.ui.core.score.ScorePath) ScoreObjectLayer(blue.score.layers.ScoreObjectLayer) AddScoreObjectEdit(blue.ui.core.score.undo.AddScoreObjectEdit) ScoreObject(blue.score.ScoreObject) ScoreObject(blue.score.ScoreObject)

Aggregations

ScorePath (blue.ui.core.score.ScorePath)9 ScoreObjectLayer (blue.score.layers.ScoreObjectLayer)8 ScoreObject (blue.score.ScoreObject)6 Layer (blue.score.layers.Layer)6 Point (java.awt.Point)4 AlphaMarquee (blue.components.AlphaMarquee)2 AddScoreObjectEdit (blue.ui.core.score.undo.AddScoreObjectEdit)2 MoveScoreObjectsEdit (blue.ui.core.score.undo.MoveScoreObjectsEdit)2 BlueData (blue.BlueData)1 BlueProject (blue.projects.BlueProject)1 TimeState (blue.score.TimeState)1 RenderTimeManager (blue.services.render.RenderTimeManager)1 ScoreController (blue.ui.core.score.ScoreController)1