Search in sources :

Example 1 with ScorePath

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

the class MoveScoreObjectsListener method mousePressed.

@Override
public void mousePressed(MouseEvent e) {
    if (currentScoreObjectView == null || !SwingUtilities.isLeftMouseButton(e)) {
        return;
    }
    ScoreObject scoreObj = currentScoreObjectView.getScoreObject();
    Collection<? extends ScoreObject> temp = ScoreController.getInstance().getSelectedScoreObjects();
    if (!temp.contains(scoreObj)) {
        return;
    }
    e.consume();
    ScorePath scorePath = ScoreController.getInstance().getScorePath();
    startPoint = e.getPoint();
    selectedScoreObjects = temp.toArray(new ScoreObject[0]);
    startTimes = new double[selectedScoreObjects.length];
    startLayerIndices = new int[selectedScoreObjects.length];
    currentLayerIndices = new int[selectedScoreObjects.length];
    minDiffTime = Double.MAX_VALUE;
    startLayer = scorePath.getGlobalLayerIndexForY(e.getY());
    lastLayerAdjust = 0;
    minYAdjust = Integer.MIN_VALUE;
    maxYAdjust = Integer.MAX_VALUE;
    initialDrag = true;
    List<Layer> allLayers = scorePath.getAllLayers();
    for (int i = 0; i < selectedScoreObjects.length; i++) {
        startTimes[i] = selectedScoreObjects[i].getStartTime();
        if (startTimes[i] < minDiffTime) {
            minDiffTime = startTimes[i];
        }
        startLayerIndices[i] = currentLayerIndices[i] = scorePath.getGlobalLayerIndexForScoreObject(selectedScoreObjects[i]);
        int minY = getMinYAdjust(allLayers, scoreObj, startLayerIndices[i]);
        int maxY = getMaxYAdjust(allLayers, scoreObj, startLayerIndices[i]);
        minYAdjust = (minY > minYAdjust) ? minY : minYAdjust;
        maxYAdjust = (maxY < maxYAdjust) ? maxY : maxYAdjust;
    }
    minDiffTime = -minDiffTime;
}
Also used : ScorePath(blue.ui.core.score.ScorePath) ScoreObject(blue.score.ScoreObject) Layer(blue.score.layers.Layer) ScoreObjectLayer(blue.score.layers.ScoreObjectLayer) Point(java.awt.Point)

Example 2 with ScorePath

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

the class AddMarkerAction method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    BlueProject project = BlueProjectManager.getInstance().getCurrentProject();
    if (project == null) {
        return;
    }
    BlueData data = project.getData();
    if (data == null) {
        return;
    }
    RenderTimeManager timeManager = Lookup.getDefault().lookup(RenderTimeManager.class);
    ScorePath path = ScoreController.getInstance().getScorePath();
    if (path.getLastLayerGroup() == null) {
        double markerTime = MainToolBar.getInstance().isRendering() ? timeManager.getRenderTime() + timeManager.getRenderStartTime() : data.getRenderStartTime();
        data.getMarkersList().addMarker(markerTime);
    }
}
Also used : BlueData(blue.BlueData) ScorePath(blue.ui.core.score.ScorePath) BlueProject(blue.projects.BlueProject) RenderTimeManager(blue.services.render.RenderTimeManager)

Example 3 with ScorePath

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

