Search in sources :

Example 6 with IGraphicsContext

use of de.mossgrabers.framework.graphics.IGraphicsContext 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);
    }
}
Also used : IGraphicsContext(de.mossgrabers.framework.graphics.IGraphicsContext) IGraphicsConfiguration(de.mossgrabers.framework.graphics.IGraphicsConfiguration) ITrack(de.mossgrabers.framework.daw.data.ITrack) ColorEx(de.mossgrabers.framework.controller.color.ColorEx) ISlot(de.mossgrabers.framework.daw.data.ISlot) IGraphicsDimensions(de.mossgrabers.framework.graphics.IGraphicsDimensions)

Example 7 with IGraphicsContext

use of de.mossgrabers.framework.graphics.IGraphicsContext 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);
}
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 8 with IGraphicsContext

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

Example 9 with IGraphicsContext

use of de.mossgrabers.framework.graphics.IGraphicsContext 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);
    }
}
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)

Example 10 with IGraphicsContext

use of de.mossgrabers.framework.graphics.IGraphicsContext in project DrivenByMoss by git-moss.

the class ListComponent 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 ColorEx textColor = configuration.getColorText();
    final ColorEx borderColor = configuration.getColorBorder();
    for (int i = 0; i < size; i++) {
        final Pair<String, Boolean> item = this.items.get(i);
        final boolean isSelected = item.getValue().booleanValue();
        final double itemTop = i * itemHeight;
        gc.fillRectangle(itemLeft, itemTop + separatorSize, itemWidth, itemHeight - 2 * separatorSize, isSelected ? textColor : borderColor);
        gc.drawTextInBounds(item.getKey(), itemLeft + inset, itemTop, itemWidth - 2 * inset, itemHeight, Align.LEFT, isSelected ? borderColor : textColor, itemHeight * 0.6);
    }
}
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)

Aggregations

ColorEx (de.mossgrabers.framework.controller.color.ColorEx)12 IGraphicsConfiguration (de.mossgrabers.framework.graphics.IGraphicsConfiguration)12 IGraphicsContext (de.mossgrabers.framework.graphics.IGraphicsContext)12 IGraphicsDimensions (de.mossgrabers.framework.graphics.IGraphicsDimensions)9 IBounds (de.mossgrabers.framework.graphics.IBounds)2 IStepInfo (de.mossgrabers.framework.daw.IStepInfo)1 StepState (de.mossgrabers.framework.daw.StepState)1 ISlot (de.mossgrabers.framework.daw.data.ISlot)1 ITrack (de.mossgrabers.framework.daw.data.ITrack)1 IImage (de.mossgrabers.framework.graphics.IImage)1 SendData (de.mossgrabers.framework.graphics.canvas.utils.SendData)1