From d878ec66e2a7af1f7005e7614ff180491c5feaee Mon Sep 17 00:00:00 2001 From: Menithal Date: Thu, 21 Jun 2018 00:07:14 +0300 Subject: [PATCH 1/4] Added Lock for not sending settings_update This occurs only when fields are being filled --- scripts/system/particle_explorer/hifi-entity-ui.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/system/particle_explorer/hifi-entity-ui.js b/scripts/system/particle_explorer/hifi-entity-ui.js index a9ebaea1c4..545a17288b 100644 --- a/scripts/system/particle_explorer/hifi-entity-ui.js +++ b/scripts/system/particle_explorer/hifi-entity-ui.js @@ -60,9 +60,10 @@ function HifiEntityUI(parent) { this.parent = parent; var self = this; + this.settingsUpdateLock = false; this.webBridgeSync = _.debounce(function (id, val) { console.log(id + " " + val + " " + self.webBridgeSync); - if (self.EventBridge) { + if (self.EventBridge && !self.settingsUpdateLock) { var sendPackage = {}; sendPackage[id] = val; self.submitChanges(sendPackage); @@ -113,7 +114,6 @@ HifiEntityUI.prototype = { var self = this; var json = {}; var keys = Object.keys(self.builtRows); - for (var i = 0; i < keys.length; i++) { var key = keys[i]; var el = self.builtRows[key]; @@ -151,6 +151,7 @@ HifiEntityUI.prototype = { json[key] = document.getElementById(key).value; } } + return json; }, @@ -158,6 +159,7 @@ HifiEntityUI.prototype = { var self = this; var fields = document.getElementsByTagName("input"); + self.settingsUpdateLock = true; if (!currentProperties.locked) { for (var i = 0; i < fields.length; i++) { fields[i].removeAttribute("disabled"); @@ -228,6 +230,8 @@ HifiEntityUI.prototype = { } } } + + self.settingsUpdateLock = false; }, connect: function (EventBridge) { this.EventBridge = EventBridge; From 32982326b1b18c7b8a86783dde2d0342f8ae504c Mon Sep 17 00:00:00 2001 From: Menithal Date: Thu, 21 Jun 2018 00:08:36 +0300 Subject: [PATCH 2/4] Moved WebBridge sync to oninput: This avoids the settings_update being called only when the image finishes loaded --- scripts/system/particle_explorer/hifi-entity-ui.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/system/particle_explorer/hifi-entity-ui.js b/scripts/system/particle_explorer/hifi-entity-ui.js index 545a17288b..63defea6ea 100644 --- a/scripts/system/particle_explorer/hifi-entity-ui.js +++ b/scripts/system/particle_explorer/hifi-entity-ui.js @@ -530,13 +530,13 @@ HifiEntityUI.prototype = { textureImage.classList.remove("no-preview"); textureImage.classList.add("no-texture"); } - self.webBridgeSync(group.id, url); }, 250); textureUrl.oninput = function (event) { // Add throttle var url = event.target.value; imageLoad(url); + self.webBridgeSync(group.id, url); }; textureUrl.onchange = textureUrl.oninput; textureImage.appendChild(image); From 903762b122278e56ec247ec21c80b019cb1f08e3 Mon Sep 17 00:00:00 2001 From: Menithal Date: Thu, 21 Jun 2018 00:17:55 +0300 Subject: [PATCH 3/4] Make sure max constraints reset This now occurs when selecting a new entity and having the UI filled again --- .../particle_explorer/hifi-entity-ui.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/scripts/system/particle_explorer/hifi-entity-ui.js b/scripts/system/particle_explorer/hifi-entity-ui.js index 63defea6ea..1f2af50ff7 100644 --- a/scripts/system/particle_explorer/hifi-entity-ui.js +++ b/scripts/system/particle_explorer/hifi-entity-ui.js @@ -151,7 +151,7 @@ HifiEntityUI.prototype = { json[key] = document.getElementById(key).value; } } - + return json; }, @@ -159,12 +159,18 @@ HifiEntityUI.prototype = { var self = this; var fields = document.getElementsByTagName("input"); + console.log("Locking Settings Update while filling input Fields."); self.settingsUpdateLock = true; if (!currentProperties.locked) { for (var i = 0; i < fields.length; i++) { fields[i].removeAttribute("disabled"); + if (fields[i].hasAttribute("data-max")) { + // Reset Max to original max + fields[i].setAttribute("max", fields[i].getAttribute("data-max")); + } } } + if (self.onSelect) { self.onSelect(); } @@ -230,8 +236,11 @@ HifiEntityUI.prototype = { } } } - - self.settingsUpdateLock = false; + // Now unlocking settings Update lock for sending messages on callbacks. + setTimeout(function () { + console.log("Unlocking UI"); + self.settingsUpdateLock = false; + }, 50); }, connect: function (EventBridge) { this.EventBridge = EventBridge; @@ -297,7 +306,7 @@ HifiEntityUI.prototype = { title.innerHTML = section; title.appendChild(dropDown); sectionDivHeader.appendChild(title); - + var collapsed = index !== 0; dropDown.innerHTML = collapsed ? "L" : "M"; @@ -565,6 +574,7 @@ HifiEntityUI.prototype = { slider.setAttribute("min", group.min !== undefined ? group.min : 0); slider.setAttribute("max", group.max !== undefined ? group.max : 10000); + slider.setAttribute("data-max", group.max !== undefined ? group.max : 10000); slider.setAttribute("step", 1); inputField.oninput = function (event) { @@ -620,6 +630,7 @@ HifiEntityUI.prototype = { slider.setAttribute("min", group.min !== undefined ? group.min : 0); slider.setAttribute("max", group.max !== undefined ? group.max : 1); + slider.setAttribute("data-max", group.max !== undefined ? group.max : 1); slider.setAttribute("step", 0.01); inputField.oninput = function (event) { From 55e75298bd88ed54dbdca76236d01bf4cdcee3d6 Mon Sep 17 00:00:00 2001 From: Menithal Date: Thu, 21 Jun 2018 01:24:32 +0300 Subject: [PATCH 4/4] Added Logging --- scripts/system/particle_explorer/hifi-entity-ui.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/system/particle_explorer/hifi-entity-ui.js b/scripts/system/particle_explorer/hifi-entity-ui.js index 1f2af50ff7..6ad3ed011c 100644 --- a/scripts/system/particle_explorer/hifi-entity-ui.js +++ b/scripts/system/particle_explorer/hifi-entity-ui.js @@ -58,12 +58,12 @@ var roundFloat = function (input, round) { function HifiEntityUI(parent) { this.parent = parent; - + console.log("Creating a new Entity UI instance!"); var self = this; this.settingsUpdateLock = false; this.webBridgeSync = _.debounce(function (id, val) { - console.log(id + " " + val + " " + self.webBridgeSync); if (self.EventBridge && !self.settingsUpdateLock) { + console.log(id + " " + val + " " + self.webBridgeSync); var sendPackage = {}; sendPackage[id] = val; self.submitChanges(sendPackage); @@ -276,6 +276,7 @@ HifiEntityUI.prototype = { if (!currentProperties.colorFinish || !currentProperties.colorFinish.red) { currentProperties.colorFinish = currentProperties.color; } + console.log("Got ScriptEvent particle_settings", data); self.fillFields(currentProperties); // Do expected property match with structure; } else if (data.messageType === 'particle_close') { @@ -284,6 +285,7 @@ HifiEntityUI.prototype = { }); }, build: function () { + console.log("Building UI Anew"); var self = this; var sections = Object.keys(this.structure); this.builtRows = {};