widgets: rename strokeWidth -> lineWidth

knob: use lineWidth in all designs
This commit is contained in:
bordun 2020-09-07 09:40:02 +02:00
parent c91d9af45d
commit 24a194aa9d
19 changed files with 59 additions and 58 deletions

View file

@ -151,7 +151,7 @@ class Canvas extends Widget {
},10)
return
case 'css':
case 'strokeWidth':
case 'lineWidth':
case 'padding':
resize.check(this.canvas, true)
setTimeout(()=>{

View file

@ -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',

View file

@ -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)

View file

@ -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

View file

@ -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)
}

View file

@ -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
}

View file

@ -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()

View file

@ -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()
}

View file

@ -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) {

View file

@ -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()

View file

@ -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
}

View file

@ -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;

View file

@ -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;

View file

@ -23,7 +23,7 @@
// transform-origin: top left;
--stroke-width: 1rem;
--line-width: 1rem;
--widget-padding: 1rem;
--color-stroke:var(--color-widget);

View file

@ -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;

View file

@ -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;

View file

@ -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();
}

View file

@ -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 {

View file

@ -58,6 +58,7 @@
&.design-solid, &.design-line {
--alpha-fill-off: 0.25;
--alpha-fill-on: 1;
--line-width: 2rem;
}
}