Search in sources :

Example 1 with ColorEx

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);
}
Also used : IHwTextDisplay(de.mossgrabers.framework.controller.hardware.IHwTextDisplay) IHwButton(de.mossgrabers.framework.controller.hardware.IHwButton) HostImpl(de.mossgrabers.bitwig.framework.daw.HostImpl) Color(com.bitwig.extension.api.Color) IntConsumer(java.util.function.IntConsumer) IHwSurfaceFactory(de.mossgrabers.framework.controller.hardware.IHwSurfaceFactory) HardwareLightVisualState(com.bitwig.extension.controller.api.HardwareLightVisualState) OutputID(de.mossgrabers.framework.controller.OutputID) Supplier(java.util.function.Supplier) IHwPianoKeyboard(de.mossgrabers.framework.controller.hardware.IHwPianoKeyboard) RelativeEncoding(de.mossgrabers.framework.controller.valuechanger.RelativeEncoding) ButtonID(de.mossgrabers.framework.controller.ButtonID) ColorEx(de.mossgrabers.framework.controller.color.ColorEx) IntSupplier(java.util.function.IntSupplier) IntFunction(java.util.function.IntFunction) BitmapImpl(de.mossgrabers.bitwig.framework.graphics.BitmapImpl) IHwLight(de.mossgrabers.framework.controller.hardware.IHwLight) OperatingSystem(de.mossgrabers.framework.utils.OperatingSystem) MultiStateHardwareLight(com.bitwig.extension.controller.api.MultiStateHardwareLight) HardwareButton(com.bitwig.extension.controller.api.HardwareButton) ContinuousID(de.mossgrabers.framework.controller.ContinuousID) IHwFader(de.mossgrabers.framework.controller.hardware.IHwFader) Consumer(java.util.function.Consumer) IBitmap(de.mossgrabers.framework.graphics.IBitmap) IHwAbsoluteKnob(de.mossgrabers.framework.controller.hardware.IHwAbsoluteKnob) IHwGraphicsDisplay(de.mossgrabers.framework.controller.hardware.IHwGraphicsDisplay) IHwRelativeKnob(de.mossgrabers.framework.controller.hardware.IHwRelativeKnob) HardwareSurface(com.bitwig.extension.controller.api.HardwareSurface) InternalHardwareLightState(com.bitwig.extension.controller.api.InternalHardwareLightState) MultiStateHardwareLight(com.bitwig.extension.controller.api.MultiStateHardwareLight) InternalHardwareLightState(com.bitwig.extension.controller.api.InternalHardwareLightState) Color(com.bitwig.extension.api.Color) ColorEx(de.mossgrabers.framework.controller.color.ColorEx) HardwareLightVisualState(com.bitwig.extension.controller.api.HardwareLightVisualState)

Example 2 with ColorEx

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);
}
Also used : Color(com.bitwig.extension.api.Color) ColorEx(de.mossgrabers.framework.controller.color.ColorEx)

Example 3 with ColorEx

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);
    }
}
Also used : IGraphicsContext(de.mossgrabers.framework.graphics.IGraphicsContext) IGraphicsConfiguration(de.mossgrabers.framework.graphics.IGraphicsConfiguration) IBounds(de.mossgrabers.framework.graphics.IBounds) ColorEx(de.mossgrabers.framework.controller.color.ColorEx) IGraphicsDimensions(de.mossgrabers.framework.graphics.IGraphicsDimensions)

Example 4 with ColorEx

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));
        }
    }
}
Also used : IPadGrid(de.mossgrabers.framework.controller.grid.IPadGrid) ColorEx(de.mossgrabers.framework.controller.color.ColorEx) GridStep(de.mossgrabers.framework.daw.data.GridStep) IStepInfo(de.mossgrabers.framework.daw.IStepInfo) INoteClip(de.mossgrabers.framework.daw.INoteClip)

Example 5 with ColorEx

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;
    }
}
Also used : IGraphicsContext(de.mossgrabers.framework.graphics.IGraphicsContext) IGraphicsConfiguration(de.mossgrabers.framework.graphics.IGraphicsConfiguration) ColorEx(de.mossgrabers.framework.controller.color.ColorEx) IGraphicsDimensions(de.mossgrabers.framework.graphics.IGraphicsDimensions) SendData(de.mossgrabers.framework.graphics.canvas.utils.SendData)

Aggregations

ColorEx (de.mossgrabers.framework.controller.color.ColorEx)35 IGraphicsConfiguration (de.mossgrabers.framework.graphics.IGraphicsConfiguration)12 IGraphicsContext (de.mossgrabers.framework.graphics.IGraphicsContext)12 IGraphicsDimensions (de.mossgrabers.framework.graphics.IGraphicsDimensions)9 IStepInfo (de.mossgrabers.framework.daw.IStepInfo)6 Color (com.bitwig.extension.api.Color)5 INoteClip (de.mossgrabers.framework.daw.INoteClip)5 GridStep (de.mossgrabers.framework.daw.data.GridStep)5 ITrack (de.mossgrabers.framework.daw.data.ITrack)5 IPadGrid (de.mossgrabers.framework.controller.grid.IPadGrid)4 IValueChanger (de.mossgrabers.framework.controller.valuechanger.IValueChanger)4 ITrackBank (de.mossgrabers.framework.daw.data.bank.ITrackBank)4 ButtonID (de.mossgrabers.framework.controller.ButtonID)3 IDrumDevice (de.mossgrabers.framework.daw.data.IDrumDevice)3 HardwareButton (com.bitwig.extension.controller.api.HardwareButton)2 HardwareLightVisualState (com.bitwig.extension.controller.api.HardwareLightVisualState)2 HardwareSurface (com.bitwig.extension.controller.api.HardwareSurface)2 InternalHardwareLightState (com.bitwig.extension.controller.api.InternalHardwareLightState)2 MultiStateHardwareLight (com.bitwig.extension.controller.api.MultiStateHardwareLight)2 HostImpl (de.mossgrabers.bitwig.framework.daw.HostImpl)2