Search in sources :

Example 1 with ScoreController

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

the class PatternLayerPanel method setSObjFromBufferMenuItemActionPerformed.

// GEN-LAST:event_editSObjMenuItemActionPerformed
private void setSObjFromBufferMenuItemActionPerformed(java.awt.event.ActionEvent evt) {
    // GEN-FIRST:event_setSObjFromBufferMenuItemActionPerformed
    ScoreController controller = ScoreController.getInstance();
    ScoreController.ScoreObjectBuffer buffer = controller.getScoreObjectBuffer();
    if (buffer.scoreObjects.size() == 1) {
        ScoreObject scoreObj = buffer.scoreObjects.get(0);
        if (!(scoreObj instanceof SoundObject)) {
            return;
        }
        SoundObject sObj = (SoundObject) scoreObj;
        SoundObject copy = sObj.deepCopy();
        copy.setStartTime(0.0f);
        copy.setSubjectiveDuration(4);
        copy.setTimeBehavior(SoundObject.TIME_BEHAVIOR_NONE);
        patternLayer.setSoundObject(copy);
        editSoundObject();
    }
}
Also used : ScoreController(blue.ui.core.score.ScoreController) SoundObject(blue.soundObject.SoundObject) ScoreObject(blue.score.ScoreObject)

Example 2 with ScoreController

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

the class PatternLayerPanel method otherMenuButtonActionPerformed.

// GEN-LAST:event_soloToggleButtonActionPerformed
@SuppressWarnings("unchecked")
private void otherMenuButtonActionPerformed(java.awt.event.ActionEvent evt) {
    // GEN-FIRST:event_otherMenuButtonActionPerformed
    Class<? extends SoundObject> current = patternLayer.getSoundObject().getClass();
    for (Component c : changeSObjMenu.getMenuComponents()) {
        JMenuItem menuItem = (JMenuItem) c;
        Class<? extends SoundObject> clazz = (Class<? extends SoundObject>) menuItem.getClientProperty("sObjClass");
        menuItem.setEnabled(!current.equals(clazz));
    }
    ScoreController controller = ScoreController.getInstance();
    Collection<? extends ScoreObject> selected = controller.getSelectedScoreObjects();
    setSObjFromBufferMenuItem.setEnabled(selected.size() == 1 && selected.iterator().next() instanceof SoundObject);
    jPopupMenu1.show(otherMenuButton, 0, otherMenuButton.getHeight());
}
Also used : ScoreController(blue.ui.core.score.ScoreController) SoundObject(blue.soundObject.SoundObject) ScoreObjectEditorTopComponent(blue.ui.core.score.layers.soundObject.ScoreObjectEditorTopComponent) Component(java.awt.Component) JMenuItem(javax.swing.JMenuItem)

Example 3 with ScoreController

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

ScoreController (blue.ui.core.score.ScoreController)3 ScoreObject (blue.score.ScoreObject)2 SoundObject (blue.soundObject.SoundObject)2 TimeState (blue.score.TimeState)1 Layer (blue.score.layers.Layer)1 ScoreObjectLayer (blue.score.layers.ScoreObjectLayer)1 ScorePath (blue.ui.core.score.ScorePath)1 ScoreObjectEditorTopComponent (blue.ui.core.score.layers.soundObject.ScoreObjectEditorTopComponent)1 Component (java.awt.Component)1 Point (java.awt.Point)1 JMenuItem (javax.swing.JMenuItem)1