use of de.mossgrabers.framework.controller.color.ColorEx in project DrivenByMoss by git-moss.
the class HwSurfaceFactoryImpl method createLight.
/**
* {@inheritDoc}
*/
@Override
public IHwLight createLight(final int surfaceID, final OutputID outputID, final Supplier<ColorEx> supplier, final Consumer<ColorEx> sendValueConsumer) {
this.lightCounter++;
final String id = createID(surfaceID, outputID == null ? "LIGHT" + this.lightCounter : outputID.name());
final MultiStateHardwareLight hardwareLight = this.hardwareSurface.createMultiStateHardwareLight(id);
final Supplier<InternalHardwareLightState> valueSupplier = () -> new RawColorLightState(supplier.get());
final Consumer<InternalHardwareLightState> hardwareUpdater = state -> {
final HardwareLightVisualState visualState = state == null ? null : state.getVisualState();
final Color c = visualState == null ? Color.blackColor() : visualState.getColor();
sendValueConsumer.accept(new ColorEx(c.getRed(), c.getGreen(), c.getBlue()));
};
return new HwLightImpl(this.host, hardwareLight, valueSupplier, hardwareUpdater);
}
use of de.mossgrabers.framework.controller.color.ColorEx in project DrivenByMoss by git-moss.
the class RawColorLightState method getVisualState.
/**
* {@inheritDoc}}
*/
@Override
public HardwareLightVisualState getVisualState() {
final Color color = Color.fromRGB(this.colorState.getRed(), this.colorState.getGreen(), this.colorState.getBlue());
final ColorEx contrastColorEx = ColorEx.calcContrastColor(this.colorState);
final Color contrastColor = Color.fromRGB(contrastColorEx.getRed(), contrastColorEx.getGreen(), contrastColorEx.getBlue());
return HardwareLightVisualState.createForColor(color, contrastColor);
}
use of de.mossgrabers.framework.controller.color.ColorEx 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.controller.color.ColorEx in project DrivenByMoss by git-moss.
the class AbstractDrumLaneView method drawGrid.
/**
* {@inheritDoc}
*/
@Override
public void drawGrid() {
final IPadGrid padGrid = this.surface.getPadGrid();
if (!this.isActive()) {
padGrid.turnOff();
return;
}
// Clip length/loop area
final INoteClip clip = this.getClip();
final int step = clip.getCurrentStep();
// Paint the sequencer steps
final int hiStep = this.isInXRange(step) ? step % this.clipCols : -1;
final int offsetY = this.scales.getDrumOffset();
final int editMidiChannel = this.configuration.getMidiEditChannel();
final List<GridStep> editNotes = this.getEditNotes();
for (int sound = 0; sound < this.lanes; sound++) {
final int noteRow = offsetY + sound;
final Optional<ColorEx> drumPadColor = this.getPadColor(this.primary, sound);
for (int col = 0; col < this.clipCols; col++) {
final IStepInfo stepInfo = clip.getStep(editMidiChannel, col, noteRow);
final boolean hilite = col == hiStep;
final int x = col % this.numColumns;
int y = this.lanes - 1 - sound;
if (col >= this.numColumns)
y += this.lanes;
padGrid.lightEx(x, y, this.getStepColor(stepInfo, hilite, drumPadColor, editMidiChannel, col, noteRow, editNotes));
}
}
}
use of de.mossgrabers.framework.controller.color.ColorEx 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;
}
}
Aggregations