pads: support percents in `pointSize

This commit is contained in:
jean-emmanuel 2025-03-13 08:04:33 +01:00
parent 8c5eea6bd0
commit fba35f1b84
4 changed files with 7 additions and 6 deletions

View file

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

View file

@ -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<this.npoints;i++) {
var pointSize = this.pads[i].cssVars.pointSize
var pointSize = this.pads[i].pointSize
this.padsCoords[i] = [clip(this.pads[i].faders.x.percent,[0,100]) / 100 * (this.width - (pointSize * 2 + 2) * PXSCALE) + (pointSize + 1) * PXSCALE
,- clip(this.pads[i].faders.y.percent,[0,100]) / 100 * (this.height - (pointSize * 2 + 2) * PXSCALE) - (pointSize + 1) * PXSCALE]

View file

@ -20,6 +20,7 @@ class Pad extends Canvas {
super.cacheCanvasStyle(style)
this.padPadding = (this.cssVars.padding + this.cssVars.lineWidth) + 2 * PXSCALE
this.pointSize = parseFloat(this.cssVars.pointSize) * (this.cssVars.pointSize.indexOf('%') > -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([

View file

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