use of de.mossgrabers.framework.graphics.canvas.utils.SendData in project DrivenByMoss by git-moss.
the class SendsComponent method draw.
/**
* {@inheritDoc}
*/
@Override
public void draw(final IGraphicsInfo info) {
super.draw(info);
final String name = this.footer.getText();
// Element is off if the name is empty
if ((name == null || name.length() == 0) && !this.isExMode)
return;
final IGraphicsContext gc = info.getContext();
final IGraphicsDimensions dimensions = info.getDimensions();
final IGraphicsConfiguration configuration = info.getConfiguration();
final double left = info.getBounds().left();
final double width = info.getBounds().width();
final double height = info.getBounds().height();
final double separatorSize = dimensions.getSeparatorSize();
final double menuHeight = dimensions.getMenuHeight();
final double unit = dimensions.getUnit();
final double inset = dimensions.getInset();
final int trackRowHeight = (int) (1.6 * unit);
final double trackRowTop = height - trackRowHeight - unit - separatorSize;
final double sliderWidth = width - 2 * inset - 1;
final double t = menuHeight + 1;
final double h = trackRowTop - t;
final double sliderAreaHeight = h;
// 4 rows of Texts and 4 rows of faders
final double sendRowHeight = sliderAreaHeight / 8;
final double sliderHeight = sendRowHeight - 2 * separatorSize;
// Background of slider area
final ColorEx backgroundColor = this.modifyIfOff(configuration.getColorBackground());
gc.fillRectangle(this.isExMode ? left - separatorSize : left, t, this.isExMode ? width + separatorSize : width, this.isExMode ? h - 2 : h, this.footer.isSelected() || this.isExMode ? this.modifyIfOff(configuration.getColorBackgroundLighter()) : backgroundColor);
double topy = menuHeight + (this.isExMode ? 0 : separatorSize);
final ColorEx textColor = this.modifyIfOff(configuration.getColorText());
final ColorEx borderColor = this.modifyIfOff(configuration.getColorBorder());
final ColorEx faderColor = this.modifyIfOff(configuration.getColorFader());
final ColorEx editColor = this.modifyIfOff(configuration.getColorEdit());
final double faderLeft = left + inset;
for (final SendData element : this.sendData) {
final String n = element.name();
if (n.length() == 0)
break;
gc.drawTextInBounds(n, faderLeft, topy + separatorSize, sliderWidth, sendRowHeight, Align.LEFT, textColor, sendRowHeight);
topy += sendRowHeight;
gc.fillRectangle(faderLeft, topy + separatorSize, sliderWidth, sliderHeight, borderColor);
final double valueWidth = element.value() * sliderWidth / dimensions.getParameterUpperBound();
final int modulatedValue = element.modulatedValue();
final boolean isSendModulated = modulatedValue != -1;
final double modulatedValueWidth = isSendModulated ? (double) (modulatedValue * sliderWidth / dimensions.getParameterUpperBound()) : valueWidth;
final double faderTop = topy + separatorSize + 1;
gc.fillRectangle(faderLeft + 1, faderTop, modulatedValueWidth - 1, sliderHeight - 2, faderColor);
final String text = element.text();
if (element.edited()) {
final boolean isTouched = text != null && text.length() > 0;
final double w = isTouched ? 3 : 1;
gc.fillRectangle(Math.min(faderLeft + sliderWidth - w - 1, faderLeft + valueWidth + 1), faderTop, w, sliderHeight - 2, editColor);
}
topy += sendRowHeight;
}
// Draw volume text on top if set
final double boxWidth = sliderWidth / 2;
final double boxLeft = faderLeft + sliderWidth - boxWidth;
topy = menuHeight;
final ColorEx backgroundDarker = this.modifyIfOff(configuration.getColorBackgroundDarker());
for (final SendData element : this.sendData) {
topy += sendRowHeight;
final String text = element.text();
if (text.length() > 0) {
final double volumeTextTop = topy + sliderHeight + 1 + (this.isExMode ? 0 : separatorSize);
gc.fillRectangle(boxLeft, volumeTextTop, boxWidth, unit, backgroundDarker);
gc.strokeRectangle(boxLeft, volumeTextTop, boxWidth - 1, unit, borderColor);
gc.drawTextInBounds(text, boxLeft, volumeTextTop, boxWidth, unit, Align.CENTER, textColor, unit);
}
topy += sendRowHeight;
}
}
use of de.mossgrabers.framework.graphics.canvas.utils.SendData in project DrivenByMoss by git-moss.
the class SendMode method updateDisplay2.
/**
* {@inheritDoc}
*/
@SuppressWarnings("null")
@Override
public void updateDisplay2(final IGraphicDisplay display) {
this.updateTrackMenu(5 + this.sendIndex % 4);
final ITrackBank tb = this.model.getCurrentTrackBank();
final IValueChanger valueChanger = this.model.getValueChanger();
final int sendOffset = this.surface.getConfiguration().isSendsAreToggled() ? 4 : 0;
for (int i = 0; i < 8; i++) {
final ITrack t = tb.getItem(i);
final SendData[] sendData = new SendData[4];
for (int j = 0; j < 4; j++) {
final int sendPos = sendOffset + j;
final ISend send = t.getSendBank().getItem(sendPos);
final boolean exists = send != null && send.doesExist();
sendData[j] = new SendData(exists ? send.getName() : " ", exists && this.sendIndex == sendPos && this.isKnobTouched[i] ? send.getDisplayedValue(8) : "", valueChanger.toDisplayValue(exists ? send.getValue() : -1), valueChanger.toDisplayValue(exists ? send.getModulatedValue() : -1), this.sendIndex == sendPos);
}
final Pair<String, Boolean> pair = this.menu.get(i);
display.addSendsElement(pair.getKey(), pair.getValue().booleanValue(), t.doesExist() ? t.getName() : "", this.updateType(t), t.getColor(), t.isSelected(), sendData, false, t.isActivated(), t.isActivated());
}
}
use of de.mossgrabers.framework.graphics.canvas.utils.SendData in project DrivenByMoss by git-moss.
the class TrackMode method updateDisplay2.
/**
* {@inheritDoc}
*/
@Override
public void updateDisplay2(final IGraphicDisplay display) {
final ITrackBank tb = this.model.getCurrentTrackBank();
final Optional<ITrack> selectedTrack = tb.getSelectedItem();
// Get the index at which to draw the Sends element
final int selectedIndex = selectedTrack.isEmpty() ? -1 : selectedTrack.get().getIndex();
int sendsIndex = selectedTrack.isEmpty() || this.model.isEffectTrackBankActive() ? -1 : selectedTrack.get().getIndex() + 1;
if (sendsIndex == 8)
sendsIndex = 6;
this.updateMenuItems(0);
final ICursorTrack cursorTrack = this.model.getCursorTrack();
final PushConfiguration config = this.surface.getConfiguration();
for (int i = 0; i < 8; i++) {
final ITrack t = tb.getItem(i);
// The menu item
final Pair<String, Boolean> pair = this.menu.get(i);
final String topMenu = pair.getKey();
final boolean topMenuSelected = pair.getValue().booleanValue();
// Channel info
final String bottomMenu = t.doesExist() ? t.getName() : "";
final ColorEx bottomMenuColor = t.getColor();
final boolean isBottomMenuOn = t.isSelected();
final IValueChanger valueChanger = this.model.getValueChanger();
if (t.isSelected()) {
final int crossfadeMode = this.getCrossfadeModeAsNumber(t);
final boolean enableVUMeters = config.isEnableVUMeters();
final int vuR = valueChanger.toDisplayValue(enableVUMeters ? t.getVuRight() : 0);
final int vuL = valueChanger.toDisplayValue(enableVUMeters ? t.getVuLeft() : 0);
display.addChannelElement(topMenu, topMenuSelected, bottomMenu, this.updateType(t), bottomMenuColor, isBottomMenuOn, valueChanger.toDisplayValue(t.getVolume()), valueChanger.toDisplayValue(t.getModulatedVolume()), this.isKnobTouched[0] ? t.getVolumeStr(8) : "", valueChanger.toDisplayValue(t.getPan()), valueChanger.toDisplayValue(t.getModulatedPan()), this.isKnobTouched[1] ? t.getPanStr(8) : "", vuL, vuR, t.isMute(), t.isSolo(), t.isRecArm(), t.isActivated(), crossfadeMode, cursorTrack.isPinned());
} else if (sendsIndex == i) {
final ITrack selTrack = tb.getItem(selectedIndex);
final SendData[] sendData = new SendData[4];
for (int j = 0; j < 4; j++) {
if (selTrack != null) {
final int sendOffset = config.isSendsAreToggled() ? 4 : 0;
final int sendPos = sendOffset + j;
final ISend send = selTrack.getSendBank().getItem(sendPos);
if (send != null) {
final boolean exists = send.doesExist();
sendData[j] = new SendData(send.getName(), exists && this.isKnobTouched[4 + j] ? send.getDisplayedValue(8) : "", valueChanger.toDisplayValue(exists ? send.getValue() : 0), valueChanger.toDisplayValue(exists ? send.getModulatedValue() : 0), true);
continue;
}
}
sendData[j] = new SendData("", "", 0, 0, true);
}
display.addSendsElement(topMenu, topMenuSelected, bottomMenu, this.updateType(t), bottomMenuColor, isBottomMenuOn, sendData, true, selTrack == null || selTrack.isActivated(), t.isActivated());
} else
display.addChannelSelectorElement(topMenu, topMenuSelected, bottomMenu, this.updateType(t), bottomMenuColor, isBottomMenuOn, t.isActivated());
}
}
use of de.mossgrabers.framework.graphics.canvas.utils.SendData in project DrivenByMoss by git-moss.
the class DeviceLayerModeSend method updateDisplayElements.
/**
* {@inheritDoc}
*/
@Override
public void updateDisplayElements(final IGraphicDisplay display, final Optional<ILayer> l) {
this.updateMenuItems(5 + this.sendIndex % 4);
final PushConfiguration config = this.surface.getConfiguration();
// Drum Pad Bank has size of 16, layers only 8
final int offset = this.getDrumPadIndex();
final int sendOffset = config.isSendsAreToggled() ? 4 : 0;
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 SendData[] sendData = new SendData[4];
for (int j = 0; j < 4; j++) {
final int sendPos = sendOffset + j;
final ISend send = layer.getSendBank().getItem(sendPos);
final boolean exists = send.doesExist();
sendData[j] = new SendData(send.getName(), exists && this.sendIndex == sendPos && this.isKnobTouched[i] ? send.getDisplayedValue() : "", exists ? send.getValue() : 0, exists ? send.getModulatedValue() : 0, this.sendIndex == sendPos);
}
display.addSendsElement(topMenu, isTopMenuOn, layer.doesExist() ? layer.getName() : "", ChannelType.LAYER, this.bank.getItem(offset + i).getColor(), layer.isSelected(), sendData, false, layer.isActivated(), layer.isActivated());
}
}
use of de.mossgrabers.framework.graphics.canvas.utils.SendData 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());
}
}
Aggregations