use of de.mossgrabers.framework.graphics.IGraphicsConfiguration in project DrivenByMoss by git-moss.
the class OptionsComponent method draw.
/**
* {@inheritDoc}
*/
@Override
public void draw(final IGraphicsInfo info) {
final IGraphicsContext gc = info.getContext();
final IGraphicsDimensions dimensions = info.getDimensions();
final double menuHeight = 2 * dimensions.getMenuHeight();
final IGraphicsConfiguration configuration = info.getConfiguration();
this.header.draw(info.withBounds(0, menuHeight));
final IBounds bounds = info.getBounds();
final double left = bounds.left();
final double height = bounds.height();
this.footer.draw(info.withBounds(height - menuHeight, menuHeight));
final boolean hasTopHeader = this.headerTop != null && !this.headerTop.isEmpty();
final boolean hasBottomHeader = this.headerBottom != null && !this.headerBottom.isEmpty();
if (!hasTopHeader && !hasBottomHeader)
return;
final double headerHeight = (height - 2 * menuHeight) / 2;
final ColorEx textColor = configuration.getColorText();
if (hasTopHeader)
gc.drawTextInHeight(this.headerTop, left, menuHeight, headerHeight, textColor, headerHeight / 2.0);
if (hasBottomHeader) {
if (this.isBottomHeaderSelected)
gc.drawTextInHeight(this.headerBottom, left, menuHeight + headerHeight, headerHeight, ColorEx.calcContrastColor(textColor), textColor, headerHeight / 2.0);
else
gc.drawTextInHeight(this.headerBottom, left, menuHeight + headerHeight, headerHeight, textColor, headerHeight / 2.0);
}
}
use of de.mossgrabers.framework.graphics.IGraphicsConfiguration 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.IGraphicsConfiguration in project DrivenByMoss by git-moss.
the class TitleValueComponent method draw.
/**
* {@inheritDoc}
*/
@Override
public void draw(final IGraphicsInfo info) {
final IGraphicsContext gc = info.getContext();
final IGraphicsConfiguration configuration = info.getConfiguration();
final ColorEx colorText = configuration.getColorText();
final ColorEx colorFader = configuration.getColorFader();
gc.drawTextInHeight(this.label, 0, 0, ROW_HEIGHT, colorText, ROW_HEIGHT);
gc.drawTextInHeight(this.label2, 0, ROW_HEIGHT, ROW_HEIGHT, colorText, ROW_HEIGHT);
if (this.value >= 0) {
final int width = this.value * 128 / RESOLUTION;
gc.strokeRectangle(1, TOP, 127, ROW_HEIGHT, colorFader);
if (this.isPan) {
if (width == CENTER)
gc.fillRectangle(CENTER + 1.0, TOP, 1, ROW_HEIGHT, colorFader);
else if (width > CENTER)
gc.fillRectangle(CENTER + 1.0, TOP, width - (double) CENTER, ROW_HEIGHT, colorFader);
else
gc.fillRectangle(width, TOP, CENTER - (double) width, ROW_HEIGHT, colorFader);
} else
gc.fillRectangle(1, TOP, width, ROW_HEIGHT, colorFader);
}
if (this.vuLeft > 0 || this.vuRight > 0) {
final double height = 2.0 * ROW_HEIGHT;
final double heightLeft = this.vuLeft * height / RESOLUTION;
final double topLeft = Math.max(height - heightLeft - 1, 0);
gc.strokeRectangle(118, topLeft, 5, heightLeft, ColorEx.BLACK);
gc.fillRectangle(119, height - heightLeft, 3, heightLeft, colorFader);
final double heightRight = this.vuRight * height / RESOLUTION;
final double topRight = Math.max(height - heightRight - 1, 0);
gc.strokeRectangle(123, topRight, 4, height - topRight, ColorEx.BLACK);
gc.fillRectangle(124, height - heightRight, 3, heightRight, colorFader);
}
}
use of de.mossgrabers.framework.graphics.IGraphicsConfiguration in project DrivenByMoss by git-moss.
the class TitleChannelsComponent method draw.
/**
* {@inheritDoc}
*/
@Override
public void draw(final IGraphicsInfo info) {
final IGraphicsContext gc = info.getContext();
final IGraphicsConfiguration configuration = info.getConfiguration();
final ColorEx colorText = configuration.getColorText();
final ColorEx colorFader = configuration.getColorFader();
gc.drawTextInHeight(this.label, 0, 0, ROW_HEIGHT, colorText, ROW_HEIGHT);
final int channelWidth = WIDTH / this.values.length;
final int halfChannelWidth = channelWidth / 2;
final int lowerHeight = HEIGHT - ROW_HEIGHT - 1;
for (int i = 0; i < this.values.length; i++) {
final int left = i * channelWidth;
final int faderHeight = this.values[i] * lowerHeight / RESOLUTION;
if (this.isPan) {
final int center = lowerHeight / 2;
if (this.selected[i]) {
if (faderHeight == center)
gc.fillRectangle(left, HEIGHT - center + 1.0, halfChannelWidth + 1.0, 1, colorFader);
else if (faderHeight > center)
gc.fillRectangle(left, HEIGHT - (double) center, halfChannelWidth + 1.0, faderHeight - (double) center, colorFader);
else
gc.fillRectangle(left, HEIGHT - lowerHeight + (double) faderHeight, halfChannelWidth + 1.0, center - faderHeight + 2.0, colorFader);
} else {
if (faderHeight == center)
gc.strokeRectangle(left + 1.0, HEIGHT - center + 1.0, halfChannelWidth, 1, colorFader);
else if (faderHeight > center)
gc.strokeRectangle(left + 1.0, HEIGHT - (double) center, halfChannelWidth, faderHeight - (double) center, colorFader);
else
gc.strokeRectangle(left + 1.0, HEIGHT - lowerHeight + (double) faderHeight, halfChannelWidth, center - faderHeight + 2.0, colorFader);
}
} else {
if (this.selected[i])
gc.fillRectangle(left, HEIGHT - (double) faderHeight, halfChannelWidth + 1.0, faderHeight, colorFader);
else
gc.strokeRectangle(left + 1.0, HEIGHT - (double) faderHeight, halfChannelWidth, faderHeight, colorFader);
}
}
}
use of de.mossgrabers.framework.graphics.IGraphicsConfiguration in project DrivenByMoss by git-moss.
the class ChannelComponent method draw.
/**
* {@inheritDoc}
*/
@Override
public void draw(final IGraphicsInfo info) {
super.draw(info);
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 halfWidth = width / 2;
final double separatorSize = dimensions.getSeparatorSize();
final double menuHeight = dimensions.getMenuHeight();
final double unit = dimensions.getUnit();
final double halfUnit = dimensions.getHalfUnit();
final double controlsTop = dimensions.getControlsTop();
final double inset = dimensions.getInset();
final int trackRowHeight = (int) (1.6 * unit);
final double trackRowTop = height - trackRowHeight - unit - separatorSize;
final double controlWidth = halfWidth - halfUnit - halfUnit / 2;
final double controlStart = left + halfWidth + halfUnit - halfUnit / 2;
final double panWidth = controlWidth - 2;
final double panStart = controlStart + 1;
final double panTop = controlsTop + 1.0;
final double panHeight = unit - separatorSize;
final double panTextTop = panTop + panHeight;
final double faderOffset = controlWidth / 4;
final double faderTop = panTop + panHeight + separatorSize + 1;
final double vuX = controlStart + separatorSize;
final double faderLeft = vuX + faderOffset;
final double faderHeight = trackRowTop - faderTop - inset + 1;
final double faderInnerHeight = faderHeight - 2 * separatorSize;
final double volumeTextWidth = 1.4 * controlWidth;
final double volumeTextLeft = faderLeft - volumeTextWidth - 2;
final double buttonHeight = (faderHeight - 4 * separatorSize) / 3;
//
// Drawing
//
final ColorEx textColor = this.modifyIfOff(configuration.getColorText());
final String name = this.footer.getText();
// Element is off if the name is empty
if (name == null || name.length() == 0)
return;
final ColorEx backgroundColor = this.modifyIfOff(configuration.getColorBackground());
// Draw the background
gc.fillRectangle(left, menuHeight + 1, width, trackRowTop - (menuHeight + 1), this.footer.isSelected() ? this.modifyIfOff(configuration.getColorBackgroundLighter()) : backgroundColor);
// Background of pan and slider area
final ColorEx borderColor = this.modifyIfOff(configuration.getColorBorder());
gc.fillRectangle(controlStart, controlsTop, halfWidth - unit + halfUnit / 2, unit, borderColor);
gc.fillRectangle(controlStart, faderTop, controlWidth, faderHeight, borderColor);
final ColorEx backgroundDarker = this.modifyIfOff(configuration.getColorBackgroundDarker());
final ColorEx editColor = this.modifyIfOff(configuration.getColorEdit());
// Crossfader A|B
final double leftColumn = left + inset - 1;
if (this.type != ChannelType.MASTER && this.type != ChannelType.LAYER && this.crossfadeMode != -1) {
final ColorEx selColor = this.editType == EDIT_TYPE_CROSSFADER || this.editType == EDIT_TYPE_ALL ? editColor : ColorEx.ORANGE;
final double crossOptWidth = controlWidth / 3.0;
this.drawButton(gc, leftColumn, controlsTop, crossOptWidth, panHeight + 2, backgroundColor, this.modifyIfOff(selColor), textColor, this.crossfadeMode == 0, "track/crossfade_a.svg", configuration, 0);
this.drawButton(gc, leftColumn + crossOptWidth, controlsTop, crossOptWidth, panHeight + 2, backgroundColor, this.modifyIfOff(selColor), textColor, this.crossfadeMode == 1, "track/crossfade_ab.svg", configuration, 0);
this.drawButton(gc, leftColumn + 2 * crossOptWidth, controlsTop, crossOptWidth, panHeight + 2, backgroundColor, this.modifyIfOff(selColor), textColor, this.crossfadeMode == 2, "track/crossfade_b.svg", configuration, 0);
}
// Panorama
gc.fillRectangle(panStart, panTop, panWidth, panHeight, backgroundDarker);
final double panRange = panWidth / 2;
final double panMiddle = panStart + panRange;
gc.drawLine(panMiddle, panTop, panMiddle, panTop + panHeight, borderColor);
final double maxValue = dimensions.getParameterUpperBound();
final double halfMax = maxValue / 2;
final boolean isPanTouched = this.panText.length() > 0;
// Panned to the left or right?
final boolean isRight = this.panValue > halfMax;
final boolean isModulatedRight = this.modulatedPanValue > halfMax;
final double v = isRight ? (this.panValue - halfMax) * panRange / halfMax : panRange - this.panValue * panRange / halfMax;
final boolean isPanModulated = this.modulatedPanValue != -1;
final double vMod;
if (isPanModulated) {
if (isModulatedRight)
vMod = (this.modulatedPanValue - halfMax) * panRange / halfMax;
else
vMod = panRange - this.modulatedPanValue * panRange / halfMax;
} else
vMod = v;
final ColorEx faderColor = this.modifyIfOff(configuration.getColorFader());
final boolean rightMod = isPanModulated ? isModulatedRight : isRight;
gc.fillRectangle(rightMod ? panMiddle + 1 : panMiddle - vMod, controlsTop + 1, vMod, panHeight, faderColor);
if (this.editType == EDIT_TYPE_PAN || this.editType == EDIT_TYPE_ALL) {
final double w = isPanTouched ? 3 : 1;
final double start = isRight ? Math.min(panMiddle + panRange - w, panMiddle + v) : Math.max(panMiddle - panRange, panMiddle - v);
gc.fillRectangle(start, controlsTop + 1, w, panHeight, editColor);
}
// Volume slider
// Ensure that maximum value is reached even if rounding errors happen
final double volumeWidth = controlWidth - 2 * separatorSize - faderOffset;
final double volumeHeight = this.volumeValue >= maxValue - 1 ? faderInnerHeight : faderInnerHeight * this.volumeValue / maxValue;
final boolean isVolumeModulated = this.modulatedVolumeValue != -1;
final double modulatedVolumeHeight;
if (isVolumeModulated) {
if (this.modulatedVolumeValue >= maxValue - 1)
modulatedVolumeHeight = faderInnerHeight;
else
modulatedVolumeHeight = faderInnerHeight * this.modulatedVolumeValue / maxValue;
} else
modulatedVolumeHeight = volumeHeight;
final double volumeTop = faderTop + separatorSize + faderInnerHeight - volumeHeight;
final double modulatedVolumeTop = isVolumeModulated ? faderTop + separatorSize + faderInnerHeight - modulatedVolumeHeight : volumeTop;
gc.fillRectangle(faderLeft, modulatedVolumeTop, volumeWidth, modulatedVolumeHeight, faderColor);
final boolean isVolumeTouched = this.volumeText.length() > 0;
if (this.editType == EDIT_TYPE_VOLUME || this.editType == EDIT_TYPE_ALL) {
final double h = isVolumeTouched ? 3 : 1;
gc.fillRectangle(faderLeft, Math.min(volumeTop + volumeHeight - h, volumeTop), volumeWidth, h, editColor);
}
// VU
final double vuHeightLeft = this.vuValueLeft >= maxValue - 1 ? faderInnerHeight : faderInnerHeight * this.vuValueLeft / maxValue;
final double vuHeightRight = this.vuValueRight >= maxValue - 1 ? faderInnerHeight : faderInnerHeight * this.vuValueRight / maxValue;
final double vuOffsetLeft = faderInnerHeight - vuHeightLeft;
final double vuOffsetRight = faderInnerHeight - vuHeightRight;
final double vuWidth = faderOffset - separatorSize;
gc.fillRectangle(vuX, faderTop + separatorSize, vuWidth + 1, faderInnerHeight, backgroundDarker);
ColorEx colorVu = this.modifyIfOff(configuration.getColorVu());
if (this.isMute)
colorVu = configuration.getColorMute();
gc.fillRectangle(vuX, faderTop + separatorSize + vuOffsetLeft, vuWidth / 2, vuHeightLeft, colorVu);
gc.fillRectangle(vuX + vuWidth / 2, faderTop + separatorSize + vuOffsetRight, vuWidth / 2, vuHeightRight, colorVu);
double buttonTop = faderTop;
if (this.type != ChannelType.LAYER) {
// Record Arm
this.drawButton(gc, leftColumn, buttonTop, controlWidth, buttonHeight - 1, backgroundColor, this.modifyIfOff(configuration.getColorRecord()), textColor, this.isArm, "channel/record_arm.svg", configuration);
}
// Solo
buttonTop += buttonHeight + 2 * separatorSize;
this.drawButton(gc, leftColumn, buttonTop, controlWidth, buttonHeight - 1, backgroundColor, this.modifyIfOff(configuration.getColorSolo()), textColor, this.isSolo, "channel/solo.svg", configuration);
// Mute
buttonTop += buttonHeight + 2 * separatorSize;
this.drawButton(gc, leftColumn, buttonTop, controlWidth, buttonHeight - 1, backgroundColor, this.modifyIfOff(configuration.getColorMute()), textColor, this.isMute, "channel/mute.svg", configuration);
// Draw panorama text on top if set
if (isPanTouched) {
gc.fillRectangle(controlStart, panTextTop, controlWidth, unit, backgroundDarker);
gc.strokeRectangle(controlStart, panTextTop, controlWidth, unit, borderColor);
gc.drawTextInBounds(this.panText, controlStart, panTextTop, controlWidth, unit, Align.CENTER, textColor, unit);
}
// Draw volume text on top if set
if (isVolumeTouched) {
final double volumeTextTop = this.volumeValue >= maxValue - 1 ? faderTop : Math.min(volumeTop - 1, faderTop + faderInnerHeight + separatorSize - unit + 1);
gc.fillRectangle(volumeTextLeft, volumeTextTop, volumeTextWidth, unit, backgroundDarker);
gc.strokeRectangle(volumeTextLeft, volumeTextTop, volumeTextWidth, unit, borderColor);
gc.drawTextInBounds(this.volumeText, volumeTextLeft, volumeTextTop, volumeTextWidth, unit, Align.CENTER, textColor, unit);
}
}
Aggregations