use of de.mossgrabers.framework.mode.Modes in project DrivenByMoss by git-moss.
the class ControlView method onButtonRow1.
/**
* {@inheritDoc}
*/
@Override
public void onButtonRow1(final int index, final ButtonEvent event) {
if (event != ButtonEvent.DOWN)
return;
final ModeManager modeManager = this.surface.getModeManager();
Modes activeModeId = modeManager.getActiveID();
if (Modes.VIEW_SELECT == activeModeId) {
if (index == 1) {
this.surface.getViewManager().setActive(Views.PLAY);
if (Modes.VOLUME.equals(modeManager.getPreviousID()))
modeManager.restore();
else
modeManager.setActive(Modes.SESSION);
} else
modeManager.restore();
this.surface.turnOffTransport();
return;
}
if (!Modes.FUNCTIONS.equals(activeModeId) && !Modes.FIXED.equals(activeModeId)) {
modeManager.setActive(Modes.FUNCTIONS);
activeModeId = Modes.FUNCTIONS;
}
if (Modes.FIXED.equals(activeModeId)) {
this.surface.getConfiguration().setNewClipLength(index);
return;
}
switch(index) {
// Undo
case 0:
this.model.getApplication().undo();
break;
// Redo
case 1:
this.model.getApplication().redo();
break;
// Delete
case 2:
this.model.getApplication().deleteSelection();
break;
// Double
case 3:
this.model.getApplication().duplicate();
break;
// New
case 4:
this.newCommand.execute();
break;
// Open the VST window
case 5:
this.model.getCursorDevice().toggleWindowOpen();
break;
// Metronome
case 6:
this.model.getTransport().toggleMetronome();
break;
// Tap Tempo on MKII
case 7:
this.model.getTransport().tapTempo();
break;
default:
// Not used
break;
}
}
use of de.mossgrabers.framework.mode.Modes in project DrivenByMoss by git-moss.
the class ModeMultiSelectCommand method executeShifted.
/**
* {@inheritDoc}
*/
@Override
public void executeShifted(final ButtonEvent event) {
if (event != ButtonEvent.UP)
return;
final Modes activeModeId = this.modeManager.getActiveID();
Modes newMode = this.currentModeID;
// If coming from a mode not on the list, activate the last one
if (this.currentModeID.equals(activeModeId)) {
final ITrackBank trackBank = this.model.getTrackBank();
int index = this.modeIds.indexOf(activeModeId);
// If a send mode is selected check if the according send exists
do {
index--;
if (index < 0 || index >= this.modeIds.size())
index = this.modeIds.size() - 1;
newMode = this.modeIds.get(index);
} while (Modes.isSendMode(newMode) && !trackBank.canEditSend(newMode.ordinal() - Modes.SEND1.ordinal()));
}
this.activateMode(newMode);
}
use of de.mossgrabers.framework.mode.Modes in project DrivenByMoss by git-moss.
the class ShiftView method getTrackButtonColor.
/**
* {@inheritDoc}
*/
@Override
public int getTrackButtonColor(final int index) {
final ITrackBank tb = this.model.getCurrentTrackBank();
final ISceneBank sceneBank = tb.getSceneBank();
final Modes mode = this.surface.getModeManager().getActiveID();
switch(index) {
case 0:
return sceneBank.canScrollPageBackwards() ? APCminiControlSurface.APC_BUTTON_STATE_ON : APCminiControlSurface.APC_BUTTON_STATE_OFF;
case 1:
return sceneBank.canScrollPageForwards() ? APCminiControlSurface.APC_BUTTON_STATE_ON : APCminiControlSurface.APC_BUTTON_STATE_OFF;
case 2:
return tb.canScrollPageBackwards() ? APCminiControlSurface.APC_BUTTON_STATE_ON : APCminiControlSurface.APC_BUTTON_STATE_OFF;
case 3:
return tb.canScrollPageForwards() ? APCminiControlSurface.APC_BUTTON_STATE_ON : APCminiControlSurface.APC_BUTTON_STATE_OFF;
case 4:
return Modes.VOLUME.equals(mode) ? APCminiControlSurface.APC_BUTTON_STATE_ON : APCminiControlSurface.APC_BUTTON_STATE_OFF;
case 5:
return Modes.PAN.equals(mode) ? APCminiControlSurface.APC_BUTTON_STATE_ON : APCminiControlSurface.APC_BUTTON_STATE_OFF;
case 6:
return Modes.isSendMode(mode) ? APCminiControlSurface.APC_BUTTON_STATE_ON : APCminiControlSurface.APC_BUTTON_STATE_OFF;
case 7:
return Modes.DEVICE_PARAMS.equals(mode) ? APCminiControlSurface.APC_BUTTON_STATE_ON : APCminiControlSurface.APC_BUTTON_STATE_OFF;
default:
// Never reached
break;
}
return APCminiColorManager.APC_COLOR_BLACK;
}
use of de.mossgrabers.framework.mode.Modes in project DrivenByMoss by git-moss.
the class ModeSwitcher method scrollUp.
/**
* Scroll upwards through the modes.
*/
public void scrollUp() {
final ModeManager modeManager = this.surface.getModeManager();
final Modes activeModeId = modeManager.getActiveID();
if (Modes.PAN == activeModeId) {
modeManager.setActive(Modes.VOLUME);
this.surface.getDisplay().notify("Volume");
} else if (Modes.VOLUME == activeModeId) {
modeManager.setActive(Modes.TRACK);
this.surface.getDisplay().notify("Track");
} else if (Modes.TRACK == activeModeId) {
modeManager.setActive(Modes.DEVICE_PARAMS);
this.surface.getDisplay().notify("Parameters");
} else {
modeManager.setActive(Modes.PAN);
this.surface.getDisplay().notify("Panorama");
}
}
use of de.mossgrabers.framework.mode.Modes in project DrivenByMoss by git-moss.
the class AbstractControllerSetup method test.
/**
* {@inheritDoc}
*/
@Override
public void test(final TestCallback callback) {
final TestFramework framework = new TestFramework(this.host);
this.getSurfaces().forEach(surface -> {
framework.scheduleFunction(() -> this.host.println("Testing controller: " + this.getClass().getName()));
final ViewManager viewManager = surface.getViewManager();
final ModeManager modeManager = surface.getModeManager();
final int max = this.model.getValueChanger().getUpperBound() - 1;
for (final Views viewID : Views.values()) {
if (viewManager.get(viewID) == null)
continue;
for (final Modes modeID : Modes.values()) {
if (modeManager.get(modeID) == null)
continue;
framework.scheduleFunction(() -> {
this.host.println("- View " + viewID + " Mode " + modeID);
viewManager.setActive(viewID);
modeManager.setActive(modeID);
for (final ButtonID buttonID : ButtonID.values()) {
final IHwButton button = surface.getButton(buttonID);
if (button == null)
continue;
button.trigger(ButtonEvent.DOWN);
button.trigger(ButtonEvent.LONG);
button.trigger(ButtonEvent.UP);
}
for (final ContinuousID continuousID : ContinuousID.values()) {
final IHwContinuousControl continuous = surface.getContinuous(continuousID);
if (continuous == null)
continue;
final TriggerCommand touchCommand = continuous.getTouchCommand();
if (touchCommand != null) {
touchCommand.execute(ButtonEvent.DOWN, 127);
touchCommand.execute(ButtonEvent.LONG, 127);
touchCommand.execute(ButtonEvent.UP, 0);
}
final ContinuousCommand command = continuous.getCommand();
if (command != null) {
command.execute(0);
command.execute(max);
command.execute(max / 2);
}
final PitchbendCommand pitchbendCommand = continuous.getPitchbendCommand();
if (pitchbendCommand != null) {
pitchbendCommand.onPitchbend(0, 0);
pitchbendCommand.onPitchbend(0, 127);
pitchbendCommand.onPitchbend(0, 64);
}
}
});
}
}
});
callback.startTesting();
framework.executeScheduler(callback);
}
Aggregations