From db165faa9f5d5d7a473a5676c22762c2b32eade8 Mon Sep 17 00:00:00 2001 From: bordun Date: Wed, 21 Apr 2021 16:35:54 +0200 Subject: [PATCH] editor: use css variable `--grid-width` at startup (allow overriding) and after disabling & enabling the grid --- CHANGELOG.md | 1 + src/client/editor/index.js | 4 ++-- src/client/globals.js | 4 +++- src/client/ipc/callbacks.js | 4 +++- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 63c4e0da..e5495c4f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - bug fixes - button: all writing strings like `"1.0"` in `label` without removing the decimals + - editor: use css variable `--grid-width` at startup (allow overriding) and after disabling & enabling the grid - midi - allow sending note off with velocity diff --git a/src/client/editor/index.js b/src/client/editor/index.js index c69e9aea..0b73209e 100644 --- a/src/client/editor/index.js +++ b/src/client/editor/index.js @@ -405,9 +405,9 @@ class Editor { this.grid = !this.grid - GRIDWIDTH = this.grid ? 10 : 1 + GRIDWIDTH = this.grid ? GRIDWIDTH_CSS : 1 - document.documentElement.style.setProperty('--grid-width', GRIDWIDTH) + document.body.style.setProperty('--grid-width', GRIDWIDTH) document.body.classList.toggle('no-grid', GRIDWIDTH == 1) } diff --git a/src/client/globals.js b/src/client/globals.js index e23cf22c..cac19a55 100644 --- a/src/client/globals.js +++ b/src/client/globals.js @@ -11,7 +11,9 @@ window.PACKAGE = require('../../package.json') window.LOADING = null window.READ_ONLY = window.READ_ONLY || false -window.GRIDWIDTH = 10 +window.GRIDWIDTH_CSS = parseInt(getComputedStyle(document.documentElement).getPropertyValue('--grid-width')) +window.GRIDWIDTH = GRIDWIDTH_CSS + window.ELECTRON_NOGPU = false diff --git a/src/client/ipc/callbacks.js b/src/client/ipc/callbacks.js index 00bdbb5b..5467d722 100644 --- a/src/client/ipc/callbacks.js +++ b/src/client/ipc/callbacks.js @@ -98,7 +98,9 @@ module.exports = { setTimeout(()=>{ var root = widgetManager.getWidgetById('root')[0] if (root) root.onPropChanged('color') - GRIDWIDTH = parseInt(getComputedStyle(document.documentElement).getPropertyValue('--grid-width')) + GRIDWIDTH_CSS = parseInt(getComputedStyle(document.documentElement).getPropertyValue('--grid-width')) + editor.toggleGrid() + editor.toggleGrid() },200)