use of de.mossgrabers.framework.controller.color.ColorEx 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.controller.color.ColorEx 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.controller.color.ColorEx 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);
}
use of de.mossgrabers.framework.controller.color.ColorEx in project DrivenByMoss by git-moss.
the class LabelComponent method drawSeparateColorLayout.
/**
* Draws the label in the SEPARATE_COLOR layout.
*
* @param info All necessary information to draw the component
*/
protected void drawSeparateColorLayout(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 top = info.getBounds().top();
final double height = info.getBounds().height();
final double unit = dimensions.getUnit();
final double doubleUnit = dimensions.getDoubleUnit();
// Draw the background
final ColorEx bgColor = this.modifyIfOff(configuration.getColorBackground());
gc.fillRectangle(left, top + 1, width, height - unit - 1, this.isSelected() ? this.modifyIfOff(configuration.getColorBackgroundLighter()) : bgColor);
// The tracks icon and name
final String iconName = this.getIcon();
final int trackRowHeight = (int) (1.6 * unit);
final double textTop = top + height - trackRowHeight - unit;
if (iconName != null) {
final IImage image = ResourceHandler.getSVGImage(iconName);
final ColorEx maskColor = this.modifyIfOff(this.getMaskColor(configuration));
if (maskColor == null)
gc.drawImage(image, left + (doubleUnit - image.getWidth()) / 2, textTop + (trackRowHeight - image.getHeight()) / 2.0);
else
gc.maskImage(image, left + (doubleUnit - image.getWidth()) / 2, textTop + (trackRowHeight - image.getHeight()) / 2.0, maskColor);
}
gc.drawTextInBounds(this.text, left + doubleUnit, textTop, width - doubleUnit, trackRowHeight, Align.LEFT, this.modifyIfOff(configuration.getColorText()), 1.2 * unit);
// The track color section
final ColorEx infoColor = this.backgroundColor;
gc.fillRectangle(left, top + height - unit, width, unit, this.isActive ? infoColor : ColorEx.evenDarker(infoColor));
}
use of de.mossgrabers.framework.controller.color.ColorEx in project DrivenByMoss by git-moss.
the class SceneListGridElement 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.colors.length;
final double itemLeft = left + separatorSize;
final double itemWidth = width - separatorSize;
final double itemHeight = height / size;
final ColorEx textColor = configuration.getColorText();
final ColorEx borderColor = configuration.getColorBackgroundLighter();
for (int i = 0; i < size; i++) {
final double itemTop = i * itemHeight;
final ColorEx backgroundColor = this.colors[i];
gc.fillRectangle(itemLeft, itemTop + separatorSize, itemWidth, itemHeight - 2 * separatorSize, backgroundColor);
if (this.exists[i])
gc.drawTextInBounds(this.names[i], itemLeft + inset, itemTop - 1, itemWidth - 2 * inset, itemHeight, Align.LEFT, ColorEx.calcContrastColor(backgroundColor), itemHeight / 2);
gc.strokeRectangle(itemLeft, itemTop + separatorSize, itemWidth, itemHeight - 2 * separatorSize, this.isSelecteds[i] ? textColor : borderColor, this.isSelecteds[i] ? 2 : 1);
}
}
Aggregations