From c7f6965c72fd83d7975ff2df1ca0ea0884a611c2 Mon Sep 17 00:00:00 2001 From: bordun Date: Fri, 31 Jan 2020 14:18:42 +0100 Subject: [PATCH] docs: add tab & root, fix default value display --- resources/docs/docs/widgets-reference.md | 83 ++++++++++++++++------- scripts/build-widgets-reference.js | 7 +- src/client/app/widgets/containers/root.js | 6 ++ src/client/app/widgets/containers/tab.js | 9 ++- 4 files changed, 78 insertions(+), 27 deletions(-) diff --git a/resources/docs/docs/widgets-reference.md b/resources/docs/docs/widgets-reference.md index 46098d23..153b8559 100644 --- a/resources/docs/docs/widgets-reference.md +++ b/resources/docs/docs/widgets-reference.md @@ -54,7 +54,7 @@ |

snap#

| `boolean` | false | By default, dragging the widget will modify it's value starting from its last value. Setting this to `true` will make it snap directly to the mouse/touch position | |

spring#

| `boolean` | false | When set to `true`, the widget will go back to its `default` value when released | |

doubleTap#

| `boolean` | false | Set to `true` to make the fader reset to its `default` value when receiving a double tap.

Can also be an osc address, in which case the widget will just send an osc message (`/ `) | -|

range#

| `object` | {
 "min": 0,
 "max": 1
}
| Defines the breakpoints of the fader's scale:
- keys can be percentages and/or `min` / `max`
- values can be `number` or `object` if a custom label is needed

Example: (`{min:{"-inf": 0}, "50%": 0.25, max: {"+inf": 1}}`) | +|

range#

| `object` | \{
 "min": 0,
 "max": 1
}
| Defines the breakpoints of the fader's scale:
- keys can be percentages and/or `min` / `max`
- values can be `number` or `object` if a custom label is needed

Example: (`{min:{"-inf": 0}, "50%": 0.25, max: {"+inf": 1}}`) | |

logScale#

| `boolean`|
`number` | false | Set to `true` to use logarithmic scale (base 10). Set to a `number` to define the logarithm's base. | |

sensitivity#

| `number` | 1 | Defines the fader's sensitivity when `snap` is `false` | |

steps#

| `string`|
`number`|
`array` | "" | Restricts the widget's value:
- `auto`: use values defined in `range`
- `number`: define a number of evenly spaced steps
- `array`: use arbitrary values | @@ -85,7 +85,7 @@ |

snap#

| `boolean` | false | By default, dragging the widget will modify it's value starting from its last value. Setting this to `true` will make it snap directly to the mouse/touch position | |

spring#

| `boolean` | false | When set to `true`, the widget will go back to its `default` value when released | |

doubleTap#

| `boolean` | false | Set to `true` to make the knob reset to its `default` value when receiving a double tap.

Can also be an osc address, in which case the widget will just send an osc message (`/ `) | -|

range#

| `object` | {
 "min": 0,
 "max": 1
}
| Defines the breakpoints of the fader's scale:
- keys can be percentages and/or `min` / `max`
- values can be `number` or `object` if a custom label is needed

Example: (`{min:{"-inf": 0}, "50%": 0.25, max: {"+inf": 1}}`) | +|

range#

| `object` | \{
 "min": 0,
 "max": 1
}
| Defines the breakpoints of the fader's scale:
- keys can be percentages and/or `min` / `max`
- values can be `number` or `object` if a custom label is needed

Example: (`{min:{"-inf": 0}, "50%": 0.25, max: {"+inf": 1}}`) | |

logScale#

| `boolean`|
`number` | false | Set to `true` to use logarithmic scale (base 10). Set to a `number` to define the logarithm's base. | |

sensitivity#

| `number` | 1 | Defines the knob's sensitivity when `snap` is `false` | |

steps#

| `string`|
`number`|
`array` | "" | Restricts the widget's value:
- `auto`: use values defined in `range`
- `number`: define a number of evenly spaced steps
- `array`: use arbitrary values | @@ -128,7 +128,7 @@ |

style#

|||| |

css#

| `string` | "" | Available CSS variables:
- `--color-gauge: color;`
- `--color-knob: color;`
- `--color-pips: color;`
- `--gauge-opacity: number;` | |

range#

|||| -|

range#

| `object` | {
 "min": 0,
 "max": 1
}
| See fader's `range` | +|

range#

| `object` | \{
 "min": 0,
 "max": 1
}
| See fader's `range` | |

horizontal#

| `boolean` | false | See fader's `horizontal` | |

alignRight#

| `boolean` | false | See fader's `alignRight` | |

input#

| `boolean` | true | See fader's `input` | @@ -189,7 +189,7 @@ |

switch#

|||| |

horizontal#

| `boolean` | false | Set to `true` to display values horizontally | |

showValues#

| `boolean` | false | If values is an object, set to `true` to display both values and labels instead of labels only | -|

values#

| `array`|
`object` | {
 "Value 1": 1,
 "Value 2": 2
}
| `Array` of possible values to switch between : `[1,2,3]`

`Object` of `"label":value` pairs. Numeric labels must be prepended or appended with a white space (or any other non-numeric character) otherwise the order of the values won't be kept | +|

values#

| `array`|
`object` | \{
 "Value 1": 1,
 "Value 2": 2
}
| `Array` of possible values to switch between : `[1,2,3]`

`Object` of `"label":value` pairs. Numeric labels must be prepended or appended with a white space (or any other non-numeric character) otherwise the order of the values won't be kept | |

traversing#

| `boolean` | true | Set to `false` to disable traversing gestures | @@ -203,7 +203,7 @@ | property | type |default | description | | --- | --- | --- | --- | | |||| -| | `array`|
`object` | {
 "Value 1": 1,
 "Value 2": 2
}
| `Array` of possible values to switch between : `[1,2,3]`

`Object` of label:value pairs. Numeric labels must be prepended or appended with a white space (or any other non-numeric character) otherwise the order of the values won't be kept

An empty option will always be prepended to values (sends an osc message without any value); it can be hidden by adding `option:first-child{display:none}` to the widget's `css` | +| | `array`|
`object` | \{
 "Value 1": 1,
 "Value 2": 2
}
| `Array` of possible values to switch between : `[1,2,3]`

`Object` of label:value pairs. Numeric labels must be prepended or appended with a white space (or any other non-numeric character) otherwise the order of the values won't be kept

An empty option will always be prepended to values (sends an osc message without any value); it can be hidden by adding `option:first-child{display:none}` to the widget's `css` | @@ -222,7 +222,7 @@ | | `boolean`|
`number` | false | - If `circular` is `false`, set this to `true` for grid layout
- Can be a `number` to define the number of columns | | | `boolean` | false | Set to `true` to make the menu stay opened after mouse/touch release | | | `boolean` | false | Set to `true` to make the menu require a double tap to be opened instead of a single tap | -| | `array`|
`object` | {
 "Value 1": 1,
 "Value 2": 2
}
| `Array` of possible values to switch between : `[1,2,3]`

`Object` of label:value pairs. Numeric labels must be prepended or appended with a white space (or any other non-numeric character) otherwise the order of the values won't be kept | +| | `array`|
`object` | \{
 "Value 1": 1,
 "Value 2": 2
}
| `Array` of possible values to switch between : `[1,2,3]`

`Object` of label:value pairs. Numeric labels must be prepended or appended with a white space (or any other non-numeric character) otherwise the order of the values won't be kept | | | `array` | "" | `Array` of `number` defining the weights of each value in `values`

Ignored when `grid` is `true` | @@ -244,8 +244,8 @@ |

snap#

| `boolean` | false | By default, the points are dragged from their initial position.

If set to `true`, touching anywhere on the widget's surface will make them snap to the touching coordinates | |

spring#

| `boolean` | false | When set to `true`, the widget will go back to its default value when released | |

pips#

| `boolean` | true | Set to `false` to hide the scale | -|

rangeX#

| `object` | {
 "min": 0,
 "max": 1
}
| Defines the min and max values for the x axis | -|

rangeY#

| `object` | {
 "min": 0,
 "max": 1
}
| Defines the min and max values for the y axis | +|

rangeX#

| `object` | \{
 "min": 0,
 "max": 1
}
| Defines the min and max values for the x axis | +|

rangeY#

| `object` | \{
 "min": 0,
 "max": 1
}
| Defines the min and max values for the y axis | |

logScaleX#

| `boolean`|
`number` | false | Set to `true` to use logarithmic scale for the x axis (base 10). Set to a `number` to define the logarithm's base. | |

logScaleY#

| `boolean`|
`number` | false | Set to `true` to use logarithmic scale for the y axis (base 10). Set to a `number` to define the logarithm's base. | |

input#

| `boolean` | true | Set to false to hide the built-in input widget | @@ -268,7 +268,7 @@ |

rgb#

|||| |

snap#

| `boolean` | false | By default, the points are dragged from their initial position.

If set to `true`, touching anywhere on the widget's surface will make them snap to the touching coordinates | |

spring#

