use of de.mossgrabers.framework.daw.IBrowser in project DrivenByMoss by git-moss.
the class BrowserView method onKnob.
/**
* {@inheritDoc}
*/
@Override
public void onKnob(final int index, final int value) {
final IBrowser browser = this.model.getBrowser();
if (!browser.isActive()) {
final ViewManager viewManager = this.surface.getViewManager();
if (viewManager.isActiveView(Views.VIEW_BROWSER))
viewManager.restoreView();
return;
}
int column;
switch(index) {
case 8:
case 9:
case 10:
case 11:
case 12:
case 13:
case 14:
column = index - 8;
if (value > 64) {
for (int i = 0; i < value - 64; i++) browser.selectNextFilterItem(column);
} else {
for (int i = 0; i < 64 - value; i++) browser.selectPreviousFilterItem(column);
}
break;
case 15:
if (value > 64) {
for (int i = 0; i < value - 64; i++) browser.selectNextResult();
} else {
for (int i = 0; i < 64 - value; i++) browser.selectPreviousResult();
}
break;
}
}
use of de.mossgrabers.framework.daw.IBrowser in project DrivenByMoss by git-moss.
the class BrowserCommand method startBrowser.
/**
* Start a browser.
*
* @param insertDevice Insert a device if true otherwise select preset
* @param beforeCurrent Insert the device before the current device if any
*/
public void startBrowser(final boolean insertDevice, final boolean beforeCurrent) {
final IBrowser browser = this.model.getBrowser();
// Patch Browser already active?
if (browser.isActive()) {
this.discardBrowser(this.getCommit());
return;
}
if (!insertDevice && this.model.getCursorDevice().hasSelectedDevice())
browser.browseForPresets();
else {
if (beforeCurrent)
browser.browseToInsertBeforeDevice();
else
browser.browseToInsertAfterDevice();
}
this.startRetries = 0;
this.activateMode();
}
use of de.mossgrabers.framework.daw.IBrowser in project DrivenByMoss by git-moss.
the class BrowserView method onGridNote.
/**
* {@inheritDoc}
*/
@Override
public void onGridNote(final int note, final int velocity) {
final IBrowser browser = this.model.getBrowser();
if (!browser.isActive()) {
final ViewManager viewManager = this.surface.getViewManager();
if (viewManager.isActiveView(Views.VIEW_BROWSER))
viewManager.restoreView();
return;
}
switch(note) {
// Cancel
case 36:
if (velocity == 0)
return;
this.model.getBrowser().stopBrowsing(false);
this.surface.getViewManager().restoreView();
break;
// OK
case 43:
if (velocity == 0)
return;
this.model.getBrowser().stopBrowsing(true);
this.surface.getViewManager().restoreView();
break;
case 38:
this.surface.sendMidiEvent(0x90, 48, velocity);
break;
case 39:
this.surface.sendMidiEvent(0x90, 60, velocity);
break;
case 40:
this.surface.sendMidiEvent(0x90, 72, velocity);
break;
case 41:
this.surface.sendMidiEvent(0x90, 84, velocity);
break;
}
if (velocity == 0)
return;
if (note >= 52 && note < 84) {
final int n = note - 52;
final int row = n / 8;
final int col = n % 8;
switch(col) {
case 6:
return;
case 7:
if (row == 0)
browser.selectNextResult();
else if (row == 1) {
for (int i = 0; i < 8; i++) browser.selectNextResult();
} else if (row == 2) {
for (int i = 0; i < 8; i++) browser.selectPreviousResult();
} else if (row == 3)
browser.selectPreviousResult();
break;
default:
if (row == 0)
browser.selectNextFilterItem(BrowserView.COLUMN_ORDER[col]);
else if (row == 1) {
for (int i = 0; i < 8; i++) browser.selectNextFilterItem(BrowserView.COLUMN_ORDER[col]);
} else if (row == 2) {
for (int i = 0; i < 8; i++) browser.selectPreviousFilterItem(BrowserView.COLUMN_ORDER[col]);
} else if (row == 3)
browser.selectPreviousFilterItem(BrowserView.COLUMN_ORDER[col]);
break;
}
return;
}
}
use of de.mossgrabers.framework.daw.IBrowser in project DrivenByMoss by git-moss.
the class DeviceBrowserMode method updateDisplay2.
/**
* {@inheritDoc}
*/
@Override
public void updateDisplay2() {
final IBrowser browser = this.model.getBrowser();
if (!browser.isActive()) {
this.surface.getModeManager().restoreMode();
return;
}
final PushDisplay display = (PushDisplay) this.surface.getDisplay();
final DisplayMessage message = display.createMessage();
switch(this.selectionMode) {
case DeviceBrowserMode.SELECTION_OFF:
String selectedResult = browser.getSelectedResult();
if (selectedResult == null || selectedResult.length() == 0)
selectedResult = "None";
final boolean isPresetSession = browser.isPresetContentType();
final String deviceName = this.model.getCursorDevice().getName();
for (int i = 0; i < 7; i++) {
final IBrowserColumn column = this.getFilterColumn(i);
final String headerTopName = i == 0 ? "Device: " + (deviceName.isEmpty() ? "None" : deviceName) : "";
final String headerBottomName = i == 0 && isPresetSession ? "Preset: " + selectedResult : "";
final String menuBottomName = getColumnName(column);
message.addOptionElement(headerTopName, column == null ? "" : column.getName(), i == this.filterColumn, headerBottomName, menuBottomName, !menuBottomName.equals(" "), false);
}
message.addOptionElement("", browser.getSelectedContentType(), this.filterColumn == -1, "", "", false, false);
break;
case DeviceBrowserMode.SELECTION_PRESET:
final IBrowserColumnItem[] results = browser.getResultColumnItems();
if (!results[0].doesExist()) {
for (int i = 0; i < 8; i++) message.addOptionElement(i == 3 ? "No results available..." : "", "", false, "", "", false, false);
display.send(message);
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(16) : "";
selected[item] = pos < results.length ? results[pos].isSelected() : false;
}
message.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;
String text = StringUtils.optimizeName(item[pos].getName(), 10);
if (!text.isEmpty())
text = text + " (" + item[pos].getHitCount() + ")";
items[itemIndex] = text;
selected[itemIndex] = item[pos].isSelected();
}
message.addListElement(items, selected);
}
break;
}
display.send(message);
}
use of de.mossgrabers.framework.daw.IBrowser in project DrivenByMoss by git-moss.
the class OSCParser method parseBrowser.
private void parseBrowser(final LinkedList<String> parts) {
if (parts.isEmpty()) {
this.host.println("Missing Browser command.");
return;
}
final IBrowser browser = this.model.getBrowser();
final String command = parts.removeFirst();
switch(command) {
case "preset":
browser.browseForPresets();
break;
case "tab":
if (parts.isEmpty()) {
this.host.println("Missing Browser Tab subcommand.");
return;
}
if (!browser.isActive())
return;
final String subCmd = parts.removeFirst();
if ("+".equals(subCmd))
browser.nextContentType();
else if ("-".equals(subCmd))
browser.previousContentType();
break;
case "device":
final String insertLocation = parts.isEmpty() ? null : parts.removeFirst();
if (insertLocation == null || "after".equals(insertLocation))
browser.browseToInsertAfterDevice();
else
browser.browseToInsertBeforeDevice();
break;
case "commit":
browser.stopBrowsing(true);
break;
case "cancel":
browser.stopBrowsing(false);
break;
case "filter":
if (parts.isEmpty()) {
this.host.println("Missing Browser Filter row.");
return;
}
int column = Integer.parseInt(parts.removeFirst());
if (column < 1 || column > 6)
return;
column = column - 1;
if (!browser.isActive())
return;
if (parts.isEmpty()) {
this.host.println("Missing Browser Filter command.");
return;
}
final String cmd = parts.removeFirst();
if ("+".equals(cmd))
browser.selectNextFilterItem(column);
else if ("-".equals(cmd))
browser.selectPreviousFilterItem(column);
else if (PART_RESET.equals(cmd))
browser.getFilterColumn(column).resetFilter();
break;
case "result":
if (!browser.isActive())
return;
final String direction = parts.isEmpty() ? "+" : parts.removeFirst();
if ("+".equals(direction))
browser.selectNextResult();
else
browser.selectPreviousResult();
break;
default:
this.host.println("Unknown Browser Command: " + command);
break;
}
}
Aggregations