From 6148458aeb274f3247e8c2a39ae61e51231eb6b7 Mon Sep 17 00:00:00 2001 From: samcake Date: Thu, 7 Dec 2017 16:04:08 -0800 Subject: [PATCH] Workable state, need final clean up and testing --- .../scripting/SelectionScriptingInterface.h | 20 ++++-- libraries/render/src/render/HighlightStyle.h | 6 +- .../developer/utilities/render/highlight2.qml | 72 +++++++++++++++---- 3 files changed, 77 insertions(+), 21 deletions(-) diff --git a/interface/src/scripting/SelectionScriptingInterface.h b/interface/src/scripting/SelectionScriptingInterface.h index a05ddaa62c..75bddbe62d 100644 --- a/interface/src/scripting/SelectionScriptingInterface.h +++ b/interface/src/scripting/SelectionScriptingInterface.h @@ -59,8 +59,6 @@ public: public slots: void selectedItemsListChanged(const QString& listName); - // void highlightStyleChanged(const QString& listName); - // void highlightStyleRemoved(const QString& listName); private: QString _listName{ "" }; @@ -90,6 +88,11 @@ class SelectionScriptingInterface : public QObject, public Dependency { public: SelectionScriptingInterface(); + /**jsdoc + * Query the names of all the selection lists + * @function Selection.getListNames + * @return An array of names of all the selection lists + */ Q_INVOKABLE QStringList getListNames() const; /**jsdoc @@ -126,8 +129,6 @@ public: */ Q_INVOKABLE bool clearSelectedItemsList(const QString& listName); - - /**jsdoc * Prints out the list of avatars, entities and overlays stored in a particular selection. * @function Selection.printList @@ -139,11 +140,18 @@ public: * Query the list of avatars, entities and overlays stored in a particular selection. * @function Selection.getList * @param listName {string} name of the selection - * @return + * @return a js object containing the following properties (if the array of obkjects are not empty): + * - "entities": [ and array of the entityID of the entities in the selection] + * - "avatars": [ and array of the avatarID of the avatars in the selection] + * - "overlays": [ and array of the overlayID of the overlays in the selection] */ Q_INVOKABLE QVariantMap getSelectedItemsList(const QString& listName) const; - // + /**jsdoc + * Query the names of the highlighted selection lists + * @function Selection.getHighlightedListNames + * @return An array of names of the selection list currently highlight enabled + */ Q_INVOKABLE QStringList getHighlightedListNames() const; /**jsdoc diff --git a/libraries/render/src/render/HighlightStyle.h b/libraries/render/src/render/HighlightStyle.h index 1243f5aa60..981b43429a 100644 --- a/libraries/render/src/render/HighlightStyle.h +++ b/libraries/render/src/render/HighlightStyle.h @@ -26,9 +26,9 @@ namespace render { }; RGBA _outlineUnoccluded{ { 1.f, 0.7f, 0.2f }, 0.9f }; - RGBA _outlineOccluded{ { 0.2f, 0.7f, 1.0f }, 0.9f }; - RGBA _fillUnoccluded{ { 1.f, 0.2f, 0.7f }, 0.0f }; - RGBA _fillOccluded{ { 0.7f, 1.f, 0.2f }, 0.0f }; + RGBA _outlineOccluded{ { 1.f, 0.7f, 0.2f }, 0.9f }; + RGBA _fillUnoccluded{ { 0.2f, 0.7f, 1.0f }, 0.0f }; + RGBA _fillOccluded{ { 0.2f, 0.7f, 1.0f }, 0.0f }; float _outlineWidth{ 2.0f }; bool _isOutlineSmooth{ false }; diff --git a/scripts/developer/utilities/render/highlight2.qml b/scripts/developer/utilities/render/highlight2.qml index b22cfd4033..af478723fa 100644 --- a/scripts/developer/utilities/render/highlight2.qml +++ b/scripts/developer/utilities/render/highlight2.qml @@ -29,14 +29,18 @@ Item { signal sendToScript(var message); Component.onCompleted: { + // Connect the signal from Selection when any selection content change and use it to refresh the current selection view + Selection.selectedItemsListChanged.connect(resetSelectionView) + } + + function resetSelectionView() { + selectionView.resetSelectionView(); } - Column { id: col spacing: 5 - anchors.left: root.left - anchors.right: root.right + anchors.fill: root anchors.margins: hifi.dimensions.contentMargin.x Row { @@ -50,6 +54,7 @@ Item { id: debug text: "Refresh" height: 24 + width: 82 onClicked: { print("list of highlight styles") root.styleList = Selection.getHighlightedListNames() @@ -57,13 +62,14 @@ Item { print(root.styleList) styleSelectorLoader.sourceComponent = undefined; styleSelectorLoader.sourceComponent = selectorWidget; + resetSelectionView(); } } Loader { id: styleSelectorLoader sourceComponent: selectorWidget - width: 350 + width: 300 anchors.right: parent.right } Component { @@ -79,11 +85,12 @@ Item { Timer { id: postpone interval: 100; running: false; repeat: false - onTriggered: { styleWidgetLoader.sourceComponent = styleWidget } + onTriggered: { + styleWidgetLoader.sourceComponent = styleWidget + } } onCurrentIndexChanged: { root.listName = model[currentIndex]; - // sendToScript("highlight "+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 styleWidgetLoader.sourceComponent = undefined; @@ -91,8 +98,6 @@ Item { postpone.start() } } - - } } @@ -101,9 +106,52 @@ Item { id: styleWidgetLoader sourceComponent: styleWidget anchors.left: parent.left - anchors.right: parent.right - } - } + anchors.right: parent.right + height: 240 + } + + Separator {} + + Rectangle { + id: selectionView + anchors.left: parent.left + anchors.right: parent.right + height: 250 + color: hifi.colors.lightGray + + function resetSelectionView() { + // myModel.resetSelectionView(); + var entities = Selection.getSelectedItemsList(root.listName)["entities"] + //print("resetSelectionView" + JSON.stringify(entities)) + myModel.clear() + var fLen = entities.length; + for (var i = 0; i < fLen; i++) { + myModel.append({ "objectID": JSON.stringify(entities[i]) }) + // print("resetSelectionView" + JSON.stringify( entities[i])) + } + } + + ListModel { + id: myModel + } + + Component { + id: myDelegate + Row { + id: fruit + Text { text: JSON.stringify(objectID) } + } + } + + ListView { + id: selectionListView + anchors.fill: parent + anchors.topMargin: 30 + model: myModel + delegate: myDelegate + } + } + } Component { id: styleWidget @@ -116,7 +164,7 @@ Item { onNewStyle: { var style = getStyle() - // print("new style " + JSON.stringify(style) ) + // print("new style " + JSON.stringify(style) ) Selection.enableListHighlight(root.listName, style) } }