Search in sources :

Example 1 with ReplaceScoreObjectEdit

use of blue.ui.core.score.undo.ReplaceScoreObjectEdit in project blue by kunstmusik.

the class ReplaceWithBufferSoundObjectAction method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    ScoreController.ScoreObjectBuffer buffer = ScoreController.getInstance().getScoreObjectBuffer();
    List<Layer> layers = scorePath.getAllLayers();
    BlueData data = BlueProjectManager.getInstance().getCurrentBlueData();
    SoundObjectLibrary sObjLib = data.getSoundObjectLibrary();
    List<Instance> instances = new ArrayList<>();
    ReplaceScoreObjectEdit top = null;
    for (SoundObject sObj : soundObjects) {
        SoundObject replacement = getReplacementObject(buffer, instances);
        replacement.setStartTime(sObj.getStartTime());
        replacement.setSubjectiveDuration(sObj.getSubjectiveDuration());
        ScoreObjectLayer layer = (ScoreObjectLayer) findLayerForSoundObject(layers, sObj);
        layer.remove(sObj);
        layer.add(replacement);
        ReplaceScoreObjectEdit edit = new ReplaceScoreObjectEdit(layer, sObj, replacement);
        if (top == null) {
            top = edit;
        } else {
            top.addEdit(edit);
        }
    }
    // FIXME - this part is not undoable...
    sObjLib.checkAndAddInstanceSoundObjects(instances);
    BlueUndoManager.setUndoManager("score");
    BlueUndoManager.addEdit(top);
}
Also used : ScoreController(blue.ui.core.score.ScoreController) BlueData(blue.BlueData) ScoreObjectLayer(blue.score.layers.ScoreObjectLayer) SoundObject(blue.soundObject.SoundObject) Instance(blue.soundObject.Instance) ReplaceScoreObjectEdit(blue.ui.core.score.undo.ReplaceScoreObjectEdit) ArrayList(java.util.ArrayList) SoundObjectLibrary(blue.SoundObjectLibrary) SoundLayer(blue.SoundLayer) ScoreObjectLayer(blue.score.layers.ScoreObjectLayer) Layer(blue.score.layers.Layer)

Aggregations

BlueData (blue.BlueData)1 SoundLayer (blue.SoundLayer)1 SoundObjectLibrary (blue.SoundObjectLibrary)1 Layer (blue.score.layers.Layer)1 ScoreObjectLayer (blue.score.layers.ScoreObjectLayer)1 Instance (blue.soundObject.Instance)1 SoundObject (blue.soundObject.SoundObject)1 ScoreController (blue.ui.core.score.ScoreController)1 ReplaceScoreObjectEdit (blue.ui.core.score.undo.ReplaceScoreObjectEdit)1 ArrayList (java.util.ArrayList)1