From 2896c32bda0058aa2f242d604525ba05e5c6c6ec Mon Sep 17 00:00:00 2001 From: Olivier Prat Date: Mon, 5 Feb 2018 17:49:31 +0100 Subject: [PATCH 1/6] Switched debug fade script to app but still working on broken layout --- .../developer/utilities/render/debugFade.js | 83 +++- scripts/developer/utilities/render/fade.qml | 438 +++++++++--------- 2 files changed, 293 insertions(+), 228 deletions(-) diff --git a/scripts/developer/utilities/render/debugFade.js b/scripts/developer/utilities/render/debugFade.js index b01c4b5e1f..d20d5a70cf 100644 --- a/scripts/developer/utilities/render/debugFade.js +++ b/scripts/developer/utilities/render/debugFade.js @@ -1,3 +1,5 @@ +"use strict"; + // // debugFade.js // developer/utilities/render @@ -9,13 +11,74 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // -// Set up the qml ui -var qml = Script.resolvePath('fade.qml'); -var window = new OverlayWindow({ - title: 'Fade', - source: qml, - width: 910, - height: 610, -}); -window.setPosition(50, 50); -window.closed.connect(function() { Script.stop(); }); +(function() { + var TABLET_BUTTON_NAME = "Fade"; + var QMLAPP_URL = Script.resolvePath("./fade.qml"); + var ICON_URL = Script.resolvePath("../../../system/assets/images/fade-i.svg"); + var ACTIVE_ICON_URL = Script.resolvePath("../../../system/assets/images/fade-a.svg"); + + + var onScreen = false; + + function onClicked() { + if (onScreen) { + tablet.gotoHomeScreen(); + } else { + tablet.loadQMLSource(QMLAPP_URL); + } + } + + var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system"); + var button = tablet.addButton({ + text: TABLET_BUTTON_NAME, + icon: ICON_URL, + activeIcon: ACTIVE_ICON_URL + }); + + var hasEventBridge = false; + + function wireEventBridge(on) { + if (!tablet) { + print("Warning in wireEventBridge(): 'tablet' undefined!"); + return; + } + if (on) { + if (!hasEventBridge) { + tablet.fromQml.connect(fromQml); + hasEventBridge = true; + } + } else { + if (hasEventBridge) { + tablet.fromQml.disconnect(fromQml); + hasEventBridge = false; + } + } + } + + function onScreenChanged(type, url) { + if (url === QMLAPP_URL) { + onScreen = true; + } else { + onScreen = false; + } + + button.editProperties({isActive: onScreen}); + wireEventBridge(onScreen); + } + + function fromQml(message) { + } + + button.clicked.connect(onClicked); + tablet.screenChanged.connect(onScreenChanged); + + Script.scriptEnding.connect(function () { + if (onScreen) { + tablet.gotoHomeScreen(); + } + button.clicked.disconnect(onClicked); + tablet.screenChanged.disconnect(onScreenChanged); + tablet.removeButton(button); + }); + +}()); \ No newline at end of file diff --git a/scripts/developer/utilities/render/fade.qml b/scripts/developer/utilities/render/fade.qml index 1dffd0fbbb..48e2cf6856 100644 --- a/scripts/developer/utilities/render/fade.qml +++ b/scripts/developer/utilities/render/fade.qml @@ -8,169 +8,176 @@ // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or https://www.apache.org/licenses/LICENSE-2.0.html // -import QtQuick 2.5 +import QtQuick 2.7 import QtQuick.Controls 1.4 -import "configSlider" +import QtQuick.Layouts 1.3 + +import "qrc:///qml/styles-uit" +import "qrc:///qml/controls-uit" as HifiControls +import "configSlider" import "../lib/plotperf" -Column { +Rectangle { + HifiConstants { id: hifi;} id: root + anchors.margins: hifi.dimensions.contentMargin.x + + color: hifi.colors.baseGray; + property var config: Render.getConfig("RenderMainView.Fade"); property var configEdit: Render.getConfig("RenderMainView.FadeEdit"); - spacing: 8 - Row { - spacing: 8 + Column { + spacing: 5 + anchors.left: parent.left + anchors.right: parent.right + anchors.margins: hifi.dimensions.contentMargin.x + HifiControls.Label { + text: "Fade" + } - CheckBox { - text: "Edit Fade" - checked: root.configEdit["editFade"] - onCheckedChanged: { - root.configEdit["editFade"] = checked; - Render.getConfig("RenderMainView.DrawFadedOpaqueBounds").enabled = checked; + Row { + anchors.left: parent.left + anchors.right: parent.right + spacing: 20 + + HifiControls.CheckBox { + boxSize: 20 + text: "Edit" + checked: root.configEdit["editFade"] + onCheckedChanged: { + root.configEdit["editFade"] = checked; + Render.getConfig("RenderMainView.DrawFadedOpaqueBounds").enabled = checked; + } + } + HifiControls.ComboBox { + id: categoryBox + width: 260 + model: ["Elements enter/leave domain", "Bubble isect. - Owner POV", "Bubble isect. - Trespasser POV", "Another user leaves/arrives", "Changing an avatar"] + Timer { + id: postpone + interval: 100; running: false; repeat: false + onTriggered: { paramWidgetLoader.sourceComponent = paramWidgets } + } + onCurrentIndexChanged: { + root.config["editedCategory"] = currentIndex; + // This is a hack to be sure the widgets below properly reflect the change of category: delete the Component + // by setting the loader source to Null and then recreate it 100ms later + paramWidgetLoader.sourceComponent = undefined; + postpone.interval = 100 + postpone.start() + } + } + HifiControls.CheckBox { + boxSize: 20 + text: "Manual" + checked: root.config["manualFade"] + onCheckedChanged: { + root.config["manualFade"] = checked; + } } } - ComboBox { - id: categoryBox - width: 400 - model: ["Elements enter/leave domain", "Bubble isect. - Owner POV", "Bubble isect. - Trespasser POV", "Another user leaves/arrives", "Changing an avatar"] - Timer { - id: postpone - interval: 100; running: false; repeat: false - onTriggered: { paramWidgetLoader.sourceComponent = paramWidgets } - } - onCurrentIndexChanged: { - root.config["editedCategory"] = currentIndex; - // This is a hack to be sure the widgets below properly reflect the change of category: delete the Component - // by setting the loader source to Null and then recreate it 100ms later - paramWidgetLoader.sourceComponent = undefined; - postpone.interval = 100 - postpone.start() - } - } - } - Row { - spacing: 8 - CheckBox { - text: "Manual" - checked: root.config["manualFade"] - onCheckedChanged: { - root.config["manualFade"] = checked; - } - } ConfigSlider { + height: 35 label: "Threshold" integral: false config: root.config property: "manualThreshold" max: 1.0 min: 0.0 - width: 400 + anchors.left: parent.left + anchors.right: parent.right } - } - - Action { - id: saveAction - text: "Save" - onTriggered: { - root.config.save() - } - } - Action { - id: loadAction - text: "Load" - onTriggered: { - root.config.load() - // This is a hack to be sure the widgets below properly reflect the change of category: delete the Component - // by setting the loader source to Null and then recreate it 500ms later - paramWidgetLoader.sourceComponent = undefined; - postpone.interval = 500 - postpone.start() - } - } - - Component { - id: paramWidgets - - Column { - spacing: 8 - - CheckBox { - text: "Invert" - checked: root.config["isInverted"] - onCheckedChanged: { root.config["isInverted"] = checked } + + Action { + id: saveAction + text: "Save" + onTriggered: { + root.config.save() } - Row { - spacing: 8 + } + Action { + id: loadAction + text: "Load" + onTriggered: { + root.config.load() + // This is a hack to be sure the widgets below properly reflect the change of category: delete the Component + // by setting the loader source to Null and then recreate it 500ms later + paramWidgetLoader.sourceComponent = undefined; + postpone.interval = 500 + postpone.start() + } + } + + Component { + id: paramWidgets + + Column { + anchors.left: parent.left + anchors.right: parent.right + spacing: 10 + + HifiControls.CheckBox { + text: "Invert" + checked: root.config["isInverted"] + onCheckedChanged: { root.config["isInverted"] = checked } + } GroupBox { title: "Base Gradient" - width: 450 + anchors.left: parent.left + anchors.right: parent.right + Column { spacing: 8 + anchors.left: parent.left + anchors.right: parent.right - ConfigSlider { - label: "Size X" - integral: false - config: root.config - property: "baseSizeX" - max: 1.0 - min: 0.0 - width: 400 - } - ConfigSlider { - label: "Size Y" - integral: false - config: root.config - property: "baseSizeY" - max: 1.0 - min: 0.0 - width: 400 - } - ConfigSlider { - label: "Size Z" - integral: false - config: root.config - property: "baseSizeZ" - max: 1.0 - min: 0.0 - width: 400 - } - ConfigSlider { - label: "Level" - integral: false - config: root.config - property: "baseLevel" - max: 1.0 - min: 0.0 - width: 400 + Repeater { + model: [ + "Size X:baseSizeX", + "Size Y:baseSizeY", + "Size Z:baseSizeZ", + "Level:baseLevel" ] + + ConfigSlider { + height: 35 + label: modelData.split(":")[0] + integral: false + config: root.config + property: modelData.split(":")[1] + max: 1.0 + min: 0.0 + } } } } GroupBox { title: "Noise Gradient" - width: 450 + Column { spacing: 8 + anchors.left: parent.left + anchors.right: parent.right ConfigSlider { + height: 35 label: "Size X" integral: false config: root.config property: "noiseSizeX" max: 1.0 min: 0.0 - width: 400 } ConfigSlider { + height: 35 label: "Size Y" integral: false config: root.config property: "noiseSizeY" max: 1.0 min: 0.0 - width: 400 } ConfigSlider { label: "Size Z" @@ -179,7 +186,6 @@ Column { property: "noiseSizeZ" max: 1.0 min: 0.0 - width: 400 } ConfigSlider { label: "Level" @@ -188,19 +194,15 @@ Column { property: "noiseLevel" max: 1.0 min: 0.0 - width: 400 } } } - } - Row { - spacing: 8 - GroupBox { title: "Edge" - width: 450 + Column { - spacing: 8 + anchors.left: parent.left + anchors.right: parent.right ConfigSlider { label: "Width" @@ -209,12 +211,13 @@ Column { property: "edgeWidth" max: 1.0 min: 0.0 - width: 400 } GroupBox { title: "Inner color" Column { - spacing: 8 + anchors.left: parent.left + anchors.right: parent.right + ConfigSlider { label: "Color R" integral: false @@ -222,7 +225,6 @@ Column { property: "edgeInnerColorR" max: 1.0 min: 0.0 - width: 400 } ConfigSlider { label: "Color G" @@ -231,7 +233,6 @@ Column { property: "edgeInnerColorG" max: 1.0 min: 0.0 - width: 400 } ConfigSlider { label: "Color B" @@ -240,7 +241,6 @@ Column { property: "edgeInnerColorB" max: 1.0 min: 0.0 - width: 400 } ConfigSlider { label: "Color intensity" @@ -249,14 +249,15 @@ Column { property: "edgeInnerIntensity" max: 5.0 min: 0.0 - width: 400 } } } GroupBox { title: "Outer color" Column { - spacing: 8 + anchors.left: parent.left + anchors.right: parent.right + ConfigSlider { label: "Color R" integral: false @@ -264,7 +265,6 @@ Column { property: "edgeOuterColorR" max: 1.0 min: 0.0 - width: 400 } ConfigSlider { label: "Color G" @@ -273,7 +273,6 @@ Column { property: "edgeOuterColorG" max: 1.0 min: 0.0 - width: 400 } ConfigSlider { label: "Color B" @@ -282,7 +281,6 @@ Column { property: "edgeOuterColorB" max: 1.0 min: 0.0 - width: 400 } ConfigSlider { label: "Color intensity" @@ -291,107 +289,111 @@ Column { property: "edgeOuterIntensity" max: 5.0 min: 0.0 - width: 400 } } } } } - Column { - GroupBox { - title: "Timing" - width: 450 - Column { - spacing: 8 + GroupBox { + title: "Timing" - ConfigSlider { - label: "Duration" - integral: false - config: root.config - property: "duration" - max: 10.0 - min: 0.1 - width: 400 + Column { + anchors.left: parent.left + anchors.right: parent.right + + ConfigSlider { + label: "Duration" + integral: false + config: root.config + property: "duration" + max: 10.0 + min: 0.1 + } + HifiControls.ComboBox { + width: 200 + model: ["Linear", "Ease In", "Ease Out", "Ease In / Out"] + currentIndex: root.config["timing"] + onCurrentIndexChanged: { + root.config["timing"] = currentIndex; } - ComboBox { - width: 400 - model: ["Linear", "Ease In", "Ease Out", "Ease In / Out"] - currentIndex: root.config["timing"] - onCurrentIndexChanged: { - root.config["timing"] = currentIndex; + } + GroupBox { + title: "Noise Animation" + Column { + anchors.left: parent.left + anchors.right: parent.right + + ConfigSlider { + label: "Speed X" + integral: false + config: root.config + property: "noiseSpeedX" + max: 1.0 + min: -1.0 + } + ConfigSlider { + label: "Speed Y" + integral: false + config: root.config + property: "noiseSpeedY" + max: 1.0 + min: -1.0 + } + ConfigSlider { + label: "Speed Z" + integral: false + config: root.config + property: "noiseSpeedZ" + max: 1.0 + min: -1.0 } } - GroupBox { - title: "Noise Animation" - Column { - spacing: 8 - ConfigSlider { - label: "Speed X" - integral: false - config: root.config - property: "noiseSpeedX" - max: 1.0 - min: -1.0 - width: 400 - } - ConfigSlider { - label: "Speed Y" - integral: false - config: root.config - property: "noiseSpeedY" - max: 1.0 - min: -1.0 - width: 400 - } - ConfigSlider { - label: "Speed Z" - integral: false - config: root.config - property: "noiseSpeedZ" - max: 1.0 - min: -1.0 - width: 400 - } + } + + PlotPerf { + title: "Threshold" + height: parent.evalEvenHeight() + object: config + valueUnit: "%" + valueScale: 0.01 + valueNumDigits: "1" + plots: [ + { + prop: "threshold", + label: "Threshold", + color: "#FFBB77" } - } - - PlotPerf { - title: "Threshold" - height: parent.evalEvenHeight() - object: config - valueUnit: "%" - valueScale: 0.01 - valueNumDigits: "1" - plots: [ - { - prop: "threshold", - label: "Threshold", - color: "#FFBB77" - } - ] - } - + ] } + } - - Row { - spacing: 8 - Button { - action: saveAction - } - Button { - action: loadAction - } - } - } + } } - } - Loader { - id: paramWidgetLoader - sourceComponent: paramWidgets + + + + Loader { + id: paramWidgetLoader + sourceComponent: paramWidgets + } + + Row { + anchors.left: parent.left + anchors.right: parent.right + + Button { + action: saveAction + } + Button { + action: loadAction + } + } + + + } -} +} \ No newline at end of file From 51ea89ffea08e79483eb94b375509edd0e05c895 Mon Sep 17 00:00:00 2001 From: Olivier Prat Date: Tue, 6 Feb 2018 15:16:50 +0100 Subject: [PATCH 2/6] Renamed fade scripts to transition scripts and still working on layout --- .../{debugFade.js => debugTransition.js} | 10 +- .../render/{fade.qml => transition.qml} | 311 ++++++++---------- 2 files changed, 150 insertions(+), 171 deletions(-) rename scripts/developer/utilities/render/{debugFade.js => debugTransition.js} (91%) rename scripts/developer/utilities/render/{fade.qml => transition.qml} (56%) diff --git a/scripts/developer/utilities/render/debugFade.js b/scripts/developer/utilities/render/debugTransition.js similarity index 91% rename from scripts/developer/utilities/render/debugFade.js rename to scripts/developer/utilities/render/debugTransition.js index d20d5a70cf..161ff3f5d4 100644 --- a/scripts/developer/utilities/render/debugFade.js +++ b/scripts/developer/utilities/render/debugTransition.js @@ -1,7 +1,7 @@ "use strict"; // -// debugFade.js +// debugTransition.js // developer/utilities/render // // Olivier Prat, created on 30/04/2017. @@ -12,10 +12,10 @@ // (function() { - var TABLET_BUTTON_NAME = "Fade"; - var QMLAPP_URL = Script.resolvePath("./fade.qml"); - var ICON_URL = Script.resolvePath("../../../system/assets/images/fade-i.svg"); - var ACTIVE_ICON_URL = Script.resolvePath("../../../system/assets/images/fade-a.svg"); + var TABLET_BUTTON_NAME = "Transition"; + var QMLAPP_URL = Script.resolvePath("./transition.qml"); + var ICON_URL = Script.resolvePath("../../../system/assets/images/transition-i.svg"); + var ACTIVE_ICON_URL = Script.resolvePath("../../../system/assets/images/transition-a.svg"); var onScreen = false; diff --git a/scripts/developer/utilities/render/fade.qml b/scripts/developer/utilities/render/transition.qml similarity index 56% rename from scripts/developer/utilities/render/fade.qml rename to scripts/developer/utilities/render/transition.qml index 48e2cf6856..5f48c69daf 100644 --- a/scripts/developer/utilities/render/fade.qml +++ b/scripts/developer/utilities/render/transition.qml @@ -1,5 +1,5 @@ // -// fade.qml +// transition.qml // developer/utilities/render // // Olivier Prat, created on 30/04/2017. @@ -27,21 +27,21 @@ Rectangle { property var config: Render.getConfig("RenderMainView.Fade"); property var configEdit: Render.getConfig("RenderMainView.FadeEdit"); - Column { + ColumnLayout { spacing: 5 - anchors.left: parent.left - anchors.right: parent.right + anchors.fill: parent anchors.margins: hifi.dimensions.contentMargin.x HifiControls.Label { - text: "Fade" + text: "Transition" } - Row { - anchors.left: parent.left - anchors.right: parent.right + RowLayout { spacing: 20 + Layout.fillWidth: true + id: root_col HifiControls.CheckBox { + anchors.verticalCenter: parent.verticalCenter boxSize: 20 text: "Edit" checked: root.configEdit["editFade"] @@ -51,13 +51,16 @@ Rectangle { } } HifiControls.ComboBox { + anchors.verticalCenter: parent.verticalCenter + Layout.fillWidth: true id: categoryBox - width: 260 model: ["Elements enter/leave domain", "Bubble isect. - Owner POV", "Bubble isect. - Trespasser POV", "Another user leaves/arrives", "Changing an avatar"] Timer { id: postpone interval: 100; running: false; repeat: false - onTriggered: { paramWidgetLoader.sourceComponent = paramWidgets } + onTriggered: { + paramWidgetLoader.sourceComponent = paramWidgets + } } onCurrentIndexChanged: { root.config["editedCategory"] = currentIndex; @@ -68,26 +71,32 @@ Rectangle { postpone.start() } } + } + + RowLayout { + spacing: 20 + height: 38 HifiControls.CheckBox { boxSize: 20 + anchors.verticalCenter: parent.verticalCenter text: "Manual" checked: root.config["manualFade"] onCheckedChanged: { root.config["manualFade"] = checked; } } - } - - ConfigSlider { - height: 35 - label: "Threshold" - integral: false - config: root.config - property: "manualThreshold" - max: 1.0 - min: 0.0 - anchors.left: parent.left - anchors.right: parent.right + ConfigSlider { + anchors.left: undefined + anchors.verticalCenter: parent.verticalCenter + height: 38 + width: 320 + label: "Threshold" + integral: false + config: root.config + property: "manualThreshold" + max: 1.0 + min: 0.0 + } } Action { @@ -110,101 +119,92 @@ Rectangle { } } + Separator {} Component { id: paramWidgets - Column { - anchors.left: parent.left - anchors.right: parent.right + ColumnLayout { spacing: 10 + width: root_col.width HifiControls.CheckBox { text: "Invert" + boxSize: 20 checked: root.config["isInverted"] onCheckedChanged: { root.config["isInverted"] = checked } } - GroupBox { - title: "Base Gradient" - anchors.left: parent.left - anchors.right: parent.right + RowLayout { + Layout.fillWidth: true - Column { - spacing: 8 - anchors.left: parent.left - anchors.right: parent.right + GroupBox { + title: "Base Gradient" + Layout.fillWidth: true - Repeater { - model: [ - "Size X:baseSizeX", - "Size Y:baseSizeY", - "Size Z:baseSizeZ", - "Level:baseLevel" ] + Column { + spacing: 8 + anchors.left: parent.left + anchors.right: parent.right - ConfigSlider { - height: 35 - label: modelData.split(":")[0] - integral: false - config: root.config - property: modelData.split(":")[1] - max: 1.0 - min: 0.0 + Repeater { + model: [ + "Size X:baseSizeX", + "Size Y:baseSizeY", + "Size Z:baseSizeZ", + "Level:baseLevel" ] + + ConfigSlider { + height: 38 + label: modelData.split(":")[0] + integral: false + config: root.config + property: modelData.split(":")[1] + max: 1.0 + min: 0.0 + } + } + } + } + GroupBox { + title: "Noise Gradient" + Layout.fillWidth: true + + Column { + spacing: 8 + anchors.left: parent.left + anchors.right: parent.right + + Repeater { + model: [ + "Size X:noiseSizeX", + "Size Y:noiseSizeY", + "Size Z:noiseSizeZ", + "Level:noiseLevel" ] + + ConfigSlider { + height: 38 + label: modelData.split(":")[0] + integral: false + config: root.config + property: modelData.split(":")[1] + max: 1.0 + min: 0.0 + } } } } } GroupBox { - title: "Noise Gradient" - + title: "Edge" + Layout.fillWidth: true + Column { spacing: 8 anchors.left: parent.left anchors.right: parent.right ConfigSlider { - height: 35 - label: "Size X" - integral: false - config: root.config - property: "noiseSizeX" - max: 1.0 - min: 0.0 - } - ConfigSlider { - height: 35 - label: "Size Y" - integral: false - config: root.config - property: "noiseSizeY" - max: 1.0 - min: 0.0 - } - ConfigSlider { - label: "Size Z" - integral: false - config: root.config - property: "noiseSizeZ" - max: 1.0 - min: 0.0 - } - ConfigSlider { - label: "Level" - integral: false - config: root.config - property: "noiseLevel" - max: 1.0 - min: 0.0 - } - } - } - GroupBox { - title: "Edge" - - Column { - anchors.left: parent.left - anchors.right: parent.right - - ConfigSlider { + height: 38 label: "Width" integral: false config: root.config @@ -212,83 +212,63 @@ Rectangle { max: 1.0 min: 0.0 } - GroupBox { - title: "Inner color" - Column { - anchors.left: parent.left - anchors.right: parent.right + Row { + spacing: 8 + anchors.left: parent.left + anchors.right: parent.right - ConfigSlider { - label: "Color R" - integral: false - config: root.config - property: "edgeInnerColorR" - max: 1.0 - min: 0.0 - } - ConfigSlider { - label: "Color G" - integral: false - config: root.config - property: "edgeInnerColorG" - max: 1.0 - min: 0.0 - } - ConfigSlider { - label: "Color B" - integral: false - config: root.config - property: "edgeInnerColorB" - max: 1.0 - min: 0.0 - } - ConfigSlider { - label: "Color intensity" - integral: false - config: root.config - property: "edgeInnerIntensity" - max: 5.0 - min: 0.0 + GroupBox { + title: "Inner color" + Layout.fillWidth: true + + Column { + anchors.left: parent.left + anchors.right: parent.right + + Repeater { + model: [ + "Color R:edgeInnerColorR", + "Color G:edgeInnerColorG", + "Color B:edgeInnerColorB", + "Color intensity:edgeInnerIntensity" ] + + ConfigSlider { + height: 38 + label: modelData.split(":")[0] + integral: false + config: root.config + property: modelData.split(":")[1] + max: 1.0 + min: 0.0 + } + } } } - } - GroupBox { - title: "Outer color" - Column { - anchors.left: parent.left - anchors.right: parent.right + GroupBox { + title: "Outer color" + Layout.fillWidth: true - ConfigSlider { - label: "Color R" - integral: false - config: root.config - property: "edgeOuterColorR" - max: 1.0 - min: 0.0 - } - ConfigSlider { - label: "Color G" - integral: false - config: root.config - property: "edgeOuterColorG" - max: 1.0 - min: 0.0 - } - ConfigSlider { - label: "Color B" - integral: false - config: root.config - property: "edgeOuterColorB" - max: 1.0 - min: 0.0 - } - ConfigSlider { - label: "Color intensity" - integral: false - config: root.config - property: "edgeOuterIntensity" - max: 5.0 - min: 0.0 + Column { + anchors.left: parent.left + anchors.right: parent.right + + Repeater { + model: [ + "Color R:edgeOuterColorR", + "Color G:edgeOuterColorG", + "Color B:edgeOuterColorB", + "Color intensity:edgeOuterIntensity" ] + + ConfigSlider { + height: 38 + label: modelData.split(":")[0] + integral: false + config: root.config + property: modelData.split(":")[1] + max: 1.0 + min: 0.0 + } + } } } } @@ -375,7 +355,6 @@ Rectangle { - Loader { id: paramWidgetLoader sourceComponent: paramWidgets From 8c12ab9b76ec20f907e1b3544184e76e2be646ba Mon Sep 17 00:00:00 2001 From: Olivier Prat Date: Tue, 6 Feb 2018 16:19:15 +0100 Subject: [PATCH 3/6] Used color selectors in transition.qml --- .../developer/utilities/render/transition.qml | 264 +++++++++--------- 1 file changed, 133 insertions(+), 131 deletions(-) diff --git a/scripts/developer/utilities/render/transition.qml b/scripts/developer/utilities/render/transition.qml index 5f48c69daf..36cab7688c 100644 --- a/scripts/developer/utilities/render/transition.qml +++ b/scripts/developer/utilities/render/transition.qml @@ -28,8 +28,9 @@ Rectangle { property var configEdit: Render.getConfig("RenderMainView.FadeEdit"); ColumnLayout { - spacing: 5 - anchors.fill: parent + spacing: 3 + anchors.left: parent.left + anchors.right: parent.right anchors.margins: hifi.dimensions.contentMargin.x HifiControls.Label { text: "Transition" @@ -75,7 +76,7 @@ Rectangle { RowLayout { spacing: 20 - height: 38 + height: 36 HifiControls.CheckBox { boxSize: 20 anchors.verticalCenter: parent.verticalCenter @@ -88,7 +89,7 @@ Rectangle { ConfigSlider { anchors.left: undefined anchors.verticalCenter: parent.verticalCenter - height: 38 + height: 36 width: 320 label: "Threshold" integral: false @@ -125,7 +126,7 @@ Rectangle { id: paramWidgets ColumnLayout { - spacing: 10 + spacing: 3 width: root_col.width HifiControls.CheckBox { @@ -142,7 +143,7 @@ Rectangle { Layout.fillWidth: true Column { - spacing: 8 + spacing: 3 anchors.left: parent.left anchors.right: parent.right @@ -154,7 +155,7 @@ Rectangle { "Level:baseLevel" ] ConfigSlider { - height: 38 + height: 36 label: modelData.split(":")[0] integral: false config: root.config @@ -170,7 +171,7 @@ Rectangle { Layout.fillWidth: true Column { - spacing: 8 + spacing: 3 anchors.left: parent.left anchors.right: parent.right @@ -182,7 +183,7 @@ Rectangle { "Level:noiseLevel" ] ConfigSlider { - height: 38 + height: 36 label: modelData.split(":")[0] integral: false config: root.config @@ -194,58 +195,118 @@ Rectangle { } } } - GroupBox { - title: "Edge" + + + ConfigSlider { + height: 36 + label: "Edge Width" + integral: false + config: root.config + property: "edgeWidth" + max: 1.0 + min: 0.0 + } + RowLayout { Layout.fillWidth: true - Column { - spacing: 8 - anchors.left: parent.left - anchors.right: parent.right + GroupBox { + title: "Edge Inner color" + Layout.fillWidth: true - ConfigSlider { - height: 38 - label: "Width" - integral: false - config: root.config - property: "edgeWidth" - max: 1.0 - min: 0.0 - } - Row { - spacing: 8 + Column { anchors.left: parent.left anchors.right: parent.right - GroupBox { - title: "Inner color" - Layout.fillWidth: true - - Column { - anchors.left: parent.left - anchors.right: parent.right - - Repeater { - model: [ - "Color R:edgeInnerColorR", - "Color G:edgeInnerColorG", - "Color B:edgeInnerColorB", - "Color intensity:edgeInnerIntensity" ] - - ConfigSlider { - height: 38 - label: modelData.split(":")[0] - integral: false - config: root.config - property: modelData.split(":")[1] - max: 1.0 - min: 0.0 - } - } + Color { + height: 30 + anchors.left: parent.left + anchors.right: parent.right + _color: Qt.rgba(root.config.edgeInnerColorR, root.config.edgeInnerColorG, root.config.edgeInnerColorB, 1.0) + onNewColor: { + root.config.edgeInnerColorR = _color.red + root.config.edgeInnerColorG = _color.green + root.config.edgeInnerColorB = _color.blue } } + ConfigSlider { + height: 36 + label: "Intensity" + integral: false + config: root.config + property: "edgeInnerIntensity" + max: 1.0 + min: 0.0 + } + } + } + GroupBox { + title: "Edge Outer color" + Layout.fillWidth: true + + Column { + anchors.left: parent.left + anchors.right: parent.right + + Color { + height: 30 + anchors.left: parent.left + anchors.right: parent.right + _color: Qt.rgba(root.config.edgeOuterColorR, root.config.edgeOuterColorG, root.config.edgeOuterColorB, 1.0) + onNewColor: { + root.config.edgeOuterColorR = _color.red + root.config.edgeOuterColorG = _color.green + root.config.edgeOuterColorB = _color.blue + } + } + ConfigSlider { + height: 36 + label: "Intensity" + integral: false + config: root.config + property: "edgeOuterIntensity" + max: 1.0 + min: 0.0 + } + } + } + } + GroupBox { + title: "Timing" + Layout.fillWidth: true + + ColumnLayout { + anchors.left: parent.left + anchors.right: parent.right + + RowLayout { + Layout.fillWidth: true + + ConfigSlider { + anchors.left: undefined + anchors.right: undefined + Layout.fillWidth: true + height: 36 + label: "Duration" + integral: false + config: root.config + property: "duration" + max: 10.0 + min: 0.1 + } + HifiControls.ComboBox { + Layout.fillWidth: true + model: ["Linear", "Ease In", "Ease Out", "Ease In / Out"] + currentIndex: root.config["timing"] + onCurrentIndexChanged: { + root.config["timing"] = currentIndex; + } + } + } + RowLayout { + Layout.fillWidth: true + GroupBox { - title: "Outer color" + title: "Noise Animation" Layout.fillWidth: true Column { @@ -254,99 +315,40 @@ Rectangle { Repeater { model: [ - "Color R:edgeOuterColorR", - "Color G:edgeOuterColorG", - "Color B:edgeOuterColorB", - "Color intensity:edgeOuterIntensity" ] + "Speed X:noiseSpeedX", + "Speed Y:noiseSpeedY", + "Speed Z:noiseSpeedZ" ] ConfigSlider { - height: 38 + height: 36 label: modelData.split(":")[0] integral: false config: root.config property: modelData.split(":")[1] max: 1.0 - min: 0.0 + min: -1.0 } } } } - } - } - } - GroupBox { - title: "Timing" - - Column { - anchors.left: parent.left - anchors.right: parent.right - - ConfigSlider { - label: "Duration" - integral: false - config: root.config - property: "duration" - max: 10.0 - min: 0.1 - } - HifiControls.ComboBox { - width: 200 - model: ["Linear", "Ease In", "Ease Out", "Ease In / Out"] - currentIndex: root.config["timing"] - onCurrentIndexChanged: { - root.config["timing"] = currentIndex; + PlotPerf { + title: "Threshold" + Layout.fillWidth: true + height: parent.evalEvenHeight() + object: config + valueUnit: "%" + valueScale: 0.01 + valueNumDigits: "1" + plots: [ + { + prop: "threshold", + label: "Threshold", + color: "#FFBB77" + } + ] } } - GroupBox { - title: "Noise Animation" - Column { - anchors.left: parent.left - anchors.right: parent.right - - ConfigSlider { - label: "Speed X" - integral: false - config: root.config - property: "noiseSpeedX" - max: 1.0 - min: -1.0 - } - ConfigSlider { - label: "Speed Y" - integral: false - config: root.config - property: "noiseSpeedY" - max: 1.0 - min: -1.0 - } - ConfigSlider { - label: "Speed Z" - integral: false - config: root.config - property: "noiseSpeedZ" - max: 1.0 - min: -1.0 - } - } - } - - PlotPerf { - title: "Threshold" - height: parent.evalEvenHeight() - object: config - valueUnit: "%" - valueScale: 0.01 - valueNumDigits: "1" - plots: [ - { - prop: "threshold", - label: "Threshold", - color: "#FFBB77" - } - ] - } - } } From fc1d9319bd6eb777af136d9245a9feab114db223 Mon Sep 17 00:00:00 2001 From: Olivier Prat Date: Tue, 6 Feb 2018 16:31:53 +0100 Subject: [PATCH 4/6] Finished correcting transition.qml layouts --- scripts/developer/utilities/render/transition.qml | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/scripts/developer/utilities/render/transition.qml b/scripts/developer/utilities/render/transition.qml index 36cab7688c..de59d32df2 100644 --- a/scripts/developer/utilities/render/transition.qml +++ b/scripts/developer/utilities/render/transition.qml @@ -305,9 +305,15 @@ Rectangle { RowLayout { Layout.fillWidth: true + function evalEvenHeight() { + // Why do we have to do that manually ? cannot seem to find a qml / anchor / layout mode that does that ? + return (height - spacing * (children.length - 1)) / children.length + } + GroupBox { title: "Noise Animation" Layout.fillWidth: true + id: animBox Column { anchors.left: parent.left @@ -334,9 +340,10 @@ Rectangle { PlotPerf { title: "Threshold" - Layout.fillWidth: true - height: parent.evalEvenHeight() - object: config + width: 200 + anchors.top: animBox.top + anchors.bottom : animBox.bottom + object: root.config valueUnit: "%" valueScale: 0.01 valueNumDigits: "1" From 733d36df473aa73c4f81d42537a312032a41840b Mon Sep 17 00:00:00 2001 From: Olivier Prat Date: Tue, 6 Feb 2018 17:57:04 +0100 Subject: [PATCH 5/6] Fixed save / load of fade effect configurations --- libraries/render-utils/src/FadeEffectJobs.cpp | 96 +++++++++---------- libraries/render-utils/src/FadeEffectJobs.h | 28 ++---- .../developer/utilities/render/transition.qml | 12 +-- 3 files changed, 58 insertions(+), 78 deletions(-) diff --git a/libraries/render-utils/src/FadeEffectJobs.cpp b/libraries/render-utils/src/FadeEffectJobs.cpp index d00632c017..da3f8dddc0 100644 --- a/libraries/render-utils/src/FadeEffectJobs.cpp +++ b/libraries/render-utils/src/FadeEffectJobs.cpp @@ -297,19 +297,20 @@ float FadeConfig::getEdgeWidth() const { return sqrtf(events[editedCategory].edgeWidth); } -void FadeConfig::setEdgeInnerColorR(float value) { - events[editedCategory].edgeInnerColor.r = value; +void FadeConfig::setEdgeInnerColor(const QColor& value) { + events[editedCategory].edgeInnerColor.r = value.redF(); + events[editedCategory].edgeInnerColor.g = value.greenF(); + events[editedCategory].edgeInnerColor.b = value.blueF(); emit dirty(); } -void FadeConfig::setEdgeInnerColorG(float value) { - events[editedCategory].edgeInnerColor.g = value; - emit dirty(); -} - -void FadeConfig::setEdgeInnerColorB(float value) { - events[editedCategory].edgeInnerColor.b = value; - emit dirty(); +QColor FadeConfig::getEdgeInnerColor() const { + QColor color; + color.setRedF(events[editedCategory].edgeInnerColor.r); + color.setGreenF(events[editedCategory].edgeInnerColor.g); + color.setBlueF(events[editedCategory].edgeInnerColor.b); + color.setAlphaF(1.0f); + return color; } void FadeConfig::setEdgeInnerIntensity(float value) { @@ -317,19 +318,20 @@ void FadeConfig::setEdgeInnerIntensity(float value) { emit dirty(); } -void FadeConfig::setEdgeOuterColorR(float value) { - events[editedCategory].edgeOuterColor.r = value; +void FadeConfig::setEdgeOuterColor(const QColor& value) { + events[editedCategory].edgeOuterColor.r = value.redF(); + events[editedCategory].edgeOuterColor.g = value.greenF(); + events[editedCategory].edgeOuterColor.b = value.blueF(); emit dirty(); } -void FadeConfig::setEdgeOuterColorG(float value) { - events[editedCategory].edgeOuterColor.g = value; - emit dirty(); -} - -void FadeConfig::setEdgeOuterColorB(float value) { - events[editedCategory].edgeOuterColor.b = value; - emit dirty(); +QColor FadeConfig::getEdgeOuterColor() const { + QColor color; + color.setRedF(events[editedCategory].edgeOuterColor.r); + color.setGreenF(events[editedCategory].edgeOuterColor.g); + color.setBlueF(events[editedCategory].edgeOuterColor.b); + color.setAlphaF(1.0f); + return color; } void FadeConfig::setEdgeOuterIntensity(float value) { @@ -352,13 +354,13 @@ QString FadeConfig::eventNames[FADE_CATEGORY_COUNT] = { }; void FadeConfig::save() const { + // Save will only work if the HIFI_USE_SOURCE_TREE_RESOURCES environment variable is set assert(editedCategory < FADE_CATEGORY_COUNT); QJsonObject lProperties; - const QString configFile = "config/" + eventNames[editedCategory] + ".json"; - QUrl path(PathUtils::resourcesPath() + configFile); - QFile file(path.toString()); + const QString configFilePath = PathUtils::resourcesPath() + "config/" + eventNames[editedCategory] + ".json"; + QFile file(configFilePath); if (!file.open(QFile::WriteOnly | QFile::Text)) { - qWarning() << "Fade event configuration file " << path << " cannot be opened"; + qWarning() << "Fade event configuration file " << configFilePath << " cannot be opened"; } else { const auto& event = events[editedCategory]; @@ -381,15 +383,13 @@ void FadeConfig::save() const { } void FadeConfig::load() { - const QString configFile = "config/" + eventNames[editedCategory] + ".json"; - - QUrl path(PathUtils::resourcesPath() + configFile); - QFile file(path.toString()); + const QString configFilePath = PathUtils::resourcesPath() + "config/" + eventNames[editedCategory] + ".json"; + QFile file(configFilePath); if (!file.exists()) { - qWarning() << "Fade event configuration file " << path << " does not exist"; + qWarning() << "Fade event configuration file " << configFilePath << " does not exist"; } else if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { - qWarning() << "Fade event configuration file " << path << " cannot be opened"; + qWarning() << "Fade event configuration file " << configFilePath << " cannot be opened"; } else { QString fileData = file.readAll(); @@ -401,14 +401,14 @@ void FadeConfig::load() { QJsonValue value; auto& event = events[editedCategory]; - qCDebug(renderlogging) << "Fade event configuration file" << path << "loaded"; + qCDebug(renderlogging) << "Fade event configuration file" << configFilePath << "loaded"; value = jsonObject["edgeInnerColor"]; if (value.isArray()) { QJsonArray data = value.toArray(); if (data.size() < 4) { - qWarning() << "Fade event configuration file " << path << " contains an invalid 'edgeInnerColor' field. Expected array of size 4"; + qWarning() << "Fade event configuration file " << configFilePath << " contains an invalid 'edgeInnerColor' field. Expected array of size 4"; } else { event.edgeInnerColor.r = (float)data.at(0).toDouble(); @@ -418,7 +418,7 @@ void FadeConfig::load() { } } else { - qWarning() << "Fade event configuration file " << path << " contains an invalid 'edgeInnerColor' field. Expected array of size 4"; + qWarning() << "Fade event configuration file " << configFilePath << " contains an invalid 'edgeInnerColor' field. Expected array of size 4"; } value = jsonObject["edgeOuterColor"]; @@ -426,7 +426,7 @@ void FadeConfig::load() { QJsonArray data = value.toArray(); if (data.size() < 4) { - qWarning() << "Fade event configuration file " << path << " contains an invalid 'edgeOuterColor' field. Expected array of size 4"; + qWarning() << "Fade event configuration file " << configFilePath << " contains an invalid 'edgeOuterColor' field. Expected array of size 4"; } else { event.edgeOuterColor.r = (float)data.at(0).toDouble(); @@ -436,7 +436,7 @@ void FadeConfig::load() { } } else { - qWarning() << "Fade event configuration file " << path << " contains an invalid 'edgeOuterColor' field. Expected array of size 4"; + qWarning() << "Fade event configuration file " << configFilePath << " contains an invalid 'edgeOuterColor' field. Expected array of size 4"; } value = jsonObject["noiseSize"]; @@ -444,7 +444,7 @@ void FadeConfig::load() { QJsonArray data = value.toArray(); if (data.size() < 3) { - qWarning() << "Fade event configuration file " << path << " contains an invalid 'noiseSize' field. Expected array of size 3"; + qWarning() << "Fade event configuration file " << configFilePath << " contains an invalid 'noiseSize' field. Expected array of size 3"; } else { event.noiseSize.x = (float)data.at(0).toDouble(); @@ -453,7 +453,7 @@ void FadeConfig::load() { } } else { - qWarning() << "Fade event configuration file " << path << " contains an invalid 'noiseSize' field. Expected array of size 3"; + qWarning() << "Fade event configuration file " << configFilePath << " contains an invalid 'noiseSize' field. Expected array of size 3"; } value = jsonObject["noiseSpeed"]; @@ -461,7 +461,7 @@ void FadeConfig::load() { QJsonArray data = value.toArray(); if (data.size() < 3) { - qWarning() << "Fade event configuration file " << path << " contains an invalid 'noiseSpeed' field. Expected array of size 3"; + qWarning() << "Fade event configuration file " << configFilePath << " contains an invalid 'noiseSpeed' field. Expected array of size 3"; } else { event.noiseSpeed.x = (float)data.at(0).toDouble(); @@ -470,7 +470,7 @@ void FadeConfig::load() { } } else { - qWarning() << "Fade event configuration file " << path << " contains an invalid 'noiseSpeed' field. Expected array of size 3"; + qWarning() << "Fade event configuration file " << configFilePath << " contains an invalid 'noiseSpeed' field. Expected array of size 3"; } value = jsonObject["baseSize"]; @@ -478,7 +478,7 @@ void FadeConfig::load() { QJsonArray data = value.toArray(); if (data.size() < 3) { - qWarning() << "Fade event configuration file " << path << " contains an invalid 'baseSize' field. Expected array of size 3"; + qWarning() << "Fade event configuration file " << configFilePath << " contains an invalid 'baseSize' field. Expected array of size 3"; } else { event.baseSize.x = (float)data.at(0).toDouble(); @@ -487,7 +487,7 @@ void FadeConfig::load() { } } else { - qWarning() << "Fade event configuration file " << path << " contains an invalid 'baseSize' field. Expected array of size 3"; + qWarning() << "Fade event configuration file " << configFilePath << " contains an invalid 'baseSize' field. Expected array of size 3"; } value = jsonObject["noiseLevel"]; @@ -495,7 +495,7 @@ void FadeConfig::load() { event.noiseLevel = (float)value.toDouble(); } else { - qWarning() << "Fade event configuration file " << path << " contains an invalid 'noiseLevel' field. Expected float value"; + qWarning() << "Fade event configuration file " << configFilePath << " contains an invalid 'noiseLevel' field. Expected float value"; } value = jsonObject["baseLevel"]; @@ -503,7 +503,7 @@ void FadeConfig::load() { event.baseLevel = (float)value.toDouble(); } else { - qWarning() << "Fade event configuration file " << path << " contains an invalid 'baseLevel' field. Expected float value"; + qWarning() << "Fade event configuration file " << configFilePath << " contains an invalid 'baseLevel' field. Expected float value"; } value = jsonObject["duration"]; @@ -511,7 +511,7 @@ void FadeConfig::load() { event.duration = (float)value.toDouble(); } else { - qWarning() << "Fade event configuration file " << path << " contains an invalid 'duration' field. Expected float value"; + qWarning() << "Fade event configuration file " << configFilePath << " contains an invalid 'duration' field. Expected float value"; } value = jsonObject["edgeWidth"]; @@ -519,7 +519,7 @@ void FadeConfig::load() { event.edgeWidth = std::min(1.f, std::max(0.f, (float)value.toDouble())); } else { - qWarning() << "Fade event configuration file " << path << " contains an invalid 'edgeWidth' field. Expected float value"; + qWarning() << "Fade event configuration file " << configFilePath << " contains an invalid 'edgeWidth' field. Expected float value"; } value = jsonObject["timing"]; @@ -527,7 +527,7 @@ void FadeConfig::load() { event.timing = std::max(0, std::min(TIMING_COUNT - 1, value.toInt())); } else { - qWarning() << "Fade event configuration file " << path << " contains an invalid 'timing' field. Expected integer value"; + qWarning() << "Fade event configuration file " << configFilePath << " contains an invalid 'timing' field. Expected integer value"; } value = jsonObject["isInverted"]; @@ -535,13 +535,13 @@ void FadeConfig::load() { event.isInverted = value.toBool(); } else { - qWarning() << "Fade event configuration file " << path << " contains an invalid 'isInverted' field. Expected boolean value"; + qWarning() << "Fade event configuration file " << configFilePath << " contains an invalid 'isInverted' field. Expected boolean value"; } emit dirty(); } else { - qWarning() << "Fade event configuration file" << path << "failed to load:" << + qWarning() << "Fade event configuration file" << configFilePath << "failed to load:" << error.errorString() << "at offset" << error.offset; } } diff --git a/libraries/render-utils/src/FadeEffectJobs.h b/libraries/render-utils/src/FadeEffectJobs.h index a585d5b98a..783f026bcd 100644 --- a/libraries/render-utils/src/FadeEffectJobs.h +++ b/libraries/render-utils/src/FadeEffectJobs.h @@ -56,13 +56,9 @@ class FadeConfig : public render::Job::Config { Q_PROPERTY(float noiseSizeZ READ getNoiseSizeZ WRITE setNoiseSizeZ NOTIFY dirty) Q_PROPERTY(float noiseLevel READ getNoiseLevel WRITE setNoiseLevel NOTIFY dirty) Q_PROPERTY(float edgeWidth READ getEdgeWidth WRITE setEdgeWidth NOTIFY dirty) - Q_PROPERTY(float edgeInnerColorR READ getEdgeInnerColorR WRITE setEdgeInnerColorR NOTIFY dirty) - Q_PROPERTY(float edgeInnerColorG READ getEdgeInnerColorG WRITE setEdgeInnerColorG NOTIFY dirty) - Q_PROPERTY(float edgeInnerColorB READ getEdgeInnerColorB WRITE setEdgeInnerColorB NOTIFY dirty) + Q_PROPERTY(QColor edgeInnerColor READ getEdgeInnerColor WRITE setEdgeInnerColor NOTIFY dirty) Q_PROPERTY(float edgeInnerIntensity READ getEdgeInnerIntensity WRITE setEdgeInnerIntensity NOTIFY dirty) - Q_PROPERTY(float edgeOuterColorR READ getEdgeOuterColorR WRITE setEdgeOuterColorR NOTIFY dirty) - Q_PROPERTY(float edgeOuterColorG READ getEdgeOuterColorG WRITE setEdgeOuterColorG NOTIFY dirty) - Q_PROPERTY(float edgeOuterColorB READ getEdgeOuterColorB WRITE setEdgeOuterColorB NOTIFY dirty) + Q_PROPERTY(QColor edgeOuterColor READ getEdgeOuterColor WRITE setEdgeOuterColor NOTIFY dirty) Q_PROPERTY(float edgeOuterIntensity READ getEdgeOuterIntensity WRITE setEdgeOuterIntensity NOTIFY dirty) Q_PROPERTY(int timing READ getTiming WRITE setTiming NOTIFY dirty) Q_PROPERTY(float noiseSpeedX READ getNoiseSpeedX WRITE setNoiseSpeedX NOTIFY dirty) @@ -129,26 +125,14 @@ public: void setEdgeWidth(float value); float getEdgeWidth() const; - void setEdgeInnerColorR(float value); - float getEdgeInnerColorR() const { return events[editedCategory].edgeInnerColor.r; } - - void setEdgeInnerColorG(float value); - float getEdgeInnerColorG() const { return events[editedCategory].edgeInnerColor.g; } - - void setEdgeInnerColorB(float value); - float getEdgeInnerColorB() const { return events[editedCategory].edgeInnerColor.b; } + void setEdgeInnerColor(const QColor& value); + QColor getEdgeInnerColor() const; void setEdgeInnerIntensity(float value); float getEdgeInnerIntensity() const { return events[editedCategory].edgeInnerColor.a; } - void setEdgeOuterColorR(float value); - float getEdgeOuterColorR() const { return events[editedCategory].edgeOuterColor.r; } - - void setEdgeOuterColorG(float value); - float getEdgeOuterColorG() const { return events[editedCategory].edgeOuterColor.g; } - - void setEdgeOuterColorB(float value); - float getEdgeOuterColorB() const { return events[editedCategory].edgeOuterColor.b; } + void setEdgeOuterColor(const QColor& value); + QColor getEdgeOuterColor() const; void setEdgeOuterIntensity(float value); float getEdgeOuterIntensity() const { return events[editedCategory].edgeOuterColor.a; } diff --git a/scripts/developer/utilities/render/transition.qml b/scripts/developer/utilities/render/transition.qml index de59d32df2..e83a85f8ed 100644 --- a/scripts/developer/utilities/render/transition.qml +++ b/scripts/developer/utilities/render/transition.qml @@ -221,11 +221,9 @@ Rectangle { height: 30 anchors.left: parent.left anchors.right: parent.right - _color: Qt.rgba(root.config.edgeInnerColorR, root.config.edgeInnerColorG, root.config.edgeInnerColorB, 1.0) + _color: root.config.edgeInnerColor onNewColor: { - root.config.edgeInnerColorR = _color.red - root.config.edgeInnerColorG = _color.green - root.config.edgeInnerColorB = _color.blue + root.config.edgeInnerColor = _color } } ConfigSlider { @@ -251,11 +249,9 @@ Rectangle { height: 30 anchors.left: parent.left anchors.right: parent.right - _color: Qt.rgba(root.config.edgeOuterColorR, root.config.edgeOuterColorG, root.config.edgeOuterColorB, 1.0) + _color: root.config.edgeOuterColor onNewColor: { - root.config.edgeOuterColorR = _color.red - root.config.edgeOuterColorG = _color.green - root.config.edgeOuterColorB = _color.blue + root.config.edgeOuterColor = _color } } ConfigSlider { From 38bc3120042a61e0a15a5e02a82f489af71b25df Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Tue, 13 Feb 2018 11:25:34 -0800 Subject: [PATCH 6/6] faster and const EntityTree::findByID() --- libraries/entities/src/EntityTree.cpp | 21 ++++++++++++++------- libraries/entities/src/EntityTree.h | 6 +++--- libraries/shared/src/SpatialParentFinder.h | 2 +- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/libraries/entities/src/EntityTree.cpp b/libraries/entities/src/EntityTree.cpp index bf29f3bec9..60bcc85575 100644 --- a/libraries/entities/src/EntityTree.cpp +++ b/libraries/entities/src/EntityTree.cpp @@ -913,18 +913,25 @@ void EntityTree::findEntities(RecurseOctreeOperation& elementFilter, recurseTreeWithOperation(elementFilter, nullptr); } -EntityItemPointer EntityTree::findEntityByID(const QUuid& id) { +EntityItemPointer EntityTree::findEntityByID(const QUuid& id) const { EntityItemID entityID(id); return findEntityByEntityItemID(entityID); } -EntityItemPointer EntityTree::findEntityByEntityItemID(const EntityItemID& entityID) /*const*/ { - EntityItemPointer foundEntity = NULL; - EntityTreeElementPointer containingElement = getContainingElement(entityID); - if (containingElement) { - foundEntity = containingElement->getEntityWithEntityItemID(entityID); +EntityItemPointer EntityTree::findEntityByEntityItemID(const EntityItemID& entityID) const { + EntityItemPointer foundEntity = nullptr; + { + QReadLocker locker(&_entityMapLock); + foundEntity = _entityMap.value(entityID); + } + if (foundEntity && !foundEntity->getElement()) { + // special case to maintain legacy behavior: + // if the entity is in the map but not in the tree + // then pretend the entity doesn't exist + return EntityItemPointer(nullptr); + } else { + return foundEntity; } - return foundEntity; } void EntityTree::fixupTerseEditLogging(EntityItemProperties& properties, QList& changedProperties) { diff --git a/libraries/entities/src/EntityTree.h b/libraries/entities/src/EntityTree.h index 8cb89d6493..90fe342f57 100644 --- a/libraries/entities/src/EntityTree.h +++ b/libraries/entities/src/EntityTree.h @@ -132,9 +132,9 @@ public: /// \param position point of query in world-frame (meters) /// \param targetRadius radius of query (meters) EntityItemPointer findClosestEntity(const glm::vec3& position, float targetRadius); - EntityItemPointer findEntityByID(const QUuid& id); - EntityItemPointer findEntityByEntityItemID(const EntityItemID& entityID); - virtual SpatiallyNestablePointer findByID(const QUuid& id) override { return findEntityByID(id); } + EntityItemPointer findEntityByID(const QUuid& id) const; + EntityItemPointer findEntityByEntityItemID(const EntityItemID& entityID) const; + virtual SpatiallyNestablePointer findByID(const QUuid& id) const override { return findEntityByID(id); } EntityItemID assignEntityID(const EntityItemID& entityItemID); /// Assigns a known ID for a creator token ID diff --git a/libraries/shared/src/SpatialParentFinder.h b/libraries/shared/src/SpatialParentFinder.h index aae7d9f040..c19babbc7f 100644 --- a/libraries/shared/src/SpatialParentFinder.h +++ b/libraries/shared/src/SpatialParentFinder.h @@ -21,7 +21,7 @@ using SpatiallyNestableWeakPointer = std::weak_ptr; using SpatiallyNestablePointer = std::shared_ptr; class SpatialParentTree { public: - virtual SpatiallyNestablePointer findByID(const QUuid& id) { return nullptr; } + virtual SpatiallyNestablePointer findByID(const QUuid& id) const { return nullptr; } }; class SpatialParentFinder : public Dependency {