From 94a6943958d6fe4388c3daab65799a2b2eaa6caa Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Thu, 11 Apr 2019 18:47:11 +0200 Subject: [PATCH] docs; add widget class static description --- resources/docs/docs/widgets-reference.md | 72 +++++++++++++++++++ scripts/build-widgets-reference.js | 3 + src/client/app/widgets/common/widget.js | 6 ++ src/client/app/widgets/containers/clone.js | 6 ++ src/client/app/widgets/containers/modal.js | 6 ++ src/client/app/widgets/containers/panel.js | 6 ++ src/client/app/widgets/containers/strip.js | 6 ++ src/client/app/widgets/inputs/file.js | 6 ++ src/client/app/widgets/inputs/gyroscope.js | 6 ++ src/client/app/widgets/inputs/input.js | 8 ++- src/client/app/widgets/inputs/keys.js | 6 ++ src/client/app/widgets/inputs/script.js | 6 ++ src/client/app/widgets/matrices/keyboard.js | 6 ++ src/client/app/widgets/matrices/matrix.js | 6 ++ src/client/app/widgets/matrices/patchbay.js | 6 ++ src/client/app/widgets/pads/multixy.js | 6 ++ src/client/app/widgets/pads/rgb.js | 6 ++ src/client/app/widgets/pads/xy.js | 6 ++ src/client/app/widgets/plots/eq.js | 20 +++++- src/client/app/widgets/plots/frame.js | 6 ++ src/client/app/widgets/plots/image.js | 8 ++- src/client/app/widgets/plots/meter.js | 6 ++ src/client/app/widgets/plots/plot.js | 6 ++ src/client/app/widgets/plots/text.js | 6 ++ src/client/app/widgets/plots/visualizer.js | 6 ++ src/client/app/widgets/sliders/encoder.js | 6 ++ src/client/app/widgets/sliders/range.js | 6 ++ .../app/widgets/switchers/crossfader.js | 8 ++- src/client/app/widgets/switchers/switcher.js | 6 ++ 29 files changed, 253 insertions(+), 4 deletions(-) diff --git a/resources/docs/docs/widgets-reference.md b/resources/docs/docs/widgets-reference.md index b1012f8a..c3386f47 100644 --- a/resources/docs/docs/widgets-reference.md +++ b/resources/docs/docs/widgets-reference.md @@ -30,6 +30,8 @@ ### fader + + | property | type |default | description | | --- | --- | --- | --- | |

style#

|||| @@ -56,6 +58,8 @@ ### knob + + | property | type |default | description | | --- | --- | --- | --- | |

style#

|||| @@ -78,6 +82,8 @@ ### encoder +A knob that sends a relative direction infomation instead of an absolute value. + | property | type |default | description | | --- | --- | --- | --- | |

encoder#

|||| @@ -92,6 +98,8 @@ ### range +A fader with two heads for setting a range. + | property | type |default | description | | --- | --- | --- | --- | |

style#

|||| @@ -114,6 +122,8 @@ ### toggle + + | property | type |default | description | | --- | --- | --- | --- | |

toggle#

|||| @@ -124,6 +134,8 @@ ### push + + | property | type |default | description | | --- | --- | --- | --- | |

push#

|||| @@ -134,6 +146,8 @@ ### switch + + | property | type |default | description | | --- | --- | --- | --- | |

switch#

|||| @@ -144,6 +158,8 @@ ### dropdown + + | property | type |default | description | | --- | --- | --- | --- | | |||| @@ -153,6 +169,8 @@ ### xy +Two-dimensional slider. + | property | type |default | description | | --- | --- | --- | --- | |

style#

|||| @@ -174,6 +192,8 @@ ### rgb +Color picker with optional alpha slider. + | property | type |default | description | | --- | --- | --- | --- | |

rgb#

|||| @@ -187,6 +207,8 @@ ### multixy +Multi-point XY pad. + | property | type |default | description | | --- | --- | --- | --- | |