| `boolean` | false | When set to `true`, the widget will go back to its default value when released | -|

range#

| `object` | {
 "min": 0,
 "max": 255
}
| Defines the widget's output scale. | +|

range#

| `object` | \{
 "min": 0,
 "max": 255
}
| Defines the widget's output scale. | |

input#

| `boolean` | true | Set to `false` to hide the built-in input widget | |

alpha#

| `boolean` | false | Set to `true` to enable alpha channel | |

osc#

|||| @@ -293,8 +293,8 @@ |

snap#

| `boolean` | false | By default, the points are dragged from their initial position.

If set to `true`, touching anywhere on the widget's surface will make them snap to the touching coordinates | |

spring#

| `boolean` | false | When set to `true`, the widget will go back to its default value when released | |

pips#

| `boolean` | true | Set to `false` to hide the scale | -|

rangeX#

| `object` | {
 "min": 0,
 "max": 1
}
| Defines the min and max values for the x axis | -|

rangeY#

| `object` | {
 "min": 0,
 "max": 1
}
| Defines the min and max values for the y axis | +|

rangeX#

| `object` | \{
 "min": 0,
 "max": 1
}
| Defines the min and max values for the x axis | +|

rangeY#

| `object` | \{
 "min": 0,
 "max": 1
}
| Defines the min and max values for the y axis | |

logScaleX#

| `boolean`|
`number` | false | Set to `true` to use logarithmic scale for the x axis (base 10). Set to a `number` to define the logarithm's base. | |

logScaleY#

| `boolean`|
`number` | false | Set to `true` to use logarithmic scale for the y axis (base 10). Set to a `number` to define the logarithm's base. | |

sensitivity#

| `number` | 1 | Defines the pad's sensitivity when `snap` is `false` | @@ -321,7 +321,7 @@ |

spacing#

| `integer` | 0 | Adds space between widgets | |

traversing#

| `boolean` | true | Set to `false` to disable traversing gestures | |

border#

| `boolean` | true | Set to `false` to disables the widgets' borders | -|

props#

| `object` | {} | Defines a set of property to override the widgets' defaults.

Formulas in this field are resolved with an extra variable representing each widget's index: `$`

Note: by default, the widgets inherit from the matrix' `id` and osc properties (`id` and `address` are appended with `/$`) | +|

props#

| `object` | \{} | Defines a set of property to override the widgets' defaults.

Formulas in this field are resolved with an extra variable representing each widget's index: `$`

Note: by default, the widgets inherit from the matrix' `id` and osc properties (`id` and `address` are appended with `/$`) | @@ -374,8 +374,8 @@ | property | type |default | description | | --- | --- | --- | --- | |

plot#

|||| -|

rangeX#

| `object` | {
 "min": 0,
 "max": 1
}
| Defines the min and max values for the x axis | -|

rangeY#

| `object` | {
 "min": 0,
 "max": 1
}
| Defines the min and max values for the y axis | +|

rangeX#

| `object` | \{
 "min": 0,
 "max": 1
}
| Defines the min and max values for the x axis | +|

rangeY#

| `object` | \{
 "min": 0,
 "max": 1
}
| Defines the min and max values for the y axis | |

logScaleX#

| `boolean`|
`number` | false | Set to `true` to use logarithmic scale for the x axis (base 10). Set to a `number` to define the logarithm's base. | |

logScaleY#

| `boolean`|
`number` | false | Set to `true` to use logarithmic scale for the y axis (base 10). Set to a `number` to define the logarithm's base. | |

origin#

| `number` | "auto" | Defines the y axis origin. Set to `false` to disable it. | @@ -399,7 +399,7 @@ |

eq#

|||| |

pips#

| `boolean` | true | Set to false to hide the scale | |

resolution#

| `number` | 128 | Defines the number of points used to compute the frequency response | -|

rangeY#

| `object` | {
 "min": 0,
 "max": 1
}
| Defines the min and max values for the y axis | +|

rangeY#

| `object` | \{
 "min": 0,
 "max": 1
}
| Defines the min and max values for the y axis | |

origin#

| `number`|
`boolean` | "auto" | Defines the y axis origin. Set to `false` to disable it | |

logScaleX#

| `boolean`|
`number` | false | Set to `true` to use logarithmic scale for the x axis (base 10). Set to a `number` to define the logarithm's base. | |

smooth#

| `boolean`|
`number` | false | Set to `true` to make the line smooth. Float values are also acceptable (works fine between `0` and `0.5`) | @@ -418,7 +418,7 @@ | --- | --- | --- | --- | |

visualizer#

|||| |

duration#

