From 58d8ec217178e205eddd2f75f741f2051fe6b474 Mon Sep 17 00:00:00 2001 From: bordun Date: Thu, 1 Oct 2020 13:25:56 +0200 Subject: [PATCH] xy/multixy: add `ephemeral` property --- CHANGELOG.md | 1 + src/client/widgets/pads/multixy.js | 2 ++ src/client/widgets/pads/xy.js | 30 ++++++++++++++++++------------ 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9da28979..d14b2909 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ - widgets - expose widgets unique identifiers with property name "uuid" + - xy/multixy: add `ephemeral` property ## 1.3.0 diff --git a/src/client/widgets/pads/multixy.js b/src/client/widgets/pads/multixy.js index 9491ebef..8136d7f6 100644 --- a/src/client/widgets/pads/multixy.js +++ b/src/client/widgets/pads/multixy.js @@ -34,6 +34,7 @@ module.exports = class MultiXy extends Pad { 'By default, the points are dragged from their initial position.', 'If set to `true`, touching anywhere on the widget\'s surface will make them snap to the touching coordinates', ]}, + ephemeral: {type: 'boolean', value: false, help: 'When set to `true`, the points will be drawn only chile touched.'}, spring: {type: 'boolean', value: false, help: 'When set to `true`, the widget will go back to its default value when released'}, pips: {type: 'boolean', value: true, help: 'Set to `false` to hide the scale'}, rangeX: {type: 'object', value: {min:0,max:1}, help: 'Defines the min and max values for the x axis'}, @@ -65,6 +66,7 @@ module.exports = class MultiXy extends Pad { ...xyDefaults, snap:this.getProp('snap'), spring:this.getProp('spring'), + ephemeral:this.getProp('ephemeral'), default:this.getProp('default').length === this.getProp('points') * 2 ? [this.getProp('default')[i*2], this.getProp('default')[i*2 + 1]] : '', rangeX:this.getProp('rangeX'), rangeY:this.getProp('rangeY'), diff --git a/src/client/widgets/pads/xy.js b/src/client/widgets/pads/xy.js index b8accd9b..f2eb5a57 100644 --- a/src/client/widgets/pads/xy.js +++ b/src/client/widgets/pads/xy.js @@ -24,6 +24,7 @@ module.exports = class Xy extends Pad { 'By default, the points are dragged from their initial position.', 'If set to `true`, touching anywhere on the widget\'s surface will make them snap to the touching coordinates', ]}, + ephemeral: {type: 'boolean', value: false, help: 'When set to `true`, the point will be drawn only chile touched.'}, spring: {type: 'boolean', value: false, help: 'When set to `true`, the widget will go back to its default value when released'}, pips: {type: 'boolean', value: true, help: 'Set to `false` to hide the scale'}, rangeX: {type: 'object', value: {min:0,max:1}, help: 'Defines the min and max values for the x axis'}, @@ -189,16 +190,19 @@ module.exports = class Xy extends Pad { var pointSize = this.pointSize, margin = this.padPadding, x = this.faders.x.percentToCoord(this.faders.x.percent), - y = this.faders.y.percentToCoord(this.faders.y.percent) + y = this.faders.y.percentToCoord(this.faders.y.percent), + ephemeral = this.getProp('ephemeral') this.clear() - this.ctx.fillStyle = this.cssVars.colorFill - this.ctx.globalAlpha = this.cssVars.alphaFillOn - this.ctx.beginPath() - this.ctx.arc(x, y, pointSize - 3 * PXSCALE, Math.PI * 2, false) - this.ctx.fill() + if (!ephemeral || this.active) { + this.ctx.fillStyle = this.cssVars.colorFill + this.ctx.globalAlpha = this.cssVars.alphaFillOn + this.ctx.beginPath() + this.ctx.arc(x, y, pointSize - 3 * PXSCALE, Math.PI * 2, false) + this.ctx.fill() + } @@ -265,12 +269,14 @@ 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] - this.ctx.strokeStyle = this.cssVars.colorStroke - this.ctx.globalAlpha = this.active ? 1 : 0.75 - this.ctx.lineWidth = 1.5 * PXSCALE - this.ctx.beginPath() - this.ctx.arc(x, y, pointSize, Math.PI * 2, false) - this.ctx.stroke() + if (!ephemeral || this.active) { + this.ctx.strokeStyle = this.cssVars.colorStroke + this.ctx.globalAlpha = this.active ? 1 : 0.75 + this.ctx.lineWidth = 1.5 * PXSCALE + this.ctx.beginPath() + this.ctx.arc(x, y, pointSize, Math.PI * 2, false) + this.ctx.stroke() + }