From 669de6d32e7652461d6a18f2eb877e4c43535447 Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Fri, 21 Jul 2017 20:56:27 +0200 Subject: [PATCH] matrices: add spacing option --- app/examples/demo.js | 61 ++++++++++++++++++- resources/docs/widgets/containers.md | 5 ++ resources/docs/widgets/matrices.md | 9 +++ .../js/app/widgets/matrices/multipush.js | 8 ++- .../js/app/widgets/matrices/multitoggle.js | 6 +- src/browser/scss/widgets/_matrices.scss | 7 ++- 6 files changed, 87 insertions(+), 9 deletions(-) diff --git a/app/examples/demo.js b/app/examples/demo.js index eedd35d9..9284ce06 100644 --- a/app/examples/demo.js +++ b/app/examples/demo.js @@ -230,7 +230,7 @@ "dashed": true, "color": "auto", "css": "margin: 20rem 0 20rem 10rem;", - "widgetId": "", + "widgetId": "knob_1", "range": { "min": 0, "max": 1 @@ -246,7 +246,7 @@ }, { "type": "meter", - "id": "meter_1", + "id": "meter_2", "label": false, "unit": "", "alignRight": false, @@ -255,7 +255,7 @@ "dashed": true, "color": "auto", "css": "margin: 20rem 0", - "widgetId": "", + "widgetId": "knob_2", "range": { "min": 0, "max": 1 @@ -684,6 +684,61 @@ "preArgs": [], "split": false, "target": [] + }, + { + "type": "multipush", + "top": 10, + "left": 620, + "id": "multipush", + "matrix": [ + 2, + 4 + ], + "start": 0, + "spacing": 5, + "label": "auto", + "width": 130, + "height": 220, + "color": "auto", + "css": "", + "traversing": true, + "on": 1, + "off": 0, + "value": "", + "precision": 2, + "address": "/multipush", + "preArgs": [], + "split": false, + "target": [], + "style": "style", + "norelease": false + }, + { + "type": "multitoggle", + "top": 240, + "left": 620, + "matrix": [ + 2, + 4 + ], + "start": 0, + "spacing": 5, + "label": "auto", + "width": 130, + "height": 220, + "color": "auto", + "css": "", + "traversing": true, + "on": 1, + "off": 0, + "value": "", + "precision": 2, + "address": "/multipush", + "preArgs": [], + "split": false, + "target": [], + "led": true, + "id": "multitoggle" } ], "tabs": [], diff --git a/resources/docs/widgets/containers.md b/resources/docs/widgets/containers.md index 5da34ed8..9c50ca7e 100644 --- a/resources/docs/widgets/containers.md +++ b/resources/docs/widgets/containers.md @@ -82,6 +82,11 @@ Unidirectionnal panel with stretching capability. By default, children widgets t - default: `false` - usage: set to `true` to stretch widgets evenly +### `spacing` +- type: `integer` +- default: `0` +- usage: adds space between widgets + ### `border` - type: `boolean` - default: `true` diff --git a/resources/docs/widgets/matrices.md b/resources/docs/widgets/matrices.md index b93643cb..3c36051a 100644 --- a/resources/docs/widgets/matrices.md +++ b/resources/docs/widgets/matrices.md @@ -69,6 +69,11 @@ Multifader creates a row of vertical faders that respond to the same gestures. - default: `0` - usage: first toggle's index +### `spacing` +- type: `integer` +- default: `0` +- usage: adds space between widgets + ### `traversing` - type: `boolean` - default: `true` @@ -112,6 +117,10 @@ Multifader creates a row of vertical faders that respond to the same gestures. - default: `0` - usage: first push's index +### `spacing` +- type: `integer` +- default: `0` +- usage: adds space between widgets ### `traversing` - type: `boolean` diff --git a/src/browser/js/app/widgets/matrices/multipush.js b/src/browser/js/app/widgets/matrices/multipush.js index a13c493d..07697b51 100644 --- a/src/browser/js/app/widgets/matrices/multipush.js +++ b/src/browser/js/app/widgets/matrices/multipush.js @@ -12,8 +12,9 @@ module.exports = class Multipush extends _matrices_base { matrix: [2,2], start:0, + spacing:0, - style:'style', + _style:'style', label:'auto', left:'auto', @@ -46,6 +47,10 @@ module.exports = class Multipush extends _matrices_base { super(options) + this.widget[0].style.setProperty('--columns', this.getProp('matrix')[0]) + this.widget[0].style.setProperty('--rows', this.getProp('matrix')[1]) + this.widget[0].style.setProperty('--spacing', this.getProp('spacing') + 'rem') + var strData = JSON.stringify(options.props) var parsers = require('../../parser'), @@ -65,7 +70,6 @@ module.exports = class Multipush extends _matrices_base { data.css = '' var element = parsewidgets([data],this.widget) - element[0].style.setProperty('width', 100/this.getProp('matrix')[0] + '%') element[0].classList.add('not-editable') this.value[i-this.start] = this.getProp('off') diff --git a/src/browser/js/app/widgets/matrices/multitoggle.js b/src/browser/js/app/widgets/matrices/multitoggle.js index 6ea6ec35..359f653c 100644 --- a/src/browser/js/app/widgets/matrices/multitoggle.js +++ b/src/browser/js/app/widgets/matrices/multitoggle.js @@ -12,6 +12,7 @@ module.exports = class Multitoggle extends _matrices_base { matrix: [2,2], start:0, + spacing:0, _style:'style', @@ -46,6 +47,10 @@ module.exports = class Multitoggle extends _matrices_base { super(options) + this.widget[0].style.setProperty('--columns', this.getProp('matrix')[0]) + this.widget[0].style.setProperty('--rows', this.getProp('matrix')[1]) + this.widget[0].style.setProperty('--spacing', this.getProp('spacing') + 'rem') + var strData = JSON.stringify(options.props) var parsers = require('../../parser'), @@ -65,7 +70,6 @@ module.exports = class Multitoggle extends _matrices_base { data.css = '' var element = parsewidgets([data],this.widget) - element[0].style.setProperty('width', 100/this.getProp('matrix')[0] + '%') element[0].classList.add('not-editable') this.value[i-this.start] = this.getProp('off') diff --git a/src/browser/scss/widgets/_matrices.scss b/src/browser/scss/widgets/_matrices.scss index ea83f6ba..3dbc13e8 100644 --- a/src/browser/scss/widgets/_matrices.scss +++ b/src/browser/scss/widgets/_matrices.scss @@ -20,12 +20,13 @@ flex-direction: row; padding:1rem 2rem 2rem 1rem; - > .widget { min-height: 0; min-width: 0; - margin:0!important; - height: auto; + // margin:0!important; + height: calc( 100% / var(--rows) - var(--spacing)); + width: calc( 100% / var(--columns) - var(--spacing)); + margin: calc(var(--spacing) / 2); .label { background:none; border:0;