Search in sources :

Example 1 with IDrumPad

use of de.mossgrabers.framework.daw.data.IDrumPad in project DrivenByMoss by git-moss.

the class DrumView method handleSelectButton.

/**
 * {@inheritDoc}
 */
@Override
public synchronized void handleSelectButton(final int playedPad) {
    // Do we have drum pads?
    final IDrumDevice primary = this.model.getDrumDevice();
    if (!primary.hasDrumPads())
        return;
    final ICursorDevice cd = this.model.getCursorDevice();
    final boolean isNested = cd.isNested();
    if (isNested) {
        // We have to move up to compare the main drum devices
        cd.selectParent();
    }
    // Can only scroll to the channel if the cursor device is the primary device
    if (primary.getPosition() != cd.getPosition())
        return;
    // Align the primary and cursor device drum bank view
    final IDrumPadBank drumPadBank = primary.getDrumPadBank();
    final int scrollPos = drumPadBank.getScrollPosition();
    final IDrumPadBank cdDrumPadBank = cd.getDrumPadBank();
    final int pageSize = cdDrumPadBank.getPageSize();
    final int adjustedPage = playedPad / pageSize * pageSize;
    cdDrumPadBank.scrollTo(scrollPos + adjustedPage, false);
    // Do not reselect
    final IDrumPad drumPad = drumPadBank.getItem(playedPad);
    if (drumPad.isSelected()) {
        // If the instrument of the pad was selected for editing, try to select it again
        if (isNested) {
            final IDrumPad selectedItem = cdDrumPadBank.getItem(playedPad % pageSize);
            if (selectedItem != null)
                selectedItem.enter();
        }
        return;
    }
    // Only activate layer mode if not one of the layer modes is already active
    final ModeManager modeManager = this.surface.getModeManager();
    if (!Modes.isLayerMode(modeManager.getActiveID()))
        modeManager.setActive(Modes.DEVICE_LAYER);
    drumPad.select();
    this.updateNoteMapping();
}
Also used : IDrumDevice(de.mossgrabers.framework.daw.data.IDrumDevice) IDrumPadBank(de.mossgrabers.framework.daw.data.bank.IDrumPadBank) IDrumPad(de.mossgrabers.framework.daw.data.IDrumPad) ICursorDevice(de.mossgrabers.framework.daw.data.ICursorDevice) ModeManager(de.mossgrabers.framework.featuregroup.ModeManager)

Example 2 with IDrumPad

use of de.mossgrabers.framework.daw.data.IDrumPad in project DrivenByMoss by git-moss.

the class Drum64View method handleSelectButton.

/**
 * {@inheritDoc}
 */
@Override
protected void handleSelectButton(final int playedPad) {
    // Do we have drum pads?
    final IDrumDevice primary = this.model.getDrumDevice64();
    if (!primary.hasDrumPads())
        return;
    final ICursorDevice cd = this.model.getCursorDevice();
    final boolean isNested = cd.isNested();
    if (isNested) {
        // We have to move up to compare the main drum devices
        cd.selectParent();
    }
    // Can only scroll to the channel if the cursor device is the primary device
    if (primary.getPosition() != cd.getPosition())
        return;
    // Align the primary and cursor device drum bank view
    final IDrumPadBank drumPadBank = primary.getDrumPadBank();
    final int scrollPos = drumPadBank.getScrollPosition();
    final IDrumPadBank cdDrumPadBank = cd.getDrumPadBank();
    final int pageSize = cdDrumPadBank.getPageSize();
    final int adjustedPage = playedPad / pageSize * pageSize;
    cdDrumPadBank.scrollTo(scrollPos + adjustedPage, false);
    // Do not reselect, if pad is already selected
    final IDrumPad drumPad = drumPadBank.getItem(playedPad);
    if (drumPad.isSelected()) {
        // If the instrument of the pad was selected for editing, try to select it again
        if (isNested) {
            final IDrumPad selectedItem = cdDrumPadBank.getItem(playedPad % pageSize);
            if (selectedItem != null)
                selectedItem.enter();
        }
        return;
    }
    // Only activate layer mode if not one of the layer modes is already active
    final ModeManager modeManager = this.surface.getModeManager();
    if (!Modes.isLayerMode(modeManager.getActiveID()))
        modeManager.setActive(Modes.DEVICE_LAYER);
    drumPad.select();
}
Also used : IDrumDevice(de.mossgrabers.framework.daw.data.IDrumDevice) IDrumPadBank(de.mossgrabers.framework.daw.data.bank.IDrumPadBank) IDrumPad(de.mossgrabers.framework.daw.data.IDrumPad) ICursorDevice(de.mossgrabers.framework.daw.data.ICursorDevice) ModeManager(de.mossgrabers.framework.featuregroup.ModeManager)

Aggregations

ICursorDevice (de.mossgrabers.framework.daw.data.ICursorDevice)2 IDrumDevice (de.mossgrabers.framework.daw.data.IDrumDevice)2 IDrumPad (de.mossgrabers.framework.daw.data.IDrumPad)2 IDrumPadBank (de.mossgrabers.framework.daw.data.bank.IDrumPadBank)2 ModeManager (de.mossgrabers.framework.featuregroup.ModeManager)2