From c2578916f1ffe46cefad125ae2b91b1b5f8b0013 Mon Sep 17 00:00:00 2001 From: bordun Date: Sat, 3 Oct 2020 17:07:49 +0200 Subject: [PATCH] widgets: move to a more flexible widget default props structure --- CHANGELOG.md | 2 + package.json | 2 +- .../docs/docs/widgets/properties-reference.md | 706 ------------------ src/client/editor/index.js | 2 +- src/client/ui/ui-inspector.js | 85 +-- src/client/widgets/basics/button.js | 59 +- src/client/widgets/basics/dropdown.js | 21 +- src/client/widgets/basics/file.js | 21 +- src/client/widgets/basics/input.js | 17 +- src/client/widgets/basics/menu.js | 56 +- src/client/widgets/basics/switch.js | 41 +- src/client/widgets/common/widget.js | 209 +++--- src/client/widgets/containers/clone.js | 22 +- src/client/widgets/containers/keyboard.js | 70 +- src/client/widgets/containers/matrix.js | 41 +- src/client/widgets/containers/modal.js | 69 +- src/client/widgets/containers/panel.js | 60 +- src/client/widgets/containers/patchbay.js | 46 +- src/client/widgets/containers/root.js | 53 +- src/client/widgets/containers/tab.js | 60 +- src/client/widgets/frames/frame.js | 20 +- src/client/widgets/frames/html.js | 34 +- src/client/widgets/frames/image.js | 44 +- src/client/widgets/frames/svg.js | 22 +- src/client/widgets/graphs/eq.js | 46 +- src/client/widgets/graphs/plot.js | 61 +- src/client/widgets/graphs/visualizer.js | 37 +- src/client/widgets/index.js | 2 +- src/client/widgets/indicators/led.js | 51 +- src/client/widgets/indicators/text.js | 30 +- src/client/widgets/pads/canvas.js | 15 +- src/client/widgets/pads/multixy.js | 50 +- src/client/widgets/pads/rgb.js | 26 +- src/client/widgets/pads/xy.js | 47 +- src/client/widgets/scripts/script.js | 39 +- src/client/widgets/scripts/variable.js | 19 +- src/client/widgets/sliders/encoder.js | 48 +- src/client/widgets/sliders/fader.js | 79 +- src/client/widgets/sliders/knob.js | 77 +- 39 files changed, 822 insertions(+), 1567 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 18acdc51..c3ebbe95 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,10 +7,12 @@ - editor - holding `alt` extends the north-west handle to the widget's size to ease dragging + - widget properties reordered (e.g. -related properties, even widget-specific, are now under the "style" category) - widgets - remove `colorBg` for all widgets except containers - widgets background color is now transparent by default (can be overridden with css) + - keyboard: added `colorBlack` and `colorWhite` properties to customize key colors ## 1.4.1 diff --git a/package.json b/package.json index 2d28f8ed..47489d00 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "open-stage-control", "productName": "Open Stage Control", "description": "Libre and modular OSC / MIDI controller", - "version": "1.4.1", + "version": "1.5.0", "author": { "name": "Jean-Emmanuel Doucet", "email": "jean-emmanuel@ammd.net" diff --git a/resources/docs/docs/widgets/properties-reference.md b/resources/docs/docs/widgets/properties-reference.md index 064cc64f..e69de29b 100644 --- a/resources/docs/docs/widgets/properties-reference.md +++ b/resources/docs/docs/widgets/properties-reference.md @@ -1,706 +0,0 @@ - - -## Common - -??? api "
Generic properties#
" - Properties shared by all widgets - - - - - === "widget" - - | property | type |default | description | - | --- | --- | --- | --- | - |
type#
| `string` | "auto" | Widget type | - |
id#
| `string` | "auto" | Widgets sharing the same `id` will act as clones and update each other's value(s) without sending extra osc messages. | - |
visible#
| `boolean` | true | Set to `false` to hide the widget. | - |
interaction#
| `boolean` | true | Set to `false` to disable pointer interactions. | - - - === "geometry" - - | property | type |default | description | - | --- | --- | --- | --- | - |
left#
| `number`|
`string` | "auto" | When both top and left are set to auto, the widget is positioned according to the normal flow of the page (from left to right, by order of creation).

Otherwise, the widget will be absolutely positioned | - |
top#
| `number`|
`percentage` | "auto" | When both top and left are set to auto, the widget is positioned according to the normal flow of the page (from left to right, by order of creation).

Otherwise, the widget will be absolutely positioned | - |
width#
| `number`|
`percentage` | "auto" | Widget width | - |
height#
| `number`|
`percentage` | "auto" | Widget height | - |
expand#
| `boolean`|
`number` | "false" | If parent's layout is `vertical` or `horizontal`, set this to `true` to stretch the widget to use available space automatically. | - - - === "style" - - | property | type |default | description | - | --- | --- | --- | --- | - |
colorBg#
| `string` | "auto" | Panel background color. Set to "auto" to inherit from parent widget. | - |
colorText#
| `string` | "auto" | Text color. Set to "auto" to inherit from parent widget. | - |
colorWidget#
| `string` | "auto" | Widget's default accent color. Set to "auto" to inherit from parent widget. | - |
colorStroke#
| `string` | "auto" | Stroke color. Set to "auto" to use `colorWidget`. | - |
colorFill#
| `string` | "auto" | Fill color. Set to "auto" to use `colorWidget`. | - |
alphaStroke#
| `number` | "auto" | Stroke color opacity. | - |
alphaFillOff#
| `number` | "auto" | Fill color opacity (off). | - |
alphaFillOn#
| `number` | "auto" | Fill color opacity (on). | - |
lineWidth#
| `number` | "auto" | Stroke width. | - |
padding#
| `number` | "auto" | Inner spacing. | - |
css#
| `string` | "" | CSS rules. See documentation.

Available css variables:
- `--color-background`: `colorBg`
- `--color-widget`: `colorWidget`
- `--color-fill`: `colorFill`
- `--color-stroke`: `colorStroke`
- `--color-text`: `colorText`
- `--widget-padding`: `padding`
- `--line-width`: `lineWidth`
- `--alpha-fill-on`: `alphaFillOn`
- `--alpha-fill-off`: `alphaFillOff`
- `--alpha-stroke`: `alphaStroke` | - - - === "value" - - | property | type |default | description | - | --- | --- | --- | --- | - |
value#
| `*` | "" | Define the widget's value depending on other widget's values / properties using the advanced property syntax | - |
default#
| `*` | "" | If set, the widget will be initialized with this value when the session is loaded. | - |
linkId#
| `string`|
`array` | "" | Widgets sharing the same `linkId` update each other's value(s) AND send their respective osc messages.

When prefixed with >>, the `linkId` will make the widget act as a master (sending but not receiving)

When prefixed with <<, the `linkId` will make the widget act as a slave (receiving but not sending) | - |
script#
| `script` | "" | Script executed whenever the widget's value updates. See documentation. | - - - === "osc" - - | property | type |default | description | - | --- | --- | --- | --- | - |
address#
| `string` | "auto" | OSC address for sending / receiving messages, it must start with a slash (`/`)

By default ("auto"), the widget's id is used: `/widget_id` | - |
preArgs#
| `*`|
`array` | "" | A value or array of values that will be prepended to the OSC messages. | - |
typeTags#
| `string` | "" | Defines the osc argument types, one letter per argument (including preArgs)
- If empty, the types are infered automatically from the values (with numbers casted to floats by default)
- If there are more arguments than type letters, the last type is used for the extra arguments

See http://opensoundcontrol.org/spec-1_0 for existing typetags | - |
decimals#
| `integer` | 2 | Defines the number of decimals to send. | - |
target#
| `string`|
`array`|
`null` | "" | This defines the targets of the widget's OSC messages
- A `string` or `array` of strings formatted as follow: `ip:port` or `["ip:port"]`
- If midi is enabled, targets can be `midi:device_name`
- If no target is set, messages can still be sent if the server has default targets | - |
ignoreDefaults#
| `boolean` | false | Set to `true` to ignore the server's default targets | - |
bypass#
| `boolean` | false | Set to `true` to prevent the widget from sending any osc message | -## Basics - -??? api "
button#
" - On / off button. - - === "style" - - | property | type |default | description | - | --- | --- | --- | --- | - |
css#
| `string` | "" | CSS rules. See documentation.

Available css variables:
- `--color-background`: `colorBg`
- `--color-widget`: `colorWidget`
- `--color-fill`: `colorFill`
- `--color-stroke`: `colorStroke`
- `--color-text`: `colorText`
- `--widget-padding`: `padding`
- `--line-width`: `lineWidth`
- `--alpha-fill-on`: `alphaFillOn`
- `--alpha-fill-off`: `alphaFillOff`
- `--alpha-stroke`: `alphaStroke`
- `--color-text-on`: `colorTextOn` | - - === "button" - - | property | type |default | description | - | --- | --- | --- | --- | - |
label#
| `string`|
`boolean` | "auto" | Set to `false` to hide completely
- Insert icons using the prefix ^ followed by the icon's name : `^play`, `^pause`, etc (see https://fontawesome.com/icons?d=gallery&s=solid&m=free)
- Icons can be transformed with the following suffixes: `.flip-[horizontal|vertical|both]`, `.rotate-[90|180|270]`, `.spin`, `.pulse`. Example: `^play.flip-horizontal` | - |
vertical#
| `boolean` | false | Set to `true` to display the text vertically | - |
wrap#
| `boolean` | false | Set to `true` to wrap long lines automatically. | - |
on#
| `*` | 1 | Set to `null` to send send no argument in the osc message | - |
off#
| `*` | 0 | Set to `null` to send send no argument in the osc message. Must be different from `on`. | - |
mode#
| `string` | "toggle" | Interraction mode:
- `toggle` (classic on/off switch)
- `push` (press & release)
- `tap` (no release)

Choices: `toggle`, `push`, `tap` | - |
doubleTap#
| `boolean` | false | Set to `true` to make the button require a double tap to be pushed instead of a single tap | - |
colorTextOn#
| `string` | "auto" | Defines the widget's text color when active. | - -??? api "
switch#
" - Value selector button. - - === "style" - - | property | type |default | description | - | --- | --- | --- | --- | - |
css#
| `string` | "" | CSS rules. See documentation.

Available css variables:
- `--color-background`: `colorBg`
- `--color-widget`: `colorWidget`
- `--color-fill`: `colorFill`
- `--color-stroke`: `colorStroke`
- `--color-text`: `colorText`
- `--widget-padding`: `padding`
- `--line-width`: `lineWidth`
- `--alpha-fill-on`: `alphaFillOn`
- `--alpha-fill-off`: `alphaFillOff`
- `--alpha-stroke`: `alphaStroke`
- `--color-text-on`: `colorTextOn` | - - === "switch" - - | property | type |default | description | - | --- | --- | --- | --- | - |
layout#
| `string` | "vertical" | Choices: `vertical`, `horizontal`, `grid` | - |
gridTemplate#
| `string`|
`number` | "" | If `layout` is `grid`, can be either a number of columns of a value css grid-template definition. | - |
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 | - |
mode#
| `string` | "tap" | Interraction mode:
- `tap`: activates when the pointer is down but prevents further scrolling
- `slide`: same as `tap` but allows sliding between values
- `click`: activates upon click only and allows further scrolling

Choices: `tap`, `slide`, `click` | - |
colorTextOn#
| `string` | "auto" | Defines the widget's text color when active. | - -??? api "" - Native dropdown menu. - - === "dropdown" - - | property | type |default | description | - | --- | --- | --- | --- | - | | `string` | "center" | Set to `left` or `right` to change text alignment (otherwise center)

Choices: `center`, `left`, `right` | - | | `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 | - -??? api "" - Drag and drop menu with a circular or grid layout. - - === "menu" - - | property | type |default | description | - | --- | --- | --- | --- | - | | `number`|
`array` | 200 | - If `layout` is `circular`: diameter (in px)
- Else: square size or `[width, height]` array | - | | `string` | "center" | Set to `left` or `right` to change text alignment (otherwise center)

Choices: `center`, `left`, `right` | - | | `string` | "center" | Set to `top` or `bottom` to change menu alignment (otherwise center)

Choices: `center`, `top`, `bottom` | - | | `string` | "center" | Set to `left` or `right` to change menu alignment (otherwise center)

Choices: `center`, `left`, `right` | - | | `string` | "circular" | Defines whether the menu's layout should be rendered in a circle or in a box

Choices: `circular`, `horizontal`, `vertical`, `grid` | - | | `string`|
`number` | "" | If `layout` is `grid`, can be either a number of columns of a value css grid-template definition. | - | | `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` | [
 1,
 2,
 3
]
| `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 `mode` is `grid` | - -??? api "
input#
" - Text input. - - === "input" - - | property | type |default | description | - | --- | --- | --- | --- | - |
align#
| `string` | "center" | Set to `left` or `right` to change text alignment (otherwise center)

Choices: `center`, `left`, `right` | - |
unit#
| `string` | "" | Unit will be appended to the displayed widget's value (it doesn't affect osc messages) | - |
asYouType#
| `boolean` | false | Set to `true` to make the input send its value at each keystroke | - -??? api "
file#
" - File/Folder selector (server-side). - - === "file" - - | property | type |default | description | - | --- | --- | --- | --- | - |
align#
| `string` | "center" | Set to `left` or `right` to change text alignment (otherwise center)

Choices: `center`, `left`, `right` | - |
directory#
| `string` | "auto" | Default browsing directory | - |
extension#
| `string` | "*" | Only display files with this extension | - |
hidePath#
| `boolean` | false | Set to `true` to only display the filename (the whole path will still be used as value) | - |
allowDir#
| `boolean` | false | Allow selecting a folder (by pressing "open" when no file is selected) | -## Containers - -??? api "
panel#
" - Widgets or Tabs container. - - === "panel" - - | property | type |default | description | - | --- | --- | --- | --- | - |
variables#
| `*` | "@\{parent.variables}" | Defines one or more arbitrary variables that can be inherited by children widgets | - |
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 | - - === "widget container" - - | property | type |default | description | - | --- | --- | --- | --- | - |
layout#
| `string` | "default" | Defines how children are laid out.

Choices: `default`, `vertical`, `horizontal`, `grid` | - |
justify#
| `string` | "start" | If `layout` is `vertical` or `horizontal`, defines how widgets should be justified.

Choices: `start`, `end`, `center`, `space-around`, `space-between` | - |
gridTemplate#
| `string`|
`number` | "" | If `layout` is `grid`, can be either a number of columns of a value css grid-template definition. | - |
contain#
| `boolean` | true | If `layout` is `vertical` or `horizontal`, prevents children from overflowing the panel. | - |
scroll#
| `boolean` | true | Set to `false` to disable scrollbars | - |
innerPadding#
| `boolean` | true | Set to `false` to make the `padding` property apply only between children and not at the container's inner boundaries. | - - === "tab container" - - | property | type |default | description | - | --- | --- | --- | --- | - |
verticalTabs#
| `boolean` | false | Set to `true` to display for vertical tab layout | - - === "value" - - | property | type |default | description | - | --- | --- | --- | --- | - |
value#
| `integer` | "" | Defines currently selected tab in the widget

