Merge branch 'master' into fastdom

This commit is contained in:
jean-emmanuel 2022-01-26 13:56:33 +01:00
commit f4a28dbec7
18 changed files with 158 additions and 110 deletions

View file

@ -1,5 +1,26 @@
# Changelog
## 1.14.4
- inspector
- color picker: inline picker widget (no longer in a modal); show color changes on the fly
## 1.14.3
- bug fixes
- osc receivers (`OSC{}` syntax) now apply the same rule as widgets regarding midi messages (only receive if the message's origin matches one of the host widget's midi targets)
- modal: rendering issue on iOS
- button: `locals.touchCoords` not updated since v1.14.0
- widgets
- clone/fragment: remove scripting properties as they are supposed to bo overriden in `props`
## 1.14.2
- bug fixes
- context-menu: double click issue in submenus on small touch screens
- clone/fragment: broken onDraw / onTouch scripts if cloned widget is a canvas
## 1.14.0, 1.14.1
- bug fixes

View file

@ -2,7 +2,7 @@
"name": "open-stage-control",
"productName": "Open Stage Control",
"description": "Libre and modular OSC / MIDI controller",
"version": "1.14.2",
"version": "1.14.3",
"author": {
"name": "Jean-Emmanuel Doucet",
"email": "jean-emmanuel@ammd.net"

View file

@ -46,6 +46,9 @@ The OSC listener syntax returns the value received on specified address (or the
Options can contain `@{}` blocks.
!!! note "Receiving MIDI"
Midi messages will be processed only if the receiver's widget includes the emitting MIDI device in its targets.
??? example "Array/Object default value"
```js
JS{

View file

@ -29,7 +29,7 @@ class Editor {
this.inspector = new UiInspector({selector: '#osc-inspector'})
this.inspector.on('update', (event)=>{
var {propName, value} = event,
var {propName, value, preventHistory} = event,
newWidgets = [],
error = false
@ -70,7 +70,7 @@ class Editor {
if (error) return
this.pushHistory()
if (!preventHistory) this.pushHistory()
if (newWidgets.length > 1) this.select(newWidgets)
@ -484,7 +484,6 @@ class Editor {
disable() {
this.unselect()
this.selectedWidgets = []

View file

@ -64,8 +64,6 @@ module.exports = {
fullscreen_addtohome: 'You must add this page to your home screen to launch it in fullscreen',
// inspector
inspector_color_confirm: 'Confirm',
inspector_color_apply: 'Apply',
inspector_error: 'An error just occured, open the console to read more.',
// nosleep

View file

@ -63,8 +63,6 @@ module.exports = {
fragment_mode_explanation: 'La session sera enregistrée sous forme de fragment : seul le premier descendant de l\'élément root sera sauvegardé.',
// inspector
inspector_color_confirm: 'Confirmer',
inspector_color_apply: 'Appliquer',
inspector_error: 'Une erreur vient de survenir, ouvrez la console pour en savoir plus.',
// nosleep

View file

@ -306,8 +306,8 @@ var converters = [
}
}
if (data.type === 'canvas') {
data.onDraw = data.draw
data.onTouch = data.touch
if (data.draw !== undefined) data.onDraw = data.draw
if (data.touch !== undefined) data.onTouch = data.touch
}
}

View file

@ -39,6 +39,30 @@ var Osc = class Osc extends EventEmitter {
}
match(widget, data) {
let widgetTarget = widget.getProp('target'),
match = true
if (data._rawTarget) {
// if the message target is provided (when message comes from another client connected to the same server)
// then we only update the widgets that have the exact same target
match = deepEqual(widgetTarget, data._rawTarget)
} else if (data.host === 'midi') {
// if the message comes from a midi port, only update widgets that send to that port
let widgetArrayTarget = Array.isArray(widgetTarget) ? widgetTarget : [widgetTarget],
strTarget = data.host + ':' + data.port
match = widgetArrayTarget.includes(strTarget) ||
(!widgetArrayTarget.includes(null) && this.serverTargets.includes(strTarget))
}
return match
}
receive(data){
if (typeof this.remoteControl.exists === 'function' && this.remoteControl.exists(data.address)) this.remoteControl.exec(data.address, data.args)
@ -47,30 +71,13 @@ var Osc = class Osc extends EventEmitter {
for (let i in widgets) {
let widgetTarget = widgets[i].getProp('target'),
match = true
if (data._rawTarget) {
// if the message target is provided (when message comes from another client connected to the same server)
// then we only update the widgets that have the exact same target
match = deepEqual(widgetTarget, data._rawTarget)
} else if (data.host === 'midi') {
// if the message comes from a midi port, only update widgets that send to that port
let widgetArrayTarget = Array.isArray(widgetTarget) ? widgetTarget : [widgetTarget],
strTarget = data.host + ':' + data.port
match = widgetArrayTarget.includes(strTarget) ||
(!widgetArrayTarget.includes(null) && this.serverTargets.includes(strTarget))
}
if (match) {
if (this.match(widgets[i], data)) {
widgets[i].setValue(restArgs,{send:false,sync:true,fromExternal:!data.target})
}
}
this.trigger(data.address, data.args)
this.trigger(data.address, data)
}

View file

@ -50,6 +50,7 @@ class ContextMenu extends UiWidget {
})
this.container.addEventListener('touchstart', (e)=>{
if (e.target.classList.contains('has-sub')) e.preventDefault()
if (!e.target.classList.contains('focus')) {
DOM.each(e.target.parentNode, '.focus', (el)=>{
el.classList.remove('focus')

View file

@ -1,10 +1,8 @@
var UiWidget = require('./ui-widget'),
Rgb = require('../widgets/pads/rgb'),
UiModal = require('./ui-modal'),
html = require('nanohtml'),
chroma = require('chroma-js'),
resize = require('../events/resize'),
locales = require('../locales')
resize = require('../events/resize')
class ColorPicker extends UiWidget {
@ -27,63 +25,56 @@ class ColorPicker extends UiWidget {
}, parent: this})
this.rgb.container.classList.add('not-editable')
this.modal = new UiModal({
width: 280,
height: 320,
closable: true,
title: '',
hide: true,
html: true,
content: html`
<div class="color-picker-modal">
${this.rgb.container}
<div class="actions">
<div class="btn color-apply">${locales('inspector_color_apply')}</div>
<div class="btn color-confirm">${locales('inspector_color_confirm')}</div>
</div>
</div>
`,
enterKey: this.confirm.bind(this)
})
DOM.get(this.modal.container, '.color-confirm')[0].addEventListener('click', this.confirm.bind(this))
DOM.get(this.modal.container, '.color-apply')[0].addEventListener('click', this.apply.bind(this))
this.container = html`
<div class="color-picker">
${this.rgb.container}
</div>
`
this.rgb.on('change', (e)=>{
e.stopPropagation = true
this.value = chroma(this.rgb.value).hex()
this.trigger('change', {preventHistory: true})
})
// this.rgb.on('dragend', (e)=>{
// this.value = chroma(this.rgb.value).hex()
// this.trigger('change')
// })
this.rgb.on('dragend', (e)=>{
this.value = chroma(this.rgb.value).hex()
this.trigger('change')
})
this.opened = 0
this.label = DOM.get(this.modal.container, '.title')[0]
this.escKeyHandler = ((e)=>{
if (e.keyCode==27) this.close()
}).bind(this)
this.enterKeyHandler = ((e)=>{
if (e.keyCode == 13) this.confirm()
}).bind(this)
}
open() {
this.label.innerHTML = this.name
this.modal.open()
this.parentNode.appendChild(this.container)
resize.check(this.rgb.container)
this.opened = 1
document.addEventListener('keydown', this.escKeyHandler)
document.addEventListener('keydown', this.enterKeyHandler)
}
close() {
this.modal.close()
if (this.parentNode.contains(this.container)) {
this.parentNode.removeChild(this.container)
}
this.setName()
this.opened = 0
}
apply() {
this.value = chroma(this.rgb.getValue(true)).css('rgba')
this.trigger('change')
document.removeEventListener('keydown', this.escKeyHandler)
document.removeEventListener('keydown', this.enterKeyHandler)
}
confirm() {
@ -114,6 +105,13 @@ class ColorPicker extends UiWidget {
}
setParent(node) {
if (this.opened && node !== this.parentNode) this.close()
this.parentNode = node
}
}
module.exports = ColorPicker

View file

@ -41,11 +41,11 @@ class UiInspector extends UiWidget {
this.parentContainer = DOM.get('osc-panel-container.right osc-panel-inner')[0]
this.colorPicker = new UiColorPicker()
this.colorPicker.on('change', ()=>{
this.colorPicker.on('change', (event)=>{
var textarea = DOM.get(this.container, `textarea[name="${this.colorPicker.name}"]`)
if (textarea) {
textarea[0].value = this.colorPicker.value
DOM.dispatchEvent(textarea[0], 'change')
DOM.dispatchEvent(textarea[0], 'change', event)
}
})
@ -55,10 +55,9 @@ class UiInspector extends UiWidget {
if (node.tagName === 'OSC-INSPECTOR-CHECKBOX') {
var name = node.getAttribute('name')
let name = node.getAttribute('name'),
textarea = DOM.get(this.container, `textarea[name="${name}"]`)
var textarea = DOM.get(this.container, `textarea[name="${name}"]`)
if (textarea) {
fastdom.mutate(()=>{
textarea[0].value = !node.classList.contains('on')
@ -68,9 +67,16 @@ class UiInspector extends UiWidget {
} else if (node.tagName === 'OSC-INSPECTOR-COLOR') {
this.colorPicker.setName(node.getAttribute('name'))
this.colorPicker.setValue(node.getAttribute('value'))
this.colorPicker.open()
let name = node.getAttribute('name')
if (this.colorPicker.name === name) {
this.colorPicker.close()
} else {
this.colorPicker.setParent(node.parentNode)
this.colorPicker.setName(name)
this.colorPicker.setValue(node.getAttribute('value'))
this.colorPicker.open()
}
} else if (node.tagName === 'LABEL') {
@ -196,6 +202,7 @@ class UiInspector extends UiWidget {
var picker = DOM.get(this.container, `osc-inspector-color[name="${this.colorPicker.name}"]`)
if (picker && picker[0]) {
this.colorPicker.setValue(picker[0].getAttribute('value'))
this.colorPicker.open()
} else {
this.colorPicker.close()
}
@ -231,7 +238,8 @@ class UiInspector extends UiWidget {
this.trigger('update', {
propName: input.name,
value: v
value: v,
preventHistory: event.detail && event.detail.preventHistory
})
// this may not be reached if an error is thrown

View file

@ -64,7 +64,7 @@ class Button extends Widget {
this.pulse = null
this.buttonSize = [100, 100]
this.exposeTouchCoords = String(this.getProp('script')).includes('touchCoords')
this.exposeTouchCoords = String(this.getProp('onValue')).includes('touchCoords')
this.parsersLocalScope.touchCoords = [0.5, 0.5]
if (this.exposeTouchCoords) {
this.on('resize', (e)=>{

View file

@ -56,7 +56,9 @@ module.exports = class OscReceiver {
}
callback(args) {
callback(data) {
var {args} = data
if (!Array.isArray(args)) args = [args]
var preArgs = this.usePreArgs ? (this.parent.getProp('preArgs') || []) : []
@ -65,6 +67,7 @@ module.exports = class OscReceiver {
for (var i in preArgs) {
if (preArgs[i] !== args[i]) return
}
if (!osc.match(this.parent, data)) return
var value = args.slice(preArgs.length)
if (value.length < 2) value = value[0]
if (typeof value === 'string' && isJSONObject(value)) {

View file

@ -26,7 +26,8 @@ class Clone extends Container() {
props: {type: 'object', value: {}, editor: 'javascript', syntaxChecker: false, help: 'Cloned widget\'s properties to override'},
},
value: null,
osc: null
osc: null,
scripting: null
})
defaults.style = {css: defaults.style.css}

View file

@ -28,7 +28,8 @@ class Fragment extends Container() {
props: {type: 'object', value: {}, editor: 'javascript', syntaxChecker: false, help: 'Fragment widget\'s properties to override'},
},
value: null,
osc: null
osc: null,
scripting: null
})
defaults.style = {css: defaults.style.css}

View file

@ -402,7 +402,7 @@ class ScriptVm extends Vm {
try {
callback()
} catch(e) {
this.errorProp('script', 'setInterval', e)
widget.errorProp('script', 'setInterval', e)
}
this.setWidget()
this.setValueOptions()

View file

@ -1,5 +1,6 @@
$header-height: 28rem;
$field-height: 24rem;
$label-width: 94rem;
$padding: 8rem;
$radius: 3rem;
@ -24,7 +25,7 @@ osc-inspector-field {
&:after {
content:"";
position: absolute;
left:94rem;
left:$label-width;
top:0;
right: 1rem;
border-top:1rem solid var(--color-ui-background);
@ -35,7 +36,7 @@ osc-inspector-field {
--widget-padding: -1rem;
> label {
width: 94rem;
width: $label-width;
text-transform: none;
padding-left: 4rem;
padding-right: 4rem;
@ -457,6 +458,9 @@ osc-inspector-category {
}
border-top-left-radius: $radius;
border-top-right-radius: $radius;
.color-picker {
margin-top: 2rem;
}
}
osc-inspector-field.last-child,
osc-inspector-field:last-child {
@ -595,38 +599,42 @@ osc-inspector-color {
}
}
.color-picker-modal {
flex: 1;
.color-picker {
position: absolute;
z-index: 99;
height: 180rem;
top: 0;
right: 22rem;
left: $label-width;
margin: 3rem 2rem;
display: flex;
flex-direction: column;
$padding: 2rem;
border: 1rem solid var(--color-ui-button);
overflow: hidden;
.widget {
background: var(--color-background);
background: var(--color-ui-background);
flex: 1;
width: auto;
--widget-padding: #{$padding};
}
.actions {
display: flex;
flex-direction: row;
align-items: flex-end;
justify-content: stretch;
height: 42rem + $padding * 2;
line-height: 38rem;
flex-shrink: 0;
background: var(--color-ui-foreground);
padding: $padding;
.btn {
flex: 1;
text-overflow: clip;
min-width: 0;
background: var(--color-ui-button);
margin-right: $padding;
&:last-child {
margin: 0;
}
--widget-padding: 0rem;
inner {
padding: 1rem;
}
.hue {
margin-left: 1rem;
width: 16rem;
--knob-size: 1rem;
}
.alpha {
margin-top: 0.5rem;
left:0;
margin-left: 0;
border:0;
}
.hue:after {
left:0;
right:0;
}
}

View file

@ -456,9 +456,11 @@
> .toggle {
--alpha-fill:var(--alpha-fill-on);
z-index: 1;
}
> label {
color: var(--color-text-on);
z-index: 2;
}
z-index: 9999999999999!important;