From ff5059465574d87ded56b5615cefb5c6dd888cd8 Mon Sep 17 00:00:00 2001 From: bordun Date: Tue, 26 Nov 2019 21:33:47 +0100 Subject: [PATCH] fader: allow adjusting gauge width --- CHANGELOG.md | 1 + src/client/app/widgets/sliders/fader.js | 12 ++++++++---- src/scss/widgets/fader.scss | 1 + 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a76f3504..d8e42742 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ - launcher: limit terminal history size to prevent slowdown/freeze - widgets - knob: text pips support + - fader: add css variable `--gauge-width` ## 0.48.3 diff --git a/src/client/app/widgets/sliders/fader.js b/src/client/app/widgets/sliders/fader.js index fbed1640..950f08f8 100644 --- a/src/client/app/widgets/sliders/fader.js +++ b/src/client/app/widgets/sliders/fader.js @@ -54,7 +54,8 @@ module.exports = class Fader extends Slider { '- `--color-gauge: color;`', '- `--color-knob: color;`', '- `--color-pips: color;`', - '- `--gauge-opacity: number;`' + '- `--gauge-opacity: number;`', + '- `--gauge-width: number;` (2-16, require a manual resize to take effect)' ]} }) @@ -66,6 +67,7 @@ module.exports = class Fader extends Slider { this.widget.classList.add('fader') this.margin = 22 + this.gaugeWidth = 2 if (this.getProp('horizontal')) { @@ -187,6 +189,8 @@ module.exports = class Fader extends Slider { super.resizeHandle(event) + this.gaugeWidth = Math.max(2, Math.min(16, parseInt(event.style.getPropertyValue('--gauge-width')) || 2)) + if (this.getProp('horizontal')){ this.ctx.setTransform(1, 0, 0, 1, 0, 0) this.ctx.rotate(-Math.PI/2) @@ -273,7 +277,7 @@ module.exports = class Fader extends Slider { } else { - this.ctx.lineWidth = 6 * PXSCALE + this.ctx.lineWidth = (this.gaugeWidth + 4) * PXSCALE this.ctx.beginPath() this.ctx.globalAlpha = 1 @@ -282,7 +286,7 @@ module.exports = class Fader extends Slider { this.ctx.lineTo(m, height - this.margin * PXSCALE + 2 * PXSCALE) this.ctx.stroke() - this.ctx.lineWidth = 4 * PXSCALE + this.ctx.lineWidth = (this.gaugeWidth + 2) * PXSCALE this.ctx.beginPath() this.ctx.globalAlpha = 1 @@ -291,7 +295,7 @@ module.exports = class Fader extends Slider { this.ctx.lineTo(m, height - this.margin * PXSCALE + 1 * PXSCALE) this.ctx.stroke() - this.ctx.lineWidth = 2 * PXSCALE + this.ctx.lineWidth = this.gaugeWidth * PXSCALE this.ctx.beginPath() this.ctx.strokeStyle = this.colors.track diff --git a/src/scss/widgets/fader.scss b/src/scss/widgets/fader.scss index 648cee64..09c43e04 100644 --- a/src/scss/widgets/fader.scss +++ b/src/scss/widgets/fader.scss @@ -2,6 +2,7 @@ --color-pips: var(--color-custom); --color-gauge: var(--color-custom); --color-knob: var(--color-custom); + --gauge-width: 2; padding: 1rem; width:100rem; height:300rem;