use of de.mossgrabers.framework.daw.DAWColor in project DrivenByMoss by git-moss.
the class AutoColorSetup method createObservers.
/**
* {@inheritDoc}
*/
@Override
protected void createObservers() {
super.createObservers();
// Update track colors if Auto Color is enabled in the settings
this.configuration.addSettingObserver(AutoColorConfiguration.ENABLE_AUTO_COLOR, () -> {
if (!this.configuration.isEnableAutoColor())
return;
final ITrackBank tb = this.model.getTrackBank();
for (int i = 0; i < tb.getPageSize(); i++) this.autoColor.matchTrackName(i, tb.getItem(i).getName());
});
// Monitor all color regular expression settings
final DAWColor[] colors = DAWColor.values();
for (int i = 0; i < colors.length; i++) {
final DAWColor color = colors[i];
this.configuration.addSettingObserver(Integer.valueOf(AutoColorConfiguration.COLOR_REGEX.intValue() + i), () -> this.autoColor.handleRegExChange(color, this.configuration.getColorRegExValue(color)));
}
// Add name observers to all tracks
final ITrackBank tb = this.model.getTrackBank();
for (int index = 0; index < tb.getPageSize(); index++) {
final int i = index;
final ITrack track = tb.getItem(index);
track.addNameObserver(name -> this.autoColor.matchTrackName(i, name));
track.addColorObserver(name -> this.autoColor.matchTrackName(i, track.getName()));
}
}
use of de.mossgrabers.framework.daw.DAWColor in project DrivenByMoss by git-moss.
the class ColorView method onGridNote.
/**
* {@inheritDoc}
*/
@Override
public void onGridNote(final int note, final int velocity) {
if (velocity > 0)
return;
final int offset = this.page * this.pageSize;
final int color = offset + note - 36;
final DAWColor[] dawColors = DAWColor.values();
if (color < dawColors.length) {
final ColorEx entry = dawColors[color].getColor();
switch(this.mode) {
case MODE_TRACK:
final ITrack cursorTrack = this.model.getCursorTrack();
if (cursorTrack.doesExist())
cursorTrack.setColor(entry);
else {
final IMasterTrack master = this.model.getMasterTrack();
if (master.isSelected())
master.setColor(entry);
}
break;
case MODE_LAYER:
final IBank<? extends ILayer> layerBank = this.getLayerBank();
final Optional<?> selectedItem = layerBank.getSelectedItem();
if (selectedItem.isPresent())
((ILayer) selectedItem.get()).setColor(entry);
break;
case MODE_CLIP:
final IClip clip = this.model.getCursorClip();
if (clip.doesExist())
clip.setColor(entry);
break;
}
}
this.surface.getViewManager().restore();
}
use of de.mossgrabers.framework.daw.DAWColor in project DrivenByMoss by git-moss.
the class ColorView method drawGrid.
/**
* {@inheritDoc}
*/
@Override
public void drawGrid() {
final IPadGrid padGrid = this.surface.getPadGrid();
final DAWColor[] dawColors = DAWColor.values();
final int offset = this.page * this.pageSize;
for (int i = 0; i < this.pageSize; i++) {
final int index = offset + i;
padGrid.light(36 + i, index < dawColors.length ? dawColors[index].name() : IPadGrid.GRID_OFF);
}
}
use of de.mossgrabers.framework.daw.DAWColor in project DrivenByMoss by git-moss.
the class AutoColorConfiguration method init.
/**
* {@inheritDoc}
*/
@Override
public void init(final ISettingsUI globalSettings, final ISettingsUI documentSettings) {
// /////////////////////////
// Auto Color
final IEnumSetting enableAutoColorSetting = globalSettings.getEnumSetting(CATEGORY_AUTO_COLOR, CATEGORY_AUTO_COLOR, ON_OFF_OPTIONS, ON_OFF_OPTIONS[1]);
enableAutoColorSetting.addValueObserver(value -> {
this.enableAutoColor = ON_OFF_OPTIONS[1].equals(value);
this.notifyObservers(ENABLE_AUTO_COLOR);
});
this.isSettingActive.add(ENABLE_AUTO_COLOR);
final DAWColor[] colors = DAWColor.values();
for (int i = 0; i < colors.length; i++) {
final DAWColor color = colors[i];
final IStringSetting setting = globalSettings.getStringSetting(color.getName(), CATEGORY_AUTO_COLOR, 256, "");
final int index = i;
final Integer colorRegexIndex = Integer.valueOf(COLOR_REGEX.intValue() + index);
setting.addValueObserver(value -> {
this.colorRegEx.put(color, value);
this.notifyObservers(colorRegexIndex);
});
this.isSettingActive.add(colorRegexIndex);
}
}
Aggregations