From b50e20c5457151368b7ead81bf44ce678de9dbe2 Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Wed, 8 Feb 2017 00:01:48 +0000 Subject: [PATCH 01/89] general function to load QML for javascript for tablet --- libraries/script-engine/src/TabletScriptingInterface.cpp | 8 ++++++++ libraries/script-engine/src/TabletScriptingInterface.h | 4 +++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/libraries/script-engine/src/TabletScriptingInterface.cpp b/libraries/script-engine/src/TabletScriptingInterface.cpp index 2414ec469f..e7f8ebe2cb 100644 --- a/libraries/script-engine/src/TabletScriptingInterface.cpp +++ b/libraries/script-engine/src/TabletScriptingInterface.cpp @@ -212,6 +212,14 @@ void TabletProxy::gotoMenuScreen() { } } +void TabletProxy::loadQMLSource(const QVariant& path) { + if (_qmlTabletRoot) { + if (_state != State::QML) { + QMetaObject::invokeMethod(_qmlTabletRoot, "loadSource", Q_ARG(const QVariant&, path)); + _state = State::QML; + } + } +} void TabletProxy::gotoHomeScreen() { if (_qmlTabletRoot) { if (_state != State::Home) { diff --git a/libraries/script-engine/src/TabletScriptingInterface.h b/libraries/script-engine/src/TabletScriptingInterface.h index 4fe2c44c10..a005152fa9 100644 --- a/libraries/script-engine/src/TabletScriptingInterface.h +++ b/libraries/script-engine/src/TabletScriptingInterface.h @@ -89,6 +89,8 @@ public: Q_INVOKABLE void gotoWebScreen(const QString& url); Q_INVOKABLE void gotoWebScreen(const QString& url, const QString& injectedJavaScriptUrl); + Q_INVOKABLE void loadQMLSource(const QVariant& path); + /**jsdoc * Creates a new button, adds it to this and returns it. * @function TabletProxy#addButton @@ -149,7 +151,7 @@ protected: QQuickItem* _qmlTabletRoot { nullptr }; QObject* _qmlOffscreenSurface { nullptr }; - enum class State { Uninitialized, Home, Web, Menu }; + enum class State { Uninitialized, Home, Web, Menu, QML }; State _state { State::Uninitialized }; }; From 4c3a6842a53c0107ae0626bdae3b5877f669aeef Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Thu, 9 Feb 2017 14:03:01 -0800 Subject: [PATCH 02/89] start on moving edit.js to tablet --- .../resources/html/createGlobalEventBridge.js | 4 +++ .../qml/controls-uit/BaseWebView.qml | 2 +- .../qml/hifi/tablet/TabletMouseHandler.qml | 8 ++---- interface/src/ui/overlays/Web3DOverlay.cpp | 17 ++++++++++++ interface/src/ui/overlays/Web3DOverlay.h | 2 ++ .../src/TabletScriptingInterface.cpp | 12 ++++++++- .../src/TabletScriptingInterface.h | 2 ++ scripts/system/edit.js | 27 +++++++++++-------- scripts/system/html/js/entityProperties.js | 1 + 9 files changed, 56 insertions(+), 19 deletions(-) diff --git a/interface/resources/html/createGlobalEventBridge.js b/interface/resources/html/createGlobalEventBridge.js index 027d6fe8db..1dd232ae0a 100644 --- a/interface/resources/html/createGlobalEventBridge.js +++ b/interface/resources/html/createGlobalEventBridge.js @@ -27,6 +27,10 @@ var EventBridge; }; }; + console.log("---"); + console.log("CREATING GLOBAL EVENT BRIDGE"); + console.log("---"); + EventBridge = new TempEventBridge(); var webChannel = new QWebChannel(qt.webChannelTransport, function (channel) { diff --git a/interface/resources/qml/controls-uit/BaseWebView.qml b/interface/resources/qml/controls-uit/BaseWebView.qml index 763e6530fb..9c22a8ff8c 100644 --- a/interface/resources/qml/controls-uit/BaseWebView.qml +++ b/interface/resources/qml/controls-uit/BaseWebView.qml @@ -15,7 +15,7 @@ import HFWebEngineProfile 1.0 WebEngineView { id: root - profile: desktop.browserProfile + // profile: desktop.browserProfile Component.onCompleted: { console.log("Connecting JS messaging to Hifi Logging") diff --git a/interface/resources/qml/hifi/tablet/TabletMouseHandler.qml b/interface/resources/qml/hifi/tablet/TabletMouseHandler.qml index 17a00eccde..f2fa5f8d75 100644 --- a/interface/resources/qml/hifi/tablet/TabletMouseHandler.qml +++ b/interface/resources/qml/hifi/tablet/TabletMouseHandler.qml @@ -84,14 +84,10 @@ Item { topMenu.focus = true; topMenu.forceActiveFocus(); // show current menu level on nav bar - if (topMenu.objectName === "") { + if (topMenu.objectName === "" || menuStack.length === 1) { breadcrumbText.text = "Menu"; } else { - if (menuStack.length === 1) { - breadcrumbText.text = "Menu"; - } else { - breadcrumbText.text = topMenu.objectName; - } + breadcrumbText.text = topMenu.objectName; } } else { breadcrumbText.text = "Menu"; diff --git a/interface/src/ui/overlays/Web3DOverlay.cpp b/interface/src/ui/overlays/Web3DOverlay.cpp index f33ef24c0d..9fc53f85e8 100644 --- a/interface/src/ui/overlays/Web3DOverlay.cpp +++ b/interface/src/ui/overlays/Web3DOverlay.cpp @@ -133,12 +133,29 @@ QString Web3DOverlay::pickURL() { void Web3DOverlay::loadSourceURL() { + // if (_javaScriptToInject == "") { + // QString javaScriptToInject; + // QFile webChannelFile(":qtwebchannel/qwebchannel.js"); + // QFile createGlobalEventBridgeFile(PathUtils::resourcesPath() + "/html/createGlobalEventBridge.js"); + // if (webChannelFile.open(QFile::ReadOnly | QFile::Text) && + // createGlobalEventBridgeFile.open(QFile::ReadOnly | QFile::Text)) { + // QString webChannelStr = QTextStream(&webChannelFile).readAll(); + // QString createGlobalEventBridgeStr = QTextStream(&createGlobalEventBridgeFile).readAll(); + // // concatenate these js files + // _javaScriptToInject = webChannelStr + createGlobalEventBridgeStr; + // } + // } + QUrl sourceUrl(_url); if (sourceUrl.scheme() == "http" || sourceUrl.scheme() == "https" || _url.toLower().endsWith(".htm") || _url.toLower().endsWith(".html")) { _webSurface->setBaseUrl(QUrl::fromLocalFile(PathUtils::resourcesPath() + "/qml/")); _webSurface->load("Web3DOverlay.qml"); + // _webSurface->load("Web3DOverlay.qml", [&](QQmlContext* context, QObject* obj) { + // qDebug() << "Web3DOverlay::loadSourceURL -- " << _javaScriptToInject; + // context->setContextProperty("eventBridgeJavaScriptToInject", QVariant(_javaScriptToInject)); + // }); _webSurface->resume(); _webSurface->getRootItem()->setProperty("url", _url); _webSurface->getRootItem()->setProperty("scriptURL", _scriptURL); diff --git a/interface/src/ui/overlays/Web3DOverlay.h b/interface/src/ui/overlays/Web3DOverlay.h index 2b9686919d..2dea70cfd6 100644 --- a/interface/src/ui/overlays/Web3DOverlay.h +++ b/interface/src/ui/overlays/Web3DOverlay.h @@ -82,6 +82,8 @@ private: QMetaObject::Connection _emitScriptEventConnection; QMetaObject::Connection _webEventReceivedConnection; + + // QString _javaScriptToInject; }; #endif // hifi_Web3DOverlay_h diff --git a/libraries/script-engine/src/TabletScriptingInterface.cpp b/libraries/script-engine/src/TabletScriptingInterface.cpp index e7f8ebe2cb..3db4d7d840 100644 --- a/libraries/script-engine/src/TabletScriptingInterface.cpp +++ b/libraries/script-engine/src/TabletScriptingInterface.cpp @@ -215,6 +215,7 @@ void TabletProxy::gotoMenuScreen() { void TabletProxy::loadQMLSource(const QVariant& path) { if (_qmlTabletRoot) { if (_state != State::QML) { + // _qmlTabletRoot->setProperty("eventBridge", QVariant::fromValue(_qmlOffscreenSurface)); QMetaObject::invokeMethod(_qmlTabletRoot, "loadSource", Q_ARG(const QVariant&, path)); _state = State::QML; } @@ -370,7 +371,7 @@ QQuickItem* TabletProxy::getQmlTablet() const { } QQuickItem* TabletProxy::getQmlMenu() const { - if (!_qmlTabletRoot) { + if (!_qmlTabletRoot) { return nullptr; } @@ -391,6 +392,15 @@ QQuickItem* TabletProxy::getQmlMenu() const { return menuList; } +QQuickItem* TabletProxy::findChild(QString childName) const { + if (!_qmlTabletRoot) { + return nullptr; + } + + return _qmlTabletRoot->findChild(childName); +} + + // // TabletButtonProxy // diff --git a/libraries/script-engine/src/TabletScriptingInterface.h b/libraries/script-engine/src/TabletScriptingInterface.h index a005152fa9..f5032dbff6 100644 --- a/libraries/script-engine/src/TabletScriptingInterface.h +++ b/libraries/script-engine/src/TabletScriptingInterface.h @@ -130,6 +130,8 @@ public: QQuickItem* getQmlMenu() const; + Q_INVOKABLE QQuickItem* findChild(QString childName) const; + signals: /**jsdoc * Signaled when this tablet receives an event from the html/js embedded in the tablet diff --git a/scripts/system/edit.js b/scripts/system/edit.js index f8cce6a544..9fa6d89bcc 100644 --- a/scripts/system/edit.js +++ b/scripts/system/edit.js @@ -457,7 +457,7 @@ var toolBar = (function () { that.toggle = function () { that.setActive(!isActive); - activeButton.editProperties({isActive: isActive}); + // activeButton.editProperties({isActive: isActive}); }; that.setActive = function (active) { @@ -1436,11 +1436,12 @@ var ServerScriptStatusMonitor = function(entityID, statusCallback) { var PropertiesTool = function (opts) { var that = {}; - var webView = new OverlayWebWindow({ - title: 'Entity Properties', - source: ENTITY_PROPERTIES_URL, - toolWindow: true - }); + var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system"); + // var webView = new OverlayWebWindow({ + // title: 'Entity Properties', + // source: ENTITY_PROPERTIES_URL, + // toolWindow: true + // }); var visible = false; @@ -1449,16 +1450,20 @@ var PropertiesTool = function (opts) { var currentSelectedEntityID = null; var statusMonitor = null; - webView.setVisible(visible); + // webView.setVisible(visible); that.setVisible = function (newVisible) { + print("PropertiesTool.setVisible --> " + newVisible); visible = newVisible; - webView.setVisible(visible); + // webView.setVisible(visible); + if (visible) { + tablet.loadQMLSource("Edit.qml"); + } }; function updateScriptStatus(info) { info.type = "server_script_status"; - webView.emitScriptEvent(JSON.stringify(info)); + tablet.emitScriptEvent(JSON.stringify(info)); }; function resetScriptStatus() { @@ -1510,10 +1515,10 @@ var PropertiesTool = function (opts) { selections.push(entity); } data.selections = selections; - webView.emitScriptEvent(JSON.stringify(data)); + tablet.emitScriptEvent(JSON.stringify(data)); }); - webView.webEventReceived.connect(function (data) { + tablet.webEventReceived.connect(function (data) { try { data = JSON.parse(data); } diff --git a/scripts/system/html/js/entityProperties.js b/scripts/system/html/js/entityProperties.js index 6b3bdaa0a4..63e964c218 100644 --- a/scripts/system/html/js/entityProperties.js +++ b/scripts/system/html/js/entityProperties.js @@ -710,6 +710,7 @@ function loaded() { if (window.EventBridge !== undefined) { var properties; + console.log("HERE -- " + (typeof EventBridge) + " -- " + JSON.stringify(EventBridge)); EventBridge.scriptEventReceived.connect(function(data) { data = JSON.parse(data); if (data.type == "server_script_status") { From e12c77e5766069ecbaa5ceb4b823542b48a58d4a Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Thu, 9 Feb 2017 14:43:44 -0800 Subject: [PATCH 03/89] move the edit tabs into tablet --- interface/resources/qml/hifi/tablet/Edit.qml | 58 ++++++++++++++++++++ scripts/system/edit.js | 8 +-- scripts/system/libraries/entityList.js | 22 ++++---- scripts/system/libraries/gridTool.js | 13 +++-- 4 files changed, 81 insertions(+), 20 deletions(-) create mode 100644 interface/resources/qml/hifi/tablet/Edit.qml diff --git a/interface/resources/qml/hifi/tablet/Edit.qml b/interface/resources/qml/hifi/tablet/Edit.qml new file mode 100644 index 0000000000..cdefefd49e --- /dev/null +++ b/interface/resources/qml/hifi/tablet/Edit.qml @@ -0,0 +1,58 @@ +import QtQuick 2.5 +import QtQuick.Controls 1.0 +import QtWebEngine 1.1 +import QtWebChannel 1.0 +import "../../controls" +import HFWebEngineProfile 1.0 + +Item { + id: editRoot + property var eventBridge; + + TabView { + id: editTabView + anchors.fill: parent + + Tab { + active: true + enabled: true + property string originalUrl: "" + + WebView { + id: entityListToolWebView + url: "../../../../../scripts/system/html/entityList.html" + eventBridge: editRoot.eventBridge + anchors.fill: parent + enabled: true + } + } + + Tab { + active: true + enabled: true + property string originalUrl: "" + + WebView { + id: entityPropertiesWebView + url: "../../../../../scripts/system/html/entityProperties.html" + eventBridge: editRoot.eventBridge + anchors.fill: parent + enabled: true + } + } + + Tab { + active: true + enabled: true + property string originalUrl: "" + + WebView { + id: entityPropertiesWebView + url: "../../../../../scripts/system/html/gridControls.html" + eventBridge: editRoot.eventBridge + anchors.fill: parent + enabled: true + } + } + } +} diff --git a/scripts/system/edit.js b/scripts/system/edit.js index aedc0f81fe..efd1e0bf3b 100644 --- a/scripts/system/edit.js +++ b/scripts/system/edit.js @@ -482,6 +482,8 @@ var toolBar = (function () { cameraManager.disable(); selectionDisplay.triggerMapping.disable(); } else { + var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system"); + tablet.loadQMLSource("Edit.qml"); UserActivityLogger.enabledEdit(); entityListTool.setVisible(true); gridTool.setVisible(true); @@ -1453,12 +1455,8 @@ var PropertiesTool = function (opts) { // webView.setVisible(visible); that.setVisible = function (newVisible) { - print("PropertiesTool.setVisible --> " + newVisible); visible = newVisible; // webView.setVisible(visible); - if (visible) { - webView.loadQMLSource("Edit.qml"); - } }; function updateScriptStatus(info) { @@ -1521,7 +1519,7 @@ var PropertiesTool = function (opts) { webView.webEventReceived.connect(function (data) { try { data = JSON.parse(data); - print("--- edit.js webView.webEventReceived ---"); + print("--- edit.js PropertiesTool webView.webEventReceived ---"); } catch(e) { print('Edit.js received web event that was not valid json.') diff --git a/scripts/system/libraries/entityList.js b/scripts/system/libraries/entityList.js index 6dc2486ffb..ff3aa41662 100644 --- a/scripts/system/libraries/entityList.js +++ b/scripts/system/libraries/entityList.js @@ -4,9 +4,10 @@ EntityListTool = function(opts) { var that = {}; var url = ENTITY_LIST_HTML_URL; - var webView = new OverlayWebWindow({ - title: 'Entity List', source: url, toolWindow: true - }); + var webView = Tablet.getTablet("com.highfidelity.interface.tablet.system"); + // var webView = new OverlayWebWindow({ + // title: 'Entity List', source: url, toolWindow: true + // }); var filterInView = false; @@ -14,13 +15,13 @@ EntityListTool = function(opts) { var visible = false; - webView.setVisible(visible); + // webView.setVisible(visible); that.webView = webView; that.setVisible = function(newVisible) { visible = newVisible; - webView.setVisible(visible); + // webView.setVisible(visible); }; that.toggleVisible = function() { @@ -100,6 +101,7 @@ EntityListTool = function(opts) { webView.webEventReceived.connect(function(data) { data = JSON.parse(data); + print("--- edit.js EntityList webView.webEventReceived ---"); if (data.type == "selectionUpdate") { var ids = data.entityIds; var entityIDs = []; @@ -149,11 +151,11 @@ EntityListTool = function(opts) { } }); - webView.visibleChanged.connect(function () { - if (webView.visible) { - that.sendUpdate(); - } - }); + // webView.visibleChanged.connect(function () { + // if (webView.visible) { + // that.sendUpdate(); + // } + // }); return that; }; diff --git a/scripts/system/libraries/gridTool.js b/scripts/system/libraries/gridTool.js index c002aec3b1..0b040246f7 100644 --- a/scripts/system/libraries/gridTool.js +++ b/scripts/system/libraries/gridTool.js @@ -228,10 +228,12 @@ GridTool = function(opts) { var verticalGrid = opts.verticalGrid; var listeners = []; - var url = GRID_CONTROLS_HTML_URL; - var webView = new OverlayWebWindow({ - title: 'Grid', source: url, toolWindow: true - }); + var webView = Tablet.getTablet("com.highfidelity.interface.tablet.system"); + // var url = GRID_CONTROLS_HTML_URL; + // var webView = new OverlayWebWindow({ + // title: 'Grid', source: url, toolWindow: true + // }); + horizontalGrid.addListener(function(data) { webView.emitScriptEvent(JSON.stringify(data)); @@ -240,6 +242,7 @@ GridTool = function(opts) { webView.webEventReceived.connect(function(data) { data = JSON.parse(data); + print("--- edit.js GridTool webView.webEventReceived ---"); if (data.type == "init") { horizontalGrid.emitUpdate(); } else if (data.type == "update") { @@ -268,7 +271,7 @@ GridTool = function(opts) { } that.setVisible = function(visible) { - webView.setVisible(visible); + // webView.setVisible(visible); } return that; From 24fc9bbe6703c1f3f96d0fbb4f20cbb7401fa303 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Thu, 9 Feb 2017 15:12:01 -0800 Subject: [PATCH 04/89] honor HUDUIEnabled setting --- scripts/system/edit.js | 37 +++++++++++++++++--------- scripts/system/libraries/entityList.js | 21 ++++++++------- scripts/system/libraries/gridTool.js | 19 +++++++------ 3 files changed, 48 insertions(+), 29 deletions(-) diff --git a/scripts/system/edit.js b/scripts/system/edit.js index efd1e0bf3b..c91e97cf56 100644 --- a/scripts/system/edit.js +++ b/scripts/system/edit.js @@ -256,6 +256,11 @@ var toolBar = (function () { text: "EDIT", sortOrder: 10 }); + tablet.screenChanged.connect(function (type, url) { + if (isActive && (type !== "QML" || url !== "Edit.qml")) { + that.toggle(); + } + }); } activeButton.clicked.connect(function() { @@ -457,7 +462,9 @@ var toolBar = (function () { that.toggle = function () { that.setActive(!isActive); - // activeButton.editProperties({isActive: isActive}); + if (Settings.getValue("HUDUIEnabled")) { + activeButton.editProperties({isActive: isActive}); + } }; that.setActive = function (active) { @@ -482,8 +489,10 @@ var toolBar = (function () { cameraManager.disable(); selectionDisplay.triggerMapping.disable(); } else { - var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system"); - tablet.loadQMLSource("Edit.qml"); + if (!Settings.getValue("HUDUIEnabled")) { + var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system"); + tablet.loadQMLSource("Edit.qml"); + } UserActivityLogger.enabledEdit(); entityListTool.setVisible(true); gridTool.setVisible(true); @@ -1438,12 +1447,17 @@ var ServerScriptStatusMonitor = function(entityID, statusCallback) { var PropertiesTool = function (opts) { var that = {}; - var webView = Tablet.getTablet("com.highfidelity.interface.tablet.system"); - // var webView = new OverlayWebWindow({ - // title: 'Entity Properties', - // source: ENTITY_PROPERTIES_URL, - // toolWindow: true - // }); + var webView = null; + if (Settings.getValue("HUDUIEnabled")) { + webView = new OverlayWebWindow({ + title: 'Entity Properties', + source: ENTITY_PROPERTIES_URL, + toolWindow: true + }); + } else { + webView = Tablet.getTablet("com.highfidelity.interface.tablet.system"); + webView.setVisible = function(value) {}; + } var visible = false; @@ -1452,11 +1466,11 @@ var PropertiesTool = function (opts) { var currentSelectedEntityID = null; var statusMonitor = null; - // webView.setVisible(visible); + webView.setVisible(visible); that.setVisible = function (newVisible) { visible = newVisible; - // webView.setVisible(visible); + webView.setVisible(visible); }; function updateScriptStatus(info) { @@ -1519,7 +1533,6 @@ var PropertiesTool = function (opts) { webView.webEventReceived.connect(function (data) { try { data = JSON.parse(data); - print("--- edit.js PropertiesTool webView.webEventReceived ---"); } catch(e) { print('Edit.js received web event that was not valid json.') diff --git a/scripts/system/libraries/entityList.js b/scripts/system/libraries/entityList.js index ff3aa41662..8ef028cdce 100644 --- a/scripts/system/libraries/entityList.js +++ b/scripts/system/libraries/entityList.js @@ -3,25 +3,29 @@ var ENTITY_LIST_HTML_URL = Script.resolvePath('../html/entityList.html'); EntityListTool = function(opts) { var that = {}; - var url = ENTITY_LIST_HTML_URL; - var webView = Tablet.getTablet("com.highfidelity.interface.tablet.system"); - // var webView = new OverlayWebWindow({ - // title: 'Entity List', source: url, toolWindow: true - // }); - + var webView = null; + if (Settings.getValue("HUDUIEnabled")) { + var url = ENTITY_LIST_HTML_URL; + webView = new OverlayWebWindow({ + title: 'Entity List', source: url, toolWindow: true + }); + } else { + webView = Tablet.getTablet("com.highfidelity.interface.tablet.system"); + webView.setVisible = function(value) {}; + } var filterInView = false; var searchRadius = 100; var visible = false; - // webView.setVisible(visible); + webView.setVisible(visible); that.webView = webView; that.setVisible = function(newVisible) { visible = newVisible; - // webView.setVisible(visible); + webView.setVisible(visible); }; that.toggleVisible = function() { @@ -101,7 +105,6 @@ EntityListTool = function(opts) { webView.webEventReceived.connect(function(data) { data = JSON.parse(data); - print("--- edit.js EntityList webView.webEventReceived ---"); if (data.type == "selectionUpdate") { var ids = data.entityIds; var entityIDs = []; diff --git a/scripts/system/libraries/gridTool.js b/scripts/system/libraries/gridTool.js index 0b040246f7..7176fd00a6 100644 --- a/scripts/system/libraries/gridTool.js +++ b/scripts/system/libraries/gridTool.js @@ -228,12 +228,16 @@ GridTool = function(opts) { var verticalGrid = opts.verticalGrid; var listeners = []; - var webView = Tablet.getTablet("com.highfidelity.interface.tablet.system"); - // var url = GRID_CONTROLS_HTML_URL; - // var webView = new OverlayWebWindow({ - // title: 'Grid', source: url, toolWindow: true - // }); - + var webView = null; + if (Settings.getValue("HUDUIEnabled")) { + var url = GRID_CONTROLS_HTML_URL; + webView = new OverlayWebWindow({ + title: 'Grid', source: url, toolWindow: true + }); + } else { + webView = Tablet.getTablet("com.highfidelity.interface.tablet.system"); + webView.setVisible = function(value) {}; + } horizontalGrid.addListener(function(data) { webView.emitScriptEvent(JSON.stringify(data)); @@ -242,7 +246,6 @@ GridTool = function(opts) { webView.webEventReceived.connect(function(data) { data = JSON.parse(data); - print("--- edit.js GridTool webView.webEventReceived ---"); if (data.type == "init") { horizontalGrid.emitUpdate(); } else if (data.type == "update") { @@ -271,7 +274,7 @@ GridTool = function(opts) { } that.setVisible = function(visible) { - // webView.setVisible(visible); + webView.setVisible(visible); } return that; From d0d13cdde1ac0357d96d09ef5b823ebd3043e16a Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Thu, 9 Feb 2017 15:52:15 -0800 Subject: [PATCH 05/89] fix tab titles --- interface/resources/qml/hifi/tablet/Edit.qml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/interface/resources/qml/hifi/tablet/Edit.qml b/interface/resources/qml/hifi/tablet/Edit.qml index cdefefd49e..e95e0f2fc0 100644 --- a/interface/resources/qml/hifi/tablet/Edit.qml +++ b/interface/resources/qml/hifi/tablet/Edit.qml @@ -14,6 +14,7 @@ Item { anchors.fill: parent Tab { + title: "Entity List" active: true enabled: true property string originalUrl: "" @@ -28,6 +29,7 @@ Item { } Tab { + title: "Entity Properties" active: true enabled: true property string originalUrl: "" @@ -42,6 +44,7 @@ Item { } Tab { + title: "Grid" active: true enabled: true property string originalUrl: "" From 7a63b07462f7efa9ffaa1c5cf48cc8c1c4a79277 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Thu, 9 Feb 2017 17:14:10 -0800 Subject: [PATCH 06/89] attempting to handle new-model dialog --- .../qml/hifi/tablet/NewModelDialog.qml | 118 ++++++++++++++++++ scripts/system/edit.js | 80 ++++++------ 2 files changed, 162 insertions(+), 36 deletions(-) create mode 100644 interface/resources/qml/hifi/tablet/NewModelDialog.qml diff --git a/interface/resources/qml/hifi/tablet/NewModelDialog.qml b/interface/resources/qml/hifi/tablet/NewModelDialog.qml new file mode 100644 index 0000000000..f2aaf0f3a5 --- /dev/null +++ b/interface/resources/qml/hifi/tablet/NewModelDialog.qml @@ -0,0 +1,118 @@ +import QtQuick 2.5 +import QtQuick.Window 2.2 +import QtQuick.Controls 1.5 + +Item { + id: newModelDialog + property var eventBridge; + + Column { + id: column1 + anchors.rightMargin: 10 + anchors.leftMargin: 10 + anchors.bottomMargin: 10 + anchors.topMargin: 10 + anchors.fill: parent + spacing: 5 + + Text { + id: text1 + text: qsTr("Model URL") + font.pixelSize: 12 + } + + TextInput { + id: textInput1 + height: 20 + text: qsTr("") + anchors.left: parent.left + anchors.leftMargin: 0 + anchors.right: parent.right + anchors.rightMargin: 0 + font.pixelSize: 12 + } + + Row { + id: row1 + height: 400 + spacing: 30 + anchors.left: parent.left + anchors.leftMargin: 0 + anchors.right: parent.right + anchors.rightMargin: 0 + + Column { + id: column2 + width: 200 + height: 400 + + CheckBox { + id: checkBox1 + text: qsTr("Dynamic") + } + + Row { + id: row2 + width: 200 + height: 400 + spacing: 20 + + Image { + id: image1 + width: 30 + height: 30 + source: "qrc:/qtquickplugin/images/template_image.png" + } + + Text { + id: text2 + width: 160 + text: qsTr("Models with automatic collisions set to 'Exact' cannot be dynamic") + wrapMode: Text.WordWrap + font.pixelSize: 12 + } + } + } + + Column { + id: column3 + height: 400 + + Text { + id: text3 + text: qsTr("Automatic Collisions") + font.pixelSize: 12 + } + + ComboBox { + id: comboBox1 + width: 200 + transformOrigin: Item.Center + model: ListModel { + id: collisionDropdown + ListElement { text: "No Collision" } + ListElement { text: "Basic - Whole model" } + ListElement { text: "Good - Sub-meshes" } + ListElement { text: "Exact - All polygons" } + } + } + + Row { + id: row3 + width: 200 + height: 400 + + Button { + id: button1 + text: qsTr("Add") + } + + Button { + id: button2 + text: qsTr("Cancel") + } + } + } + } + } +} diff --git a/scripts/system/edit.js b/scripts/system/edit.js index c91e97cf56..9df6a30322 100644 --- a/scripts/system/edit.js +++ b/scripts/system/edit.js @@ -287,30 +287,33 @@ var toolBar = (function () { var SHAPE_TYPE_DEFAULT = SHAPE_TYPE_STATIC_MESH; var DYNAMIC_DEFAULT = false; - var result = Window.customPrompt({ - textInput: { - label: "Model URL" - }, - comboBox: { - label: "Automatic Collisions", - index: SHAPE_TYPE_DEFAULT, - items: SHAPE_TYPES - }, - checkBox: { - label: "Dynamic", - checked: DYNAMIC_DEFAULT, - disableForItems: [ - SHAPE_TYPE_STATIC_MESH - ], - checkStateOnDisable: false, - warningOnDisable: "Models with automatic collisions set to 'Exact' cannot be dynamic" - } - }); - if (result) { - var url = result.textInput; - var shapeType; - switch (result.comboBox) { + if (Settings.getValue("HUDUIEnabled")) { + // HUD-ui version of new-model dialog + var result = Window.customPrompt({ + textInput: { + label: "Model URL" + }, + comboBox: { + label: "Automatic Collisions", + index: SHAPE_TYPE_DEFAULT, + items: SHAPE_TYPES + }, + checkBox: { + label: "Dynamic", + checked: DYNAMIC_DEFAULT, + disableForItems: [ + SHAPE_TYPE_STATIC_MESH + ], + checkStateOnDisable: false, + warningOnDisable: "Models with automatic collisions set to 'Exact' cannot be dynamic" + } + }); + + if (result) { + var url = result.textInput; + var shapeType; + switch (result.comboBox) { case SHAPE_TYPE_SIMPLE_HULL: shapeType = "simple-hull"; break; @@ -322,21 +325,26 @@ var toolBar = (function () { break; default: shapeType = "none"; - } + } - var dynamic = result.checkBox !== null ? result.checkBox : DYNAMIC_DEFAULT; - if (shapeType === "static-mesh" && dynamic) { - // The prompt should prevent this case - print("Error: model cannot be both static mesh and dynamic. This should never happen."); - } else if (url) { - createNewEntity({ - type: "Model", - modelURL: url, - shapeType: shapeType, - dynamic: dynamic, - gravity: dynamic ? { x: 0, y: -10, z: 0 } : { x: 0, y: 0, z: 0 } - }); + var dynamic = result.checkBox !== null ? result.checkBox : DYNAMIC_DEFAULT; + if (shapeType === "static-mesh" && dynamic) { + // The prompt should prevent this case + print("Error: model cannot be both static mesh and dynamic. This should never happen."); + } else if (url) { + createNewEntity({ + type: "Model", + modelURL: url, + shapeType: shapeType, + dynamic: dynamic, + gravity: dynamic ? { x: 0, y: -10, z: 0 } : { x: 0, y: 0, z: 0 } + }); + } } + } else { + // tablet version of new-model dialog + var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system"); + tablet.loadQMLSource("NewModelDialog.qml"); } }); From 3171ce160269b5312969952e547e024c02d1f81f Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Fri, 10 Feb 2017 12:03:26 -0800 Subject: [PATCH 07/89] hook up more of new-model dialog --- interface/resources/qml/hifi/tablet/Edit.qml | 87 +++++++++++-------- .../qml/hifi/tablet/NewModelDialog.qml | 28 +++++- .../src/TabletScriptingInterface.cpp | 29 +++++++ .../src/TabletScriptingInterface.h | 2 + scripts/system/edit.js | 14 ++- 5 files changed, 120 insertions(+), 40 deletions(-) diff --git a/interface/resources/qml/hifi/tablet/Edit.qml b/interface/resources/qml/hifi/tablet/Edit.qml index cdefefd49e..fe13397c99 100644 --- a/interface/resources/qml/hifi/tablet/Edit.qml +++ b/interface/resources/qml/hifi/tablet/Edit.qml @@ -5,53 +5,70 @@ import QtWebChannel 1.0 import "../../controls" import HFWebEngineProfile 1.0 -Item { +StackView { id: editRoot + objectName: "stack" + initialItem: editBasePage + property var eventBridge; + signal sendToScript(var message); - TabView { - id: editTabView - anchors.fill: parent + function pushSource(path) { + editRoot.push(Qt.resolvedUrl(path)); + editRoot.currentItem.eventBridge = editRoot.eventBridge; + editRoot.currentItem.sendToScript.connect(editRoot.sendToScript); + } - Tab { - active: true - enabled: true - property string originalUrl: "" + function popSource() { + editRoot.pop(); + } - WebView { - id: entityListToolWebView - url: "../../../../../scripts/system/html/entityList.html" - eventBridge: editRoot.eventBridge - anchors.fill: parent + Component { + id: editBasePage + TabView { + id: editTabView + anchors.fill: parent + + Tab { + active: true enabled: true + property string originalUrl: "" + + WebView { + id: entityListToolWebView + url: "../../../../../scripts/system/html/entityList.html" + eventBridge: editRoot.eventBridge + anchors.fill: parent + enabled: true + } } - } - Tab { - active: true - enabled: true - property string originalUrl: "" - - WebView { - id: entityPropertiesWebView - url: "../../../../../scripts/system/html/entityProperties.html" - eventBridge: editRoot.eventBridge - anchors.fill: parent + Tab { + active: true enabled: true + property string originalUrl: "" + + WebView { + id: entityPropertiesWebView + url: "../../../../../scripts/system/html/entityProperties.html" + eventBridge: editRoot.eventBridge + anchors.fill: parent + enabled: true + } } - } - Tab { - active: true - enabled: true - property string originalUrl: "" - - WebView { - id: entityPropertiesWebView - url: "../../../../../scripts/system/html/gridControls.html" - eventBridge: editRoot.eventBridge - anchors.fill: parent + Tab { + active: true enabled: true + property string originalUrl: "" + + WebView { + id: entityPropertiesWebView + url: "../../../../../scripts/system/html/gridControls.html" + eventBridge: editRoot.eventBridge + anchors.fill: parent + enabled: true + } } } } diff --git a/interface/resources/qml/hifi/tablet/NewModelDialog.qml b/interface/resources/qml/hifi/tablet/NewModelDialog.qml index f2aaf0f3a5..15d7fc3616 100644 --- a/interface/resources/qml/hifi/tablet/NewModelDialog.qml +++ b/interface/resources/qml/hifi/tablet/NewModelDialog.qml @@ -1,10 +1,24 @@ -import QtQuick 2.5 -import QtQuick.Window 2.2 -import QtQuick.Controls 1.5 +// +// NewModelDialog.qml +// qml/hifi +// +// Created by Seth Alves on 2017-2-10 +// Copyright 2017 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// -Item { +import QtQuick 2.5 +import QtQuick.Controls 1.4 + +Rectangle { id: newModelDialog + width: parent.width + height: parent.height + property var eventBridge; + signal sendToScript(var message); Column { id: column1 @@ -105,11 +119,17 @@ Item { Button { id: button1 text: qsTr("Add") + onClicked: { + newModelDialog.sendToScript({method: 'newModelDialogAdd'}) + } } Button { id: button2 text: qsTr("Cancel") + onClicked: { + newModelDialog.sendToScript({method: 'newModelDialogCancel'}) + } } } } diff --git a/libraries/script-engine/src/TabletScriptingInterface.cpp b/libraries/script-engine/src/TabletScriptingInterface.cpp index 2e64be750f..fe68f350d2 100644 --- a/libraries/script-engine/src/TabletScriptingInterface.cpp +++ b/libraries/script-engine/src/TabletScriptingInterface.cpp @@ -234,8 +234,37 @@ void TabletProxy::loadQMLSource(const QVariant& path) { _state = State::QML; emit screenChanged(QVariant("QML"), path); } + } else { + qCDebug(scriptengine) << "tablet cannot load QML because _qmlTabletRoot is null"; } } + +void TabletProxy::pushOntoStack(const QVariant& path) { + if (_qmlTabletRoot) { + auto stack = _qmlTabletRoot->findChild("stack"); + if (stack) { + QMetaObject::invokeMethod(stack, "pushSource", Q_ARG(const QVariant&, path)); + } else { + qCDebug(scriptengine) << "tablet cannot push QML because _qmlTabletRoot doesn't have child stack"; + } + } else { + qCDebug(scriptengine) << "tablet cannot push QML because _qmlTabletRoot is null"; + } +} + +void TabletProxy::popFromStack() { + if (_qmlTabletRoot) { + auto stack = _qmlTabletRoot->findChild("stack"); + if (stack) { + QMetaObject::invokeMethod(stack, "popSource"); + } else { + qCDebug(scriptengine) << "tablet cannot pop QML because _qmlTabletRoot doesn't have child stack"; + } + } else { + qCDebug(scriptengine) << "tablet cannot pop QML because _qmlTabletRoot is null"; + } +} + void TabletProxy::gotoHomeScreen() { if (_qmlTabletRoot) { if (_state != State::Home) { diff --git a/libraries/script-engine/src/TabletScriptingInterface.h b/libraries/script-engine/src/TabletScriptingInterface.h index 93f5bcf6ba..ff2213dfcc 100644 --- a/libraries/script-engine/src/TabletScriptingInterface.h +++ b/libraries/script-engine/src/TabletScriptingInterface.h @@ -90,6 +90,8 @@ public: Q_INVOKABLE void gotoWebScreen(const QString& url, const QString& injectedJavaScriptUrl); Q_INVOKABLE void loadQMLSource(const QVariant& path); + Q_INVOKABLE void pushOntoStack(const QVariant& path); + Q_INVOKABLE void popFromStack(); /**jsdoc * Creates a new button, adds it to this and returns it. diff --git a/scripts/system/edit.js b/scripts/system/edit.js index 9df6a30322..95b75ff343 100644 --- a/scripts/system/edit.js +++ b/scripts/system/edit.js @@ -225,6 +225,16 @@ var toolBar = (function () { return button; } + function fromQml(message) { // messages are {method, params}, like json-rpc. See also sendToQml. + print("fromQml: " + JSON.stringify(message)); + var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system"); + tablet.popFromStack(); + // switch (message.method) { + // case 'selected': + // break; + // } + } + function initialize() { Script.scriptEnding.connect(cleanup); @@ -249,6 +259,7 @@ var toolBar = (function () { alpha: 0.9, defaultState: 1 }); + systemToolbar.fromQml.connect(fromQml); } else { tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system"); activeButton = tablet.addButton({ @@ -261,6 +272,7 @@ var toolBar = (function () { that.toggle(); } }); + tablet.fromQml.connect(fromQml); } activeButton.clicked.connect(function() { @@ -344,7 +356,7 @@ var toolBar = (function () { } else { // tablet version of new-model dialog var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system"); - tablet.loadQMLSource("NewModelDialog.qml"); + tablet.pushOntoStack("NewModelDialog.qml"); } }); From 0b358a2ac7fbd22be36bb988e89bb94031daf284 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Fri, 10 Feb 2017 13:29:06 -0800 Subject: [PATCH 08/89] finish hooking up new-model dialog --- .../qml/hifi/tablet/NewModelDialog.qml | 21 ++- scripts/system/edit.js | 132 +++++++++--------- 2 files changed, 81 insertions(+), 72 deletions(-) diff --git a/interface/resources/qml/hifi/tablet/NewModelDialog.qml b/interface/resources/qml/hifi/tablet/NewModelDialog.qml index 15d7fc3616..246e8d515d 100644 --- a/interface/resources/qml/hifi/tablet/NewModelDialog.qml +++ b/interface/resources/qml/hifi/tablet/NewModelDialog.qml @@ -14,8 +14,8 @@ import QtQuick.Controls 1.4 Rectangle { id: newModelDialog - width: parent.width - height: parent.height + // width: parent.width + // height: parent.height property var eventBridge; signal sendToScript(var message); @@ -36,7 +36,7 @@ Rectangle { } TextInput { - id: textInput1 + id: modelURL height: 20 text: qsTr("") anchors.left: parent.left @@ -59,9 +59,10 @@ Rectangle { id: column2 width: 200 height: 400 + spacing: 10 CheckBox { - id: checkBox1 + id: dynamic text: qsTr("Dynamic") } @@ -91,6 +92,7 @@ Rectangle { Column { id: column3 height: 400 + spacing: 10 Text { id: text3 @@ -99,7 +101,7 @@ Rectangle { } ComboBox { - id: comboBox1 + id: collisionType width: 200 transformOrigin: Item.Center model: ListModel { @@ -120,7 +122,14 @@ Rectangle { id: button1 text: qsTr("Add") onClicked: { - newModelDialog.sendToScript({method: 'newModelDialogAdd'}) + newModelDialog.sendToScript({ + method: 'newModelDialogAdd', + params: { + textInput: modelURL.text, + checkBox: dynamic.checked, + comboBox: collisionType.currentIndex + } + }); } } diff --git a/scripts/system/edit.js b/scripts/system/edit.js index 95b75ff343..bc977b84eb 100644 --- a/scripts/system/edit.js +++ b/scripts/system/edit.js @@ -13,6 +13,8 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +/* global Script, SelectionDisplay, LightOverlayManager, CameraManager, Grid, GridTool, EntityListTook, EntityListTool, Vec3, SelectionManager, Overlays, OverlayWebWindow, UserActivityLogger, Settings, Entities, Tablet, Toolbars, Messages, Menu, Camera, progressDialog, tooltip, MyAvatar, Quat, Controller, Clipboard, HMD, UndoStack, ParticleExplorerTool */ + (function() { // BEGIN LOCAL_SCOPE var HIFI_PUBLIC_BUCKET = "http://s3.amazonaws.com/hifi-public/"; @@ -58,18 +60,13 @@ selectionManager.addEventListener(function () { var DEGREES_TO_RADIANS = Math.PI / 180.0; var RADIANS_TO_DEGREES = 180.0 / Math.PI; -var epsilon = 0.001; var MIN_ANGULAR_SIZE = 2; var MAX_ANGULAR_SIZE = 45; var allowLargeModels = true; var allowSmallModels = true; -var SPAWN_DISTANCE = 1; var DEFAULT_DIMENSION = 0.20; -var DEFAULT_TEXT_DIMENSION_X = 1.0; -var DEFAULT_TEXT_DIMENSION_Y = 1.0; -var DEFAULT_TEXT_DIMENSION_Z = 0.01; var DEFAULT_DIMENSIONS = { x: DEFAULT_DIMENSION, @@ -84,7 +81,6 @@ var MENU_EASE_ON_FOCUS = "Ease Orientation on Focus"; var MENU_SHOW_LIGHTS_IN_EDIT_MODE = "Show Lights in Edit Mode"; var MENU_SHOW_ZONES_IN_EDIT_MODE = "Show Zones in Edit Mode"; -var SETTING_INSPECT_TOOL_ENABLED = "inspectToolEnabled"; var SETTING_AUTO_FOCUS_ON_SELECT = "autoFocusOnSelect"; var SETTING_EASE_ON_FOCUS = "cameraEaseOnFocus"; var SETTING_SHOW_LIGHTS_IN_EDIT_MODE = "showLightsInEditMode"; @@ -156,13 +152,13 @@ function hideMarketplace() { marketplaceWindow.setURL("about:blank"); } -function toggleMarketplace() { - if (marketplaceWindow.visible) { - hideMarketplace(); - } else { - showMarketplace(); - } -} +// function toggleMarketplace() { +// if (marketplaceWindow.visible) { +// hideMarketplace(); +// } else { +// showMarketplace(); +// } +// } var TOOLS_PATH = Script.resolvePath("assets/images/tools/"); @@ -225,14 +221,55 @@ var toolBar = (function () { return button; } + var SHAPE_TYPE_NONE = 0; + var SHAPE_TYPE_SIMPLE_HULL = 1; + var SHAPE_TYPE_SIMPLE_COMPOUND = 2; + var SHAPE_TYPE_STATIC_MESH = 3; + var DYNAMIC_DEFAULT = false; + + function handleNewModelDialogResult(result) { + if (result) { + var url = result.textInput; + var shapeType; + switch (result.comboBox) { + case SHAPE_TYPE_SIMPLE_HULL: + shapeType = "simple-hull"; + break; + case SHAPE_TYPE_SIMPLE_COMPOUND: + shapeType = "simple-compound"; + break; + case SHAPE_TYPE_STATIC_MESH: + shapeType = "static-mesh"; + break; + default: + shapeType = "none"; + } + + var dynamic = result.checkBox !== null ? result.checkBox : DYNAMIC_DEFAULT; + if (shapeType === "static-mesh" && dynamic) { + // The prompt should prevent this case + print("Error: model cannot be both static mesh and dynamic. This should never happen."); + } else if (url) { + createNewEntity({ + type: "Model", + modelURL: url, + shapeType: shapeType, + dynamic: dynamic, + gravity: dynamic ? { x: 0, y: -10, z: 0 } : { x: 0, y: 0, z: 0 } + }); + } + } + } + function fromQml(message) { // messages are {method, params}, like json-rpc. See also sendToQml. print("fromQml: " + JSON.stringify(message)); var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system"); tablet.popFromStack(); - // switch (message.method) { - // case 'selected': - // break; - // } + switch (message.method) { + case "newModelDialogAdd": + handleNewModelDialogResult(message.params); + break; + } } function initialize() { @@ -283,22 +320,16 @@ var toolBar = (function () { toolBar.writeProperty("shown", false); addButton("openAssetBrowserButton","assets-01.svg",function(){ Window.showAssetServer(); - }) + }); addButton("newModelButton", "model-01.svg", function () { - var SHAPE_TYPE_NONE = 0; - var SHAPE_TYPE_SIMPLE_HULL = 1; - var SHAPE_TYPE_SIMPLE_COMPOUND = 2; - var SHAPE_TYPE_STATIC_MESH = 3; var SHAPE_TYPES = []; SHAPE_TYPES[SHAPE_TYPE_NONE] = "No Collision"; SHAPE_TYPES[SHAPE_TYPE_SIMPLE_HULL] = "Basic - Whole model"; SHAPE_TYPES[SHAPE_TYPE_SIMPLE_COMPOUND] = "Good - Sub-meshes"; SHAPE_TYPES[SHAPE_TYPE_STATIC_MESH] = "Exact - All polygons"; - var SHAPE_TYPE_DEFAULT = SHAPE_TYPE_STATIC_MESH; - var DYNAMIC_DEFAULT = false; if (Settings.getValue("HUDUIEnabled")) { // HUD-ui version of new-model dialog @@ -322,37 +353,7 @@ var toolBar = (function () { } }); - if (result) { - var url = result.textInput; - var shapeType; - switch (result.comboBox) { - case SHAPE_TYPE_SIMPLE_HULL: - shapeType = "simple-hull"; - break; - case SHAPE_TYPE_SIMPLE_COMPOUND: - shapeType = "simple-compound"; - break; - case SHAPE_TYPE_STATIC_MESH: - shapeType = "static-mesh"; - break; - default: - shapeType = "none"; - } - - var dynamic = result.checkBox !== null ? result.checkBox : DYNAMIC_DEFAULT; - if (shapeType === "static-mesh" && dynamic) { - // The prompt should prevent this case - print("Error: model cannot be both static mesh and dynamic. This should never happen."); - } else if (url) { - createNewEntity({ - type: "Model", - modelURL: url, - shapeType: shapeType, - dynamic: dynamic, - gravity: dynamic ? { x: 0, y: -10, z: 0 } : { x: 0, y: 0, z: 0 } - }); - } - } + handleNewModelDialogResult(result); } else { // tablet version of new-model dialog var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system"); @@ -661,7 +662,6 @@ var idleMouseTimerId = null; var CLICK_TIME_THRESHOLD = 500 * 1000; // 500 ms var CLICK_MOVE_DISTANCE_THRESHOLD = 20; var IDLE_MOUSE_TIMEOUT = 200; -var DEFAULT_ENTITY_DRAG_DROP_DISTANCE = 2.0; var lastMouseMoveEvent = null; @@ -1232,11 +1232,11 @@ function getPositionToCreateEntity() { var position = Vec3.sum(MyAvatar.position, Vec3.multiply(direction, distance)); if (Camera.mode === "entity" || Camera.mode === "independent") { - position = Vec3.sum(Camera.position, Vec3.multiply(Quat.getFront(Camera.orientation), distance)) + position = Vec3.sum(Camera.position, Vec3.multiply(Quat.getFront(Camera.orientation), distance)); } position.y += 0.5; if (position.x > HALF_TREE_SCALE || position.y > HALF_TREE_SCALE || position.z > HALF_TREE_SCALE) { - return null + return null; } return position; } @@ -1250,11 +1250,11 @@ function getPositionToImportEntity() { var position = Vec3.sum(MyAvatar.position, Vec3.multiply(direction, longest)); if (Camera.mode === "entity" || Camera.mode === "independent") { - position = Vec3.sum(Camera.position, Vec3.multiply(Quat.getFront(Camera.orientation), longest)) + position = Vec3.sum(Camera.position, Vec3.multiply(Quat.getFront(Camera.orientation), longest)); } if (position.x > HALF_TREE_SCALE || position.y > HALF_TREE_SCALE || position.z > HALF_TREE_SCALE) { - return null + return null; } return position; @@ -1455,11 +1455,11 @@ var ServerScriptStatusMonitor = function(entityID, statusCallback) { Entities.getServerScriptStatus(entityID, onStatusReceived); } }, 1000); - }; + } }; self.stop = function() { self.active = false; - } + }; Entities.getServerScriptStatus(entityID, onStatusReceived); }; @@ -1496,7 +1496,7 @@ var PropertiesTool = function (opts) { function updateScriptStatus(info) { info.type = "server_script_status"; webView.emitScriptEvent(JSON.stringify(info)); - }; + } function resetScriptStatus() { updateScriptStatus({ @@ -1555,7 +1555,7 @@ var PropertiesTool = function (opts) { data = JSON.parse(data); } catch(e) { - print('Edit.js received web event that was not valid json.') + print('Edit.js received web event that was not valid json.'); return; } var i, properties, dY, diff, newPosition; @@ -1576,12 +1576,12 @@ var PropertiesTool = function (opts) { } else { if (data.properties.dynamic === false) { // this object is leaving dynamic, so we zero its velocities - data.properties["velocity"] = { + data.properties.velocity = { x: 0, y: 0, z: 0 }; - data.properties["angularVelocity"] = { + data.properties.angularVelocity = { x: 0, y: 0, z: 0 From fead52f626e347564fc17eaed892b9996c492646 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Fri, 10 Feb 2017 15:18:01 -0800 Subject: [PATCH 09/89] put new-entity buttons in a tab of the edit app --- interface/resources/qml/hifi/tablet/Edit.qml | 120 +++++++++++++++++- .../qml/hifi/tablet/NewModelDialog.qml | 4 +- scripts/system/edit.js | 39 +++--- .../particle_explorer/particleExplorerTool.js | 25 ++-- 4 files changed, 160 insertions(+), 28 deletions(-) diff --git a/interface/resources/qml/hifi/tablet/Edit.qml b/interface/resources/qml/hifi/tablet/Edit.qml index 4300c80bd8..7cdf706497 100644 --- a/interface/resources/qml/hifi/tablet/Edit.qml +++ b/interface/resources/qml/hifi/tablet/Edit.qml @@ -31,11 +31,112 @@ StackView { anchors.fill: parent Tab { - title: "Entity List" + title: "Create Entities" active: true enabled: true property string originalUrl: "" + Flow { + id: createEntitiesFlow + spacing: 16 + + Button { + iconSource: "../../../../../scripts/system/assets/images/tools/assets-01.svg" + text: "ASSETS" + onClicked: { + editRoot.sendToScript({ + method: "newEntityButtonClicked", params: { buttonName: "openAssetBrowserButton" } + }); + } + } + + Button { + iconSource: "../../../../../scripts/system/assets/images/tools/model-01.svg" + text: "MODEL" + onClicked: { + editRoot.sendToScript({ + method: "newEntityButtonClicked", params: { buttonName: "newModelButton" } + }); + } + } + + Button { + iconSource: "../../../../../scripts/system/assets/images/tools/cube-01.svg" + text: "CUBE" + onClicked: { + editRoot.sendToScript({ + method: "newEntityButtonClicked", params: { buttonName: "newCubeButton" } + }); + } + } + + Button { + iconSource: "../../../../../scripts/system/assets/images/tools/sphere-01.svg" + text: "SPHERE" + onClicked: { + editRoot.sendToScript({ + method: "newEntityButtonClicked", params: { buttonName: "newSphereButton" } + }); + } + } + + Button { + iconSource: "../../../../../scripts/system/assets/images/tools/light-01.svg" + text: "LIGHT" + onClicked: { + editRoot.sendToScript({ + method: "newEntityButtonClicked", params: { buttonName: "newLightButton" } + }); + } + } + + Button { + iconSource: "../../../../../scripts/system/assets/images/tools/text-01.svg" + text: "TEXT" + onClicked: { + editRoot.sendToScript({ + method: "newEntityButtonClicked", params: { buttonName: "newTextButton" } + }); + } + } + + Button { + iconSource: "../../../../../scripts/system/assets/images/tools/web-01.svg" + text: "WEB" + onClicked: { + editRoot.sendToScript({ + method: "newEntityButtonClicked", params: { buttonName: "newWebButton" } + }); + } + } + + Button { + iconSource: "../../../../../scripts/system/assets/images/tools/zone-01.svg" + text: "ZONE" + onClicked: { + editRoot.sendToScript({ + method: "newEntityButtonClicked", params: { buttonName: "newZoneButton" } + }); + } + } + + Button { + iconSource: "../../../../../scripts/system/assets/images/tools/particle-01.svg" + text: "PARTICLE" + onClicked: { + editRoot.sendToScript({ + method: "newEntityButtonClicked", params: { buttonName: "newParticleButton" } + }); + } + } + } + } + + Tab { + title: "Entity List" + active: true + enabled: true + property string originalUrl: "" WebView { id: entityListToolWebView @@ -68,13 +169,28 @@ StackView { property string originalUrl: "" WebView { - id: entityPropertiesWebView + id: gridControlsWebView url: "../../../../../scripts/system/html/gridControls.html" eventBridge: editRoot.eventBridge anchors.fill: parent enabled: true } } + + Tab { + title: "Particle Explorer" + active: true + enabled: true + property string originalUrl: "" + + WebView { + id: particleExplorerWebView + url: "../../../../../scripts/system/particle_explorer/particleExplorer.html" + eventBridge: editRoot.eventBridge + anchors.fill: parent + enabled: true + } + } } } } diff --git a/interface/resources/qml/hifi/tablet/NewModelDialog.qml b/interface/resources/qml/hifi/tablet/NewModelDialog.qml index 246e8d515d..13c0d963ea 100644 --- a/interface/resources/qml/hifi/tablet/NewModelDialog.qml +++ b/interface/resources/qml/hifi/tablet/NewModelDialog.qml @@ -123,7 +123,7 @@ Rectangle { text: qsTr("Add") onClicked: { newModelDialog.sendToScript({ - method: 'newModelDialogAdd', + method: "newModelDialogAdd", params: { textInput: modelURL.text, checkBox: dynamic.checked, @@ -137,7 +137,7 @@ Rectangle { id: button2 text: qsTr("Cancel") onClicked: { - newModelDialog.sendToScript({method: 'newModelDialogCancel'}) + newModelDialog.sendToScript({method: "newModelDialogCancel"}) } } } diff --git a/scripts/system/edit.js b/scripts/system/edit.js index bc977b84eb..d3e2143316 100644 --- a/scripts/system/edit.js +++ b/scripts/system/edit.js @@ -201,24 +201,30 @@ var toolBar = (function () { } } + var buttonHandlers = {}; // only used to tablet mode + function addButton(name, image, handler) { - var imageUrl = TOOLS_PATH + image; - var button = toolBar.addButton({ - objectName: name, - imageURL: imageUrl, - imageOffOut: 1, - imageOffIn: 2, - imageOnOut: 0, - imageOnIn: 2, - alpha: 0.9, - visible: true - }); - if (handler) { - button.clicked.connect(function () { - Script.setTimeout(handler, 100); + if (Settings.getValue("HUDUIEnabled")) { + var imageUrl = TOOLS_PATH + image; + var button = toolBar.addButton({ + objectName: name, + imageURL: imageUrl, + imageOffOut: 1, + imageOffIn: 2, + imageOnOut: 0, + imageOnIn: 2, + alpha: 0.9, + visible: true }); + if (handler) { + button.clicked.connect(function () { + Script.setTimeout(handler, 100); + }); + } + return button; + } else { + buttonHandlers[name] = handler; } - return button; } var SHAPE_TYPE_NONE = 0; @@ -269,6 +275,9 @@ var toolBar = (function () { case "newModelDialogAdd": handleNewModelDialogResult(message.params); break; + case "newEntityButtonClicked": + buttonHandlers[message.params.buttonName](); + break; } } diff --git a/scripts/system/particle_explorer/particleExplorerTool.js b/scripts/system/particle_explorer/particleExplorerTool.js index 8a28445c33..e592161414 100644 --- a/scripts/system/particle_explorer/particleExplorerTool.js +++ b/scripts/system/particle_explorer/particleExplorerTool.js @@ -18,12 +18,17 @@ ParticleExplorerTool = function() { var that = {}; that.createWebView = function() { - var url = PARTICLE_EXPLORER_HTML_URL; - that.webView = new OverlayWebWindow({ - title: 'Particle Explorer', - source: url, - toolWindow: true - }); + if (Settings.getValue("HUDUIEnabled")) { + var url = PARTICLE_EXPLORER_HTML_URL; + that.webView = new OverlayWebWindow({ + title: 'Particle Explorer', + source: url, + toolWindow: true + }); + } else { + that.webView = Tablet.getTablet("com.highfidelity.interface.tablet.system"); + that.webView.setVisible = function(value) {}; + } that.webView.setVisible(true); that.webView.webEventReceived.connect(that.webEventReceived); @@ -35,8 +40,10 @@ ParticleExplorerTool = function() { return; } - that.webView.close(); - that.webView = null; + if (Settings.getValue("HUDUIEnabled")) { + that.webView.close(); + that.webView = null; + } that.activeParticleEntity = 0; } @@ -55,4 +62,4 @@ ParticleExplorerTool = function() { return that; -}; \ No newline at end of file +}; From 44aa3e044bc017f533d49e8beeec03ed7cc727cb Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Fri, 10 Feb 2017 16:56:53 -0800 Subject: [PATCH 10/89] make it so near grabbing while edit is active doesn't select a new entity --- interface/resources/qml/hifi/tablet/Edit.qml | 29 ++- .../system/controllers/handControllerGrab.js | 13 +- .../system/libraries/entitySelectionTool.js | 191 ++++++++++-------- 3 files changed, 139 insertions(+), 94 deletions(-) diff --git a/interface/resources/qml/hifi/tablet/Edit.qml b/interface/resources/qml/hifi/tablet/Edit.qml index 7cdf706497..44959395fa 100644 --- a/interface/resources/qml/hifi/tablet/Edit.qml +++ b/interface/resources/qml/hifi/tablet/Edit.qml @@ -2,6 +2,7 @@ import QtQuick 2.5 import QtQuick.Controls 1.0 import QtWebEngine 1.1 import QtWebChannel 1.0 +import QtQuick.Controls.Styles 1.4 import "../../controls" import HFWebEngineProfile 1.0 @@ -28,10 +29,11 @@ StackView { id: editBasePage TabView { id: editTabView - anchors.fill: parent + // anchors.fill: parent + height: 60 Tab { - title: "Create Entities" + title: "Create" active: true enabled: true property string originalUrl: "" @@ -133,7 +135,7 @@ StackView { } Tab { - title: "Entity List" + title: "List" active: true enabled: true property string originalUrl: "" @@ -148,7 +150,7 @@ StackView { } Tab { - title: "Entity Properties" + title: "Properties" active: true enabled: true property string originalUrl: "" @@ -178,7 +180,7 @@ StackView { } Tab { - title: "Particle Explorer" + title: "Particles" active: true enabled: true property string originalUrl: "" @@ -191,6 +193,23 @@ StackView { enabled: true } } + + + style: TabViewStyle { + frameOverlap: 1 + tab: Rectangle { + color: styleData.selected ? "slategrey" :"grey" + implicitWidth: text.width + 25 + implicitHeight: 60 + radius: 2 + Text { + id: text + anchors.centerIn: parent + text: styleData.title + color: styleData.selected ? "white" : "white" + } + } + } } } } diff --git a/scripts/system/controllers/handControllerGrab.js b/scripts/system/controllers/handControllerGrab.js index 527a9cfc2b..f61ea3013e 100644 --- a/scripts/system/controllers/handControllerGrab.js +++ b/scripts/system/controllers/handControllerGrab.js @@ -13,8 +13,8 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html /* global getEntityCustomData, flatten, Xform, Script, Quat, Vec3, MyAvatar, Entities, Overlays, Settings, - Reticle, Controller, Camera, Messages, Mat4, getControllerWorldLocation, getGrabPointSphereOffset, setGrabCommunications, - Menu, HMD */ + Reticle, Controller, Camera, Messages, Mat4, getControllerWorldLocation, getGrabPointSphereOffset, + setGrabCommunications, Menu, HMD, isInEditMode */ /* eslint indent: ["error", 4, { "outerIIFEBody": 0 }] */ (function() { // BEGIN LOCAL_SCOPE @@ -1667,6 +1667,15 @@ function MyController(hand) { } if (rayPickInfo.entityID) { + if (this.triggerSmoothedGrab() && isInEditMode()) { + this.searchIndicatorOn(rayPickInfo.searchRay); + Messages.sendLocalMessage("entityToolUpdates", JSON.stringify({ + method: "selectEntity", + entityID: rayPickInfo.entityID + })); + return; + } + entity = rayPickInfo.entityID; name = entityPropertiesCache.getProps(entity).name; if (this.entityWantsTrigger(entity)) { diff --git a/scripts/system/libraries/entitySelectionTool.js b/scripts/system/libraries/entitySelectionTool.js index b9bae72d14..4fd708a86e 100644 --- a/scripts/system/libraries/entitySelectionTool.js +++ b/scripts/system/libraries/entitySelectionTool.js @@ -11,6 +11,8 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +/* global HIFI_PUBLIC_BUCKET, SPACE_LOCAL, Script, SelectionManager */ + HIFI_PUBLIC_BUCKET = "http://s3.amazonaws.com/hifi-public/"; SPACE_LOCAL = "local"; @@ -28,7 +30,7 @@ SelectionManager = (function() { var that = {}; function subscribeToUpdateMessages() { - Messages.subscribe('entityToolUpdates'); + Messages.subscribe("entityToolUpdates"); Messages.messageReceived.connect(handleEntitySelectionToolUpdates); } @@ -40,8 +42,20 @@ SelectionManager = (function() { return; } - if (message === 'callUpdate') { - that._update(); + var messageParsed; + try { + messageParsed = JSON.parse(message); + } catch (err) { + print("error -- entitySelectionTool got malformed message: " + message); + } + + // if (message === 'callUpdate') { + // that._update(); + // } + + if (messageParsed.method === "selectEntity") { + print("setting selection to " + messageParsed.entityID); + that.setSelections([messageParsed.entityID]); } } @@ -149,13 +163,14 @@ SelectionManager = (function() { }; that._update = function(selectionUpdated) { - if (that.selections.length == 0) { + var properties = null; + if (that.selections.length === 0) { that.localDimensions = null; that.localPosition = null; that.worldDimensions = null; that.worldPosition = null; } else if (that.selections.length == 1) { - var properties = Entities.getEntityProperties(that.selections[0]); + properties = Entities.getEntityProperties(that.selections[0]); that.localDimensions = properties.dimensions; that.localPosition = properties.position; that.localRotation = properties.rotation; @@ -170,7 +185,7 @@ SelectionManager = (function() { that.localDimensions = null; that.localPosition = null; - var properties = Entities.getEntityProperties(that.selections[0]); + properties = Entities.getEntityProperties(that.selections[0]); var brn = properties.boundingBox.brn; var tfl = properties.boundingBox.tfl; @@ -203,9 +218,9 @@ SelectionManager = (function() { SelectionDisplay.setSpaceMode(SPACE_WORLD); } - for (var i = 0; i < listeners.length; i++) { + for (var j = 0; j < listeners.length; j++) { try { - listeners[i](selectionUpdated === true); + listeners[j](selectionUpdated === true); } catch (e) { print("EntitySelectionTool got exception: " + JSON.stringify(e)); } @@ -229,8 +244,8 @@ function getRelativeCenterPosition(dimensions, registrationPoint) { return { x: -dimensions.x * (registrationPoint.x - 0.5), y: -dimensions.y * (registrationPoint.y - 0.5), - z: -dimensions.z * (registrationPoint.z - 0.5), - } + z: -dimensions.z * (registrationPoint.z - 0.5) + }; } SelectionDisplay = (function() { @@ -253,7 +268,7 @@ SelectionDisplay = (function() { var spaceMode = SPACE_LOCAL; var mode = "UNKNOWN"; - var overlayNames = new Array(); + var overlayNames = []; var lastCameraPosition = Camera.getPosition(); var lastCameraOrientation = Camera.getOrientation(); @@ -679,8 +694,7 @@ SelectionDisplay = (function() { green: 0, blue: 0 }, - ignoreRayIntersection: true, // always ignore this - visible: false, + ignoreRayIntersection: true // always ignore this }); var yRailOverlay = Overlays.addOverlay("line3d", { visible: false, @@ -700,8 +714,7 @@ SelectionDisplay = (function() { green: 255, blue: 0 }, - ignoreRayIntersection: true, // always ignore this - visible: false, + ignoreRayIntersection: true // always ignore this }); var zRailOverlay = Overlays.addOverlay("line3d", { visible: false, @@ -721,8 +734,7 @@ SelectionDisplay = (function() { green: 0, blue: 255 }, - ignoreRayIntersection: true, // always ignore this - visible: false, + ignoreRayIntersection: true // always ignore this }); var rotateZeroOverlay = Overlays.addOverlay("line3d", { @@ -1016,44 +1028,46 @@ SelectionDisplay = (function() { that.TRIGGER_OFF_VALUE = 0.15; that.triggered = false; var activeHand = Controller.Standard.RightHand; - function makeTriggerHandler(hand) { - return function (value) { - if (!that.triggered && (value > that.TRIGGER_GRAB_VALUE)) { // should we smooth? - that.triggered = true; - if (activeHand !== hand) { - // No switching while the other is already triggered, so no need to release. - activeHand = (activeHand === Controller.Standard.RightHand) ? Controller.Standard.LeftHand : Controller.Standard.RightHand; - } - if (Reticle.pointingAtSystemOverlay || Overlays.getOverlayAtPoint(Reticle.position)) { - return; - } - var eventResult = that.mousePressEvent({}); - if (!eventResult || (eventResult === 'selectionBox')) { - var pickRay = controllerComputePickRay(); - if (pickRay) { - var entityIntersection = Entities.findRayIntersection(pickRay, true); + // function makeTriggerHandler(hand) { + // return function (value) { + // if (!that.triggered && (value > that.TRIGGER_GRAB_VALUE)) { // should we smooth? + // that.triggered = true; + // if (activeHand !== hand) { + // // No switching while the other is already triggered, so no need to release. + // activeHand = (activeHand === Controller.Standard.RightHand) ? Controller.Standard.LeftHand : Controller.Standard.RightHand; + // } + // if (Reticle.pointingAtSystemOverlay || Overlays.getOverlayAtPoint(Reticle.position)) { + // return; + // } + // var eventResult = that.mousePressEvent({}); + // if (!eventResult || (eventResult === 'selectionBox')) { + // var pickRay = controllerComputePickRay(); + // if (pickRay) { + // var entityIntersection = Entities.findRayIntersection(pickRay, true); - var overlayIntersection = Overlays.findRayIntersection(pickRay); - if (entityIntersection.intersects && - (!overlayIntersection.intersects || (entityIntersection.distance < overlayIntersection.distance))) { + // var overlayIntersection = Overlays.findRayIntersection(pickRay); + // if (entityIntersection.intersects && + // (!overlayIntersection.intersects || (entityIntersection.distance < overlayIntersection.distance))) { + + // if (HMD.tabletID === entityIntersection.entityID) { + // return; + // } + + // selectionManager.setSelections([entityIntersection.entityID]); + // } + // } + // } + // } else if (that.triggered && (value < that.TRIGGER_OFF_VALUE)) { + // that.triggered = false; + // that.mouseReleaseEvent({}); + // } + // }; + // } + // that.triggerMapping.from(Controller.Standard.RT).peek().to(makeTriggerHandler(Controller.Standard.RightHand)); + // that.triggerMapping.from(Controller.Standard.LT).peek().to(makeTriggerHandler(Controller.Standard.LeftHand)); - if (HMD.tabletID === entityIntersection.entityID) { - return; - } - selectionManager.setSelections([entityIntersection.entityID]); - } - } - } - } else if (that.triggered && (value < that.TRIGGER_OFF_VALUE)) { - that.triggered = false; - that.mouseReleaseEvent({}); - } - }; - } - that.triggerMapping.from(Controller.Standard.RT).peek().to(makeTriggerHandler(Controller.Standard.RightHand)); - that.triggerMapping.from(Controller.Standard.LT).peek().to(makeTriggerHandler(Controller.Standard.LeftHand)); function controllerComputePickRay() { var controllerPose = getControllerWorldLocation(activeHand, true); if (controllerPose.valid && that.triggered) { @@ -1072,7 +1086,7 @@ SelectionDisplay = (function() { onBegin: tool.onBegin, onMove: tool.onMove, onEnd: tool.onEnd, - } + }; } @@ -1080,8 +1094,8 @@ SelectionDisplay = (function() { for (var i = 0; i < allOverlays.length; i++) { Overlays.deleteOverlay(allOverlays[i]); } - for (var i = 0; i < selectionBoxes.length; i++) { - Overlays.deleteOverlay(selectionBoxes[i]); + for (var j = 0; j < selectionBoxes.length; j++) { + Overlays.deleteOverlay(selectionBoxes[j]); } }; @@ -1125,7 +1139,7 @@ SelectionDisplay = (function() { }); that.updateHandles(); - } + }; that.updateRotationHandles = function() { var diagonal = (Vec3.length(selectionManager.worldDimensions) / 2) * 1.1; @@ -1572,7 +1586,7 @@ SelectionDisplay = (function() { that.unselectAll = function() {}; that.updateHandles = function() { - if (SelectionManager.selections.length == 0) { + if (SelectionManager.selections.length === 0) { that.setOverlaysVisible(false); return; } @@ -1608,7 +1622,8 @@ SelectionDisplay = (function() { var bottom = -registrationPointDimensions.y; var top = dimensions.y - registrationPointDimensions.y; var near = -registrationPointDimensions.z; - var front = far = dimensions.z - registrationPointDimensions.z; + var far = dimensions.z - registrationPointDimensions.z; + var front = far; var worldTop = SelectionManager.worldDimensions.y / 2; @@ -1808,9 +1823,9 @@ SelectionDisplay = (function() { if (selectionManager.selections.length == 1) { var properties = Entities.getEntityProperties(selectionManager.selections[0]); - if (properties.type == "Light" && properties.isSpotlight == true) { - var stretchHandlesVisible = false; - var extendedStretchHandlesVisible = false; + if (properties.type == "Light" && properties.isSpotlight === true) { + stretchHandlesVisible = false; + extendedStretchHandlesVisible = false; Overlays.editOverlay(grabberSpotLightCenter, { position: position, @@ -1903,9 +1918,9 @@ SelectionDisplay = (function() { Overlays.editOverlay(grabberPointLightN, { visible: false }); - } else if (properties.type == "Light" && properties.isSpotlight == false) { - var stretchHandlesVisible = false; - var extendedStretchHandlesVisible = false; + } else if (properties.type == "Light" && properties.isSpotlight === false) { + stretchHandlesVisible = false; + extendedStretchHandlesVisible = false; Overlays.editOverlay(grabberPointLightT, { position: TOP, rotation: rotation, @@ -2171,28 +2186,28 @@ SelectionDisplay = (function() { })); } - var i = 0; + i = 0; // Only show individual selections boxes if there is more than 1 selection if (selectionManager.selections.length > 1) { for (; i < selectionManager.selections.length; i++) { - var properties = Entities.getEntityProperties(selectionManager.selections[i]); + var props = Entities.getEntityProperties(selectionManager.selections[i]); // Adjust overlay position to take registrationPoint into account // centeredRP = registrationPoint with range [-0.5, 0.5] - var centeredRP = Vec3.subtract(properties.registrationPoint, { + var centeredRP = Vec3.subtract(props.registrationPoint, { x: 0.5, y: 0.5, z: 0.5 }); - var offset = vec3Mult(properties.dimensions, centeredRP); + var offset = vec3Mult(props.dimensions, centeredRP); offset = Vec3.multiply(-1, offset); - offset = Vec3.multiplyQbyV(properties.rotation, offset); - var boxPosition = Vec3.sum(properties.position, offset); + offset = Vec3.multiplyQbyV(props.rotation, offset); + var boxPosition = Vec3.sum(props.position, offset); Overlays.editOverlay(selectionBoxes[i], { position: boxPosition, - rotation: properties.rotation, - dimensions: properties.dimensions, + rotation: props.rotation, + dimensions: props.dimensions, visible: true, }); } @@ -2584,11 +2599,11 @@ SelectionDisplay = (function() { y: v1.y * v2.y, z: v1.z * v2.z }; - } - // stretchMode - name of mode - // direction - direction to stretch in - // pivot - point to use as a pivot - // offset - the position of the overlay tool relative to the selections center position + }; + // stretchMode - name of mode + // direction - direction to stretch in + // pivot - point to use as a pivot + // offset - the position of the overlay tool relative to the selections center position var makeStretchTool = function(stretchMode, direction, pivot, offset, customOnMove) { var signs = { x: direction.x < 0 ? -1 : (direction.x > 0 ? 1 : 0), @@ -2640,7 +2655,7 @@ SelectionDisplay = (function() { }); // Scale pivot to be in the same range as registrationPoint - var scaledPivot = Vec3.multiply(0.5, pivot) + var scaledPivot = Vec3.multiply(0.5, pivot); deltaPivot = Vec3.subtract(centeredRP, scaledPivot); var scaledOffset = Vec3.multiply(0.5, offset); @@ -2652,14 +2667,16 @@ SelectionDisplay = (function() { var scaledOffsetWorld = vec3Mult(initialDimensions, offsetRP); pickRayPosition = Vec3.sum(initialPosition, Vec3.multiplyQbyV(rotation, scaledOffsetWorld)); + var start = null; + var end = null; if (numDimensions == 1 && mask.x) { - var start = Vec3.multiplyQbyV(rotation, { + start = Vec3.multiplyQbyV(rotation, { x: -10000, y: 0, z: 0 }); start = Vec3.sum(start, properties.position); - var end = Vec3.multiplyQbyV(rotation, { + end = Vec3.multiplyQbyV(rotation, { x: 10000, y: 0, z: 0 @@ -2672,13 +2689,13 @@ SelectionDisplay = (function() { }); } if (numDimensions == 1 && mask.y) { - var start = Vec3.multiplyQbyV(rotation, { + start = Vec3.multiplyQbyV(rotation, { x: 0, y: -10000, z: 0 }); start = Vec3.sum(start, properties.position); - var end = Vec3.multiplyQbyV(rotation, { + end = Vec3.multiplyQbyV(rotation, { x: 0, y: 10000, z: 0 @@ -2691,13 +2708,13 @@ SelectionDisplay = (function() { }); } if (numDimensions == 1 && mask.z) { - var start = Vec3.multiplyQbyV(rotation, { + start = Vec3.multiplyQbyV(rotation, { x: 0, y: 0, z: -10000 }); start = Vec3.sum(start, properties.position); - var end = Vec3.multiplyQbyV(rotation, { + end = Vec3.multiplyQbyV(rotation, { x: 0, y: 0, z: 10000 @@ -2730,13 +2747,13 @@ SelectionDisplay = (function() { }; } } else if (numDimensions == 2) { - if (mask.x == 0) { + if (mask.x === 0) { planeNormal = { x: 1, y: 0, z: 0 }; - } else if (mask.y == 0) { + } else if (mask.y === 0) { planeNormal = { x: 0, y: 1, @@ -2894,7 +2911,7 @@ SelectionDisplay = (function() { }); SelectionManager._update(); - }; + } function radiusStretchFunc(vector, change) { var props = selectionManager.savedProperties[selectionManager.selections[0]]; @@ -4413,7 +4430,7 @@ SelectionDisplay = (function() { scale: handleSize / 1.25, }); } - } + }; Script.update.connect(that.updateHandleSizes); that.mouseReleaseEvent = function(event) { From 6f506d602301e9aa221613fb8a2b584be859404c Mon Sep 17 00:00:00 2001 From: Faye Li Date: Mon, 13 Feb 2017 14:40:45 -0800 Subject: [PATCH 11/89] some attempts to get icons in create tab --- interface/resources/images/sphere-01.svg | 108 +++++++++++++++++++ interface/resources/qml/hifi/tablet/Edit.qml | 46 ++++---- 2 files changed, 135 insertions(+), 19 deletions(-) create mode 100644 interface/resources/images/sphere-01.svg diff --git a/interface/resources/images/sphere-01.svg b/interface/resources/images/sphere-01.svg new file mode 100644 index 0000000000..975199c8da --- /dev/null +++ b/interface/resources/images/sphere-01.svg @@ -0,0 +1,108 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/interface/resources/qml/hifi/tablet/Edit.qml b/interface/resources/qml/hifi/tablet/Edit.qml index 44959395fa..5301ff78f8 100644 --- a/interface/resources/qml/hifi/tablet/Edit.qml +++ b/interface/resources/qml/hifi/tablet/Edit.qml @@ -4,6 +4,7 @@ import QtWebEngine 1.1 import QtWebChannel 1.0 import QtQuick.Controls.Styles 1.4 import "../../controls" +import "../toolbars" import HFWebEngineProfile 1.0 StackView { @@ -41,9 +42,17 @@ StackView { Flow { id: createEntitiesFlow spacing: 16 + anchors.right: parent.right + anchors.rightMargin: 30 + anchors.left: parent.left + anchors.leftMargin: 30 + anchors.bottom: parent.bottom + anchors.bottomMargin: 30 + anchors.top: parent.top + anchors.topMargin: 30 - Button { - iconSource: "../../../../../scripts/system/assets/images/tools/assets-01.svg" + TabletButton { + icon: "icons/assets-01.svg" text: "ASSETS" onClicked: { editRoot.sendToScript({ @@ -52,8 +61,8 @@ StackView { } } - Button { - iconSource: "../../../../../scripts/system/assets/images/tools/model-01.svg" + TabletButton { + icon: "model-01.svg" text: "MODEL" onClicked: { editRoot.sendToScript({ @@ -62,8 +71,8 @@ StackView { } } - Button { - iconSource: "../../../../../scripts/system/assets/images/tools/cube-01.svg" + TabletButton { + icon: "../cube-01.svg" text: "CUBE" onClicked: { editRoot.sendToScript({ @@ -72,9 +81,8 @@ StackView { } } - Button { - iconSource: "../../../../../scripts/system/assets/images/tools/sphere-01.svg" - text: "SPHERE" + ToolbarButton { + imageURL: "../images/sphere-01.svg" onClicked: { editRoot.sendToScript({ method: "newEntityButtonClicked", params: { buttonName: "newSphereButton" } @@ -82,8 +90,8 @@ StackView { } } - Button { - iconSource: "../../../../../scripts/system/assets/images/tools/light-01.svg" + TabletButton { + icon: "../scripts/system/assets/images/tools/light-01.svg" text: "LIGHT" onClicked: { editRoot.sendToScript({ @@ -92,8 +100,8 @@ StackView { } } - Button { - iconSource: "../../../../../scripts/system/assets/images/tools/text-01.svg" + TabletButton { + icon: "../scripts/system/assets/images/tools/text-01.svg" text: "TEXT" onClicked: { editRoot.sendToScript({ @@ -102,8 +110,8 @@ StackView { } } - Button { - iconSource: "../../../../../scripts/system/assets/images/tools/web-01.svg" + TabletButton { + icon: "../scripts/system/assets/images/tools/web-01.svg" text: "WEB" onClicked: { editRoot.sendToScript({ @@ -112,8 +120,8 @@ StackView { } } - Button { - iconSource: "../../../../../scripts/system/assets/images/tools/zone-01.svg" + TabletButton { + icon: "../scripts/system/assets/images/tools/zone-01.svg" text: "ZONE" onClicked: { editRoot.sendToScript({ @@ -122,8 +130,8 @@ StackView { } } - Button { - iconSource: "../../../../../scripts/system/assets/images/tools/particle-01.svg" + TabletButton { + icon: "../scripts/system/assets/images/tools/particle-01.svg" text: "PARTICLE" onClicked: { editRoot.sendToScript({ From a57a0435c1a348ce40d9c5b608e948b14b021af8 Mon Sep 17 00:00:00 2001 From: Faye Li Date: Mon, 13 Feb 2017 15:13:10 -0800 Subject: [PATCH 12/89] fix overlapping issue with the delete button --- scripts/system/html/css/edit-style.css | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/system/html/css/edit-style.css b/scripts/system/html/css/edit-style.css index 251d0a2d75..06a60b5405 100644 --- a/scripts/system/html/css/edit-style.css +++ b/scripts/system/html/css/edit-style.css @@ -871,6 +871,7 @@ textarea:enabled[scrolling="true"]::-webkit-resizer { float: right; margin-right: 0; background-color: #ff0000; + min-width: 90px; } #entity-list { From 3a23ec86d55c8a6b91b2356ff41982b6aac81247 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Tue, 14 Feb 2017 13:57:48 -0800 Subject: [PATCH 13/89] handles etc work better --- .../system/controllers/handControllerGrab.js | 68 +++++++++++------- scripts/system/html/js/entityList.js | 4 +- scripts/system/html/js/entityProperties.js | 4 +- .../system/libraries/entitySelectionTool.js | 70 +++++++++---------- 4 files changed, 80 insertions(+), 66 deletions(-) diff --git a/scripts/system/controllers/handControllerGrab.js b/scripts/system/controllers/handControllerGrab.js index f61ea3013e..e7ca74cf54 100644 --- a/scripts/system/controllers/handControllerGrab.js +++ b/scripts/system/controllers/handControllerGrab.js @@ -738,6 +738,7 @@ function MyController(hand) { this.grabPointIntersectsEntity = false; this.stylus = null; this.homeButtonTouched = false; + this.editTriggered = false; // Until there is some reliable way to keep track of a "stack" of parentIDs, we'll have problems // when more than one avatar does parenting grabs on things. This script tries to work @@ -858,9 +859,10 @@ function MyController(hand) { }; this.setState = function(newState, reason) { - if ((isInEditMode() && this.grabbedEntity !== HMD.tabletID )&& (newState !== STATE_OFF && - newState !== STATE_SEARCHING && - newState !== STATE_OVERLAY_STYLUS_TOUCHING)) { + if ((isInEditMode() && this.grabbedEntity !== HMD.tabletID) && + (newState !== STATE_OFF && + newState !== STATE_SEARCHING && + newState !== STATE_OVERLAY_STYLUS_TOUCHING)) { return; } setGrabCommunications((newState === STATE_DISTANCE_HOLDING) || (newState === STATE_NEAR_GRABBING)); @@ -1037,7 +1039,7 @@ function MyController(hand) { } var searchSphereLocation = Vec3.sum(distantPickRay.origin, - Vec3.multiply(distantPickRay.direction, this.searchSphereDistance)); + Vec3.multiply(distantPickRay.direction, this.searchSphereDistance)); this.searchSphereOn(searchSphereLocation, SEARCH_SPHERE_SIZE * this.searchSphereDistance, (this.triggerSmoothedGrab() || this.secondarySqueezed()) ? COLORS_GRAB_SEARCHING_FULL_SQUEEZE : @@ -1199,6 +1201,10 @@ function MyController(hand) { this.checkForUnexpectedChildren(); + if (this.editTriggered) { + this.editTriggered = false; + } + if (this.triggerSmoothedReleased() && this.secondaryReleased()) { this.waitForTriggerRelease = false; } @@ -1636,22 +1642,24 @@ function MyController(hand) { return aDistance - bDistance; }); entity = grabbableEntities[0]; - name = entityPropertiesCache.getProps(entity).name; - this.grabbedEntity = entity; - if (this.entityWantsTrigger(entity)) { - if (this.triggerSmoothedGrab()) { - this.setState(STATE_NEAR_TRIGGER, "near trigger '" + name + "'"); - return; + if (!isInEditMode() || entity == HMD.tabletID) { + name = entityPropertiesCache.getProps(entity).name; + this.grabbedEntity = entity; + if (this.entityWantsTrigger(entity)) { + if (this.triggerSmoothedGrab()) { + this.setState(STATE_NEAR_TRIGGER, "near trigger '" + name + "'"); + return; + } else { + // potentialNearTriggerEntity = entity; + } } else { - // potentialNearTriggerEntity = entity; - } - } else { - // If near something grabbable, grab it! - if ((this.triggerSmoothedGrab() || this.secondarySqueezed()) && nearGrabEnabled) { - this.setState(STATE_NEAR_GRABBING, "near grab '" + name + "'"); - return; - } else { - // potentialNearGrabEntity = entity; + // If near something grabbable, grab it! + if ((this.triggerSmoothedGrab() || this.secondarySqueezed()) && nearGrabEnabled) { + this.setState(STATE_NEAR_GRABBING, "near grab '" + name + "'"); + return; + } else { + // potentialNearGrabEntity = entity; + } } } } @@ -1666,16 +1674,22 @@ function MyController(hand) { } } - if (rayPickInfo.entityID) { - if (this.triggerSmoothedGrab() && isInEditMode()) { - this.searchIndicatorOn(rayPickInfo.searchRay); - Messages.sendLocalMessage("entityToolUpdates", JSON.stringify({ - method: "selectEntity", - entityID: rayPickInfo.entityID - })); - return; + if (isInEditMode()) { + this.searchIndicatorOn(rayPickInfo.searchRay); + if (this.triggerSmoothedGrab()) { + if (!this.editTriggered && rayPickInfo.entityID) { + Messages.sendLocalMessage("entityToolUpdates", JSON.stringify({ + method: "selectEntity", + entityID: rayPickInfo.entityID + })); + } + this.editTriggered = true; } + Reticle.setVisible(false); + return; + } + if (rayPickInfo.entityID) { entity = rayPickInfo.entityID; name = entityPropertiesCache.getProps(entity).name; if (this.entityWantsTrigger(entity)) { diff --git a/scripts/system/html/js/entityList.js b/scripts/system/html/js/entityList.js index 1af9c1e1d6..048d5561df 100644 --- a/scripts/system/html/js/entityList.js +++ b/scripts/system/html/js/entityList.js @@ -330,10 +330,10 @@ function loaded() { } } else if (data.type == "update") { var newEntities = data.entities; - if (newEntities.length == 0) { + if (newEntities && newEntities.length == 0) { elNoEntitiesMessage.style.display = "block"; elFooter.firstChild.nodeValue = "0 entities found"; - } else { + } else if (newEntities) { elNoEntitiesMessage.style.display = "none"; for (var i = 0; i < newEntities.length; i++) { var id = newEntities[i].id; diff --git a/scripts/system/html/js/entityProperties.js b/scripts/system/html/js/entityProperties.js index 957cea4528..1c15aafa8b 100644 --- a/scripts/system/html/js/entityProperties.js +++ b/scripts/system/html/js/entityProperties.js @@ -732,7 +732,7 @@ function loaded() { } } else if (data.type == "update") { - if (data.selections.length == 0) { + if (!data.selections || data.selections.length == 0) { if (editor !== null && lastEntityID !== null) { saveJSONUserData(true); deleteJSONEditor(); @@ -741,7 +741,7 @@ function loaded() { elType.innerHTML = "No selection"; elID.innerHTML = ""; disableProperties(); - } else if (data.selections.length > 1) { + } else if (data.selections && data.selections.length > 1) { deleteJSONEditor(); var selections = data.selections; diff --git a/scripts/system/libraries/entitySelectionTool.js b/scripts/system/libraries/entitySelectionTool.js index 4fd708a86e..08ae7ae5f7 100644 --- a/scripts/system/libraries/entitySelectionTool.js +++ b/scripts/system/libraries/entitySelectionTool.js @@ -1028,44 +1028,44 @@ SelectionDisplay = (function() { that.TRIGGER_OFF_VALUE = 0.15; that.triggered = false; var activeHand = Controller.Standard.RightHand; - // function makeTriggerHandler(hand) { - // return function (value) { - // if (!that.triggered && (value > that.TRIGGER_GRAB_VALUE)) { // should we smooth? - // that.triggered = true; - // if (activeHand !== hand) { - // // No switching while the other is already triggered, so no need to release. - // activeHand = (activeHand === Controller.Standard.RightHand) ? Controller.Standard.LeftHand : Controller.Standard.RightHand; - // } - // if (Reticle.pointingAtSystemOverlay || Overlays.getOverlayAtPoint(Reticle.position)) { - // return; - // } - // var eventResult = that.mousePressEvent({}); - // if (!eventResult || (eventResult === 'selectionBox')) { - // var pickRay = controllerComputePickRay(); - // if (pickRay) { - // var entityIntersection = Entities.findRayIntersection(pickRay, true); + function makeTriggerHandler(hand) { + return function (value) { + if (!that.triggered && (value > that.TRIGGER_GRAB_VALUE)) { // should we smooth? + that.triggered = true; + if (activeHand !== hand) { + // No switching while the other is already triggered, so no need to release. + activeHand = (activeHand === Controller.Standard.RightHand) ? Controller.Standard.LeftHand : Controller.Standard.RightHand; + } + if (Reticle.pointingAtSystemOverlay || Overlays.getOverlayAtPoint(Reticle.position)) { + return; + } + var eventResult = that.mousePressEvent({}); + // if (!eventResult || (eventResult === 'selectionBox')) { + // var pickRay = controllerComputePickRay(); + // if (pickRay) { + // var entityIntersection = Entities.findRayIntersection(pickRay, true); - // var overlayIntersection = Overlays.findRayIntersection(pickRay); - // if (entityIntersection.intersects && - // (!overlayIntersection.intersects || (entityIntersection.distance < overlayIntersection.distance))) { + // var overlayIntersection = Overlays.findRayIntersection(pickRay); + // if (entityIntersection.intersects && + // (!overlayIntersection.intersects || (entityIntersection.distance < overlayIntersection.distance))) { - // if (HMD.tabletID === entityIntersection.entityID) { - // return; - // } + // if (HMD.tabletID === entityIntersection.entityID) { + // return; + // } - // selectionManager.setSelections([entityIntersection.entityID]); - // } - // } - // } - // } else if (that.triggered && (value < that.TRIGGER_OFF_VALUE)) { - // that.triggered = false; - // that.mouseReleaseEvent({}); - // } - // }; - // } - // that.triggerMapping.from(Controller.Standard.RT).peek().to(makeTriggerHandler(Controller.Standard.RightHand)); - // that.triggerMapping.from(Controller.Standard.LT).peek().to(makeTriggerHandler(Controller.Standard.LeftHand)); + // selectionManager.setSelections([entityIntersection.entityID]); + // } + // } + // } + } else if (that.triggered && (value < that.TRIGGER_OFF_VALUE)) { + that.triggered = false; + that.mouseReleaseEvent({}); + } + }; + } + that.triggerMapping.from(Controller.Standard.RT).peek().to(makeTriggerHandler(Controller.Standard.RightHand)); + that.triggerMapping.from(Controller.Standard.LT).peek().to(makeTriggerHandler(Controller.Standard.LeftHand)); function controllerComputePickRay() { @@ -2064,7 +2064,7 @@ SelectionDisplay = (function() { }); Overlays.editOverlay(grabberPointLightL, { visible: false - }); + }); Overlays.editOverlay(grabberPointLightR, { visible: false }); From 22baab13592c6de7622db085cf64bcee7f0b5918 Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Wed, 15 Feb 2017 15:24:08 +0000 Subject: [PATCH 14/89] updating branch with master --- .../resources/qml/hifi/tablet/TabletMenu.qml | 13 +++++-- ...etMouseHandler.qml => TabletMenuStack.qml} | 37 +++++++++++-------- interface/src/Application.cpp | 11 +++++- 3 files changed, 42 insertions(+), 19 deletions(-) rename interface/resources/qml/hifi/tablet/{TabletMouseHandler.qml => TabletMenuStack.qml} (88%) diff --git a/interface/resources/qml/hifi/tablet/TabletMenu.qml b/interface/resources/qml/hifi/tablet/TabletMenu.qml index cd3a9cacae..618aa30fb4 100644 --- a/interface/resources/qml/hifi/tablet/TabletMenu.qml +++ b/interface/resources/qml/hifi/tablet/TabletMenu.qml @@ -2,8 +2,14 @@ import QtQuick 2.5 import QtGraphicalEffects 1.0 import QtQuick.Controls 1.4 import QtQml 2.2 +import QtWebChannel 1.0 +import QtWebEngine 1.1 +import HFWebEngineProfile 1.0 + + import "." import "../../styles-uit" +import "../../controls" FocusScope { id: tabletMenu @@ -14,8 +20,9 @@ FocusScope { property var rootMenu: Menu { objectName:"rootMenu" } property var point: Qt.point(50, 50) - - TabletMouseHandler { id: menuPopperUpper } + property var eventBridge; + signal sendToScript(var message); + TabletMenuStack { id: menuPopperUpper } Rectangle { id: bgNavBar @@ -101,6 +108,6 @@ FocusScope { buildMenu() } function buildMenu() { - menuPopperUpper.popup(tabletMenu, rootMenu.items) + menuPopperUpper.popup(rootMenu.items); } } diff --git a/interface/resources/qml/hifi/tablet/TabletMouseHandler.qml b/interface/resources/qml/hifi/tablet/TabletMenuStack.qml similarity index 88% rename from interface/resources/qml/hifi/tablet/TabletMouseHandler.qml rename to interface/resources/qml/hifi/tablet/TabletMenuStack.qml index f2fa5f8d75..f84f90fbb3 100644 --- a/interface/resources/qml/hifi/tablet/TabletMouseHandler.qml +++ b/interface/resources/qml/hifi/tablet/TabletMenuStack.qml @@ -1,7 +1,7 @@ // // MessageDialog.qml // -// Created by Bradley Austin Davis on 18 Jan 2016 +// Created by Dante Ruiz on 13 Feb 2017 // Copyright 2016 High Fidelity, Inc. // // Distributed under the Apache License, Version 2.0. @@ -28,8 +28,11 @@ Item { } } - QtObject { + StackView { + anchors.fill: parent id: d + objectName: "stack" + initialItem: topMenu property var menuStack: [] property var topMenu: null; property var modelMaker: Component { ListModel { } } @@ -53,6 +56,12 @@ Item { } } + function pushSource(path) { + } + + function popSource() { + } + function toModel(items) { var result = modelMaker.createObject(tabletMenu); for (var i = 0; i < items.length; ++i) { @@ -76,15 +85,15 @@ Item { } function popMenu() { - if (menuStack.length) { - menuStack.pop().destroy(); + if (d.depth) { + d.pop(); } - if (menuStack.length) { - topMenu = menuStack[menuStack.length - 1]; + if (d.depth) { + topMenu = d.currentItem; topMenu.focus = true; topMenu.forceActiveFocus(); // show current menu level on nav bar - if (topMenu.objectName === "" || menuStack.length === 1) { + if (topMenu.objectName === "" || d.depth === 1) { breadcrumbText.text = "Menu"; } else { breadcrumbText.text = topMenu.objectName; @@ -96,16 +105,14 @@ Item { } function pushMenu(newMenu) { - menuStack.push(newMenu); + d.push({ item:newMenu, destroyOnPop: true}); topMenu = newMenu; topMenu.focus = true; topMenu.forceActiveFocus(); } function clearMenus() { - while (menuStack.length) { - popMenu() - } + d.clear() } function clampMenuPosition(menu) { @@ -123,7 +130,7 @@ Item { } } - function buildMenu(items, targetPosition) { + function buildMenu(items) { var model = toModel(items); // Menus must be childed to desktop for Z-ordering var newMenu = menuViewMaker.createObject(tabletMenu, { model: model, isSubMenu: topMenu !== null }); @@ -154,13 +161,13 @@ Item { } - function popup(parent, items) { + function popup(items) { d.clearMenus(); - d.buildMenu(items, point); + d.buildMenu(items); } function closeLastMenu() { - if (d.menuStack.length > 1) { + if (d.depth > 1) { d.popMenu(); return true; } diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index b7aecfa597..663c1f81fb 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -5743,8 +5743,17 @@ bool Application::displayAvatarAttachmentConfirmationDialog(const QString& name) } void Application::toggleRunningScriptsWidget() const { + auto tabletScriptingInterface = DependencyManager::get(); + auto tabletWindow = tabletScriptingInterface->getTabletWindow(); static const QUrl url("hifi/dialogs/RunningScripts.qml"); - DependencyManager::get()->show(url, "RunningScripts"); + if (tabletWindow) { + auto tablet = dynamic_cast(tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system")); + if (tablet) { + tablet->pushOntoStack("../..//hifi/dialogs/RunningScripts.qml"); + } + } else { + DependencyManager::get()->show(url, "RunningScripts"); + } //if (_runningScriptsWidget->isVisible()) { // if (_runningScriptsWidget->hasFocus()) { // _runningScriptsWidget->hide(); From 792c7ff51f144d6515bf977f370be8267e94bbe4 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Wed, 15 Feb 2017 10:41:56 -0800 Subject: [PATCH 15/89] PointerEvent will now relay keyboard modifiers --- interface/src/ui/overlays/Overlays.cpp | 12 +++++------ interface/src/ui/overlays/Web3DOverlay.cpp | 3 +-- .../src/EntityTreeRenderer.cpp | 21 ++++++++++++------- libraries/shared/src/PointerEvent.cpp | 13 ++++++++---- libraries/shared/src/PointerEvent.h | 6 +++++- .../system/libraries/entitySelectionTool.js | 2 +- 6 files changed, 36 insertions(+), 21 deletions(-) diff --git a/interface/src/ui/overlays/Overlays.cpp b/interface/src/ui/overlays/Overlays.cpp index e81e48f2bc..8a71d51a8b 100644 --- a/interface/src/ui/overlays/Overlays.cpp +++ b/interface/src/ui/overlays/Overlays.cpp @@ -693,8 +693,9 @@ static PointerEvent::Button toPointerButton(const QMouseEvent& event) { } } -PointerEvent Overlays::calculatePointerEvent(Overlay::Pointer overlay, PickRay ray, - RayToOverlayIntersectionResult rayPickResult, QMouseEvent* event, PointerEvent::EventType eventType) { +PointerEvent Overlays::calculatePointerEvent(Overlay::Pointer overlay, PickRay ray, + RayToOverlayIntersectionResult rayPickResult, QMouseEvent* event, + PointerEvent::EventType eventType) { auto thisOverlay = std::dynamic_pointer_cast(overlay); @@ -704,10 +705,9 @@ PointerEvent Overlays::calculatePointerEvent(Overlay::Pointer overlay, PickRay r auto dimensions = thisOverlay->getSize(); glm::vec2 pos2D = projectOntoOverlayXYPlane(position, rotation, dimensions, ray, rayPickResult); - PointerEvent pointerEvent(eventType, MOUSE_POINTER_ID, - pos2D, rayPickResult.intersection, - rayPickResult.surfaceNormal, ray.direction, - toPointerButton(*event), toPointerButtons(*event)); + + PointerEvent pointerEvent(eventType, MOUSE_POINTER_ID, pos2D, rayPickResult.intersection, rayPickResult.surfaceNormal, + ray.direction, toPointerButton(*event), toPointerButtons(*event), event->modifiers()); return pointerEvent; } diff --git a/interface/src/ui/overlays/Web3DOverlay.cpp b/interface/src/ui/overlays/Web3DOverlay.cpp index cb649e8766..72bd0228f3 100644 --- a/interface/src/ui/overlays/Web3DOverlay.cpp +++ b/interface/src/ui/overlays/Web3DOverlay.cpp @@ -344,9 +344,8 @@ void Web3DOverlay::handlePointerEvent(const PointerEvent& event) { QList touchPoints; touchPoints.push_back(point); - QTouchEvent* touchEvent = new QTouchEvent(type); + QTouchEvent* touchEvent = new QTouchEvent(type, &_touchDevice, event.getKeyboardModifiers()); touchEvent->setWindow(_webSurface->getWindow()); - touchEvent->setDevice(&_touchDevice); touchEvent->setTarget(_webSurface->getRootItem()); touchEvent->setTouchPoints(touchPoints); touchEvent->setTouchPointStates(touchPointState); diff --git a/libraries/entities-renderer/src/EntityTreeRenderer.cpp b/libraries/entities-renderer/src/EntityTreeRenderer.cpp index 4f4f3bf67f..4e105e4149 100644 --- a/libraries/entities-renderer/src/EntityTreeRenderer.cpp +++ b/libraries/entities-renderer/src/EntityTreeRenderer.cpp @@ -713,7 +713,8 @@ void EntityTreeRenderer::mousePressEvent(QMouseEvent* event) { PointerEvent pointerEvent(PointerEvent::Press, MOUSE_POINTER_ID, pos2D, rayPickResult.intersection, rayPickResult.surfaceNormal, ray.direction, - toPointerButton(*event), toPointerButtons(*event)); + toPointerButton(*event), toPointerButtons(*event), + Qt::NoModifier); // TODO -- check for modifier keys? emit mousePressOnEntity(rayPickResult.entityID, pointerEvent); @@ -753,7 +754,8 @@ void EntityTreeRenderer::mouseReleaseEvent(QMouseEvent* event) { PointerEvent pointerEvent(PointerEvent::Release, MOUSE_POINTER_ID, pos2D, rayPickResult.intersection, rayPickResult.surfaceNormal, ray.direction, - toPointerButton(*event), toPointerButtons(*event)); + toPointerButton(*event), toPointerButtons(*event), + Qt::NoModifier); // TODO -- check for modifier keys? emit mouseReleaseOnEntity(rayPickResult.entityID, pointerEvent); if (_entitiesScriptEngine) { @@ -773,7 +775,8 @@ void EntityTreeRenderer::mouseReleaseEvent(QMouseEvent* event) { PointerEvent pointerEvent(PointerEvent::Release, MOUSE_POINTER_ID, pos2D, rayPickResult.intersection, rayPickResult.surfaceNormal, ray.direction, - toPointerButton(*event), toPointerButtons(*event)); + toPointerButton(*event), toPointerButtons(*event), + Qt::NoModifier); // TODO -- check for modifier keys? emit clickReleaseOnEntity(_currentClickingOnEntityID, pointerEvent); if (_entitiesScriptEngine) { @@ -803,7 +806,8 @@ void EntityTreeRenderer::mouseMoveEvent(QMouseEvent* event) { PointerEvent pointerEvent(PointerEvent::Move, MOUSE_POINTER_ID, pos2D, rayPickResult.intersection, rayPickResult.surfaceNormal, ray.direction, - toPointerButton(*event), toPointerButtons(*event)); + toPointerButton(*event), toPointerButtons(*event), + Qt::NoModifier); // TODO -- check for modifier keys? emit mouseMoveOnEntity(rayPickResult.entityID, pointerEvent); @@ -823,7 +827,8 @@ void EntityTreeRenderer::mouseMoveEvent(QMouseEvent* event) { PointerEvent pointerEvent(PointerEvent::Move, MOUSE_POINTER_ID, pos2D, rayPickResult.intersection, rayPickResult.surfaceNormal, ray.direction, - toPointerButton(*event), toPointerButtons(*event)); + toPointerButton(*event), toPointerButtons(*event), + Qt::NoModifier); // TODO -- check for modifier keys? emit hoverLeaveEntity(_currentHoverOverEntityID, pointerEvent); if (_entitiesScriptEngine) { @@ -864,7 +869,8 @@ void EntityTreeRenderer::mouseMoveEvent(QMouseEvent* event) { PointerEvent pointerEvent(PointerEvent::Move, MOUSE_POINTER_ID, pos2D, rayPickResult.intersection, rayPickResult.surfaceNormal, ray.direction, - toPointerButton(*event), toPointerButtons(*event)); + toPointerButton(*event), toPointerButtons(*event), + Qt::NoModifier); // TODO -- check for modifier keys? emit hoverLeaveEntity(_currentHoverOverEntityID, pointerEvent); if (_entitiesScriptEngine) { @@ -883,7 +889,8 @@ void EntityTreeRenderer::mouseMoveEvent(QMouseEvent* event) { PointerEvent pointerEvent(PointerEvent::Move, MOUSE_POINTER_ID, pos2D, rayPickResult.intersection, rayPickResult.surfaceNormal, ray.direction, - toPointerButton(*event), toPointerButtons(*event)); + toPointerButton(*event), toPointerButtons(*event), + Qt::NoModifier); // TODO -- check for modifier keys? emit holdingClickOnEntity(_currentClickingOnEntityID, pointerEvent); if (_entitiesScriptEngine) { diff --git a/libraries/shared/src/PointerEvent.cpp b/libraries/shared/src/PointerEvent.cpp index ed9acb9ada..0833657886 100644 --- a/libraries/shared/src/PointerEvent.cpp +++ b/libraries/shared/src/PointerEvent.cpp @@ -25,9 +25,9 @@ PointerEvent::PointerEvent() { } PointerEvent::PointerEvent(EventType type, uint32_t id, - const glm::vec2& pos2D, const glm::vec3& pos3D, - const glm::vec3& normal, const glm::vec3& direction, - Button button, uint32_t buttons) : + const glm::vec2& pos2D, const glm::vec3& pos3D, + const glm::vec3& normal, const glm::vec3& direction, + Button button, uint32_t buttons, Qt::KeyboardModifiers keyboardModifiers) : _type(type), _id(id), _pos2D(pos2D), @@ -35,7 +35,8 @@ PointerEvent::PointerEvent(EventType type, uint32_t id, _normal(normal), _direction(direction), _button(button), - _buttons(buttons) + _buttons(buttons), + _keyboardModifiers(keyboardModifiers) { ; } @@ -119,6 +120,8 @@ QScriptValue PointerEvent::toScriptValue(QScriptEngine* engine, const PointerEve obj.setProperty("isSecondaryHeld", areFlagsSet(event._buttons, SecondaryButton)); obj.setProperty("isTertiaryHeld", areFlagsSet(event._buttons, TertiaryButton)); + obj.setProperty("keyboardModifiers", QScriptValue(event.getKeyboardModifiers())); + return obj; } @@ -174,5 +177,7 @@ void PointerEvent::fromScriptValue(const QScriptValue& object, PointerEvent& eve if (tertiary) { event._buttons |= TertiaryButton; } + + event._keyboardModifiers = (Qt::KeyboardModifiers)(object.property("keyboardModifiers").toUInt32()); } } diff --git a/libraries/shared/src/PointerEvent.h b/libraries/shared/src/PointerEvent.h index 054835c4fc..2b98a50487 100644 --- a/libraries/shared/src/PointerEvent.h +++ b/libraries/shared/src/PointerEvent.h @@ -12,6 +12,8 @@ #ifndef hifi_PointerEvent_h #define hifi_PointerEvent_h +#include + #include #include #include @@ -35,7 +37,7 @@ public: PointerEvent(EventType type, uint32_t id, const glm::vec2& pos2D, const glm::vec3& pos3D, const glm::vec3& normal, const glm::vec3& direction, - Button button, uint32_t buttons); + Button button, uint32_t buttons, Qt::KeyboardModifiers keyboardModifiers); static QScriptValue toScriptValue(QScriptEngine* engine, const PointerEvent& event); static void fromScriptValue(const QScriptValue& object, PointerEvent& event); @@ -50,6 +52,7 @@ public: const glm::vec3& getDirection() const { return _direction; } Button getButton() const { return _button; } uint32_t getButtons() const { return _buttons; } + Qt::KeyboardModifiers getKeyboardModifiers() const { return _keyboardModifiers; } private: EventType _type; @@ -61,6 +64,7 @@ private: Button _button { NoButtons }; // button assosiated with this event, (if type is Press, this will be the button that is pressed) uint32_t _buttons { NoButtons }; // the current state of all the buttons. + Qt::KeyboardModifiers _keyboardModifiers { Qt::NoModifier }; }; Q_DECLARE_METATYPE(PointerEvent) diff --git a/scripts/system/libraries/entitySelectionTool.js b/scripts/system/libraries/entitySelectionTool.js index 08ae7ae5f7..2471de98d3 100644 --- a/scripts/system/libraries/entitySelectionTool.js +++ b/scripts/system/libraries/entitySelectionTool.js @@ -2064,7 +2064,7 @@ SelectionDisplay = (function() { }); Overlays.editOverlay(grabberPointLightL, { visible: false - }); + }); Overlays.editOverlay(grabberPointLightR, { visible: false }); From e6853a925549e148648349e7351d8a073e9c3278 Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Wed, 15 Feb 2017 18:57:06 +0000 Subject: [PATCH 16/89] updated menu stack --- interface/resources/qml/hifi/tablet/TabletMenu.qml | 13 +++++-------- .../resources/qml/hifi/tablet/TabletMenuStack.qml | 7 ++++++- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/interface/resources/qml/hifi/tablet/TabletMenu.qml b/interface/resources/qml/hifi/tablet/TabletMenu.qml index 10ee247b2d..e4895740e6 100644 --- a/interface/resources/qml/hifi/tablet/TabletMenu.qml +++ b/interface/resources/qml/hifi/tablet/TabletMenu.qml @@ -19,7 +19,7 @@ FocusScope { height: 720 property var rootMenu: Menu { objectName:"rootMenu" } - property var point: Qt.point(50, 50) + property var point: Qt.point(50, 50); property var eventBridge; signal sendToScript(var message); TabletMenuStack { id: menuPopperUpper } @@ -64,6 +64,7 @@ FocusScope { // navigate back to root level menu onClicked: { buildMenu(); + breadcrumbText.text = "Menu"; tabletRoot.playButtonClickSound(); } } @@ -106,12 +107,9 @@ FocusScope { function setRootMenu(menu) { tabletMenu.rootMenu = menu - buildMenu() + buildMenu(); } function buildMenu() { -<<<<<<< HEAD - menuPopperUpper.popup(rootMenu.items); -======= // Build submenu if specified. if (subMenu !== "") { var index = 0; @@ -124,13 +122,12 @@ FocusScope { } subMenu = ""; // Continue with full menu after initially displaying submenu. if (found) { - menuPopperUpper.popup(tabletMenu, rootMenu.items[index].items); + menuPopperUpper.popup(rootMenu.items[index].items); return; } } // Otherwise build whole menu. - menuPopperUpper.popup(tabletMenu, rootMenu.items); ->>>>>>> 01bdac49d04ec897a3da7a264a1a26748a4e1938 + menuPopperUpper.popup(rootMenu.items); } } diff --git a/interface/resources/qml/hifi/tablet/TabletMenuStack.qml b/interface/resources/qml/hifi/tablet/TabletMenuStack.qml index f84f90fbb3..c33f4e648b 100644 --- a/interface/resources/qml/hifi/tablet/TabletMenuStack.qml +++ b/interface/resources/qml/hifi/tablet/TabletMenuStack.qml @@ -27,12 +27,13 @@ Item { d.clearMenus(); } } - + StackView { anchors.fill: parent id: d objectName: "stack" initialItem: topMenu + property var menuStack: [] property var topMenu: null; property var modelMaker: Component { ListModel { } } @@ -57,9 +58,13 @@ Item { } function pushSource(path) { + d.push(Qt.resolvedUrl(path)); + d.currentItem.eventBridge = tabletMenu.eventBridge + d.currentItem.sendToScript.connect(tabletMenu.sendToScript); } function popSource() { + d.pop(); } function toModel(items) { From 1038e97c7f1c5a0d80e7fe08d8ebcc17dee88b1d Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Wed, 15 Feb 2017 11:14:23 -0800 Subject: [PATCH 17/89] fix windows build --- libraries/shared/src/PointerEvent.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/shared/src/PointerEvent.h b/libraries/shared/src/PointerEvent.h index 2b98a50487..980510b091 100644 --- a/libraries/shared/src/PointerEvent.h +++ b/libraries/shared/src/PointerEvent.h @@ -64,7 +64,7 @@ private: Button _button { NoButtons }; // button assosiated with this event, (if type is Press, this will be the button that is pressed) uint32_t _buttons { NoButtons }; // the current state of all the buttons. - Qt::KeyboardModifiers _keyboardModifiers { Qt::NoModifier }; + Qt::KeyboardModifiers _keyboardModifiers; // set of keys held when event was generated }; Q_DECLARE_METATYPE(PointerEvent) From 3ea0f6d2d2ea08b82b6f8f83d486048d924ac368 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Wed, 15 Feb 2017 11:34:48 -0800 Subject: [PATCH 18/89] allow lasers to scroll tablet while in edit-mode --- scripts/system/controllers/handControllerGrab.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/system/controllers/handControllerGrab.js b/scripts/system/controllers/handControllerGrab.js index 6e81c3de52..4c08bb6ef5 100644 --- a/scripts/system/controllers/handControllerGrab.js +++ b/scripts/system/controllers/handControllerGrab.js @@ -862,7 +862,8 @@ function MyController(hand) { if ((isInEditMode() && this.grabbedEntity !== HMD.tabletID) && (newState !== STATE_OFF && newState !== STATE_SEARCHING && - newState !== STATE_OVERLAY_STYLUS_TOUCHING)) { + newState !== STATE_OVERLAY_STYLUS_TOUCHING && + newState !== STATE_OVERLAY_LASER_TOUCHING)) { return; } setGrabCommunications((newState === STATE_DISTANCE_HOLDING) || (newState === STATE_NEAR_GRABBING)); From 076b0ed3ab1b2308d593c94ced1cf096350a5582 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Wed, 15 Feb 2017 15:00:25 -0800 Subject: [PATCH 19/89] get particle explorer working, again --- scripts/system/edit.js | 17 ++++++++----- .../system/libraries/entitySelectionTool.js | 25 +++---------------- .../particle_explorer/particleExplorer.html | 2 +- .../particle_explorer/particleExplorer.js | 9 ++++--- .../particle_explorer/particleExplorerTool.js | 5 ++-- 5 files changed, 25 insertions(+), 33 deletions(-) diff --git a/scripts/system/edit.js b/scripts/system/edit.js index 39dd3bc598..fdc14445c5 100644 --- a/scripts/system/edit.js +++ b/scripts/system/edit.js @@ -1924,12 +1924,17 @@ entityListTool.webView.webEventReceived.connect(function (data) { selectedParticleEntity = ids[0]; particleExplorerTool.setActiveParticleEntity(ids[0]); - particleExplorerTool.webView.webEventReceived.connect(function (data) { - data = JSON.parse(data); - if (data.messageType === "page_loaded") { - particleExplorerTool.webView.emitScriptEvent(JSON.stringify(particleData)); - } - }); + if (Settings.getValue("HUDUIEnabled")) { + particleExplorerTool.webView.webEventReceived.connect(function (data) { + data = JSON.parse(data); + if (data.messageType === "page_loaded") { + particleExplorerTool.webView.emitScriptEvent(JSON.stringify(particleData)); + } + }); + } else { + // in the tablet version, the page was loaded earlier + particleExplorerTool.webView.emitScriptEvent(JSON.stringify(particleData)); + } } else { selectedParticleEntity = 0; particleExplorerTool.destroyWebView(); diff --git a/scripts/system/libraries/entitySelectionTool.js b/scripts/system/libraries/entitySelectionTool.js index 2471de98d3..596620b59a 100644 --- a/scripts/system/libraries/entitySelectionTool.js +++ b/scripts/system/libraries/entitySelectionTool.js @@ -1034,30 +1034,13 @@ SelectionDisplay = (function() { that.triggered = true; if (activeHand !== hand) { // No switching while the other is already triggered, so no need to release. - activeHand = (activeHand === Controller.Standard.RightHand) ? Controller.Standard.LeftHand : Controller.Standard.RightHand; + activeHand = (activeHand === Controller.Standard.RightHand) ? + Controller.Standard.LeftHand : Controller.Standard.RightHand; } if (Reticle.pointingAtSystemOverlay || Overlays.getOverlayAtPoint(Reticle.position)) { return; } - var eventResult = that.mousePressEvent({}); - // if (!eventResult || (eventResult === 'selectionBox')) { - // var pickRay = controllerComputePickRay(); - // if (pickRay) { - // var entityIntersection = Entities.findRayIntersection(pickRay, true); - - - // var overlayIntersection = Overlays.findRayIntersection(pickRay); - // if (entityIntersection.intersects && - // (!overlayIntersection.intersects || (entityIntersection.distance < overlayIntersection.distance))) { - - // if (HMD.tabletID === entityIntersection.entityID) { - // return; - // } - - // selectionManager.setSelections([entityIntersection.entityID]); - // } - // } - // } + that.mousePressEvent({}); } else if (that.triggered && (value < that.TRIGGER_OFF_VALUE)) { that.triggered = false; that.mouseReleaseEvent({}); @@ -2065,7 +2048,7 @@ SelectionDisplay = (function() { Overlays.editOverlay(grabberPointLightL, { visible: false }); - Overlays.editOverlay(grabberPointLightR, { + Overlays.editOverlay(grabberPointLightR, { visible: false }); Overlays.editOverlay(grabberPointLightF, { diff --git a/scripts/system/particle_explorer/particleExplorer.html b/scripts/system/particle_explorer/particleExplorer.html index 260d8a7813..d12ceac14b 100644 --- a/scripts/system/particle_explorer/particleExplorer.html +++ b/scripts/system/particle_explorer/particleExplorer.html @@ -76,4 +76,4 @@ body{ - \ No newline at end of file + diff --git a/scripts/system/particle_explorer/particleExplorer.js b/scripts/system/particle_explorer/particleExplorer.js index 4fd0978a84..44fa242435 100644 --- a/scripts/system/particle_explorer/particleExplorer.js +++ b/scripts/system/particle_explorer/particleExplorer.js @@ -358,9 +358,12 @@ function listenForSettingsUpdates() { settings[key] = value; }); - loadGUI(); + if (gui) { + manuallyUpdateDisplay(); + } else { + loadGUI(); + } } - }); } @@ -505,4 +508,4 @@ function registerDOMElementsForListenerBlocking() { }); }); }); -} \ No newline at end of file +} diff --git a/scripts/system/particle_explorer/particleExplorerTool.js b/scripts/system/particle_explorer/particleExplorerTool.js index e592161414..0be7c6b588 100644 --- a/scripts/system/particle_explorer/particleExplorerTool.js +++ b/scripts/system/particle_explorer/particleExplorerTool.js @@ -58,8 +58,9 @@ ParticleExplorerTool = function() { that.activeParticleEntity = id; } + if (Settings.getValue("HUDUIEnabled")) { + that.createWebView(); + } return that; - - }; From 33c1c3ac112bb179fa5bfaaa856ebfdb85f1a9f7 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Wed, 15 Feb 2017 15:19:49 -0800 Subject: [PATCH 20/89] when a new particle-entity is created, hook the particle explorer to it --- scripts/system/edit.js | 54 +++++++++++++++++++++++++----------------- 1 file changed, 32 insertions(+), 22 deletions(-) diff --git a/scripts/system/edit.js b/scripts/system/edit.js index fdc14445c5..4820421d46 100644 --- a/scripts/system/edit.js +++ b/scripts/system/edit.js @@ -180,8 +180,12 @@ var toolBar = (function () { position = grid.snapToSurface(grid.snapToGrid(position, false, dimensions), dimensions), properties.position = position; entityID = Entities.addEntity(properties); + if (properties.type == "ParticleEffect") { + selectParticleEntity(entityID); + } } else { - Window.notifyEditError("Can't create " + properties.type + ": " + properties.type + " would be out of bounds."); + Window.notifyEditError("Can't create " + properties.type + ": " + + properties.type + " would be out of bounds."); } selectionManager.clearSelections(); @@ -1903,6 +1907,32 @@ var showMenuItem = propertyMenu.addMenuItem("Show in Marketplace"); var propertiesTool = new PropertiesTool(); var particleExplorerTool = new ParticleExplorerTool(); var selectedParticleEntity = 0; + +function selectParticleEntity(entityID) { + var properties = Entities.getEntityProperties(entityID); + var particleData = { + messageType: "particle_settings", + currentProperties: properties + }; + particleExplorerTool.destroyWebView(); + particleExplorerTool.createWebView(); + + selectedParticleEntity = entityID; + particleExplorerTool.setActiveParticleEntity(entityID); + + if (Settings.getValue("HUDUIEnabled")) { + particleExplorerTool.webView.webEventReceived.connect(function (data) { + data = JSON.parse(data); + if (data.messageType === "page_loaded") { + particleExplorerTool.webView.emitScriptEvent(JSON.stringify(particleData)); + } + }); + } else { + // in the tablet version, the page was loaded earlier + particleExplorerTool.webView.emitScriptEvent(JSON.stringify(particleData)); + } +} + entityListTool.webView.webEventReceived.connect(function (data) { data = JSON.parse(data); if (data.type === "selectionUpdate") { @@ -1914,27 +1944,7 @@ entityListTool.webView.webEventReceived.connect(function (data) { return; } // Destroy the old particles web view first - particleExplorerTool.destroyWebView(); - particleExplorerTool.createWebView(); - var properties = Entities.getEntityProperties(ids[0]); - var particleData = { - messageType: "particle_settings", - currentProperties: properties - }; - selectedParticleEntity = ids[0]; - particleExplorerTool.setActiveParticleEntity(ids[0]); - - if (Settings.getValue("HUDUIEnabled")) { - particleExplorerTool.webView.webEventReceived.connect(function (data) { - data = JSON.parse(data); - if (data.messageType === "page_loaded") { - particleExplorerTool.webView.emitScriptEvent(JSON.stringify(particleData)); - } - }); - } else { - // in the tablet version, the page was loaded earlier - particleExplorerTool.webView.emitScriptEvent(JSON.stringify(particleData)); - } + selectParticleEntity(ids[0]) } else { selectedParticleEntity = 0; particleExplorerTool.destroyWebView(); From 3d7733219cb0343b615d48f484277069fb5fb740 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Wed, 15 Feb 2017 16:15:18 -0800 Subject: [PATCH 21/89] edit's open-asset-browser button works, again --- scripts/system/edit.js | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/scripts/system/edit.js b/scripts/system/edit.js index 4820421d46..5f7556592e 100644 --- a/scripts/system/edit.js +++ b/scripts/system/edit.js @@ -330,9 +330,12 @@ var toolBar = (function () { that.toggle(); }); - toolBar = Toolbars.getToolbar(EDIT_TOOLBAR); - toolBar.writeProperty("shown", false); - addButton("openAssetBrowserButton","assets-01.svg",function(){ + if (Settings.getValue("HUDUIEnabled")) { + toolBar = Toolbars.getToolbar(EDIT_TOOLBAR); + toolBar.writeProperty("shown", false); + } + + addButton("openAssetBrowserButton", "assets-01.svg", function(){ Window.showAssetServer(); }); @@ -543,12 +546,14 @@ var toolBar = (function () { // everybody else to think that Interface has lost focus overall. fogbugzid:558 // Window.setFocus(); } - // Sets visibility of tool buttons, excluding the power button - toolBar.writeProperty("shown", active); - var visible = toolBar.readProperty("visible"); - if (active && !visible) { - toolBar.writeProperty("shown", false); - toolBar.writeProperty("shown", true); + if (Settings.getValue("HUDUIEnabled")) { + // Sets visibility of tool buttons, excluding the power button + toolBar.writeProperty("shown", active); + var visible = toolBar.readProperty("visible"); + if (active && !visible) { + toolBar.writeProperty("shown", false); + toolBar.writeProperty("shown", true); + } } lightOverlayManager.setVisible(isActive && Menu.isOptionChecked(MENU_SHOW_LIGHTS_IN_EDIT_MODE)); Entities.setDrawZoneBoundaries(isActive && Menu.isOptionChecked(MENU_SHOW_ZONES_IN_EDIT_MODE)); @@ -1593,7 +1598,7 @@ var PropertiesTool = function (opts) { for (i = 0; i < selectionManager.selections.length; i++) { Entities.editEntity(selectionManager.selections[i], properties); } - } else { + } else if (data.properties) { if (data.properties.dynamic === false) { // this object is leaving dynamic, so we zero its velocities data.properties.velocity = { From 12b8a7748895dfd30ef958431038e48c69d459e2 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Wed, 15 Feb 2017 16:29:50 -0800 Subject: [PATCH 22/89] in edit.js, convert entity property ID to be a text-field so the data can be copied --- scripts/system/html/entityProperties.html | 2 +- scripts/system/html/js/entityProperties.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/system/html/entityProperties.html b/scripts/system/html/entityProperties.html index b11127b26c..59c420b547 100644 --- a/scripts/system/html/entityProperties.html +++ b/scripts/system/html/entityProperties.html @@ -77,7 +77,7 @@
- +