use of de.mossgrabers.framework.daw.IBrowser in project DrivenByMoss by git-moss.
the class DevicePresetsMode method navigatePresets.
/**
* Navigate to the next or previous result item.
*
* @param moveUp True to move up
*/
public void navigatePresets(final boolean moveUp) {
this.selectionMode = DevicePresetsMode.SELECTION_PRESET;
final IBrowser browser = this.model.getBrowser();
if (!browser.isActive())
return;
if (moveUp)
browser.selectNextResult();
else
browser.selectPreviousResult();
}
use of de.mossgrabers.framework.daw.IBrowser in project DrivenByMoss by git-moss.
the class DevicePresetsMode method updateDisplay.
/**
* {@inheritDoc}
*/
@Override
public void updateDisplay() {
final Display d = this.surface.getDisplay();
if (!this.model.hasSelectedDevice()) {
d.clearRow(2).done(2).setRow(0, " Please select a device... ");
return;
}
final IBrowser browser = this.model.getBrowser();
if (!browser.isActive()) {
d.setRow(0, " No active Browsing Session. ").setRow(2, " Press Browse again... ");
return;
}
d.clear();
String selectedResult;
switch(this.selectionMode) {
case DevicePresetsMode.SELECTION_OFF:
selectedResult = browser.getSelectedResult();
d.setBlock(0, 0, "Preset:").setBlock(2, 0, selectedResult == null ? "None" : selectedResult);
for (int i = 0; i < 6; i++) {
final IBrowserColumn column = browser.getFilterColumn(i);
d.setCell(0, 2 + i, StringUtils.shortenAndFixASCII(column.getName() + ":", 8)).setCell(2, 2 + i, column.doesCursorExist() ? column.getCursorName() : "");
}
break;
case DevicePresetsMode.SELECTION_PRESET:
final IBrowserColumnItem[] results = browser.getResultColumnItems();
for (int i = 0; i < 16; i++) d.setCell(i % 2 * 2, i / 2, (results[i].isSelected() ? SLDisplay.RIGHT_ARROW : " ") + results[i].getName());
break;
case DevicePresetsMode.SELECTION_FILTER:
final IBrowserColumnItem[] items = browser.getFilterColumn(this.filterColumn).getItems();
for (int i = 0; i < 16; i++) {
final String name = StringUtils.fixASCII(items[i].getName());
String text = (items[i].isSelected() ? SLDisplay.RIGHT_ARROW : " ") + name + " ";
if (!name.isEmpty()) {
final String hitStr = "(" + items[i].getHitCount() + ")";
text = text.substring(0, 17 - hitStr.length()) + hitStr;
}
d.setCell(i % 2 * 2, i / 2, text);
}
break;
}
d.allDone();
}
use of de.mossgrabers.framework.daw.IBrowser in project DrivenByMoss by git-moss.
the class DeviceBrowserMode method updateDisplay1.
/**
* {@inheritDoc}
*/
@Override
public void updateDisplay1(final ITextDisplay display) {
final IBrowser browser = this.model.getBrowser();
if (!browser.isActive())
return;
switch(this.selectionMode) {
case DeviceBrowserMode.SELECTION_OFF:
String selectedContentType = browser.getSelectedContentType();
if (this.filterColumn == -1)
selectedContentType = Push1Display.SELECT_ARROW + selectedContentType;
display.setCell(0, 7, selectedContentType);
display.setBlock(2, 2, "Selection:");
String selectedResult = browser.getSelectedResult();
selectedResult = selectedResult == null || selectedResult.isBlank() ? "None" : selectedResult;
String[] infoText = browser.getInfoText().split(":");
infoText = new String[] { infoText[0] + ":", infoText.length == 1 ? "" : infoText[1].trim() };
String info1 = infoText[0].length() > 17 ? infoText[0].substring(0, 17) : infoText[0];
String info2 = infoText[0].length() > 17 ? infoText[0].substring(17, infoText[0].length()) : "";
display.setBlock(2, 0, info1).setBlock(2, 1, info2);
info1 = infoText[1].length() > 17 ? infoText[1].substring(0, 17) : infoText[1];
info2 = infoText[1].length() > 17 ? infoText[1].substring(17, infoText[1].length()) : "";
display.setBlock(3, 0, info1).setBlock(3, 1, info2);
final String sel1 = selectedResult.length() > 17 ? selectedResult.substring(0, 17) : selectedResult;
final String sel2 = selectedResult.length() > 17 ? selectedResult.substring(17, selectedResult.length()) : "";
display.setBlock(3, 2, sel1).setCell(3, 6, sel2);
if (this.model.getHost().supports(Capability.HAS_BROWSER_PREVIEW)) {
display.setCell(2, 7, "Preview:");
display.setCell(3, 7, browser.isPreviewEnabled() ? "On" : "Off");
}
for (int i = 0; i < 7; i++) {
final Optional<IBrowserColumn> column = this.getFilterColumn(i);
String name = column.isEmpty() ? "" : StringUtils.shortenAndFixASCII(column.get().getName(), 8);
if (i == this.filterColumn)
name = Push1Display.SELECT_ARROW + name;
display.setCell(0, i, name).setCell(1, i, getColumnName(column));
}
break;
case DeviceBrowserMode.SELECTION_PRESET:
final IBrowserColumnItem[] results = browser.getResultColumnItems();
if (!results[0].doesExist()) {
display.clear().setBlock(1, 1, " No results").setBlock(1, 2, "available...").allDone();
return;
}
for (int i = 0; i < 16; i++) {
if (i < results.length)
display.setBlock(i % 4, i / 4, (results[i].isSelected() ? Push1Display.SELECT_ARROW : " ") + results[i].getName(16));
else
display.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() ? Push1Display.SELECT_ARROW : " ") + items[i].getName() + " ";
if (!items[i].getName().isEmpty()) {
final String hitStr = "(" + items[i].getHitCount() + ")";
text = text.substring(0, 17 - hitStr.length()) + hitStr;
}
display.setBlock(i % 4, i / 4, text);
}
break;
default:
// Not used
break;
}
}
use of de.mossgrabers.framework.daw.IBrowser in project DrivenByMoss by git-moss.
the class DeviceBrowserMode method selectNext.
private void selectNext(final int index, final int count) {
final IBrowser browser = this.model.getBrowser();
if (index < 7) {
final Optional<IBrowserColumn> fc = this.getFilterColumn(index);
if (fc.isPresent() && fc.get().doesExist()) {
final int fi = fc.get().getIndex();
if (fi < 0)
return;
this.filterColumn = fi;
for (int i = 0; i < count; i++) browser.selectNextFilterItem(this.filterColumn);
}
} else {
for (int i = 0; i < count; i++) browser.selectNextResult();
}
}
use of de.mossgrabers.framework.daw.IBrowser in project DrivenByMoss by git-moss.
the class DeviceBrowserMode method getFilterColumn.
private Optional<IBrowserColumn> getFilterColumn(final int index) {
final IBrowser browser = this.model.getBrowser();
int column = -1;
final boolean[] browserDisplayFilter = this.surface.getConfiguration().getBrowserDisplayFilter();
for (int i = 0; i < browser.getFilterColumnCount(); i++) {
if (browserDisplayFilter[i]) {
column++;
if (column == index)
return Optional.of(browser.getFilterColumn(i));
}
}
return Optional.empty();
}
Aggregations