Merge branch 'master' of github.com:jean-emmanuel/open-stage-control
This commit is contained in:
commit
1ca16a8565
49 changed files with 801 additions and 364 deletions
47
CHANGELOG.md
47
CHANGELOG.md
|
|
@ -1,14 +1,61 @@
|
|||
# Changelog
|
||||
|
||||
## 1.6.3
|
||||
|
||||
- bug fixes
|
||||
- missing context menu (copy, paste) in inspector inputs
|
||||
- osc listeners not resolving "auto" address
|
||||
- `ELECTRON_RUN_AS_NODE` headless mode not working without `--no-gui` option
|
||||
|
||||
- editor
|
||||
- add console panel under the inspector to ease debugging
|
||||
|
||||
- widgets
|
||||
- keyboard: add `velocity` property (allows mapping the touch coordinates between `off` (top) and `on` (bottom))
|
||||
- input: add `validation` property (allows defining a regular expression that the valud must match)
|
||||
- midi
|
||||
- accept sending sysex strings without spaces between the bytes
|
||||
|
||||
- misc
|
||||
- sessions converted from v0 will use the widget's html property to display the former label property
|
||||
|
||||
## 1.6.2
|
||||
|
||||
- bug fixes
|
||||
- matrix: issues when changing non-dynamic properties (content not properly removed)
|
||||
- input: apply default value when receiving an empty value or no value at all
|
||||
|
||||
## 1.6.1
|
||||
|
||||
- bug fixes
|
||||
- keyboard: prevent `script` property from being copied to each key
|
||||
|
||||
- widgets
|
||||
- keyboard: make `on` and `off` properties dynamic
|
||||
- script: add `getIndex` function
|
||||
- matrix/keyboard: `id` variable in script is now the `id` of the child widget that triggered the event
|
||||
|
||||
## 1.6.0
|
||||
|
||||
- bug fixes
|
||||
- range: error when setting `default` property
|
||||
- range: fix `doubleTap` property
|
||||
|
||||
- widgets
|
||||
- all: add `html` property to allow inserting custom content in widgets (label, value, etc) and style it with the `css` property.
|
||||
|
||||
- scripting:
|
||||
- `send()`: ignore the widget's `bypass` property (allows bypassing default messages and define custom ones)
|
||||
- `set()`: add supports for wildcards in the id parameter
|
||||
- `set()`: add a 3rd optional parameter for preventing further script executions and/or osc messages from being sent
|
||||
|
||||
- custom module
|
||||
- automatically reload custom module when the file is modified
|
||||
- add support for loading submodules with `require()`
|
||||
|
||||
- theme
|
||||
- automatically reload theme when the file is modified
|
||||
|
||||
## 1.5.4
|
||||
|
||||
- bug fixes
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
"name": "open-stage-control",
|
||||
"productName": "Open Stage Control",
|
||||
"description": "Libre and modular OSC / MIDI controller",
|
||||
"version": "1.5.4",
|
||||
"version": "1.6.2",
|
||||
"author": {
|
||||
"name": "Jean-Emmanuel Doucet",
|
||||
"email": "jean-emmanuel@ammd.net"
|
||||
|
|
|
|||
|
|
@ -81,6 +81,12 @@ Returns specified server option. `name` must be the option's long name without t
|
|||
|
||||
----
|
||||
|
||||
#### `settings.appAddresses()`
|
||||
|
||||
Returns the server's http addresses.
|
||||
|
||||
----
|
||||
|
||||
#### `options`
|
||||
|
||||
`Array` containing the extra options passed to `--custom-module` after the filename
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ A widget can fetch its own properties or its direct parent's by using the keywor
|
|||
|
||||
#### `uuid`
|
||||
|
||||
Each widget has a unique random identifier that can be retreived with the property name `uuid` (e.g. `@{this.uuid}`, `@{parent.uuid}`).
|
||||
Each widget has a unique random identifier that can be retreived with the property name `uuid` (e.g. `@{this.uuid}`, `@{parent.uuid}`).
|
||||
|
||||
#### Dynamic properties
|
||||
|
||||
|
|
@ -34,12 +34,12 @@ Some properties have much cheaper update routines and can be considered as `dyna
|
|||
|
||||
#### Object properties
|
||||
|
||||
If the retreived property is an object (`{}`) or an array (`[]`), a subset can be retreived directly by appending a dot and a key (array index or object key) : `@{parent.variables.key}`
|
||||
If the retreived property is an object (`{}`), a subset can be retreived directly by appending a dot and a key (array index or object key) : `@{parent.variables.key}`
|
||||
|
||||
|
||||
#### Nesting
|
||||
|
||||
The inheritance syntax supports 1-level nesting : `@{fader_@{toggle_1}}`
|
||||
The inheritance syntax supports 1-level nesting for defining the target widget's id dynamically : `@{fader_@{toggle_1}}`
|
||||
|
||||
|
||||
## OSC listeners: `OSC{address, default, usePreArgs}`
|
||||
|
|
@ -65,7 +65,7 @@ Options can contain `@{}` blocks.
|
|||
|
||||
## Javascript: `JS{{ <code> }}`
|
||||
|
||||
This syntax allows writing formulas in pure javascript. The code will be compiled as a function and executed in a restricted context.
|
||||
This syntax allows writing formulas in [Javascript](https://developer.mozilla.org/en-US/docs/Web/JavaScript). The code will be compiled as a function and executed in a restricted context.
|
||||
|
||||
- if no `return` statement is found, the formula will return an empty string
|
||||
- javascript [strict mode](https://developer.mozilla.org/fr/docs/Web/JavaScript/Reference/Strict_mode) is always enabled
|
||||
|
|
@ -84,7 +84,7 @@ A property cannot contain multiple `JS{{}}` blocks
|
|||
- `url`: server url,
|
||||
- `platform`: operating system as seen by the client
|
||||
|
||||
In this context, `@{} / OSC{}` are also seen as variables (named `VAR_XXX`), not as the value they hold,
|
||||
In this context, `@{} / OSC{}` are also seen as variables (named `VAR_XXX`), not as the value they hold.
|
||||
|
||||
Parsing errors can be read in the DevTool console (F12).
|
||||
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@
|
|||
| <h6 id="alphaFillOn">alphaFillOn<sup><i class="fas fa-bolt" title="dynamic"></i></sup><a class="headerlink" href="#alphaFillOn" title="Permanent link">#</a></h6> | `number` | <code>"auto"</code> | Fill color opacity (on). |
|
||||
| <h6 id="lineWidth">lineWidth<sup><i class="fas fa-bolt" title="dynamic"></i></sup><a class="headerlink" href="#lineWidth" title="Permanent link">#</a></h6> | `number` | <code>"auto"</code> | Stroke width. |
|
||||
| <h6 id="padding">padding<sup><i class="fas fa-bolt" title="dynamic"></i></sup><a class="headerlink" href="#padding" title="Permanent link">#</a></h6> | `number` | <code>"auto"</code> | Inner spacing. |
|
||||
| <h6 id="html">html<sup><i class="fas fa-bolt" title="dynamic"></i></sup><a class="headerlink" href="#html" title="Permanent link">#</a></h6> | `string` | <code>""</code> | Custom html content to be inserted in the widget (before the widget's content).<br/><br/>The code is automatically wrapped in <div class="html"></div><br/><br/>Allowed HTML tags:<br/><br/> h1-6, blockquote, p, a, ul, ol, nl, li,<br/><br/> b, i, strong, em, strike, code, hr, br, div,<br/><br/> table, thead, img, caption, tbody, tr, th, td, pre<br/><br/>Allowed attributes:<br/><br/> <*>: class, style, title<br/><br/> <img>: src, width, height |
|
||||
| <h6 id="css">css<sup><i class="fas fa-bolt" title="dynamic"></i></sup><a class="headerlink" href="#css" title="Permanent link">#</a></h6> | `string` | <code>""</code> | CSS rules. See <a href="https://openstagecontrol.ammd.net/docs/customization/css-tips/">documentation</a>.<br/><br/>Available css variables:<br/>- `--color-background`: `colorBg`<br/>- `--color-widget`: `colorWidget`<br/>- `--color-fill`: `colorFill`<br/>- `--color-stroke`: `colorStroke`<br/>- `--color-text`: `colorText`<br/>- `--widget-padding`: `padding`<br/>- `--line-width`: `lineWidth`<br/>- `--alpha-fill-on`: `alphaFillOn`<br/>- `--alpha-fill-off`: `alphaFillOff`<br/>- `--alpha-stroke`: `alphaStroke` |
|
||||
|
||||
|
||||
|
|
@ -341,8 +342,8 @@
|
|||
| <h6 id="keyboard_keys">keys<a class="headerlink" href="#keyboard_keys" title="Permanent link">#</a></h6> | `number` | <code>25</code> | Defines the number keys |
|
||||
| <h6 id="keyboard_start">start<a class="headerlink" href="#keyboard_start" title="Permanent link">#</a></h6> | `number` | <code>48</code> | MIDI note number to start with (default is C4)<br/><br/>Standard keyboards settings are: `[25, 48]`, `[49, 36]`, `[61, 36]`, `[88, 21]` |
|
||||
| <h6 id="keyboard_traversing">traversing<sup><i class="fas fa-bolt" title="dynamic"></i></sup><a class="headerlink" href="#keyboard_traversing" title="Permanent link">#</a></h6> | `boolean` | <code>true</code> | Set to `false` to disable traversing gestures |
|
||||
| <h6 id="keyboard_on">on<a class="headerlink" href="#keyboard_on" title="Permanent link">#</a></h6> | `*` | <code>1</code> | Set to `null` to send send no argument in the osc message<br/><br/>Can be an `object` if the type needs to be specified (see preArgs) |
|
||||
| <h6 id="keyboard_off">off<a class="headerlink" href="#keyboard_off" title="Permanent link">#</a></h6> | `*` | <code>0</code> | Set to `null` to send send no argument in the osc message<br/><br/>Can be an `object` if the type needs to be specified (see preArgs) |
|
||||
| <h6 id="keyboard_on">on<sup><i class="fas fa-bolt" title="dynamic"></i></sup><a class="headerlink" href="#keyboard_on" title="Permanent link">#</a></h6> | `*` | <code>1</code> | Set to `null` to send send no argument in the osc message<br/><br/>Can be an `object` if the type needs to be specified (see preArgs) |
|
||||
| <h6 id="keyboard_off">off<sup><i class="fas fa-bolt" title="dynamic"></i></sup><a class="headerlink" href="#keyboard_off" title="Permanent link">#</a></h6> | `*` | <code>0</code> | Set to `null` to send send no argument in the osc message<br/><br/>Can be an `object` if the type needs to be specified (see preArgs) |
|
||||
| <h6 id="keyboard_mode">mode<a class="headerlink" href="#keyboard_mode" title="Permanent link">#</a></h6> | `string` | <code>"push"</code> | Interraction mode:<br/>- `push` (press & release)<br/>- `toggle` (on/off switches)<br/>- `tap` (no release)<br/><br/>Choices: `push`, `toggle`, `tap` |
|
||||
|
||||
??? api "<div id="patchbay">patchbay<a class="headerlink" href="#patchbay" title="Permanent link">#</a></div>"
|
||||
|
|
@ -456,12 +457,6 @@
|
|||
??? api "<div id="html">html<a class="headerlink" href="#html" title="Permanent link">#</a></div>"
|
||||
Simple HTML parser.
|
||||
|
||||
=== "html"
|
||||
|
||||
| property | type |default | description |
|
||||
| --- | --- | --- | --- |
|
||||
| <h6 id="html_html">html<sup><i class="fas fa-bolt" title="dynamic"></i></sup><a class="headerlink" href="#html_html" title="Permanent link">#</a></h6> | `string` | <code>""</code> | Allowed HTML tags:<br/><br/> h1-6, blockquote, p, a, ul, ol, nl, li,<br/><br/> b, i, strong, em, strike, code, hr, br, div,<br/><br/> table, thead, img, caption, tbody, tr, th, td, pre<br/><br/>Allowed attributes:<br/><br/> <*>: class, style, title<br/><br/> <img>: src, width, height |
|
||||
|
||||
??? api "<div id="image">image<a class="headerlink" href="#image" title="Permanent link">#</a></div>"
|
||||
Load a image (url or base64-encoded).
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,11 @@
|
|||
# Scripting
|
||||
|
||||
The `script` property allows widgets to run javascript code when their value update. It differs from the [javascript property syntax ](./advanced-syntaxes.md#available-variables) in the following ways:
|
||||
The `script` property allows widgets to run [Javascript](https://developer.mozilla.org/en-US/docs/Web/JavaScript) code when their value update.
|
||||
|
||||
- no `JS{{}}` wrapper, just the code
|
||||
- `@{}`, `OSC{}`, `JS{{}}` and `#{}` blocks are replaced with their value before the script's compilation
|
||||
!!! info "It's slightly different from the [javascript property syntax ](./advanced-syntaxes/#javascript-js-code)"
|
||||
|
||||
!!! warning "Avoid advanced syntax in scripts"
|
||||
To avoid syntax errors it is recommended to use `getProp()` and `get()` instead of `@{}` and `OSC{}`. `JS{{}}` and `#{}` blocks should be avoided here as well.
|
||||
- no `JS{{}}` wrapper, just the code
|
||||
- `@{}`, `OSC{}`, `JS{{}}` and `#{}` blocks are replaced with their literal value before the script's compilation, therefore **it is recommended to avoid these syntaxes** and use `getProp()` and `get()` instead.
|
||||
|
||||
## Event-dependent variables
|
||||
|
||||
|
|
@ -18,6 +17,13 @@ Depending on what triggered the script's execution, a few variables are availabl
|
|||
- `value`: widget's value
|
||||
- `touch`: see [Touch state](#touch-state)
|
||||
|
||||
??? infos "Keyboard & Matrix"
|
||||
In keyboards and matrices, `id` is the id of the child widget that triggered the event, and `value` is an array containing the children's values.
|
||||
The touched widget's value can be retrieved with:
|
||||
```javascript
|
||||
value[getIndex(id)]
|
||||
```
|
||||
|
||||
**Event: keyboard** (script widget only)
|
||||
|
||||
- `type` (`string`): `keydown` or `keyup`
|
||||
|
|
@ -63,12 +69,16 @@ Returns the value of the first matching widget.
|
|||
|
||||
----
|
||||
|
||||
#### `set(id, value)`
|
||||
- `id`: widget `id` as a string. Can be `"this"` to target the host widget, or `"parent"` to target the parent widget.
|
||||
#### `set(id, value, options)`
|
||||
- `id`: widget `id` as a string. Can be `"this"` to target the host widget, or `"parent"` to target the parent widget. `id` may contains wildcards ('\*').
|
||||
- `value`: new value for the widget.
|
||||
- `options` (optional): `object`, accepts the following items:
|
||||
- `sync: false` (prevents widgets from triggering synchronization and scripts)
|
||||
- `send: false` (prevents widgets from sending osc messages)
|
||||
|
||||
Sets the value of the first matching widget.
|
||||
If the event that triggered the script's execution was initiated by a user interaction, this will make the widget send its value as well.
|
||||
Sets the value of the first matching widget. If `ìd` contains wildcards, affects all matching widgets **except** the emitting widget.
|
||||
|
||||
If the event that triggered the script's execution was initiated by a user interaction, this will make the widget send its value as well (unless `options` is set to `{send: false}`).
|
||||
|
||||
----
|
||||
|
||||
|
|
@ -77,8 +87,12 @@ If the event that triggered the script's execution was initiated by a user inter
|
|||
- `address`: osc address, must start with a `/`
|
||||
- `args`: value or `{type: "OSC_TYPE_LETTER", value: VALUE}` `object`
|
||||
|
||||
Sends an osc message.
|
||||
|
||||
If the event that triggered the script's execution was not initiated by a user interaction, this function will have no effect.
|
||||
|
||||
This function ignores the widget's `bypass` property.
|
||||
|
||||
----
|
||||
|
||||
#### `getProp(id, name)`
|
||||
|
|
@ -89,11 +103,18 @@ Returns the property called `"name"` of the first matching widget.
|
|||
|
||||
----
|
||||
|
||||
#### `getIndex(id)`
|
||||
- `id` (optional): widget `id` as a string. Defaults to `"this"`.
|
||||
|
||||
Returns the widget's index in its container.
|
||||
|
||||
----
|
||||
|
||||
#### `updateProp(id, name)`
|
||||
- `id`: widget `id` as a string. Can be `"this"` to target the host widget, or `"parent"` to target the parent widget.
|
||||
- `name`: property name.
|
||||
|
||||
Forcers a widget to check if one of its properties has changed and update itself if needed.
|
||||
Forces a widget to check if one of its properties has changed and update itself if needed.
|
||||
|
||||
----
|
||||
|
||||
|
|
@ -174,9 +195,11 @@ Sets the scroll state of a container.
|
|||
#### `toolbar(i1, i2, ...)`
|
||||
- `iX`: menu entry index
|
||||
|
||||
Trigger toolbar action at specified index. Examples:
|
||||
Trigger toolbar action at specified index.
|
||||
|
||||
- `toolbar(0, 0)` -> Open a new session
|
||||
- `toolbar(3)` -> Toggle full screen
|
||||
!!! example "Examples"
|
||||
|
||||
Actions will only be triggered if initiated with a user interaction. Fullscreen cannot be toggled with a simulated interaction (i.e. using `/SET`)
|
||||
- `toolbar(0, 0)` -> Open a new session
|
||||
- `toolbar(3)` -> Toggle full screen
|
||||
|
||||
Actions will only be triggered if initiated with a user interaction. Fullscreen cannot be toggled with a simulated interaction (i.e. using `/SET`)
|
||||
|
|
|
|||
|
|
@ -2,13 +2,14 @@ var widgetManager = require('../managers/widgets'),
|
|||
resize = require('../events/resize'),
|
||||
stateManager = require('../managers/state'),
|
||||
parser = require('../parser'),
|
||||
Panel,
|
||||
Panel, Matrix,
|
||||
editor,
|
||||
scrollState = {}
|
||||
|
||||
setTimeout(()=>{
|
||||
editor = require('./')
|
||||
Panel = require('../widgets/containers/panel')
|
||||
Matrix = require('../widgets/containers/matrix')
|
||||
})
|
||||
|
||||
function updateWidget(widget, options={}) {
|
||||
|
|
@ -43,6 +44,7 @@ function updateWidget(widget, options={}) {
|
|||
}
|
||||
|
||||
var reuseChildren = options.reuseChildren !== false && widget instanceof Panel
|
||||
&& !(widget instanceof Matrix)
|
||||
|
||||
var children = undefined,
|
||||
removedChildren = []
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ var {updateWidget, incrementWidget} = require('./data-workers'),
|
|||
UiInspector = require('../ui/ui-inspector'),
|
||||
UiTree = require('../ui/ui-tree'),
|
||||
UiDragResize = require('../ui/ui-dragresize'),
|
||||
uiConsole = require('../ui/ui-console'),
|
||||
notifications = require('../ui/notifications'),
|
||||
locales = require('../locales'),
|
||||
{leftUiSidePanel, rightUiSidePanel} = require('../ui/'),
|
||||
|
|
@ -51,17 +52,19 @@ class Editor {
|
|||
w.props[propName] = previousValue
|
||||
updateWidget(w, {changedProps: [propName], preventSelect: this.selectedWidgets.length > 1})
|
||||
|
||||
notifications.add({
|
||||
if (uiConsole.minimized || rightUiSidePanel.minimized) notifications.add({
|
||||
class: 'error',
|
||||
message: locales('inspector_error'),
|
||||
duration: 7000
|
||||
})
|
||||
console.error(
|
||||
`Error while setting ${propName} to: ${JSON.stringify(value)}.`,
|
||||
'It\'s probably a bug, please a new bug ticket with these informations (https://github.com/jean-emmanuel/open-stage-control/issues).'
|
||||
`Error while setting ${propName} to: ${JSON.stringify(value)}.\n` +
|
||||
'It\'s probably a bug, please open a new bug ticket with the followigin informations at' +
|
||||
'https://github.com/jean-emmanuel/open-stage-control/issues'
|
||||
)
|
||||
console.error(e)
|
||||
error = true
|
||||
throw e
|
||||
// console.error(e)
|
||||
// error = true
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,9 @@ if (macOs) {
|
|||
DOM.dispatchEvent(event.target, 'fast-right-click', event)
|
||||
})
|
||||
} else {
|
||||
document.body.setAttribute('oncontextmenu', 'return false')
|
||||
document.body.addEventListener('contextmenu', (event)=>{
|
||||
if (event.target && (!event.target.tagName.match(/INPUT|TEXTAREA|OSC-CONSOLE|OSC-CONSOLE-MESSAGE/))) event.preventDefault()
|
||||
})
|
||||
}
|
||||
|
||||
function mouseToFastClick(event) {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,10 @@
|
|||
module.exports = {
|
||||
|
||||
// console
|
||||
console_title: 'Console',
|
||||
console_clear: 'Clear console',
|
||||
|
||||
|
||||
// editor
|
||||
editor: 'Editor',
|
||||
editor_enabled: 'Enabled',
|
||||
|
|
@ -46,7 +51,7 @@ module.exports = {
|
|||
// inspector
|
||||
inspector_color_confirm: 'Confirm',
|
||||
inspector_color_apply: 'Apply',
|
||||
inspector_error: 'An error just occured, open F12 to read more.',
|
||||
inspector_error: 'An error just occured, open the console to read more.',
|
||||
|
||||
// nosleep
|
||||
nosleep: 'Prevent sleep',
|
||||
|
|
|
|||
|
|
@ -1,5 +1,9 @@
|
|||
module.exports = {
|
||||
|
||||
// console
|
||||
console_title: 'Console',
|
||||
console_clear: 'Vider la console',
|
||||
|
||||
// editor
|
||||
editor: 'Editeur',
|
||||
editor_enabled: 'Activé',
|
||||
|
|
@ -46,7 +50,7 @@ module.exports = {
|
|||
// inspector
|
||||
inspector_color_confirm: 'Confirmer',
|
||||
inspector_color_apply: 'Appliquer',
|
||||
inspector_error: 'Une erreur vient de survenir, appuyez sur F12 pour en savoir plus.',
|
||||
inspector_error: 'Une erreur vient de survenir, ouvrez la console pour en savoir plus.',
|
||||
|
||||
// nosleep
|
||||
nosleep: 'Empêcher la veille',
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ var ipc = require('../../ipc/'),
|
|||
uiFileupload = require('../../ui/ui-fileupload'),
|
||||
UiModal = require('../../ui/ui-modal'),
|
||||
uiLoading = require('../../ui/ui-loading'),
|
||||
uiConsole = require('../../ui/ui-console'),
|
||||
{saveAs} = require('file-saver'),
|
||||
widgetManager = require('../widgets'),
|
||||
locales = require('../../locales'),
|
||||
|
|
@ -39,6 +40,7 @@ var SessionManager = class SessionManager {
|
|||
setTimeout(()=>{
|
||||
try {
|
||||
|
||||
uiConsole.clear()
|
||||
this.session = new Session(session)
|
||||
container.innerHTML = ''
|
||||
parser.reset()
|
||||
|
|
|
|||
|
|
@ -211,6 +211,12 @@ var converters = [
|
|||
|
||||
}
|
||||
|
||||
var label = data.label === undefined ? 'auto' : data.label
|
||||
if (label !== false && data.type && !data.type.match(/button|menu|modal|clone|html/)) {
|
||||
label = label === 'auto' ? '@{this.id}' : label
|
||||
data.html = label
|
||||
}
|
||||
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
var StackTrace = require('stacktrace-js'),
|
||||
ipc = require('./ipc')
|
||||
ipc = require('./ipc'),
|
||||
uiConsole
|
||||
|
||||
window.onerror = function(msg,url,row,col, error) {
|
||||
|
||||
|
|
@ -17,10 +18,14 @@ window.onerror = function(msg,url,row,col, error) {
|
|||
|
||||
}).join('\n')
|
||||
|
||||
if (!uiConsole) uiConsole = require('./ui/ui-console')
|
||||
uiConsole.log('error', `${msg}\n${stringifiedStack}`)
|
||||
ipc.send('errorLog', `(ERROR, CLIENT) ${msg}\n${stringifiedStack}`)
|
||||
|
||||
}).catch(()=>{
|
||||
|
||||
if (!uiConsole) uiConsole = require('./ui/ui-console')
|
||||
uiConsole.log('error', `${msg}\n at ${url}:${row}:${col}\n (no stacktrace available)`)
|
||||
ipc.send('errorLog', `(ERROR, CLIENT) ${msg}\n at ${url}:${row}:${col}\n (no stacktrace available)`)
|
||||
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
var UiSidePanel = require('./ui-sidepanel'),
|
||||
locales = require('../locales')
|
||||
|
||||
|
||||
module.exports = {
|
||||
leftUiSidePanel: new UiSidePanel({selector: 'osc-panel-container.left', label: locales('editor_tree')}),
|
||||
rightUiSidePanel: new UiSidePanel({selector: 'osc-panel-container.right', label: locales('editor_inspector')})
|
||||
|
|
|
|||
|
|
@ -3,4 +3,5 @@ require('../events/click')
|
|||
require('./ios')
|
||||
require('./notifications')
|
||||
require('./ui-workspace')
|
||||
require('./ui-toolbar')
|
||||
require('./main-menu')
|
||||
require('./ui-console')
|
||||
|
|
|
|||
236
src/client/ui/main-menu.js
Normal file
236
src/client/ui/main-menu.js
Normal file
|
|
@ -0,0 +1,236 @@
|
|||
var UiToolbar = require('./ui-toolbar'),
|
||||
ipc = require('../ipc'),
|
||||
locales = require('../locales'),
|
||||
notifications = require('./notifications'),
|
||||
fullscreen = require('./fullscreen'),
|
||||
editor = require('../editor'),
|
||||
sessionManager = require('../managers/session/'),
|
||||
stateManager = require('../managers/state'),
|
||||
{leftUiSidePanel, rightUiSidePanel} = require('../ui/'),
|
||||
uiConsole = require('../ui/ui-console')
|
||||
|
||||
|
||||
var recentSessions = [{label: locales('file_open_recent_wait'), class: 'disabled'}]
|
||||
var menuEntries = [
|
||||
|
||||
{
|
||||
label: locales('session'),
|
||||
action: [
|
||||
{
|
||||
label: locales('session_new'),
|
||||
action: sessionManager.create.bind(sessionManager),
|
||||
class: ()=>{return READ_ONLY ? 'disabled' :''}
|
||||
},
|
||||
{
|
||||
separator: true
|
||||
},
|
||||
{
|
||||
label: locales('file_open'),
|
||||
action: sessionManager.browse.bind(sessionManager),
|
||||
shortcut: 'mod + o',
|
||||
class: ()=>{return READ_ONLY ? 'disabled' :''}
|
||||
},
|
||||
{
|
||||
label: locales('file_open_recent'),
|
||||
action: recentSessions,
|
||||
class: ()=>{return !recentSessions.length ? 'disabled' :''}
|
||||
},
|
||||
{
|
||||
separator: true
|
||||
},
|
||||
{
|
||||
label: locales('file_save'),
|
||||
action: sessionManager.save.bind(sessionManager),
|
||||
shortcut: 'mod + s',
|
||||
class: ()=>{return READ_ONLY || sessionManager.session === null ? 'disabled' :''}
|
||||
},
|
||||
{
|
||||
label: locales('file_save_as'),
|
||||
action: sessionManager.saveAs.bind(sessionManager),
|
||||
shortcut: 'mod + shift + s',
|
||||
class: ()=>{return READ_ONLY || sessionManager.session === null ? 'disabled' :''}
|
||||
},
|
||||
{
|
||||
separator: true
|
||||
},
|
||||
{
|
||||
label: locales('file_import'),
|
||||
action: sessionManager.import.bind(sessionManager),
|
||||
class: ()=>{return READ_ONLY ? 'disabled' :''}
|
||||
},
|
||||
{
|
||||
label: locales('file_export'),
|
||||
action: sessionManager.export.bind(sessionManager),
|
||||
class: ()=>{return READ_ONLY || sessionManager.session === null ? 'disabled' :''}
|
||||
},
|
||||
|
||||
]
|
||||
},
|
||||
{
|
||||
label: locales('state'),
|
||||
class: ()=>{return sessionManager.session === null ? 'disabled' : ''},
|
||||
action: [
|
||||
{
|
||||
label: locales('state_store'),
|
||||
action: stateManager.quickSave.bind(stateManager)
|
||||
},
|
||||
{
|
||||
label: locales('state_recall'),
|
||||
class: ()=>{return stateManager.quickState === null ? 'disabled' : ''},
|
||||
action: stateManager.quickLoad.bind(stateManager)
|
||||
},
|
||||
{
|
||||
label: locales('state_send'),
|
||||
action: ()=>{
|
||||
stateManager.send()
|
||||
notifications.add({
|
||||
icon: 'sliders-h',
|
||||
message: locales('state_sendsuccess')
|
||||
})
|
||||
}
|
||||
},
|
||||
{
|
||||
separator: true
|
||||
},
|
||||
{
|
||||
label: locales('file_open'),
|
||||
action: stateManager.browse.bind(stateManager),
|
||||
class: ()=>{return READ_ONLY ? 'disabled' :''}
|
||||
},
|
||||
{
|
||||
label: locales('file_save'),
|
||||
action: stateManager.save.bind(stateManager),
|
||||
class: ()=>{return READ_ONLY ? 'disabled' :''}
|
||||
},
|
||||
{
|
||||
label: locales('file_save_as'),
|
||||
action: stateManager.saveAs.bind(stateManager),
|
||||
class: ()=>{return READ_ONLY ? 'disabled' :''}
|
||||
},
|
||||
{
|
||||
separator: true
|
||||
},
|
||||
{
|
||||
label: locales('file_import'),
|
||||
action: stateManager.import.bind(stateManager),
|
||||
class: ()=>{return READ_ONLY ? 'disabled' :''}
|
||||
},
|
||||
{
|
||||
label: locales('file_export'),
|
||||
action: stateManager.export.bind(stateManager),
|
||||
class: ()=>{return READ_ONLY ? 'disabled' :''}
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
label: locales('editor'),
|
||||
class: ()=>{return sessionManager.session === null || READ_ONLY ? 'disabled' : ''},
|
||||
action: [
|
||||
{
|
||||
label: locales('editor_enabled'),
|
||||
class: ()=>{return 'toggle ' + (editor.enabled ? 'on' : 'off')},
|
||||
action: ()=>{
|
||||
if (editor.enabled) editor.disable()
|
||||
else editor.enable()
|
||||
},
|
||||
shortcut: 'mod + e'
|
||||
},
|
||||
{
|
||||
separator: true
|
||||
},
|
||||
{
|
||||
label: locales('editor_grid'),
|
||||
class: ()=>{return 'toggle ' + (editor.grid ? 'on' : 'off')},
|
||||
action: editor.toggleGrid.bind(editor),
|
||||
shortcut: 'mod + g'
|
||||
|
||||
},
|
||||
{
|
||||
label: locales('editor_tree'),
|
||||
class: ()=>{return 'toggle ' + (leftUiSidePanel.minimized ? 'off' : 'on')},
|
||||
action: ()=>{return leftUiSidePanel.minimized ? leftUiSidePanel.restore() : leftUiSidePanel.minimize()},
|
||||
shortcut: 'mod + t'
|
||||
|
||||
|
||||
},
|
||||
{
|
||||
label: locales('editor_inspector'),
|
||||
class: ()=>{return 'toggle ' + (rightUiSidePanel.minimized ? 'off' : 'on')},
|
||||
action: ()=>{return rightUiSidePanel.minimized ? rightUiSidePanel.restore() : rightUiSidePanel.minimize()},
|
||||
shortcut: 'mod + i'
|
||||
},
|
||||
{
|
||||
label: locales('console_title'),
|
||||
class: ()=>{return 'toggle ' + (uiConsole.minimized ? 'off' : 'on')},
|
||||
action: ()=>{return uiConsole.minimized ? uiConsole.restore() : uiConsole.minimize()}
|
||||
},
|
||||
{
|
||||
separator: true
|
||||
},
|
||||
{
|
||||
label: locales('editor_percents'),
|
||||
class: ()=>{return 'toggle ' + (editor.usePercents ? 'on' : 'off')},
|
||||
action: ()=>{editor.usePercents = !editor.usePercents}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
separator: true
|
||||
},
|
||||
{
|
||||
label: locales('fullscreen'),
|
||||
class: ()=>{return 'toggle ' + (fullscreen.isFullscreen ? 'on' : 'off')},
|
||||
action: ()=>{
|
||||
if (fullscreen.isEnabled) fullscreen.toggle()
|
||||
},
|
||||
shortcut: 'f11'
|
||||
}
|
||||
|
||||
]
|
||||
|
||||
if (navigator.userAgent.match(/Android|iPhone|iPad|iPod/i)) {
|
||||
|
||||
var NoSleep = require('nosleep.js'),
|
||||
noSleep = new NoSleep(),
|
||||
noSleepState = false
|
||||
|
||||
menuEntries.push({
|
||||
label: locales('nosleep'),
|
||||
class: ()=>{return 'toggle ' + (noSleepState ? 'on' : 'off')},
|
||||
action:()=>{
|
||||
noSleepState = !noSleepState
|
||||
if (noSleepState) noSleep.disable()
|
||||
else noSleep.enable()
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class MainMenu extends UiToolbar {
|
||||
|
||||
constructor(options) {
|
||||
|
||||
super(options)
|
||||
|
||||
ipc.on('sessionList', (data)=>{
|
||||
if (recentSessions.length) {
|
||||
recentSessions.splice(0, 10)
|
||||
}
|
||||
for (let s of data) [
|
||||
recentSessions.push({
|
||||
label: s,
|
||||
action: ()=>{sessionManager.requestOpen(s)}
|
||||
})
|
||||
]
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
module.exports = new MainMenu({selector: '#main-menu', position: [40, 1], entries: menuEntries})
|
||||
113
src/client/ui/ui-console.js
Normal file
113
src/client/ui/ui-console.js
Normal file
|
|
@ -0,0 +1,113 @@
|
|||
var UiSidePanel = require('./ui-sidepanel'),
|
||||
html = require('nanohtml'),
|
||||
raw = require('nanohtml/raw'),
|
||||
locales = require('../locales'),
|
||||
{icon} = require('./utils')
|
||||
|
||||
class UiConsole extends UiSidePanel {
|
||||
|
||||
constructor(options) {
|
||||
|
||||
super(options)
|
||||
|
||||
this.header = DOM.get(this.container, 'osc-panel-header')[0]
|
||||
|
||||
this.header.appendChild(html`<label>${locales('console_title')}</label>`)
|
||||
this.messages = this.content.appendChild(html`<osc-console></osc-console>`)
|
||||
// this.inputWrapper = this.container.appendChild(html`<osc-console-input></osc-console-inpu>`)
|
||||
// this.input = this.inputWrapper.appendChild(html`<textarea></textarea>`)
|
||||
|
||||
this.actions = this.header.appendChild(html`<div class="actions"></div>`)
|
||||
this.clearBtn = this.actions.appendChild(html`<div class="clear" title="${locales('console_clear')}">${raw(icon('trash'))}</div>`)
|
||||
this.clearBtn.addEventListener('click', ()=>{
|
||||
this.clear()
|
||||
})
|
||||
|
||||
this.length = 0
|
||||
this.maxLength = 200
|
||||
|
||||
var _this = this,
|
||||
log = console.log,
|
||||
error = console.error
|
||||
|
||||
console.log = function(message){
|
||||
_this.log('log', message)
|
||||
log(...arguments)
|
||||
}
|
||||
|
||||
console.error = function(message){
|
||||
_this.log('error', message)
|
||||
error(...arguments)
|
||||
}
|
||||
|
||||
// this.input.addEventListener('keydown', (event)=>{
|
||||
// if (event.keyCode === 13 && !event.shiftKey) {
|
||||
//
|
||||
// event.preventDefault()
|
||||
// DOM.dispatchEvent(event.target, 'change')
|
||||
//
|
||||
// }
|
||||
// })
|
||||
//
|
||||
// this.input.addEventListener('change', (event)=>{
|
||||
// try {
|
||||
// console.log(eval(this.input.value))
|
||||
// } catch (err) {
|
||||
// console.error(err)
|
||||
// }
|
||||
// this.input.value = ''
|
||||
// })
|
||||
|
||||
|
||||
this.enable()
|
||||
|
||||
}
|
||||
|
||||
log(type, message) {
|
||||
|
||||
var node = this.messages.appendChild(html`
|
||||
<osc-console-message class="${type}">
|
||||
|
||||
</osc-console-message>
|
||||
`)
|
||||
|
||||
if (typeof message === 'object') {
|
||||
if (!(message instanceof Error)) {
|
||||
try {
|
||||
message = JSON.stringify(message)
|
||||
} catch (_) {}
|
||||
} else {
|
||||
message = String(message) + message.stack
|
||||
}
|
||||
}
|
||||
|
||||
node.textContent = message
|
||||
if (type !== 'error' && node.textContent.match(/error/i)) node.classList.add('error')
|
||||
|
||||
node.scrollIntoView()
|
||||
|
||||
if (++this.length > this.maxLength) this.purge()
|
||||
|
||||
|
||||
}
|
||||
|
||||
purge() {
|
||||
|
||||
var children = [...this.messages.children]
|
||||
for (var i = 0; i < this.maxLength / 2; i++) {
|
||||
this.messages.removeChild(children[i])
|
||||
}
|
||||
this.length = this.maxLength / 2 + 1
|
||||
|
||||
}
|
||||
|
||||
clear() {
|
||||
|
||||
this.messages.innerHTML = ''
|
||||
this.length = 0
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = new UiConsole({selector: '#osc-console', size: 40})
|
||||
|
|
@ -223,6 +223,8 @@ class UiInspector extends UiWidget {
|
|||
value: v
|
||||
})
|
||||
|
||||
// this may not be reached if an error is thrown
|
||||
// but the lock will undone at the next inspect() call
|
||||
this.lock = false
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ class UiSidePanel extends UiWidget {
|
|||
|
||||
this.cacheKey = 'ui.' + options.selector
|
||||
|
||||
this.minWidth = options.size || 250
|
||||
this.minWidth = options.size === undefined ? 250 : options.size
|
||||
this.width = cache.get(this.cacheKey + '.width') || options.size || 250
|
||||
|
||||
this.disabled = false
|
||||
|
|
|
|||
|
|
@ -1,209 +1,5 @@
|
|||
var UiWidget = require('./ui-widget'),
|
||||
ContextMenu = require('./context-menu'),
|
||||
ipc = require('../ipc'),
|
||||
locales = require('../locales'),
|
||||
notifications = require('./notifications'),
|
||||
fullscreen = require('./fullscreen'),
|
||||
editor = require('../editor'),
|
||||
sessionManager = require('../managers/session/'),
|
||||
stateManager = require('../managers/state'),
|
||||
{leftUiSidePanel, rightUiSidePanel} = require('../ui/')
|
||||
|
||||
|
||||
var recentSessions = [{label: locales('file_open_recent_wait'), class: 'disabled'}]
|
||||
var menuEntries = [
|
||||
|
||||
{
|
||||
label: locales('session'),
|
||||
action: [
|
||||
{
|
||||
label: locales('session_new'),
|
||||
action: sessionManager.create.bind(sessionManager),
|
||||
class: ()=>{return READ_ONLY ? 'disabled' :''}
|
||||
},
|
||||
{
|
||||
separator: true
|
||||
},
|
||||
{
|
||||
label: locales('file_open'),
|
||||
action: sessionManager.browse.bind(sessionManager),
|
||||
shortcut: 'mod + o',
|
||||
class: ()=>{return READ_ONLY ? 'disabled' :''}
|
||||
},
|
||||
{
|
||||
label: locales('file_open_recent'),
|
||||
action: recentSessions,
|
||||
class: ()=>{return !recentSessions.length ? 'disabled' :''}
|
||||
},
|
||||
{
|
||||
separator: true
|
||||
},
|
||||
{
|
||||
label: locales('file_save'),
|
||||
action: sessionManager.save.bind(sessionManager),
|
||||
shortcut: 'mod + s',
|
||||
class: ()=>{return READ_ONLY || sessionManager.session === null ? 'disabled' :''}
|
||||
},
|
||||
{
|
||||
label: locales('file_save_as'),
|
||||
action: sessionManager.saveAs.bind(sessionManager),
|
||||
shortcut: 'mod + shift + s',
|
||||
class: ()=>{return READ_ONLY || sessionManager.session === null ? 'disabled' :''}
|
||||
},
|
||||
{
|
||||
separator: true
|
||||
},
|
||||
{
|
||||
label: locales('file_import'),
|
||||
action: sessionManager.import.bind(sessionManager),
|
||||
class: ()=>{return READ_ONLY ? 'disabled' :''}
|
||||
},
|
||||
{
|
||||
label: locales('file_export'),
|
||||
action: sessionManager.export.bind(sessionManager),
|
||||
class: ()=>{return READ_ONLY || sessionManager.session === null ? 'disabled' :''}
|
||||
},
|
||||
|
||||
]
|
||||
},
|
||||
{
|
||||
label: locales('state'),
|
||||
class: ()=>{return sessionManager.session === null ? 'disabled' : ''},
|
||||
action: [
|
||||
{
|
||||
label: locales('state_store'),
|
||||
action: stateManager.quickSave.bind(stateManager)
|
||||
},
|
||||
{
|
||||
label: locales('state_recall'),
|
||||
class: ()=>{return stateManager.quickState === null ? 'disabled' : ''},
|
||||
action: stateManager.quickLoad.bind(stateManager)
|
||||
},
|
||||
{
|
||||
label: locales('state_send'),
|
||||
action: ()=>{
|
||||
stateManager.send()
|
||||
notifications.add({
|
||||
icon: 'sliders-h',
|
||||
message: locales('state_sendsuccess')
|
||||
})
|
||||
}
|
||||
},
|
||||
{
|
||||
separator: true
|
||||
},
|
||||
{
|
||||
label: locales('file_open'),
|
||||
action: stateManager.browse.bind(stateManager),
|
||||
class: ()=>{return READ_ONLY ? 'disabled' :''}
|
||||
},
|
||||
{
|
||||
label: locales('file_save'),
|
||||
action: stateManager.save.bind(stateManager),
|
||||
class: ()=>{return READ_ONLY ? 'disabled' :''}
|
||||
},
|
||||
{
|
||||
label: locales('file_save_as'),
|
||||
action: stateManager.saveAs.bind(stateManager),
|
||||
class: ()=>{return READ_ONLY ? 'disabled' :''}
|
||||
},
|
||||
{
|
||||
separator: true
|
||||
},
|
||||
{
|
||||
label: locales('file_import'),
|
||||
action: stateManager.import.bind(stateManager),
|
||||
class: ()=>{return READ_ONLY ? 'disabled' :''}
|
||||
},
|
||||
{
|
||||
label: locales('file_export'),
|
||||
action: stateManager.export.bind(stateManager),
|
||||
class: ()=>{return READ_ONLY ? 'disabled' :''}
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
label: locales('editor'),
|
||||
class: ()=>{return sessionManager.session === null || READ_ONLY ? 'disabled' : ''},
|
||||
action: [
|
||||
{
|
||||
label: locales('editor_enabled'),
|
||||
class: ()=>{return 'toggle ' + (editor.enabled ? 'on' : 'off')},
|
||||
action: ()=>{
|
||||
if (editor.enabled) editor.disable()
|
||||
else editor.enable()
|
||||
},
|
||||
shortcut: 'mod + e'
|
||||
},
|
||||
{
|
||||
separator: true
|
||||
},
|
||||
{
|
||||
label: locales('editor_grid'),
|
||||
class: ()=>{return 'toggle ' + (editor.grid ? 'on' : 'off')},
|
||||
action: editor.toggleGrid.bind(editor),
|
||||
shortcut: 'mod + g'
|
||||
|
||||
},
|
||||
{
|
||||
label: locales('editor_tree'),
|
||||
class: ()=>{return 'toggle ' + (leftUiSidePanel.minimized ? 'off' : 'on')},
|
||||
action: ()=>{return leftUiSidePanel.minimized ? leftUiSidePanel.restore() : leftUiSidePanel.minimize()},
|
||||
shortcut: 'mod + t'
|
||||
|
||||
|
||||
},
|
||||
{
|
||||
label: locales('editor_inspector'),
|
||||
class: ()=>{return 'toggle ' + (rightUiSidePanel.minimized ? 'off' : 'on')},
|
||||
action: ()=>{return rightUiSidePanel.minimized ? rightUiSidePanel.restore() : rightUiSidePanel.minimize()},
|
||||
shortcut: 'mod + i'
|
||||
},
|
||||
{
|
||||
separator: true
|
||||
},
|
||||
{
|
||||
label: locales('editor_percents'),
|
||||
class: ()=>{return 'toggle ' + (editor.usePercents ? 'on' : 'off')},
|
||||
action: ()=>{editor.usePercents = !editor.usePercents}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
separator: true
|
||||
},
|
||||
{
|
||||
label: locales('fullscreen'),
|
||||
class: ()=>{return 'toggle ' + (fullscreen.isFullscreen ? 'on' : 'off')},
|
||||
action: ()=>{
|
||||
if (fullscreen.isEnabled) fullscreen.toggle()
|
||||
},
|
||||
shortcut: 'f11'
|
||||
}
|
||||
|
||||
]
|
||||
|
||||
if (navigator.userAgent.match(/Android|iPhone|iPad|iPod/i)) {
|
||||
|
||||
var NoSleep = require('nosleep.js'),
|
||||
noSleep = new NoSleep(),
|
||||
noSleepState = false
|
||||
|
||||
menuEntries.push({
|
||||
label: locales('nosleep'),
|
||||
class: ()=>{return 'toggle ' + (noSleepState ? 'on' : 'off')},
|
||||
action:()=>{
|
||||
noSleepState = !noSleepState
|
||||
if (noSleepState) noSleep.disable()
|
||||
else noSleep.enable()
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
ContextMenu = require('./context-menu')
|
||||
|
||||
class UiToolbar extends UiWidget {
|
||||
|
||||
|
|
@ -212,23 +8,11 @@ class UiToolbar extends UiWidget {
|
|||
super(options)
|
||||
|
||||
this.menu = new ContextMenu({
|
||||
position: [40, 1]
|
||||
position: options.position
|
||||
})
|
||||
this.opened = false
|
||||
this.entries = menuEntries
|
||||
this.menu.bindShortcuts(menuEntries)
|
||||
|
||||
ipc.on('sessionList', (data)=>{
|
||||
if (recentSessions.length) {
|
||||
recentSessions.splice(0, 10)
|
||||
}
|
||||
for (let s of data) [
|
||||
recentSessions.push({
|
||||
label: s,
|
||||
action: ()=>{sessionManager.requestOpen(s)}
|
||||
})
|
||||
]
|
||||
})
|
||||
this.entries = options.entries
|
||||
this.menu.bindShortcuts(this.entries)
|
||||
|
||||
this.container.addEventListener('fast-click', (e)=>{
|
||||
if (this.opened) this.close()
|
||||
|
|
@ -247,8 +31,7 @@ class UiToolbar extends UiWidget {
|
|||
open(e) {
|
||||
|
||||
if (this.opened) return
|
||||
|
||||
this.menu.open(e, menuEntries)
|
||||
this.menu.open(e.detail, this.entries)
|
||||
|
||||
this.opened = true
|
||||
this.toggleState()
|
||||
|
|
@ -276,4 +59,4 @@ class UiToolbar extends UiWidget {
|
|||
}
|
||||
|
||||
|
||||
module.exports = new UiToolbar({selector: 'osc-toolbar'})
|
||||
module.exports = UiToolbar
|
||||
|
|
|
|||
|
|
@ -63,10 +63,10 @@ class Button extends Widget {
|
|||
|
||||
if (this.getProp('doubleTap')) {
|
||||
|
||||
doubletab(this.widget, ()=>{
|
||||
doubletab(this.container, (e)=>{
|
||||
|
||||
this.active = true
|
||||
this.setValue(this.getProp('on'), {sync: true, send: true})
|
||||
this.setValue(this.getProp('on'), {sync: true, send: true, y: e.offsetY})
|
||||
|
||||
if (tap) this.container.classList.add('active')
|
||||
|
||||
|
|
@ -74,17 +74,17 @@ class Button extends Widget {
|
|||
|
||||
} else {
|
||||
|
||||
this.on('draginit',()=>{
|
||||
this.on('draginit',(e)=>{
|
||||
|
||||
if (this.active) return
|
||||
|
||||
this.active = true
|
||||
this.setValue(this.getProp('on'), {sync: true, send: true})
|
||||
this.setValue(this.getProp('on'), {sync: true, send: true, y: e.offsetY})
|
||||
|
||||
if (tap) this.container.classList.add('active')
|
||||
|
||||
|
||||
}, {element: this.widget})
|
||||
}, {element: this.container})
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -97,36 +97,36 @@ class Button extends Widget {
|
|||
if (!tap) this.setValue(this.getProp('off'), {sync: true, send: true})
|
||||
if (tap) this.container.classList.remove('active')
|
||||
|
||||
}, {element: this.widget})
|
||||
}, {element: this.container})
|
||||
|
||||
} else {
|
||||
|
||||
if (this.getProp('doubleTap')) {
|
||||
|
||||
doubletab(this.widget, ()=>{
|
||||
doubletab(this.container, (e)=>{
|
||||
|
||||
|
||||
this.active = true
|
||||
this.setValue(this.state ? this.getProp('off') : this.getProp('on'), {sync: true, send: true})
|
||||
this.setValue(this.state ? this.getProp('off') : this.getProp('on'), {sync: true, send: true, y: e.offsetY})
|
||||
|
||||
})
|
||||
|
||||
} else {
|
||||
|
||||
this.on('draginit',()=>{
|
||||
this.on('draginit',(e)=>{
|
||||
|
||||
if (this.active) return
|
||||
|
||||
this.active = true
|
||||
this.setValue(this.state ? this.getProp('off') : this.getProp('on'), {sync: true, send: true})
|
||||
this.setValue(this.state ? this.getProp('off') : this.getProp('on'), {sync: true, send: true, y: e.offsetY})
|
||||
|
||||
}, {element: this.widget})
|
||||
}, {element: this.container})
|
||||
|
||||
this.on('dragend',()=>{
|
||||
|
||||
this.active = false
|
||||
|
||||
}, {element: this.widget})
|
||||
}, {element: this.container})
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,14 @@ class Input extends Canvas {
|
|||
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'}
|
||||
asYouType: {type: 'boolean', value: false, help: 'Set to `true` to make the input send its value at each keystroke'},
|
||||
validation: {type: 'string', value: '', help: [
|
||||
'Regular expression: if the submitted value doesn\'t match the regular expression, it will be reset to the last valid value.',
|
||||
'If leading and trailing slashes are omitted, they will be added automatically and the flag will be set to "gm"',
|
||||
'Examples:',
|
||||
'- `^[0-9]*$` accepts digits only, any number of them',
|
||||
'- `/^[a-z\s]{0,10}$/i` accept between 0 and 10 alphabetic characters and spaces (case insensitive)',
|
||||
]}
|
||||
}
|
||||
})
|
||||
|
||||
|
|
@ -37,6 +44,7 @@ class Input extends Canvas {
|
|||
this.stringValue = ''
|
||||
this.focused = false
|
||||
this.tabKeyBlur = false
|
||||
this.validation = null
|
||||
|
||||
if (this.getProp('vertical')) this.widget.classList.add('vertical')
|
||||
if (this.getProp('align') === 'left') this.widget.classList.add('left')
|
||||
|
|
@ -53,6 +61,17 @@ class Input extends Canvas {
|
|||
this.tabKeyBlur = false
|
||||
})
|
||||
var asYouType = this.getProp('asYouType')
|
||||
|
||||
if (this.getProp('validation') !== '') {
|
||||
var validation = String(this.getProp('validation')),
|
||||
flags = validation.match(/^\/.*\/.*$/) ? validation.split('/').pop() : 'gm',
|
||||
regExpString = validation.match(/^\/.*\/.*$/) ? validation.replace(/^\/(.*)\/.*$/, '$1') : validation
|
||||
|
||||
if (!regExpString.match(/^\^.*\$$/)) regExpString = '^' + regExpString + '$'
|
||||
|
||||
this.validation = new RegExp(regExpString, flags)
|
||||
}
|
||||
|
||||
this.input.addEventListener('keydown', (e)=>{
|
||||
if (e.keyCode === 13) this.blur() // enter
|
||||
else if (e.keyCode === 27) this.blur(false) // esc
|
||||
|
|
@ -120,12 +139,19 @@ class Input extends Canvas {
|
|||
|
||||
setValue(v, options={} ) {
|
||||
|
||||
if (this.validation && !String(v).match(this.validation)) {
|
||||
this.input.value = this.value
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
this.value = JSON.parse(v)
|
||||
} catch (err) {
|
||||
this.value = v
|
||||
}
|
||||
|
||||
if (this.value === '' || this.value === null) this.value = this.getProp('default')
|
||||
|
||||
this.stringValue = this.getStringValue()
|
||||
this.batchDraw()
|
||||
|
||||
|
|
|
|||
|
|
@ -36,7 +36,10 @@ module.exports = class OscReceiver {
|
|||
|
||||
if (this.address[0] !== '/') {
|
||||
var parentAddress = this.parent.getProp('address') || this.parent.resolveProp('address', undefined, false, this)
|
||||
if (parentAddress === 'auto') parentAddress = '/' + this.parent.getProp('id')
|
||||
if (parentAddress === 'auto') {
|
||||
var id = this.parent.getProp('id') || this.parent.resolveProp('id', undefined, false, this)
|
||||
parentAddress = '/' + id
|
||||
}
|
||||
this.prefix = parentAddress
|
||||
if (this.prefix[this.prefix.length - 1] !== '/') this.prefix += '/'
|
||||
}
|
||||
|
|
|
|||
|
|
@ -216,7 +216,9 @@ class Widget extends EventEmitter {
|
|||
event: 'value'
|
||||
}, builtIn: true, parent: this})
|
||||
this.on('change', (e)=>{
|
||||
if (e.widget === this && this.mounted && !e.options.fromEdit) this.script.setValue(this.value, {...e.options, id: e.options.id || e.id})
|
||||
if (e.widget === this && this.mounted && !e.options.fromEdit) {
|
||||
this.script.setValue(e.options.widget ? e.options.widget.value : this.value, {...e.options, id: e.options.id || e.id})
|
||||
}
|
||||
})
|
||||
if (String(this.getProp('script')).includes('touch')) {
|
||||
this.on('touch', (e)=>{
|
||||
|
|
@ -659,7 +661,7 @@ class Widget extends EventEmitter {
|
|||
} catch (err) {
|
||||
let stackline = err.stack ? (err.stack.match(/>:([0-9]+):[0-9]+/) || '') : '',
|
||||
line = stackline.length > 1 ? ' at line ' + (parseInt(stackline[1]) - 2) : ''
|
||||
console.log((this.getProp('id') || this.props.id) + '.' + propName + ': JS{{}} error:\n' + err + line)
|
||||
console.error((this.getProp('id') || this.props.id) + '.' + propName + ': JS{{}} error:\n' + err + line)
|
||||
}
|
||||
|
||||
try {
|
||||
|
|
@ -680,7 +682,7 @@ class Widget extends EventEmitter {
|
|||
} catch (err) {
|
||||
let stackline = err.stack ? (err.stack.match(/>:([0-9]+):[0-9]+/) || '') : '',
|
||||
line = stackline.length > 1 ? ' at line ' + (parseInt(stackline[1]) - 2) : ''
|
||||
console.log((this.getProp('id') || this.props.id) + '.' + propName + ': #{} error:\n' + err + line)
|
||||
console.error((this.getProp('id') || this.props.id) + '.' + propName + ': #{} error:\n' + err + line)
|
||||
}
|
||||
|
||||
for (let k in variables) {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
var Panel = require('./panel'),
|
||||
Widget = require('../common/widget'),
|
||||
parser = require('../../parser')
|
||||
parser = require('../../parser'),
|
||||
{mapToScale} = require('../utils')
|
||||
|
||||
|
||||
class Keyboard extends Panel {
|
||||
|
|
@ -28,11 +29,12 @@ class Keyboard extends Panel {
|
|||
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)'
|
||||
]},
|
||||
velocity: {type: 'boolean', value: false, help: [
|
||||
'Set to `true` to map the touch coordinates between `off` (top) and `on` (bottom). Requires `on` and `off` to be numbers',
|
||||
]},
|
||||
mode: {type: 'string', value: 'push', choices: ['push', 'toggle', 'tap'], help: [
|
||||
'Interraction mode:',
|
||||
|
|
@ -51,21 +53,53 @@ class Keyboard extends Panel {
|
|||
|
||||
this.childrenType = undefined
|
||||
this.value = []
|
||||
this.keyHeight = 100
|
||||
|
||||
this.on('resize', (e)=>{
|
||||
this.keyHeight = e.height
|
||||
}, {element: this.widget})
|
||||
|
||||
|
||||
this.on('change',(e)=>{
|
||||
|
||||
if (e.widget === this) return
|
||||
var widget = e.widget
|
||||
|
||||
if (widget === this) return
|
||||
|
||||
|
||||
var value
|
||||
if (widget.getValue()) {
|
||||
if (this.getProp('velocity')) {
|
||||
var height = widget._black ? this.keyHeight * 0.65 : this.keyHeight
|
||||
value = mapToScale(e.options.y, [0, height * 0.9], [this.getProp('off'), this.getProp('on')], this.decimals)
|
||||
} else {
|
||||
value = this.getProp('on')
|
||||
}
|
||||
} else {
|
||||
value = this.getProp('off')
|
||||
}
|
||||
|
||||
this.value[widget._index] = value
|
||||
|
||||
if (e.options.send) {
|
||||
var start = parseInt(this.getProp('start'))
|
||||
this.sendValue({
|
||||
v: [e.widget._index + start, value]
|
||||
})
|
||||
}
|
||||
|
||||
this.changed({
|
||||
...e.options,
|
||||
id: widget.getProp('id')
|
||||
})
|
||||
|
||||
this.value[e.widget._index] = e.widget.getValue()
|
||||
this.changed(e.options)
|
||||
|
||||
})
|
||||
|
||||
var start = parseInt(this.getProp('start')),
|
||||
keys = parseInt(this.getProp('keys'))
|
||||
|
||||
var strData = JSON.stringify(options.props),
|
||||
pattern = 'wbwbwwbwbwbw',
|
||||
var pattern = 'wbwbwwbwbwbw',
|
||||
whiteKeys = 0, whiteKeys2 = 0, i
|
||||
|
||||
for (i = start; i < keys + start && i < 109; i++) {
|
||||
|
|
@ -76,24 +110,20 @@ class Keyboard extends Panel {
|
|||
|
||||
for (i = start; i < keys + start && i < 109; i++) {
|
||||
|
||||
var data = JSON.parse(strData)
|
||||
|
||||
data.top = data.left = data.height = data.width = 'auto'
|
||||
data.type = 'button'
|
||||
data.mode = this.getProp('mode')
|
||||
data.id = this.getProp('id') + '/' + i
|
||||
data.label = false
|
||||
data.css = ''
|
||||
|
||||
data.target = '@{parent.target}'
|
||||
data.decimals = '@{parent.decimals}'
|
||||
|
||||
data.address = '@{parent.address}'
|
||||
data.preArgs = `JS{{
|
||||
var a = @{parent.preArgs};
|
||||
var b = typeof a === 'string' && a === '' ? [] : Array.isArray(a) ? a : [a];
|
||||
return b.concat([${i}])
|
||||
}}`
|
||||
var data = {
|
||||
top: 'auto',
|
||||
left: 'auto',
|
||||
height: 'auto',
|
||||
width: 'auto',
|
||||
type: 'button',
|
||||
mode: this.getProp('mode'),
|
||||
id: this.getProp('id') + '/' + i,
|
||||
label: false,
|
||||
css: '',
|
||||
bypass: true,
|
||||
on: 1,
|
||||
off: 0,
|
||||
}
|
||||
|
||||
var key = parser.parse({
|
||||
data: data,
|
||||
|
|
@ -111,6 +141,7 @@ class Keyboard extends Panel {
|
|||
} else {
|
||||
key.container.classList.add('black')
|
||||
key.container.style.setProperty('--rank', whiteKeys2)
|
||||
key._black = true
|
||||
}
|
||||
|
||||
this.value[i - start] = this.getProp('off')
|
||||
|
|
@ -119,8 +150,24 @@ class Keyboard extends Panel {
|
|||
|
||||
}
|
||||
|
||||
setValue(v, options={}) {
|
||||
|
||||
if (!Array.isArray(v) || v.length !== 2) return
|
||||
if (v[1] !== this.getProp('on') && v[1] !== this.getProp('off')) return
|
||||
|
||||
var start = parseInt(this.getProp('start'))
|
||||
this.children[v[0] - start].setValue(v[1] === this.getProp('on') ? 1 : 0, options)
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Keyboard.dynamicProps = Keyboard.prototype.constructor.dynamicProps.concat(
|
||||
'on',
|
||||
'off',
|
||||
)
|
||||
|
||||
Keyboard.cssVariables = Keyboard.prototype.constructor.cssVariables.concat(
|
||||
{js: 'colorWhite', css: '--color-white-key'},
|
||||
{js: 'colorBlack', css: '--color-black-key'}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,9 @@
|
|||
var Panel = require('./panel'),
|
||||
StaticProperties = require('../mixins/static_properties'),
|
||||
parser = require('../../parser'),
|
||||
{deepCopy} = require('../../utils')
|
||||
|
||||
|
||||
class Matrix extends StaticProperties(Panel) {
|
||||
class Matrix extends Panel {
|
||||
|
||||
static description() {
|
||||
|
||||
|
|
@ -45,22 +44,16 @@ class Matrix extends StaticProperties(Panel) {
|
|||
|
||||
if (e.widget === this) return
|
||||
|
||||
if (this.getProp('widgetType') === 'clone') {
|
||||
var widget = this.getProp('widgetType') === 'clone' ? e.widget.parent : e.widget
|
||||
|
||||
if (e.widget.parent.parent !== this) return
|
||||
if (widget.parent !== this) return
|
||||
|
||||
this.value[e.widget.parent._index] = e.widget.getValue()
|
||||
this.value[widget._index] = e.widget.getValue()
|
||||
|
||||
} else {
|
||||
|
||||
if (e.widget.parent !== this) return
|
||||
|
||||
this.value[e.widget._index] = e.widget.getValue()
|
||||
|
||||
|
||||
}
|
||||
|
||||
this.changed(e.options)
|
||||
this.changed({
|
||||
...e.options,
|
||||
id: widget.getProp('id')
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ class ScriptVm extends Vm {
|
|||
|
||||
super.registerGlobals()
|
||||
|
||||
this.sandbox.contentWindow.set = (id, value)=>{
|
||||
this.sandbox.contentWindow.set = (id, value, extraOptions = {send: true, sync: true})=>{
|
||||
|
||||
var options = this.getValueOptions()
|
||||
options.fromScript = true
|
||||
|
|
@ -67,11 +67,24 @@ class ScriptVm extends Vm {
|
|||
// if (id === options.id) options.sync = false // loop stop
|
||||
// if (this.getWidget() === options.widget) options.sync = false // loop stop
|
||||
|
||||
var widgets = this.resolveId(id)
|
||||
if (extraOptions.send === false) options.send = false
|
||||
if (extraOptions.sync === false) options.sync = false
|
||||
|
||||
var widgets
|
||||
if (id.includes('*')) {
|
||||
var widget = this.getWidget()
|
||||
if (widget.builtIn) widget = widget.parent
|
||||
widgets = this.resolveId(
|
||||
Object.keys(widgetManager.idRoute).filter(key => key.match(new RegExp('^' + id.replace(/\*/g, '.*') + '$')))
|
||||
).filter(w => w !== widget)
|
||||
} else {
|
||||
widgets = this.resolveId(id).slice(0, 1)
|
||||
}
|
||||
|
||||
|
||||
for (var i = widgets.length - 1; i >= 0; i--) {
|
||||
|
||||
return widgets[i].setValue(value, options)
|
||||
widgets[i].setValue(value, options)
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -100,7 +113,7 @@ class ScriptVm extends Vm {
|
|||
var widget = this.getWidget()
|
||||
if (widget.builtIn) widget = widget.parent
|
||||
|
||||
widget.sendValue(overrides)
|
||||
widget.sendValue(overrides, {force: true})
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -149,6 +162,13 @@ class ScriptVm extends Vm {
|
|||
|
||||
}
|
||||
|
||||
this.sandbox.contentWindow.getIndex = (id = 'this')=>{
|
||||
|
||||
var widget = this.resolveId(id).pop()
|
||||
if (widget) return widget.parent.children.indexOf(widget)
|
||||
|
||||
}
|
||||
|
||||
this.sandbox.contentWindow.getScroll = (id)=>{
|
||||
|
||||
var widgets = this.resolveId(id)
|
||||
|
|
@ -319,7 +339,7 @@ class ScriptVm extends Vm {
|
|||
|
||||
if (!options.send) return
|
||||
|
||||
toolbar = toolbar || require('../../ui/ui-toolbar')
|
||||
toolbar = toolbar || require('../../ui/main-menu')
|
||||
|
||||
var action = toolbar.entries.filter(x=>!x.separator)
|
||||
|
||||
|
|
@ -333,7 +353,7 @@ class ScriptVm extends Vm {
|
|||
|
||||
}
|
||||
|
||||
for (var imports of ['set', 'get', 'getProp', 'updateProp', 'send', 'httpGet', 'stateGet', 'stateSet', 'storage',
|
||||
for (var imports of ['set', 'get', 'getProp', 'getIndex', 'updateProp', 'send', 'httpGet', 'stateGet', 'stateSet', 'storage',
|
||||
'setInterval', 'clearInterval', 'setTimeout', 'clearTimeout', 'unfocus', 'setScroll', 'getScroll', 'toolbar']) {
|
||||
this.sanitize(this.sandbox.contentWindow[imports])
|
||||
}
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ class Script extends Widget {
|
|||
|
||||
let stackline = err.stack ? (err.stack.match(/>:([0-9]+):[0-9]+/) || '') : '',
|
||||
line = stackline.length > 1 ? ' at line ' + (parseInt(stackline[1]) - 2) : ''
|
||||
console.log((this.getProp('id') || this.props.id) + '.script error:\n' + err + line)
|
||||
console.error((this.getProp('id') || this.props.id) + '.script error:\n' + err + line)
|
||||
this.script = ()=>{}
|
||||
|
||||
}
|
||||
|
|
@ -107,8 +107,10 @@ class Script extends Widget {
|
|||
this.scriptLock = true
|
||||
try {
|
||||
this.script(context, this.builtIn ? this.parent.parsersLocalScope : this.parsersLocalScope)
|
||||
} catch(e) {
|
||||
console.log(e)
|
||||
} catch(err) {
|
||||
let stackline = err.stack ? (err.stack.match(/>:([0-9]+):[0-9]+/) || '') : '',
|
||||
line = stackline.length > 1 ? ' at line ' + (parseInt(stackline[1]) - 2) : ''
|
||||
console.error((this.getProp('id') || this.props.id) + '.script error:\n' + err + line)
|
||||
}
|
||||
this.scriptLock = false
|
||||
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ class Range extends Fader {
|
|||
visible: false,
|
||||
horizontal:this.getProp('horizontal'),
|
||||
default:this.getProp('default').length === 2 ? this.getProp('default')[1] : this.getProp('range').max,
|
||||
origin: this.getProp('default').length === 2 ? this.getProp('default')[1] : this.getProp('range').max,
|
||||
snap:this.getProp('snap'),
|
||||
spring:this.getProp('spring'),
|
||||
range:this.getProp('range'),
|
||||
|
|
@ -67,10 +68,9 @@ class Range extends Fader {
|
|||
|
||||
this.touchMap = {}
|
||||
|
||||
this.setValue([
|
||||
this.faders[0].rangeValsMin,
|
||||
this.faders[1].rangeValsMax
|
||||
])
|
||||
|
||||
this.originValue = this.faders.map(f => f.originValue)
|
||||
this.setValue(this.getSpringValue())
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -170,15 +170,20 @@ class Range extends Fader {
|
|||
|
||||
setValue(v, options={}) {
|
||||
|
||||
if (!this.faders) return // prevent Fader.constructor
|
||||
if (!v || !v.length || v.length!=2) return
|
||||
|
||||
|
||||
this.faders[0].rangeValsMax = v[1]
|
||||
this.faders[1].rangeValsMin = v[0]
|
||||
|
||||
if (!options.dragged) {
|
||||
this.faders[0].setValue(v[0])
|
||||
this.faders[1].setValue(v[1])
|
||||
var opt = {
|
||||
...options,
|
||||
send: false,
|
||||
sync: false
|
||||
}
|
||||
this.faders[0].setValue(v[0], opt)
|
||||
this.faders[1].setValue(v[1], opt)
|
||||
}
|
||||
this.value = [
|
||||
this.faders[0].getValue(),
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ class Slider extends Canvas {
|
|||
} else {
|
||||
|
||||
doubletab(this.widget, ()=>{
|
||||
this.setValue(this.getSpringValue(),{sync:true, send:true, fromLocal:true})
|
||||
this.setValue(this.getSpringValue(),{sync:true, send:true, fromLocal:true, doubleTab:true})
|
||||
})
|
||||
|
||||
}
|
||||
|
|
@ -184,7 +184,7 @@ class Slider extends Canvas {
|
|||
setValue(v,options={}) {
|
||||
|
||||
if (typeof v != 'number') return
|
||||
if (this.touched && !options.dragged) return this.setValueTouchedQueue = [v, options]
|
||||
if (this.touched && !options.dragged && !options.doubleTab) return this.setValueTouchedQueue = [v, options]
|
||||
|
||||
var value = clip(v,[this.rangeValsMin,this.rangeValsMax])
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
<body>
|
||||
<osc-workspace>
|
||||
<osc-toolbar></osc-toolbar>
|
||||
<osc-toolbar id="main-menu"></osc-toolbar>
|
||||
<osc-panel-container class="left">
|
||||
<div class="resize-handle left"></div>
|
||||
<div class="toggle-button left"></div>
|
||||
|
|
@ -37,6 +37,17 @@
|
|||
<osc-panel-inner class="right">
|
||||
<osc-panel-header></osc-panel-header>
|
||||
<osc-panel-content class="right" id="osc-inspector"></osc-panel-content>
|
||||
|
||||
<osc-panel-container class="bottom" id="osc-console">
|
||||
<div class="resize-handle bottom"></div>
|
||||
<div class="toggle-button bottom"></div>
|
||||
<osc-panel-inner class="bottom">
|
||||
<osc-panel-header></osc-panel-header>
|
||||
<osc-panel-content></osc-panel-content>
|
||||
</osc-panel-inner>
|
||||
</osc-panel-container>
|
||||
|
||||
|
||||
</osc-panel-inner>
|
||||
</osc-panel-container>
|
||||
<osc-modal-container></osc-modal-container>
|
||||
|
|
|
|||
|
|
@ -194,8 +194,9 @@ def send_midi(name, event, *args):
|
|||
m = []
|
||||
for arg in args:
|
||||
if type(arg) is str:
|
||||
arg = arg.split(' ')
|
||||
arg = [int(x, 16) for x in arg]
|
||||
arg = arg.replace(' ', '') # remove spaces
|
||||
arg = [arg[i:i+2] for i in range(0, len(arg), 2)] # split in 2 chars bytes
|
||||
arg = [int(x, 16) for x in arg] # parse hex bytes
|
||||
for x in arg:
|
||||
m.append(x)
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -1 +1,2 @@
|
|||
python-rtmidi == 1.4.2
|
||||
pyinstaller
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
@import 'ui/notifications';
|
||||
@import 'ui/grid';
|
||||
@import 'ui/inspector';
|
||||
@import 'ui/console';
|
||||
@import 'ui/tree';
|
||||
@import 'ui/dragresize';
|
||||
@import 'ui/selectarea';
|
||||
|
|
|
|||
72
src/scss/ui/console.scss
Normal file
72
src/scss/ui/console.scss
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
$padding: 8rem;
|
||||
|
||||
#osc-console {
|
||||
osc-panel-header {
|
||||
border-top: 1rem solid var(--color-background);
|
||||
}
|
||||
.toggle-button {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
display: flex;
|
||||
position: relative;
|
||||
flex-direction: column;
|
||||
::-webkit-scrollbar-thumb, ::-webkit-scrollbar-track-piece {
|
||||
border-left-color: var(--color-background)!important;
|
||||
border-top-color: var(--color-background)!important;
|
||||
}
|
||||
|
||||
.actions {
|
||||
position: absolute;
|
||||
right: 0;
|
||||
padding: $padding;
|
||||
|
||||
div {
|
||||
cursor: pointer;
|
||||
color: var(--color-text);
|
||||
opacity: 0.25;
|
||||
&:hover {
|
||||
opacity: 0.5
|
||||
}
|
||||
}
|
||||
i {
|
||||
pointer-events: none;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
osc-console {
|
||||
display: block;
|
||||
height: 100%;
|
||||
padding: $padding;
|
||||
overflow-y: auto;
|
||||
background: var(--color-background);
|
||||
}
|
||||
|
||||
osc-console-message {
|
||||
user-select: text;
|
||||
cursor: text;
|
||||
display: block;
|
||||
white-space: pre;
|
||||
&.error {
|
||||
color: var(--color-error);
|
||||
}
|
||||
|
||||
margin-bottom: 4rem;
|
||||
}
|
||||
|
||||
osc-console-input {
|
||||
display: block;
|
||||
padding: 4rem;
|
||||
background: var(--color-ui-background);
|
||||
height: 30rem;
|
||||
textarea {
|
||||
padding: 4rem;
|
||||
display: block;
|
||||
background: var(--color-background);
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
resize: none;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
osc-toolbar {
|
||||
--size: 34rem;
|
||||
position: fixed;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
height:var(--size);
|
||||
|
|
|
|||
|
|
@ -126,7 +126,7 @@ osc-panel-container {
|
|||
background: var(--color-ui-background);
|
||||
font-size: 14rem;
|
||||
z-index: 2;
|
||||
transition: transform 0.2s ease-out 0.1s, border-color 0.2s ease-out 0.1s;
|
||||
transition: transform 0.2s ease-out 0.1s, border-color 0.1s ease-out 0.1s;
|
||||
will-change: transform;
|
||||
|
||||
border-style: solid;
|
||||
|
|
@ -215,8 +215,8 @@ osc-panel-container {
|
|||
|
||||
}
|
||||
|
||||
&:hover .toggle-button, .toggle-button:hover {
|
||||
transition: transform 0.2s ease-out 0s, border-color 0.2s ease-out 0s;
|
||||
&:hover > .toggle-button, .toggle-button:hover {
|
||||
transition: transform 0.2s ease-out 0s, border-color 0.3s ease-out 0s;
|
||||
transform: translateX(0) translateY(0);
|
||||
border-color: var(--color-background);
|
||||
&:after {
|
||||
|
|
@ -298,6 +298,7 @@ osc-panel-header {
|
|||
font-size: 109%;
|
||||
text-overflow: ellipsis;
|
||||
padding: 0 8rem;
|
||||
flex-shrink: 0;
|
||||
|
||||
&:before {
|
||||
content: "";
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@
|
|||
bottom:0;
|
||||
margin: var(--widget-spacing);
|
||||
padding: var(--widget-padding);
|
||||
pointer-events: none;
|
||||
|
||||
|
||||
@include pseudo-stroke($z: -1);
|
||||
|
|
@ -577,7 +578,7 @@
|
|||
color:var(--color-fill);
|
||||
caret-color: var(--color-fill);
|
||||
|
||||
|
||||
height: 100%;
|
||||
|
||||
&:focus::selection {
|
||||
background: var(--color-fill);
|
||||
|
|
|
|||
|
|
@ -3,8 +3,7 @@ var path = require('path'),
|
|||
settings = require('./settings'),
|
||||
osc = require('./osc'),
|
||||
{ipc} = require('./server'),
|
||||
{deepCopy, resolveHomeDir} = require('./utils'),
|
||||
theme = require('./theme')
|
||||
{deepCopy, resolveHomeDir} = require('./utils')
|
||||
|
||||
var widgetHashTable = {},
|
||||
clipboard = {clipboard: null, idClipboard: null}
|
||||
|
|
@ -404,8 +403,6 @@ module.exports = {
|
|||
|
||||
reloadCss() {
|
||||
// (dev) hot css reload
|
||||
|
||||
theme.load()
|
||||
ipc.send('reloadCss')
|
||||
},
|
||||
|
||||
|
|
|
|||
|
|
@ -52,7 +52,10 @@ class CustomModule {
|
|||
}
|
||||
},
|
||||
console: console,
|
||||
settings: settings,
|
||||
settings: {
|
||||
read: settings.read,
|
||||
appAddresses: settings.appAddresses,
|
||||
},
|
||||
setTimeout: this.setTimeout.bind(this),
|
||||
clearTimeout: this.clearTimeout.bind(this),
|
||||
setInterval: this.setInterval.bind(this),
|
||||
|
|
@ -153,7 +156,7 @@ class CustomModule {
|
|||
if (this.load()) {
|
||||
console.log('(INFO) Custom module reloaded successfully')
|
||||
} else {
|
||||
console.log('(ERROR) Failed to reload custom module')
|
||||
console.error('(ERROR) Failed to reload custom module')
|
||||
this.unload()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ var template = [{
|
|||
if (process.platform === 'darwin') {
|
||||
// Add app menu (macOs)
|
||||
template.unshift({
|
||||
label: settings.infos.appName,
|
||||
label: settings.infos.productName,
|
||||
submenu: [
|
||||
{
|
||||
label: 'Hide ' + infos.productName,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
var path = require('path'),
|
||||
{BrowserWindow, dialog, shell, screen} = require('electron'),
|
||||
{BrowserWindow, dialog, shell, screen, Menu, MenuItem} = require('electron'),
|
||||
shortcut = require('electron-localshortcut'),
|
||||
app = require('./electron-app'),
|
||||
settings = require('./settings'),
|
||||
|
|
@ -10,7 +10,7 @@ module.exports = function(options={}) {
|
|||
var window
|
||||
|
||||
window = new BrowserWindow({
|
||||
title: options.title || settings.infos.appName,
|
||||
title: options.title || settings.infos.productName,
|
||||
icon: path.resolve(__dirname + '/../assets/logo.png'),
|
||||
backgroundColor: options.color || theme.backgroundColor,
|
||||
type: options.type,
|
||||
|
|
@ -131,6 +131,15 @@ module.exports = function(options={}) {
|
|||
settings.write('geometry', geometry)
|
||||
})
|
||||
|
||||
var menu = new Menu()
|
||||
menu.append(new MenuItem({role: 'copy'}))
|
||||
menu.append(new MenuItem({role: 'paste'}))
|
||||
window.webContents.on('context-menu', (e, data) => {
|
||||
menu.items[0].enabled = data.editFlags.canCopy
|
||||
menu.items[1].enabled = data.editFlags.canPaste
|
||||
menu.popup({window: window, x: e.x, y: e.y })
|
||||
}, false)
|
||||
|
||||
if (options.shortcuts) {
|
||||
|
||||
shortcut.register(window,'CmdOrCtrl+R',function(){
|
||||
|
|
|
|||
|
|
@ -32,8 +32,7 @@ function nodeMode() {
|
|||
})
|
||||
|
||||
}
|
||||
|
||||
if (process.title === 'node' || process.title === 'node.exe') {
|
||||
if (process.title === 'node' || process.title === 'node.exe' || process.env.ELECTRON_RUN_AS_NODE) {
|
||||
|
||||
nodeMode()
|
||||
|
||||
|
|
|
|||
|
|
@ -129,7 +129,7 @@ class OscTCPServer extends EventEmitter {
|
|||
}
|
||||
|
||||
zeroconf.publish({
|
||||
name: settings.infos.appName + (settings.read('instance-name') ? ' (' + settings.read('instance-name') + ')' : ''),
|
||||
name: settings.infos.productName + (settings.read('instance-name') ? ' (' + settings.read('instance-name') + ')' : ''),
|
||||
protocol: 'tcp',
|
||||
type: 'osc',
|
||||
port: tcpInPort
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ oscUDPServer.on('error', function(e) {
|
|||
})
|
||||
|
||||
zeroconf.publish({
|
||||
name: settings.infos.appName + (settings.read('instance-name') ? ' (' + settings.read('instance-name') + ')' : ''),
|
||||
name: settings.infos.productName + (settings.read('instance-name') ? ' (' + settings.read('instance-name') + ')' : ''),
|
||||
protocol: 'udp',
|
||||
type: 'osc',
|
||||
port: oscInPort
|
||||
|
|
|
|||
|
|
@ -144,7 +144,7 @@ function httpCheck(ok, error){
|
|||
}
|
||||
|
||||
zeroconf.publish({
|
||||
name: settings.infos.appName + (settings.read('instanceName') ? ' (' + settings.read('instanceName') + ')' : ''),
|
||||
name: settings.infos.productName + (settings.read('instanceName') ? ' (' + settings.read('instanceName') + ')' : ''),
|
||||
type: 'http',
|
||||
port: settings.read('port') || 8080
|
||||
}).on('error', (e)=>{
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ var cli = false
|
|||
for (let i in argv) {
|
||||
if (!cliOnly.includes(i)) cli = true
|
||||
}
|
||||
if (process.title === 'node' || process.title === 'node.exe') {
|
||||
if (process.title === 'node' || process.title === 'node.exe' || process.env.ELECTRON_RUN_AS_NODE) {
|
||||
cli = true
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
var fs = require('fs'),
|
||||
path = require('path'),
|
||||
settings = require('./settings')
|
||||
settings = require('./settings'),
|
||||
chokidar = require('chokidar'),
|
||||
ipc
|
||||
|
||||
class Theme {
|
||||
|
||||
|
|
@ -9,6 +11,7 @@ class Theme {
|
|||
this.themes = []
|
||||
this.files = []
|
||||
this.css = []
|
||||
this.watcher = null
|
||||
|
||||
this.defaultColor = '#151a24'
|
||||
this.backgroundColor = this.defaultColor
|
||||
|
|
@ -31,6 +34,12 @@ class Theme {
|
|||
}
|
||||
}
|
||||
|
||||
this.watcher = chokidar.watch(this.files).on('change', ()=>{
|
||||
if (!ipc) ipc = require('./server').ipc
|
||||
this.load()
|
||||
ipc.send('reloadCss')
|
||||
})
|
||||
|
||||
this.load()
|
||||
|
||||
return this
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue