use of de.mossgrabers.framework.featuregroup.ModeManager in project DrivenByMoss by git-moss.
the class SequencerView method handleSequencerArea.
/**
* {@inheritDoc}
*/
@Override
protected void handleSequencerArea(final int index, final int x, final int y, final int velocity) {
// Handle note editor mode
final ModeManager modeManager = this.surface.getModeManager();
if (velocity > 0) {
if (modeManager.isActive(Modes.NOTE)) {
// Store existing note for editing
final INoteClip clip = this.getClip();
final int channel = this.configuration.getMidiEditChannel();
final int mappedY = this.keyManager.map(y);
final StepState state = clip.getStep(channel, x, mappedY).getState();
if (state == StepState.START)
this.editNote(clip, channel, x, mappedY, true);
return;
}
} else {
if (this.isNoteEdited)
this.isNoteEdited = false;
if (modeManager.isActive(Modes.NOTE))
return;
}
super.handleSequencerArea(index, x, y, velocity);
}
use of de.mossgrabers.framework.featuregroup.ModeManager in project DrivenByMoss by git-moss.
the class DeviceParamsMode method moveUp.
/**
* Move up the hierarchy.
*/
protected void moveUp() {
final ModeManager modeManager = this.surface.getModeManager();
if (modeManager.isActive(Modes.DEVICE_CHAINS)) {
modeManager.setActive(Modes.DEVICE_PARAMS);
return;
}
// There is no device on the track move upwards to the track view
final ICursorDevice cd = this.model.getCursorDevice();
if (!cd.doesExist()) {
this.surface.getButton(ButtonID.TRACK).trigger(ButtonEvent.DOWN);
return;
}
// Parameter banks are shown -> show devices
final DeviceParamsMode deviceParamsMode = (DeviceParamsMode) modeManager.get(Modes.DEVICE_PARAMS);
if (!deviceParamsMode.isShowDevices()) {
deviceParamsMode.setShowDevices(true);
return;
}
// Devices are shown, if nested show the layers otherwise move up to the tracks
if (cd.isNested()) {
cd.selectParent();
this.model.getHost().scheduleTask(() -> {
if (cd.hasLayers())
modeManager.setActive(this.surface.getConfiguration().getCurrentLayerMixMode());
else
modeManager.setActive(Modes.DEVICE_PARAMS);
deviceParamsMode.setShowDevices(false);
cd.selectChannel();
}, 300);
return;
}
// Move up to the track
if (this.model.isCursorDeviceOnMasterTrack())
this.surface.getButton(ButtonID.MASTERTRACK).trigger(ButtonEvent.DOWN);
else
this.surface.getButton(ButtonID.TRACK).trigger(ButtonEvent.DOWN);
}
use of de.mossgrabers.framework.featuregroup.ModeManager in project DrivenByMoss by git-moss.
the class DeviceParamsMode method onFirstRow.
/**
* {@inheritDoc}
*/
@Override
public void onFirstRow(final int index, final ButtonEvent event) {
if (event == ButtonEvent.DOWN)
return;
if (event == ButtonEvent.UP) {
final ICursorDevice cd = this.model.getCursorDevice();
if (!cd.doesExist())
return;
// Select parameter bank if parameter banks are visible
if (!this.showDevices) {
cd.getParameterPageBank().selectPage(index);
return;
}
// Duplicate device
if (this.surface.isPressed(ButtonID.DUPLICATE)) {
this.surface.setTriggerConsumed(ButtonID.DUPLICATE);
cd.duplicate();
return;
}
// Delete device
if (this.surface.isPressed(ButtonID.DELETE)) {
this.surface.setTriggerConsumed(ButtonID.DELETE);
cd.getDeviceBank().getItem(index).remove();
return;
}
// Select device
if (cd.getIndex() != index) {
cd.getDeviceBank().getItem(index).select();
return;
}
// No layers, show devices
final ModeManager modeManager = this.surface.getModeManager();
if (!cd.hasLayers()) {
((DeviceParamsMode) modeManager.get(Modes.DEVICE_PARAMS)).setShowDevices(false);
return;
}
// If there are layers, make sure one is selected
final Optional<?> layer = cd.getLayerBank().getSelectedItem();
if (layer.isEmpty())
cd.getLayerBank().getItem(0).select();
modeManager.setActive(this.surface.getConfiguration().getCurrentLayerMixMode());
return;
}
// LONG press - move upwards
this.surface.setTriggerConsumed(ButtonID.get(ButtonID.ROW1_1, index));
this.moveUp();
}
use of de.mossgrabers.framework.featuregroup.ModeManager in project DrivenByMoss by git-moss.
the class AbstractTrackMode method onSecondRow.
/**
* {@inheritDoc}
*/
@Override
public void onSecondRow(final int index, final ButtonEvent event) {
if (event != ButtonEvent.DOWN)
return;
final ITrackBank tb = this.model.getCurrentTrackBank();
final ITrack track = tb.getItem(index);
if (this.surface.isPressed(ButtonID.STOP_CLIP)) {
track.stop();
return;
}
final PushConfiguration config = this.surface.getConfiguration();
if (!this.isPush2 || config.isMuteLongPressed() || config.isSoloLongPressed() || config.isMuteSoloLocked()) {
if (config.isMuteState())
track.toggleMute();
else
track.toggleSolo();
return;
}
final ModeManager modeManager = this.surface.getModeManager();
switch(index) {
case 0:
if (modeManager.isActive(Modes.VOLUME))
modeManager.setActive(Modes.TRACK);
else
modeManager.setActive(Modes.VOLUME);
break;
case 1:
if (modeManager.isActive(Modes.PAN))
modeManager.setActive(Modes.TRACK);
else
modeManager.setActive(Modes.PAN);
break;
case 2:
if (modeManager.isActive(Modes.CROSSFADER))
modeManager.setActive(Modes.TRACK);
else
modeManager.setActive(Modes.CROSSFADER);
break;
case 3:
if (!this.model.isEffectTrackBankActive()) {
config.setSendsAreToggled(!config.isSendsAreToggled());
if (!modeManager.isActive(Modes.TRACK))
modeManager.setActive(Modes.get(Modes.SEND1, config.isSendsAreToggled() ? 4 : 0));
}
break;
case 7:
if (!this.model.isEffectTrackBankActive()) {
if (this.lastSendIsAccessible())
this.handleSendEffect(config.isSendsAreToggled() ? 7 : 3);
else
this.model.getTrackBank().selectParent();
}
break;
default:
this.handleSendEffect(index - (config.isSendsAreToggled() ? 0 : 4));
break;
}
config.setDebugMode(modeManager.getActiveID());
}
use of de.mossgrabers.framework.featuregroup.ModeManager in project DrivenByMoss by git-moss.
the class DeviceLayerMode method getButtonColor.
/**
* {@inheritDoc}
*/
@Override
public int getButtonColor(final ButtonID buttonID) {
final ICursorDevice cd = this.model.getCursorDevice();
if (cd == null || !cd.hasLayers())
return super.getButtonColor(buttonID);
// Drum Pad Bank has size of 16, layers only 8
final int offset = this.getDrumPadIndex();
int index = this.isButtonRow(0, buttonID);
if (index >= 0) {
final IChannel dl = this.bank.getItem(offset + buttonID.ordinal() - ButtonID.ROW1_1.ordinal());
if (dl.doesExist() && dl.isActivated()) {
if (dl.isSelected())
return this.isPush2 ? PushColorManager.PUSH2_COLOR_ORANGE_HI : PushColorManager.PUSH1_COLOR_ORANGE_HI;
return this.isPush2 ? PushColorManager.PUSH2_COLOR_YELLOW_LO : PushColorManager.PUSH1_COLOR_YELLOW_LO;
}
return super.getButtonColor(buttonID);
}
index = this.isButtonRow(1, buttonID);
if (index >= 0) {
final boolean muteState = this.configuration.isMuteState();
final IChannel layer = this.bank.getItem(offset + index);
if (this.isPush2) {
if (this.configuration.isMuteLongPressed() || this.configuration.isSoloLongPressed() || this.configuration.isMuteSoloLocked()) {
if (layer.doesExist()) {
if (muteState) {
if (layer.isMute())
return PushColorManager.PUSH2_COLOR2_AMBER_LO;
} else if (layer.isSolo())
return PushColorManager.PUSH2_COLOR2_YELLOW_HI;
}
return PushColorManager.PUSH2_COLOR_BLACK;
}
final ModeManager modeManager = this.surface.getModeManager();
switch(index) {
case 0:
return modeManager.isActive(Modes.DEVICE_LAYER_VOLUME) ? PushColorManager.PUSH2_COLOR2_WHITE : PushColorManager.PUSH2_COLOR_BLACK;
case 1:
return modeManager.isActive(Modes.DEVICE_LAYER_PAN) ? PushColorManager.PUSH2_COLOR2_WHITE : PushColorManager.PUSH2_COLOR_BLACK;
case 4:
case 5:
case 6:
case 7:
return modeManager.isActive(this.getSendMode(index)) ? PushColorManager.PUSH2_COLOR2_WHITE : PushColorManager.PUSH2_COLOR_BLACK;
default:
return PushColorManager.PUSH2_COLOR_BLACK;
}
}
if (!cd.hasLayers())
return index == 7 ? PushColorManager.PUSH1_COLOR2_WHITE : super.getButtonColor(buttonID);
if (layer.doesExist()) {
if (muteState)
return layer.isMute() ? PushColorManager.PUSH1_COLOR_BLACK : PushColorManager.PUSH1_COLOR2_YELLOW_HI;
return layer.isSolo() ? PushColorManager.PUSH1_COLOR2_BLUE_HI : PushColorManager.PUSH1_COLOR2_GREY_LO;
}
}
return super.getButtonColor(buttonID);
}
Aggregations