matrices: support setting split property as a string to allow using children's indexes in their address ($ is replaced with the index number) (#250)

This commit is contained in:
jean-emmanuel 2018-03-22 12:43:35 +01:00
parent fbad6391cd
commit 77a48d5c8e
6 changed files with 73 additions and 20 deletions

View file

@ -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

View file

@ -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)

View file

@ -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')

View file

@ -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')

View file

@ -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')

View file

@ -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')