style#

|||| @@ -210,6 +232,8 @@ ### matrix +Generic matrix for creating rows/columns of widgets. + | property | type |default | description | | --- | --- | --- | --- | |

matrix#

|||| @@ -223,6 +247,8 @@ ### keyboard +Piano keyboard. + | property | type |default | description | | --- | --- | --- | --- | |

style#

|||| @@ -238,6 +264,8 @@ ### patchbay +Connect inputs to outputs. + | property | type |default | description | | --- | --- | --- | --- | |

style#

|||| @@ -250,6 +278,8 @@ ### plot +XY coordinates plot. + | property | type |default | description | | --- | --- | --- | --- | |

plot#

|||| @@ -267,6 +297,8 @@ ### eq +Draws frequency response between from from an array of filter objects. + | property | type |default | description | | --- | --- | --- | --- | |

eq#

|||| @@ -276,9 +308,13 @@ |

origin#

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

logScaleX#

| `boolean` | false | Set to `true` to use logarithmic scale for the x axis (log10) | |

smooth#

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

value#

|||| +|

value#

| `array` | "" | Each item must be an object with the following properties
- `type`: string ("highpass", "highshelf", "lowpass", "lowshelf", "peak" or "notch")
- `freq`: number (filter's resonant frequency)
- `q`: number (Q factor)
- `gain`: number
- `on`: boolean | ### visualizer +Display its value over time. + | property | type |default | description | | --- | --- | --- | --- | |

visualizer#

|||| @@ -291,6 +327,8 @@ ### led + + | property | type |default | description | | --- | --- | --- | --- | |

led#

|||| @@ -299,6 +337,8 @@ ### rgbled + + | property | type |default | description | | --- | --- | --- | --- | |

value#

|||| @@ -306,6 +346,8 @@ ### meter +Non-interactable fader. + | property | type |default | description | | --- | --- | --- | --- | |

style#

|||| @@ -323,6 +365,8 @@ ### text +Display text. + | property | type |default | description | | --- | --- | --- | --- | |

text#

|||| @@ -332,6 +376,8 @@ ### image +Load a image (url or base64-encoded). + | property | type |default | description | | --- | --- | --- | --- | |

image#

|||| @@ -345,6 +391,8 @@ ### svg + + | property | type |default | description | | --- | --- | --- | --- | |

svg#

|||| @@ -352,6 +400,8 @@ ### frame +Embed a page in a frame (local network only). + | property | type |default | description | | --- | --- | --- | --- | |

style#

|||| @@ -365,6 +415,8 @@ ### panel +Widget container. + | property | type |default | description | | --- | --- | --- | --- | |

panel#

|||| @@ -379,6 +431,8 @@ ### strip +Widget container that display its children in a single column or row. + | property | type |default | description | | --- | --- | --- | --- | |

strip#

|||| @@ -393,6 +447,8 @@ ### modal +A toggle button that opens a popup panel. + | property | type |default | description | | --- | --- | --- | --- | | |||| @@ -410,6 +466,8 @@ ### clone +Widget replication with overridable properties. + | property | type |default | description | | --- | --- | --- | --- | |

clone#

|||| @@ -421,6 +479,8 @@ ### switcher +Store other widgets' values and recall them. + | property | type |default | description | | --- | --- | --- | --- | |

switcher#

|||| @@ -430,6 +490,8 @@ ### crossfader +Switcher with linear interpolation slider. + | property | type |default | description | | --- | --- | --- | --- | |

crossfader#

|||| @@ -440,6 +502,8 @@ ### input +Text input. + | property | type |default | description | | --- | --- | --- | --- | |

input#

|||| @@ -450,6 +514,8 @@ ### keys +Keyboard binding. + | property | type |default | description | | --- | --- | --- | --- | |

keys#

|||| @@ -460,6 +526,8 @@ ### script +Evaluates a script each time it receives a value. + | property | type |default | description | | --- | --- | --- | --- | |

script#

|||| @@ -468,6 +536,8 @@ ### gyroscope +Device motion/orientation sensor. + | property | type |default | description | | --- | --- | --- | --- | |

gyroscope#

|||| @@ -480,6 +550,8 @@ ### file +File selector (server-side). + | property | type |default | description | | --- | --- | --- | --- | |

input#

|||| diff --git a/scripts/build-widgets-reference.js b/scripts/build-widgets-reference.js index 34992039..eb594d88 100644 --- a/scripts/build-widgets-reference.js +++ b/scripts/build-widgets-reference.js @@ -51,6 +51,7 @@ for (var k in widgets.categories) { for (var kk in category) { var type = category[kk], defaults = widgets.widgets[type].defaults(), + description = widgets.widgets[type].description(), separator = false @@ -58,6 +59,8 @@ for (var k in widgets.categories) { ### ${type} + ${description} + | property | type |default | description | | --- | --- | --- | --- |` ) diff --git a/src/client/app/widgets/common/widget.js b/src/client/app/widgets/common/widget.js index 66ed00f7..db5592d6 100644 --- a/src/client/app/widgets/common/widget.js +++ b/src/client/app/widgets/common/widget.js @@ -33,6 +33,12 @@ setTimeout(()=>{ class Widget extends EventEmitter { + static description() { + + return '' + + } + static defaults(insert={}, except=[], push={}) { var defaults = { diff --git a/src/client/app/widgets/containers/clone.js b/src/client/app/widgets/containers/clone.js index cc3f3f92..a065644d 100644 --- a/src/client/app/widgets/containers/clone.js +++ b/src/client/app/widgets/containers/clone.js @@ -10,6 +10,12 @@ var excludedCloneClasses = ['widget', 'absolute-position', 'ui-resizable', 'ui- class Clone extends Container { + static description() { + + return 'Widget replication with overridable properties.' + + } + static defaults() { return super.defaults({ diff --git a/src/client/app/widgets/containers/modal.js b/src/client/app/widgets/containers/modal.js index 2660bb15..ff0eb684 100644 --- a/src/client/app/widgets/containers/modal.js +++ b/src/client/app/widgets/containers/modal.js @@ -8,6 +8,12 @@ var Panel = require('./panel'), module.exports = class Modal extends Panel { + static description() { + + return 'A toggle button that opens a popup panel.' + + } + static defaults() { return Widget.defaults({ diff --git a/src/client/app/widgets/containers/panel.js b/src/client/app/widgets/containers/panel.js index e1633c2b..392b5117 100644 --- a/src/client/app/widgets/containers/panel.js +++ b/src/client/app/widgets/containers/panel.js @@ -6,6 +6,12 @@ var Container = require('../common/container'), class Panel extends Container { + static description() { + + return 'Widget container.' + + } + static defaults() { return super.defaults({ diff --git a/src/client/app/widgets/containers/strip.js b/src/client/app/widgets/containers/strip.js index 710e2775..04f1ec3d 100644 --- a/src/client/app/widgets/containers/strip.js +++ b/src/client/app/widgets/containers/strip.js @@ -3,6 +3,12 @@ var Panel = require('./panel'), module.exports = class Strip extends Panel { + static description() { + + return 'Widget container that display its children in a single column or row.' + + } + static defaults() { return Widget.defaults({ diff --git a/src/client/app/widgets/inputs/file.js b/src/client/app/widgets/inputs/file.js index 4d82ed8d..e9e36edb 100644 --- a/src/client/app/widgets/inputs/file.js +++ b/src/client/app/widgets/inputs/file.js @@ -5,6 +5,12 @@ var Widget = require('../common/widget'), module.exports = class Input extends Widget { + static description() { + + return 'File selector (server-side).' + + } + static defaults() { return super.defaults({ diff --git a/src/client/app/widgets/inputs/gyroscope.js b/src/client/app/widgets/inputs/gyroscope.js index f1563d0b..f46e3419 100644 --- a/src/client/app/widgets/inputs/gyroscope.js +++ b/src/client/app/widgets/inputs/gyroscope.js @@ -8,6 +8,12 @@ var Widget = require('../common/widget'), class Gyroscope extends Widget { + static description() { + + return 'Device motion/orientation sensor.' + + } + static defaults() { return super.defaults({ diff --git a/src/client/app/widgets/inputs/input.js b/src/client/app/widgets/inputs/input.js index 4c85419d..4f552c3e 100644 --- a/src/client/app/widgets/inputs/input.js +++ b/src/client/app/widgets/inputs/input.js @@ -4,6 +4,12 @@ var Canvas = require('../common/canvas'), module.exports = class Input extends Canvas { + static description() { + + return 'Text input.' + + } + static defaults() { return super.defaults({ @@ -66,7 +72,7 @@ module.exports = class Input extends Canvas { this.widget.insertBefore(this.input, this.canvas) this.input.focus() this.input.setSelectionRange(0, this.input.value.length) - + } blur(change=true) { diff --git a/src/client/app/widgets/inputs/keys.js b/src/client/app/widgets/inputs/keys.js index 8c61a7d5..107b6aaa 100644 --- a/src/client/app/widgets/inputs/keys.js +++ b/src/client/app/widgets/inputs/keys.js @@ -6,6 +6,12 @@ var Widget = require('../common/widget'), class Keys extends Widget { + static description() { + + return 'Keyboard binding.' + + } + static defaults() { return super.defaults({ diff --git a/src/client/app/widgets/inputs/script.js b/src/client/app/widgets/inputs/script.js index 75d75c18..cb299378 100644 --- a/src/client/app/widgets/inputs/script.js +++ b/src/client/app/widgets/inputs/script.js @@ -7,6 +7,12 @@ var Widget = require('../common/widget'), class Script extends Widget { + static description() { + + return 'Evaluates a script each time it receives a value.' + + } + static defaults() { return super.defaults({ diff --git a/src/client/app/widgets/matrices/keyboard.js b/src/client/app/widgets/matrices/keyboard.js index 2cff75c3..62910206 100644 --- a/src/client/app/widgets/matrices/keyboard.js +++ b/src/client/app/widgets/matrices/keyboard.js @@ -4,6 +4,12 @@ var _matrix_base = require('./_matrix_base'), module.exports = class Keyboard extends _matrix_base { + static description() { + + return 'Piano keyboard.' + + } + static defaults() { return super.defaults({ diff --git a/src/client/app/widgets/matrices/matrix.js b/src/client/app/widgets/matrices/matrix.js index 67fbf892..96eb98bf 100644 --- a/src/client/app/widgets/matrices/matrix.js +++ b/src/client/app/widgets/matrices/matrix.js @@ -6,6 +6,12 @@ var _matrix_base = require('./_matrix_base'), class Matrix extends _matrix_base { + static description() { + + return 'Generic matrix for creating rows/columns of widgets.' + + } + static defaults() { return super.defaults({ diff --git a/src/client/app/widgets/matrices/patchbay.js b/src/client/app/widgets/matrices/patchbay.js index a6ac4296..0092dbf4 100644 --- a/src/client/app/widgets/matrices/patchbay.js +++ b/src/client/app/widgets/matrices/patchbay.js @@ -53,6 +53,12 @@ class PatchBayNode extends Widget { class PatchBay extends Canvas { + static description() { + + return 'Connect inputs to outputs.' + + } + static defaults() { return super.defaults({ diff --git a/src/client/app/widgets/pads/multixy.js b/src/client/app/widgets/pads/multixy.js index ecdeba44..e33c00ae 100644 --- a/src/client/app/widgets/pads/multixy.js +++ b/src/client/app/widgets/pads/multixy.js @@ -9,6 +9,12 @@ var xyDefaults = Xy.defaults()._props() module.exports = class MultiXy extends Pad { + static description() { + + return 'Multi-point XY pad.' + + } + static defaults() { return super.defaults({ diff --git a/src/client/app/widgets/pads/rgb.js b/src/client/app/widgets/pads/rgb.js index 6be45e7c..20dc25ab 100644 --- a/src/client/app/widgets/pads/rgb.js +++ b/src/client/app/widgets/pads/rgb.js @@ -10,6 +10,12 @@ var faderDefaults = Fader.defaults()._props(), module.exports = class Rgb extends Pad { + static description() { + + return 'Color picker with optional alpha slider.' + + } + static defaults() { return super.defaults({ diff --git a/src/client/app/widgets/pads/xy.js b/src/client/app/widgets/pads/xy.js index e99e348e..490d457c 100644 --- a/src/client/app/widgets/pads/xy.js +++ b/src/client/app/widgets/pads/xy.js @@ -8,6 +8,12 @@ var faderDefaults = Fader.defaults()._props() module.exports = class Xy extends Pad { + static description() { + + return 'Two-dimensional slider.' + + } + static defaults() { return super.defaults({ diff --git a/src/client/app/widgets/plots/eq.js b/src/client/app/widgets/plots/eq.js index abca866f..a06e6d75 100644 --- a/src/client/app/widgets/plots/eq.js +++ b/src/client/app/widgets/plots/eq.js @@ -4,6 +4,12 @@ var {clip} = require('../utils'), module.exports = class Eq extends _plots_base { + static description() { + + return 'Draws frequency response between from from an array of filter objects.' + + } + static defaults() { return super.defaults({ @@ -17,7 +23,19 @@ module.exports = class Eq extends _plots_base { logScaleX: {type: 'boolean', value: false, help: 'Set to `true` to use logarithmic scale for the x axis (log10)'}, smooth: {type: 'boolean|number', value: false, help: 'Set to `true` to make the line smooth. Float values are also acceptable (works fine between `0` and `0.5`)'}, - }, ['target', 'precision', 'bypass'], {}) + }, ['target', 'precision', 'bypass'], { + + value: {type: 'array', value: '', help: [ + 'Each item must be an object with the following properties', + '- `type`: string ("highpass", "highshelf", "lowpass", "lowshelf", "peak" or "notch")', + '- `freq`: number (filter\'s resonant frequency)', + '- `q`: number (Q factor)', + '- `gain`: number', + '- `on`: boolean', + + ]} + + }) } diff --git a/src/client/app/widgets/plots/frame.js b/src/client/app/widgets/plots/frame.js index 5a96033b..28593575 100644 --- a/src/client/app/widgets/plots/frame.js +++ b/src/client/app/widgets/plots/frame.js @@ -5,6 +5,12 @@ var Widget = require('../common/widget'), class Frame extends Widget { + static description() { + + return 'Embed a page in a frame (local network only).' + + } + static defaults() { return super.defaults({ diff --git a/src/client/app/widgets/plots/image.js b/src/client/app/widgets/plots/image.js index 789ba11c..548f89b1 100644 --- a/src/client/app/widgets/plots/image.js +++ b/src/client/app/widgets/plots/image.js @@ -2,7 +2,13 @@ var Widget = require('../common/widget'), ipc = require('../../ipc'), html = require('nanohtml') -module.exports = class Led extends Widget { +module.exports = class Image extends Widget { + + static description() { + + return 'Load a image (url or base64-encoded).' + + } static defaults() { diff --git a/src/client/app/widgets/plots/meter.js b/src/client/app/widgets/plots/meter.js index c2600635..62222462 100644 --- a/src/client/app/widgets/plots/meter.js +++ b/src/client/app/widgets/plots/meter.js @@ -3,6 +3,12 @@ var Fader = require('../sliders/fader'), module.exports = class Meter extends Fader { + static description() { + + return 'Non-interactable fader.' + + } + static defaults() { return Widget.defaults({ diff --git a/src/client/app/widgets/plots/plot.js b/src/client/app/widgets/plots/plot.js index 55cfc59b..a89cb199 100644 --- a/src/client/app/widgets/plots/plot.js +++ b/src/client/app/widgets/plots/plot.js @@ -2,6 +2,12 @@ var _plots_base = require('./_plots_base') module.exports = class Plot extends _plots_base { + static description() { + + return 'XY coordinates plot.' + + } + static defaults() { diff --git a/src/client/app/widgets/plots/text.js b/src/client/app/widgets/plots/text.js index f332e7f4..f1577e0f 100644 --- a/src/client/app/widgets/plots/text.js +++ b/src/client/app/widgets/plots/text.js @@ -4,6 +4,12 @@ var {iconify} = require('../../ui/utils'), module.exports = class Text extends Widget { + static description() { + + return 'Display text.' + + } + static defaults() { return super.defaults({ diff --git a/src/client/app/widgets/plots/visualizer.js b/src/client/app/widgets/plots/visualizer.js index ed930494..bb899fca 100644 --- a/src/client/app/widgets/plots/visualizer.js +++ b/src/client/app/widgets/plots/visualizer.js @@ -3,6 +3,12 @@ var {clip} = require('../utils'), module.exports = class Visualizer extends _plots_base { + static description() { + + return 'Display its value over time.' + + } + static defaults() { return super.defaults({ diff --git a/src/client/app/widgets/sliders/encoder.js b/src/client/app/widgets/sliders/encoder.js index ee5fa70d..075c3d5f 100644 --- a/src/client/app/widgets/sliders/encoder.js +++ b/src/client/app/widgets/sliders/encoder.js @@ -29,6 +29,12 @@ var DisplayKnob = class extends Knob { module.exports = class Encoder extends Widget { + static description() { + + return 'A knob that sends a relative direction infomation instead of an absolute value.' + + } + static defaults() { return super.defaults({ diff --git a/src/client/app/widgets/sliders/range.js b/src/client/app/widgets/sliders/range.js index a75b5d89..aa3d8ab0 100644 --- a/src/client/app/widgets/sliders/range.js +++ b/src/client/app/widgets/sliders/range.js @@ -174,6 +174,12 @@ var RangeFader = class RangeFader extends Fader { class Range extends Widget { + static description() { + + return 'A fader with two heads for setting a range.' + + } + static defaults() { return super.defaults({ diff --git a/src/client/app/widgets/switchers/crossfader.js b/src/client/app/widgets/switchers/crossfader.js index d51558df..65b630e9 100644 --- a/src/client/app/widgets/switchers/crossfader.js +++ b/src/client/app/widgets/switchers/crossfader.js @@ -8,6 +8,12 @@ var faderDefaults = Fader.defaults()._props() module.exports = class Crossfader extends Switcher { + static description() { + + return 'Switcher with linear interpolation slider.' + + } + static defaults(){ return Widget.defaults({ @@ -21,7 +27,7 @@ module.exports = class Crossfader extends Switcher { horizontal: {type: 'boolean', value: false, help: 'Set to `true` to display values horizontally'} }) - + } constructor(options) { diff --git a/src/client/app/widgets/switchers/switcher.js b/src/client/app/widgets/switchers/switcher.js index 87a84613..461c2b3c 100644 --- a/src/client/app/widgets/switchers/switcher.js +++ b/src/client/app/widgets/switchers/switcher.js @@ -6,6 +6,12 @@ var switchDefaults = Switch.defaults()._props() module.exports = class Switcher extends _switchers_base { + static description() { + + return 'Store other widgets\' values and recall them.' + + } + static defaults() { return super.defaults({