From 5df9c436b21de8f5e5ba42e96eb02423f858dc10 Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Mon, 17 Oct 2022 20:00:41 +0200 Subject: [PATCH] widgets: add borderRadius property --- CHANGELOG.md | 3 ++- src/client/widgets/common/widget.js | 2 ++ src/client/widgets/indicators/led.js | 8 -------- src/scss/widgets.scss | 3 +++ 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 304214ca..cf192336 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,8 @@ - button: add `decoupled` property (restrict visual feedback to values received from osc/midi messages) - canvas: iOS: trigger `onTouch` when `event.force`, `event.altitudeAngle` or `event.azimuthAngle` updates - knob: add `snap-alt` mode (snap mode that allows jumping between range.min and range.max) - + - all: add `borderRadius` property + - scripting - add `updateCanvas()` function (forces a canvas widget to redraw) diff --git a/src/client/widgets/common/widget.js b/src/client/widgets/common/widget.js index 0ddeb5f7..f8da3084 100644 --- a/src/client/widgets/common/widget.js +++ b/src/client/widgets/common/widget.js @@ -83,6 +83,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).'}, lineWidth: {type: 'number', value: 'auto', help: 'Stroke width.'}, + borderRadius: {type: 'number|string', value: 'auto', help: 'Border radius expressed as a number or a css string. This property may not work for all widgets.'}, padding: {type: 'number', value: 'auto', help: 'Inner spacing.'}, html: {type: 'string', value: '', editor: 'html', syntaxChecker: false, help: [ 'Custom html content to be inserted in the widget (before the widget\'s content). Elements are all unstyled by default, `css` should be used to customize their appearance.', @@ -1316,6 +1317,7 @@ Widget.cssVariables = [ {js: 'colorText', css: '--color-text'}, {js: 'padding', css: '--widget-padding', 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: 'borderRadius', css: '--border-radius', toCss: x=>parseFloat(x) == x ? x + 'rem' : x}, {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)}, diff --git a/src/client/widgets/indicators/led.js b/src/client/widgets/indicators/led.js index 4f8b43f7..f93b0c4d 100644 --- a/src/client/widgets/indicators/led.js +++ b/src/client/widgets/indicators/led.js @@ -17,10 +17,6 @@ module.exports = class Led extends StaticProperties(Widget, {bypass: true, inter widget: { interaction: null }, - style: { - _separator_led_style: 'Led style', - borderRadius: {type: 'string', value: '', help: 'Css border-radius property.'}, - }, class_specific: { mode: {type: 'string', value: 'intensity', choices: ['intensity', 'color'], help: 'Defines how value is interpreted (see `value`)'}, range: {type: 'object', value: {min:0, max:1}, help: 'Value range'}, @@ -53,10 +49,6 @@ module.exports = class Led extends StaticProperties(Widget, {bypass: true, inter this.setValueIntensity(this.getProp('mode') === 'intensity' ? this.getProp('range').min : this.getProp('range').max) - var bR = this.getProp('borderRadius') - if (parseInt(bR) == bR) bR += 'rem' - this.container.style.setProperty('--border-radius', bR) - } setValue(v, options={}) { diff --git a/src/scss/widgets.scss b/src/scss/widgets.scss index dde39806..01c432b0 100644 --- a/src/scss/widgets.scss +++ b/src/scss/widgets.scss @@ -37,6 +37,9 @@ --alpha-pips: 0.5; --alpha-pips-text: 0.7; + --border-radius: 0; + + border-radius: var(--border-radius); color: var(--color-text);