use of de.mossgrabers.framework.controller.color.ColorEx in project DrivenByMoss by git-moss.
the class ChannelComponent method drawButton.
/**
* Draws a button a gradient background.
*
* @param gc The graphics context
* @param left The left bound of the drawing area
* @param top The top bound of the drawing area
* @param width The width of the drawing area
* @param height The height of the drawing area
* @param backgroundColor The background color
* @param isOnColor The color if the button is on
* @param textColor The color of the buttons text
* @param isOn True if the button is on
* @param iconName The name of the buttons icon
* @param configuration The layout settings
* @param radius The radius of the surrounding border rectangle
*/
private void drawButton(final IGraphicsContext gc, final double left, final double top, final double width, final double height, final ColorEx backgroundColor, final ColorEx isOnColor, final ColorEx textColor, final boolean isOn, final String iconName, final IGraphicsConfiguration configuration, final double radius) {
final ColorEx borderColor = this.modifyIfOff(configuration.getColorBorder());
gc.fillRoundedRectangle(left, top, width, height, radius, borderColor);
if (isOn)
gc.fillRoundedRectangle(left + 1, top + 1, width - 2, height - 2, radius, isOnColor);
else
gc.fillGradientRoundedRectangle(left + 1, top + 1, width - 2, height - 2, radius, backgroundColor, ColorEx.brighter(backgroundColor));
final IImage icon = ResourceHandler.getSVGImage(iconName);
gc.maskImage(icon, left + (width - icon.getWidth()) / 2, top + (height - icon.getHeight()) / 2, isOn ? borderColor : textColor);
}
use of de.mossgrabers.framework.controller.color.ColorEx in project DrivenByMoss by git-moss.
the class DrumView method drawGrid.
/**
* {@inheritDoc}
*/
@Override
public void drawGrid() {
final IPadGrid padGrid = this.surface.getPadGrid();
final IDrumDevice primary = this.model.getDrumDevice();
if (this.isPlayMode) {
for (int y = 0; y < 2; y++) {
for (int x = 0; x < 8; x++) {
final int index = 8 * y + x;
padGrid.lightEx(x, 1 - y, this.getDrumPadColor(index, primary, false));
}
}
return;
}
if (!this.isActive()) {
padGrid.turnOff();
return;
}
// Paint the sequencer steps
final INoteClip clip = this.getClip();
final int step = clip.getCurrentStep();
final int hiStep = this.isInXRange(step) ? step % this.sequencerSteps : -1;
final int offsetY = this.scales.getDrumOffset();
final int editMidiChannel = this.configuration.getMidiEditChannel();
final int selPad = this.getSelectedPad();
final List<GridStep> editNotes = this.getEditNotes();
for (int col = 0; col < DrumView.NUM_DISPLAY_COLS; col++) {
final int noteRow = offsetY + selPad;
final IStepInfo stepInfo = clip.getStep(editMidiChannel, col, noteRow);
final boolean hilite = col == hiStep;
final int x = col % GRID_COLUMNS;
final int y = col / GRID_COLUMNS;
final Optional<ColorEx> rowColor = this.getPadColor(primary, this.selectedPad);
padGrid.lightEx(x, y, this.getStepColor(stepInfo, hilite, rowColor, editMidiChannel, col, noteRow, editNotes));
}
}
use of de.mossgrabers.framework.controller.color.ColorEx in project DrivenByMoss by git-moss.
the class AbstractGraphicDisplay method renderImage.
private void renderImage() {
this.image.render(this.configuration.isAntialiasEnabled(), gc -> {
final int width = this.dimensions.getWidth();
final int height = this.dimensions.getHeight();
final double separatorSize = this.dimensions.getSeparatorSize();
// Clear display
final ColorEx colorBorder = this.configuration.getColorBorder();
gc.fillRectangle(0, 0, width, height, colorBorder);
final List<IComponent> elements = this.info.getComponents();
final int size = elements.size();
if (size == 0)
return;
final int gridWidth = width / size;
final double paintWidth = gridWidth - separatorSize;
final double offsetX = separatorSize / 2.0;
final IGraphicsInfo graphicsInfo = new DefaultGraphicsInfo(gc, this.configuration, this.dimensions);
for (int i = 0; i < size; i++) {
final IComponent component = elements.get(i);
if (component != null)
component.draw(graphicsInfo.withBounds(i * gridWidth + offsetX, 0, paintWidth, height));
}
final String notification = this.info.getNotification();
if (notification == null)
return;
final ColorEx colorText = this.configuration.getColorText();
gc.drawTextInBounds(notification, 0, 0, width, height, Align.CENTER, colorText, colorBorder, height / 4.0);
});
}
use of de.mossgrabers.framework.controller.color.ColorEx 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()));
}
use of de.mossgrabers.framework.controller.color.ColorEx in project DrivenByMoss by git-moss.
the class DeviceParamsMode method updateDisplay2.
/**
* {@inheritDoc}
*/
@Override
public void updateDisplay2(final IGraphicDisplay display) {
final ICursorDevice cd = this.model.getCursorDevice();
if (!this.checkExists2(display, cd))
return;
final String color = this.model.getCurrentTrackBank().getSelectedChannelColorEntry();
final ColorEx bottomMenuColor = DAWColor.getColorEntry(color);
final IDeviceBank deviceBank = cd.getDeviceBank();
final IParameterBank parameterBank = cd.getParameterBank();
final IParameterPageBank parameterPageBank = cd.getParameterPageBank();
final int selectedPage = parameterPageBank.getSelectedItemIndex();
final boolean hasPinning = this.model.getHost().supports(Capability.HAS_PINNING);
final IValueChanger valueChanger = this.model.getValueChanger();
for (int i = 0; i < parameterBank.getPageSize(); i++) {
final boolean isTopMenuOn = this.getTopMenuEnablement(cd, hasPinning, i);
String bottomMenu;
final String bottomMenuIcon;
boolean isBottomMenuOn;
if (this.showDevices) {
final IDevice item = deviceBank.getItem(i);
bottomMenuIcon = item.getName();
bottomMenu = item.doesExist() ? item.getName(12) : "";
isBottomMenuOn = i == cd.getIndex();
} else {
bottomMenuIcon = cd.getName();
bottomMenu = parameterPageBank.getItem(i);
if (bottomMenu.length() > 12)
bottomMenu = bottomMenu.substring(0, 12);
isBottomMenuOn = i == selectedPage;
}
final IParameter param = parameterBank.getItem(i);
final boolean exists = param.doesExist();
final String parameterName = exists ? param.getName(9) : "";
final int parameterValue = valueChanger.toDisplayValue(exists ? param.getValue() : 0);
final String parameterValueStr = exists ? param.getDisplayedValue(8) : "";
final boolean parameterIsActive = this.isKnobTouched[i];
final int parameterModulatedValue = valueChanger.toDisplayValue(exists ? param.getModulatedValue() : -1);
display.addParameterElement(this.hostMenu[i], isTopMenuOn, bottomMenu, bottomMenuIcon, bottomMenuColor, isBottomMenuOn, parameterName, parameterValue, parameterValueStr, parameterIsActive, parameterModulatedValue);
}
}
Aggregations