| `number` | 1 | Defines visualization duration in seconds | -|

range#

| `object` | {
 "min": 0,
 "max": 1
}
| Defines the min and max values for the y axis | +|

range#

| `object` | \{
 "min": 0,
 "max": 1
}
| Defines the min and max values for the y axis | |

origin#

| `number` | "auto" | Defines the y axis origin. Set to `false` to disable it | |

logScale#

| `boolean`|
`number` | false | Set to `true` to use logarithmic scale for the y axis (base 10). Set to a `number` to define the logarithm's base. | |

smooth#

| `boolean`|
`number` | false | Set to `true` to make the line smooth. Float values are also acceptable (works fine between `0` and `0.5`) | @@ -435,7 +435,7 @@ | property | type |default | description | | --- | --- | --- | --- | |

led#

|||| -|

range#

| `object` | {
 "min": 0,
 "max": 1
}
| Value to led intensity mapping range | +|

range#

| `object` | \{
 "min": 0,
 "max": 1
}
| Value to led intensity mapping range | |

logScale#

| `boolean`|
`number` | false | Set to `true` to use logarithmic scale (base 10). Set to a `number` to define the logarithm's base. | @@ -464,7 +464,7 @@ |

style#

|||| |

css#

| `string` | "" | Available CSS variables:
- `--color-gauge: color;`
- `--color-knob: color;`
- `--color-pips: color;`
- `--gauge-opacity: number;` | |

meter#

|||| -|

range#

| `object` | {
 "min": 0,
 "max": 1
}
| See fader's `range` | +|

range#

| `object` | \{
 "min": 0,
 "max": 1
}
| See fader's `range` | |

logScale#

| `boolean` | false | See fader's `logScale` | |

origin#

| `number` | "auto" | See fader's `origin` | |

unit#

| `string` | "auto" | See fader's `unit` | @@ -571,7 +571,7 @@ |

value#

|||| |

value#

| `integer` | "" | Defines currently opened tab in the widget

A tab can be opened only by setting its parent's value | |

children#

|||| -|

variables#

| `*` | "@{parent.variables}" | Defines one or more arbitrary variables that can be inherited by children widgets | +|

variables#

| `*` | "@\{parent.variables}" | Defines one or more arbitrary variables that can be inherited by children widgets | |

widgets#

| `array` | [] | Each element of the array must be a widget object. A panel cannot contain widgets and tabs simultaneously. | |

tabs#

| `array` | [] | Each element of the array must be a tab object. A panel cannot contain widgets and tabs simultaneously | @@ -592,7 +592,7 @@ |

border#

| `boolean` | true | By default, widgets in panels/strip have their border disabled, except for panels and strips. Set to `false` to apply this rule to the panel too | |

spacing#

| `integer`|
`percentage` | 0 | Adds space between widgets. Percents are always relative to the strips width | |

children#

|||| -|

variables#

| `*` | "@{parent.variables}" | Defines one or more arbitrary variables that can be inherited by children widgets | +|

variables#

| `*` | "@\{parent.variables}" | Defines one or more arbitrary variables that can be inherited by children widgets | |

widgets#

| `array` | [] | Each element of the array must be a widget object
- By default, children widgets that don't have an explicit `width`/`height` set will be shrinked to respect the sizes specified by others
- Adding `flex:1;` to a children's `css` will give it the ability the fill the remaining space
- Multiple children can have a `flex:x;` css property (`x` will ponderate their expansion) | @@ -616,7 +616,7 @@ | |||| | | `integer` | "" | Defines the modal's state:`0` for closed, `1` for opened | | |||| -| | `*` | "@{parent.variables}" | Defines one or more arbitrary variables that can be inherited by children widgets | +| | `*` | "@\{parent.variables}" | Defines one or more arbitrary variables that can be inherited by children widgets | | | `array` | [] | Each element of the array must be a widget object | @@ -632,7 +632,44 @@ |

clone#

|||| |

widgetId#

| `string` | "" | `id` of the widget to clone | |

overrides#

|||| -|

props#

| `object` | {} | Cloned widget's properties to override | +|

props#

| `object` | \{} | Cloned widget's properties to override | + + + + +
+ + +
Main (unique) container
+ +| property | type |default | description | +| --- | --- | --- | --- | +|

id#

| `string` | "root" | Widgets sharing the same id will act as clones and update each other's value(s) without sending extra osc messages | +|

value#

|||| +|

value#

| `integer` | "" | Defines currently opened tab in the widget

A tab can be opened only by setting its parent's value | +|

children#

|||| +|

traversing#

| `boolean` | false | Set to `true` to enable traversing gestures in this widget. Set to `smart` or `auto` to limit affected widgets by the type of the first touched widget | +|

variables#

| `*` | \{} | Defines one or more arbitrary variables that can be inherited by children widgets | +|

tabs#

| `array` | [
 \{}
]
| Each element of the array must be a tab object |
+ + + + +
+ + +
Tabbed panel widget
+ +| property | type |default | description | +| --- | --- | --- | --- | +|

tab#

|||| +|

detached#

| `boolean` | true | Set to `false` if the tab contains `frame` widgets that should not be reloaded when the tab open | +|

value#

|||| +|

value#

| `integer` | "" | Defines currently opened tab in the widget

A tab can be opened only by setting its parent's value | +|

children#

|||| +|

variables#

| `*` | "@\{parent.variables}" | Defines one or more arbitrary variables that can be inherited by children widgets | +|

widgets#

| `array` | [] | Each element of the array must be a widget object. A tab cannot contain widgets and tabs simultaneously | +|

tabs#

| `array` | [] | Each element of the array must be a tab object. A tab cannot contain widgets and tabs simultaneously |
@@ -667,7 +704,7 @@ |

switcher#

|||| |

linkedWidgets#

| `string`|
`array` | "" | - `String`: a widget's `id` whose state changes will be stored
- `Array`: a list of widget `id` string | |

horizontal#

| `boolean` | false | Set to `true` to display values horizontally | -|

values#

| `array`|
`object` | {
 "Value 1": 1,
 "Value 2": 2
}
| Each item represents a bank that stores the values from the widgets listed in `linkedWidgets`
- `Array` of possible values to switch between : `[1,2,3]`
- `Object` of `"label":value` pairs. Numeric labels must be prepended or appended with a white space (or any other non-numeric character) otherwise the order of the values won't be kept | +|

values#

| `array`|
`object` | \{
 "Value 1": 1,
 "Value 2": 2
}
| Each item represents a bank that stores the values from the widgets listed in `linkedWidgets`
- `Array` of possible values to switch between : `[1,2,3]`
- `Object` of `"label":value` pairs. Numeric labels must be prepended or appended with a white space (or any other non-numeric character) otherwise the order of the values won't be kept | diff --git a/scripts/build-widgets-reference.js b/scripts/build-widgets-reference.js index fe1e1ed0..346d2cf6 100644 --- a/scripts/build-widgets-reference.js +++ b/scripts/build-widgets-reference.js @@ -47,9 +47,12 @@ for (var propName in base) { doc.push('') - for (var k in widgets.categories) { var category = widgets.categories[k] + if (k == 'Containers') { + category.push('root') + category.push('tab') + } doc.push(` @@ -94,7 +97,7 @@ for (var k in widgets.categories) { dynamic = widgets.widgets[type].dynamicProps.includes(propName) ? '' : '' doc.push(` - |

${propName}${dynamic}#

| \`${prop.type.replace(/\|/g,'\`|
\`')}\` | ${(JSON.stringify(prop.value, null, ' ') || '').replace(/\n/g,'
')}
| ${help} |` + |

${propName}${dynamic}#

| \`${prop.type.replace(/\|/g,'\`|
\`')}\` | ${(JSON.stringify(prop.value, null, ' ') || '').replace(/\n/g,'
').replace('{','\\{')}
| ${help} |` ) separator = false } diff --git a/src/client/app/widgets/containers/root.js b/src/client/app/widgets/containers/root.js index 3985525c..df63ccfc 100644 --- a/src/client/app/widgets/containers/root.js +++ b/src/client/app/widgets/containers/root.js @@ -7,6 +7,12 @@ var Panel = require('./panel'), class Root extends Panel { + static description() { + + return 'Main (unique) container' + + } + static defaults() { return Widget.defaults({}, ['label', '_geometry', 'left', 'top', 'width', 'height'], { diff --git a/src/client/app/widgets/containers/tab.js b/src/client/app/widgets/containers/tab.js index e822a8c5..0e035f6b 100644 --- a/src/client/app/widgets/containers/tab.js +++ b/src/client/app/widgets/containers/tab.js @@ -4,14 +4,19 @@ var Panel = require('./panel'), module.exports = class Tab extends Panel { + static description() { + + return 'Tabbed panel widget' + + } + static defaults() { return Widget.defaults({ _tab:'tab', - detached: {type: 'boolean', value: true, help: [ - ]} + detached: {type: 'boolean', value: true, help: 'Set to `false` if the tab contains `frame` widgets that should not be reloaded when the tab open '} }, ['_geometry', 'left', 'top', 'width', 'height'], {