From de410b683346cf516e579cbd3236bed1fcb25a5b Mon Sep 17 00:00:00 2001 From: samcake Date: Mon, 4 Dec 2017 17:29:01 -0800 Subject: [PATCH] I need a color editor --- .../scripting/SelectionScriptingInterface.h | 40 +++++++++++++ .../utilities/lib/plotperf/XColor.qml | 59 +++++++++++++++++++ .../developer/utilities/lib/plotperf/qmldir | 3 +- .../developer/utilities/render/highlight2.qml | 18 ++++-- 4 files changed, 115 insertions(+), 5 deletions(-) create mode 100644 scripts/developer/utilities/lib/plotperf/XColor.qml diff --git a/interface/src/scripting/SelectionScriptingInterface.h b/interface/src/scripting/SelectionScriptingInterface.h index 6abf07537e..2d9dc07661 100644 --- a/interface/src/scripting/SelectionScriptingInterface.h +++ b/interface/src/scripting/SelectionScriptingInterface.h @@ -132,8 +132,48 @@ public: */ Q_INVOKABLE bool clearSelectedItemsList(const QString& listName); + /**jsdoc + * Enable highlighting for the named selection. + * If the Selection doesn't exist, it will be created. + * All objects in the list will be displayed with the highlight effect as specified from the highlightStyle. + * The function can be called several times with different values in the style to modify it. + * + * @function Selection.enableListHighlight + * @param listName {string} name of the selection + * @param highlightStyle {jsObject} highlight style fields (see Selection.getListHighlightStyle for a detailed description of the highlightStyle). + * @returns {bool} true if the selection was successfully enabled for highlight. + */ Q_INVOKABLE bool enableListHighlight(const QString& listName, const QVariantMap& highlightStyle); + /**jsdoc + * Disable highlighting for the named selection. + * If the Selection doesn't exist or wasn't enabled for highliting then nothing happens simply returning false. + * + * @function Selection.disableListHighlight + * @param listName {string} name of the selection + * @returns {bool} true if the selection was successfully disabled for highlight, false otherwise. + */ Q_INVOKABLE bool disableListHighlight(const QString& listName); + /**jsdoc + * Query the highlight style values for the named selection. + * If the Selection doesn't exist or hasn't been highlight enabled yet, it will return an empty object. + * Otherwise, the jsObject describes the highlight style properties: + * - outlineUnoccludedColor: {xColor} Color of the specified highlight region + * - outlineOccludedColor: {xColor} " + * - fillUnoccludedColor: {xColor} " + * - fillOccludedColor: {xColor} " + * + * - outlineUnoccludedOpacity: {float} Opacity value ranging from 0.0 (not visible) to 1.0 (fully opaque) for the specified highlight region + * - outlineOccludedOpacity: {float} " + * - fillUnoccludedOpacity: {float} " + * - fillOccludedOpacity: {float} " + * + * - outlineWidth: {float} width of the outline expressed in pixels + * - isOutlineSmooth: {bool} true to enable oultine smooth falloff + * + * @function Selection.getListHighlightStyle + * @param listName {string} name of the selection + * @returns {jsObject} highlight style as described above + */ Q_INVOKABLE QVariantMap getListHighlightStyle(const QString& listName) const; render::HighlightStyle getHighlightStyle(const QString& listName) const; diff --git a/scripts/developer/utilities/lib/plotperf/XColor.qml b/scripts/developer/utilities/lib/plotperf/XColor.qml new file mode 100644 index 0000000000..1e1d28c059 --- /dev/null +++ b/scripts/developer/utilities/lib/plotperf/XColor.qml @@ -0,0 +1,59 @@ +// +// XColor.qml +// +// Created by Sam Gateau 12/4/2017 +// Copyright 2017 High Fidelity, Inc. +// +// 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.7 +import QtQuick.Controls 1.4 as Original +import QtQuick.Controls.Styles 1.4 + +import "qrc:///qml/styles-uit" +import "qrc:///qml/controls-uit" as HifiControls + + +Item { + HifiConstants { id: hifi } + id: root + + anchors.left: parent.left + anchors.right: parent.right + height: 24 + property var color + property alias label: labelControl.text + + function getColor() { + return Qt.rgba(color.red / 255.0, color.green / 255.0, color.blue / 255.0, 1.0 ); + } + + Rectangle { + id: current + HifiConstants { id: hifi;} + color: root.getColor(); + } + + Component.onCompleted: { + // Binding favors qml value, so set it first + bindingControl.when = true; + } + + HifiControls.Label { + id: labelControl + text: root.label + enabled: true + anchors.left: root.left + anchors.right: root.horizontalCenter + anchors.verticalCenter: root.verticalCenter + } + + Binding { + id: bindingControl + target: root.color + property: root.property + when: false + } +} diff --git a/scripts/developer/utilities/lib/plotperf/qmldir b/scripts/developer/utilities/lib/plotperf/qmldir index 5668f5034c..829592f87d 100644 --- a/scripts/developer/utilities/lib/plotperf/qmldir +++ b/scripts/developer/utilities/lib/plotperf/qmldir @@ -1 +1,2 @@ -PlotPerf 1.0 PlotPerf.qml \ No newline at end of file +PlotPerf 1.0 PlotPerf.qml +XColor 1.0 XColor.qml \ No newline at end of file diff --git a/scripts/developer/utilities/render/highlight2.qml b/scripts/developer/utilities/render/highlight2.qml index 6be74fcf40..b6dc49613e 100644 --- a/scripts/developer/utilities/render/highlight2.qml +++ b/scripts/developer/utilities/render/highlight2.qml @@ -15,6 +15,7 @@ import QtQuick.Layouts 1.3 import "qrc:///qml/styles-uit" import "qrc:///qml/controls-uit" as HifiControls import "configSlider" +import "../lib/plotperf" Rectangle { id: root @@ -22,8 +23,8 @@ Rectangle { color: hifi.colors.baseGray; anchors.margins: hifi.dimensions.contentMargin.x - property var debugConfig: Render.getConfig("RenderMainView.HighlightDebug") - property var highlightConfig: Render.getConfig("UpdateScene.HighlightStageSetup") + //property var debugConfig: Render.getConfig("RenderMainView.HighlightDebug") + //property var highlightConfig: Render.getConfig("UpdateScene.HighlightStageSetup") signal sendToScript(var message); @@ -60,9 +61,17 @@ Rectangle { onCheckedChanged: { sendToScript("add "+checked.toString()) } - } + } + } + Separator {} + + XColor { + color: { "red": 0, "green": 255, "blue": 0} } + Separator {} + +/* HifiControls.ComboBox { id: box width: 350 @@ -112,7 +121,7 @@ Rectangle { Column { spacing: 10 anchors.left: parent.left - anchors.right: parent.right + anchors.right: parent.right HifiControls.CheckBox { text: "Smooth" checked: root.highlightConfig["isOutlineSmooth"] @@ -173,5 +182,6 @@ Rectangle { } } } + */ } }