A tab can be opened only by setting its parent's value | - - === "children" - - | property | type |default | description | - | --- | --- | --- | --- | - |
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 | - -??? api "" - A toggle button that opens a popup panel. Cannot contain tabs directly. - - === "modal" - - | property | type |default | description | - | --- | --- | --- | --- | - | | `string`|
`boolean` | "auto" | Set to `false` to hide completely
- Insert icons using the prefix ^ followed by the icon's name : `^play`, `^pause`, etc (see https://fontawesome.com/icons?d=gallery&s=solid&m=free)
- Icons can be transformed with the following suffixes: `.flip-[horizontal|vertical|both]`, `.rotate-[90|180|270]`, `.spin`, `.pulse`. Example: `^play.flip-horizontal` | - | | `boolean` | false | Set to `true` to make the modal require a double tap to open instead of a single tap | - | | `*` | "@\{parent.variables}" | Defines one or more arbitrary variables that can be inherited by children widgets | - | | `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 | - - === "popup" - - | property | type |default | description | - | --- | --- | --- | --- | - | | `string`|
`boolean` | "auto" | Alternative label for the modal popup | - | | `number`|
`percentage` | "80%" | Modal popup's size | - | | `number`|
`percentage` | "80%" | Modal popup's size | - | | `number`|
`percentage` | "auto" | Modal popup's position | - | | `number`|
`percentage` | "auto" | Modal popup's position | - - === "widget container" - - | property | type |default | description | - | --- | --- | --- | --- | - | | `string` | "default" | Defines how children are laid out.

Choices: `default`, `vertical`, `horizontal`, `grid` | - | | `string`|
`number` | "" | If `layout` is `grid`, can be either a number of columns of a value css grid-template definition. | - | | `boolean` | true | If `layout` is `vertical` or `horizontal`, prevents children from overflowing the panel. | - | | `boolean` | true | Set to `false` to disable scrollbars | - | | `boolean` | true | Set to `false` to make the `padding` property apply only between children and not at the container's inner boundaries. | - - === "value" - - | property | type |default | description | - | --- | --- | --- | --- | - | | `integer` | "" | Defines the modal's state:`0` for closed, `1` for opened | - - === "children" - - | property | type |default | description | - | --- | --- | --- | --- | - | | `array` | [] | Each element of the array must be a widget object | - -??? api "
clone#
" - Widget replication with overridable properties. - - === "clone" - - | property | type |default | description | - | --- | --- | --- | --- | - |
widgetId#
| `string` | "" | `id` of the widget to clone | - |
props#
| `object` | \{} | Cloned widget's properties to override | - -??? api "
matrix#
" - Generic matrix for creating rows/columns of widgets. - - === "matrix" - - | property | type |default | description | - | --- | --- | --- | --- | - |
widgetType#
| `string` | "button" | Defines the type of the widgets in the matrix | - |
quantity#
| `number` | 4 | Defines the number of widgets in the matrix | - |
start#
| `integer` | 0 | First widget's index | - |
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 `/$`) | - - === "layout" - - | property | type |default | description | - | --- | --- | --- | --- | - |
layout#
| `string` | "horizontal" | Defines how children are laid out.

Choices: `horizontal`, `vertical`, `grid` | - |
gridTemplate#
| `string`|
`number` | "" | If `layout` is `grid`, can be either a number of columns of a value css grid-template definition. | - |
traversing#
| `boolean` | true | Set to `false` to disable traversing gestures | - |
innerPadding#
| `boolean` | true | Set to `false` to make the `padding` property apply only between children and not at the container's inner boundaries. | - -??? api "
keyboard#
" - Piano keyboard. - - === "style" - - | property | type |default | description | - | --- | --- | --- | --- | - |
css#
| `string` | "" | Available CSS variables:
- `--color-white:color;` (white keys color)
- `--color-black:color;` (black keys color) | - - === "keyboard" - - | property | type |default | description | - | --- | --- | --- | --- | - |
keys#
| `number` | 25 | Defines the number keys | - |
start#
| `number` | 48 | MIDI note number to start with (default is C4)

Standard keyboards settings are: `[25, 48]`, `[49, 36]`, `[61, 36]`, `[88, 21]` | - |
traversing#
| `boolean` | true | Set to `false` to disable traversing gestures | - |
on#
| `*` | 1 | Set to `null` to send send no argument in the osc message

Can be an `object` if the type needs to be specified (see preArgs) | - |
off#
| `*` | 0 | Set to `null` to send send no argument in the osc message

Can be an `object` if the type needs to be specified (see preArgs) | - |
mode#
| `string` | "push" | Interraction mode:
- `push` (press & release)
- `toggle` (on/off switches)
- `tap` (no release)

Choices: `push`, `toggle`, `tap` | - -??? api "
patchbay#
" - Connect inputs to outputs. - - === "style" - - | property | type |default | description | - | --- | --- | --- | --- | - |
css#
| `string` | "" | The inputs/ouputs width can be adjusted by using the `.nodes` selector:

`.nodes { width: 25% }` | - - === "patchbay" - - | property | type |default | description | - | --- | --- | --- | --- | - |
inputs#
| `array`|
`object` | [
 "input_1",
 "input_2"
]
| - `Array` of input names : `['input_1', 'input_2']`
- `Object` of `"label_1": "input_1"` 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



Patchbay inputs can be connected to one or more outputs and will send messages of the following form when they are connected/disconnected:

`/patchbay_address input_x output_x output_y etc`

If no output is connected to the input, the message will be `/patchbay_address input_x`

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#
| `array`|
`object` | [
 "output_1",
 "output_2"
]
| List of output values the inputs can connect to (see `inputs`). | - -??? api "
root#
" - Main (unique) container - - === "panel" - - | property | type |default | description | - | --- | --- | --- | --- | - |
variables#
| `*` | "@\{parent.variables}" | Defines one or more arbitrary variables that can be inherited by children widgets | - |
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 | - - === "widget container" - - | property | type |default | description | - | --- | --- | --- | --- | - |
layout#
| `string` | "default" | Defines how children are laid out.

Choices: `default`, `vertical`, `horizontal`, `grid` | - |
justify#
| `string` | "start" | If `layout` is `vertical` or `horizontal`, defines how widgets should be justified.

Choices: `start`, `end`, `center`, `space-around`, `space-between` | - |
gridTemplate#
| `string`|
`number` | "" | If `layout` is `grid`, can be either a number of columns of a value css grid-template definition. | - |
contain#
| `boolean` | true | If `layout` is `vertical` or `horizontal`, prevents children from overflowing the panel. | - |
scroll#
| `boolean` | true | Set to `false` to disable scrollbars | - |
innerPadding#
| `boolean` | true | Set to `false` to make the `padding` property apply only between children and not at the container's inner boundaries. | - - === "tab container" - - | property | type |default | description | - | --- | --- | --- | --- | - |
verticalTabs#
| `boolean` | false | Set to `true` to display for vertical tab layout | - - === "value" - - | property | type |default | description | - | --- | --- | --- | --- | - |
value#
| `integer` | "" | Defines currently widgeted tab in the widget

A tab can be opened only by setting its parent's value | - - === "children" - - | property | type |default | description | - | --- | --- | --- | --- | - |
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 | - -??? api "
tab#
" - Tabbed panel widget - - === "panel" - - | property | type |default | description | - | --- | --- | --- | --- | - |
label#
| `string`|
`boolean` | "auto" | Set to `false` to hide completely
- Insert icons using the prefix ^ followed by the icon's name : `^play`, `^pause`, etc (see https://fontawesome.com/icons?d=gallery&s=solid&m=free)
- Icons can be transformed with the following suffixes: `.flip-[horizontal|vertical|both]`, `.rotate-[90|180|270]`, `.spin`, `.pulse`. Example: `^play.flip-horizontal` | - |
variables#
| `*` | "@\{parent.variables}" | Defines one or more arbitrary variables that can be inherited by children widgets | - |
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 | - - === "widget container" - - | property | type |default | description | - | --- | --- | --- | --- | - |
layout#
| `string` | "default" | Defines how children are laid out.

Choices: `default`, `vertical`, `horizontal`, `grid` | - |
justify#
| `string` | "start" | If `layout` is `vertical` or `horizontal`, defines how widgets should be justified.

Choices: `start`, `end`, `center`, `space-around`, `space-between` | - |
gridTemplate#
| `string`|
`number` | "" | If `layout` is `grid`, can be either a number of columns of a value css grid-template definition. | - |
contain#
| `boolean` | true | If `layout` is `vertical` or `horizontal`, prevents children from overflowing the panel. | - |
scroll#
| `boolean` | true | Set to `false` to disable scrollbars | - |
innerPadding#
| `boolean` | true | Set to `false` to make the `padding` property apply only between children and not at the container's inner boundaries. | - - === "tab container" - - | property | type |default | description | - | --- | --- | --- | --- | - |
verticalTabs#
| `boolean` | false | Set to `true` to display for vertical tab layout | - - === "value" - - | property | type |default | description | - | --- | --- | --- | --- | - |
value#
| `integer` | "" | Defines currently widgeted tab in the widget

A tab can be opened only by setting its parent's value | - - === "children" - - | property | type |default | description | - | --- | --- | --- | --- | - |
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 | -## Frames - -??? api "
frame#
" - Embed a page in a frame (local network only). - - === "value" - - | property | type |default | description | - | --- | --- | --- | --- | - |
value#
| `string` | "" | External web page URL. | - -??? api "
svg#
" - Svg parser. - - === "svg" - - | property | type |default | description | - | --- | --- | --- | --- | - |
svg#
| `string` | "" | Svg xml definition (will be wrapped in a `< svg />` element) | - -??? api "
html#
" - Simple HTML parser. - - === "html" - - | property | type |default | description | - | --- | --- | --- | --- | - |
html#
| `string` | "" | Allowed HTML tags:

  h1-6, blockquote, p, a, ul, ol, nl, li,

  b, i, strong, em, strike, code, hr, br, div,

  table, thead, img, caption, tbody, tr, th, td, pre

Allowed attributes:

  <*>: class, style, title

  : src, width, height | - -??? api "
image#
" - Load a image (url or base64-encoded). - - === "image" - - | property | type |default | description | - | --- | --- | --- | --- | - |
size#
| `string` | "cover" | CSS background-size | - |
position#
| `string` | "center" | CSS background-position | - |
repeat#
| `string` | "no-repeat" | CSS background-repeat | - |
cache#
| `boolean` | true | Set to false to disable image caching (forces file reload when updating or editing the widget).

When true, sending `reload` to the widget reloads its image without changing its value | - - === "value" - - | property | type |default | description | - | --- | --- | --- | --- | - |
value#
| `string` | "" | - File `url` or `path` (relative to the session file location by default, falling back to absolute path)
- Base64 encoded image : `data:image/...` | -## Graphs - -??? api "
plot#
" - XY coordinates plot. - - === "plot" - - | property | type |default | description | - | --- | --- | --- | --- | - |
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. | - |
dots#
| `boolean` | false | Draw dots on the line | - |
bars#
| `boolean` | false | Set to `true` to use draw bars instead (disables `logScaleX` and forces `x axis` even spacing) | - |
pips#
| `boolean` | true | Set to `false` to hide the scale | - - === "value" - - | property | type |default | description | - | --- | --- | --- | --- | - |
value#
| `array`|
`string` | "" | - `Array` of `y` values
- `Array` of `[x, y]` `array` values
- `String` `array`
- `String` `object` to update specific coordinates only: `{0:1, 4:0}` will change the 1st and 5th points' coordinates | - -??? api "
eq#
" - Draws logarithmic frequency response from an array of filter objects. - - === "eq" - - | property | type |default | description | - | --- | --- | --- | --- | - |
filters#
| `array` | "" | Each item must be an object with the following properties
- `type`: string ("highpass", "highshelf", "lowpass", "lowshelf", "peak", "bandpass" or "notch", default: "peak")
- `freq`: number (filter's resonant frequency, default: 1000)
- `q`: number (Q factor, default: 1)
- `gain`: number (default: 0)
- `on`: boolean (default: true)

See https://developer.mozilla.org/en-US/docs/Web/API/BiquadFilterNode | - |
pips#
| `boolean` | true | Set to false to hide the scale | - |
rangeX#
| `object` | \{
 "min": 20,
 "max": 22000
}
| Defines the min and max values for the x axis (in Hz, logarithmic scale) | - |
rangeY#
| `object` | \{
 "min": -6,
 "max": 6
}
| Defines the min and max values for the y axis (in dB) | - |
origin#
| `number`|
`boolean` | "auto" | Defines the y axis origin. Set to `false` to disable it | - -??? api "
visualizer#
" - Display its value over time. - - === "visualizer" - - | property | type |default | description | - | --- | --- | --- | --- | - |
duration#
| `number` | 1 | Defines visualization duration in seconds | - |
framerate#
| `number` | 30 | Defines visualization framerate | - |
rangeY#
| `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 | - |
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. | - |
pips#
| `boolean` | true | Set to `false` to hide the scale | - |
freeze#
| `boolean` | false | Set to `true` to freeze current view and ignore incoming values | -## Indicators - -??? api "
led#
" - Intensity display. - - === "led" - - | property | type |default | description | - | --- | --- | --- | --- | - |
mode#
| `string` | "intensity" | Defines how value is interpreted (see `value`)

Choices: `intensity`, `color` | - |
range#
| `object` | \{
 "min": 0,
 "max": 1
}
| Value range | - |
alphaRange#
| `object` | \{
 "min": 0,
 "max": 1
}
| Alpha range (if `mode` is `color`) | - |
logScale#
| `boolean` | false | If `mode` is `intensity`, set to `true` to use logarithmic scale. | - |
borderRadius#
| `string` | "" | Css border-radius property. | - - === "value" - - | property | type |default | description | - | --- | --- | --- | --- | - |
value#
| `number`|
`array`|
`string` | "" | If `mode` is `intensity`:
- `Number`: `intensity` between `range.min` and `range.max`

If `mode` is `color`:
- `Array`: `[r, g, b]` (`r`, `g` and `b` between `range.min` and `range.max`)
- `Array`: `[r, g, b, alpha]` (`alpha` between `alphaRange.min` and `alphaRange.max`)
- `String`: CSS color | - -??? api "
text#
" - Display text. - - === "text" - - | property | type |default | description | - | --- | --- | --- | --- | - |
vertical#
| `boolean` | false | Set to `true` to display the text vertically | - |
wrap#
| `boolean` | false | Set to `true` to wrap long lines automatically. | - |
align#
| `string` | "center" | Css text-align property.

Choices: `center`, `left`, `right` | -## Pads - -??? api "
xy#
" - Two-dimensional slider. - - === "xy" - - | property | type |default | description | - | --- | --- | --- | --- | - |
pointSize#
| `integer` | 20 | Defines the points' size | - |
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 | - |
ephemeral#
| `boolean` | false | When set to `true`, the point will be drawn only chile touched. | - |
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 | - |
logScaleX#
| `boolean`|
`number` | false | Set to `true` to use logarithmic scale for the x axis. Set to `-1` for exponential scale. | - |
logScaleY#
| `boolean`|
`number` | false | Set to `true` to use logarithmic scale for the y axis. Set to `-1` for exponential scale. | - |
doubleTap#
| `boolean`|
`string` | false | Set to `true` to make the fader reset to its default value when receiving a double tap.

Can also be an osc address, which case the widget will just send an osc message: `/ ` | - |
sensitivity#
| `number` | 1 | Defines the pad's sensitivity when `snap` is `false` | - -??? api "
rgb#
" - Color picker with optional alpha slider. - - === "rgb" - - | property | type |default | description | - | --- | --- | --- | --- | - |
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. | - |
alpha#
| `boolean` | false | Set to `true` to enable alpha channel | - |
rangeAlpha#
| `object` | \{
 "min": 0,
 "max": 1
}
| Defines the widget's output scale for the alpha channel. | - -??? api "
multixy#
" - Multi-point XY pad. - - === "multi xy" - - | property | type |default | description | - | --- | --- | --- | --- | - |
points#
| `integer`|
`array` | 2 | Defines the number of points on the pad

Can be an array of strings that will be used as labels for the points (ex: `['A', 'B']`) | - - === "xy" - - | property | type |default | description | - | --- | --- | --- | --- | - |
pointSize#
| `integer` | 20 | Defines the points' size | - |
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 | - |
ephemeral#
| `boolean` | false | When set to `true`, the points will be drawn only chile touched. | - |
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 | - |
logScaleX#
| `boolean`|
`number` | false | Set to `true` to use logarithmic scale for the x axis. Set to `-1` for exponential scale. | - |
logScaleY#
| `boolean`|
`number` | false | Set to `true` to use logarithmic scale for the y axis. Set to `-1` for exponential scale. | - |
sensitivity#
| `number` | 1 | Defines the pad's sensitivity when `snap` is `false` | -## Sliders - -??? api "
fader#
" - Vertical / horizontal slider. - - === "style" - - | property | type |default | description | - | --- | --- | --- | --- | - |
css#
| `string` | "" | CSS rules. See documentation.

Available css variables:
- `--color-background`: `colorBg`
- `--color-widget`: `colorWidget`
- `--color-fill`: `colorFill`
- `--color-stroke`: `colorStroke`
- `--color-text`: `colorText`
- `--widget-padding`: `padding`
- `--line-width`: `lineWidth`
- `--alpha-fill-on`: `alphaFillOn`
- `--alpha-fill-off`: `alphaFillOff`
- `--alpha-stroke`: `alphaStroke`
- `--alpha-pips`: `alphaPips`
- `--alpha-pips-text`: `alphaPipsText`
- `--knob-size`: `knobSize` | - - === "fader" - - | property | type |default | description | - | --- | --- | --- | --- | - |
design#
| `string` | "default" | Design style

Choices: `default`, `round`, `compact` | - |
knobSize#
| `number` | "auto" | Fader knob size | - |
horizontal#
| `boolean` | false | Set to `true` to display the fader horizontally | - |
pips#
| `boolean` | false | Set to `true` to show range breakpoints (ignored if `design` is `compact`) | - |
dashed#
| `boolean`|
`array` | false | Set to `true` to display a dashed gauge. Can be set as an `array` of two numbers : `[dash_size, gap_size]` | - |
gradient#
| `array`|
`object` | [] | When set, the meter's gauge will be filled with a linear color gradient
- each item must be a CSS color string.
- as an `object`: each key must be a number between 0 and 1
- each item must be a CSS color string.

