From 37bf03a336479cf3857cea8101c70cc991868571 Mon Sep 17 00:00:00 2001 From: bordun Date: Thu, 27 Feb 2020 16:47:01 +0100 Subject: [PATCH] fader modes, rgb fix --- src/client/widgets/common/widget.js | 3 +- src/client/widgets/containers/matrix.js | 1 - src/client/widgets/sliders/fader.js | 58 ++++++++++++++++++++----- src/scss/widgets/pads.scss | 2 +- src/scss/widgets/sliders.scss | 9 +++- 5 files changed, 58 insertions(+), 15 deletions(-) diff --git a/src/client/widgets/common/widget.js b/src/client/widgets/common/widget.js index 1d8d44af..b9eef7a8 100644 --- a/src/client/widgets/common/widget.js +++ b/src/client/widgets/common/widget.js @@ -1018,7 +1018,8 @@ Widget.cssVariables = [ {js: 'padding', css: '--widget-padding', toCss: x=>parseFloat(x) + 'rem', toJs: x=>parseFloat(x) * PXSCALE}, {js: 'alphaFillOn', css: '--alpha-fill-on', toCss: x=>parseFloat(x), toJs: x=>parseFloat(x)}, {js: 'alphaFillOff', css: '--alpha-fill-off', toCss: x=>parseFloat(x), toJs: x=>parseFloat(x)}, - {js: 'alphaStroke', css: '--alpha-stroke', toCss: x=>parseFloat(x), toJs: x=>parseFloat(x)} + {js: 'alphaStroke', css: '--alpha-stroke', toCss: x=>parseFloat(x), toJs: x=>parseFloat(x)}, + {js: 'colorForegroud', css: '--color-foreground'} ] Widget.dynamicProps = [ diff --git a/src/client/widgets/containers/matrix.js b/src/client/widgets/containers/matrix.js index 40aa9fda..6dcb8e08 100644 --- a/src/client/widgets/containers/matrix.js +++ b/src/client/widgets/containers/matrix.js @@ -28,7 +28,6 @@ class Matrix extends StaticProperties(Panel, {scroll: false}) { quantity: {type: 'number', value: 4, help: 'Defines the number of widgets in the matrix'}, start: {type: 'integer', value: 0, help: 'First widget\'s index'}, traversing: {type: 'boolean', value: true, help: 'Set to `false` to disable traversing gestures'}, - restrainModals: {type: 'boolean', value: true, help: 'Set to `false` to let modal widgets ignore this container\'s boundaries.'}, props: {type: 'object', value: {}, help: [ 'Defines a set of property to override the widgets\' defaults.', 'Formulas in this field are resolved with an extra variable representing each widget\'s index: `$`', diff --git a/src/client/widgets/sliders/fader.js b/src/client/widgets/sliders/fader.js index 40c7868e..b58533cf 100644 --- a/src/client/widgets/sliders/fader.js +++ b/src/client/widgets/sliders/fader.js @@ -17,7 +17,7 @@ module.exports = class Fader extends Slider { _fader:'fader', - mode: {type: 'string', value: 'flat', choices: ['flat', 'line'], help: 'Design style'}, + mode: {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: true, help: 'Set to `false` to hide the scale'}, @@ -65,7 +65,7 @@ module.exports = class Fader extends Slider { this.gaugeGradient = null - this.container.classList.toggle('alt', this.getProp('mode') !== 'flat') + this.container.classList.add('design-' + this.getProp('mode')) if (false && this.getProp('pips')) { @@ -200,7 +200,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'), - flat = this.getProp('mode') === 'flat' + compact = this.getProp('mode') === 'compact' // sharp border trick if (width % 2 && parseInt(m) === m) m -= 0.5 @@ -211,7 +211,7 @@ module.exports = class Fader extends Slider { this.ctx.strokeStyle = this.gaugeGradient || this.cssVars.colorFill - if (flat) { + if (compact) { this.ctx.lineWidth = Math.round(width - this.gaugePadding * 2) } else { this.ctx.lineWidth = 2 * PXSCALE @@ -242,7 +242,7 @@ module.exports = class Fader extends Slider { if (dashed) this.ctx.setLineDash([]) - if (flat) { + if (compact) { // stroke @@ -265,12 +265,45 @@ module.exports = class Fader extends Slider { this.ctx.fillStyle = this.cssVars.colorFill this.ctx.beginPath() - this.ctx.rect(this.gaugePadding, Math.min(d, height - 3 * PXSCALE), width - this.gaugePadding * 2, PXSCALE) + this.ctx.rect(this.gaugePadding, Math.min(d, height - this.gaugePadding - PXSCALE), width - this.gaugePadding * 2, PXSCALE) this.ctx.fill() this.clearRect = [0, 0, width, height] + } else if (this.getProp('mode') === 'classic') { + + + if (this.cssVars.alphaStroke) { + + this.ctx.globalAlpha = 1 + this.ctx.fillStyle = this.cssVars.colorForegroud + + 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.beginPath() + this.ctx.lineWidth = PXSCALE + 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 @@ -280,12 +313,15 @@ module.exports = class Fader extends Slider { this.ctx.arc(m, d, 3 * PXSCALE, 0, 2 * Math.PI) this.ctx.fill() - this.ctx.globalAlpha = 0.25 - this.ctx.fillStyle = this.cssVars.colorFill - this.ctx.beginPath() - this.ctx.arc(m, d, 10 * 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() + } this.clearRect = [m - 10 * PXSCALE, this.gaugePadding - 10 * PXSCALE, 20 * PXSCALE, height - 2 * this.gaugePadding + 20 * PXSCALE] diff --git a/src/scss/widgets/pads.scss b/src/scss/widgets/pads.scss index 7fa4b253..75642e23 100644 --- a/src/scss/widgets/pads.scss +++ b/src/scss/widgets/pads.scss @@ -100,7 +100,7 @@ left: 2rem; right: 2rem; bottom: 0; - background: linear-gradient(to top, #F00, #FF0080, #F0F, #8000FF, #00F, #0080FF, #0FF, #00FF80, #0F0, #80FF00, #FF0, #FF8000, #F00) repeat scroll 0% 0%; + background: linear-gradient(to bottom, #F00, #FF0080, #F0F, #8000FF, #00F, #0080FF, #0FF, #00FF80, #0F0, #80FF00, #FF0, #FF8000, #F00) repeat scroll 0% 0%; opacity: 0.75; z-index: -1; } diff --git a/src/scss/widgets/sliders.scss b/src/scss/widgets/sliders.scss index c9eddb07..e9844359 100644 --- a/src/scss/widgets/sliders.scss +++ b/src/scss/widgets/sliders.scss @@ -20,11 +20,18 @@ --widget-padding: 1rem; - &.alt { + &.design-classic { --widget-padding: 10rem; + --alpha-stroke: 0.5; --alpha-fill-off: 0.25; --alpha-fill-on: 1; + } + &.design-round { + --widget-padding: 10rem; + --alpha-stroke: 0.25; + --alpha-fill-off: 0.25; + --alpha-fill-on: 1; } }