Search in sources :

Example 26 with ColorEx

use of de.mossgrabers.framework.controller.color.ColorEx in project DrivenByMoss by git-moss.

the class TrackMode method updateDisplay2.

/**
 * {@inheritDoc}
 */
@Override
public void updateDisplay2(final IGraphicDisplay display) {
    final ITrackBank tb = this.model.getCurrentTrackBank();
    final Optional<ITrack> selectedTrack = tb.getSelectedItem();
    // Get the index at which to draw the Sends element
    final int selectedIndex = selectedTrack.isEmpty() ? -1 : selectedTrack.get().getIndex();
    int sendsIndex = selectedTrack.isEmpty() || this.model.isEffectTrackBankActive() ? -1 : selectedTrack.get().getIndex() + 1;
    if (sendsIndex == 8)
        sendsIndex = 6;
    this.updateMenuItems(0);
    final ICursorTrack cursorTrack = this.model.getCursorTrack();
    final PushConfiguration config = this.surface.getConfiguration();
    for (int i = 0; i < 8; i++) {
        final ITrack t = tb.getItem(i);
        // The menu item
        final Pair<String, Boolean> pair = this.menu.get(i);
        final String topMenu = pair.getKey();
        final boolean topMenuSelected = pair.getValue().booleanValue();
        // Channel info
        final String bottomMenu = t.doesExist() ? t.getName() : "";
        final ColorEx bottomMenuColor = t.getColor();
        final boolean isBottomMenuOn = t.isSelected();
        final IValueChanger valueChanger = this.model.getValueChanger();
        if (t.isSelected()) {
            final int crossfadeMode = this.getCrossfadeModeAsNumber(t);
            final boolean enableVUMeters = config.isEnableVUMeters();
            final int vuR = valueChanger.toDisplayValue(enableVUMeters ? t.getVuRight() : 0);
            final int vuL = valueChanger.toDisplayValue(enableVUMeters ? t.getVuLeft() : 0);
            display.addChannelElement(topMenu, topMenuSelected, bottomMenu, this.updateType(t), bottomMenuColor, isBottomMenuOn, valueChanger.toDisplayValue(t.getVolume()), valueChanger.toDisplayValue(t.getModulatedVolume()), this.isKnobTouched[0] ? t.getVolumeStr(8) : "", valueChanger.toDisplayValue(t.getPan()), valueChanger.toDisplayValue(t.getModulatedPan()), this.isKnobTouched[1] ? t.getPanStr(8) : "", vuL, vuR, t.isMute(), t.isSolo(), t.isRecArm(), t.isActivated(), crossfadeMode, cursorTrack.isPinned());
        } else if (sendsIndex == i) {
            final ITrack selTrack = tb.getItem(selectedIndex);
            final SendData[] sendData = new SendData[4];
            for (int j = 0; j < 4; j++) {
                if (selTrack != null) {
                    final int sendOffset = config.isSendsAreToggled() ? 4 : 0;
                    final int sendPos = sendOffset + j;
                    final ISend send = selTrack.getSendBank().getItem(sendPos);
                    if (send != null) {
                        final boolean exists = send.doesExist();
                        sendData[j] = new SendData(send.getName(), exists && this.isKnobTouched[4 + j] ? send.getDisplayedValue(8) : "", valueChanger.toDisplayValue(exists ? send.getValue() : 0), valueChanger.toDisplayValue(exists ? send.getModulatedValue() : 0), true);
                        continue;
                    }
                }
                sendData[j] = new SendData("", "", 0, 0, true);
            }
            display.addSendsElement(topMenu, topMenuSelected, bottomMenu, this.updateType(t), bottomMenuColor, isBottomMenuOn, sendData, true, selTrack == null || selTrack.isActivated(), t.isActivated());
        } else
            display.addChannelSelectorElement(topMenu, topMenuSelected, bottomMenu, this.updateType(t), bottomMenuColor, isBottomMenuOn, t.isActivated());
    }
}
Also used : PushConfiguration(de.mossgrabers.controller.ableton.push.PushConfiguration) ITrack(de.mossgrabers.framework.daw.data.ITrack) ITrackBank(de.mossgrabers.framework.daw.data.bank.ITrackBank) ColorEx(de.mossgrabers.framework.controller.color.ColorEx) ICursorTrack(de.mossgrabers.framework.daw.data.ICursorTrack) IValueChanger(de.mossgrabers.framework.controller.valuechanger.IValueChanger) ISend(de.mossgrabers.framework.daw.data.ISend) SendData(de.mossgrabers.framework.graphics.canvas.utils.SendData)

Example 27 with ColorEx

use of de.mossgrabers.framework.controller.color.ColorEx in project DrivenByMoss by git-moss.

the class TitleValueComponent method draw.

/**
 * {@inheritDoc}
 */
@Override
public void draw(final IGraphicsInfo info) {
    final IGraphicsContext gc = info.getContext();
    final IGraphicsConfiguration configuration = info.getConfiguration();
    final ColorEx colorText = configuration.getColorText();
    final ColorEx colorFader = configuration.getColorFader();
    gc.drawTextInHeight(this.label, 0, 0, ROW_HEIGHT, colorText, ROW_HEIGHT);
    gc.drawTextInHeight(this.label2, 0, ROW_HEIGHT, ROW_HEIGHT, colorText, ROW_HEIGHT);
    if (this.value >= 0) {
        final int width = this.value * 128 / RESOLUTION;
        gc.strokeRectangle(1, TOP, 127, ROW_HEIGHT, colorFader);
        if (this.isPan) {
            if (width == CENTER)
                gc.fillRectangle(CENTER + 1.0, TOP, 1, ROW_HEIGHT, colorFader);
            else if (width > CENTER)
                gc.fillRectangle(CENTER + 1.0, TOP, width - (double) CENTER, ROW_HEIGHT, colorFader);
            else
                gc.fillRectangle(width, TOP, CENTER - (double) width, ROW_HEIGHT, colorFader);
        } else
            gc.fillRectangle(1, TOP, width, ROW_HEIGHT, colorFader);
    }
    if (this.vuLeft > 0 || this.vuRight > 0) {
        final double height = 2.0 * ROW_HEIGHT;
        final double heightLeft = this.vuLeft * height / RESOLUTION;
        final double topLeft = Math.max(height - heightLeft - 1, 0);
        gc.strokeRectangle(118, topLeft, 5, heightLeft, ColorEx.BLACK);
        gc.fillRectangle(119, height - heightLeft, 3, heightLeft, colorFader);
        final double heightRight = this.vuRight * height / RESOLUTION;
        final double topRight = Math.max(height - heightRight - 1, 0);
        gc.strokeRectangle(123, topRight, 4, height - topRight, ColorEx.BLACK);
        gc.fillRectangle(124, height - heightRight, 3, heightRight, colorFader);
    }
}
Also used : IGraphicsContext(de.mossgrabers.framework.graphics.IGraphicsContext) IGraphicsConfiguration(de.mossgrabers.framework.graphics.IGraphicsConfiguration) ColorEx(de.mossgrabers.framework.controller.color.ColorEx)

Example 28 with ColorEx

use of de.mossgrabers.framework.controller.color.ColorEx in project DrivenByMoss by git-moss.

the class TitleChannelsComponent method draw.

/**
 * {@inheritDoc}
 */
@Override
public void draw(final IGraphicsInfo info) {
    final IGraphicsContext gc = info.getContext();
    final IGraphicsConfiguration configuration = info.getConfiguration();
    final ColorEx colorText = configuration.getColorText();
    final ColorEx colorFader = configuration.getColorFader();
    gc.drawTextInHeight(this.label, 0, 0, ROW_HEIGHT, colorText, ROW_HEIGHT);
    final int channelWidth = WIDTH / this.values.length;
    final int halfChannelWidth = channelWidth / 2;
    final int lowerHeight = HEIGHT - ROW_HEIGHT - 1;
    for (int i = 0; i < this.values.length; i++) {
        final int left = i * channelWidth;
        final int faderHeight = this.values[i] * lowerHeight / RESOLUTION;
        if (this.isPan) {
            final int center = lowerHeight / 2;
            if (this.selected[i]) {
                if (faderHeight == center)
                    gc.fillRectangle(left, HEIGHT - center + 1.0, halfChannelWidth + 1.0, 1, colorFader);
                else if (faderHeight > center)
                    gc.fillRectangle(left, HEIGHT - (double) center, halfChannelWidth + 1.0, faderHeight - (double) center, colorFader);
                else
                    gc.fillRectangle(left, HEIGHT - lowerHeight + (double) faderHeight, halfChannelWidth + 1.0, center - faderHeight + 2.0, colorFader);
            } else {
                if (faderHeight == center)
                    gc.strokeRectangle(left + 1.0, HEIGHT - center + 1.0, halfChannelWidth, 1, colorFader);
                else if (faderHeight > center)
                    gc.strokeRectangle(left + 1.0, HEIGHT - (double) center, halfChannelWidth, faderHeight - (double) center, colorFader);
                else
                    gc.strokeRectangle(left + 1.0, HEIGHT - lowerHeight + (double) faderHeight, halfChannelWidth, center - faderHeight + 2.0, colorFader);
            }
        } else {
            if (this.selected[i])
                gc.fillRectangle(left, HEIGHT - (double) faderHeight, halfChannelWidth + 1.0, faderHeight, colorFader);
            else
                gc.strokeRectangle(left + 1.0, HEIGHT - (double) faderHeight, halfChannelWidth, faderHeight, colorFader);
        }
    }
}
Also used : IGraphicsContext(de.mossgrabers.framework.graphics.IGraphicsContext) IGraphicsConfiguration(de.mossgrabers.framework.graphics.IGraphicsConfiguration) ColorEx(de.mossgrabers.framework.controller.color.ColorEx)

