Search in sources :

Example 1 with Color

use of com.bitwig.extension.api.Color in project DrivenByMoss by git-moss.

the class ColorSettingImpl method addValueObserver.

/**
 * {@inheritDoc}
 */
@Override
public void addValueObserver(final IValueObserver<ColorEx> observer) {
    this.colorValue.addValueObserver((red, green, blue) -> observer.update(new ColorEx(red, green, blue)));
    // Directly fire the current value
    final Color color = this.colorValue.get();
    observer.update(new ColorEx(color.getRed(), color.getGreen(), color.getBlue()));
}
Also used : ColorEx(de.mossgrabers.framework.controller.color.ColorEx) Color(com.bitwig.extension.api.Color)

Example 2 with Color

use of com.bitwig.extension.api.Color 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 3 with Color

use of com.bitwig.extension.api.Color 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 4 with Color

use of com.bitwig.extension.api.Color in project DrivenByMoss by git-moss.

the class EncodedColorLightState method getVisualState.

/**
 * {@inheritDoc}}
 */
@Override
public HardwareLightVisualState getVisualState() {
    if (this.encodedColorState == -1)
        return HardwareLightVisualState.createForColor(Color.blackColor(), Color.whiteColor());
    final int colorIndex = this.encodedColorState & 0xFF;
    final int blinkColorIndex = this.encodedColorState >> 8 & 0xFF;
    final boolean blinkFast = (this.encodedColorState >> 16 & 1) > 0;
    final ColorEx colorEx = this.stateToColorFunction.apply(colorIndex);
    final Color color = Color.fromRGB(colorEx.getRed(), colorEx.getGreen(), colorEx.getBlue());
    final ColorEx contrastColorEx = ColorEx.calcContrastColor(colorEx);
    final Color contrastColor = Color.fromRGB(contrastColorEx.getRed(), contrastColorEx.getGreen(), contrastColorEx.getBlue());
    if (blinkColorIndex <= 0 || blinkColorIndex >= 128)
        return HardwareLightVisualState.createForColor(color, contrastColor);
    final ColorEx blinkColorEx = this.stateToColorFunction.apply(blinkColorIndex);
    final Color blinkColor = Color.fromRGB(blinkColorEx.getRed(), blinkColorEx.getGreen(), blinkColorEx.getBlue());
    final ColorEx contrastBlinkColorEx = ColorEx.calcContrastColor(blinkColorEx);
    final Color contrastBlinkColor = Color.fromRGB(contrastBlinkColorEx.getRed(), contrastBlinkColorEx.getGreen(), contrastBlinkColorEx.getBlue());
    final double blinkTimeInSec = blinkFast ? 0.5 : 1;
    return HardwareLightVisualState.createBlinking(blinkColor, color, contrastBlinkColor, contrastColor, blinkTimeInSec, blinkTimeInSec);
}
Also used : ColorEx(de.mossgrabers.framework.controller.color.ColorEx) Color(com.bitwig.extension.api.Color)

Aggregations

Color (com.bitwig.extension.api.Color)4 ColorEx (de.mossgrabers.framework.controller.color.ColorEx)4 HardwareButton (com.bitwig.extension.controller.api.HardwareButton)1 HardwareLightVisualState (com.bitwig.extension.controller.api.HardwareLightVisualState)1 HardwareSurface (com.bitwig.extension.controller.api.HardwareSurface)1 InternalHardwareLightState (com.bitwig.extension.controller.api.InternalHardwareLightState)1 MultiStateHardwareLight (com.bitwig.extension.controller.api.MultiStateHardwareLight)1 HostImpl (de.mossgrabers.bitwig.framework.daw.HostImpl)1 BitmapImpl (de.mossgrabers.bitwig.framework.graphics.BitmapImpl)1 ButtonID (de.mossgrabers.framework.controller.ButtonID)1 ContinuousID (de.mossgrabers.framework.controller.ContinuousID)1 OutputID (de.mossgrabers.framework.controller.OutputID)1 IHwAbsoluteKnob (de.mossgrabers.framework.controller.hardware.IHwAbsoluteKnob)1 IHwButton (de.mossgrabers.framework.controller.hardware.IHwButton)1 IHwFader (de.mossgrabers.framework.controller.hardware.IHwFader)1 IHwGraphicsDisplay (de.mossgrabers.framework.controller.hardware.IHwGraphicsDisplay)1 IHwLight (de.mossgrabers.framework.controller.hardware.IHwLight)1 IHwPianoKeyboard (de.mossgrabers.framework.controller.hardware.IHwPianoKeyboard)1 IHwRelativeKnob (de.mossgrabers.framework.controller.hardware.IHwRelativeKnob)1 IHwSurfaceFactory (de.mossgrabers.framework.controller.hardware.IHwSurfaceFactory)1