From 9f68640b833057c046f60eae7e81fcebb1e39906 Mon Sep 17 00:00:00 2001 From: bordun Date: Mon, 7 Sep 2020 09:40:02 +0200 Subject: [PATCH] widgets: rename strokeWidth -> lineWidth knob: use lineWidth in all designs --- src/client/widgets/common/canvas.js | 2 +- src/client/widgets/common/widget.js | 8 ++++---- src/client/widgets/containers/clone.js | 4 ++-- src/client/widgets/graphs/plot.js | 4 ++-- src/client/widgets/pads/multixy.js | 2 +- src/client/widgets/pads/pad.js | 2 +- src/client/widgets/sliders/encoder.js | 6 +++--- src/client/widgets/sliders/fader.js | 4 ++-- src/client/widgets/sliders/knob.js | 26 +++++++++++++------------- src/client/widgets/sliders/range.js | 2 +- src/client/widgets/sliders/slider.js | 2 +- src/scss/mixins.scss | 10 +++++----- src/scss/themes/default.scss | 2 +- src/scss/widgets.scss | 2 +- src/scss/widgets/basics.scss | 8 ++++---- src/scss/widgets/containers.scss | 26 +++++++++++++------------- src/scss/widgets/frames.scss | 2 +- src/scss/widgets/pads.scss | 4 ++-- src/scss/widgets/sliders.scss | 1 + 19 files changed, 59 insertions(+), 58 deletions(-) diff --git a/src/client/widgets/common/canvas.js b/src/client/widgets/common/canvas.js index cc316d05..6c7194f1 100644 --- a/src/client/widgets/common/canvas.js +++ b/src/client/widgets/common/canvas.js @@ -151,7 +151,7 @@ class Canvas extends Widget { },10) return case 'css': - case 'strokeWidth': + case 'lineWidth': case 'padding': resize.check(this.canvas, true) setTimeout(()=>{ diff --git a/src/client/widgets/common/widget.js b/src/client/widgets/common/widget.js index 0c236959..f260505b 100644 --- a/src/client/widgets/common/widget.js +++ b/src/client/widgets/common/widget.js @@ -80,7 +80,7 @@ class Widget extends EventEmitter { alphaFillOff: {type: 'number', value: 'auto', help: 'Fill color opacity (off).'}, alphaFillOn: {type: 'number', value: 'auto', help: 'Fill color opacity (on).'}, - strokeWidth: {type: 'number', value: 'auto', help: 'Stroke width.'}, + lineWidth: {type: 'number', value: 'auto', help: 'Stroke width.'}, padding: {type: 'number', value: 'auto', help: 'Inner spacing.'}, @@ -818,7 +818,7 @@ class Widget extends EventEmitter { case 'alphaStroke': case 'alphaFillOff': case 'alphaFillOn': - case 'strokeWidth': + case 'lineWidth': case 'padding': this.setCssVariables() return @@ -1040,7 +1040,7 @@ Widget.cssVariables = [ {js: 'colorStroke', css: '--color-stroke'}, {js: 'colorText', css: '--color-text'}, {js: 'padding', css: '--widget-padding', toCss: x=>parseFloat(x) + 'rem', toJs: x=>parseFloat(x) * PXSCALE}, - {js: 'strokeWidth', css: '--stroke-width', toCss: x=>parseFloat(x) + 'rem', toJs: x=>parseFloat(x) * PXSCALE}, + {js: 'lineWidth', css: '--line-width', 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)}, @@ -1065,7 +1065,7 @@ Widget.dynamicProps = [ 'alphaFillOff', 'alphaFillOn', 'padding', - 'strokeWidth', + 'lineWidth', 'css', 'value', diff --git a/src/client/widgets/containers/clone.js b/src/client/widgets/containers/clone.js index 9ee61d2f..7a00331a 100644 --- a/src/client/widgets/containers/clone.js +++ b/src/client/widgets/containers/clone.js @@ -26,7 +26,7 @@ class Clone extends Container() { props: {type: 'object', value: {}, help: 'Cloned widget\'s properties to override'}, }, [ - 'colorBg', 'colorText', 'colorWidget', 'colorFill', 'colorStroke', 'alphaStroke', 'alphaFillOff', 'alphaFillOn', 'padding', 'strokeWidth', + 'colorBg', 'colorText', 'colorWidget', 'colorFill', 'colorStroke', 'alphaStroke', 'alphaFillOff', 'alphaFillOn', 'padding', 'lineWidth', 'label', 'color', '_value', 'default', 'value', 'script', 'linkId', '_osc', 'decimals', 'address', 'preArgs', 'typeTags', 'target', 'ignoreDefaults', 'bypass' @@ -298,7 +298,7 @@ class Clone extends Container() { case 'alphaFillOff': case 'alphaFillOn': case 'colorBg': - case 'strokeWidth': + case 'lineWidth': case 'padding': for (var w of this.children) { if (w) w.onPropChanged(propName) diff --git a/src/client/widgets/graphs/plot.js b/src/client/widgets/graphs/plot.js index d104fbcb..9660f351 100644 --- a/src/client/widgets/graphs/plot.js +++ b/src/client/widgets/graphs/plot.js @@ -88,7 +88,7 @@ module.exports = class Plot extends StaticProperties(Canvas, {bypass: true, inte this.ctx.fillStyle = this.cssVars.colorText this.ctx.globalAlpha = this.cssVars.alphaPips - var margin = this.cssVars.padding + this.cssVars.strokeWidth + var margin = this.cssVars.padding + this.cssVars.lineWidth if (margin < this.fontSize * 1.5) return @@ -114,7 +114,7 @@ module.exports = class Plot extends StaticProperties(Canvas, {bypass: true, inte draw_line() { var points = [], - padding = this.cssVars.padding + this.cssVars.strokeWidth, + padding = this.cssVars.padding + this.cssVars.lineWidth, decimals = this.getProp('smooth') ? 1 : 0, length = this.value.length, x, y, i, previousValue, nx, ny diff --git a/src/client/widgets/pads/multixy.js b/src/client/widgets/pads/multixy.js index b1a71452..9491ebef 100644 --- a/src/client/widgets/pads/multixy.js +++ b/src/client/widgets/pads/multixy.js @@ -287,7 +287,7 @@ module.exports = class MultiXy extends Pad { case 'alphaFillOff': case 'alphaFillOn': case 'padding': - case 'strokeWidth': + case 'lineWidth': for (var w of this.pads) { w.onPropChanged(propName) } diff --git a/src/client/widgets/pads/pad.js b/src/client/widgets/pads/pad.js index 62f8238e..bf0acd80 100644 --- a/src/client/widgets/pads/pad.js +++ b/src/client/widgets/pads/pad.js @@ -22,7 +22,7 @@ class Pad extends Canvas { super.cacheCanvasStyle(style) this.pointSize = parseFloat(style.getPropertyValue('--pointSize')) * PXSCALE - this.padPadding = (this.cssVars.padding + this.cssVars.strokeWidth) + 2 * PXSCALE + this.padPadding = (this.cssVars.padding + this.cssVars.lineWidth) + 2 * PXSCALE } diff --git a/src/client/widgets/sliders/encoder.js b/src/client/widgets/sliders/encoder.js index ac8716ce..c4efa2bb 100644 --- a/src/client/widgets/sliders/encoder.js +++ b/src/client/widgets/sliders/encoder.js @@ -213,7 +213,7 @@ module.exports = class Encoder extends StaticProperties(Knob, {angle: 360, range min = this.percentToAngle(0), max = this.percentToAngle(100), minRadius = this.minDimension / 6, - maxRadius = this.minDimension / 2 - this.cssVars.strokeWidth, + maxRadius = this.minDimension / 2 - this.cssVars.lineWidth, gaugeWidth = maxRadius - minRadius, gaugeRadius = maxRadius - gaugeWidth / 2 @@ -245,11 +245,11 @@ module.exports = class Encoder extends StaticProperties(Knob, {angle: 360, range } // stroke - if (this.cssVars.strokeWidth) { + if (this.cssVars.lineWidth) { this.ctx.globalAlpha = this.cssVars.alphaStroke this.ctx.strokeStyle = this.cssVars.colorStroke - this.ctx.lineWidth = this.cssVars.strokeWidth + this.ctx.lineWidth = this.cssVars.lineWidth if (this.minDimension > 40) { this.ctx.beginPath() diff --git a/src/client/widgets/sliders/fader.js b/src/client/widgets/sliders/fader.js index 5821fe0e..ed7cefc4 100644 --- a/src/client/widgets/sliders/fader.js +++ b/src/client/widgets/sliders/fader.js @@ -235,7 +235,7 @@ class Fader extends Slider { if (compact) { // stroke - if (this.cssVars.strokeWidth) { + if (this.cssVars.lineWidth) { this.ctx.globalAlpha = this.cssVars.alphaStroke this.ctx.strokeStyle = this.cssVars.colorStroke @@ -246,7 +246,7 @@ class Fader extends Slider { this.ctx.lineTo(width, height) this.ctx.lineTo(0, height) this.ctx.closePath() - this.ctx.lineWidth = 2 * this.cssVars.strokeWidth + this.ctx.lineWidth = 2 * this.cssVars.lineWidth this.ctx.stroke() } diff --git a/src/client/widgets/sliders/knob.js b/src/client/widgets/sliders/knob.js index c25f8daf..f9f56834 100644 --- a/src/client/widgets/sliders/knob.js +++ b/src/client/widgets/sliders/knob.js @@ -176,8 +176,8 @@ module.exports = class Knob extends Slider { max = this.percentToAngle(100), dashed = this.getProp('dashed'), pips = this.getProp('pips'), - minRadius = this.minDimension / 6 - (pips ? this.fontSize * 0.75 : 0) - this.cssVars.strokeWidth / 2, - maxRadius = this.minDimension / 2 - (pips ? this.fontSize * 2 : 0) - this.cssVars.strokeWidth / 2 + minRadius = this.minDimension / 6 - (pips ? this.fontSize * 0.75 : 0) - this.cssVars.lineWidth / 2, + maxRadius = this.minDimension / 2 - (pips ? this.fontSize * 2 : 0) - this.cssVars.lineWidth / 2 if (dashed) dashed = Array.isArray(dashed) ? dashed.map(x=>parseFloat(x)) : [1.5, 1.5] @@ -218,10 +218,10 @@ module.exports = class Knob extends Slider { // stroke - if (this.cssVars.strokeWidth) { + if (this.cssVars.lineWidth) { this.ctx.globalAlpha = this.cssVars.alphaStroke this.ctx.strokeStyle = this.cssVars.colorStroke - this.ctx.lineWidth = this.cssVars.strokeWidth + this.ctx.lineWidth = this.cssVars.lineWidth this.ctx.beginPath() this.ctx.arc(this.width / 2, this.height / 2, maxRadius, 0, 2 * Math.PI) @@ -233,7 +233,7 @@ module.exports = class Knob extends Slider { this.ctx.globalAlpha = 1 this.ctx.strokeStyle = this.cssVars.colorFill - this.ctx.lineWidth = 2.5 * PXSCALE + this.ctx.lineWidth = this.cssVars.lineWidth + .5 * PXSCALE let r1 = minRadius + this.gaugePadding, r2 = maxRadius - this.gaugePadding, @@ -257,7 +257,7 @@ module.exports = class Knob extends Slider { // fill this.ctx.strokeStyle = this.cssVars.colorFill - this.ctx.lineWidth = 2 * PXSCALE + this.ctx.lineWidth = this.cssVars.lineWidth if (this.cssVars.alphaFillOff) { this.ctx.globalAlpha = this.cssVars.alphaFillOff @@ -281,7 +281,7 @@ module.exports = class Knob extends Slider { this.ctx.globalAlpha = 1 this.ctx.strokeStyle = this.cssVars.colorBg - this.ctx.lineWidth = 2.5 * PXSCALE + this.ctx.lineWidth = this.cssVars.lineWidth + .5 * PXSCALE let r1 = minRadius, r2 = maxRadius / 1.25 + PXSCALE , @@ -298,7 +298,7 @@ module.exports = class Knob extends Slider { // fill this.ctx.strokeStyle = this.cssVars.colorFill - this.ctx.lineWidth = 2 * PXSCALE + this.ctx.lineWidth = this.cssVars.lineWidth if (this.cssVars.alphaFillOff) { this.ctx.globalAlpha = this.cssVars.alphaFillOff @@ -322,10 +322,10 @@ module.exports = class Knob extends Slider { this.ctx.globalAlpha = 1 this.ctx.strokeStyle = this.cssVars.colorFill - this.ctx.lineWidth = 2.5 * PXSCALE + this.ctx.lineWidth = this.cssVars.lineWidth let r1 = minRadius * 1.5, - r2 = maxRadius + 0.5 * PXSCALE, + r2 = maxRadius + this.cssVars.lineWidth / 2 - 0.5 * PXSCALE, a = 2 * Math.PI - d this.ctx.beginPath() @@ -340,13 +340,13 @@ module.exports = class Knob extends Slider { if (pips) { - this.ctx.lineWidth = 1.5 * PXSCALE + this.ctx.lineWidth = this.cssVars.lineWidth / 2 + 0.5 * PXSCALE this.ctx.strokeStyle = this.cssVars.colorStroke this.ctx.globalAlpha = this.cssVars.alphaPips for (var pip of this.rangeKeys) { - let r1 = maxRadius + 3 * PXSCALE, + let r1 = maxRadius + this.cssVars.lineWidth / 2 + 2 * PXSCALE, r2 = r1 + 4 * PXSCALE, a = 2 * Math.PI - this.percentToAngle(pip) @@ -358,7 +358,7 @@ module.exports = class Knob extends Slider { } - var radius = maxRadius + (this.fontSize + 4 * PXSCALE) + var radius = maxRadius + (this.fontSize + this.cssVars.lineWidth / 2 + 2 * PXSCALE) this.ctx.fillStyle = this.cssVars.colorText this.ctx.globalAlpha = this.cssVars.alphaPipsText for (var p in this.pipTexts) { diff --git a/src/client/widgets/sliders/range.js b/src/client/widgets/sliders/range.js index 6f72c620..d954ddb6 100644 --- a/src/client/widgets/sliders/range.js +++ b/src/client/widgets/sliders/range.js @@ -275,7 +275,7 @@ class Range extends Fader { this.ctx.lineTo(width, height) this.ctx.lineTo(0, height) this.ctx.closePath() - this.ctx.lineWidth = 2 * this.cssVars.strokeWidth + this.ctx.lineWidth = 2 * this.cssVars.lineWidth this.ctx.stroke() diff --git a/src/client/widgets/sliders/slider.js b/src/client/widgets/sliders/slider.js index a5c76a13..792579e3 100644 --- a/src/client/widgets/sliders/slider.js +++ b/src/client/widgets/sliders/slider.js @@ -144,7 +144,7 @@ class Slider extends Canvas { super.cacheCanvasStyle(style) - this.gaugePadding = this.cssVars.padding + this.cssVars.strokeWidth + this.gaugePadding = this.cssVars.padding + this.cssVars.lineWidth } diff --git a/src/scss/mixins.scss b/src/scss/mixins.scss index 3eec8e69..5de3094e 100644 --- a/src/scss/mixins.scss +++ b/src/scss/mixins.scss @@ -2,7 +2,7 @@ &:before { content:""; position: absolute; - border: var(--stroke-width) solid var(--color-stroke); + border: var(--line-width) solid var(--color-stroke); opacity: var(--alpha-stroke); top: 0; left: 0; @@ -20,10 +20,10 @@ position: absolute; background: var(--color-fill); opacity: var(--alpha-fill); - top: var(--stroke-width); - left: var(--stroke-width); - right: var(--stroke-width); - bottom: var(--stroke-width); + top: var(--line-width); + left: var(--line-width); + right: var(--line-width); + bottom: var(--line-width); pointer-events: none; margin: var(--widget-padding); z-index: $z; diff --git a/src/scss/themes/default.scss b/src/scss/themes/default.scss index e5f296ca..66fa786e 100644 --- a/src/scss/themes/default.scss +++ b/src/scss/themes/default.scss @@ -29,7 +29,7 @@ $font-menu: sans-serif; --color-context-menu-text: #{$nord1}; - --stroke-width: 1rem; + --line-width: 1rem; --alpha-scrollbar: 0.25; --alpha-scrollbar-on: 0.75; diff --git a/src/scss/widgets.scss b/src/scss/widgets.scss index 89874732..25a41eaa 100644 --- a/src/scss/widgets.scss +++ b/src/scss/widgets.scss @@ -23,7 +23,7 @@ // transform-origin: top left; - --stroke-width: 1rem; + --line-width: 1rem; --widget-padding: 1rem; --color-stroke:var(--color-widget); diff --git a/src/scss/widgets/basics.scss b/src/scss/widgets/basics.scss index 4ced82ab..4b6cb4f0 100644 --- a/src/scss/widgets/basics.scss +++ b/src/scss/widgets/basics.scss @@ -88,7 +88,7 @@ display: flex; flex-direction: column; --widget-spacing: calc(var(--widget-padding) / 2); - margin: calc(var(--widget-spacing) + var(--stroke-width)); + margin: calc(var(--widget-spacing) + var(--line-width)); } @@ -125,7 +125,7 @@ overflow: hidden; @include pseudo-fill($z: -1); &:after { - --stroke-width: 1rem; + --line-width: 1rem; margin: calc(var(--widget-spacing) - 1rem); } @@ -250,7 +250,7 @@ @include pseudo-stroke($z: 2); &:before { - border-width: var(--stroke-width); + border-width: var(--line-width); } @@ -350,7 +350,7 @@ display: flex; flex-direction: row; - padding: calc(var(--widget-padding) / 2 + var(--stroke-width)); + padding: calc(var(--widget-padding) / 2 + var(--line-width)); .item { position: relative; diff --git a/src/scss/widgets/containers.scss b/src/scss/widgets/containers.scss index 2b73a207..1153d63f 100644 --- a/src/scss/widgets/containers.scss +++ b/src/scss/widgets/containers.scss @@ -188,7 +188,7 @@ &.contains-widgets { > inner { - margin: calc(var(--widget-spacing) + var(--stroke-width)); + margin: calc(var(--widget-spacing) + var(--line-width)); } &.no-inner-padding > inner { @@ -300,10 +300,10 @@ z-index: 101; } &:first-child:before { - margin-left: var(--stroke-width); + margin-left: var(--line-width); } &:last-child:before { - margin-right: var(--stroke-width); + margin-right: var(--line-width); } } @@ -336,11 +336,11 @@ z-index: 101; } &:first-child:before { - margin-top: var(--stroke-width); + margin-top: var(--line-width); margin-left: 0; } &:last-child:before { - margin-bottom: var(--stroke-width); + margin-bottom: var(--line-width); margin-right: 0; } } @@ -556,23 +556,23 @@ display: flex; flex-direction: column; align-items:stretch; - margin-bottom: var(--stroke-width); + margin-bottom: var(--line-width); width: 25%; } .inputs, .outputs { position: relative; @include pseudo-stroke(); - top: var(--stroke-width); + top: var(--line-width); margin-top: -1rem; - height: calc(100% - var(--stroke-width) * 2 + 2rem); + height: calc(100% - var(--line-width) * 2 + 2rem); } .inputs:before { - border-width: 0 var(--stroke-width) 0 0; + border-width: 0 var(--line-width) 0 0; } .outputs:before { - border-width: 0 0 0 var(--stroke-width); + border-width: 0 0 0 var(--line-width); } } @@ -606,11 +606,11 @@ --color-white-key: #ccc; --color-black-key: #1A1A1A; - --widget-keypad: calc(var(--widget-padding) + var(--stroke-width)); + --widget-keypad: calc(var(--widget-padding) + var(--line-width)); > inner { - padding: calc(var(--widget-padding) + var(--stroke-width)); + padding: calc(var(--widget-padding) + var(--line-width)); flex: 1; @include pseudo-stroke($z: 2); position: relative; @@ -623,7 +623,7 @@ --alpha-fill-off: var(--alpha-key-off); --alpha-fill-on: var(--alpha-key-on); - --stroke-width: 0!important; + --line-width: 0!important; inner { margin: 1rem 0.5rem!important; --widget-padding: -1rem; diff --git a/src/scss/widgets/frames.scss b/src/scss/widgets/frames.scss index 219bc8ff..781e6d5c 100644 --- a/src/scss/widgets/frames.scss +++ b/src/scss/widgets/frames.scss @@ -10,7 +10,7 @@ position: relative; flex: 1; display: flex; - padding: calc(var(--widget-spacing) + var(--stroke-width)); + padding: calc(var(--widget-spacing) + var(--line-width)); background-clip: content-box; @include pseudo-stroke(); } diff --git a/src/scss/widgets/pads.scss b/src/scss/widgets/pads.scss index e502a506..89f7cbab 100644 --- a/src/scss/widgets/pads.scss +++ b/src/scss/widgets/pads.scss @@ -52,7 +52,7 @@ --widget-spacing: calc(var(--widget-padding) / 2); - padding: calc(var(--stroke-width) + var(--widget-spacing)); + padding: calc(var(--line-width) + var(--widget-spacing)); grid-template: "a a b" auto / 1fr; @@ -70,7 +70,7 @@ width: auto; margin: var(--widget-spacing); --widget-padding: 2rem; - --stroke-width: 0; + --line-width: 0; } .pad { diff --git a/src/scss/widgets/sliders.scss b/src/scss/widgets/sliders.scss index a53e88ac..9410baa5 100644 --- a/src/scss/widgets/sliders.scss +++ b/src/scss/widgets/sliders.scss @@ -58,6 +58,7 @@ &.design-solid, &.design-line { --alpha-fill-off: 0.25; --alpha-fill-on: 1; + --line-width: 2rem; } }