use of de.mossgrabers.framework.controller.color.ColorEx in project DrivenByMoss by git-moss.
the class DeviceLayerMode method updateDisplayElements.
/**
* Update all 8 elements.
*
* @param display The display
* @param l The channel data
*/
protected void updateDisplayElements(final IGraphicDisplay display, final Optional<ILayer> l) {
// Drum Pad Bank has size of 16, layers only 8
final int offset = this.getDrumPadIndex();
// Get the index at which to draw the Sends element
int sendsIndex = l.isEmpty() ? -1 : l.get().getIndex() - offset + 1;
if (sendsIndex == 8)
sendsIndex = 6;
this.updateMenuItems(-1);
final PushConfiguration config = this.surface.getConfiguration();
for (int i = 0; i < 8; i++) {
final IChannel layer = this.bank.getItem(offset + i);
final Pair<String, Boolean> pair = this.menu.get(i);
final String topMenu = pair.getKey();
final boolean isTopMenuOn = pair.getValue().booleanValue();
// Channel info
final String bottomMenu = layer.doesExist() ? layer.getName(12) : "";
final ColorEx bottomMenuColor = layer.getColor();
final boolean isBottomMenuOn = layer.isSelected();
if (layer.isSelected()) {
final IValueChanger valueChanger = this.model.getValueChanger();
final boolean enableVUMeters = config.isEnableVUMeters();
final int vuR = valueChanger.toDisplayValue(enableVUMeters ? layer.getVuRight() : 0);
final int vuL = valueChanger.toDisplayValue(enableVUMeters ? layer.getVuLeft() : 0);
display.addChannelElement(topMenu, isTopMenuOn, bottomMenu, ChannelType.LAYER, bottomMenuColor, isBottomMenuOn, valueChanger.toDisplayValue(layer.getVolume()), valueChanger.toDisplayValue(layer.getModulatedVolume()), this.isKnobTouched[0] ? layer.getVolumeStr(8) : "", valueChanger.toDisplayValue(layer.getPan()), valueChanger.toDisplayValue(layer.getModulatedPan()), this.isKnobTouched[1] ? layer.getPanStr(8) : "", vuL, vuR, layer.isMute(), layer.isSolo(), false, layer.isActivated(), 0, false);
} else if (sendsIndex == i && l.isPresent()) {
final ITrackBank fxTrackBank = this.model.getEffectTrackBank();
final SendData[] sendData = new SendData[4];
for (int j = 0; j < 4; j++) {
final int sendOffset = config.isSendsAreToggled() ? 4 : 0;
final int sendPos = sendOffset + j;
final ISend send = l.get().getSendBank().getItem(sendPos);
final boolean doesExist = send.doesExist();
sendData[j] = new SendData(fxTrackBank == null ? send.getName() : fxTrackBank.getItem(sendPos).getName(), doesExist && this.isKnobTouched[4 + j] ? send.getDisplayedValue() : "", doesExist ? send.getValue() : 0, doesExist ? send.getModulatedValue() : 0, true);
}
display.addSendsElement(topMenu, isTopMenuOn, layer.doesExist() ? layer.getName() : "", ChannelType.LAYER, this.bank.getItem(offset + i).getColor(), layer.isSelected(), sendData, true, l.get().isActivated(), layer.isActivated());
} else
display.addChannelSelectorElement(topMenu, isTopMenuOn, bottomMenu, ChannelType.LAYER, bottomMenuColor, isBottomMenuOn, layer.isActivated());
}
}
use of de.mossgrabers.framework.controller.color.ColorEx in project DrivenByMoss by git-moss.
the class DeviceBrowserMode method updateDisplay2.
/**
* {@inheritDoc}
*/
@Override
public void updateDisplay2(final IGraphicDisplay display) {
final IBrowser browser = this.model.getBrowser();
if (!browser.isActive())
return;
switch(this.selectionMode) {
case DeviceBrowserMode.SELECTION_OFF:
String selectedResult = browser.getSelectedResult();
selectedResult = selectedResult == null || selectedResult.isBlank() ? "Selection: None" : "Selection: " + selectedResult;
for (int i = 0; i < 7; i++) {
final Optional<IBrowserColumn> column = this.getFilterColumn(i);
final String headerTopName = i == 0 ? browser.getInfoText() : "";
final String headerBottomName = i == 0 ? selectedResult : "";
final String menuBottomName = getColumnName(column);
display.addOptionElement(headerTopName, column.isEmpty() ? "" : column.get().getName(), i == this.filterColumn, headerBottomName, menuBottomName, !menuBottomName.equals(" "), false);
}
final boolean supportsPreview = this.model.getHost().supports(Capability.HAS_BROWSER_PREVIEW);
final String bottomMenu = supportsPreview ? "Preview" : "";
final ColorEx menuBottomColor = browser.isPreviewEnabled() ? ColorEx.ORANGE : ColorEx.GRAY;
display.addOptionElement("", browser.getSelectedContentType(), this.filterColumn == -1, null, "", bottomMenu, false, supportsPreview ? menuBottomColor : null, false);
break;
case DeviceBrowserMode.SELECTION_PRESET:
final IBrowserColumnItem[] results = browser.getResultColumnItems();
if (!results[0].doesExist()) {
for (int i = 0; i < 8; i++) display.addOptionElement(i == 3 ? "No results available..." : "", "", false, "", "", false, false);
return;
}
for (int i = 0; i < 8; i++) {
final String[] items = new String[6];
final boolean[] selected = new boolean[6];
for (int item = 0; item < 6; item++) {
final int pos = i * 6 + item;
items[item] = pos < results.length ? results[pos].getName(14) : "";
selected[item] = pos < results.length && results[pos].isSelected();
}
display.addListElement(items, selected);
}
break;
case DeviceBrowserMode.SELECTION_FILTER:
final IBrowserColumnItem[] item = browser.getFilterColumn(this.filterColumn).getItems();
for (int i = 0; i < 8; i++) {
final String[] items = new String[6];
final boolean[] selected = new boolean[6];
for (int itemIndex = 0; itemIndex < 6; itemIndex++) {
final int pos = i * 6 + itemIndex;
final String hitText = " (" + item[pos].getHitCount() + ")";
String text = item[pos].getName(12 - hitText.length());
if (!text.isEmpty())
text = text + hitText;
items[itemIndex] = text;
selected[itemIndex] = item[pos].isSelected();
}
display.addListElement(items, selected);
}
break;
default:
// Not used
break;
}
}
use of de.mossgrabers.framework.controller.color.ColorEx in project DrivenByMoss by git-moss.
the class Kontrol1LightGuide method sendNoteState.
/**
* {@inheritDoc}
*/
@Override
protected void sendNoteState(final int channel, final int note, final int color) {
if (note < 0 || note >= 88)
return;
final ColorEx colorEx = this.colorManager.getColor(color, null);
final int[] rgb = colorEx.toIntRGB127();
// After previous translation to controller, note is only the index into the 0..N LEDs
this.usbDevice.setKeyLED(note, rgb[0], rgb[1], rgb[2]);
}
use of de.mossgrabers.framework.controller.color.ColorEx in project DrivenByMoss by git-moss.
the class SLMkIIIControllerSetup method registerTriggerCommands.
/**
* {@inheritDoc}
*/
@Override
protected void registerTriggerCommands() {
final SLMkIIIControlSurface surface = this.getSurface();
final ModeManager modeManager = surface.getModeManager();
final ViewManager viewManager = surface.getViewManager();
final ITransport t = this.model.getTransport();
final ITrackBank tb = this.model.getTrackBank();
final WindCommand<SLMkIIIControlSurface, SLMkIIIConfiguration> rewindCommand = new WindCommand<>(this.model, surface, false);
final WindCommand<SLMkIIIControlSurface, SLMkIIIConfiguration> forwardCommand = new WindCommand<>(this.model, surface, true);
this.addButton(ButtonID.REWIND, "<<", rewindCommand, 15, SLMkIIIControlSurface.MKIII_TRANSPORT_REWIND, () -> rewindCommand.isRewinding() ? 1 : 0, SLMkIIIColorManager.BUTTON_STATE_WIND_ON, SLMkIIIColorManager.BUTTON_STATE_WIND_HI);
this.addButton(ButtonID.FORWARD, ">>", forwardCommand, 15, SLMkIIIControlSurface.MKIII_TRANSPORT_FORWARD, () -> forwardCommand.isForwarding() ? 1 : 0, SLMkIIIColorManager.BUTTON_STATE_WIND_ON, SLMkIIIColorManager.BUTTON_STATE_WIND_HI);
this.addButton(ButtonID.LOOP, "Loop", new SLMkIIIToggleLoopCommand(this.model, surface), 15, SLMkIIIControlSurface.MKIII_TRANSPORT_LOOP, () -> t.isLoop() ? 1 : 0, SLMkIIIColorManager.BUTTON_STATE_LOOP_ON, SLMkIIIColorManager.BUTTON_STATE_LOOP_HI);
this.addButton(ButtonID.STOP, "Stop", new StopCommand<>(this.model, surface), 15, SLMkIIIControlSurface.MKIII_TRANSPORT_STOP, () -> !t.isPlaying() ? 1 : 0, SLMkIIIColorManager.BUTTON_STATE_STOP_ON, SLMkIIIColorManager.BUTTON_STATE_STOP_HI);
this.addButton(ButtonID.PLAY, "Play", new SLMkIIIPlayCommand(this.model, surface), 15, SLMkIIIControlSurface.MKIII_TRANSPORT_PLAY, () -> t.isPlaying() ? 1 : 0, SLMkIIIColorManager.BUTTON_STATE_PLAY_ON, SLMkIIIColorManager.BUTTON_STATE_PLAY_HI);
this.addButton(ButtonID.RECORD, "Record", new RecordCommand<>(this.model, surface), 15, SLMkIIIControlSurface.MKIII_TRANSPORT_RECORD, () -> {
final boolean isOn = this.isRecordShifted(surface) ? t.isLauncherOverdub() : t.isRecording();
return isOn ? 1 : 0;
}, SLMkIIIColorManager.BUTTON_STATE_REC_ON, SLMkIIIColorManager.BUTTON_STATE_REC_HI, SLMkIIIColorManager.BUTTON_STATE_OVR_ON, SLMkIIIColorManager.BUTTON_STATE_OVR_HI);
for (int i = 0; i < 8; i++) {
final int index = i;
final ButtonID buttonID = ButtonID.get(ButtonID.ROW1_1, i);
this.addButton(buttonID, "Select " + (i + 1), new ButtonRowModeCommand<>(0, i, this.model, surface), 15, SLMkIIIControlSurface.MKIII_DISPLAY_BUTTON_1 + i, new FeatureGroupButtonColorSupplier(modeManager, buttonID));
this.addButton(ButtonID.get(ButtonID.ROW2_1, i), "Mute/Monitor " + (i + 1), new ButtonAreaCommand(0, i, this.model, surface), 15, SLMkIIIControlSurface.MKIII_BUTTON_ROW1_1 + i, () -> {
final ITrack track = tb.getItem(index);
if (!track.doesExist())
return SLMkIIIColorManager.SLMKIII_BLACK;
if (surface.isMuteSolo())
return track.isMute() ? SLMkIIIColorManager.SLMKIII_ORANGE : SLMkIIIColorManager.SLMKIII_ORANGE_HALF;
return track.isMonitor() ? SLMkIIIColorManager.SLMKIII_GREEN : SLMkIIIColorManager.SLMKIII_GREEN_HALF;
});
this.addButton(ButtonID.get(ButtonID.ROW3_1, i), "Solo/Arm" + (i + 1), new ButtonAreaCommand(1, i, this.model, surface), 15, SLMkIIIControlSurface.MKIII_BUTTON_ROW2_1 + i, () -> {
final ITrack track = tb.getItem(index);
if (!track.doesExist())
return SLMkIIIColorManager.SLMKIII_BLACK;
if (surface.isMuteSolo())
return track.isSolo() ? SLMkIIIColorManager.SLMKIII_YELLOW : SLMkIIIColorManager.SLMKIII_YELLOW_HALF;
return track.isRecArm() ? SLMkIIIColorManager.SLMKIII_RED : SLMkIIIColorManager.SLMKIII_RED_HALF;
});
}
this.addButton(ButtonID.ARROW_UP, "Up", new DeviceModeCommand(this.model, surface), 15, SLMkIIIControlSurface.MKIII_DISPLAY_UP, () -> getDeviceModeColor(modeManager));
this.addButton(ButtonID.ARROW_DOWN, "Down", new TrackModeCommand(this.model, surface), 15, SLMkIIIControlSurface.MKIII_DISPLAY_DOWN, () -> getTrackModeColor(modeManager));
this.addButton(ButtonID.SHIFT, "Shift", new ShiftCommand<>(this.model, surface), 15, SLMkIIIControlSurface.MKIII_SHIFT);
this.addButton(ButtonID.USER, "Options", new ModeSelectCommand<>(this.model, surface, Modes.FUNCTIONS, true), 15, SLMkIIIControlSurface.MKIII_OPTIONS, () -> modeManager.isActive(Modes.FUNCTIONS) ? SLMkIIIColorManager.SLMKIII_DARK_BROWN : SLMkIIIColorManager.SLMKIII_DARK_GREY);
this.addButton(ButtonID.OCTAVE_UP, "Up", (event, value) -> {
if (event == ButtonEvent.UP)
surface.toggleMuteSolo();
}, 15, SLMkIIIControlSurface.MKIII_BUTTONS_UP, () -> surface.isMuteSolo() ? SLMkIIIColorManager.SLMKIII_ORANGE : SLMkIIIColorManager.SLMKIII_ORANGE_HALF);
this.addButton(ButtonID.OCTAVE_DOWN, "Down", (event, value) -> {
if (event == ButtonEvent.UP)
surface.toggleMuteSolo();
}, 15, SLMkIIIControlSurface.MKIII_BUTTONS_DOWN, () -> !surface.isMuteSolo() ? SLMkIIIColorManager.SLMKIII_RED : SLMkIIIColorManager.SLMKIII_RED_HALF);
final ModeCursorCommand<SLMkIIIControlSurface, SLMkIIIConfiguration> cursorLeftCommand = new ModeCursorCommand<>(Direction.LEFT, this.model, surface, true);
this.addButton(ButtonID.ARROW_LEFT, "Left", cursorLeftCommand, 15, SLMkIIIControlSurface.MKIII_TRACK_LEFT, () -> getCursorColor(modeManager, cursorLeftCommand));
final ModeCursorCommand<SLMkIIIControlSurface, SLMkIIIConfiguration> cursorRightCommand = new ModeCursorCommand<>(Direction.RIGHT, this.model, surface, true);
this.addButton(ButtonID.ARROW_RIGHT, "Right", cursorRightCommand, 15, SLMkIIIControlSurface.MKIII_TRACK_RIGHT, () -> getCursorColor(modeManager, cursorRightCommand));
for (int i = 0; i < 2; i++) {
final ButtonID sceneButtonID = ButtonID.get(ButtonID.SCENE1, i);
this.addButton(sceneButtonID, "Scene " + (i + 1), new ViewButtonCommand<>(sceneButtonID, surface), 15, SLMkIIIControlSurface.MKIII_SCENE_1 + i, new FeatureGroupButtonColorSupplier(viewManager, sceneButtonID));
}
this.addButton(ButtonID.SCENE7, "Scene Up", (event, value) -> {
if (event != ButtonEvent.DOWN)
return;
if (viewManager.isActive(Views.SESSION))
this.model.getSceneBank().scrollBackwards();
else if (viewManager.isActive(Views.DRUM)) {
final DrumView drumView = (DrumView) viewManager.get(Views.DRUM);
if (drumView.isPlayMode())
drumView.onOctaveUp(ButtonEvent.DOWN);
else
drumView.onLeft(ButtonEvent.DOWN);
} else if (viewManager.isActive(Views.COLOR))
((ColorView<?, ?>) viewManager.get(Views.COLOR)).setPage(0);
}, 15, SLMkIIIControlSurface.MKIII_SCENE_UP, this::getSceneUpColor);
this.addButton(ButtonID.SCENE8, "Scene Down", (event, value) -> {
if (event != ButtonEvent.DOWN)
return;
if (viewManager.isActive(Views.SESSION))
this.model.getSceneBank().scrollForwards();
else if (viewManager.isActive(Views.DRUM)) {
final DrumView drumView = (DrumView) viewManager.get(Views.DRUM);
if (drumView.isPlayMode())
drumView.onOctaveDown(ButtonEvent.DOWN);
else
drumView.onRight(ButtonEvent.DOWN);
} else if (viewManager.isActive(Views.COLOR))
((ColorView<?, ?>) viewManager.get(Views.COLOR)).setPage(1);
}, 15, SLMkIIIControlSurface.MKIII_SCENE_DOWN, this::getSceneDownColor);
this.addButton(ButtonID.SESSION, "Grid", (event, value) -> {
if (event != ButtonEvent.DOWN)
return;
viewManager.setActive(viewManager.isActive(Views.SESSION) ? Views.DRUM : Views.SESSION);
this.getSurface().getDisplay().notify(viewManager.isActive(Views.SESSION) ? "Session" : "Sequencer");
}, 15, SLMkIIIControlSurface.MKIII_GRID, () -> viewManager.isActive(Views.SESSION) ? SLMkIIIColorManager.SLMKIII_GREEN : SLMkIIIColorManager.SLMKIII_BLUE);
this.addButton(ButtonID.DUPLICATE, "Duplicate", NopCommand.INSTANCE, 15, SLMkIIIControlSurface.MKIII_DUPLICATE, () -> surface.isPressed(ButtonID.DUPLICATE) ? SLMkIIIColorManager.SLMKIII_AMBER : SLMkIIIColorManager.SLMKIII_AMBER_HALF);
final SLMkIIIDisplay display = surface.getDisplay();
for (int i = 0; i < 8; i++) {
final int index = i;
surface.createLight(OutputID.get(OutputID.LED1, i), () -> {
final ITrack track = tb.getItem(index);
return track.getColor().dim(this.valueChanger.toNormalizedValue(track.getVolume()));
}, color -> display.setFaderLEDColor(SLMkIIIControlSurface.MKIII_FADER_LED_1 + index, color));
surface.createLight(OutputID.get(OutputID.LED_RING1, i), () -> {
// Note: On mode change the color does not change if the value is the same,
// let's ignore that since it is only visible in the simulation GUI
final IMode mode = modeManager.getActive();
if (mode == null)
return 0;
final int value = Math.max(0, mode.getKnobValue(index));
return this.valueChanger.toMidiValue(value);
}, color -> surface.setTrigger(SLMkIIIControlSurface.MKIII_KNOB_1 + index, color), state -> {
// On the device, the send value is displayed on the display as a knob
// On the simulation GUI represent it as a dimmed color of the mode
final BaseMode<?> mode = (BaseMode<?>) modeManager.getActive();
if (mode == null)
return ColorEx.BLACK;
final ColorEx c = this.colorManager.getColor(mode.getModeColor(), null);
return c.dim(this.valueChanger.toNormalizedValue(this.valueChanger.toDAWValue(state)));
}, null);
}
}
use of de.mossgrabers.framework.controller.color.ColorEx in project DrivenByMoss by git-moss.
the class DrumView method drawGrid.
/**
* {@inheritDoc}
*/
@Override
public void drawGrid() {
final IPadGrid padGrid = this.surface.getPadGrid();
final IDrumDevice primary = this.model.getDrumDevice();
if (this.isPlayMode) {
for (int y = 0; y < 2; y++) {
for (int x = 0; x < 8; x++) {
final int index = 8 * y + x;
padGrid.lightEx(x, 1 - y, this.getDrumPadColor(index, primary, false));
}
}
return;
}
if (!this.isActive()) {
padGrid.turnOff();
return;
}
// Paint the sequencer steps
final INoteClip clip = this.getClip();
final int step = clip.getCurrentStep();
final int hiStep = this.isInXRange(step) ? step % this.sequencerSteps : -1;
final int offsetY = this.scales.getDrumOffset();
final int editMidiChannel = this.configuration.getMidiEditChannel();
final int selPad = this.getSelectedPad();
final List<GridStep> editNotes = this.getEditNotes();
for (int col = 0; col < DrumView.NUM_DISPLAY_COLS; col++) {
final int noteRow = offsetY + selPad;
final IStepInfo stepInfo = clip.getStep(editMidiChannel, col, noteRow);
final boolean hilite = col == hiStep;
final int x = col % GRID_COLUMNS;
final int y = col / GRID_COLUMNS;
final Optional<ColorEx> rowColor = this.getPadColor(primary, this.selectedPad);
padGrid.lightEx(x, y, this.getStepColor(stepInfo, hilite, rowColor, editMidiChannel, col, noteRow, editNotes));
}
}
Aggregations