use of de.mossgrabers.framework.graphics.IGraphicsContext 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.IGraphicsContext 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.IGraphicsContext 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);
}
}
use of de.mossgrabers.framework.graphics.IGraphicsContext in project DrivenByMoss by git-moss.
the class ClipListComponent method draw.
/**
* {@inheritDoc}
*/
@Override
public void draw(final IGraphicsInfo 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 separatorSize = dimensions.getSeparatorSize();
final double inset = dimensions.getInset();
final int size = this.items.size();
final double itemLeft = left + separatorSize;
final double itemWidth = width - separatorSize;
final double itemHeight = height / size;
final double fontHeight = itemHeight > 30 ? itemHeight / 2 : itemHeight * 2 / 3;
final double boxLeft = itemLeft + inset;
final double boxWidth = fontHeight - 2 * separatorSize;
final double radius = boxWidth / 2;
final ColorEx textColor = configuration.getColorText();
final ColorEx borderColor = configuration.getColorBackgroundLighter();
for (int i = 0; i < size; i++) {
final Pair<ITrack, ISlot> pair = this.items.get(i);
final ISlot slot = pair.getValue();
final ITrack track = pair.getKey();
final double itemTop = i * itemHeight;
String name = slot.getName();
final double boxTop = itemTop + (itemHeight - fontHeight) / 2;
// Draw the background
final ColorEx clipBackgroundColor = slot.getColor();
if (track.isGroup()) {
if (name.isEmpty())
name = "Scene " + (slot.getPosition() + 1);
gc.fillRectangle(itemLeft, itemTop + separatorSize, itemWidth, itemHeight - 2 * separatorSize, ColorEx.darker(ColorEx.DARK_GRAY));
gc.fillRectangle(itemLeft + itemWidth - 2 * inset, itemTop + separatorSize, 2 * inset, itemHeight - 2 * separatorSize, clipBackgroundColor);
} else
gc.fillRectangle(itemLeft, itemTop + separatorSize, itemWidth, itemHeight - 2 * separatorSize, clipBackgroundColor);
if (slot.doesExist()) {
// Draw the play/record state indicator box
final boolean isPlaying = slot.isPlaying();
if (isPlaying || slot.isRecording() || slot.isPlayingQueued() || slot.isRecordingQueued())
gc.fillRectangle(boxLeft, boxTop, fontHeight, fontHeight, ColorEx.BLACK);
// Draw the play, record or stop symbol depending on the slots state
if (slot.hasContent()) {
if (slot.isRecording())
gc.fillCircle(boxLeft + separatorSize + radius, boxTop + separatorSize + radius, radius, ColorEx.RED);
else {
ColorEx fillColor = ColorEx.darker(clipBackgroundColor);
if (isPlaying)
fillColor = ColorEx.GREEN;
else if (slot.isPlayingQueued() || slot.isRecordingQueued())
fillColor = ColorEx.WHITE;
gc.fillTriangle(boxLeft + separatorSize, boxTop + separatorSize, boxLeft + separatorSize, boxTop + fontHeight - separatorSize, boxLeft + fontHeight - separatorSize, boxTop + fontHeight / 2, fillColor);
}
} else {
if (track.isRecArm())
gc.fillCircle(boxLeft + separatorSize + radius, boxTop + separatorSize + radius, radius, ColorEx.DARK_GRAY);
else
gc.fillRectangle(boxLeft + separatorSize, boxTop + separatorSize, boxWidth, boxWidth, ColorEx.DARK_GRAY);
}
// Draw the text
gc.drawTextInBounds(name, itemLeft + 2 * inset + fontHeight, itemTop - 1, itemWidth - 2 * inset, itemHeight, Align.LEFT, ColorEx.BLACK, fontHeight);
}
// Draw the border
ColorEx color = borderColor;
if (slot.isSelected())
color = textColor;
else if (track.isSelected())
color = ColorEx.darker(ColorEx.YELLOW);
gc.strokeRectangle(itemLeft, itemTop + separatorSize, itemWidth, itemHeight - 2 * separatorSize, color, slot.isSelected() ? 2 : 1);
}
}
use of de.mossgrabers.framework.graphics.IGraphicsContext in project DrivenByMoss by git-moss.
the class LabelComponent method draw.
/**
* {@inheritDoc}
*/
@Override
public void draw(final IGraphicsInfo info) {
if (this.layout == LabelLayout.SEPARATE_COLOR) {
this.drawSeparateColorLayout(info);
return;
}
final IGraphicsConfiguration configuration = info.getConfiguration();
final IBounds bounds = info.getBounds();
final IGraphicsDimensions dimensions = info.getDimensions();
final double separatorSize = dimensions.getSeparatorSize();
final double menuHeight = dimensions.getMenuHeight();
final ColorEx bgColor = this.getBackgroundColor(configuration);
final ColorEx textColor = ColorEx.calcContrastColor(bgColor);
if (this.text == null || this.text.length() == 0) {
if (this.layout == LabelLayout.SMALL_HEADER) {
// Remove the 2 pixels of the previous menus border line
info.getContext().fillRectangle(bounds.left() - separatorSize, menuHeight - 2, separatorSize, 1, configuration.getColorBorder());
}
return;
}
final double left = bounds.left();
final double top = bounds.top();
final double width = bounds.width();
final double height = bounds.height();
final IGraphicsContext gc = info.getContext();
if (this.layout == LabelLayout.SMALL_HEADER) {
gc.fillRectangle(left, top, width, menuHeight - 1.0, bgColor);
gc.fillRectangle(left, menuHeight - 2.0, width + separatorSize, 1, this.isSelected ? bgColor : textColor);
} else
gc.fillRectangle(left, top, width, height, bgColor);
final double unit = dimensions.getUnit();
if (this.layout == LabelLayout.SMALL_HEADER)
gc.drawTextInBounds(this.text, left, 1, width, unit + separatorSize, Align.CENTER, textColor, unit);
else
gc.drawTextInBounds(this.text, left, top, width, height, Align.CENTER, textColor, height / 2);
}
Aggregations