Search in sources :

Example 36 with IBrowser

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

the class BrowserMode method setValue.

/**
 * {@inheritDoc}
 */
@Override
public void setValue(final int index, final int value) {
    final IBrowser browser = this.model.getBrowser();
    if (!browser.isActive())
        return;
    final int diff = value - this.lastValue;
    final boolean isLeft = value == 0 || diff < 0;
    this.lastValue = value;
    switch(index) {
        case 0:
        case 1:
        case 2:
        case 3:
        case 4:
        case 5:
        case 6:
            if (isLeft)
                browser.selectPreviousFilterItem(BrowserMode.COLUMN_ORDER[index]);
            else
                browser.selectNextFilterItem(BrowserMode.COLUMN_ORDER[index]);
            break;
        case 7:
            if (isLeft)
                browser.selectPreviousResult();
            else
                browser.selectNextResult();
            break;
        default:
            // Not used
            break;
    }
}
Also used : IBrowser(de.mossgrabers.framework.daw.IBrowser)

Example 37 with IBrowser

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

the class BrowserMode method updateDisplay.

/**
 * {@inheritDoc}
 */
@Override
public void updateDisplay() {
    final IBrowser browser = this.model.getBrowser();
    if (!browser.isActive())
        return;
    final String[] rows = new String[3];
    final boolean[] sels = new boolean[] { false, false, false };
    final IGraphicDisplay display = this.surface.getGraphicsDisplay();
    final int idx = this.getTouchedKnob();
    if (idx < 0) {
        final String selectedResult = browser.getSelectedResult();
        rows[0] = browser.getSelectedContentType().toUpperCase(Locale.US);
        rows[1] = "Selection: ";
        rows[2] = selectedResult == null || selectedResult.isBlank() ? "None" : selectedResult;
    } else if (idx == 8) {
        final IBrowserColumnItem[] results = browser.getResultColumnItems();
        if (results[0].doesExist()) {
            for (int item = 0; item < 3; item++) {
                rows[item] = item < results.length ? results[item].getName() : "";
                sels[item] = item < results.length && results[item].isSelected();
            }
        } else {
            rows[0] = "No";
            rows[1] = "results ";
            rows[2] = "available...";
        }
    } else {
        final IBrowserColumn filterColumn = browser.getFilterColumn(idx);
        if (filterColumn.doesExist() && filterColumn.doesCursorExist()) {
            final IBrowserColumnItem[] item = filterColumn.getItems();
            for (int itemIndex = 0; itemIndex < 3; itemIndex++) {
                final int pos = itemIndex;
                String text = StringUtils.optimizeName(item[pos].getName(), 10);
                if (!text.isEmpty())
                    text = text + " (" + item[pos].getHitCount() + ")";
                rows[itemIndex] = text;
                sels[itemIndex] = item[pos].isSelected();
            }
        } else {
            rows[0] = "";
            rows[1] = "";
            rows[2] = "";
        }
    }
    display.addListElement(rows, sels);
    display.send();
}
Also used : IBrowser(de.mossgrabers.framework.daw.IBrowser) IGraphicDisplay(de.mossgrabers.framework.controller.display.IGraphicDisplay) IBrowserColumn(de.mossgrabers.framework.daw.data.IBrowserColumn)

Example 38 with IBrowser

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())
        return;
    switch(note) {
        // Cancel
        case 36:
            if (velocity == 0)
                return;
            browser.stopBrowsing(false);
            this.surface.getViewManager().restore();
            break;
        // OK
        case 43:
            if (velocity == 0)
                return;
            browser.stopBrowsing(true);
            this.surface.getViewManager().restore();
            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;
        default:
            // Not used
            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;
        }
    }
}
Also used : IBrowser(de.mossgrabers.framework.daw.IBrowser)

Example 39 with IBrowser

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

Example 40 with IBrowser

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

the class DeviceBrowserMode method selectPrevious.

private void selectPrevious(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 j = 0; j < count; j++) browser.selectPreviousFilterItem(this.filterColumn);
        }
    } else {
        for (int j = 0; j < count; j++) browser.selectPreviousResult();
    }
}
Also used : IBrowser(de.mossgrabers.framework.daw.IBrowser) IBrowserColumn(de.mossgrabers.framework.daw.data.IBrowserColumn)

Aggregations

IBrowser (de.mossgrabers.framework.daw.IBrowser)49 IBrowserColumn (de.mossgrabers.framework.daw.data.IBrowserColumn)21 IBrowserColumnItem (de.mossgrabers.framework.daw.data.IBrowserColumnItem)11 ICursorDevice (de.mossgrabers.framework.daw.data.ICursorDevice)5 ITextDisplay (de.mossgrabers.framework.controller.display.ITextDisplay)4 ViewManager (de.mossgrabers.framework.view.ViewManager)4 Display (de.mossgrabers.framework.controller.display.Display)3 ICursorDevice (de.mossgrabers.framework.daw.ICursorDevice)3 ITrack (de.mossgrabers.framework.daw.data.ITrack)3 IChannelBank (de.mossgrabers.framework.daw.IChannelBank)2 ViewManager (de.mossgrabers.framework.featuregroup.ViewManager)2 PushDisplay (de.mossgrabers.push.controller.PushDisplay)2 SLMkIIIDisplay (de.mossgrabers.controller.novation.slmkiii.controller.SLMkIIIDisplay)1 ParametersMode (de.mossgrabers.controller.novation.slmkiii.mode.device.ParametersMode)1 UnknownCommandException (de.mossgrabers.controller.osc.exception.UnknownCommandException)1 ColorEx (de.mossgrabers.framework.controller.color.ColorEx)1 IGraphicDisplay (de.mossgrabers.framework.controller.display.IGraphicDisplay)1 ILayer (de.mossgrabers.framework.daw.data.ILayer)1 IMasterTrack (de.mossgrabers.framework.daw.data.IMasterTrack)1 ModeManager (de.mossgrabers.framework.featuregroup.ModeManager)1