Merge branch 'master' into v1

This commit is contained in:
bordun 2020-02-23 16:36:10 +01:00
commit 3ad7915b8f
103 changed files with 94 additions and 59 deletions

View file

@ -1,8 +1,13 @@
# Changelog
## 0.49.5
- bug fixes
- launcher: file/folder browsing not working
## 0.49.4
- bug fixes:
- bug fixes
- image: fixed absolute paths
- image: reset to 'default' instead of 'value' when receiving an empty value
- launcher: use current midi config for "List devices" action

View file

@ -7,6 +7,7 @@ module.exports = {
return {
target: e.target,
firstTarget: null,
offsetX: e.offsetX,
offsetY: e.offsetY,
pageX: e.pageX,
@ -33,6 +34,8 @@ module.exports = {
event = module.exports.fix(event)
event.firstTarget = previousEvent ? previousEvent.firstTarget : event.target
if (event.movementX === undefined) {
event.movementX = previousEvent ? event.pageX - previousEvent.pageX : 0

View file

@ -1,8 +1,8 @@
require('./app/stacktrace')
require('./app/globals')
require('./stacktrace')
require('./globals')
var {loading} = require('./app/ui/utils'),
locales = require('./app/locales')
var {loading} = require('./ui/utils'),
locales = require('./locales')
document.addEventListener('DOMContentLoaded', function(event) {
@ -12,11 +12,11 @@ document.addEventListener('DOMContentLoaded', function(event) {
setTimeout(()=>{
var ipc = require('./app/ipc/')
var ipc = require('./ipc/')
ipc.init()
require('./app/ui/init')
require('./ui/init')
ipc.send('ready', {backupId: ARGV.backupId})

View file

@ -94,10 +94,10 @@ module.exports = {
setTimeout(()=>{
var root = widgetManager.getWidgetById('root')[0]
if (root) root.onPropChanged('color')
GRIDWIDTH = parseInt(getComputedStyle(document.documentElement).getPropertyValue('--grid-width'))
},200)
GRIDWIDTH = parseInt(getComputedStyle(document.documentElement).getPropertyValue('--grid-width'))
},
readOnly: function(){

View file

@ -41,7 +41,7 @@ class UiDragResize extends UiWidget {
this.on('draginit', (event)=>{
var node = event.target
var node = event.firstTarget
if (!this.handles.includes(node)) return
this.initLeft = this.left
@ -51,7 +51,7 @@ class UiDragResize extends UiWidget {
this.container.classList.add('dragging')
this.dragging = node.getAttribute('data-action').split(',')
event.traversing = false // stop traversing here
event.traversing = false
}, {element: this.container})
@ -83,6 +83,9 @@ class UiDragResize extends UiWidget {
this.on('dragend', (event)=>{
var node = event.firstTarget
if (!this.handles.includes(node)) return
this.container.classList.remove('dragging')
this.left = Math.max(0, this.left)
this.top = Math.max(0, this.top)

View file

@ -32,8 +32,6 @@ class Modal extends Panel {
}, [], {
_chidlren:'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'
@ -114,7 +112,7 @@ class Modal extends Panel {
this.popupContent.classList.add('layout-' + this.getProp('layout'))
this.popupContent.style.setProperty('--widget-padding', this.getProp('padding') != 'auto' ? parseFloat(this.getProp('padding')) + 'rem' : '')
}

View file

@ -27,8 +27,6 @@ class Panel extends Container() {
}, [], {
_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'},

View file

@ -25,8 +25,6 @@ class Root extends StaticProperties(Panel, {scroll: false, label: false, id: 'ro
}, ['label', '_geometry', 'left', 'top', 'width', 'height', 'scroll'], {
_children:'children',
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: [

View file

@ -24,8 +24,6 @@ module.exports = class Tab extends StaticProperties(Panel, {scroll: true}) {
}, ['_geometry', 'left', 'top', 'width', 'height', 'scroll'], {
_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'},

View file

@ -39,13 +39,13 @@ class Frame extends StaticProperties(Widget, {bypass: true}) {
super({...options, html: html`
<inner>
<iframe src="" sandbox="allow-scripts"></iframe>
<iframe class="frame" src="" sandbox="allow-scripts"></iframe>
</inner>`
})
if (!this.getProp('border')) this.container.classList.add('noborder')
this.frame = DOM.get(this.widget, 'iframe')[0]
this.frame = DOM.get(this.widget, '.frame')[0]
this.errorText = html`<span>${locales('iframe_unauthorized')}<span>`
this.errorTextMounted = false

View file

@ -37,19 +37,24 @@ class Html extends StaticProperties(Widget, {bypass: true}) {
constructor(options) {
super({...options, html: html`<inner></inner>`})
super({...options, html: html`
<inner>
<div class="frame"></div>
</inner>
`})
if (!this.getProp('border')) this.container.classList.add('noborder')
this.frame = DOM.get(this.widget, '.frame')[0]
}
updateHtml(){
var newHtml = html`<div class="html"></div>`
var newHtml = this.frame.cloneNode(false)
newHtml.innerHTML = sanitizeHtml(this.getProp('html'), sanitizeOptions)
morph(this.widget, newHtml)
morph(this.frame, newHtml)
}

View file

@ -40,13 +40,18 @@ module.exports = class Image extends StaticProperties(Widget, {bypass: true}) {
constructor(options) {
super({...options, html: html`<inner></inner>`})
super({...options, html: html`
<inner>
<div class="frame"></div>
</inner>
`})
if (!this.getProp('border')) this.container.classList.add('noborder')
this.frame = DOM.get(this.widget, '.frame')[0]
this.widget.style.setProperty('background-size', this.getProp('size'))
this.widget.style.setProperty('background-position', this.getProp('position'))
this.widget.style.setProperty('background-repeat', this.getProp('repeat'))
this.frame.style.setProperty('background-size', this.getProp('size'))
this.frame.style.setProperty('background-position', this.getProp('position'))
this.frame.style.setProperty('background-repeat', this.getProp('repeat'))
}
@ -82,9 +87,9 @@ module.exports = class Image extends StaticProperties(Widget, {bypass: true}) {
if (url) {
this.widget.style.setProperty('background-image', `url("${url}${cache_query}")`)
this.frame.style.setProperty('background-image', `url("${url}${cache_query}")`)
} else {
this.widget.style.setProperty('background-image', '')
this.frame.style.setProperty('background-image', '')
}
if (options.sync) this.changed(options)

View file

@ -34,10 +34,12 @@ class Svg extends StaticProperties(Widget, {bypass: true}) {
super({...options, html: html`
<inner>
<svg></svg>
<svg class="frame"></svg>
</inner>
`})
this.frame = DOM.get(this.widget, '.frame')[0]
this.height = undefined
this.width = undefined
@ -58,12 +60,11 @@ class Svg extends StaticProperties(Widget, {bypass: true}) {
svg = svg.replace(/([0-9.]+%y)/gi, m=>(parseFloat(m) * this.height / 100).toFixed(2))
var newSvg = html`<svg></svg>`,
node = html`<div class="svg">${newSvg}</div>`
var node = this.frame.cloneNode(false)
newSvg.innerHTML = svg
node.innerHTML = svg
morph(this.widget, node)
morph(this.frame, node)
}

View file

@ -66,7 +66,7 @@ module.exports.categories = {
'Containers':['panel', 'modal', 'clone'],
'Frames':['frame', 'svg', 'html', 'image'],
'Graphs':['plot','eq','visualizer'],
'Indicator':['led', 'text'],
'Indicators':['led', 'text'],
'Inputs':['input', 'keys', 'script', 'gyroscope', 'file'],
'Matrices':['matrix', 'keyboard', 'patchbay'],
'Pads':['xy','rgb','multixy', 'canvas'],

View file

@ -108,10 +108,10 @@ module.exports = class Encoder extends StaticProperties(Knob, {angle: 360, range
} else {
// snap or circular
var offsetX = this.lastOffsetX + e.movementX / e.inertia,
offsetY = this.lastOffsetY + e.movementY / e.inertia
var offsetX = this.lastOffsetX + e.movementX,
offsetY = this.lastOffsetY + e.movementY
if (true || e.traversing && this.getProp('mode') === 'circular') {
if (e.traversing || this.getProp('mode') === 'circular') {
// circular
var diff = this.angleToPercent(this.coordsToAngle(offsetX, offsetY), true) - this.angleToPercent(this.coordsToAngle(this.lastOffsetX, this.lastOffsetY), true)
if (Math.abs(diff) < 50 && diff !== 0) this.setPercent(this.percent + diff)

View file

@ -15,11 +15,15 @@ module.exports = class Knob extends Slider {
_knob:'knob',
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',
]},
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', value: false, help: 'Set to `true` to display a dashed gauge'},
angle: {type: 'number', value: 270, help: 'Defines the angle\'s width of the knob, in degrees'},
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 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 (`/<doubleTap> <preArgs>`)'
@ -31,7 +35,7 @@ module.exports = class Knob extends Slider {
'Example: (`{min:{"-inf": 0}, "50%": 0.25, max: {"+inf": 1}}`)'
]},
logScale: {type: 'boolean|number', value: false, help: 'Set to `true` to use logarithmic scale (base 10). Set to a `number` to define the logarithm\'s base.'},
sensitivity: {type: 'number', value: 1, help: 'Defines the knob\'s sensitivity when `snap` is `false` '},
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`',
@ -79,9 +83,7 @@ module.exports = class Knob extends Slider {
this.lastOffsetX = e.offsetX
this.lastOffsetY = e.offsetY
// if (!(e.traversing || this.getProp('snap')) || e.ctrlKey) return
if (this.getProp('snap')) {
if (this.getProp('mode') === 'snap') {
this.percent = this.angleToPercent(this.coordsToAngle(e.offsetX, e.offsetY))
@ -94,18 +96,18 @@ module.exports = class Knob extends Slider {
dragHandle(e) {
if (!(e.traversing || this.getProp('snap')) || e.ctrlKey) {
if ((this.getProp('mode') === 'vertical' && !e.traversing) || e.ctrlKey) {
// vertical
this.percent = -100 * (e.movementY / e.inertia * this.getProp('sensitivity')) / this.minDimension + this.percent
} else {
//snap
var offsetX = this.lastOffsetX + e.movementX / e.inertia,
offsetY = this.lastOffsetY + e.movementY / e.inertia
// snap or circular
var offsetX = this.lastOffsetX + e.movementX,
offsetY = this.lastOffsetY + e.movementY
if (e.traversing && !this.getProp('snap')) {
var diff = this.angleToPercent(this.coordsToAngle(offsetX, offsetY), true) - this.angleToPercent(this.coordsToAngle(this.lastOffsetX, this.lastOffsetY), true)
if (e.traversing || this.getProp('mode') === 'circular') {
// circular
var diff = this.angleToPercent(this.coordsToAngle(offsetX, offsetY)) - this.angleToPercent(this.coordsToAngle(this.lastOffsetX, this.lastOffsetY))
if (Math.abs(diff) < 50 && diff !== 0) this.percent += diff
} else {
@ -121,7 +123,7 @@ module.exports = class Knob extends Slider {
}
this.percent = clip(this.percent,[0,100])
// this.percent = clip(this.percent,[0,100])
this.setValue(this.percentToValue(this.percent), {send:true,sync:true,dragged:true})
@ -137,11 +139,9 @@ module.exports = class Knob extends Slider {
}
angleToPercent(angle, ignoreMaxAngle=false) {
angleToPercent(angle) {
return ignoreMaxAngle ?
clip(angle, [0, 360]) / 360 * 100 :
clip(angle - (360 - this.maxAngle) / 2, [0, this.maxAngle]) / this.maxAngle * 100
return clip(angle - (360 - this.maxAngle) / 2, [0, this.maxAngle]) / this.maxAngle * 100
}

Some files were not shown because too many files have changed in this diff Show more