From fe23ef1485e4a152e339d6f40b53deab374bdb31 Mon Sep 17 00:00:00 2001 From: Sam Gateau Date: Sun, 3 Mar 2019 23:35:40 -0800 Subject: [PATCH] Adding the prop library --- .../developer/utilities/lib/prop/Global.qml | 44 +++++++ .../utilities/lib/prop/PropColor.qml | 0 .../developer/utilities/lib/prop/PropEnum.qml | 110 ++++++++++++++++++ .../developer/utilities/lib/prop/PropItem.qml | 62 ++++++++++ .../utilities/lib/prop/PropLabel.qml | 25 ++++ .../utilities/lib/prop/PropScalar.qml | 71 +++++++++++ .../utilities/lib/prop/PropSplitter.qml | 21 ++++ .../developer/utilities/lib/prop/PropText.qml | 24 ++++ scripts/developer/utilities/lib/prop/qmldir | 8 ++ scripts/developer/utilities/render/luci.qml | 59 ++++++++++ scripts/developer/utilities/render/luci2.js | 13 +++ 11 files changed, 437 insertions(+) create mode 100644 scripts/developer/utilities/lib/prop/Global.qml create mode 100644 scripts/developer/utilities/lib/prop/PropColor.qml create mode 100644 scripts/developer/utilities/lib/prop/PropEnum.qml create mode 100644 scripts/developer/utilities/lib/prop/PropItem.qml create mode 100644 scripts/developer/utilities/lib/prop/PropLabel.qml create mode 100644 scripts/developer/utilities/lib/prop/PropScalar.qml create mode 100644 scripts/developer/utilities/lib/prop/PropSplitter.qml create mode 100644 scripts/developer/utilities/lib/prop/PropText.qml create mode 100644 scripts/developer/utilities/lib/prop/qmldir create mode 100644 scripts/developer/utilities/render/luci.qml create mode 100644 scripts/developer/utilities/render/luci2.js diff --git a/scripts/developer/utilities/lib/prop/Global.qml b/scripts/developer/utilities/lib/prop/Global.qml new file mode 100644 index 0000000000..be189e3c96 --- /dev/null +++ b/scripts/developer/utilities/lib/prop/Global.qml @@ -0,0 +1,44 @@ +// +// Prop/Global.qml +// +// Created by Sam Gateau on 3/2/2019 +// Copyright 2019 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 stylesUit 1.0 +import controlsUit 1.0 as HifiControls + + +Item { + HifiConstants { id: hifi } + id: root + + property real lineHeight: 32 + property real slimHeight: 24 + + property var color: hifi.colors.baseGray + property var colorBackHighlight: hifi.colors.baseGrayHighlight + property var colorBorderLight: hifi.colors.lightGray + property var colorBorderHighight: hifi.colors.blueHighlight + + property real fontSize: 12 + property var fontFamily: "Raleway" + property var fontWeight: Font.DemiBold + property var fontColor: hifi.colors.faintGray + + property var splitterRightWidthScale: 0.44 + property real splitterWidth: 4 + + property var labelTextAlign: Text.AlignRight + property var labelTextElide: Text.ElideMiddle + + property var valueAreaWidthScale: 0.3 * (1.0 - splitterRightWidthScale) + property var valueTextAlign: Text.AlignHCenter + property real valueBorderWidth: 1 + property real valueBorderRadius: 2 +} \ No newline at end of file diff --git a/scripts/developer/utilities/lib/prop/PropColor.qml b/scripts/developer/utilities/lib/prop/PropColor.qml new file mode 100644 index 0000000000..e69de29bb2 diff --git a/scripts/developer/utilities/lib/prop/PropEnum.qml b/scripts/developer/utilities/lib/prop/PropEnum.qml new file mode 100644 index 0000000000..fe6200d971 --- /dev/null +++ b/scripts/developer/utilities/lib/prop/PropEnum.qml @@ -0,0 +1,110 @@ +// +// PropEnum.qml +// +// Created by Sam Gateau on 3/2/2019 +// Copyright 2019 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 2.2 + +PropItem { + Global { id: global } + id: root + + property alias valueVar : valueCombo.currentIndex + property alias enums : valueCombo.model + + ComboBox { + id: valueCombo + + flat: true + + anchors.left: root.splitter.right + anchors.right: parent.right + anchors.verticalCenter: root.verticalCenter + height: global.slimHeight + + currentIndex: root.valueVarGetter() + onCurrentIndexChanged: { root.valueVarSetter(currentIndex); } + + delegate: ItemDelegate { + width: valueCombo.width + height: valueCombo.height + contentItem: PropText { + text: modelData + horizontalAlignment: global.valueTextAlign + } + background: Rectangle { + color:highlighted?global.colorBackHighlight:global.color; + } + highlighted: valueCombo.highlightedIndex === index + } + + indicator: Canvas { + id: canvas + x: valueCombo.width - width - valueCombo.rightPadding + y: valueCombo.topPadding + (valueCombo.availableHeight - height) / 2 + width: 12 + height: 8 + contextType: "2d" + + Connections { + target: valueCombo + onPressedChanged: canvas.requestPaint() + } + + onPaint: { + context.reset(); + context.moveTo(0, 0); + context.lineTo(width, 0); + context.lineTo(width / 2, height); + context.closePath(); + context.fillStyle = (valueCombo.pressed) ? global.colorBorderHighight : global.colorBorderLight; + context.fill(); + } + } + + contentItem: PropText { + leftPadding: 0 + rightPadding: valueCombo.indicator.width + valueCombo.spacing + + text: valueCombo.displayText + horizontalAlignment: global.valueTextAlign + } + + background: Rectangle { + implicitWidth: 120 + implicitHeight: 40 + color: global.color + border.color: valueCombo.popup.visible ? global.colorBorderHighight : global.colorBorderLight + border.width: global.valueBorderWidth + radius: global.valueBorderRadius + } + + popup: Popup { + y: valueCombo.height - 1 + width: valueCombo.width + implicitHeight: contentItem.implicitHeight + 2 + padding: 1 + + contentItem: ListView { + clip: true + implicitHeight: contentHeight + model: valueCombo.popup.visible ? valueCombo.delegateModel : null + currentIndex: valueCombo.highlightedIndex + + ScrollIndicator.vertical: ScrollIndicator { } + } + + background: Rectangle { + color: global.color + border.color: global.colorBorderHighight + radius: global.valueBorderRadius + } + } + } +} diff --git a/scripts/developer/utilities/lib/prop/PropItem.qml b/scripts/developer/utilities/lib/prop/PropItem.qml new file mode 100644 index 0000000000..ee1e99a772 --- /dev/null +++ b/scripts/developer/utilities/lib/prop/PropItem.qml @@ -0,0 +1,62 @@ +// +// PropItem.qml +// +// Created by Sam Gateau on 3/2/2019 +// Copyright 2019 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 + +Item { + Global { id: global } + + id: root + + // Prop item is designed to author an object[property]: + property var object: NULL + property string property: "" + + // value is accessed through the "valueVarSetter" and "valueVarGetter" + // By default, these just go get or set the value from the object[property] + // + function defaultGet() { return root.object[root.property]; } + function defaultSet(value) { root.object[root.property] = value; } + property var valueVarSetter: defaultSet + property var valueVarGetter: defaultGet + + // PropItem is stretching horizontally accross its parent + // Fixed height + anchors.left: parent.left + anchors.right: parent.right + height: global.lineHeight + + + // LabelControl And SplitterControl are on the left side of the PropItem + property bool showLabel: true + property alias labelControl: labelControl + property alias label: labelControl.text + + property var labelAreaWidth: root.width * global.splitterRightWidthScale - global.splitterWidth + + PropText { + id: labelControl + text: root.label + enabled: root.showLabel + + anchors.left: root.left + anchors.verticalCenter: root.verticalCenter + width: labelAreaWidth + } + + property alias splitter: splitterControl + PropSplitter { + id: splitterControl + + anchors.left: labelControl.right + size: global.splitterWidth + } + +} diff --git a/scripts/developer/utilities/lib/prop/PropLabel.qml b/scripts/developer/utilities/lib/prop/PropLabel.qml new file mode 100644 index 0000000000..9dbeffe0ec --- /dev/null +++ b/scripts/developer/utilities/lib/prop/PropLabel.qml @@ -0,0 +1,25 @@ +// +// PropLabel.qml +// +// Created by Sam Gateau on 3/2/2019 +// Copyright 2019 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 2.2 + +Label { + Global { id: global } + + color: global.fontColor + font.pixelSize: global.fontSize + font.family: global.fontFamily + font.weight: global.fontWeight + verticalAlignment: Text.AlignVCenter + horizontalAlignment: global.labelTextAlign + elide: global.labelTextElide +} + diff --git a/scripts/developer/utilities/lib/prop/PropScalar.qml b/scripts/developer/utilities/lib/prop/PropScalar.qml new file mode 100644 index 0000000000..29b42e2801 --- /dev/null +++ b/scripts/developer/utilities/lib/prop/PropScalar.qml @@ -0,0 +1,71 @@ +// +// PropItem.qml +// +// Created by Sam Gateau on 3/2/2019 +// Copyright 2019 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 controlsUit 1.0 as HifiControls + +PropItem { + Global { id: global } + id: root + + // Scalar Prop + property bool integral: false + property var numDigits: 2 + + + property alias valueVar : sliderControl.value + property alias min: sliderControl.minimumValue + property alias max: sliderControl.maximumValue + + + + property bool showValue: true + + + signal valueChanged(real value) + + Component.onCompleted: { + valueVar = root.valueVarGetter(); + } + + PropLabel { + id: valueLabel + enabled: root.showValue + + anchors.left: root.splitter.right + anchors.verticalCenter: root.verticalCenter + width: root.width * global.valueAreaWidthScale + horizontalAlignment: global.valueTextAlign + height: global.slimHeight + + text: sliderControl.value.toFixed(root.integral ? 0 : root.numDigits) + + background: Rectangle { + color: global.color + border.color: global.colorBorderLight + border.width: global.valueBorderWidth + radius: global.valueBorderRadius + } + } + + HifiControls.Slider { + id: sliderControl + stepSize: root.integral ? 1.0 : 0.0 + anchors.left: valueLabel.right + anchors.right: root.right + anchors.rightMargin: 0 + anchors.verticalCenter: root.verticalCenter + + onValueChanged: { root.valueVarSetter(value) } + } + + +} diff --git a/scripts/developer/utilities/lib/prop/PropSplitter.qml b/scripts/developer/utilities/lib/prop/PropSplitter.qml new file mode 100644 index 0000000000..25f668a6eb --- /dev/null +++ b/scripts/developer/utilities/lib/prop/PropSplitter.qml @@ -0,0 +1,21 @@ +// +// PropSplitter.qml +// +// Created by Sam Gateau on 3/2/2019 +// Copyright 2019 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 + +Item { + id: root + property real size + + width: size // Must be non-zero + height: size + + anchors.verticalCenter: parent.verticalCenter +} diff --git a/scripts/developer/utilities/lib/prop/PropText.qml b/scripts/developer/utilities/lib/prop/PropText.qml new file mode 100644 index 0000000000..b1669f3836 --- /dev/null +++ b/scripts/developer/utilities/lib/prop/PropText.qml @@ -0,0 +1,24 @@ +// +// Prop/Text.qml +// +// Created by Sam Gateau on 3/2/2019 +// Copyright 2019 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 + +Text { + Global { id: global } + + color: global.fontColor + font.pixelSize: global.fontSize + font.family: global.fontFamily + font.weight: global.fontWeight + verticalAlignment: Text.AlignVCenter + horizontalAlignment: global.labelTextAlign + elide: global.labelTextElide +} + diff --git a/scripts/developer/utilities/lib/prop/qmldir b/scripts/developer/utilities/lib/prop/qmldir new file mode 100644 index 0000000000..44e4889ab6 --- /dev/null +++ b/scripts/developer/utilities/lib/prop/qmldir @@ -0,0 +1,8 @@ +PropGlobal 1.0 PropGlobal.qml +PropText 1.0 PropText.qml +PropLabel 1.0 PropLabel.qml +PropSplitter 1.0 PropSplitter.qml +PropItem 1.0 PropItem.qml +PropScalar 1.0 PropScalar.qml +PropEnum 1.0 PropEnum.qml +PropColor 1.0 PropColor.qml diff --git a/scripts/developer/utilities/render/luci.qml b/scripts/developer/utilities/render/luci.qml new file mode 100644 index 0000000000..959a24e9be --- /dev/null +++ b/scripts/developer/utilities/render/luci.qml @@ -0,0 +1,59 @@ +// +// luci.qml +// +// Created by Sam Gateau on 3/2/2019 +// Copyright 2019 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 +import QtQuick.Layouts 1.3 + +import controlsUit 1.0 as HifiControls + +import "../lib/prop" as Prop + +Rectangle { + Prop.Global { id: prop;} + id: render; + anchors.fill: parent + color: prop.color; + + property var mainViewTask: Render.getConfig("RenderMainView") + + Column { + anchors.left: parent.left + anchors.right: parent.right + Repeater { + model: [ "Tone mapping exposure:ToneMapping:exposure:5.0:-5.0", + "Tone:ToneMapping:exposure:5.0:-5.0" + ] + Prop.PropScalar { + label: qsTr(modelData.split(":")[0]) + integral: false + object: render.mainViewTask.getConfig(modelData.split(":")[1]) + property: modelData.split(":")[2] + max: modelData.split(":")[3] + min: modelData.split(":")[4] + + anchors.left: parent.left + anchors.right: parent.right + } + } + Prop.PropEnum { + label: "Tone Curve" + object: render.mainViewTask.getConfig("ToneMapping") + property: "curve" + enums: [ + "RGB", + "SRGB", + "Reinhard", + "Filmic", + ] + anchors.left: parent.left + anchors.right: parent.right + } + } +} \ No newline at end of file diff --git a/scripts/developer/utilities/render/luci2.js b/scripts/developer/utilities/render/luci2.js new file mode 100644 index 0000000000..4aea49a059 --- /dev/null +++ b/scripts/developer/utilities/render/luci2.js @@ -0,0 +1,13 @@ +function openEngineTaskView() { + // Set up the qml ui + var qml = Script.resolvePath('luci.qml'); + var window = new OverlayWindow({ + title: 'luci qml', + source: qml, + width: 300, + height: 400 + }); + window.setPosition(200, 50); + //window.closed.connect(function() { Script.stop(); }); + } + openEngineTaskView(); \ No newline at end of file