use of de.mossgrabers.framework.featuregroup.ModeManager in project DrivenByMoss by git-moss.
the class SwingCommand method execute.
/**
* {@inheritDoc}
*/
@Override
public void execute(final ButtonEvent event, final int velocity) {
final ModeManager modeManager = this.surface.getModeManager();
// Switch Gain/Velocity note edit parameters
if (modeManager.isActive(Modes.NOTE) && this.surface.getViewManager().isActive(Views.DRUM, Views.PLAY)) {
if (event == ButtonEvent.DOWN) {
final EditNoteMode mode = (EditNoteMode) modeManager.get(Modes.NOTE);
final boolean isPanorama = mode.getSelectedItem() == EditNoteMode.PANORAMA;
mode.selectItem(isPanorama ? EditNoteMode.DURATION : EditNoteMode.PANORAMA);
this.surface.getDisplay().notify(isPanorama ? "Duration" : "Panorama");
}
return;
}
super.execute(event, velocity);
}
use of de.mossgrabers.framework.featuregroup.ModeManager 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);
}
use of de.mossgrabers.framework.featuregroup.ModeManager in project DrivenByMoss by git-moss.
the class RasteredKnobCommand method execute.
/**
* {@inheritDoc}
*/
@Override
public void execute(final int value) {
final ModeManager modeManager = this.surface.getModeManager();
if (modeManager.isActive(Modes.BROWSER)) {
final DeviceBrowserMode mode = (DeviceBrowserMode) modeManager.get(Modes.BROWSER);
mode.changeSelectedColumnValue(value);
return;
}
if (this.surface.isSelectPressed()) {
this.transport.changeLoopStart(this.model.getValueChanger().isIncrease(value), this.surface.isKnobSensitivitySlow());
return;
}
super.execute(value);
this.mvHelper.notifyTempo();
}
use of de.mossgrabers.framework.featuregroup.ModeManager in project DrivenByMoss by git-moss.
the class SelectPlayViewCommand method execute.
/**
* {@inheritDoc}
*/
@Override
public void execute(final ButtonEvent event, final int velocity) {
if (event != ButtonEvent.DOWN)
return;
final ModeManager modeManager = this.surface.getModeManager();
final ViewManager viewManager = this.surface.getViewManager();
if (Views.isSessionView(viewManager.getActiveID())) {
final ITrack cursorTrack = this.model.getCursorTrack();
if (!cursorTrack.doesExist()) {
this.surface.getDisplay().notify("Please select a track first.");
return;
}
final Views preferredView = viewManager.getPreferredView(cursorTrack.getPosition());
viewManager.setActive(preferredView == null ? Views.PLAY : preferredView);
if (modeManager.isActive(Modes.SESSION) || modeManager.isTemporary())
modeManager.restore();
return;
}
if (modeManager.isActive(Modes.VIEW_SELECT))
modeManager.restore();
else
modeManager.setTemporary(Modes.VIEW_SELECT);
}
use of de.mossgrabers.framework.featuregroup.ModeManager in project DrivenByMoss by git-moss.
the class PushQuantizeCommand method execute.
/**
* {@inheritDoc}
*/
@Override
public void execute(final ButtonEvent event, final int velocity) {
final ModeManager modeManager = this.surface.getModeManager();
if (event == ButtonEvent.LONG || event == ButtonEvent.DOWN && this.surface.isShiftPressed()) {
modeManager.setTemporary(Modes.REC_ARM);
this.surface.setTriggerConsumed(ButtonID.QUANTIZE);
return;
}
if (event != ButtonEvent.UP)
return;
if (Modes.REC_ARM.equals(modeManager.getActiveID()))
modeManager.restore();
else
this.quantize();
}
Aggregations