Examples: `['blue', 'red']`, {'0': 'blue', '0.9': 'blue', '1': 'red'} | - |
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}}`) | - |
logScale#
| `boolean`|
`number` | false | Set to `true` to use logarithmic scale. Set to `-1` for exponential scale. | - |
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 | - |
origin#
| `number` | "auto" | Defines the starting point's value of the fader's gauge | - -??? api "
knob#
" - Rotative knob slider. - - === "style" - - | property | type |default | description | - | --- | --- | --- | --- | - |
css#
| `string` | "" | CSS rules. See documentation.

Available css variables:
- `--color-background`: `colorBg`
- `--color-widget`: `colorWidget`
- `--color-fill`: `colorFill`
- `--color-stroke`: `colorStroke`
- `--color-text`: `colorText`
- `--widget-padding`: `padding`
- `--line-width`: `lineWidth`
- `--alpha-fill-on`: `alphaFillOn`
- `--alpha-fill-off`: `alphaFillOff`
- `--alpha-stroke`: `alphaStroke`
- `--alpha-pips`: `alphaPips`
- `--alpha-pips-text`: `alphaPipsText` | - - === "knob" - - | property | type |default | description | - | --- | --- | --- | --- | - |
design#
| `string` | "default" | Design style

Note: "solid" design uses "colorStroke" for the central knob color.

Choices: `default`, `solid`, `line` | - |
mode#
| `string` | "vertical" | - `circular`: relative move in circular motion
- `snap`: snap to touch position and move in vertical motion
- `vertical`: relative move in vertical motion

Choices: `vertical`, `circular`, `snap` | - |
spring#
| `boolean` | false | When set to `true`, the widget will go back to its `default` value when released | - |
pips#
| `boolean` | false | Set to `true` to show the scale's breakpoints | - |
dashed#
| `boolean`|
`array` | false | Set to `true` to display a dashed gauge. Can be set as an `array` of two numbers : `[dash_size, gap_size]` | - |
angle#
| `number` | 270 | Defines the angle's width of the knob, in degrees | - |
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}}`) | - |
logScale#
| `boolean`|
`number` | false | Set to `true` to use logarithmic scale. Set to `-1` for exponential scale. | - |
sensitivity#
| `number` | 1 | Defines the knob's sensitivity when `mode` is not `snap` | - |
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 | - |
origin#
| `number` | "auto" | Defines the starting point's value of the knob's gauge | - -??? api "
encoder#
" - A knob that sends a relative direction infomation instead of an absolute value. - - === "encoder" - - | property | type |default | description | - | --- | --- | --- | --- | - |
ticks#
| `number` | 360 | defines the granularity / verbosity of the encoder (number of step for a 360° arc) | - |
back#
| `*` | -1 | Defines which value is sent when rotating the encoder anticlockwise | - |
forth#
| `*` | 1 | Defines which value is sent when rotating the encoder clockwise | - |
release#
| `number` | "" | Defines which value is sent when releasing the encoder:
- Set to `null` to send send no argument in the osc message
- Can be an `object` if the type needs to be specified | - |
mode#
| `string` | "circular" | - `circular`: relative move in circular motion
- `snap`: snap to touch position and move in vertical motion
- `vertical`: relative move in vertical motion

Choices: `circular`, `snap`, `vertical` | - |
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 (`/ `) | - - === "osc" - - | property | type |default | description | - | --- | --- | --- | --- | - |
touchAddress#
| `string` | "" | OSC address for touched state messages: `/touchAddress [preArgs] 0/1` | - -??? api "
range#
" - A fader with two heads for setting a range. - - === "style" - - | property | type |default | description | - | --- | --- | --- | --- | - |
css#
| `string` | "" | CSS rules. See documentation.

Available css variables:
- `--color-background`: `colorBg`
- `--color-widget`: `colorWidget`
- `--color-fill`: `colorFill`
- `--color-stroke`: `colorStroke`
- `--color-text`: `colorText`
- `--widget-padding`: `padding`
- `--line-width`: `lineWidth`
- `--alpha-fill-on`: `alphaFillOn`
- `--alpha-fill-off`: `alphaFillOff`
- `--alpha-stroke`: `alphaStroke`
- `--alpha-pips`: `alphaPips`
- `--alpha-pips-text`: `alphaPipsText`
- `--knob-size`: `knobSize` | - - === "fader" - - | property | type |default | description | - | --- | --- | --- | --- | - |
design#
| `string` | "default" | Design style

Choices: `default`, `round`, `compact` | - |
knobSize#
| `number` | "auto" | Fader knob size | - |
horizontal#
| `boolean` | false | Set to `true` to display the fader horizontally | - |
pips#
| `boolean` | false | Set to `true` to show range breakpoints (ignored if `design` is `compact`) | - |
dashed#
| `boolean`|
`array` | false | Set to `true` to display a dashed gauge. Can be set as an `array` of two numbers : `[dash_size, gap_size]` | - |
gradient#
| `array`|
`object` | [] | When set, the meter's gauge will be filled with a linear color gradient
- each item must be a CSS color string.
- as an `object`: each key must be a number between 0 and 1
- each item must be a CSS color string.

