Search in sources :

Example 1 with IBrowserColumnItem

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 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);
}
Also used : IBrowser(de.mossgrabers.framework.daw.IBrowser) IBrowserColumnItem(de.mossgrabers.framework.daw.data.IBrowserColumnItem) PushDisplay(de.mossgrabers.push.controller.PushDisplay) IBrowserColumn(de.mossgrabers.framework.daw.data.IBrowserColumn) DisplayMessage(de.mossgrabers.push.controller.DisplayMessage)

Example 2 with IBrowserColumnItem

use of de.mossgrabers.framework.daw.data.IBrowserColumnItem 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();
}
Also used : IBrowser(de.mossgrabers.framework.daw.IBrowser) IBrowserColumnItem(de.mossgrabers.framework.daw.data.IBrowserColumnItem) IBrowserColumn(de.mossgrabers.framework.daw.data.IBrowserColumn) Display(de.mossgrabers.framework.controller.display.Display) SLDisplay(de.mossgrabers.sl.controller.SLDisplay)

Example 3 with IBrowserColumnItem

use of de.mossgrabers.framework.daw.data.IBrowserColumnItem in project DrivenByMoss by git-moss.

the class DevicePresetsMode method updateDisplay.

/**
 * {@inheritDoc}
 */
@Override
public void updateDisplay() {
    final ITextDisplay d = this.surface.getTextDisplay().clear();
    if (!this.model.hasSelectedDevice()) {
        d.setRow(0, "                       Please select a device...                       ");
        d.done(0).done(1);
        return;
    }
    final IBrowser browser = this.model.getBrowser();
    if (!browser.isActive()) {
        d.setRow(0, "                     No active Browsing Session.                       ");
        d.setRow(1, "                        Press Browse again...                          ");
        d.done(0).done(1);
        return;
    }
    String selectedResult;
    switch(this.selectionMode) {
        case DevicePresetsMode.SELECTION_OFF:
            selectedResult = browser.getSelectedResult();
            d.setBlock(0, 0, "Preset:").setBlock(1, 0, selectedResult == null ? "None" : selectedResult);
            for (int i = 0; i < 6; i++) {
                final IBrowserColumn column = browser.getFilterColumn(i);
                final String columnName = column.doesExist() ? StringUtils.shortenAndFixASCII(column.getName() + ":", 8) : "";
                d.setCell(0, 2 + i, columnName).setCell(1, 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, 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, i / 2, text);
            }
            break;
        default:
            // Not used
            break;
    }
    d.done(0).done(1);
}
Also used : IBrowser(de.mossgrabers.framework.daw.IBrowser) IBrowserColumnItem(de.mossgrabers.framework.daw.data.IBrowserColumnItem) IBrowserColumn(de.mossgrabers.framework.daw.data.IBrowserColumn) ITextDisplay(de.mossgrabers.framework.controller.display.ITextDisplay)

Example 4 with IBrowserColumnItem

use of de.mossgrabers.framework.daw.data.IBrowserColumnItem in project DrivenByMoss by git-moss.

the class BrowseMode method updateDisplay.

/**
 * {@inheritDoc}
 */
@Override
public void updateDisplay() {
    final ITextDisplay d = this.surface.getTextDisplay();
    final IBrowser browser = this.model.getBrowser();
    if (!browser.isActive())
        return;
    d.clear();
    String selectedResult;
    switch(this.selectionMode) {
        case BrowseMode.SELECTION_OFF:
            d.setCell(0, 0, "BROWSE").setCell(1, 0, browser.getSelectedContentType().toUpperCase(Locale.US));
            selectedResult = browser.getSelectedResult();
            d.setCell(0, 8, "SELECTED").setCell(1, 8, selectedResult == null ? "NONE" : selectedResult);
            for (int i = 0; i < 7; i++) {
                final IBrowserColumn column = browser.getFilterColumn(i);
                d.setCell(0, 1 + i, StringUtils.shortenAndFixASCII(column.getName() + ":", 8).toUpperCase(Locale.US)).setCell(1, 1 + i, column.doesCursorExist() ? column.getCursorName().toUpperCase(Locale.US) : "");
            }
            break;
        case BrowseMode.SELECTION_PRESET:
            d.setCell(0, 0, "SELECTED");
            final IBrowserColumnItem[] results = browser.getResultColumnItems();
            for (int i = 0; i < 16; i++) d.setCell(i % 2, 1 + i / 2, (results[i].isSelected() ? ">" : " ") + results[i].getName().toUpperCase(Locale.US));
            break;
        case BrowseMode.SELECTION_FILTER:
            final IBrowserColumn fc = browser.getFilterColumn(this.filterColumn);
            d.setCell(0, 0, fc.getName().toUpperCase(Locale.US));
            final IBrowserColumnItem[] items = fc.getItems();
            for (int i = 0; i < 16; i++) {
                final String name = items[i].getName().toUpperCase(Locale.US);
                final String text = (items[i].isSelected() ? ">" : " ") + name;
                d.setCell(i % 2, 1 + i / 2, text);
            }
            break;
        default:
            // No more modes
            break;
    }
    d.allDone();
}
Also used : IBrowser(de.mossgrabers.framework.daw.IBrowser) IBrowserColumnItem(de.mossgrabers.framework.daw.data.IBrowserColumnItem) IBrowserColumn(de.mossgrabers.framework.daw.data.IBrowserColumn) ITextDisplay(de.mossgrabers.framework.controller.display.ITextDisplay)

Example 5 with IBrowserColumnItem

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 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;
    }
}
Also used : IBrowser(de.mossgrabers.framework.daw.IBrowser) IBrowserColumnItem(de.mossgrabers.framework.daw.data.IBrowserColumnItem) IBrowserColumn(de.mossgrabers.framework.daw.data.IBrowserColumn)

Aggregations

IBrowserColumnItem (de.mossgrabers.framework.daw.data.IBrowserColumnItem)15 IBrowserColumn (de.mossgrabers.framework.daw.data.IBrowserColumn)13 IBrowser (de.mossgrabers.framework.daw.IBrowser)11 Display (de.mossgrabers.framework.controller.display.Display)3 ITextDisplay (de.mossgrabers.framework.controller.display.ITextDisplay)3 PushDisplay (de.mossgrabers.push.controller.PushDisplay)2 ColorEx (de.mossgrabers.framework.controller.color.ColorEx)1 ICursorDevice (de.mossgrabers.framework.daw.ICursorDevice)1 ICursorDevice (de.mossgrabers.framework.daw.data.ICursorDevice)1 DisplayMessage (de.mossgrabers.push.controller.DisplayMessage)1 SLDisplay (de.mossgrabers.sl.controller.SLDisplay)1