use of de.mossgrabers.framework.daw.data.IBrowserColumnItem in project DrivenByMoss by git-moss.
the class DeviceBrowserMode method updateDisplay1.
/**
* {@inheritDoc}
*/
@Override
public void updateDisplay1() {
final IBrowser browser = this.model.getBrowser();
if (!browser.isActive()) {
this.surface.getModeManager().restoreMode();
return;
}
final Display d = this.surface.getDisplay().clear();
switch(this.selectionMode) {
case DeviceBrowserMode.SELECTION_OFF:
final String selectedResult = browser.getSelectedResult();
final String deviceName = this.model.getCursorDevice().getName();
String selectedContentType = browser.getSelectedContentType();
if (this.filterColumn == -1)
selectedContentType = PushDisplay.RIGHT_ARROW + selectedContentType;
d.setCell(0, 7, selectedContentType).setBlock(3, 0, " Selected Device:").setBlock(3, 1, deviceName.length() == 0 ? "None" : deviceName);
final boolean isPresetSession = browser.isPresetContentType();
d.setBlock(3, 2, isPresetSession ? " Selected Preset:" : "").setBlock(3, 3, isPresetSession ? selectedResult == null || selectedResult.length() == 0 ? "None" : selectedResult : "");
for (int i = 0; i < 7; i++) {
final IBrowserColumn column = this.getFilterColumn(i);
String name = column == null ? "" : StringUtils.shortenAndFixASCII(column.getName(), 8);
if (i == this.filterColumn)
name = PushDisplay.RIGHT_ARROW + name;
d.setCell(0, i, name).setCell(1, i, getColumnName(column));
}
break;
case DeviceBrowserMode.SELECTION_PRESET:
final IBrowserColumnItem[] results = browser.getResultColumnItems();
if (!results[0].doesExist()) {
d.clear().setBlock(1, 1, " No results").setBlock(1, 2, "available...").allDone();
return;
}
for (int i = 0; i < 16; i++) {
if (i < results.length)
d.setBlock(i % 4, i / 4, (results[i].isSelected() ? PushDisplay.RIGHT_ARROW : " ") + results[i].getName(16));
else
d.setBlock(i % 4, i / 4, "");
}
break;
case DeviceBrowserMode.SELECTION_FILTER:
final IBrowserColumnItem[] items = browser.getFilterColumn(this.filterColumn).getItems();
for (int i = 0; i < 16; i++) {
String text = (items[i].isSelected() ? PushDisplay.RIGHT_ARROW : " ") + items[i].getName() + " ";
if (!items[i].getName().isEmpty()) {
final String hitStr = "(" + items[i].getHitCount() + ")";
text = text.substring(0, 17 - hitStr.length()) + hitStr;
}
d.setBlock(i % 4, i / 4, text);
}
break;
}
d.allDone();
}
use of de.mossgrabers.framework.daw.data.IBrowserColumnItem in project DrivenByMoss by git-moss.
the class BrowserColumnImpl method enableObservers.
/**
* {@inheritDoc}
*/
@Override
public void enableObservers(final boolean enable) {
Util.setIsSubscribed(this.column.exists(), enable);
Util.setIsSubscribed(this.column.name(), enable);
Util.setIsSubscribed(this.column.getWildcardItem().name(), enable);
Util.setIsSubscribed(this.itemBank.cursorIndex(), enable);
for (final IBrowserColumnItem item : this.items) item.enableObservers(enable);
Util.setIsSubscribed(this.cursorResult.exists(), enable);
Util.setIsSubscribed(this.cursorResult.name(), enable);
}
use of de.mossgrabers.framework.daw.data.IBrowserColumnItem in project DrivenByMoss by git-moss.
the class DeviceBrowserMode method updateDisplay2.
/**
* {@inheritDoc}
*/
@Override
public void updateDisplay2(final IGraphicDisplay display) {
final IBrowser browser = this.model.getBrowser();
if (!browser.isActive())
return;
switch(this.selectionMode) {
case DeviceBrowserMode.SELECTION_OFF:
String selectedResult = browser.getSelectedResult();
selectedResult = selectedResult == null || selectedResult.isBlank() ? "Selection: None" : "Selection: " + selectedResult;
for (int i = 0; i < 7; i++) {
final Optional<IBrowserColumn> column = this.getFilterColumn(i);
final String headerTopName = i == 0 ? browser.getInfoText() : "";
final String headerBottomName = i == 0 ? selectedResult : "";
final String menuBottomName = getColumnName(column);
display.addOptionElement(headerTopName, column.isEmpty() ? "" : column.get().getName(), i == this.filterColumn, headerBottomName, menuBottomName, !menuBottomName.equals(" "), false);
}
final boolean supportsPreview = this.model.getHost().supports(Capability.HAS_BROWSER_PREVIEW);
final String bottomMenu = supportsPreview ? "Preview" : "";
final ColorEx menuBottomColor = browser.isPreviewEnabled() ? ColorEx.ORANGE : ColorEx.GRAY;
display.addOptionElement("", browser.getSelectedContentType(), this.filterColumn == -1, null, "", bottomMenu, false, supportsPreview ? menuBottomColor : null, false);
break;
case DeviceBrowserMode.SELECTION_PRESET:
final IBrowserColumnItem[] results = browser.getResultColumnItems();
if (!results[0].doesExist()) {
for (int i = 0; i < 8; i++) display.addOptionElement(i == 3 ? "No results available..." : "", "", false, "", "", false, false);
return;
}
for (int i = 0; i < 8; i++) {
final String[] items = new String[6];
final boolean[] selected = new boolean[6];
for (int item = 0; item < 6; item++) {
final int pos = i * 6 + item;
items[item] = pos < results.length ? results[pos].getName(14) : "";
selected[item] = pos < results.length && results[pos].isSelected();
}
display.addListElement(items, selected);
}
break;
case DeviceBrowserMode.SELECTION_FILTER:
final IBrowserColumnItem[] item = browser.getFilterColumn(this.filterColumn).getItems();
for (int i = 0; i < 8; i++) {
final String[] items = new String[6];
final boolean[] selected = new boolean[6];
for (int itemIndex = 0; itemIndex < 6; itemIndex++) {
final int pos = i * 6 + itemIndex;
final String hitText = " (" + item[pos].getHitCount() + ")";
String text = item[pos].getName(12 - hitText.length());
if (!text.isEmpty())
text = text + hitText;
items[itemIndex] = text;
selected[itemIndex] = item[pos].isSelected();
}
display.addListElement(items, selected);
}
break;
default:
// Not used
break;
}
}
use of de.mossgrabers.framework.daw.data.IBrowserColumnItem in project DrivenByMoss by git-moss.
the class DeviceBrowserMode method updateDisplay.
/**
* {@inheritDoc}
*/
@Override
public void updateDisplay() {
final IBrowser browser = this.model.getBrowser();
final ITextDisplay d = this.surface.getTextDisplay();
final boolean isPresetSession = browser.isPresetContentType();
final ICursorDevice cd = this.model.getCursorDevice();
if (isPresetSession && !(browser.isActive() && cd.doesExist())) {
d.notify("No active Browsing Session. Select device and press Browser...");
return;
}
d.clear();
switch(this.selectionMode) {
case SELECTION_OFF:
for (int i = 0; i < 7; i++) {
final Optional<IBrowserColumn> column = this.getFilterColumn(i);
String value = "";
String name = "";
if (column.isPresent()) {
final IBrowserColumn browserColumn = column.get();
if (browserColumn.doesCursorExist())
value = browserColumn.getCursorName().equals(browserColumn.getWildcard()) ? "-" : browserColumn.getCursorName();
name = StringUtils.shortenAndFixASCII(browserColumn.getName(), 6);
}
d.setCell(0, i, name).setCell(1, i, value);
}
final String selectedResult = browser.getSelectedResult();
d.setCell(0, 7, browser.getSelectedContentType()).setCell(1, 7, selectedResult == null || selectedResult.length() == 0 ? "-" : selectedResult);
break;
case SELECTION_PRESET:
final IBrowserColumnItem[] results = browser.getResultColumnItems();
for (int i = 0; i < browser.getNumFilterColumnEntries(); i++) {
if (i < results.length)
d.setBlock(i / 4, i % 4, (results[i].isSelected() ? ">" : " ") + StringUtils.fixASCII(results[i].getName()));
else
break;
}
break;
case SELECTION_FILTER:
final IBrowserColumnItem[] items = browser.getFilterColumn(this.filterColumn).getItems();
for (int i = 0; i < browser.getNumResults(); i++) d.setBlock(i / 4, i % 4, (items[i].isSelected() ? ">" : " ") + StringUtils.fixASCII(items[i].getName()));
break;
default:
// Not used
break;
}
d.allDone();
}
use of de.mossgrabers.framework.daw.data.IBrowserColumnItem in project DrivenByMoss by git-moss.
the class BrowserModule method flush.
/**
* {@inheritDoc}
*/
@Override
public void flush(final boolean dump) {
final String browserAddress = "/browser/";
final IBrowser browser = this.model.getBrowser();
final boolean isActive = browser.isActive();
this.writer.sendOSC(browserAddress + "isActive", isActive, dump);
if (!isActive)
return;
this.writer.sendOSC(browserAddress + "tab", browser.getSelectedContentType(), dump);
IBrowserColumn column;
// Filter Columns
for (int i = 0; i < browser.getFilterColumnCount(); i++) {
final String filterAddress = browserAddress + "filter/" + (i + 1) + "/";
column = browser.getFilterColumn(i);
this.writer.sendOSC(filterAddress + TAG_EXISTS, column.doesExist(), dump);
this.writer.sendOSC(filterAddress + TAG_NAME, column.getName(), dump);
this.writer.sendOSC(filterAddress + "wildcard", column.getWildcard(), dump);
final IBrowserColumnItem[] items = column.getItems();
for (int j = 0; j < items.length; j++) {
final String browserItemAddress = filterAddress + "item/" + (j + 1) + "/";
this.writer.sendOSC(browserItemAddress + TAG_EXISTS, items[j].doesExist(), dump);
this.writer.sendOSC(browserItemAddress + TAG_NAME, items[j].getName(), dump);
this.writer.sendOSC(browserItemAddress + "hits", items[j].getHitCount(), dump);
this.writer.sendOSC(browserItemAddress + "isSelected", items[j].isSelected(), dump);
}
}
// Presets
final String presetAddress = browserAddress + "result/";
final IBrowserColumnItem[] items = browser.getResultColumnItems();
for (int i = 0; i < items.length; i++) {
final String browserPresetAddress = presetAddress + (i + 1) + "/";
this.writer.sendOSC(browserPresetAddress + TAG_EXISTS, items[i].doesExist(), dump);
this.writer.sendOSC(browserPresetAddress + TAG_NAME, items[i].getName(), dump);
this.writer.sendOSC(browserPresetAddress + "hits", items[i].getHitCount(), dump);
this.writer.sendOSC(browserPresetAddress + "isSelected", items[i].isSelected(), dump);
}
}
Aggregations