Example 29 with ColorEx

use of de.mossgrabers.framework.controller.color.ColorEx in project DrivenByMoss by git-moss.

the class ClipModule method flush.

/**
 * {@inheritDoc}
 */
@Override
public void flush(final boolean dump) {
    final INoteClip cursorClip = this.model.getCursorClip();
    this.writer.sendOSC("/clip/exists", cursorClip.doesExist(), dump);
    this.writer.sendOSC("/clip/pinned", cursorClip.isPinned(), dump);
    ColorEx color = cursorClip.getColor();
    if (color == null)
        color = ColorEx.BLACK;
    this.writer.sendOSCColor("/clip/color", color.getRed(), color.getGreen(), color.getBlue(), dump);
}
Also used : ColorEx(de.mossgrabers.framework.controller.color.ColorEx) INoteClip(de.mossgrabers.framework.daw.INoteClip)

Example 30 with ColorEx

use of de.mossgrabers.framework.controller.color.ColorEx in project DrivenByMoss by git-moss.

the class SessionMode method updateDisplay1Clips.

private void updateDisplay1Clips(final ITextDisplay display) {
    final ITrackBank tb = this.model.getCurrentTrackBank();
    final int numTracks = tb.getPageSize();
    final int numScenes = tb.getSceneBank().getPageSize();
    final boolean flipSession = this.surface.getConfiguration().isFlipSession();
    final int maxCols = flipSession ? numScenes : numTracks;
    int maxRows = flipSession ? numTracks : numScenes;
    if (this.rowDisplayMode != RowDisplayMode.ALL)
        maxRows = maxRows / 2;
    for (int col = 0; col < maxCols; col++) {
        for (int row = 0; row < maxRows; row++) {
            int x = flipSession ? row : col;
            int y = flipSession ? col : row;
            if (this.rowDisplayMode == RowDisplayMode.LOWER) {
                if (flipSession)
                    x += maxRows;
                else
                    y += maxRows;
            }
            final ITrack track = tb.getItem(x);
            final ISlot slot = track.getSlotBank().getItem(y);
            if (!slot.doesExist())
                continue;
            String name = slot.getName(8);
            if (track.isGroup()) {
                if (name.isEmpty())
                    name = "Scene " + (slot.getPosition() + 1);
            } else {
                // https://github.com/teotigraphix/Framework4Bitwig/issues/193
                if (name.isEmpty()) {
                    final ColorEx color = slot.getColor();
                    if (color.getRed() != 0 || color.getGreen() != 0 || color.getBlue() != 0)
                        name = "--------";
                }
            }
            if (slot.isSelected())
                name = Push1Display.SELECT_ARROW + name;
            else if (slot.isPlaying())
                name = ">" + name;
            else if (slot.isPlayingQueued() || slot.isRecordingQueued())
                name = ")" + name;
            else if (track.isRecArm() || slot.isRecording())
                name = "*" + name;
            else if (slot.hasContent())
                name = Push1Display.RIGHT_ARROW + name;
            else
                name = Push1Display.DEGREE + name;
            display.setCell(row, col, StringUtils.shortenAndFixASCII(name, 8));
        }
    }
}
Also used : ITrack(de.mossgrabers.framework.daw.data.ITrack) ITrackBank(de.mossgrabers.framework.daw.data.bank.ITrackBank) ColorEx(de.mossgrabers.framework.controller.color.ColorEx) ISlot(de.mossgrabers.framework.daw.data.ISlot)

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