From fba35f1b84662205b69455f37e3f58b38b117ba1 Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Thu, 13 Mar 2025 08:04:33 +0100 Subject: [PATCH] pads: support percents in `pointSize --- CHANGELOG.md | 1 + src/client/widgets/pads/multixy.js | 4 ++-- src/client/widgets/pads/pad.js | 3 ++- src/client/widgets/pads/xy.js | 5 ++--- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 13d6ed84..28bd1d0e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ - xy: add `label` property - multixy: add `padsAttr` property for per-pad customization - panel: `tabsPosition` can now be `hidden` + - pads: support percents in `pointSize` ## 1.27.5 diff --git a/src/client/widgets/pads/multixy.js b/src/client/widgets/pads/multixy.js index 7baed047..37e8409d 100644 --- a/src/client/widgets/pads/multixy.js +++ b/src/client/widgets/pads/multixy.js @@ -22,7 +22,7 @@ class MultiXy extends Pad { var defaults = super.defaults().extend({ style: { _separator_xy_style: 'Xy style', - pointSize: {type: 'integer', value: 20, help: 'Defines the points\' size'}, + pointSize: {type: 'integer', value: 20, help: 'Defines the points\' default size (may be in %)'}, ephemeral: {type: 'boolean', value: false, help: 'When set to `true`, the points will be drawn only while touched.'}, pips: {type: 'boolean', value: true, help: 'Set to `false` to hide the scale'}, }, @@ -273,7 +273,7 @@ class MultiXy extends Pad { updateHandlesPosition() { for (var i=0;i -1 ? this.width / 100 : PXSCALE) } @@ -96,7 +97,7 @@ class Pad extends Canvas { } Pad.cssVariables = Pad.prototype.constructor.cssVariables.concat( - {js: 'pointSize', css: '--point-size', toCss: x=>parseFloat(x) + 'rem', toJs: x=>parseFloat(x) * PXSCALE}, + {js: 'pointSize', css: '--point-size'}, ) Pad.dynamicProps = Pad.prototype.constructor.dynamicProps.filter(n => n !== 'decimals').concat([ diff --git a/src/client/widgets/pads/xy.js b/src/client/widgets/pads/xy.js index 783d360c..76225f9b 100644 --- a/src/client/widgets/pads/xy.js +++ b/src/client/widgets/pads/xy.js @@ -18,7 +18,7 @@ module.exports = class Xy extends Pad { var defaults = super.defaults().extend({ style: { _separator_xy_style: 'Xy style', - pointSize: {type: 'integer', value: 20, help: 'Defines the points\' size'}, + pointSize: {type: 'integer', value: 20, help: 'Defines the points\' size (may be in %)'}, ephemeral: {type: 'boolean', value: false, help: 'When set to `true`, the point will be drawn only while touched.'}, pips: {type: 'boolean', value: true, help: 'Set to `false` to hide the scale'}, label: {type: 'string', value: '', help: 'Text displayed in the handle'} @@ -222,14 +222,13 @@ module.exports = class Xy extends Pad { if (!this.visible) return - var pointSize = this.cssVars.pointSize, + var pointSize = this.pointSize, x = this.faders.x.percentToCoord(this.faders.x.percent), y = this.faders.y.percentToCoord(this.faders.y.percent), ephemeral = this.getProp('ephemeral') this.clear() - if (!ephemeral || this.active) { this.ctx.fillStyle = this.cssVars.colorFill this.ctx.globalAlpha = this.cssVars.alphaFillOn