be4 copy paste any widget
This commit is contained in:
parent
9744fe422b
commit
8edcb8d044
32 changed files with 412 additions and 356 deletions
|
|
@ -17,7 +17,8 @@ class Switch extends Widget {
|
|||
|
||||
_switch:'switch',
|
||||
|
||||
horizontal: {type: 'boolean', value: false, help: 'Set to `true` to display values horizontally'},
|
||||
layout: {type: 'string', value: 'vertical', choices: ['vertical', 'horizontal', 'grid'], help:''},
|
||||
gridTemplate: {type: 'string|number', value: '', help:'If `layout` is `grid`, can be either a number of columns of a value css grid-template definition.'},
|
||||
showValues: {type: 'boolean', value: false, help: 'If values is an object, set to `true` to display both values and labels instead of labels only'},
|
||||
values: {type: 'array|object', value: {'Value 1':1,'Value 2':2}, help: [
|
||||
'`Array` of possible values to switch between : `[1,2,3]`',
|
||||
|
|
@ -39,7 +40,13 @@ class Switch extends Widget {
|
|||
|
||||
super({...options, html: html`<inner></inner>`})
|
||||
|
||||
if (this.getProp('horizontal')) this.container.classList.add('horizontal')
|
||||
this.container.classList.add('layout-' + this.getProp('layout'))
|
||||
|
||||
if (this.getProp('layout') === 'grid') {
|
||||
var template = this.getProp('gridTemplate') || 2
|
||||
this.widget.style.gridTemplate = template === parseInt(template) ? `none / repeat(${template}, 1fr)` : template
|
||||
}
|
||||
|
||||
|
||||
this.values = []
|
||||
this.stringValues = []
|
||||
|
|
|
|||
|
|
@ -68,6 +68,7 @@ class Widget extends EventEmitter {
|
|||
]},
|
||||
width: {type: 'number|percentage', value: 'auto', help: ''},
|
||||
height: {type: 'number|percentage', value: 'auto', help: ''},
|
||||
expand: {type: 'boolean|number', value: 'false', help: 'If parent\'s layout is `vertical` or `horizontal`, set this to `true` to stretch the widget to use available space automatically.'},
|
||||
|
||||
_style:'style',
|
||||
|
||||
|
|
@ -756,6 +757,7 @@ class Widget extends EventEmitter {
|
|||
|
||||
case 'height':
|
||||
case 'width':
|
||||
case 'expand':
|
||||
this.setContainerStyles(['geometry'])
|
||||
var container = this.parent !== widgetManager && this.parent.getProp('layout') !== 'default' ? this.parent.container : this.container
|
||||
resize.check(container)
|
||||
|
|
@ -851,6 +853,7 @@ class Widget extends EventEmitter {
|
|||
}
|
||||
}
|
||||
this.container.classList.toggle('absolute-position', absolutePos)
|
||||
this.container.classList.toggle('flex-expand', this.getProp('expand'))
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -859,13 +862,13 @@ class Widget extends EventEmitter {
|
|||
|
||||
// label
|
||||
if (this.getProp('label') === false) {
|
||||
this.container.classList.add('nolabel')
|
||||
this.container.classList.add('no-label')
|
||||
this.label.innerHTML = ''
|
||||
} else {
|
||||
this.container.classList.remove('nolabel')
|
||||
this.container.classList.remove('no-label')
|
||||
var label = this.getProp('label') == 'auto'?
|
||||
this.getProp('id'):
|
||||
iconify(this.getProp('label'))
|
||||
iconify(this.getProp('label').replace(/</g, '<'))
|
||||
|
||||
this.label.innerHTML = label
|
||||
this.container.appendChild(this.label)
|
||||
|
|
@ -1037,6 +1040,7 @@ Widget.dynamicProps = [
|
|||
'left',
|
||||
'height',
|
||||
'width',
|
||||
'expand',
|
||||
|
||||
|
||||
'colorText',
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ var Container = require('../common/container'),
|
|||
{diff, diffToWidget} = require('../../editor/diff'),
|
||||
html = require('nanohtml')
|
||||
|
||||
var excludedCloneClasses = ['widget', 'absolute-position', 'not-editable', 'editing']
|
||||
var excludedCloneClasses = ['widget', 'absolute-position', 'not-editable', 'editing', 'flex-expand']
|
||||
|
||||
class Clone extends Container() {
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,9 @@ class Panel extends Container() {
|
|||
|
||||
colorPanel: {type: 'string', value: 'auto', help:''},
|
||||
layout: {type: 'string', value: 'default', choices: ['default', 'vertical', 'horizontal', 'grid'], help:''},
|
||||
justify: {type: 'string', value: 'start', choices: ['start', 'end', 'center', 'space-around', 'space-between'], help:'If `layout` is `vertical` or `horizontal`, defines how widgets should be justified.'},
|
||||
gridTemplate: {type: 'string|number', value: '', help:'If `layout` is `grid`, can be either a number of columns of a value css grid-template definition.'},
|
||||
verticalTabs: {type: 'boolean', value: false, help: 'Set to `true` to display for vertical tab layout'},
|
||||
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'},
|
||||
scroll: {type: 'boolean', value: true, help: 'Set to `false` to disable scrollbars'},
|
||||
variables: {type: '*', value: '@{parent.variables}', help: 'Defines one or more arbitrary variables that can be inherited by children widgets'},
|
||||
|
|
@ -50,14 +52,24 @@ class Panel extends Container() {
|
|||
this.container.classList.toggle('no-scroll', !this.getProp('scroll'))
|
||||
this.container.classList.add('layout-' + this.getProp('layout'))
|
||||
|
||||
if (this.getProp('layout') === 'grid') {
|
||||
var layout = this.getProp('layout')
|
||||
if (layout === 'grid') {
|
||||
|
||||
var template = this.getProp('gridTemplate') || 2
|
||||
this.widget.style.gridTemplate = template === parseInt(template) ? `none / repeat(${template}, 1fr)` : template
|
||||
|
||||
} else if (layout === 'vertical' || layout === 'horizontal'){
|
||||
|
||||
var justify = this.getProp('justify')
|
||||
if (justify === 'start' || justify === 'end') justify = 'flex-' + justify
|
||||
this.widget.style.justifyContent = justify
|
||||
|
||||
}
|
||||
|
||||
if (this.getProp('tabs') && this.getProp('tabs').length) {
|
||||
|
||||
this.container.classList.add('contains-tabs')
|
||||
this.container.classList.toggle('vertical-tabs', this.getProp('verticalTabs'))
|
||||
|
||||
} else {
|
||||
|
||||
|
|
@ -74,7 +86,7 @@ class Panel extends Container() {
|
|||
|
||||
this.value = -1
|
||||
|
||||
this.navigation = this.widget.appendChild(html`<div class="navigation"></div>`)
|
||||
this.navigation = this.widget.appendChild(html`<div class="navigation ${this.getProp('verticalTabs') ? 'vertical' : ''}"></div>`)
|
||||
|
||||
this.children = options.children || new Array(this.getProp('tabs').length)
|
||||
for (let i = 0; i < this.children.length; i++) {
|
||||
|
|
@ -156,11 +168,12 @@ class Panel extends Container() {
|
|||
if (!widget.getProp('visible')) style += 'display:none;'
|
||||
|
||||
this.tabs.push(widget)
|
||||
this.navigation.appendChild(html`
|
||||
var label = html`
|
||||
<div class="tablink" data-widget="${widget.hash}" style="${style}">
|
||||
${raw(widget.label.innerHTML)}
|
||||
</div>
|
||||
`)
|
||||
`
|
||||
label.innerHTML = widget.label.innerHTML
|
||||
this.navigation.appendChild(label)
|
||||
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,9 @@ class Root extends StaticProperties(Panel, {scroll: false, label: false, id: 'ro
|
|||
|
||||
colorPanel: {type: 'string', value: 'auto', help:''},
|
||||
layout: {type: 'string', value: 'default', choices: ['default', 'vertical', 'horizontal', 'grid'], help:''},
|
||||
justify: {type: 'string', value: 'start', choices: ['start', 'end', 'center', 'space-around', 'space-between'], help:'If `layout` is `vertical` or `horizontal`, defines how widgets should be justified.'},
|
||||
gridTemplate: {type: 'string|number', value: '', help:'If `layout` is `grid`, can be either a number of columns of a value css grid-template definition.'},
|
||||
verticalTabs: {type: 'boolean', value: false, help: 'Set to `true` to display for vertical tab layout'},
|
||||
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: '', help: 'Defines one or more arbitrary variables that can be inherited by children widgets'},
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,9 @@ module.exports = class Tab extends Panel {
|
|||
|
||||
// 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', 'grid'], help:''},
|
||||
justify: {type: 'string', value: 'start', choices: ['start', 'end', 'center', 'space-around', 'space-between'], help:'If `layout` is `vertical` or `horizontal`, defines how widgets should be justified.'},
|
||||
gridTemplate: {type: 'string|number', value: '', help:'If `layout` is `grid`, can be either a number of columns of a value css grid-template definition.'},
|
||||
verticalTabs: {type: 'boolean', value: false, help: 'Set to `true` to display for vertical tab layout'},
|
||||
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'},
|
||||
scroll: {type: 'boolean', value: true, help: 'Set to `false` to disable scrollbars'},
|
||||
variables: {type: '*', value: '@{parent.variables}', help: 'Defines one or more arbitrary variables that can be inherited by children widgets'},
|
||||
|
|
|
|||
|
|
@ -17,9 +17,8 @@ module.exports = class Fader extends Slider {
|
|||
|
||||
_fader:'fader',
|
||||
|
||||
mode: {type: 'string', value: 'compact', choices: ['compact', 'classic', 'round'], help: 'Design style'},
|
||||
design: {type: 'string', value: 'compact', choices: ['compact', 'classic', 'round'], help: 'Design style'},
|
||||
horizontal: {type: 'boolean', value: false, help: 'Set to `true` to display the fader horizontally'},
|
||||
alignRight: {type: 'boolean', value: false, help: 'Set to `true` to invert the pip\'s and fader\'s position'},
|
||||
pips: {type: 'boolean', value: false, help: 'Set to `true` to show range breakpoints'},
|
||||
dashed: {type: 'boolean', value: false, help: 'Set to `true` to display a dashed gauge'},
|
||||
gradient: {type: 'array|object', value: [], help: [
|
||||
|
|
@ -65,8 +64,6 @@ module.exports = class Fader extends Slider {
|
|||
|
||||
this.gaugeGradient = null
|
||||
|
||||
this.container.classList.add('design-' + this.getProp('mode'))
|
||||
|
||||
}
|
||||
|
||||
draginitHandle(e) {
|
||||
|
|
@ -180,7 +177,7 @@ module.exports = class Fader extends Slider {
|
|||
o = Math.round(this.percentToCoord(this.valueToPercent(this.originValue))),
|
||||
m = this.getProp('horizontal') ? this.height / 2 : this.width / 2,
|
||||
dashed = this.getProp('dashed'),
|
||||
compact = this.getProp('mode') === 'compact'
|
||||
compact = this.getProp('design') === 'compact'
|
||||
|
||||
this.clear()
|
||||
|
||||
|
|
@ -256,7 +253,7 @@ module.exports = class Fader extends Slider {
|
|||
this.clearRect = [0, 0, width, height]
|
||||
|
||||
|
||||
} else if (this.getProp('mode') === 'classic') {
|
||||
} else if (this.getProp('design') === 'classic') {
|
||||
|
||||
|
||||
if (this.cssVars.alphaStroke) {
|
||||
|
|
@ -342,7 +339,7 @@ module.exports = class Fader extends Slider {
|
|||
var width = this.getProp('horizontal') ? this.height : this.width,
|
||||
height = !this.getProp('horizontal') ? this.height : this.width,
|
||||
m = this.getProp('horizontal') ? this.height / 2 : this.width / 2,
|
||||
compact = this.getProp('mode') === 'compact'
|
||||
compact = this.getProp('design') === 'compact'
|
||||
|
||||
if (width % 2 && parseInt(m) !== m) m -= 0.5
|
||||
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ module.exports = class Knob extends Slider {
|
|||
|
||||
_knob:'knob',
|
||||
|
||||
design: {type: 'string', value: 'default', choices: ['default', 'classic'], help: 'Design style'},
|
||||
mode: {type: 'string', value: 'vertical', choices: ['vertical', 'circular', 'snap'], help: [
|
||||
'- `circular`: relative move in circular motion',
|
||||
'- `snap`: snap to touch position and move in vertical motion',
|
||||
|
|
@ -181,58 +182,118 @@ module.exports = class Knob extends Slider {
|
|||
|
||||
this.clear()
|
||||
|
||||
// fill
|
||||
this.ctx.strokeStyle = this.cssVars.colorFill
|
||||
this.ctx.lineWidth = gaugeWidth - this.gaugePadding * 2
|
||||
if (this.getProp('design') === 'default') {
|
||||
|
||||
// fill
|
||||
this.ctx.strokeStyle = this.cssVars.colorFill
|
||||
this.ctx.lineWidth = gaugeWidth - this.gaugePadding * 2
|
||||
|
||||
if (this.cssVars.alphaFillOff) {
|
||||
this.ctx.globalAlpha = this.cssVars.alphaFillOff
|
||||
this.ctx.beginPath()
|
||||
this.ctx.arc(this.width / 2, this.height / 2, gaugeRadius, min, max)
|
||||
this.ctx.stroke()
|
||||
}
|
||||
|
||||
if (dashed) this.ctx.setLineDash([1.5 * PXSCALE, 1.5 * PXSCALE])
|
||||
|
||||
if (this.cssVars.alphaFillOn) {
|
||||
this.ctx.globalAlpha = this.cssVars.alphaFillOn
|
||||
this.ctx.beginPath()
|
||||
this.ctx.arc(this.width / 2, this.height / 2, gaugeRadius, o, d, o > d)
|
||||
this.ctx.stroke()
|
||||
}
|
||||
|
||||
if (dashed) this.ctx.setLineDash([])
|
||||
|
||||
|
||||
// stroke
|
||||
|
||||
this.ctx.globalAlpha = this.cssVars.alphaStroke
|
||||
this.ctx.strokeStyle = this.cssVars.colorStroke
|
||||
this.ctx.lineWidth = PXSCALE
|
||||
|
||||
if (this.cssVars.alphaFillOff) {
|
||||
this.ctx.globalAlpha = this.cssVars.alphaFillOff
|
||||
this.ctx.beginPath()
|
||||
this.ctx.arc(this.width / 2, this.height / 2, gaugeRadius, min, max)
|
||||
this.ctx.arc(this.width / 2, this.height / 2, minRadius, 0, 2 * Math.PI)
|
||||
this.ctx.stroke()
|
||||
|
||||
this.ctx.beginPath()
|
||||
this.ctx.arc(this.width / 2, this.height / 2, maxRadius, 0, 2 * Math.PI)
|
||||
this.ctx.stroke()
|
||||
|
||||
|
||||
// knob
|
||||
|
||||
this.ctx.globalAlpha = 1
|
||||
this.ctx.strokeStyle = this.cssVars.colorFill
|
||||
this.ctx.lineWidth = 1.5 * PXSCALE
|
||||
|
||||
let r1 = minRadius + this.gaugePadding,
|
||||
r2 = maxRadius - this.gaugePadding,
|
||||
a = 2 * Math.PI - d
|
||||
|
||||
this.ctx.beginPath()
|
||||
this.ctx.moveTo(r1 * Math.cos(a) + this.width / 2, this.height / 2 - r1 * Math.sin(a))
|
||||
this.ctx.lineTo(r2 * Math.cos(a) + this.width / 2, this.height / 2 - r2 * Math.sin(a))
|
||||
this.ctx.stroke()
|
||||
|
||||
} else {
|
||||
|
||||
// fill
|
||||
this.ctx.strokeStyle = this.cssVars.colorFill
|
||||
this.ctx.lineWidth = 2 * PXSCALE
|
||||
|
||||
if (this.cssVars.alphaFillOff) {
|
||||
this.ctx.globalAlpha = this.cssVars.alphaFillOff
|
||||
this.ctx.beginPath()
|
||||
this.ctx.arc(this.width / 2, this.height / 2, maxRadius, min, max)
|
||||
this.ctx.stroke()
|
||||
}
|
||||
|
||||
if (dashed) this.ctx.setLineDash([1.5 * PXSCALE, 1.5 * PXSCALE])
|
||||
|
||||
if (this.cssVars.alphaFillOn) {
|
||||
this.ctx.globalAlpha = this.cssVars.alphaFillOn
|
||||
this.ctx.beginPath()
|
||||
this.ctx.arc(this.width / 2, this.height / 2, maxRadius, o, d, o > d)
|
||||
this.ctx.stroke()
|
||||
}
|
||||
|
||||
if (dashed) this.ctx.setLineDash([])
|
||||
|
||||
|
||||
|
||||
// center
|
||||
this.ctx.fillStyle = this.cssVars.colorPanel
|
||||
this.ctx.strokeStyle = this.cssVars.colorStroke
|
||||
this.ctx.lineWidth = 1 * PXSCALE
|
||||
|
||||
this.ctx.beginPath()
|
||||
this.ctx.arc(this.width / 2, this.height / 2, maxRadius - (2 + this.cssVars.padding) * PXSCALE, 0, 2 * Math.PI)
|
||||
this.ctx.globalAlpha = this.cssVars.alphaStroke
|
||||
this.ctx.stroke()
|
||||
this.ctx.globalAlpha = 1
|
||||
// this.ctx.fill()
|
||||
|
||||
|
||||
|
||||
// knob
|
||||
this.ctx.globalAlpha = 1
|
||||
this.ctx.fillStyle = this.cssVars.colorFill
|
||||
this.ctx.lineWidth = 1.5 * PXSCALE
|
||||
|
||||
let r1 = maxRadius - (8 + this.cssVars.padding) * PXSCALE,
|
||||
r2 = maxRadius / 3 ,
|
||||
a = 2 * Math.PI - d
|
||||
|
||||
this.ctx.beginPath()
|
||||
this.ctx.arc(r1 * Math.cos(a) + this.width / 2, this.height / 2 - r1 * Math.sin(a), 1.5 * PXSCALE, 0, 2*Math.PI)
|
||||
this.ctx.fill()
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (dashed) this.ctx.setLineDash([1.5 * PXSCALE, 1.5 * PXSCALE])
|
||||
|
||||
if (this.cssVars.alphaFillOn) {
|
||||
this.ctx.globalAlpha = this.cssVars.alphaFillOn
|
||||
this.ctx.beginPath()
|
||||
this.ctx.arc(this.width / 2, this.height / 2, gaugeRadius, o, d, o > d)
|
||||
this.ctx.stroke()
|
||||
}
|
||||
|
||||
if (dashed) this.ctx.setLineDash([])
|
||||
|
||||
|
||||
// stroke
|
||||
|
||||
this.ctx.globalAlpha = this.cssVars.alphaStroke
|
||||
this.ctx.strokeStyle = this.cssVars.colorStroke
|
||||
this.ctx.lineWidth = PXSCALE
|
||||
|
||||
this.ctx.beginPath()
|
||||
this.ctx.arc(this.width / 2, this.height / 2, minRadius, 0, 2 * Math.PI)
|
||||
this.ctx.stroke()
|
||||
|
||||
this.ctx.beginPath()
|
||||
this.ctx.arc(this.width / 2, this.height / 2, maxRadius, 0, 2 * Math.PI)
|
||||
this.ctx.stroke()
|
||||
|
||||
|
||||
// knob
|
||||
|
||||
this.ctx.globalAlpha = 1
|
||||
this.ctx.strokeStyle = this.cssVars.colorFill
|
||||
this.ctx.lineWidth = 1.5 * PXSCALE
|
||||
|
||||
let r1 = minRadius + this.gaugePadding,
|
||||
r2 = maxRadius - this.gaugePadding,
|
||||
a = 2 * Math.PI - d
|
||||
|
||||
this.ctx.beginPath()
|
||||
this.ctx.moveTo(r1 * Math.cos(a) + this.width / 2, this.height / 2 - r1 * Math.sin(a))
|
||||
this.ctx.lineTo(r2 * Math.cos(a) + this.width / 2, this.height / 2 - r2 * Math.sin(a))
|
||||
this.ctx.stroke()
|
||||
|
||||
// pips
|
||||
|
||||
|
|
|
|||
|
|
@ -3,12 +3,11 @@ var {clip} = require('../utils'),
|
|||
Fader = require('./fader'),
|
||||
Input = require('../inputs/input'),
|
||||
touchstate = require('../mixins/touch_state'),
|
||||
html = require('nanohtml'),
|
||||
StaticProperties = require('../mixins/static_properties')
|
||||
html = require('nanohtml')
|
||||
|
||||
var faderDefaults = Fader.defaults()._props()
|
||||
|
||||
class Range extends StaticProperties(Fader, {mode: 'compact'}) {
|
||||
class Range extends Fader {
|
||||
|
||||
static description() {
|
||||
|
||||
|
|
@ -16,15 +15,6 @@ class Range extends StaticProperties(Fader, {mode: 'compact'}) {
|
|||
|
||||
}
|
||||
|
||||
static defaults() {
|
||||
|
||||
var defaults = super.defaults()
|
||||
delete defaults.mode
|
||||
|
||||
return defaults
|
||||
|
||||
}
|
||||
|
||||
constructor(options) {
|
||||
|
||||
options.multitouch = true
|
||||
|
|
@ -209,19 +199,36 @@ class Range extends StaticProperties(Fader, {mode: 'compact'}) {
|
|||
|
||||
var d = Math.round(fader.percentToCoord(fader.valueToPercent(this.faders[this.getProp('horizontal')?0:1].value))),
|
||||
d2 = Math.round(fader.percentToCoord(fader.valueToPercent(this.faders[this.getProp('horizontal')?1:0].value))),
|
||||
m = Math.round(this.getProp('horizontal') ? this.height / 2 : this.width / 2)
|
||||
|
||||
// sharp border trick
|
||||
if (width % 2 && parseInt(m) === m) m -= 0.5
|
||||
|
||||
var dashed = this.getProp('dashed')
|
||||
m = this.getProp('horizontal') ? this.height / 2 : this.width / 2,
|
||||
dashed = this.getProp('dashed'),
|
||||
compact = this.getProp('design') === 'compact'
|
||||
|
||||
this.clear()
|
||||
|
||||
if (this.getProp('pips') && !compact) m -= 10 * PXSCALE
|
||||
|
||||
// sharp border trick
|
||||
if (compact) {
|
||||
if (width % 2 && parseInt(m) === m) m -= 0.5
|
||||
} else {
|
||||
if (width % 2 && parseInt(m) !== m) m -= 0.5
|
||||
}
|
||||
|
||||
|
||||
this.ctx.strokeStyle = this.gaugeGradient || this.cssVars.colorFill
|
||||
this.ctx.lineWidth = Math.round(width - this.gaugePadding * 2)
|
||||
|
||||
if (compact) {
|
||||
this.ctx.lineWidth = Math.round(width - this.gaugePadding * 2)
|
||||
} else {
|
||||
this.ctx.lineWidth = 2 * PXSCALE
|
||||
}
|
||||
|
||||
|
||||
if (dashed) this.ctx.setLineDash([PXSCALE, PXSCALE])
|
||||
|
||||
|
||||
if (this.cssVars.alphaFillOff) {
|
||||
// gaugo off
|
||||
this.ctx.globalAlpha = this.cssVars.alphaFillOff
|
||||
this.ctx.beginPath()
|
||||
this.ctx.moveTo(m, height - this.gaugePadding)
|
||||
|
|
@ -229,12 +236,9 @@ class Range extends StaticProperties(Fader, {mode: 'compact'}) {
|
|||
this.ctx.stroke()
|
||||
}
|
||||
|
||||
if (dashed) {
|
||||
this.ctx.lineDashOffset = d % 2 ? PXSCALE : 0 // avoid flickering
|
||||
this.ctx.setLineDash([PXSCALE, PXSCALE])
|
||||
}
|
||||
|
||||
if (this.cssVars.alphaFillOn) {
|
||||
// gaugo on
|
||||
this.ctx.globalAlpha = this.cssVars.alphaFillOn
|
||||
this.ctx.beginPath()
|
||||
this.ctx.moveTo(m, d)
|
||||
|
|
@ -244,31 +248,114 @@ class Range extends StaticProperties(Fader, {mode: 'compact'}) {
|
|||
|
||||
if (dashed) this.ctx.setLineDash([])
|
||||
|
||||
this.ctx.globalAlpha = this.cssVars.alphaStroke
|
||||
this.ctx.strokeStyle = this.cssVars.colorStroke
|
||||
if (compact) {
|
||||
|
||||
this.ctx.beginPath()
|
||||
this.ctx.moveTo(0, 0)
|
||||
this.ctx.lineTo(width, 0)
|
||||
this.ctx.lineTo(width, height)
|
||||
this.ctx.lineTo(0, height)
|
||||
this.ctx.closePath()
|
||||
this.ctx.lineWidth = 2 * PXSCALE
|
||||
this.ctx.stroke()
|
||||
// stroke
|
||||
|
||||
this.ctx.globalAlpha = this.cssVars.alphaStroke
|
||||
this.ctx.strokeStyle = this.cssVars.colorStroke
|
||||
|
||||
this.ctx.beginPath()
|
||||
this.ctx.moveTo(0, 0)
|
||||
this.ctx.lineTo(width, 0)
|
||||
this.ctx.lineTo(width, height)
|
||||
this.ctx.lineTo(0, height)
|
||||
this.ctx.closePath()
|
||||
this.ctx.lineWidth = 2 * PXSCALE
|
||||
this.ctx.stroke()
|
||||
|
||||
|
||||
this.ctx.globalAlpha = 1
|
||||
this.ctx.fillStyle = this.cssVars.colorFill
|
||||
// flat knob
|
||||
|
||||
this.ctx.beginPath()
|
||||
this.ctx.rect(this.gaugePadding, Math.min(d, height - 3 * PXSCALE), width - this.gaugePadding * 2, PXSCALE)
|
||||
this.ctx.fill()
|
||||
this.ctx.globalAlpha = 1
|
||||
this.ctx.fillStyle = this.cssVars.colorFill
|
||||
|
||||
this.ctx.beginPath()
|
||||
this.ctx.rect(this.gaugePadding, Math.min(d2, height - 3 * PXSCALE), width - this.gaugePadding * 2, PXSCALE)
|
||||
this.ctx.fill()
|
||||
this.ctx.beginPath()
|
||||
this.ctx.rect(this.gaugePadding, Math.min(d, height - this.gaugePadding - PXSCALE), width - this.gaugePadding * 2, PXSCALE)
|
||||
this.ctx.fill()
|
||||
|
||||
// extra knob
|
||||
this.ctx.beginPath()
|
||||
this.ctx.rect(this.gaugePadding, Math.min(d2, height - this.gaugePadding - PXSCALE), width - this.gaugePadding * 2, PXSCALE)
|
||||
this.ctx.fill()
|
||||
|
||||
|
||||
this.clearRect = [0, 0, width, height]
|
||||
|
||||
|
||||
} else if (this.getProp('design') === 'classic') {
|
||||
|
||||
for (let _d of [d, d2]) {
|
||||
|
||||
if (this.cssVars.alphaStroke) {
|
||||
|
||||
this.ctx.globalAlpha = 1
|
||||
this.ctx.fillStyle = this.cssVars.colorPanel
|
||||
|
||||
this.ctx.beginPath()
|
||||
this.ctx.rect(m - 6 * PXSCALE, _d - 10 * PXSCALE, 12 * PXSCALE, 20 * PXSCALE)
|
||||
this.ctx.fill()
|
||||
|
||||
this.ctx.globalAlpha = this.cssVars.alphaStroke
|
||||
this.ctx.strokeStyle = this.cssVars.colorStroke
|
||||
this.ctx.lineWidth = PXSCALE
|
||||
|
||||
this.ctx.beginPath()
|
||||
this.ctx.rect(m - 5.5 * PXSCALE, _d - 9.5 * PXSCALE, 11 * PXSCALE, 19 * PXSCALE)
|
||||
this.ctx.stroke()
|
||||
|
||||
}
|
||||
|
||||
this.ctx.globalAlpha = 1
|
||||
this.ctx.fillStyle = this.cssVars.colorWidget
|
||||
|
||||
this.ctx.beginPath()
|
||||
this.ctx.rect(m - 3 * PXSCALE, _d, 6 * PXSCALE, PXSCALE)
|
||||
this.ctx.fill()
|
||||
|
||||
}
|
||||
|
||||
this.clearRect = [m - 10 * PXSCALE, this.gaugePadding - 10 * PXSCALE, 20 * PXSCALE, height - 2 * this.gaugePadding + 20 * PXSCALE]
|
||||
|
||||
} else {
|
||||
|
||||
this.ctx.globalAlpha = 1
|
||||
this.ctx.fillStyle = this.cssVars.colorFill
|
||||
|
||||
this.ctx.beginPath()
|
||||
this.ctx.arc(m, d, 3 * PXSCALE, 0, 2 * Math.PI)
|
||||
this.ctx.fill()
|
||||
|
||||
// extra knob
|
||||
this.ctx.beginPath()
|
||||
this.ctx.arc(m, d2, 3 * PXSCALE, 0, 2 * Math.PI)
|
||||
this.ctx.fill()
|
||||
|
||||
|
||||
if (this.cssVars.alphaStroke) {
|
||||
this.ctx.globalAlpha = this.cssVars.alphaStroke
|
||||
this.ctx.fillStyle = this.cssVars.colorFill
|
||||
|
||||
this.ctx.beginPath()
|
||||
this.ctx.arc(m, d, 10 * PXSCALE, 0, 2 * Math.PI)
|
||||
this.ctx.fill()
|
||||
|
||||
// extra knob
|
||||
this.ctx.beginPath()
|
||||
this.ctx.arc(m, d2, 10 * PXSCALE, 0, 2 * Math.PI)
|
||||
this.ctx.fill()
|
||||
}
|
||||
|
||||
this.clearRect = [m - 11 * PXSCALE, this.gaugePadding - 11 * PXSCALE, 22 * PXSCALE, height - 2 * this.gaugePadding + 22 * PXSCALE]
|
||||
|
||||
}
|
||||
|
||||
if (this.getProp('pips')) {
|
||||
this.ctx.globalAlpha = 1
|
||||
this.ctx.drawImage(this.pips, 0, 0);
|
||||
if (!compact) this.clearRect = [this.clearRect, [m + 10 * PXSCALE, 0, 10 * PXSCALE + this.pipsTextSize, height]]
|
||||
}
|
||||
|
||||
this.clearRect = [0, 0, width, height]
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@ class Slider extends Canvas {
|
|||
<canvas></canvas>
|
||||
`})
|
||||
|
||||
this.container.classList.add('design-' + this.getProp('design'))
|
||||
|
||||
this.value = undefined
|
||||
this.percent = 0
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue