v1 on fire
This commit is contained in:
parent
6a308202ce
commit
216951a6ea
27 changed files with 279 additions and 115 deletions
|
|
@ -21,7 +21,6 @@ class Dropdown extends Widget {
|
|||
values: {type: 'array|object', value: {'Value 1':1,'Value 2':2}, help: [
|
||||
'`Array` of possible values to switch between : `[1,2,3]`',
|
||||
'`Object` of label:value pairs. Numeric labels must be prepended or appended with a white space (or any other non-numeric character) otherwise the order of the values won\'t be kept',
|
||||
'An empty option will always be prepended to values (sends an osc message without any value); it can be hidden by adding `option:first-child{display:none}` to the widget\'s `css`'
|
||||
]}
|
||||
|
||||
})
|
||||
|
|
@ -30,9 +29,15 @@ class Dropdown extends Widget {
|
|||
|
||||
constructor(options) {
|
||||
|
||||
super({...options, html: html`<div class="select"></div>`})
|
||||
super({...options, html: html`
|
||||
<inner>
|
||||
<div class="text"></div>
|
||||
<div class="icon"></div>
|
||||
</inner>
|
||||
`})
|
||||
|
||||
this.select = this.widget.appendChild(html`<select class="no-keybinding"></select>`)
|
||||
this.text = DOM.get(this.widget, '.text')[0]
|
||||
|
||||
this.values = []
|
||||
this.keys = []
|
||||
|
|
@ -80,6 +85,7 @@ class Dropdown extends Widget {
|
|||
var i = this.values.indexOf(v)
|
||||
|
||||
this.value = this.values[i]
|
||||
this.text.textContent = this.value
|
||||
|
||||
if (!options.fromLocal) this.select.selectedIndex = i + 1
|
||||
|
||||
|
|
|
|||
|
|
@ -47,11 +47,14 @@ class Menu extends Widget {
|
|||
|
||||
super({...options, html: html`
|
||||
<inner>
|
||||
<div class="text"></div>
|
||||
<div class="icon"></div>
|
||||
</inner>
|
||||
|
||||
`})
|
||||
|
||||
this.menu = html`<menu></menu>`
|
||||
this.text = DOM.get(this.widget, '.text')[0]
|
||||
|
||||
this.opened = false
|
||||
|
||||
|
|
@ -222,6 +225,8 @@ class Menu extends Widget {
|
|||
|
||||
}
|
||||
|
||||
if (circular) this.menu.appendChild(html`<div class="center"></div>`)
|
||||
|
||||
|
||||
this.setValue(this.value)
|
||||
|
||||
|
|
@ -267,7 +272,7 @@ class Menu extends Widget {
|
|||
|
||||
DOM.each(this.menu, '.on', (el)=>{el.classList.remove('on')})
|
||||
if (i > -1) DOM.get(this.menu, '.item')[i].classList.add('on')
|
||||
this.widget.textContent = this.stringValues[i] || this.value
|
||||
this.text.textContent = this.stringValues[i] || this.value
|
||||
|
||||
if (options.send) this.sendValue()
|
||||
if (options.sync) this.changed(options)
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ class Toggle extends Widget {
|
|||
|
||||
if (this.getProp('doubleTap')) {
|
||||
|
||||
doubletab(this.container, ()=>{
|
||||
doubletab(this.widget, ()=>{
|
||||
|
||||
this.setValue(this.getProp('on'), {sync: true, send: true})
|
||||
|
||||
|
|
@ -67,7 +67,7 @@ class Toggle extends Widget {
|
|||
this.active = true
|
||||
this.setValue(this.getProp('on'), {sync: true, send: true})
|
||||
|
||||
}, {element: this.container})
|
||||
}, {element: this.widget})
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -76,13 +76,13 @@ class Toggle extends Widget {
|
|||
this.active = false
|
||||
this.setValue(this.getProp('off'), {sync: true, send: !tap})
|
||||
|
||||
}, {element: this.container})
|
||||
}, {element: this.widget})
|
||||
|
||||
} else {
|
||||
|
||||
if (this.getProp('doubleTap')) {
|
||||
|
||||
doubletab(this.container, ()=>{
|
||||
doubletab(this.widget, ()=>{
|
||||
|
||||
this.setValue(this.state ? this.getProp('off') : this.getProp('on'), {sync: true, send: true})
|
||||
|
||||
|
|
@ -97,13 +97,13 @@ class Toggle extends Widget {
|
|||
this.active = true
|
||||
this.setValue(this.state ? this.getProp('off') : this.getProp('on'), {sync: true, send: true})
|
||||
|
||||
}, {element: this.container})
|
||||
}, {element: this.widget})
|
||||
|
||||
this.on('dragend',()=>{
|
||||
|
||||
this.active = false
|
||||
|
||||
}, {element: this.container})
|
||||
}, {element: this.widget})
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -135,32 +135,22 @@ class Canvas extends Widget {
|
|||
|
||||
this.cssVars.padding = parseFloat(style.getPropertyValue('--widget-padding')) * PXSCALE // rem unit
|
||||
|
||||
this.cssVars.colorWidget = style.getPropertyValue('--color-widget')
|
||||
this.cssVars.colorFill = style.getPropertyValue('--color-fill')
|
||||
this.cssVars.colorStroke = style.getPropertyValue('--color-stroke')
|
||||
this.cssVars.colorForeground = style.getPropertyValue('--color-foreground')
|
||||
|
||||
this.cssVars.alphaStroke = parseFloat(style.getPropertyValue('--alpha-stroke'))
|
||||
this.cssVars.alphaFillOff = parseFloat(style.getPropertyValue('--alpha-fill-off'))
|
||||
this.cssVars.alphaFillOn = parseFloat(style.getPropertyValue('--alpha-fill-on'))
|
||||
this.cssVars.colorText = style.getPropertyValue('--color-text').trim()
|
||||
this.cssVars.colorWidget = style.getPropertyValue('--color-widget').trim()
|
||||
this.cssVars.colorFill = style.getPropertyValue('--color-fill').trim()
|
||||
this.cssVars.colorStroke = style.getPropertyValue('--color-stroke').trim()
|
||||
this.cssVars.colorForeground = style.getPropertyValue('--color-foreground').trim()
|
||||
|
||||
|
||||
this.cssVars.alphaStroke = parseFloat(style.getPropertyValue('--alpha-stroke').trim())
|
||||
this.cssVars.alphaFillOff = parseFloat(style.getPropertyValue('--alpha-fill-off').trim())
|
||||
this.cssVars.alphaFillOn = parseFloat(style.getPropertyValue('--alpha-fill-on').trim())
|
||||
this.cssVars.alphaPips = parseFloat(style.getPropertyValue('--alpha-pips').trim())
|
||||
|
||||
|
||||
this.colors.custom = style.getPropertyValue('--color-custom')
|
||||
this.colors.track = style.getPropertyValue('--color-track')
|
||||
this.colors.text = style.getPropertyValue('--color-text')
|
||||
this.colors.textFade = style.getPropertyValue('--color-text-fade')
|
||||
this.colors.raised = style.getPropertyValue('--color-raised')
|
||||
this.colors.bg = style.getPropertyValue('--color-bg')
|
||||
this.colors.fg = style.getPropertyValue('--color-fg')
|
||||
this.colors.faded = style.getPropertyValue('--color-faded')
|
||||
this.colors.light = style.getPropertyValue('--color-light')
|
||||
|
||||
this.fontFamily = style.getPropertyValue('font-family')
|
||||
this.textAlign = style.getPropertyValue('text-align')
|
||||
this.fontSize = parseFloat(style.getPropertyValue('font-size'))
|
||||
this.fontWeight = parseFloat(style.getPropertyValue('font-weight'))
|
||||
this.fontFamily = style.getPropertyValue('font-family').trim()
|
||||
this.textAlign = style.getPropertyValue('text-align').trim()
|
||||
this.fontSize = parseFloat(style.getPropertyValue('font-size').trim())
|
||||
this.fontWeight = parseFloat(style.getPropertyValue('font-weight').trim())
|
||||
|
||||
this.ctx.font = this.fontWeight + ' ' + this.fontSize + 'px ' + this.fontFamily
|
||||
this.ctx.textBaseline = 'middle'
|
||||
|
|
@ -207,6 +197,7 @@ class Canvas extends Widget {
|
|||
switch (propName) {
|
||||
|
||||
case 'css':
|
||||
case 'colorText':
|
||||
case 'colorWidget':
|
||||
case 'colorFill':
|
||||
case 'colorStroke':
|
||||
|
|
@ -219,7 +210,12 @@ class Canvas extends Widget {
|
|||
},10)
|
||||
return
|
||||
case 'padding':
|
||||
resize.check(this.widget)
|
||||
resize.check(this.canvas, true)
|
||||
setTimeout(()=>{
|
||||
this.cacheCanvasStyle()
|
||||
this.batchDraw()
|
||||
},10)
|
||||
return
|
||||
}
|
||||
|
||||
return ret
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ class Widget extends EventEmitter {
|
|||
'Insert icons using the prefix ^ followed by the icon\'s name : ^play, ^pause, etc (see https://fontawesome.com/icons?d=gallery&s=solid&m=free)'
|
||||
]},
|
||||
visible: {type: 'boolean', value: true, help: 'Set to `false` to hide the widget.'},
|
||||
// interaction: {type: 'boolean', value: true, help: 'Set to `false` to disable pointer interactions.'},
|
||||
interaction: {type: 'boolean', value: true, help: 'Set to `false` to disable pointer interactions.'},
|
||||
|
||||
_geometry:'geometry',
|
||||
|
||||
|
|
@ -78,6 +78,7 @@ class Widget extends EventEmitter {
|
|||
alphaStroke: {type: 'number', value: 'auto', help: 'Defines the widget\'s accent color (css variable `--custom-color`). Must be a valid CSS color. Set to "auto" to inherit from parent widget.'},
|
||||
alphaFillOff: {type: 'number', value: 'auto', help: 'Defines the widget\'s accent color (css variable `--custom-color`). Must be a valid CSS color. Set to "auto" to inherit from parent widget.'},
|
||||
alphaFillOn: {type: 'number', value: 'auto', help: 'Defines the widget\'s accent color (css variable `--custom-color`). Must be a valid CSS color. Set to "auto" to inherit from parent widget.'},
|
||||
colorText: {type: 'string', value: 'auto', help: 'Defines the widget\'s accent color (css variable `--custom-color`). Must be a valid CSS color. Set to "auto" to inherit from parent widget.'},
|
||||
|
||||
padding: {type: 'number', value: 'auto', help: 'Defines the widget\'s accent color (css variable `--custom-color`). Must be a valid CSS color. Set to "auto" to inherit from parent widget.'},
|
||||
|
||||
|
|
@ -87,8 +88,8 @@ class Widget extends EventEmitter {
|
|||
|
||||
_value: 'value',
|
||||
|
||||
default: {type: '*', value: '', help: 'If set, the widget will be initialized with this value when the session is loaded.'},
|
||||
value: {type: '*', value: '', help: 'Define the widget\'s value depending on other widget\'s values / properties using the advanced property syntax'},
|
||||
default: {type: '*', value: '', help: 'If set, the widget will be initialized with this value when the session is loaded.'},
|
||||
linkId: {type: 'string|array', value: '', help: [
|
||||
'Widgets sharing the same `linkId` update each other\'s value(s) AND send their respective osc messages.',
|
||||
'When prefixed with >>, the `linkId` will make the widget act as a master (sending but not receiving)',
|
||||
|
|
@ -192,6 +193,8 @@ class Widget extends EventEmitter {
|
|||
this.container._widget_instance = this
|
||||
this.setContainerStyles()
|
||||
|
||||
this.container.classList.toggle('no-interaction', !this.getProp('interaction'))
|
||||
|
||||
}
|
||||
|
||||
contains(widget) {
|
||||
|
|
@ -596,7 +599,7 @@ class Widget extends EventEmitter {
|
|||
// one bracket nesting allowed, if we need two: #\{(?:[^{}]|\{(?:[^{}]|\{[^{}]*\})*\})*\}
|
||||
|
||||
var code = m.substr(2, m.length - 3).trim()
|
||||
|
||||
|
||||
if (!this.parsers[code]) this.parsers[code] = evaljs('return ' + code, defaultScope)
|
||||
|
||||
let r = this.parsers[code](jsScope)
|
||||
|
|
@ -755,6 +758,10 @@ class Widget extends EventEmitter {
|
|||
resize.check(this.container)
|
||||
return
|
||||
|
||||
case 'interaction':
|
||||
this.container.classList.toggle('no-interaction', !this.getProp('interaction'))
|
||||
return
|
||||
|
||||
case 'label':
|
||||
this.setContainerStyles(['label'])
|
||||
if (oldPropValue === false || this.getProp('label') === false) {
|
||||
|
|
@ -771,6 +778,7 @@ class Widget extends EventEmitter {
|
|||
}
|
||||
return
|
||||
|
||||
case 'colorText':
|
||||
case 'colorWidget':
|
||||
case 'colorFill':
|
||||
case 'colorStroke':
|
||||
|
|
@ -785,7 +793,6 @@ class Widget extends EventEmitter {
|
|||
case 'address':
|
||||
case 'preArgs':
|
||||
case 'target':
|
||||
case 'noSync':
|
||||
if (propName === 'address') {
|
||||
for (var k in this.oscReceivers) {
|
||||
var receiver = this.oscReceivers[k]
|
||||
|
|
@ -935,21 +942,12 @@ class Widget extends EventEmitter {
|
|||
if (styles.includes('color')) {
|
||||
|
||||
// color
|
||||
for (var cssvar of ['color-widget', 'color-fill', 'color-stroke', 'alpha-stroke', 'alpha-fill-on', 'alpha-fill-off']) {
|
||||
for (var cssvar of ['color-text', 'color-widget', 'color-fill', 'color-stroke', 'alpha-stroke', 'alpha-fill-on', 'alpha-fill-off']) {
|
||||
var val = this.getProp(cssvar.replace(/\-([a-z])/g, (a,s)=>s.toUpperCase()))
|
||||
this.container.style.setProperty('--' + cssvar, val !== undefined && val != 'auto' ? val : '')
|
||||
}
|
||||
this.container.style.setProperty('--widget-padding', this.getProp('padding') !== undefined && this.getProp('padding') != 'auto' ? parseFloat(this.getProp('padding')) + 'rem' : '')
|
||||
|
||||
|
||||
// this.container.style.setProperty('--color-widget', this.getProp('colorWidget') && this.getProp('colorWidget') != 'auto' ? this.getProp('colorWidget') : '')
|
||||
// this.container.style.setProperty('--color-fill', this.getProp('colorFill') != 'auto' ? this.getProp('colorFill') : '')
|
||||
// this.container.style.setProperty('--color-stroke', this.getProp('colorStroke') != 'auto' ? this.getProp('colorStroke') : '')
|
||||
// this.container.style.setProperty('--alpha-stroke', this.getProp('alphaStroke') != 'auto' ? parseFloat(this.getProp('alphaStroke')) : '')
|
||||
// this.container.style.setProperty('--alpha-fill-on', this.getProp('alphaFillOn') != 'auto' ? parseFloat(this.getProp('alphaFillOn')) : '')
|
||||
// this.container.style.setProperty('--alpha-fill-off', this.getProp('alphaFillOff') != 'auto' ? parseFloat(this.getProp('alphaFillOff')) : '')
|
||||
// this.container.style.setProperty('--widget-padding', this.getProp('padding') != 'auto' ? parseFloat(this.getProp('padding')) + 'rem' : '')
|
||||
|
||||
}
|
||||
|
||||
return style
|
||||
|
|
@ -978,6 +976,7 @@ Widget.parsersContexts = {}
|
|||
Widget.dynamicProps = [
|
||||
'visible',
|
||||
'label',
|
||||
'interaction',
|
||||
|
||||
'top',
|
||||
'left',
|
||||
|
|
@ -985,6 +984,7 @@ Widget.dynamicProps = [
|
|||
'width',
|
||||
|
||||
|
||||
'colorText',
|
||||
'colorWidget',
|
||||
'colorFill',
|
||||
'colorStroke',
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ module.exports = class Tab extends StaticProperties(Panel, {scroll: true}) {
|
|||
|
||||
_tab:'tab',
|
||||
|
||||
detached: {type: 'boolean', value: true, help: 'Set to `false` if the tab contains `frame` widgets that should not be reloaded when the tab opens'},
|
||||
// detached: {type: 'boolean', value: true, help: 'Set to `false` if the tab contains `frame` widgets that should not be reloaded when the tab opens'},
|
||||
layout: {type: 'string', value: 'default', choices: ['default', 'vertical', 'horizontal'], help:''},
|
||||
traversing: {type: 'boolean', value: false, help: 'Set to `true` to enable traversing gestures in this widget. Set to `smart` or `auto` to limit affected widgets by the type of the first touched widget'},
|
||||
variables: {type: '*', value: '@{parent.variables}', help: 'Defines one or more arbitrary variables that can be inherited by children widgets'},
|
||||
|
|
|
|||
|
|
@ -16,10 +16,6 @@ class Frame extends StaticProperties(Widget, {bypass: true}) {
|
|||
|
||||
return super.defaults({
|
||||
|
||||
_frame: 'frame',
|
||||
|
||||
border: {type: 'boolean', value: true, help: 'Set to `false` to disable the borders and background-color'},
|
||||
|
||||
}, ['precision', 'bypass'], {
|
||||
|
||||
label: {type: 'string|boolean', value: 'auto', help: [
|
||||
|
|
@ -39,7 +35,7 @@ class Frame extends StaticProperties(Widget, {bypass: true}) {
|
|||
|
||||
super({...options, html: html`
|
||||
<inner>
|
||||
<iframe class="frame" src="" sandbox="allow-scripts"></iframe>
|
||||
<iframe class="frame" src="" sandbox="allow-scripts allow-same-origin"></iframe>
|
||||
</inner>`
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,6 @@ class Html extends StaticProperties(Widget, {bypass: true}) {
|
|||
' b, i, strong, em, strike, code, hr, br, div,',
|
||||
' table, thead, img, caption, tbody, tr, th, td, pre'
|
||||
]},
|
||||
border: {type: 'boolean', value: true, help: 'Set to `false` to disable the borders and background-color'},
|
||||
|
||||
}, ['precision', 'bypass'], {})
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ module.exports = class Image extends StaticProperties(Widget, {bypass: true}) {
|
|||
size: {type: 'string', value: 'cover', help: 'CSS background-size'},
|
||||
position: {type: 'string', value: 'center', help: 'CSS background-position'},
|
||||
repeat: {type: 'string', value: 'no-repeat', help: 'CSS background-repeat'},
|
||||
border: {type: 'boolean', value: true, help: 'Set to `false` to disable the borders and background-color'},
|
||||
cache: {type: 'boolean', value: true, help: [
|
||||
'Set to false to disable image caching (forces file reload when updating or editing the widget).',
|
||||
'When true, sending `reload` to the widget reloads its image without changing its value'
|
||||
|
|
|
|||
|
|
@ -23,8 +23,6 @@ class Svg extends StaticProperties(Widget, {bypass: true}) {
|
|||
'- will be wrapped in a `< svg />` element',
|
||||
'- `<path>` commands support a special percent notation (`%x` and `%y`)'
|
||||
]},
|
||||
border: {type: 'boolean', value: true, help: 'Set to `false` to disable the borders and background-color'},
|
||||
|
||||
|
||||
}, ['precision', 'bypass'], {})
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
var {clip} = require('../utils'),
|
||||
Plot = require('./plot')
|
||||
Plot = require('./plot'),
|
||||
Widget = require('../common/widget')
|
||||
|
||||
module.exports = class Eq extends Plot {
|
||||
|
||||
|
|
@ -11,7 +12,7 @@ module.exports = class Eq extends Plot {
|
|||
|
||||
static defaults() {
|
||||
|
||||
return super.defaults({
|
||||
return Widget.defaults({
|
||||
|
||||
_eq:'eq',
|
||||
|
||||
|
|
@ -22,7 +23,7 @@ module.exports = class Eq extends Plot {
|
|||
logScaleX: {type: 'boolean|number', value: false, help: 'Set to `true` to use logarithmic scale for the x axis (base 10). Set to a `number` to define the logarithm\'s base.'},
|
||||
smooth: {type: 'boolean|number', value: false, help: 'Set to `true` to make the line smooth. Float values are also acceptable (works fine between `0` and `0.5`)'},
|
||||
|
||||
}, ['precision', 'bypass'], {
|
||||
}, ['interaction', 'precision', 'bypass'], {
|
||||
|
||||
value: {type: 'array', value: '', help: [
|
||||
'Each item must be an object with the following properties',
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ var {mapToScale} = require('../utils'),
|
|||
html = require('nanohtml'),
|
||||
StaticProperties = require('../mixins/static_properties')
|
||||
|
||||
module.exports = class Plot extends StaticProperties(Canvas, {bypass: true}) {
|
||||
module.exports = class Plot extends StaticProperties(Canvas, {bypass: true, interaction: false}) {
|
||||
|
||||
static description() {
|
||||
|
||||
|
|
@ -28,7 +28,7 @@ module.exports = class Plot extends StaticProperties(Canvas, {bypass: true}) {
|
|||
smooth: {type: 'boolean|number', value: false, help: 'Set to `true` to make the line smooth. Float values are also acceptable (works fine between `0` and `0.5`)'},
|
||||
pips:{type: 'boolean', value: true, help: 'Set to `false` to hide the scale'},
|
||||
|
||||
}, ['precision', 'bypass'], {
|
||||
}, ['interaction', 'precision', 'bypass'], {
|
||||
|
||||
value: {type: 'array|string', value: '', help: [
|
||||
'- `Array` of `y` values',
|
||||
|
|
@ -87,8 +87,8 @@ module.exports = class Plot extends StaticProperties(Canvas, {bypass: true}) {
|
|||
|
||||
draw_pips() {
|
||||
|
||||
this.ctx.globalAlpha = 1
|
||||
this.ctx.fillStyle = this.colors.textFade
|
||||
this.ctx.fillStyle = this.cssVars.colorText
|
||||
this.ctx.globalAlpha = this.cssVars.alphaPips
|
||||
|
||||
var margin = this.cssVars.padding
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ var {clip} = require('../utils'),
|
|||
StaticProperties = require('../mixins/static_properties')
|
||||
|
||||
|
||||
module.exports = class Visualizer extends StaticProperties(Plot, {rangeX: {min: '', max: ''}, dots: false, smooth: false}) {
|
||||
module.exports = class Visualizer extends StaticProperties(Plot, {rangeX: {min: '', max: ''}, dots: false, smooth: false, interaction: false}) {
|
||||
|
||||
static description() {
|
||||
|
||||
|
|
@ -24,7 +24,7 @@ module.exports = class Visualizer extends StaticProperties(Plot, {rangeX: {min:
|
|||
logScaleY: {type: 'boolean|number', value: false, help: 'Set to `true` to use logarithmic scale for the y axis (base 10). Set to a `number` to define the logarithm\'s base.'},
|
||||
pips:{type: 'boolean', value: true, help: 'Set to `false` to hide the scale'},
|
||||
|
||||
}, ['precision', 'bypass'], {})
|
||||
}, ['interaction', 'precision', 'bypass'], {})
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ var {mapToScale, clip} = require('../utils'),
|
|||
html = require('nanohtml'),
|
||||
StaticProperties = require('../mixins/static_properties')
|
||||
|
||||
module.exports = class Led extends StaticProperties(Widget, {bypass: true}) {
|
||||
module.exports = class Led extends StaticProperties(Widget, {bypass: true, interaction: false}) {
|
||||
|
||||
static description() {
|
||||
|
||||
|
|
@ -24,7 +24,7 @@ module.exports = class Led extends StaticProperties(Widget, {bypass: true}) {
|
|||
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.'},
|
||||
borderRadius: {type: 'string', value: '', help: 'Css border-radius property.'},
|
||||
|
||||
}, ['precision', 'bypass'], {
|
||||
}, ['interaction', 'precision', 'bypass'], {
|
||||
|
||||
value: {type: 'number|array|string', value: '', help: [
|
||||
'- `Number`: if `mode` is set to `intensity`',
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ var {iconify} = require('../../ui/utils'),
|
|||
html = require('nanohtml'),
|
||||
StaticProperties = require('../mixins/static_properties')
|
||||
|
||||
module.exports = class Text extends StaticProperties(Widget, {bypass: true}) {
|
||||
module.exports = class Text extends StaticProperties(Widget, {bypass: true, interaction: false}) {
|
||||
|
||||
static description() {
|
||||
|
||||
|
|
@ -24,7 +24,7 @@ module.exports = class Text extends StaticProperties(Widget, {bypass: true}) {
|
|||
]},
|
||||
align: {type: 'string', value: 'center', choices: ['center', 'left', 'right'], help: 'Css text-align property.'},
|
||||
|
||||
}, ['precision', 'bypass'], {})
|
||||
}, ['interaction', 'precision', 'bypass'], {})
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ var Canvas = require('../common/canvas'),
|
|||
{deepCopy} = require('../../utils'),
|
||||
html = require('nanohtml')
|
||||
|
||||
module.exports = class Input extends Canvas {
|
||||
class Input extends Canvas {
|
||||
|
||||
static description() {
|
||||
|
||||
|
|
@ -18,7 +18,6 @@ module.exports = class Input extends Canvas {
|
|||
|
||||
align: {type: 'string', value: 'center', choices: ['center', 'left', 'right'], help: 'Set to `left` or `right` to change text alignment (otherwise center)'},
|
||||
unit: {type: 'string', value: '', help: 'Unit will be appended to the displayed widget\'s value (it doesn\'t affect osc messages)'},
|
||||
editable: {type: 'boolean', value: true, help: 'Set to `false` to make the input non-editable'},
|
||||
asYouType: {type: 'boolean', value: false, help: 'Set to `true` to make the input send its value at each keystroke'}
|
||||
|
||||
})
|
||||
|
|
@ -43,7 +42,8 @@ module.exports = class Input extends Canvas {
|
|||
if (this.getProp('align') === 'right') this.widget.classList.add('right')
|
||||
|
||||
|
||||
if (this.getProp('editable')) {
|
||||
if (this.getProp('interaction')) {
|
||||
|
||||
this.canvas.setAttribute('tabindex', 0)
|
||||
this.canvas.addEventListener('focus', this.focus.bind(this))
|
||||
this.input = html`<input class="no-keybinding"></input>`
|
||||
|
|
@ -62,8 +62,7 @@ module.exports = class Input extends Canvas {
|
|||
})
|
||||
}
|
||||
})
|
||||
} else {
|
||||
this.widget.classList.add('not-editable')
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -144,7 +143,7 @@ module.exports = class Input extends Canvas {
|
|||
|
||||
this.clear()
|
||||
|
||||
this.ctx.fillStyle = this.colors.text
|
||||
this.ctx.fillStyle = this.cssVars.colorText
|
||||
|
||||
if (this.textAlign == 'center') {
|
||||
this.ctx.fillText(v, Math.round(width/2), Math.round(height/2))
|
||||
|
|
@ -166,3 +165,9 @@ module.exports = class Input extends Canvas {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
Input.dynamicProps = Input.prototype.constructor.dynamicProps
|
||||
.filter(x=>x !== 'interaction')
|
||||
|
||||
|
||||
module.exports = Input
|
||||
|
|
|
|||
|
|
@ -199,8 +199,8 @@ module.exports = class MultiXy extends Pad {
|
|||
t = (this.labels ? this.getProp('points')[i] : i) + '',
|
||||
length = this.fontSize * t.length
|
||||
|
||||
this.ctx.globalAlpha = 1
|
||||
this.ctx.fillStyle = this.pads[i].colors.text
|
||||
this.ctx.fillStyle = this.pads[i].cssVars.colorText
|
||||
this.ctx.globalAlpha = this.cssVars.alphaPips
|
||||
this.ctx.fillText(t, x + 0.5 * PXSCALE, y + PXSCALE)
|
||||
|
||||
this.clearRect[i] = [x - length / 2, y - this.fontSize / 2, length, this.fontSize + 2 * PXSCALE]
|
||||
|
|
|
|||
|
|
@ -213,9 +213,9 @@ module.exports = class Xy extends Pad {
|
|||
var pipTexts = margin >= this.fontSize * 1.5
|
||||
|
||||
this.ctx.lineWidth = PXSCALE
|
||||
this.ctx.fillStyle = this.colors.textFade
|
||||
this.ctx.fillStyle = this.cssVars.colorText
|
||||
this.ctx.strokeStyle = this.cssVars.colorStroke
|
||||
this.ctx.globalAlpha = 1
|
||||
this.ctx.globalAlpha = this.cssVars.alphaPips
|
||||
this.ctx.beginPath()
|
||||
|
||||
for (let i in this.faders.x.rangeKeys) {
|
||||
|
|
|
|||
|
|
@ -107,8 +107,8 @@ module.exports = class Knob extends Slider {
|
|||
|
||||
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
|
||||
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.percent += diff * 360 / this.maxAngle
|
||||
|
||||
} else {
|
||||
|
||||
|
|
@ -139,9 +139,11 @@ module.exports = class Knob extends Slider {
|
|||
|
||||
}
|
||||
|
||||
angleToPercent(angle) {
|
||||
angleToPercent(angle, ignoreMaxAngle=false) {
|
||||
|
||||
return clip(angle - (360 - this.maxAngle) / 2, [0, this.maxAngle]) / this.maxAngle * 100
|
||||
return ignoreMaxAngle ?
|
||||
clip(angle, [0, 360]) / 360 * 100
|
||||
: clip(angle - (360 - this.maxAngle) / 2, [0, this.maxAngle]) / this.maxAngle * 100
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -238,9 +240,9 @@ module.exports = class Knob extends Slider {
|
|||
|
||||
if (pips) {
|
||||
|
||||
this.ctx.globalAlpha = 1
|
||||
this.ctx.lineWidth = 1.5 * PXSCALE
|
||||
this.ctx.strokeStyle = this.cssVars.colorStroke
|
||||
this.ctx.globalAlpha = this.cssVars.alphaStroke
|
||||
|
||||
for (var pip of this.rangeKeys.concat(this.valueToPercent(this.originValue))) {
|
||||
|
||||
|
|
@ -257,7 +259,8 @@ module.exports = class Knob extends Slider {
|
|||
}
|
||||
|
||||
var radius = maxRadius + this.fontSize * 1.5
|
||||
this.ctx.fillStyle = this.colors.textFade
|
||||
this.ctx.fillStyle = this.cssVars.colorText
|
||||
this.ctx.globalAlpha = this.cssVars.alphaPips
|
||||
for (var p in this.pipTexts) {
|
||||
if (this.pipTexts[p] == undefined) continue
|
||||
var angle = this.percentToAngle(p),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue