diff --git a/CHANGELOG.md b/CHANGELOG.md index 86aaa3b3..7d72719e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## 0.28.0 + +- widgets + - matrices: support setting `split` property as a string to allow using children's indexes in their address (`$` is replaced with the index number) + ## 0.27.2 - bug fixes diff --git a/resources/docs/widgets/matrices.md b/resources/docs/widgets/matrices.md index f4a1650d..a139f10d 100644 --- a/resources/docs/widgets/matrices.md +++ b/resources/docs/widgets/matrices.md @@ -19,7 +19,7 @@ Multifader creates a row of vertical faders that respond to the same gestures. - usage: number of faders in the row, each fader will inherit its parent's properties and the following ones (where `i` is the fader's index in the row) - `id`: same as the widget's with `/i` appended to it - `label`: `i` - - `address`: same as the widget's with `/i` appended to it + - `address`: see `split` ### `start` - type: `integer` @@ -32,9 +32,12 @@ Multifader creates a row of vertical faders that respond to the same gestures. - usage: enable traversing gestures ### `split` -- type: `boolean` +- type: `boolean|string` - default: `false` -- usage: if `true`, the fader's index will be appended to the widget's osc `address`; if `false` it will be prepended to the widget's `preArgs` +- usage: + - `true`: the widget's index will be appended to the matrice's osc `address` + - `false`: it will be prepended to the widget's `preArgs` + - `string`: will be used to define the widgets' addresses, replacing dollar signs (`$`) with their respective index (to insert the actual dollar sign, it must be escaped with a backslash (`\$`)). ### `color` - type: `string|array` @@ -62,7 +65,7 @@ Multifader creates a row of vertical faders that respond to the same gestures. - usage: defines the number of columns and and rows. Each cell will contain a toggle button that will inherit its parent's properties and the following ones (where `i` is the fader's index in the row) - `id`: same as the widget's with `/i` appended to it - `label`: `i` - - `address`: same as the widget's with `/i` appended to it + - `address`: see `split` ### `start` - type: `integer` @@ -80,9 +83,12 @@ Multifader creates a row of vertical faders that respond to the same gestures. - usage: enable traversing gestures ### `split` -- type: `boolean` +- type: `boolean|string` - default: `false` -- usage: if `true`, the toggle's index will be appended to the widget's osc `address`; if `false` it will be prepended to the widget's `preArgs` +- usage: + - `true`: the widget's index will be appended to the matrice's osc `address` + - `false`: it will be prepended to the widget's `preArgs` + - `string`: will be used to define the widgets' addresses, replacing dollar signs (`$`) with their respective index (to insert the actual dollar sign, it must be escaped with a backslash (`\$`)). ### `color` - type: `string|array` @@ -110,7 +116,7 @@ Multifader creates a row of vertical faders that respond to the same gestures. - usage: defines the number of columns and and rows. Each cell will contain a push button that will inherit its parent's properties and the following ones (where `i` is the fader's index in the row) - `id`: same as the widget's with `/i` appended to it - `label`: `i` - - `address`: same as the widget's with `/i` appended to it + - `address`: see `split` ### `start` - type: `integer` @@ -128,9 +134,12 @@ Multifader creates a row of vertical faders that respond to the same gestures. - usage: enable traversing gestures ### `split` -- type: `boolean` +- type: `boolean|string` - default: `false` -- usage: if `true`, the push's index will be appended to the widget's osc `address`; if `false` it will be prepended to the widget's `preArgs` +- usage: + - `true`: the widget's index will be appended to the matrice's osc `address` + - `false`: it will be prepended to the widget's `preArgs` + - `string`: will be used to define the widgets' addresses, replacing dollar signs (`$`) with their respective index (to insert the actual dollar sign, it must be escaped with a backslash (`\$`)). ### `color` - type: `string|array` @@ -144,7 +153,7 @@ Multifader creates a row of vertical faders that respond to the same gestures. ## Keyboard -This one works pretty much like the multipush, excepts it looks like a piano keyboard ad +This one works pretty much like the multipush, excepts it looks like a piano keyboard. ```js { @@ -177,9 +186,12 @@ This one works pretty much like the multipush, excepts it looks like a piano key - usage: enable traversing gestures ### `split` -- type: `boolean` +- type: `boolean|string` - default: `false` -- usage: if `true`, the note's midi code will be appended to the widget's osc `address`; if `false` it will be prepended to the widget's `preArgs` +- usage: + - `true`: the widget's index will be appended to the matrice's osc `address` + - `false`: it will be prepended to the widget's `preArgs` + - `string`: will be used to define the widgets' addresses, replacing dollar signs (`$`) with their respective index (to insert the actual dollar sign, it must be escaped with a backslash (`\$`)). ### `options` - see push's [`options`](buttons/#push) diff --git a/src/browser/js/app/widgets/matrices/keyboard.js b/src/browser/js/app/widgets/matrices/keyboard.js index d7e84a2d..2525d8f9 100644 --- a/src/browser/js/app/widgets/matrices/keyboard.js +++ b/src/browser/js/app/widgets/matrices/keyboard.js @@ -66,10 +66,19 @@ module.exports = class Keyboard extends Matrix { data.type = 'push' data.id = this.getProp('id') + '/' + i data.label = false - data.address = this.getProp('split') ? '@{parent.address}/' + i : '@{parent.address}' - data.preArgs = this.getProp('split') ? '@{parent.preArgs}' : '#{concat(@{parent.preArgs},[' + i + '])}' data.css = '' + if (!this.getProp('split')) { + data.address = '@{parent.address}' + data.preArgs = '#{concat(@{parent.preArgs},[' + i + '])}' + } else if (typeof this.getProp('split') === 'string' && this.getProp('split')[0] === '/' && /[^\\]\$/.test(this.getProp('split'))) { + data.address = this.getProp('split').replace(/([^\\])(\$)/g,'$1' + i).replace(/\\\$/g, '$') + data.preArgs = '@{parent.preArgs}' + } else if (this.getProp('split')) { + data.address = '@{parent.address}/' + i + data.preArgs = '@{parent.preArgs}' + } + var key = parser.parse([data], this.widget, this) key.container.classList.add('not-editable') diff --git a/src/browser/js/app/widgets/matrices/multifader.js b/src/browser/js/app/widgets/matrices/multifader.js index 1784a763..b9626e00 100644 --- a/src/browser/js/app/widgets/matrices/multifader.js +++ b/src/browser/js/app/widgets/matrices/multifader.js @@ -87,10 +87,19 @@ module.exports = class Multifader extends Matrix { data.type = 'fader' data.id = this.getProp('id') + '/' + i data.label = i - data.address = this.getProp('split') ? '@{parent.address}/' + i : '@{parent.address}' - data.preArgs = this.getProp('split') ? '@{parent.preArgs}' : '#{concat(@{parent.preArgs},[' + i + '])}' data.css = '' + if (!this.getProp('split')) { + data.address = '@{parent.address}' + data.preArgs = '#{concat(@{parent.preArgs},[' + i + '])}' + } else if (typeof this.getProp('split') === 'string' && this.getProp('split')[0] === '/' && /[^\\]\$/.test(this.getProp('split'))) { + data.address = this.getProp('split').replace(/([^\\])(\$)/g,'$1' + i).replace(/\\\$/g, '$') + data.preArgs = '@{parent.preArgs}' + } else if (this.getProp('split')) { + data.address = '@{parent.address}/' + i + data.preArgs = '@{parent.preArgs}' + } + var fader = parser.parse([data], this.widget, this) fader.container.classList.add('not-editable') diff --git a/src/browser/js/app/widgets/matrices/multipush.js b/src/browser/js/app/widgets/matrices/multipush.js index 9cecc154..9b467233 100644 --- a/src/browser/js/app/widgets/matrices/multipush.js +++ b/src/browser/js/app/widgets/matrices/multipush.js @@ -66,10 +66,19 @@ module.exports = class Multipush extends Matrix { data.type = 'push' data.id = this.getProp('id') + '/' + i data.label = i - data.address = this.getProp('split') ? '@{parent.address}/' + i : '@{parent.address}' - data.preArgs = this.getProp('split') ? '@{parent.preArgs}' : '#{concat(@{parent.preArgs},[' + i + '])}' data.css = '' + if (!this.getProp('split')) { + data.address = '@{parent.address}' + data.preArgs = '#{concat(@{parent.preArgs},[' + i + '])}' + } else if (typeof this.getProp('split') === 'string' && this.getProp('split')[0] === '/' && /[^\\]\$/.test(this.getProp('split'))) { + data.address = this.getProp('split').replace(/([^\\])(\$)/g,'$1' + i).replace(/\\\$/g, '$') + data.preArgs = '@{parent.preArgs}' + } else if (this.getProp('split')) { + data.address = '@{parent.address}/' + i + data.preArgs = '@{parent.preArgs}' + } + var push = parser.parse([data], this.widget, this) push.container.classList.add('not-editable') diff --git a/src/browser/js/app/widgets/matrices/multitoggle.js b/src/browser/js/app/widgets/matrices/multitoggle.js index e145d629..4ba966e0 100644 --- a/src/browser/js/app/widgets/matrices/multitoggle.js +++ b/src/browser/js/app/widgets/matrices/multitoggle.js @@ -66,10 +66,19 @@ module.exports = class Multitoggle extends Matrix { data.type = 'toggle' data.id = this.getProp('id') + '/' + i data.label = i - data.address = this.getProp('split') ? '@{parent.address}/' + i : '@{parent.address}' - data.preArgs = this.getProp('split') ? '@{parent.preArgs}' : '#{concat(@{parent.preArgs},[' + i + '])}' data.css = '' + if (!this.getProp('split')) { + data.address = '@{parent.address}' + data.preArgs = '#{concat(@{parent.preArgs},[' + i + '])}' + } else if (typeof this.getProp('split') === 'string' && this.getProp('split')[0] === '/' && /[^\\]\$/.test(this.getProp('split'))) { + data.address = this.getProp('split').replace(/([^\\])(\$)/g,'$1' + i).replace(/\\\$/g, '$') + data.preArgs = '@{parent.preArgs}' + } else if (this.getProp('split')) { + data.address = '@{parent.address}/' + i + data.preArgs = '@{parent.preArgs}' + } + var toggle = parser.parse([data], this.widget, this) toggle.container.classList.add('not-editable')