the class DuplicateScoreObjectsAction method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    // FIXME - this needs to work with ScoreObjects...
    Collection<? extends ScoreObject> scoreObjects = ScoreController.getInstance().getSelectedScoreObjects();
    if (!scoreObjects.isEmpty()) {
        ScorePath path = ScoreController.getInstance().getScorePath();
        AddScoreObjectEdit top = null;
        for (ScoreObject sObj : scoreObjects) {
            ScoreObject clone = sObj.deepCopy();
            clone.setStartTime(clone.getStartTime() + clone.getSubjectiveDuration());
            ScoreObjectLayer layer = (ScoreObjectLayer) path.getLayerForScoreObject(sObj);
            if (layer == null) {
                JOptionPane.showMessageDialog(WindowManager.getDefault().getMainWindow(), "Could not find Layer for ScoreObject", "Error", JOptionPane.ERROR_MESSAGE);
                return;
            }
            layer.add(clone);
            AddScoreObjectEdit edit = new AddScoreObjectEdit(layer, clone);
            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)

Example 4 with ScorePath

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

the class NudgeDownAction 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()];
        int lastIndex = layers.size() - 1;
        for (int i = 0; i < scoreObjects.length; i++) {
            int index = path.getGlobalLayerIndexForScoreObject(scoreObjects[i]);
            if (index >= lastIndex) {
                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 5 with ScorePath

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

the class MoveScoreObjectsListener method mouseDragged.

@Override
public void mouseDragged(MouseEvent e) {
    ScoreController scoreController = ScoreController.getInstance();
    ScorePath scorePath = ScoreController.getInstance().getScorePath();
    List<Layer> allLayers = scorePath.getAllLayers();
    e.consume();
    if (initialDrag) {
        initialDrag = false;
        if ((e.getModifiers() & OS_CTRL_KEY) == OS_CTRL_KEY) {
            for (int i = 0; i < selectedScoreObjects.length; i++) {
                ScoreObject original = selectedScoreObjects[i];
                ScoreObject clone = original.deepCopy();
                ScoreObjectLayer layer = (ScoreObjectLayer) allLayers.get(startLayerIndices[i]);
                layer.add(clone);
                scoreController.removeSelectedScoreObject(original);
                scoreController.addSelectedScoreObject(clone);
                selectedScoreObjects[i] = clone;
            }
        }
    }
    double diffTime = e.getX() - startPoint.x;
    TimeState timeState = scoreTC.getTimeState();
    diffTime = diffTime / timeState.getPixelSecond();
    if (diffTime < minDiffTime) {
        diffTime = minDiffTime;
    }
    if (timeState.isSnapEnabled()) {
        double tempStart = -minDiffTime + diffTime;
        double snappedStart = ScoreUtilities.getSnapValueMove(tempStart, timeState.getSnapValue());
        diffTime = snappedStart + minDiffTime;
    }
    int newLayerIndex = scorePath.getGlobalLayerIndexForY(e.getY());
    int layerAdjust = newLayerIndex - startLayer;
    layerAdjust = Math.max(layerAdjust, minYAdjust);
    layerAdjust = Math.min(layerAdjust, maxYAdjust);
    boolean layerAdjusted = lastLayerAdjust != layerAdjust;
    if (layerAdjusted) {
        lastLayerAdjust = layerAdjust;
    }
    for (int i = 0; i < selectedScoreObjects.length; i++) {
        selectedScoreObjects[i].setStartTime(startTimes[i] + diffTime);
        if (layerAdjusted) {
            ScoreObject scoreObj = selectedScoreObjects[i];
            int startIndex = startLayerIndices[i];
            int curLayerIndex = currentLayerIndices[i];
            int newSObjLayerIndex = startIndex + layerAdjust;
            allLayers.get(curLayerIndex).remove(scoreObj);
            // Re-add moved scoreObject as selected
            scoreController.addSelectedScoreObject(scoreObj);
            ((ScoreObjectLayer) allLayers.get(newSObjLayerIndex)).add(scoreObj);
            currentLayerIndices[i] = newSObjLayerIndex;
        }
    }
}
Also used : ScoreController(blue.ui.core.score.ScoreController) ScorePath(blue.ui.core.score.ScorePath) ScoreObjectLayer(blue.score.layers.ScoreObjectLayer) ScoreObject(blue.score.ScoreObject) TimeState(blue.score.TimeState) Layer(blue.score.layers.Layer) ScoreObjectLayer(blue.score.layers.ScoreObjectLayer) Point(java.awt.Point)

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