use of de.mossgrabers.framework.graphics.IGraphicsDimensions 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));
}
use of de.mossgrabers.framework.graphics.IGraphicsDimensions 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);
}
}
use of de.mossgrabers.framework.graphics.IGraphicsDimensions 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);
}
}
use of de.mossgrabers.framework.graphics.IGraphicsDimensions in project DrivenByMoss by git-moss.
the class ParameterComponent method draw.
/**
* {@inheritDoc}
*/
@Override
public void draw(final IGraphicsInfo info) {
super.draw(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 menuHeight = dimensions.getMenuHeight();
final double unit = dimensions.getUnit();
final double controlsTop = dimensions.getControlsTop();
final double inset = dimensions.getInset();
final boolean isValueMissing = this.paramValue == -1;
final boolean isModulated = this.modulatedParamValue != -1;
final int trackRowHeight = (int) (1.6 * unit);
final double trackRowTop = height - trackRowHeight - unit - separatorSize;
// Component is off if the name is empty
if (this.paramName == null || this.paramName.length() == 0)
return;
final double elementWidth = width - 2 * inset;
final double elementHeight = (trackRowTop - controlsTop - inset) / 3;
// Draw the background
final ColorEx backgroundColor = configuration.getColorBackground();
gc.fillRectangle(left, menuHeight + 1, width, trackRowTop - (isValueMissing ? controlsTop + elementHeight : menuHeight + 1), this.isTouched ? configuration.getColorBackgroundLighter() : backgroundColor);
// Draw the name and value texts
final ColorEx textColor = configuration.getColorText();
final double fontSize = elementHeight * 2 / 3;
gc.drawTextInBounds(this.paramName, left + inset - 1, controlsTop - inset, elementWidth, elementHeight, Align.CENTER, textColor, fontSize);
gc.drawTextInBounds(this.paramValueText, left + inset - 1, controlsTop - inset + elementHeight, elementWidth, elementHeight, Align.CENTER, textColor, fontSize);
// Value slider
if (isValueMissing)
return;
final double elementInnerWidth = elementWidth - 2;
final double maxValue = dimensions.getParameterUpperBound();
final double value = isModulated ? this.modulatedParamValue : this.paramValue;
final double valueSliderWidth = value >= maxValue - 1 ? elementInnerWidth : elementInnerWidth * value / maxValue;
final double innerTop = controlsTop + 2 * elementHeight + 1;
final ColorEx borderColor = configuration.getColorBorder();
gc.fillRectangle(left + inset - 1, controlsTop + 2 * elementHeight, elementWidth, elementHeight, borderColor);
gc.fillRectangle(left + inset, innerTop, valueSliderWidth, elementHeight - 2, configuration.getColorFader());
final double w = this.isTouched ? 3 : 1;
final double valueWidth = this.paramValue >= maxValue - 1 ? elementInnerWidth : elementInnerWidth * this.paramValue / maxValue;
gc.fillRectangle(left + inset + Math.max(0, valueWidth - w), innerTop, w, elementHeight - 2, configuration.getColorEdit());
}
Aggregations