diff --git a/CHANGELOG.md b/CHANGELOG.md index 607cbb0f..34ed8c51 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ - app address / qr code not updating when network changes - issue after theme auto reload (broken grid, colors not updated) +- widgets + - pads: expose css variable `--point-size` + - custom module - provide error backtraces in module.exports functions diff --git a/src/client/widgets/common/canvas.js b/src/client/widgets/common/canvas.js index 54a9e014..3fbc6568 100644 --- a/src/client/widgets/common/canvas.js +++ b/src/client/widgets/common/canvas.js @@ -197,6 +197,7 @@ class Canvas extends Widget { case 'alphaFillOff': case 'alphaFillOn': case 'colorBg': + case 'pointSize': fastdom.measure(()=>{ this.cacheCanvasStyle() fastdom.mutate(()=>{ diff --git a/src/client/widgets/pads/multixy.js b/src/client/widgets/pads/multixy.js index 88fb1569..64a600e5 100644 --- a/src/client/widgets/pads/multixy.js +++ b/src/client/widgets/pads/multixy.js @@ -64,7 +64,6 @@ module.exports = class MultiXy extends Pad { this.npoints = Array.isArray(this.getProp('points')) ? this.getProp('points').length : this.getProp('points') || 0 this.labels = Array.isArray(this.getProp('points')) - this.pointSize = parseInt(this.getProp('pointSize')) this.preventChildrenTouchState = true this.pads = [] @@ -82,7 +81,7 @@ module.exports = class MultiXy extends Pad { logScaleX:this.getProp('logScaleX'), logScaleY:this.getProp('logScaleY'), axisLock:this.getProp('axisLock'), - pointSize: this.getProp('pointSize'), + pointSize: 'auto', pips: this.getProp('pips') && i == this.npoints-1, sensitivity: this.getProp('sensitivity'), input:false @@ -249,9 +248,9 @@ module.exports = class MultiXy extends Pad { updateHandlesPosition() { for (var i=0;i `}) - this.canvas.style.setProperty('--pointSize', parseInt(this.getProp('pointSize')) + 'rem') - } cacheCanvasStyle(style) { @@ -21,16 +19,35 @@ class Pad extends Canvas { super.cacheCanvasStyle(style) - this.pointSize = parseFloat(style.getPropertyValue('--pointSize')) * PXSCALE this.padPadding = (this.cssVars.padding + this.cssVars.lineWidth) + 2 * PXSCALE } + onPropChanged(propName, options, oldPropValue) { + + var ret = super.onPropChanged(...arguments) + + switch (propName) { + case 'pointSize': + this.setCssVariables() + return + } + + return ret + + + } + } +Pad.cssVariables = Pad.prototype.constructor.cssVariables.concat( + {js: 'pointSize', css: '--point-size', toCss: x=>parseFloat(x) + 'rem', toJs: x=>parseFloat(x) * PXSCALE}, +) + Pad.dynamicProps = Pad.prototype.constructor.dynamicProps.filter(n => n !== 'decimals').concat([ 'spring', - 'axisLock' + 'axisLock', + 'pointSize' ]) module.exports = Pad diff --git a/src/client/widgets/pads/xy.js b/src/client/widgets/pads/xy.js index f2e4a1aa..42609df2 100644 --- a/src/client/widgets/pads/xy.js +++ b/src/client/widgets/pads/xy.js @@ -208,7 +208,7 @@ module.exports = class Xy extends Pad { draw() { - var pointSize = this.pointSize, + var pointSize = this.cssVars.pointSize, margin = this.padPadding, x = this.faders.x.percentToCoord(this.faders.x.percent), y = this.faders.y.percentToCoord(this.faders.y.percent), @@ -287,7 +287,7 @@ module.exports = class Xy extends Pad { } - if (!pipsDrawn) this.clearRect = [x - this.pointSize - 2 * PXSCALE, y - this.pointSize - 2 * PXSCALE, (this.pointSize + PXSCALE) * 4, (this.pointSize + PXSCALE) * 4] + if (!pipsDrawn) this.clearRect = [x - pointSize - 2 * PXSCALE, y - pointSize - 2 * PXSCALE, (pointSize + PXSCALE) * 4, (pointSize + PXSCALE) * 4] if (!ephemeral || this.active) { diff --git a/src/scss/widgets/pads.scss b/src/scss/widgets/pads.scss index 34feae3e..ba13d73d 100644 --- a/src/scss/widgets/pads.scss +++ b/src/scss/widgets/pads.scss @@ -30,6 +30,8 @@ .multixy-container { + --point-size: 20rem; + canvas:not(:first-child) { position: absolute; top: 0;