diff --git a/CHANGELOG.md b/CHANGELOG.md index 21dbe1a4..adbba7b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ - widgets: circular value feedback issues - editor: `ctrl + e` not working when hitm multiple times without releasing `ctrl` +- widgets + - patchbay: add `in`, `out` and `both` modes to `exclusive` property + - custom module - add optional `errorCallback` argument to`loadJSON` and `saveJSON` diff --git a/src/client/managers/session/session.js b/src/client/managers/session/session.js index 7609c6a4..cfe1de6c 100644 --- a/src/client/managers/session/session.js +++ b/src/client/managers/session/session.js @@ -311,6 +311,14 @@ var converters = [ } } + }, + { + version: '1.23.0', + widget: (data)=>{ + if (data.type === 'patchbay' && data.exclusive === true) { + data.exclusive = 'in' + } + } } ] diff --git a/src/client/widgets/containers/patchbay.js b/src/client/widgets/containers/patchbay.js index eef74a1e..15698b85 100644 --- a/src/client/widgets/containers/patchbay.js +++ b/src/client/widgets/containers/patchbay.js @@ -39,10 +39,28 @@ class PatchBayNode extends Widget { } } - if (this.parent.getProp('exclusive') && this.value.length > 1) { + if ( + (this.parent.getProp('exclusive') === true + || this.parent.getProp('exclusive') === 'in' + || this.parent.getProp('exclusive') === 'both') + && this.value.length > 1 + ) { this.value = [this.value.pop()] } + if ( + (this.parent.getProp('exclusive') === 'out' || this.parent.getProp('exclusive') === 'both') + && this.value.length > 0 + ) { + for (var input of this.parent.inputsWidgets) { + if (input !== this && input.value.some(x=>this.value.includes(x))) { + input.setValue(input.value.filter(x=>!this.value.includes(x)), options) + } + } + } + + + this.parent.batchDraw() if (options.send) this.sendValue() @@ -89,7 +107,11 @@ class PatchBay extends Container(Canvas) { 'The inputs values can be consumed with the property inheritance syntax: `@{patchbay_id/input_1}` returns an array of output names connected to `input_1`' ]}, outputs: {type: 'array|object', value: ['output_1', 'output_2'], help: 'List of output values the inputs can connect to (see `inputs`).'}, - exclusive: {type: 'boolean', value: false, help: 'If set to `true`, each input will be allowed to have only one connection at a time.'}, + exclusive: {type: 'string', value: false, choices: [false, 'in', 'out', 'both'], help: [ + '- `in`: allows only one connection per input', + '- `out`: allows only one connection per output', + '- `both`: allows only one connection per input and output' + ]} } })