Examples: `['blue', 'red']`, {'0': 'blue', '0.9': 'blue', '1': 'red'} | - |
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}}`) | - |
logScale#
| `boolean`|
`number` | false | Set to `true` to use logarithmic scale. Set to `-1` for exponential scale. | - |
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 | - |
origin#
| `number` | "auto" | Defines the starting point's value of the fader's gauge | -## Scripts - -??? api "
script#
" - Evaluates a script each time it receives a value. - - === "script" - - | property | type |default | description | - | --- | --- | --- | --- | - |
event#
| `string` | "value" | Define which events trigger the script's execution.

Choices: `value`, `keyboard` | - |
script#
| `script` | "" | Script executed whenever the widget's receives the defined event. See documentation. | - - === "event: keyboard" - - | property | type |default | description | - | --- | --- | --- | --- | - |
keyBinding#
| `string`|
`array` | "" | Key combo `string` or `array` of strings (see KeyboardJS documentation) | - |
keyRepeat#
| `boolean` | true | Set to `false` to prevent keydown repeats when holding the key combo pressed | - |
keyType#
| `string` | "keydown" | Determines which key event trigger the script's execution

Choices: `keydown`, `keyup`, `both` | - -??? api "
variable#
" - Receives / stores a value, to be used in scripts (using the get function) or in properties (using the @{} syntax). diff --git a/src/client/editor/index.js b/src/client/editor/index.js index da580538..47154731 100644 --- a/src/client/editor/index.js +++ b/src/client/editor/index.js @@ -39,7 +39,7 @@ class Editor { if ((propName === 'label' || propName === 'popupLabel') && value === true) { w.props[propName] = 'auto' } else { - w.props[propName] = value !== '' ? value : deepCopy(defaults[w.props.type][propName].value) + w.props[propName] = value !== '' ? value : deepCopy(defaults[w.props.type]._props()[propName]) } try { diff --git a/src/client/ui/ui-inspector.js b/src/client/ui/ui-inspector.js index 9857e2a5..7e3eb5b3 100644 --- a/src/client/ui/ui-inspector.js +++ b/src/client/ui/ui-inspector.js @@ -18,7 +18,7 @@ class UiInspector extends UiWidget { this.mounted = false - this.expandedCategories = ['_widget'] + this.expandedCategories = ['widget'] this.widget = null @@ -114,65 +114,52 @@ class UiInspector extends UiWidget { this.widget = widget - let category + for (let categoryName in props) { - for (let propName in props) { + if (categoryName === 'children') continue - if (propName === '_children' || propName === 'tabs' || propName === 'widgets' || propName === '_props') continue + let category = html``, + categoryLabel = categoryName === 'class_specific' ? widget.props.type : categoryName - let field, - shared = true + category.appendChild(html` +
${categoryLabel}${categoryName === 'widget' && widgets.length > 1 ? `s (${widgets.length})` : ''}
+ `) - for (var w of widgets) { - if (defaults[w.props.type][propName] === undefined) { - shared = false + let notEmpty + + for (let propName in props[categoryName]) { + + // skip if property is not shared between selected widgets + if (widgets.some((w)=>{ + for (let c in defaults[w.props.type]) { + if (!defaults[w.props.type][c].hasOwnProperty(propName)) return false + } + })) continue + + let field = propName.includes('_separator') ? + html`
${props[categoryName][propName]}
` : + new UiInspectorField({ + parent: this, + widget: widget, + name: propName, + value: widget.props[propName], + default: defaults[widget.props.type][categoryName][propName], + tabIndex: tabIndex++ + }).container + + if (field) { + category.appendChild(field) + notEmpty = true } - } - - if (!shared) continue - - - if (propName.indexOf('_separator') > -1) { - - field = html`
${props[propName]}
` - - } else if (propName.indexOf('_') === 0) { - - if (category) content.appendChild(category) - - category = html`` - - field = html`
${props[propName]}${propName === '_widget' && widgets.length > 1 ? `s (${widgets.length})` : ''}
` - - } else if (widget.props[propName] === undefined) { - - continue - - } else { - - field = new UiInspectorField({ - parent: this, - widget: widget, - name: propName, - value: widget.props[propName], - default: defaults[w.props.type][propName], - tabIndex: tabIndex++ - }).container - - if (!field) continue } - if (category) { - category.appendChild(field) - } else { - content.appendChild(field) - } + if (notEmpty) { + content.appendChild(category) + } } - if (category) content.appendChild(category) - this.lock = true if (this.mounted) { diff --git a/src/client/widgets/basics/button.js b/src/client/widgets/basics/button.js index bac856f5..9af22b43 100644 --- a/src/client/widgets/basics/button.js +++ b/src/client/widgets/basics/button.js @@ -14,36 +14,37 @@ class Button extends Widget { static defaults() { - return super.defaults({ + return super.defaults(Button).extend({ + style: { + _separator_button_style: 'Button style', + colorTextOn: {type: 'string', value: 'auto', help: 'Defines the widget\'s text color when active.'}, + label: {type: 'string|boolean', value: 'auto', help: [ + 'Set to `false` to hide completely', + '- Insert icons using the prefix ^ followed by the icon\'s name : `^play`, `^pause`, etc (see https://fontawesome.com/icons?d=gallery&s=solid&m=free)', + '- Icons can be transformed with the following suffixes: `.flip-[horizontal|vertical|both]`, `.rotate-[90|180|270]`, `.spin`, `.pulse`. Example: `^play.flip-horizontal`', + ]}, + vertical: {type: 'boolean', value: false, help: 'Set to `true` to display the text vertically'}, + wrap: {type: 'boolean', value: false, help: [ + 'Set to `true` to wrap long lines automatically.', + ]}, + }, + class_specific: { + on: {type: '*', value: 1, help: [ + 'Set to `null` to send send no argument in the osc message', + ]}, + off: {type: '*', value: 0, help: [ + 'Set to `null` to send send no argument in the osc message. Must be different from `on`.', + ]}, + mode: {type: 'string', value: 'toggle', choices: ['toggle', 'push', 'tap'], help: [ + 'Interraction mode:', + '- `toggle` (classic on/off switch)', + '- `push` (press & release)', + '- `tap` (no release)' + ]}, + doubleTap: {type: 'boolean', value: false, help: 'Set to `true` to make the button require a double tap to be pushed instead of a single tap'}, - - _class_specific: 'button', - - label: {type: 'string|boolean', value: 'auto', help: [ - 'Set to `false` to hide completely', - '- Insert icons using the prefix ^ followed by the icon\'s name : `^play`, `^pause`, etc (see https://fontawesome.com/icons?d=gallery&s=solid&m=free)', - '- Icons can be transformed with the following suffixes: `.flip-[horizontal|vertical|both]`, `.rotate-[90|180|270]`, `.spin`, `.pulse`. Example: `^play.flip-horizontal`', - ]}, - vertical: {type: 'boolean', value: false, help: 'Set to `true` to display the text vertically'}, - wrap: {type: 'boolean', value: false, help: [ - 'Set to `true` to wrap long lines automatically.', - ]}, - on: {type: '*', value: 1, help: [ - 'Set to `null` to send send no argument in the osc message', - ]}, - off: {type: '*', value: 0, help: [ - 'Set to `null` to send send no argument in the osc message. Must be different from `on`.', - ]}, - mode: {type: 'string', value: 'toggle', choices: ['toggle', 'push', 'tap'], help: [ - 'Interraction mode:', - '- `toggle` (classic on/off switch)', - '- `push` (press & release)', - '- `tap` (no release)' - ]}, - doubleTap: {type: 'boolean', value: false, help: 'Set to `true` to make the button require a double tap to be pushed instead of a single tap'}, - colorTextOn: {type: 'string', value: 'auto', help: 'Defines the widget\'s text color when active.'}, - - }, [], {}, Button) + } + }) } diff --git a/src/client/widgets/basics/dropdown.js b/src/client/widgets/basics/dropdown.js index 97f1f637..d8389203 100644 --- a/src/client/widgets/basics/dropdown.js +++ b/src/client/widgets/basics/dropdown.js @@ -13,16 +13,17 @@ class Dropdown extends MenuBase { static defaults() { - return super.defaults({ - - _class_specific: 'dropdown', - - align: {type: 'string', value: 'center', choices: ['center', 'left', 'right'], help: 'Set to `left` or `right` to change text alignment (otherwise center)'}, - values: {type: 'array|object', value: {'Value 1':1,'Value 2':2}, help: [ - '`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', - ]} - + return super.defaults().extend({ + style: { + _separator_dropdown_style: 'Dropdown style', + align: {type: 'string', value: 'center', choices: ['center', 'left', 'right'], help: 'Set to `left` or `right` to change text alignment (otherwise center)'}, + }, + class_specific: { + values: {type: 'array|object', value: {'Value 1':1,'Value 2':2}, help: [ + '`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/src/client/widgets/basics/file.js b/src/client/widgets/basics/file.js index ffc760f3..d05f369d 100644 --- a/src/client/widgets/basics/file.js +++ b/src/client/widgets/basics/file.js @@ -12,16 +12,17 @@ module.exports = class File extends Widget { static defaults() { - return super.defaults({ - - _class_specific: 'file', - - align: {type: 'string', value: 'center', choices: ['center', 'left', 'right'], help: 'Set to `left` or `right` to change text alignment (otherwise center)'}, - directory: {type: 'string', value: 'auto', help: 'Default browsing directory'}, - extension: {type: 'string', value: '*', help: 'Only display files with this extension'}, - hidePath: {type: 'boolean', value: false, help: 'Set to `true` to only display the filename (the whole path will still be used as value)'}, - allowDir: {type: 'boolean', value: false, help: 'Allow selecting a folder (by pressing "open" when no file is selected)'} - + return super.defaults().extend({ + style: { + _separator_file_style: 'File style', + align: {type: 'string', value: 'center', choices: ['center', 'left', 'right'], help: 'Set to `left` or `right` to change text alignment (otherwise center)'}, + hidePath: {type: 'boolean', value: false, help: 'Set to `true` to only display the filename (the whole path will still be used as value)'}, + }, + class_specific: { + directory: {type: 'string', value: 'auto', help: 'Default browsing directory'}, + extension: {type: 'string', value: '*', help: 'Only display files with this extension'}, + allowDir: {type: 'boolean', value: false, help: 'Allow selecting a folder (by pressing "open" when no file is selected)'} + } }) } diff --git a/src/client/widgets/basics/input.js b/src/client/widgets/basics/input.js index 8e267277..eac66e36 100644 --- a/src/client/widgets/basics/input.js +++ b/src/client/widgets/basics/input.js @@ -12,14 +12,15 @@ class Input extends Canvas { static defaults() { - return super.defaults({ - - _class_specific: 'input', - - align: {type: 'string', value: 'center', choices: ['center', 'left', 'right'], help: 'Set to `left` or `right` to change text alignment (otherwise center)'}, - unit: {type: 'string', value: '', help: 'Unit will be appended to the displayed widget\'s value (it doesn\'t affect osc messages)'}, - asYouType: {type: 'boolean', value: false, help: 'Set to `true` to make the input send its value at each keystroke'} - + return super.defaults().extend({ + style: { + _separator_input_style: 'Input style', + align: {type: 'string', value: 'center', choices: ['center', 'left', 'right'], help: 'Set to `left` or `right` to change text alignment (otherwise center)'}, + unit: {type: 'string', value: '', help: 'Unit will be appended to the displayed widget\'s value (it doesn\'t affect osc messages)'}, + }, + class_specific: { + asYouType: {type: 'boolean', value: false, help: 'Set to `true` to make the input send its value at each keystroke'} + } }) } diff --git a/src/client/widgets/basics/menu.js b/src/client/widgets/basics/menu.js index 46b5cdd6..a79c5f92 100644 --- a/src/client/widgets/basics/menu.js +++ b/src/client/widgets/basics/menu.js @@ -14,32 +14,36 @@ class Menu extends MenuBase { static defaults() { - return super.defaults({ - - _class_specific: 'menu', - - size: {type: 'number|array', value: 200, help: [ - '- If `layout` is `circular`: diameter (in px)', - '- Else: square size or `[width, height]` array', - ]}, - textAlign: {type: 'string', value: 'center', choices: ['center', 'left', 'right'], help: 'Set to `left` or `right` to change text alignment (otherwise center)'}, - menuAlignV: {type: 'string', value: 'center', choices: ['center', 'top', 'bottom'], help: 'Set to `top` or `bottom` to change menu alignment (otherwise center)'}, - menuAlignH: {type: 'string', value: 'center', choices: ['center', 'left', 'right'], help: 'Set to `left` or `right` to change menu alignment (otherwise center)'}, - layout: {type: 'string', value: 'circular', choices: ['circular', 'horizontal', 'vertical', 'grid'], help: [ - 'Defines whether the menu\'s layout should be rendered in a circle or in a box' - ]}, - gridTemplate: {type: 'string|number', value: '', help:'If `layout` is `grid`, can be either a number of columns of a value css grid-template definition.'}, - toggle: {type: 'boolean', value: false, help: 'Set to `true` to make the menu stay opened after mouse/touch release'}, - doubleTap: {type: 'boolean', value: false, help: 'Set to `true` to make the menu require a double tap to be opened instead of a single tap'}, - values: {type: 'array|object', value: [1, 2, 3], help: [ - '`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', - ]}, - weights: {type: 'array', value: '', help: [ - '`Array` of `number` defining the weights of each value in `values`', - 'Ignored when `mode` is `grid`' - ]}, - + return super.defaults().extend({ + geometry: { + _separator_menu_geometry: 'Menu geometry', + size: {type: 'number|array', value: 200, help: [ + '- If `layout` is `circular`: diameter (in px)', + '- Else: square size or `[width, height]` array', + ]}, + }, + style: { + _separator_menu_style: 'Menu style', + textAlign: {type: 'string', value: 'center', choices: ['center', 'left', 'right'], help: 'Set to `left` or `right` to change text alignment (otherwise center)'}, + menuAlignV: {type: 'string', value: 'center', choices: ['center', 'top', 'bottom'], help: 'Set to `top` or `bottom` to change menu alignment (otherwise center)'}, + menuAlignH: {type: 'string', value: 'center', choices: ['center', 'left', 'right'], help: 'Set to `left` or `right` to change menu alignment (otherwise center)'}, + layout: {type: 'string', value: 'circular', choices: ['circular', 'horizontal', 'vertical', 'grid'], help: [ + 'Defines whether the menu\'s layout should be rendered in a circle or in a box' + ]}, + gridTemplate: {type: 'string|number', value: '', help:'If `layout` is `grid`, can be either a number of columns of a value css grid-template definition.'}, + }, + class_specific: { + toggle: {type: 'boolean', value: false, help: 'Set to `true` to make the menu stay opened after mouse/touch release'}, + doubleTap: {type: 'boolean', value: false, help: 'Set to `true` to make the menu require a double tap to be opened instead of a single tap'}, + values: {type: 'array|object', value: [1, 2, 3], help: [ + '`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', + ]}, + weights: {type: 'array', value: '', help: [ + '`Array` of `number` defining the weights of each value in `values`', + 'Ignored when `mode` is `grid`' + ]}, + } }) } diff --git a/src/client/widgets/basics/switch.js b/src/client/widgets/basics/switch.js index adef332d..ae12584f 100644 --- a/src/client/widgets/basics/switch.js +++ b/src/client/widgets/basics/switch.js @@ -13,25 +13,26 @@ class Switch extends MenuBase { static defaults() { - return super.defaults({ - - _class_specific: 'switch', - - layout: {type: 'string', value: 'vertical', choices: ['vertical', 'horizontal', 'grid'], help:''}, - gridTemplate: {type: 'string|number', value: '', help:'If `layout` is `grid`, can be either a number of columns of a value css grid-template definition.'}, - values: {type: 'array|object', value: {'Value 1':1,'Value 2':2}, help: [ - '`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', - ]}, - mode: {type: 'string', value: 'tap', choices: ['tap', 'slide', 'click'], help: [ - 'Interraction mode:', - '- `tap`: activates when the pointer is down but prevents further scrolling', - '- `slide`: same as `tap` but allows sliding between values', - '- `click`: activates upon click only and allows further scrolling', - ]}, - colorTextOn: {type: 'string', value: 'auto', help: 'Defines the widget\'s text color when active.'}, - - }, [], {}, Switch) + return super.defaults(Switch).extend({ + style: { + _separator_switch_style: 'Switch style', + colorTextOn: {type: 'string', value: 'auto', help: 'Defines the widget\'s text color when active.'}, + layout: {type: 'string', value: 'vertical', choices: ['vertical', 'horizontal', 'grid'], help:''}, + gridTemplate: {type: 'string|number', value: '', help:'If `layout` is `grid`, can be either a number of columns of a value css grid-template definition.'}, + }, + class_specific: { + values: {type: 'array|object', value: {'Value 1':1,'Value 2':2}, help: [ + '`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', + ]}, + mode: {type: 'string', value: 'tap', choices: ['tap', 'slide', 'click'], help: [ + 'Interraction mode:', + '- `tap`: activates when the pointer is down but prevents further scrolling', + '- `slide`: same as `tap` but allows sliding between values', + '- `click`: activates upon click only and allows further scrolling', + ]}, + } + }) } @@ -121,7 +122,7 @@ class Switch extends MenuBase { super.setCssVariables() - this.container.classList.toggle('padding-0', this.getProp('padding') === -1) + this.container.classList.toggle('padding-0', this.getProp('padding') === -1) } } diff --git a/src/client/widgets/common/widget.js b/src/client/widgets/common/widget.js index 2e2334ee..3be66877 100644 --- a/src/client/widgets/common/widget.js +++ b/src/client/widgets/common/widget.js @@ -43,124 +43,117 @@ class Widget extends EventEmitter { } - static defaults(insert={}, except=[], push={}, Class=Widget) { + static defaults(Class=Widget) { var defaults = { + widget: { + type: {type: 'string', value: 'auto', help: 'Widget type'}, + id: {type: 'string', value: 'auto', help: 'Widgets sharing the same `id` will act as clones and update each other\'s value(s) without sending extra osc messages.' }, + visible: {type: 'boolean', value: true, help: 'Set to `false` to hide the widget.'}, + interaction: {type: 'boolean', value: true, help: 'Set to `false` to disable pointer interactions.'}, + }, + geometry: { + left: {type: 'number|string', value: 'auto', help: [ + 'When both top and left are set to auto, the widget is positioned according to the normal flow of the page (from left to right, by order of creation).', + 'Otherwise, the widget will be absolutely positioned' + ]}, + top: {type: 'number|percentage', value: 'auto', help: [ + 'When both top and left are set to auto, the widget is positioned according to the normal flow of the page (from left to right, by order of creation).', + 'Otherwise, the widget will be absolutely positioned' + ]}, + width: {type: 'number|percentage', value: 'auto', help: 'Widget width'}, + height: {type: 'number|percentage', value: 'auto', help: 'Widget height'}, + expand: {type: 'boolean|number', value: 'false', help: 'If parent\'s layout is `vertical` or `horizontal`, set this to `true` to stretch the widget to use available space automatically.'}, + }, + style: { + colorText: {type: 'string', value: 'auto', help: 'Text color. Set to "auto" to inherit from parent widget.'}, + colorWidget: {type: 'string', value: 'auto', help: 'Widget\'s default accent color. Set to "auto" to inherit from parent widget.'}, + colorStroke: {type: 'string', value: 'auto', help: 'Stroke color. Set to "auto" to use `colorWidget`.'}, + colorFill: {type: 'string', value: 'auto', help: 'Fill color. Set to "auto" to use `colorWidget`.'}, + alphaStroke: {type: 'number', value: 'auto', help: 'Stroke color opacity.'}, + alphaFillOff: {type: 'number', value: 'auto', help: 'Fill color opacity (off).'}, + alphaFillOn: {type: 'number', value: 'auto', help: 'Fill color opacity (on).'}, + lineWidth: {type: 'number', value: 'auto', help: 'Stroke width.'}, + padding: {type: 'number', value: 'auto', help: 'Inner spacing.'}, + css: {type: 'string', value: '', help: [ + 'CSS rules. See documentation.', + 'Available css variables:', + ...Class.cssVariables.map(x=>'- `' + x.css + '`: `' + x.js + '`') + ]}, + }, + class_specific: { - _widget: 'widget', - - type: {type: 'string', value: 'auto', help: 'Widget type'}, - id: {type: 'string', value: 'auto', help: 'Widgets sharing the same `id` will act as clones and update each other\'s value(s) without sending extra osc messages.' }, - visible: {type: 'boolean', value: true, help: 'Set to `false` to hide the widget.'}, - interaction: {type: 'boolean', value: true, help: 'Set to `false` to disable pointer interactions.'}, - - _geometry: 'geometry', - - left: {type: 'number|string', value: 'auto', help: [ - 'When both top and left are set to auto, the widget is positioned according to the normal flow of the page (from left to right, by order of creation).', - 'Otherwise, the widget will be absolutely positioned' - ]}, - top: {type: 'number|percentage', value: 'auto', help: [ - 'When both top and left are set to auto, the widget is positioned according to the normal flow of the page (from left to right, by order of creation).', - 'Otherwise, the widget will be absolutely positioned' - ]}, - width: {type: 'number|percentage', value: 'auto', help: 'Widget width'}, - height: {type: 'number|percentage', value: 'auto', help: 'Widget height'}, - expand: {type: 'boolean|number', value: 'false', help: 'If parent\'s layout is `vertical` or `horizontal`, set this to `true` to stretch the widget to use available space automatically.'}, - - _style: 'style', - - - colorText: {type: 'string', value: 'auto', help: 'Text color. Set to "auto" to inherit from parent widget.'}, - colorWidget: {type: 'string', value: 'auto', help: 'Widget\'s default accent color. Set to "auto" to inherit from parent widget.'}, - colorStroke: {type: 'string', value: 'auto', help: 'Stroke color. Set to "auto" to use `colorWidget`.'}, - colorFill: {type: 'string', value: 'auto', help: 'Fill color. Set to "auto" to use `colorWidget`.'}, - alphaStroke: {type: 'number', value: 'auto', help: 'Stroke color opacity.'}, - alphaFillOff: {type: 'number', value: 'auto', help: 'Fill color opacity (off).'}, - alphaFillOn: {type: 'number', value: 'auto', help: 'Fill color opacity (on).'}, - - lineWidth: {type: 'number', value: 'auto', help: 'Stroke width.'}, - padding: {type: 'number', value: 'auto', help: 'Inner spacing.'}, - - - - css: {type: 'string', value: '', help: [ - 'CSS rules. See documentation.', - 'Available css variables:', - ...Class.cssVariables.map(x=>'- `' + x.css + '`: `' + x.js + '`') - ]}, - - _value: 'value', - - value: {type: '*', value: '', help: 'Define the widget\'s value depending on other widget\'s values / properties using the advanced property syntax'}, - default: {type: '*', value: '', help: 'If set, the widget will be initialized with this value when the session is loaded.'}, - linkId: {type: 'string|array', value: '', help: [ - 'Widgets sharing the same `linkId` update each other\'s value(s) AND send their respective osc messages.', - 'When prefixed with >>, the `linkId` will make the widget act as a master (sending but not receiving)', - 'When prefixed with <<, the `linkId` will make the widget act as a slave (receiving but not sending)' - ]}, - script: {type: 'script', value: '', help: 'Script executed whenever the widget\'s value updates. See documentation.'}, - - _osc: 'osc', - - address: {type: 'string', value: 'auto', help: [ - 'OSC address for sending / receiving messages, it must start with a slash (`/`)', - 'By default ("auto"), the widget\'s id is used: `/widget_id`', - ]}, - preArgs: {type: '*|array', value: '', help: [ - 'A value or array of values that will be prepended to the OSC messages.', - ]}, - typeTags: {type: 'string', value: '', help: [ - 'Defines the osc argument types, one letter per argument (including preArgs)', - '- If empty, the types are infered automatically from the values (with numbers casted to floats by default)', - '- If there are more arguments than type letters, the last type is used for the extra arguments', - 'See http://opensoundcontrol.org/spec-1_0 for existing typetags' - ]}, - decimals: {type: 'integer', value: 2, help: [ - 'Defines the number of decimals to send.', - ]}, - target: {type: 'string|array|null', value: '', help: [ - 'This defines the targets of the widget\'s OSC messages', - '- A `string` or `array` of strings formatted as follow: `ip:port` or `["ip:port"]`', - '- If midi is enabled, targets can be `midi:device_name`', - '- If no target is set, messages can still be sent if the server has default targets', - ]}, - ignoreDefaults: {type: 'boolean', value: false, help: 'Set to `true` to ignore the server\'s default targets'}, - bypass: {type: 'boolean', value: false, help: 'Set to `true` to prevent the widget from sending any osc message'} - - } - - // okay that's bad, but keys happen to be ordered anyway... - - var alterDefaults = {} - - for (var k in defaults) { - if (k === '_value') { - for (var l in insert) { - alterDefaults[l] = insert[l] - } + }, + value: { + value: {type: '*', value: '', help: 'Define the widget\'s value depending on other widget\'s values / properties using the advanced property syntax'}, + default: {type: '*', value: '', help: 'If set, the widget will be initialized with this value when the session is loaded.'}, + linkId: {type: 'string|array', value: '', help: [ + 'Widgets sharing the same `linkId` update each other\'s value(s) AND send their respective osc messages.', + 'When prefixed with >>, the `linkId` will make the widget act as a master (sending but not receiving)', + 'When prefixed with <<, the `linkId` will make the widget act as a slave (receiving but not sending)' + ]}, + script: {type: 'script', value: '', help: 'Script executed whenever the widget\'s value updates. See documentation.'}, + }, + osc: { + address: {type: 'string', value: 'auto', help: [ + 'OSC address for sending / receiving messages, it must start with a slash (`/`)', + 'By default ("auto"), the widget\'s id is used: `/widget_id`', + ]}, + preArgs: {type: '*|array', value: '', help: [ + 'A value or array of values that will be prepended to the OSC messages.', + ]}, + typeTags: {type: 'string', value: '', help: [ + 'Defines the osc argument types, one letter per argument (including preArgs)', + '- If empty, the types are infered automatically from the values (with numbers casted to floats by default)', + '- If there are more arguments than type letters, the last type is used for the extra arguments', + 'See http://opensoundcontrol.org/spec-1_0 for existing typetags' + ]}, + decimals: {type: 'integer', value: 2, help: [ + 'Defines the number of decimals to send.', + ]}, + target: {type: 'string|array|null', value: '', help: [ + 'This defines the targets of the widget\'s OSC messages', + '- A `string` or `array` of strings formatted as follow: `ip:port` or `["ip:port"]`', + '- If midi is enabled, targets can be `midi:device_name`', + '- If no target is set, messages can still be sent if the server has default targets', + ]}, + ignoreDefaults: {type: 'boolean', value: false, help: 'Set to `true` to ignore the server\'s default targets'}, + bypass: {type: 'boolean', value: false, help: 'Set to `true` to prevent the widget from sending any osc message'} } - if (except.indexOf(k) < 0) alterDefaults[k] = defaults[k] } - for (var m in push) { - if (!alterDefaults[m]) alterDefaults[m] = [] - if (typeof push[m] === 'string') alterDefaults[m] = push[m] - else Object.assign(alterDefaults[m], push[m]) - } - - alterDefaults._props = function() { - var props = {} - for (var k in this) { - if (k[0] !== '_') { - props[k] = this[k].value + Object.defineProperty(defaults, '_props', { + enumerable: false, + value: function(){ + let props = {} + for (let category in this) { + for (let k in this[category]) { + if (k[0] === '_') continue + props[k] = this[category][k].value + } } + return props } - return props - } + }) + Object.defineProperty(defaults, 'extend', { + enumerable: false, + value: function(obj){ + for (let i in obj) { + if (obj[i] === null) delete this[i] + else { + if (this[i] === undefined) this[i] = {} + Object.assign(this[i], obj[i]) + for (let j in obj[i]) { + if (obj[i][j] === null) delete this[i][j] + } + } + } + return this + } + }) - return alterDefaults + return defaults } diff --git a/src/client/widgets/containers/clone.js b/src/client/widgets/containers/clone.js index 7a00331a..6a7b2d50 100644 --- a/src/client/widgets/containers/clone.js +++ b/src/client/widgets/containers/clone.js @@ -18,19 +18,19 @@ class Clone extends Container() { static defaults() { - return super.defaults({ + var defaults = super.defaults().extend({ - _class_specific: 'clone', + class_specific: { + widgetId: {type: 'string', value: '', help: '`id` of the widget to clone'}, + props: {type: 'object', value: {}, help: 'Cloned widget\'s properties to override'}, + }, + value: null, + osc: null + }) + + defaults.style = {css: defaults.style.css} - widgetId: {type: 'string', value: '', help: '`id` of the widget to clone'}, - props: {type: 'object', value: {}, help: 'Cloned widget\'s properties to override'}, - - }, [ - 'colorBg', 'colorText', 'colorWidget', 'colorFill', 'colorStroke', 'alphaStroke', 'alphaFillOff', 'alphaFillOn', 'padding', 'lineWidth', - 'label', 'color', - '_value', 'default', 'value', 'script', 'linkId', - '_osc', 'decimals', 'address', 'preArgs', 'typeTags', 'target', 'ignoreDefaults', 'bypass' - ]) + return defaults } diff --git a/src/client/widgets/containers/keyboard.js b/src/client/widgets/containers/keyboard.js index 27711a84..01cfa1fe 100644 --- a/src/client/widgets/containers/keyboard.js +++ b/src/client/widgets/containers/keyboard.js @@ -3,7 +3,7 @@ var Panel = require('./panel'), parser = require('../../parser') -module.exports = class Keyboard extends Panel { +class Keyboard extends Panel { static description() { @@ -13,39 +13,34 @@ module.exports = class Keyboard extends Panel { static defaults() { - return Widget.defaults({ - - _class_specific: 'keyboard', - - keys: {type: 'number', value: 25, help: 'Defines the number keys'}, - start: {type: 'number', value: 48, help: [ - 'MIDI note number to start with (default is C4)', - 'Standard keyboards settings are: `[25, 48]`, `[49, 36]`, `[61, 36]`, `[88, 21]`' - ]}, - traversing: {type: 'boolean', value: true, help: 'Set to `false` to disable traversing gestures'}, - on: {type: '*', value: 1, help: [ - 'Set to `null` to send send no argument in the osc message', - 'Can be an `object` if the type needs to be specified (see preArgs)' - ]}, - off: {type: '*', value: 0, help: [ - 'Set to `null` to send send no argument in the osc message', - 'Can be an `object` if the type needs to be specified (see preArgs)' - ]}, - mode: {type: 'string', value: 'push', choices: ['push', 'toggle', 'tap'], help: [ - 'Interraction mode:', - '- `push` (press & release)', - '- `toggle` (on/off switches)', - '- `tap` (no release)' - ]}, - - }, [], { - - css: {type: 'string', value: '', help: [ - 'Available CSS variables:', - '- `--color-white:color;` (white keys color)', - '- `--color-black:color;` (black keys color)' - ]} - + return Widget.defaults().extend({ + style: { + _separator_keyboard_style: 'Keyboard style', + colorWhite: {type: 'string', value: 'auto', help: 'White keys color.'}, + colorBlack: {type: 'string', value: 'auto', help: 'Black keys color.'}, + }, + class_specific: { + keys: {type: 'number', value: 25, help: 'Defines the number keys'}, + start: {type: 'number', value: 48, help: [ + 'MIDI note number to start with (default is C4)', + 'Standard keyboards settings are: `[25, 48]`, `[49, 36]`, `[61, 36]`, `[88, 21]`' + ]}, + traversing: {type: 'boolean', value: true, help: 'Set to `false` to disable traversing gestures'}, + on: {type: '*', value: 1, help: [ + 'Set to `null` to send send no argument in the osc message', + 'Can be an `object` if the type needs to be specified (see preArgs)' + ]}, + off: {type: '*', value: 0, help: [ + 'Set to `null` to send send no argument in the osc message', + 'Can be an `object` if the type needs to be specified (see preArgs)' + ]}, + mode: {type: 'string', value: 'push', choices: ['push', 'toggle', 'tap'], help: [ + 'Interraction mode:', + '- `push` (press & release)', + '- `toggle` (on/off switches)', + '- `tap` (no release)' + ]}, + } }) } @@ -125,3 +120,10 @@ module.exports = class Keyboard extends Panel { } } + +Keyboard.cssVariables = Keyboard.prototype.constructor.cssVariables.concat( + {js: 'colorWhite', css: '--color-white-key'}, + {js: 'colorBlack', css: '--color-black-key'} +) + +module.exports = Keyboard diff --git a/src/client/widgets/containers/matrix.js b/src/client/widgets/containers/matrix.js index a98365a3..b9af5862 100644 --- a/src/client/widgets/containers/matrix.js +++ b/src/client/widgets/containers/matrix.js @@ -1,11 +1,10 @@ var Panel = require('./panel'), - Widget = require('../common/widget'), StaticProperties = require('../mixins/static_properties'), parser = require('../../parser'), {deepCopy} = require('../../utils') -class Matrix extends StaticProperties(Panel, {scroll: false}) { +class Matrix extends StaticProperties(Panel) { static description() { @@ -15,28 +14,22 @@ class Matrix extends StaticProperties(Panel, {scroll: false}) { static defaults() { - return Widget.defaults({ - - _class_specific: 'matrix', - - colorBg: {type: 'string', value: 'auto', help: 'Panel background color. Set to "auto" to inherit from parent widget.'}, - widgetType: {type: 'string', value: 'button', help: 'Defines the type of the widgets in the matrix'}, - quantity: {type: 'number', value: 4, help: 'Defines the number of widgets in the matrix'}, - start: {type: 'integer', value: 0, help: 'First widget\'s index'}, - props: {type: 'object', value: {}, help: [ - '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 `/$`)' - ]}, - - _separator: 'layout', - - layout: {type: 'string', value: 'horizontal', choices: ['horizontal', 'vertical', 'grid'], help: 'Defines how children are laid out.'}, - gridTemplate: {type: 'string|number', value: '', help:'If `layout` is `grid`, can be either a number of columns of a value css grid-template definition.'}, - traversing: {type: 'boolean', value: true, help: 'Set to `false` to disable traversing gestures'}, - innerPadding: {type : 'boolean', value: true, help: 'Set to `false` to make the `padding` property apply only between children and not at the container\'s inner boundaries.'}, - - }, [], {}) + return super.defaults().extend({ + class_specific: { + widgetType: {type: 'string', value: 'button', help: 'Defines the type of the widgets in the matrix'}, + quantity: {type: 'number', value: 4, help: 'Defines the number of widgets in the matrix'}, + start: {type: 'integer', value: 0, help: 'First widget\'s index'}, + props: {type: 'object', value: {}, help: [ + '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 `/$`)' + ]}, + }, + style: { + layout: {type: 'string', value: 'horizontal', choices: ['horizontal', 'vertical', 'grid'], help: 'Defines how children are laid out.'}, + verticalTabs: null, + } + }) } diff --git a/src/client/widgets/containers/modal.js b/src/client/widgets/containers/modal.js index 1ce0b79b..4ce7b4b3 100644 --- a/src/client/widgets/containers/modal.js +++ b/src/client/widgets/containers/modal.js @@ -1,5 +1,4 @@ var Panel = require('./panel'), - Widget = require('../common/widget'), {icon, iconify} = require('../../ui/utils'), resize = require('../../events/resize'), doubletab = require('../mixins/double_tap'), @@ -16,45 +15,35 @@ class Modal extends Panel { static defaults() { - return Widget.defaults({ - - _class_specific: 'modal', - - colorBg: {type: 'string', value: 'auto', help: 'Panel background color. Set to "auto" to inherit from parent widget.'}, - label: {type: 'string|boolean', value: 'auto', help: [ - 'Set to `false` to hide completely', - '- Insert icons using the prefix ^ followed by the icon\'s name : `^play`, `^pause`, etc (see https://fontawesome.com/icons?d=gallery&s=solid&m=free)', - '- Icons can be transformed with the following suffixes: `.flip-[horizontal|vertical|both]`, `.rotate-[90|180|270]`, `.spin`, `.pulse`. Example: `^play.flip-horizontal`', - ]}, - doubleTap: {type: 'boolean', value: false, help: 'Set to `true` to make the modal require a double tap to open instead of a single tap'}, - variables: {type: '*', value: '@{parent.variables}', help: 'Defines one or more arbitrary variables that can be inherited by children widgets'}, - traversing: {type: 'boolean', value: false, help: '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'}, - - _separator: 'popup', - - popupLabel: {type: 'string|boolean', value: 'auto', help: 'Alternative label for the modal popup'}, - popupWidth: {type: 'number|percentage', value: '80%', help: 'Modal popup\'s size'}, - popupHeight: {type: 'number|percentage', value: '80%', help: 'Modal popup\'s size'}, - popupLeft: {type: 'number|percentage', value: 'auto', help: 'Modal popup\'s position'}, - popupTop: {type: 'number|percentage', value: 'auto', help: 'Modal popup\'s position'}, - - _separator1: 'widget container', - - layout: {type: 'string', value: 'default', choices: ['default', 'vertical', 'horizontal', 'grid'], help: 'Defines how children are laid out.'}, - gridTemplate: {type: 'string|number', value: '', help:'If `layout` is `grid`, can be either a number of columns of a value css grid-template definition.'}, - contain: {type: 'boolean', value: true, help:'If `layout` is `vertical` or `horizontal`, prevents children from overflowing the panel.'}, - scroll: {type: 'boolean', value: true, help: 'Set to `false` to disable scrollbars'}, - innerPadding: {type : 'boolean', value: true, help: 'Set to `false` to make the `padding` property apply only between children and not at the container\'s inner boundaries.'}, - - }, [], { - - _children: 'children', - - widgets: {type: 'array', value: [], help: 'Each element of the array must be a widget object'}, - value: {type: 'integer', value: '', help: [ - 'Defines the modal\'s state:`0` for closed, `1` for opened' - ]}, - + return super.defaults().extend({ + class_specific: { + doubleTap: {type: 'boolean', value: false, help: 'Set to `true` to make the modal require a double tap to open instead of a single tap'}, + }, + geometry: { + _separator_modal_geometry: 'Modal geometry', + popupWidth: {type: 'number|percentage', value: '80%', help: 'Modal popup\'s size'}, + popupHeight: {type: 'number|percentage', value: '80%', help: 'Modal popup\'s size'}, + popupLeft: {type: 'number|percentage', value: 'auto', help: 'Modal popup\'s position'}, + popupTop: {type: 'number|percentage', value: 'auto', help: 'Modal popup\'s position'}, + }, + style: { + _separator_modal_style: 'Modal style', + label: {type: 'string|boolean', value: 'auto', help: [ + 'Set to `false` to hide completely', + '- Insert icons using the prefix ^ followed by the icon\'s name : `^play`, `^pause`, etc (see https://fontawesome.com/icons?d=gallery&s=solid&m=free)', + '- Icons can be transformed with the following suffixes: `.flip-[horizontal|vertical|both]`, `.rotate-[90|180|270]`, `.spin`, `.pulse`. Example: `^play.flip-horizontal`', + ]}, + popupLabel: {type: 'string|boolean', value: 'auto', help: 'Alternative label for the modal popup'}, + verticalTabs: null, + }, + children: { + tab: null + }, + value: { + value: {type: 'integer', value: '', help: [ + 'Defines the modal\'s state:`0` for closed, `1` for opened' + ]}, + } }) } diff --git a/src/client/widgets/containers/panel.js b/src/client/widgets/containers/panel.js index 118c0f28..1a0c7c3d 100644 --- a/src/client/widgets/containers/panel.js +++ b/src/client/widgets/containers/panel.js @@ -15,42 +15,34 @@ class Panel extends Container() { static defaults() { - return super.defaults({ - - _class_specific: 'panel', - - colorBg: {type: 'string', value: 'auto', help: 'Panel background color. Set to "auto" to inherit from parent widget.'}, - variables: {type: '*', value: '@{parent.variables}', help: 'Defines one or more arbitrary variables that can be inherited by children widgets'}, - traversing: {type: 'boolean', value: false, help: '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'}, - - _separator1: 'widget container', - - layout: {type: 'string', value: 'default', choices: ['default', 'vertical', 'horizontal', 'grid'], help:'Defines how children are laid out.'}, - justify: {type: 'string', value: 'start', choices: ['start', 'end', 'center', 'space-around', 'space-between'], help:'If `layout` is `vertical` or `horizontal`, defines how widgets should be justified.'}, - gridTemplate: {type: 'string|number', value: '', help:'If `layout` is `grid`, can be either a number of columns of a value css grid-template definition.'}, - contain: {type: 'boolean', value: true, help:'If `layout` is `vertical` or `horizontal`, prevents children from overflowing the panel.'}, - scroll: {type: 'boolean', value: true, help: 'Set to `false` to disable scrollbars'}, - innerPadding: {type : 'boolean', value: true, help: 'Set to `false` to make the `padding` property apply only between children and not at the container\'s inner boundaries.'}, - - _separator2: 'tab container', - - verticalTabs: {type: 'boolean', value: false, help: 'Set to `true` to display for vertical tab layout'}, - - }, [], { - - _children: 'children', - - widgets: {type: 'array', value: [], help: 'Each element of the array must be a widget object. A panel cannot contain widgets and tabs simultaneously.'}, - tabs: {type: 'array', value: [], help: 'Each element of the array must be a tab object. A panel cannot contain widgets and tabs simultaneously'}, - - value: {type: 'integer', value: '', help: [ - 'Defines currently selected tab in the widget', - 'A tab can be opened only by setting its parent\'s value' - ]}, - + return super.defaults().extend({ + class_specific: { + variables: {type: '*', value: '@{parent.variables}', help: 'Defines one or more arbitrary variables that can be inherited by children widgets'}, + traversing: {type: 'boolean', value: false, help: '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'}, + }, + style: { + _separator_panel_style: 'Panel style', + colorBg: {type: 'string', value: 'auto', help: 'Panel background color. Set to "auto" to inherit from parent widget.'}, + layout: {type: 'string', value: 'default', choices: ['default', 'vertical', 'horizontal', 'grid'], help:'Defines how children are laid out.'}, + justify: {type: 'string', value: 'start', choices: ['start', 'end', 'center', 'space-around', 'space-between'], help:'If `layout` is `vertical` or `horizontal`, defines how widgets should be justified.'}, + gridTemplate: {type: 'string|number', value: '', help:'If `layout` is `grid`, can be either a number of columns of a value css grid-template definition.'}, + contain: {type: 'boolean', value: true, help:'If `layout` is `vertical` or `horizontal`, prevents children from overflowing the panel.'}, + scroll: {type: 'boolean', value: true, help: 'Set to `false` to disable scrollbars'}, + innerPadding: {type : 'boolean', value: true, help: 'Set to `false` to make the `padding` property apply only between children and not at the container\'s inner boundaries.'}, + verticalTabs: {type: 'boolean', value: false, help: 'Set to `true` to display for vertical tab layout'}, + }, + value: { + value: {type: 'integer', value: '', help: [ + 'Defines currently selected tab in the widget', + 'A tab can be opened only by setting its parent\'s value' + ]} + }, + children: { + widgets: {type: 'array', value: [], help: 'Each element of the array must be a widget object. A panel cannot contain widgets and tabs simultaneously.'}, + tabs: {type: 'array', value: [], help: 'Each element of the array must be a tab object. A panel cannot contain widgets and tabs simultaneously'}, + } }) - } constructor(options) { diff --git a/src/client/widgets/containers/patchbay.js b/src/client/widgets/containers/patchbay.js index 12703ef6..e2a7e429 100644 --- a/src/client/widgets/containers/patchbay.js +++ b/src/client/widgets/containers/patchbay.js @@ -10,8 +10,10 @@ class PatchBayNode extends Widget { static defaults() { - return super.defaults({ - label: {type: 'string', value: ''} + return super.defaults().extend({ + style: { + label: {type: 'string', value: ''} + } }) } @@ -71,27 +73,25 @@ class PatchBay extends Container(Canvas) { static defaults() { - return super.defaults({ - - _class_specific: 'patchbay', - - inputs: {type: 'array|object', value: ['input_1', 'input_2'], help: [ - '- `Array` of input names : `[\'input_1\', \'input_2\']`', - '- `Object` of `"label_1": "input_1"` 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', - '', - 'Patchbay inputs can be connected to one or more outputs and will send messages of the following form when they are connected/disconnected: ', - '`/patchbay_address input_x output_x output_y etc`', - 'If no output is connected to the input, the message will be `/patchbay_address input_x`', - '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`).'}, - - }, [], { - - css: {type: 'string', value: '', help: [ - 'The inputs/ouputs width can be adjusted by using the `.nodes` selector:', - '`.nodes { width: 25% }`', - ]} + return super.defaults().extend({ + style: { + css: {type: 'string', value: '', help: [ + 'The inputs/ouputs width can be adjusted by using the `.nodes` selector:', + '`.nodes { width: 25% }`', + ]} + }, + class_specific: { + inputs: {type: 'array|object', value: ['input_1', 'input_2'], help: [ + '- `Array` of input names : `[\'input_1\', \'input_2\']`', + '- `Object` of `"label_1": "input_1"` 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', + '', + 'Patchbay inputs can be connected to one or more outputs and will send messages of the following form when they are connected/disconnected: ', + '`/patchbay_address input_x output_x output_y etc`', + 'If no output is connected to the input, the message will be `/patchbay_address input_x`', + '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`).'}, + } }) } diff --git a/src/client/widgets/containers/root.js b/src/client/widgets/containers/root.js index 0e03956c..467dbc95 100644 --- a/src/client/widgets/containers/root.js +++ b/src/client/widgets/containers/root.js @@ -1,5 +1,4 @@ var Panel = require('./panel'), - Widget = require('../common/widget'), StaticProperties = require('../mixins/static_properties') class Root extends StaticProperties(Panel, {visible: true, label: false, id: 'root'}) { @@ -12,43 +11,21 @@ class Root extends StaticProperties(Panel, {visible: true, label: false, id: 'ro static defaults() { - return Widget.defaults({ - - _class_specific: 'panel', - - colorBg: {type: 'string', value: 'auto', help: 'Panel background color. Set to "auto" to inherit from parent widget.'}, - variables: {type: '*', value: '@{parent.variables}', help: 'Defines one or more arbitrary variables that can be inherited by children widgets'}, - traversing: {type: 'boolean', value: false, help: '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'}, - - _separator1: 'widget container', - - layout: {type: 'string', value: 'default', choices: ['default', 'vertical', 'horizontal', 'grid'], help:'Defines how children are laid out.'}, - justify: {type: 'string', value: 'start', choices: ['start', 'end', 'center', 'space-around', 'space-between'], help:'If `layout` is `vertical` or `horizontal`, defines how widgets should be justified.'}, - gridTemplate: {type: 'string|number', value: '', help:'If `layout` is `grid`, can be either a number of columns of a value css grid-template definition.'}, - contain: {type: 'boolean', value: true, help:'If `layout` is `vertical` or `horizontal`, prevents children from overflowing the panel.'}, - scroll: {type: 'boolean', value: true, help: 'Set to `false` to disable scrollbars'}, - innerPadding: {type : 'boolean', value: true, help: 'Set to `false` to make the `padding` property apply only between children and not at the container\'s inner boundaries.'}, - - _separator2: 'tab container', - - verticalTabs: {type: 'boolean', value: false, help: 'Set to `true` to display for vertical tab layout'}, - - }, [ - 'visible', 'label', - 'left', 'top', 'expand', - 'colorFill', 'colorStroke', 'alphaStroke', 'alphaFillOff', - ], { - - _children:'children', - - widgets: {type: 'array', value: [], help: 'Each element of the array must be a widget object. A panel cannot contain widgets and tabs simultaneously.'}, - tabs: {type: 'array', value: [], help: 'Each element of the array must be a tab object. A panel cannot contain widgets and tabs simultaneously'}, - - value: {type: 'integer', value: '', help: [ - 'Defines currently widgeted tab in the widget', - 'A tab can be opened only by setting its parent\'s value' - ]}, - + return super.defaults().extend({ + widgets: { + visible: null, + }, + geometry: { + left: null, + top: null, + expand: null, + }, + style: { + colorFill: null, + colorStroke: null, + alphaStroke: null, + alphaFillOff: null, + } }) } diff --git a/src/client/widgets/containers/tab.js b/src/client/widgets/containers/tab.js index d634728e..ebf38dcb 100644 --- a/src/client/widgets/containers/tab.js +++ b/src/client/widgets/containers/tab.js @@ -1,5 +1,4 @@ var Panel = require('./panel'), - Widget = require('../common/widget'), resize = require('../../events/resize'), {iconify} = require('../../ui/utils') @@ -13,49 +12,20 @@ class Tab extends Panel { static defaults() { - return Widget.defaults({ - - - _class_specific: 'panel', - - colorBg: {type: 'string', value: 'auto', help: 'Panel background color. Set to "auto" to inherit from parent widget.'}, - label: {type: 'string|boolean', value: 'auto', help: [ - 'Set to `false` to hide completely', - '- Insert icons using the prefix ^ followed by the icon\'s name : `^play`, `^pause`, etc (see https://fontawesome.com/icons?d=gallery&s=solid&m=free)', - '- Icons can be transformed with the following suffixes: `.flip-[horizontal|vertical|both]`, `.rotate-[90|180|270]`, `.spin`, `.pulse`. Example: `^play.flip-horizontal`', - ]}, - variables: {type: '*', value: '@{parent.variables}', help: 'Defines one or more arbitrary variables that can be inherited by children widgets'}, - traversing: {type: 'boolean', value: false, help: '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'}, - // detached: {type: 'boolean', value: true, help: 'Set to `false` if the tab contains `frame` widgets that should not be reloaded when the tab opens'}, - - _separator1: 'widget container', - - layout: {type: 'string', value: 'default', choices: ['default', 'vertical', 'horizontal', 'grid'], help:'Defines how children are laid out.'}, - justify: {type: 'string', value: 'start', choices: ['start', 'end', 'center', 'space-around', 'space-between'], help:'If `layout` is `vertical` or `horizontal`, defines how widgets should be justified.'}, - gridTemplate: {type: 'string|number', value: '', help:'If `layout` is `grid`, can be either a number of columns of a value css grid-template definition.'}, - contain: {type: 'boolean', value: true, help:'If `layout` is `vertical` or `horizontal`, prevents children from overflowing the panel.'}, - scroll: {type: 'boolean', value: true, help: 'Set to `false` to disable scrollbars'}, - innerPadding: {type : 'boolean', value: true, help: 'Set to `false` to make the `padding` property apply only between children and not at the container\'s inner boundaries.'}, - - _separator2: 'tab container', - - verticalTabs: {type: 'boolean', value: false, help: 'Set to `true` to display for vertical tab layout'}, - - }, [ - '_geometry', 'left', 'top', 'width', 'height', 'expand', - 'colorStroke', 'alphaStroke', 'alphaFillOff', 'alphaFillOn' - ], { - - _children:'children', - - widgets: {type: 'array', value: [], help: 'Each element of the array must be a widget object. A panel cannot contain widgets and tabs simultaneously.'}, - tabs: {type: 'array', value: [], help: 'Each element of the array must be a tab object. A panel cannot contain widgets and tabs simultaneously'}, - - value: {type: 'integer', value: '', help: [ - 'Defines currently widgeted tab in the widget', - 'A tab can be opened only by setting its parent\'s value' - ]}, - + return super.defaults().extend({ + geometry: null, + style: { + _separator_tab_style: 'Tab style', + label: {type: 'string|boolean', value: 'auto', help: [ + 'Set to `false` to hide completely', + '- Insert icons using the prefix ^ followed by the icon\'s name : `^play`, `^pause`, etc (see https://fontawesome.com/icons?d=gallery&s=solid&m=free)', + '- Icons can be transformed with the following suffixes: `.flip-[horizontal|vertical|both]`, `.rotate-[90|180|270]`, `.spin`, `.pulse`. Example: `^play.flip-horizontal`', + ]}, + colorStroke: null, + alphaStroke: null, + alphaFillOff: null, + alphaFillOn: null, + } }) } @@ -87,7 +57,6 @@ class Tab extends Panel { hide() { if (this.detached) return - if (this.getProp('detached')) this.container.removeChild(this.widget) this.container.classList.remove('show') this.detached = true this.setVisibility() @@ -95,7 +64,6 @@ class Tab extends Panel { show() { if (!this.detached) return - if (this.getProp('detached')) this.container.appendChild(this.widget) this.container.classList.add('show') this.detached = false this.setVisibility() diff --git a/src/client/widgets/frames/frame.js b/src/client/widgets/frames/frame.js index 01b05494..87821e1a 100644 --- a/src/client/widgets/frames/frame.js +++ b/src/client/widgets/frames/frame.js @@ -13,14 +13,18 @@ class Frame extends StaticProperties(Widget, {bypass: true}) { static defaults() { - return super.defaults({ - - }, ['decimals', 'typeTags', 'bypass', 'ignoreDefaults'], { - - value: {type: 'string', value: '', help: [ - 'External web page URL.', - ]} - + return super.defaults().extend({ + value: { + value: {type: 'string', value: '', help: [ + 'External web page URL.', + ]} + }, + osc: { + decimals: null, + typeTags: null, + bypass: null, + ignoreDefaults: null + } }) } diff --git a/src/client/widgets/frames/html.js b/src/client/widgets/frames/html.js index fc36d477..81bb5ccd 100644 --- a/src/client/widgets/frames/html.js +++ b/src/client/widgets/frames/html.js @@ -23,21 +23,25 @@ class Html extends StaticProperties(Widget, {bypass: true}) { static defaults() { - return super.defaults({ - - _class_specific: 'html', - - html: {type: 'string', value: '', help: [ - 'Allowed HTML tags:', - '  h1-6, blockquote, p, a, ul, ol, nl, li,', - '  b, i, strong, em, strike, code, hr, br, div,', - '  table, thead, img, caption, tbody, tr, th, td, pre', - 'Allowed attributes:', - '  <*>: class, style, title', - '  : src, width, height', - ]}, - - }, ['decimals', 'typeTags', 'bypass', 'ignoreDefaults'], {}) + return super.defaults().extend({ + class_specific: { + html: {type: 'string', value: '', help: [ + 'Allowed HTML tags:', + '  h1-6, blockquote, p, a, ul, ol, nl, li,', + '  b, i, strong, em, strike, code, hr, br, div,', + '  table, thead, img, caption, tbody, tr, th, td, pre', + 'Allowed attributes:', + '  <*>: class, style, title', + '  : src, width, height', + ]}, + }, + osc: { + decimals: null, + typeTags: null, + bypass: null, + ignoreDefaults: null + } + }) } diff --git a/src/client/widgets/frames/image.js b/src/client/widgets/frames/image.js index 61f46074..005076d8 100644 --- a/src/client/widgets/frames/image.js +++ b/src/client/widgets/frames/image.js @@ -13,25 +13,31 @@ module.exports = class Image extends StaticProperties(Widget, {bypass: true}) { static defaults() { - return super.defaults({ - - _class_specific: 'image', - - size: {type: 'string', value: 'cover', help: 'CSS background-size'}, - position: {type: 'string', value: 'center', help: 'CSS background-position'}, - repeat: {type: 'string', value: 'no-repeat', help: 'CSS background-repeat'}, - cache: {type: 'boolean', value: true, help: [ - 'Set to false to disable image caching (forces file reload when updating or editing the widget).', - 'When true, sending `reload` to the widget reloads its image without changing its value' - ]} - - }, ['decimals', 'typeTags', 'bypass', 'ignoreDefaults'], { - - value: {type: 'string', value: '', help: [ - '- File `url` or `path` (relative to the session file location by default, falling back to absolute path)', - '- Base64 encoded image : `data:image/...`' - ]} - + return super.defaults().extend({ + style: { + _separator_image_style: 'Image style', + size: {type: 'string', value: 'cover', help: 'CSS background-size'}, + position: {type: 'string', value: 'center', help: 'CSS background-position'}, + repeat: {type: 'string', value: 'no-repeat', help: 'CSS background-repeat'}, + }, + class_specific: { + cache: {type: 'boolean', value: true, help: [ + 'Set to false to disable image caching (forces file reload when updating or editing the widget).', + 'When true, sending `reload` to the widget reloads its image without changing its value' + ]} + }, + value: { + value: {type: 'string', value: '', help: [ + '- File `url` or `path` (relative to the session file location by default, falling back to absolute path)', + '- Base64 encoded image : `data:image/...`' + ]} + }, + osc: { + decimals: null, + typeTags: null, + bypass: null, + ignoreDefaults: null + } }) } diff --git a/src/client/widgets/frames/svg.js b/src/client/widgets/frames/svg.js index 83b3f5db..2a886536 100644 --- a/src/client/widgets/frames/svg.js +++ b/src/client/widgets/frames/svg.js @@ -14,15 +14,19 @@ class Svg extends StaticProperties(Widget, {bypass: true}) { static defaults() { - return super.defaults({ - - _class_specific: 'svg', - - svg: {type: 'string', value: '', help: [ - 'Svg xml definition (will be wrapped in a `< svg />` element)', - ]}, - - }, ['decimals', 'typeTags', 'bypass', 'ignoreDefaults'], {}) + return super.defaults().extend({ + class_specific: { + svg: {type: 'string', value: '', help: [ + 'Svg xml definition (will be wrapped in a `< svg />` element)', + ]}, + }, + osc: { + decimals: null, + typeTags: null, + bypass: null, + ignoreDefaults: null + } + }) } diff --git a/src/client/widgets/graphs/eq.js b/src/client/widgets/graphs/eq.js index fd381f6d..343a667d 100644 --- a/src/client/widgets/graphs/eq.js +++ b/src/client/widgets/graphs/eq.js @@ -1,6 +1,5 @@ var {mapToScale} = require('../utils'), Plot = require('./plot'), - Widget = require('../common/widget'), StaticProperties = require('../mixins/static_properties') class Eq extends StaticProperties(Plot, {logScaleX: false, logScaleY:false, smooth:true}) { @@ -13,26 +12,33 @@ class Eq extends StaticProperties(Plot, {logScaleX: false, logScaleY:false, smoo static defaults() { - return Widget.defaults({ + return super.defaults().extend({ + widget: { + interaction: null + }, + class_specific: { + filters: {type: 'array', value: '', help: [ + 'Each item must be an object with the following properties', + '- `type`: string ("highpass", "highshelf", "lowpass", "lowshelf", "peak", "bandpass" or "notch", default: "peak")', + '- `freq`: number (filter\'s resonant frequency, default: 1000)', + '- `q`: number (Q factor, default: 1)', + '- `gain`: number (default: 0)', + '- `on`: boolean (default: true)', + 'See https://developer.mozilla.org/en-US/docs/Web/API/BiquadFilterNode' - _class_specific: 'eq', - - filters: {type: 'array', value: '', help: [ - 'Each item must be an object with the following properties', - '- `type`: string ("highpass", "highshelf", "lowpass", "lowshelf", "peak", "bandpass" or "notch", default: "peak")', - '- `freq`: number (filter\'s resonant frequency, default: 1000)', - '- `q`: number (Q factor, default: 1)', - '- `gain`: number (default: 0)', - '- `on`: boolean (default: true)', - 'See https://developer.mozilla.org/en-US/docs/Web/API/BiquadFilterNode' - - ]}, - pips: {type: 'boolean', value: true, help: 'Set to false to hide the scale'}, - rangeX: {type: 'object', value: {min: 20, max: 22000}, help: 'Defines the min and max values for the x axis (in Hz, logarithmic scale)'}, - rangeY: {type: 'object', value: {min:-6, max:6}, help: 'Defines the min and max values for the y axis (in dB)'}, - origin: {type: 'number|boolean', value: 'auto', help: 'Defines the y axis origin. Set to `false` to disable it'}, - - }, ['interaction', 'decimals', 'typeTags', 'bypass', 'ignoreDefaults']) + ]}, + pips: {type: 'boolean', value: true, help: 'Set to false to hide the scale'}, + rangeX: {type: 'object', value: {min: 20, max: 22000}, help: 'Defines the min and max values for the x axis (in Hz, logarithmic scale)'}, + rangeY: {type: 'object', value: {min:-6, max:6}, help: 'Defines the min and max values for the y axis (in dB)'}, + origin: {type: 'number|boolean', value: 'auto', help: 'Defines the y axis origin. Set to `false` to disable it'}, + }, + osc: { + decimals: null, + typeTags: null, + bypass: null, + ignoreDefaults: null + } + }) } diff --git a/src/client/widgets/graphs/plot.js b/src/client/widgets/graphs/plot.js index a20467b0..32f28f20 100644 --- a/src/client/widgets/graphs/plot.js +++ b/src/client/widgets/graphs/plot.js @@ -13,29 +13,46 @@ module.exports = class Plot extends StaticProperties(Canvas, {bypass: true, inte static defaults() { + return super.defaults().extend({ + widget: { + interaction: null + }, + style: { + _separator_plot_style: 'Plot style', + dots: {type: 'boolean', value: false, help: 'Draw dots on the line'}, + bars: {type: 'boolean', value: false, help: 'Set to `true` to use draw bars instead (disables `logScaleX` and forces `x axis` even spacing)'}, + pips:{type: 'boolean', value: true, help: 'Set to `false` to hide the scale'}, + }, + class_specific: { + filters: {type: 'array', value: '', help: [ + 'Each item must be an object with the following properties', + '- `type`: string ("highpass", "highshelf", "lowpass", "lowshelf", "peak", "bandpass" or "notch", default: "peak")', + '- `freq`: number (filter\'s resonant frequency, default: 1000)', + '- `q`: number (Q factor, default: 1)', + '- `gain`: number (default: 0)', + '- `on`: boolean (default: true)', + 'See https://developer.mozilla.org/en-US/docs/Web/API/BiquadFilterNode' - return super.defaults({ - - _class_specific: 'plot', - - rangeX: {type: 'object', value: {min:0,max:1}, help: 'Defines the min and max values for the x axis'}, - rangeY: {type: 'object', value: {min:0,max:1}, help: 'Defines the min and max values for the y axis'}, - logScaleX: {type: 'boolean|number', value: false, help: 'Set to `true` to use logarithmic scale for the x axis (base 10). Set to a `number` to define the logarithm\'s base.'}, - logScaleY: {type: 'boolean|number', value: false, help: 'Set to `true` to use logarithmic scale for the y axis (base 10). Set to a `number` to define the logarithm\'s base.'}, - origin: {type: 'number', value: 'auto', help: 'Defines the y axis origin. Set to `false` to disable it.'}, - dots: {type: 'boolean', value: false, help: 'Draw dots on the line'}, - bars: {type: 'boolean', value: false, help: 'Set to `true` to use draw bars instead (disables `logScaleX` and forces `x axis` even spacing)'}, - pips:{type: 'boolean', value: true, help: 'Set to `false` to hide the scale'}, - - }, ['interaction', 'decimals', 'typeTags', 'bypass', 'ignoreDefaults'], { - - value: {type: 'array|string', value: '', help: [ - '- `Array` of `y` values', - '- `Array` of `[x, y]` `array` values', - '- `String` `array`', - '- `String` `object` to update specific coordinates only: `{0:1, 4:0}` will change the 1st and 5th points\' coordinates', - ]} - + ]}, + pips: {type: 'boolean', value: true, help: 'Set to false to hide the scale'}, + rangeX: {type: 'object', value: {min: 20, max: 22000}, help: 'Defines the min and max values for the x axis (in Hz, logarithmic scale)'}, + rangeY: {type: 'object', value: {min:-6, max:6}, help: 'Defines the min and max values for the y axis (in dB)'}, + origin: {type: 'number|boolean', value: 'auto', help: 'Defines the y axis origin. Set to `false` to disable it'}, + }, + value: { + value: {type: 'array|string', value: '', help: [ + '- `Array` of `y` values', + '- `Array` of `[x, y]` `array` values', + '- `String` `array`', + '- `String` `object` to update specific coordinates only: `{0:1, 4:0}` will change the 1st and 5th points\' coordinates', + ]} + }, + osc: { + decimals: null, + typeTags: null, + bypass: null, + ignoreDefaults: null + } }) } diff --git a/src/client/widgets/graphs/visualizer.js b/src/client/widgets/graphs/visualizer.js index e139259d..cb1aafa3 100644 --- a/src/client/widgets/graphs/visualizer.js +++ b/src/client/widgets/graphs/visualizer.js @@ -1,5 +1,4 @@ var {clip} = require('../utils'), - Widget = require('../common/widget'), Plot = require('./plot'), StaticProperties = require('../mixins/static_properties'), canvasQueue = require('../common/queue') @@ -15,19 +14,29 @@ class Visualizer extends StaticProperties(Plot, {rangeX: {min: '', max: ''}, dot static defaults() { - return Widget.defaults({ - - _class_specific: 'visualizer', - - duration: {type: 'number', value: 1, help: 'Defines visualization duration in seconds'}, - framerate: {type: 'number', value: 30, help: 'Defines visualization framerate'}, - rangeY: {type: 'object', value: {min:0,max:1}, help: 'Defines the min and max values for the y axis'}, - origin: {type: 'number', value: 'auto', help: 'Defines the y axis origin. Set to `false` to disable it'}, - logScaleY: {type: 'boolean|number', value: false, help: 'Set to `true` to use logarithmic scale for the y axis (base 10). Set to a `number` to define the logarithm\'s base.'}, - pips:{type: 'boolean', value: true, help: 'Set to `false` to hide the scale'}, - freeze: {type: 'boolean', value: false, help: 'Set to `true` to freeze current view and ignore incoming values'} - - }, ['interaction', 'decimals', 'typeTags', 'bypass', 'ignoreDefaults'], {}) + return super.defaults().extend({ + widget: { + interaction: null + }, + style: { + _separator_visualizer_style: 'Visualizer style', + pips:{type: 'boolean', value: true, help: 'Set to `false` to hide the scale'}, + }, + class_specific: { + duration: {type: 'number', value: 1, help: 'Defines visualization duration in seconds'}, + framerate: {type: 'number', value: 30, help: 'Defines visualization framerate'}, + rangeY: {type: 'object', value: {min:0,max:1}, help: 'Defines the min and max values for the y axis'}, + origin: {type: 'number', value: 'auto', help: 'Defines the y axis origin. Set to `false` to disable it'}, + logScaleY: {type: 'boolean|number', value: false, help: 'Set to `true` to use logarithmic scale for the y axis (base 10). Set to a `number` to define the logarithm\'s base.'}, + freeze: {type: 'boolean', value: false, help: 'Set to `true` to freeze current view and ignore incoming values'} + }, + osc: { + decimals: null, + typeTags: null, + bypass: null, + ignoreDefaults: null + } + }) } diff --git a/src/client/widgets/index.js b/src/client/widgets/index.js index c201c795..2a40455a 100644 --- a/src/client/widgets/index.js +++ b/src/client/widgets/index.js @@ -38,7 +38,7 @@ module.exports.widgets = { xy: require('./pads/xy'), rgb: require('./pads/rgb'), multixy: require('./pads/multixy'), - canvas: require('./pads/canvas'), + // canvas: require('./pads/canvas'), // sliders fader: require('./sliders/fader'), diff --git a/src/client/widgets/indicators/led.js b/src/client/widgets/indicators/led.js index 1aca0b1d..4f8b43f7 100644 --- a/src/client/widgets/indicators/led.js +++ b/src/client/widgets/indicators/led.js @@ -13,27 +13,36 @@ module.exports = class Led extends StaticProperties(Widget, {bypass: true, inter static defaults() { - return super.defaults({ - - _class_specific: 'led', - - mode: {type: 'string', value: 'intensity', choices: ['intensity', 'color'], help: 'Defines how value is interpreted (see `value`)'}, - range: {type: 'object', value: {min:0, max:1}, help: 'Value range'}, - alphaRange: {type: 'object', value: {min:0, max:1}, help: 'Alpha range (if `mode` is `color`)'}, - logScale: {type: 'boolean', value: false, help: 'If `mode` is `intensity`, set to `true` to use logarithmic scale.'}, - borderRadius: {type: 'string', value: '', help: 'Css border-radius property.'}, - - }, ['interaction', 'decimals', 'bypass', 'ignoreDefaults'], { - - value: {type: 'number|array|string', value: '', help: [ - 'If `mode` is `intensity`:', - '- `Number`: `intensity` between `range.min` and `range.max`', - 'If `mode` is `color`:', - '- `Array`: `[r, g, b]` (`r`, `g` and `b` between `range.min` and `range.max`)', - '- `Array`: `[r, g, b, alpha]` (`alpha` between `alphaRange.min` and `alphaRange.max`)', - '- `String`: CSS color', - ]} - + return super.defaults().extend({ + widget: { + interaction: null + }, + style: { + _separator_led_style: 'Led style', + borderRadius: {type: 'string', value: '', help: 'Css border-radius property.'}, + }, + class_specific: { + mode: {type: 'string', value: 'intensity', choices: ['intensity', 'color'], help: 'Defines how value is interpreted (see `value`)'}, + range: {type: 'object', value: {min:0, max:1}, help: 'Value range'}, + alphaRange: {type: 'object', value: {min:0, max:1}, help: 'Alpha range (if `mode` is `color`)'}, + logScale: {type: 'boolean', value: false, help: 'If `mode` is `intensity`, set to `true` to use logarithmic scale.'}, + }, + value: { + value: {type: 'number|array|string', value: '', help: [ + 'If `mode` is `intensity`:', + '- `Number`: `intensity` between `range.min` and `range.max`', + 'If `mode` is `color`:', + '- `Array`: `[r, g, b]` (`r`, `g` and `b` between `range.min` and `range.max`)', + '- `Array`: `[r, g, b, alpha]` (`alpha` between `alphaRange.min` and `alphaRange.max`)', + '- `String`: CSS color', + ]} + }, + osc: { + decimals: null, + typeTags: null, + bypass: null, + ignoreDefaults: null + } }) } diff --git a/src/client/widgets/indicators/text.js b/src/client/widgets/indicators/text.js index e919c774..fd88e513 100644 --- a/src/client/widgets/indicators/text.js +++ b/src/client/widgets/indicators/text.js @@ -13,17 +13,25 @@ module.exports = class Text extends StaticProperties(Widget, {bypass: true, inte static defaults() { - return super.defaults({ - - _class_specific: 'text', - - vertical: {type: 'boolean', value: false, help: 'Set to `true` to display the text vertically'}, - wrap: {type: 'boolean', value: false, help: [ - 'Set to `true` to wrap long lines automatically.', - ]}, - align: {type: 'string', value: 'center', choices: ['center', 'left', 'right'], help: 'Css text-align property.'}, - - }, ['interaction', 'decimals', 'bypass', 'ignoreDefaults'], {}) + return super.defaults().extend({ + widget: { + interaction: null + }, + style: { + _separator_text_style: 'Text style', + vertical: {type: 'boolean', value: false, help: 'Set to `true` to display the text vertically'}, + wrap: {type: 'boolean', value: false, help: [ + 'Set to `true` to wrap long lines automatically.', + ]}, + align: {type: 'string', value: 'center', choices: ['center', 'left', 'right'], help: 'Css text-align property.'}, + }, + osc: { + decimals: null, + typeTags: null, + bypass: null, + ignoreDefaults: null + } + }) } diff --git a/src/client/widgets/pads/canvas.js b/src/client/widgets/pads/canvas.js index 6fc16004..d88b09c9 100644 --- a/src/client/widgets/pads/canvas.js +++ b/src/client/widgets/pads/canvas.js @@ -11,15 +11,12 @@ class CanvasWidget extends Canvas { static defaults() { - return super.defaults({ - - _class_specific: 'canvas', - - - onCreate: {type: 'string', value: '', help: ' '}, - onTouch: {type: 'string', value: '', help: ' '}, - - }, [], {}) + return super.defaults().extend({ + class_specific: { + onCreate: {type: 'string', value: '', help: ' '}, + onTouch: {type: 'string', value: '', help: ' '}, + } + }) } diff --git a/src/client/widgets/pads/multixy.js b/src/client/widgets/pads/multixy.js index cf75c5ba..299c97d2 100644 --- a/src/client/widgets/pads/multixy.js +++ b/src/client/widgets/pads/multixy.js @@ -17,33 +17,31 @@ module.exports = class MultiXy extends Pad { static defaults() { - return super.defaults({ - _class_specific: 'multi xy', - - points: {type: 'integer|array', value: 2, help: [ - 'Defines the number of points on the pad', - 'Can be an array of strings that will be used as labels for the points (ex: `[\'A\', \'B\']`)' - ]}, - - - _separator: 'xy', - - pointSize: {type: 'integer', value: 20, help: 'Defines the points\' size'}, - snap: {type: 'boolean', value: false, help: [ - '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', - ]}, - ephemeral: {type: 'boolean', value: false, help: 'When set to `true`, the points will be drawn only chile touched.'}, - spring: {type: 'boolean', value: false, help: 'When set to `true`, the widget will go back to its default value when released'}, - pips: {type: 'boolean', value: true, help: 'Set to `false` to hide the scale'}, - rangeX: {type: 'object', value: {min:0,max:1}, help: 'Defines the min and max values for the x axis'}, - rangeY: {type: 'object', value: {min:0,max:1}, help: 'Defines the min and max values for the y axis'}, - logScaleX: {type: 'boolean|number', value: false, help: 'Set to `true` to use logarithmic scale for the x axis. Set to `-1` for exponential scale.'}, - logScaleY: {type: 'boolean|number', value: false, help: 'Set to `true` to use logarithmic scale for the y axis. Set to `-1` for exponential scale.'}, - sensitivity: {type: 'number', value: 1, help: 'Defines the pad\'s sensitivity when `snap` is `false` '}, - - }, [], {}) + return super.defaults().extend({ + style: { + _separator_xy_style: 'Xy style', + pointSize: {type: 'integer', value: 20, help: 'Defines the points\' size'}, + ephemeral: {type: 'boolean', value: false, help: 'When set to `true`, the points will be drawn only chile touched.'}, + pips: {type: 'boolean', value: true, help: 'Set to `false` to hide the scale'}, + }, + class_specific: { + points: {type: 'integer|array', value: 2, help: [ + 'Defines the number of points on the pad', + 'Can be an array of strings that will be used as labels for the points (ex: `[\'A\', \'B\']`)' + ]}, + snap: {type: 'boolean', value: false, help: [ + '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: {type: 'boolean', value: false, help: 'When set to `true`, the widget will go back to its default value when released'}, + rangeX: {type: 'object', value: {min:0,max:1}, help: 'Defines the min and max values for the x axis'}, + rangeY: {type: 'object', value: {min:0,max:1}, help: 'Defines the min and max values for the y axis'}, + logScaleX: {type: 'boolean|number', value: false, help: 'Set to `true` to use logarithmic scale for the x axis. Set to `-1` for exponential scale.'}, + logScaleY: {type: 'boolean|number', value: false, help: 'Set to `true` to use logarithmic scale for the y axis. Set to `-1` for exponential scale.'}, + sensitivity: {type: 'number', value: 1, help: 'Defines the pad\'s sensitivity when `snap` is `false` '}, + } + }) } diff --git a/src/client/widgets/pads/rgb.js b/src/client/widgets/pads/rgb.js index 025f20a2..4ec06440 100644 --- a/src/client/widgets/pads/rgb.js +++ b/src/client/widgets/pads/rgb.js @@ -18,21 +18,17 @@ module.exports = class Rgb extends Widget { static defaults() { - return super.defaults({ - - _class_specific: 'rgb', - - snap: {type: 'boolean', value: false, help: [ - '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: {type: 'boolean', value: false, help: 'When set to `true`, the widget will go back to its default value when released'}, - range: {type: 'object', value: {min: 0, max: 255}, help: 'Defines the widget\'s output scale.'}, - alpha:{type: 'boolean', value: false, help: 'Set to `true` to enable alpha channel'}, - rangeAlpha: {type: 'object', value: {min: 0, max: 1}, help: 'Defines the widget\'s output scale for the alpha channel.'}, - - }, ['color'], { - + return super.defaults().extend({ + class_specific: { + snap: {type: 'boolean', value: false, help: [ + '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: {type: 'boolean', value: false, help: 'When set to `true`, the widget will go back to its default value when released'}, + range: {type: 'object', value: {min: 0, max: 255}, help: 'Defines the widget\'s output scale.'}, + alpha:{type: 'boolean', value: false, help: 'Set to `true` to enable alpha channel'}, + rangeAlpha: {type: 'object', value: {min: 0, max: 1}, help: 'Defines the widget\'s output scale for the alpha channel.'}, + } }) } diff --git a/src/client/widgets/pads/xy.js b/src/client/widgets/pads/xy.js index bb140449..5f6328c1 100644 --- a/src/client/widgets/pads/xy.js +++ b/src/client/widgets/pads/xy.js @@ -15,29 +15,30 @@ module.exports = class Xy extends Pad { static defaults() { - return super.defaults({ - - _class_specific: 'xy', - - pointSize: {type: 'integer', value: 20, help: 'Defines the points\' size'}, - snap: {type: 'boolean', value: false, help: [ - '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', - ]}, - ephemeral: {type: 'boolean', value: false, help: 'When set to `true`, the point will be drawn only chile touched.'}, - spring: {type: 'boolean', value: false, help: 'When set to `true`, the widget will go back to its default value when released'}, - pips: {type: 'boolean', value: true, help: 'Set to `false` to hide the scale'}, - rangeX: {type: 'object', value: {min:0,max:1}, help: 'Defines the min and max values for the x axis'}, - rangeY: {type: 'object', value: {min:0,max:1}, help: 'Defines the min and max values for the y axis'}, - logScaleX: {type: 'boolean|number', value: false, help: 'Set to `true` to use logarithmic scale for the x axis. Set to `-1` for exponential scale.'}, - logScaleY: {type: 'boolean|number', value: false, help: 'Set to `true` to use logarithmic scale for the y axis. Set to `-1` for exponential scale.'}, - doubleTap: {type: 'boolean|string', value: false, help: [ - 'Set to `true` to make the fader reset to its default value when receiving a double tap.', - 'Can also be an osc address, which case the widget will just send an osc message: `/ `' - ]}, - sensitivity: {type: 'number', value: 1, help: 'Defines the pad\'s sensitivity when `snap` is `false` '}, - - }, [], {}) + return super.defaults().extend({ + style: { + _separator_xy_style: 'Xy style', + pointSize: {type: 'integer', value: 20, help: 'Defines the points\' size'}, + ephemeral: {type: 'boolean', value: false, help: 'When set to `true`, the point will be drawn only while touched.'}, + pips: {type: 'boolean', value: true, help: 'Set to `false` to hide the scale'}, + }, + class_specific: { + snap: {type: 'boolean', value: false, help: [ + '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: {type: 'boolean', value: false, help: 'When set to `true`, the widget will go back to its default value when released'}, + rangeX: {type: 'object', value: {min:0,max:1}, help: 'Defines the min and max values for the x axis'}, + rangeY: {type: 'object', value: {min:0,max:1}, help: 'Defines the min and max values for the y axis'}, + logScaleX: {type: 'boolean|number', value: false, help: 'Set to `true` to use logarithmic scale for the x axis. Set to `-1` for exponential scale.'}, + logScaleY: {type: 'boolean|number', value: false, help: 'Set to `true` to use logarithmic scale for the y axis. Set to `-1` for exponential scale.'}, + doubleTap: {type: 'boolean|string', value: false, help: [ + 'Set to `true` to make the fader reset to its default value when receiving a double tap.', + 'Can also be an osc address, which case the widget will just send an osc message: `/ `' + ]}, + sensitivity: {type: 'number', value: 1, help: 'Defines the pad\'s sensitivity when `snap` is `false` '}, + } + }) } diff --git a/src/client/widgets/scripts/script.js b/src/client/widgets/scripts/script.js index a3440959..7d77591e 100644 --- a/src/client/widgets/scripts/script.js +++ b/src/client/widgets/scripts/script.js @@ -14,29 +14,26 @@ class Script extends Widget { static defaults() { - return super.defaults({ + return super.defaults().extend({ + widget: { + visible: null, + interaction: null + }, + geometry: null, + style: null, + class_specific: { + event: {type: 'string', value: 'value', choices: ['value', 'keyboard'], help: 'Define which events trigger the script\'s execution.'}, + script: {type: 'script', value: '', help: 'Script executed whenever the widget\'s receives the defined event. See documentation.'}, - _class_specific: 'script', + _separator: 'event: keyboard', - event: {type: 'string', value: 'value', choices: ['value', 'keyboard'], help: 'Define which events trigger the script\'s execution.'}, - script: {}, - - _separator: 'event: keyboard', - - keyBinding: {type: 'string|array', value: '', help: 'Key combo `string` or `array` of strings (see KeyboardJS documentation)'}, - keyRepeat: {type: 'boolean', value: true, help: 'Set to `false` to prevent keydown repeats when holding the key combo pressed'}, - keyType: {type: 'string', value: 'keydown', choices: ['keydown', 'keyup', 'both'], help: 'Determines which key event trigger the script\'s execution'}, - - - - }, [ - - 'visible', 'interaction', - '_geometry', 'left', 'top', 'width', 'height', 'expand', - '_style', 'colorBg', 'colorText', 'colorWidget', 'colorFill', 'colorStroke', 'alphaStroke', 'alphaFillOn', 'alphaFillOff', 'padding', 'lineWidth', 'css' - - ], { - script: {type: 'script', value: '', help: 'Script executed whenever the widget\'s receives the defined event. See documentation.'}, + keyBinding: {type: 'string|array', value: '', help: 'Key combo `string` or `array` of strings (see KeyboardJS documentation)'}, + keyRepeat: {type: 'boolean', value: true, help: 'Set to `false` to prevent keydown repeats when holding the key combo pressed'}, + keyType: {type: 'string', value: 'keydown', choices: ['keydown', 'keyup', 'both'], help: 'Determines which key event trigger the script\'s execution'}, + }, + value: { + script: null + } }) } diff --git a/src/client/widgets/scripts/variable.js b/src/client/widgets/scripts/variable.js index afa114e1..c03bf7d5 100644 --- a/src/client/widgets/scripts/variable.js +++ b/src/client/widgets/scripts/variable.js @@ -1,7 +1,7 @@ var Widget = require('../common/widget'), StaticProperties = require('../mixins/static_properties') -module.exports = class Variable extends StaticProperties(Widget, {bypass: true, interaction: false, visible: false}) { +module.exports = class Variable extends StaticProperties(Widget, {interaction: false, visible: false}) { static description() { @@ -11,15 +11,14 @@ module.exports = class Variable extends StaticProperties(Widget, {bypass: true, static defaults() { - return super.defaults({ - - - }, [ - 'visible', 'interaction', - '_geometry', 'left', 'top', 'width', 'height', 'expand', - '_style', 'colorBg', 'colorText', 'colorWidget', 'colorFill', 'colorStroke', 'alphaStroke', 'alphaFillOn', 'alphaFillOff', 'padding', 'css', - 'decimals', 'bypass' - ], {}) + return super.defaults().extend({ + widget: { + visible: null, + interaction: null + }, + geometry: null, + style: null, + }) } diff --git a/src/client/widgets/sliders/encoder.js b/src/client/widgets/sliders/encoder.js index c4efa2bb..3ea5973b 100644 --- a/src/client/widgets/sliders/encoder.js +++ b/src/client/widgets/sliders/encoder.js @@ -1,8 +1,6 @@ var Knob = require('./knob'), - Widget = require('../common/widget'), StaticProperties = require('../mixins/static_properties') - module.exports = class Encoder extends StaticProperties(Knob, {angle: 360, range: {min: 0, max: 1}, sensitivity: 1, steps: ''}) { static description() { @@ -13,32 +11,26 @@ module.exports = class Encoder extends StaticProperties(Knob, {angle: 360, range static defaults() { - return Widget.defaults({ - - _class_specific: 'encoder', - - ticks: {type: 'number', value: 360, help: 'defines the granularity / verbosity of the encoder (number of step for a 360° arc)'}, - back: {type: '*', value: -1, help: 'Defines which value is sent when rotating the encoder anticlockwise'}, - forth: {type: '*', value: 1, help: 'Defines which value is sent when rotating the encoder clockwise'}, - release: {type: 'number', value: '', help: [ - 'Defines which value is sent when releasing the encoder:', - '- Set to `null` to send send no argument in the osc message', - '- Can be an `object` if the type needs to be specified' - ]}, - mode: {type: 'string', value: 'circular', choices: ['circular', 'snap', 'vertical'], help: [ - '- `circular`: relative move in circular motion', - '- `snap`: snap to touch position and move in vertical motion', - '- `vertical`: relative move in vertical motion', - ]}, - doubleTap: {type: 'boolean', value: false, help: [ - '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 (`/ `)' - ]}, - - }, [], { - - touchAddress: {type: 'string', value:'', help: 'OSC address for touched state messages: `/touchAddress [preArgs] 0/1`'}, - + return super.defaults().extend({ + class_specific: { + ticks: {type: 'number', value: 360, help: 'defines the granularity / verbosity of the encoder (number of step for a 360° arc)'}, + back: {type: '*', value: -1, help: 'Defines which value is sent when rotating the encoder anticlockwise'}, + forth: {type: '*', value: 1, help: 'Defines which value is sent when rotating the encoder clockwise'}, + release: {type: 'number', value: '', help: [ + 'Defines which value is sent when releasing the encoder:', + '- Set to `null` to send send no argument in the osc message', + '- Can be an `object` if the type needs to be specified' + ]}, + mode: {type: 'string', value: 'circular', choices: ['circular', 'snap', 'vertical'], help: [ + '- `circular`: relative move in circular motion', + '- `snap`: snap to touch position and move in vertical motion', + '- `vertical`: relative move in vertical motion', + ]}, + doubleTap: {type: 'boolean', value: false, help: [ + '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 (`/ `)' + ]}, + } }) } diff --git a/src/client/widgets/sliders/fader.js b/src/client/widgets/sliders/fader.js index 08d1ad13..67ef857f 100644 --- a/src/client/widgets/sliders/fader.js +++ b/src/client/widgets/sliders/fader.js @@ -11,45 +11,46 @@ class Fader extends Slider { static defaults() { - return super.defaults({ - - _class_specific: 'fader', - - design: {type: 'string', value: 'default', choices: ['default', 'round', 'compact'], help: 'Design style'}, - knobSize: {type: 'number', value: 'auto', help: 'Fader knob size'}, - horizontal: {type: 'boolean', value: false, help: 'Set to `true` to display the fader horizontally'}, - pips: {type: 'boolean', value: false, help: 'Set to `true` to show range breakpoints (ignored if `design` is `compact`)'}, - dashed: {type: 'boolean|array', value: false, help: 'Set to `true` to display a dashed gauge. Can be set as an `array` of two numbers : `[dash_size, gap_size]`'}, - gradient: {type: 'array|object', value: [], help: [ - 'When set, the meter\'s gauge will be filled with a linear color gradient', - '- each item must be a CSS color string.', - '- as an `object`: each key must be a number between 0 and 1', - '- each item must be a CSS color string.', - 'Examples: `[\'blue\', \'red\']`, {\'0\': \'blue\', \'0.9\': \'blue\', \'1\': \'red\'} ' - ]}, - snap: {type: 'boolean', value: false, help: '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: {type: 'boolean', value: false, help: 'When set to `true`, the widget will go back to its `default` value when released'}, - doubleTap: {type: 'boolean', value: false, help: [ - '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: {type: 'object', value: {min:0,max:1}, help: [ - '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: {type: 'boolean|number', value: false, help: 'Set to `true` to use logarithmic scale. Set to `-1` for exponential scale.'}, - sensitivity: {type: 'number', value: 1, help: 'Defines the fader\'s sensitivity when `snap` is `false` '}, - steps: {type: 'string|number|array', value: '', help: [ - 'Restricts the widget\'s value:', - '- `auto`: use values defined in `range`', - '- `number`: define a number of evenly spaced steps', - '- `array`: use arbitrary values', - ]}, - origin: {type: 'number', value: 'auto', help: 'Defines the starting point\'s value of the fader\'s gauge'}, - - }, [], {}, Fader) + return super.defaults(Fader).extend({ + style: { + _separator_fader_style: 'Fader style', + design: {type: 'string', value: 'default', choices: ['default', 'round', 'compact'], help: 'Design style'}, + knobSize: {type: 'number', value: 'auto', help: 'Fader knob size'}, + horizontal: {type: 'boolean', value: false, help: 'Set to `true` to display the fader horizontally'}, + pips: {type: 'boolean', value: false, help: 'Set to `true` to show range breakpoints (ignored if `design` is `compact`)'}, + dashed: {type: 'boolean|array', value: false, help: 'Set to `true` to display a dashed gauge. Can be set as an `array` of two numbers : `[dash_size, gap_size]`'}, + gradient: {type: 'array|object', value: [], help: [ + 'When set, the meter\'s gauge will be filled with a linear color gradient', + '- each item must be a CSS color string.', + '- as an `object`: each key must be a number between 0 and 1', + '- each item must be a CSS color string.', + 'Examples: `[\'blue\', \'red\']`, {\'0\': \'blue\', \'0.9\': \'blue\', \'1\': \'red\'} ' + ]}, + }, + class_specific: { + snap: {type: 'boolean', value: false, help: '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: {type: 'boolean', value: false, help: 'When set to `true`, the widget will go back to its `default` value when released'}, + doubleTap: {type: 'boolean', value: false, help: [ + '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: {type: 'object', value: {min:0,max:1}, help: [ + '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: {type: 'boolean|number', value: false, help: 'Set to `true` to use logarithmic scale. Set to `-1` for exponential scale.'}, + sensitivity: {type: 'number', value: 1, help: 'Defines the fader\'s sensitivity when `snap` is `false` '}, + steps: {type: 'string|number|array', value: '', help: [ + 'Restricts the widget\'s value:', + '- `auto`: use values defined in `range`', + '- `number`: define a number of evenly spaced steps', + '- `array`: use arbitrary values', + ]}, + origin: {type: 'number', value: 'auto', help: 'Defines the starting point\'s value of the fader\'s gauge'}, + } + }) } diff --git a/src/client/widgets/sliders/knob.js b/src/client/widgets/sliders/knob.js index 37c42d73..6bb432dd 100644 --- a/src/client/widgets/sliders/knob.js +++ b/src/client/widgets/sliders/knob.js @@ -11,44 +11,45 @@ module.exports = class Knob extends Slider { static defaults() { - return super.defaults({ - - _class_specific: 'knob', - - design: {type: 'string', value: 'default', choices: ['default', 'solid', 'line'], help: [ - 'Design style', - 'Note: "solid" design uses "colorStroke" for the central knob color.' - ]}, - mode: {type: 'string', value: 'vertical', choices: ['vertical', 'circular', 'snap'], help: [ - '- `circular`: relative move in circular motion', - '- `snap`: snap to touch position and move in vertical motion', - '- `vertical`: relative move in vertical motion', - ]}, - spring: {type: 'boolean', value: false, help: 'When set to `true`, the widget will go back to its `default` value when released'}, - pips: {type: 'boolean', value: false, help: 'Set to `true` to show the scale\'s breakpoints'}, - dashed: {type: 'boolean|array', value: false, help: 'Set to `true` to display a dashed gauge. Can be set as an `array` of two numbers : `[dash_size, gap_size]`'}, - angle: {type: 'number', value: 270, help: 'Defines the angle\'s width of the knob, in degrees'}, - doubleTap: {type: 'boolean', value: false, help: [ - '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: {type: 'object', value: {min:0,max:1}, help: [ - '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: {type: 'boolean|number', value: false, help: 'Set to `true` to use logarithmic scale. Set to `-1` for exponential scale.'}, - sensitivity: {type: 'number', value: 1, help: 'Defines the knob\'s sensitivity when `mode` is not `snap` '}, - steps: {type: 'string|number|array', value: '', help: [ - 'Restricts the widget\'s value:', - '- `auto`: use values defined in `range`', - '- `number`: define a number of evenly spaced steps', - '- `array`: use arbitrary values', - ]}, - origin: {type: 'number', value: 'auto', help: 'Defines the starting point\'s value of the knob\'s gauge'}, - - }, [], {}, Knob) + return super.defaults(Knob).extend({ + style: { + _separator_knob_style: 'Knob style', + design: {type: 'string', value: 'default', choices: ['default', 'solid', 'line'], help: [ + 'Design style', + 'Note: "solid" design uses "colorStroke" for the central knob color.' + ]}, + pips: {type: 'boolean', value: false, help: 'Set to `true` to show the scale\'s breakpoints'}, + dashed: {type: 'boolean|array', value: false, help: 'Set to `true` to display a dashed gauge. Can be set as an `array` of two numbers : `[dash_size, gap_size]`'}, + angle: {type: 'number', value: 270, help: 'Defines the angle\'s width of the knob, in degrees'}, + }, + class_specific: { + mode: {type: 'string', value: 'vertical', choices: ['vertical', 'circular', 'snap'], help: [ + '- `circular`: relative move in circular motion', + '- `snap`: snap to touch position and move in vertical motion', + '- `vertical`: relative move in vertical motion', + ]}, + spring: {type: 'boolean', value: false, help: 'When set to `true`, the widget will go back to its `default` value when released'}, + doubleTap: {type: 'boolean', value: false, help: [ + '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: {type: 'object', value: {min:0,max:1}, help: [ + '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: {type: 'boolean|number', value: false, help: 'Set to `true` to use logarithmic scale. Set to `-1` for exponential scale.'}, + sensitivity: {type: 'number', value: 1, help: 'Defines the knob\'s sensitivity when `mode` is not `snap` '}, + steps: {type: 'string|number|array', value: '', help: [ + 'Restricts the widget\'s value:', + '- `auto`: use values defined in `range`', + '- `number`: define a number of evenly spaced steps', + '- `array`: use arbitrary values', + ]}, + origin: {type: 'number', value: 'auto', help: 'Defines the starting point\'s value of the knob\'s gauge'}, + } + }) }