From 2d85669b08537be891c01a3e3cf8209078a84c3f Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Tue, 13 Mar 2018 16:30:43 -0700 Subject: [PATCH 01/15] fix backedColumn width --- interface/resources/qml/hifi/AssetServer.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/resources/qml/hifi/AssetServer.qml b/interface/resources/qml/hifi/AssetServer.qml index 34be11d4df..c2eef3547b 100644 --- a/interface/resources/qml/hifi/AssetServer.qml +++ b/interface/resources/qml/hifi/AssetServer.qml @@ -561,7 +561,7 @@ Windows.ScrollingWindow { id: bakedColumn title: "Use Baked?" role: "baked" - width: 100 + width: 170 } itemDelegate: Loader { From 2fb1fbe027114f931fcb2939fd22b55c65e44e29 Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Wed, 14 Mar 2018 09:17:22 -0700 Subject: [PATCH 02/15] fix sorting --- interface/resources/qml/hifi/AssetServer.qml | 61 ++++++++++--------- .../AssetMappingsScriptingInterface.cpp | 6 +- .../AssetMappingsScriptingInterface.h | 1 + 3 files changed, 39 insertions(+), 29 deletions(-) diff --git a/interface/resources/qml/hifi/AssetServer.qml b/interface/resources/qml/hifi/AssetServer.qml index c2eef3547b..ceb56fe445 100644 --- a/interface/resources/qml/hifi/AssetServer.qml +++ b/interface/resources/qml/hifi/AssetServer.qml @@ -57,7 +57,7 @@ Windows.ScrollingWindow { Component.onDestruction: { assetMappingsModel.autoRefreshEnabled = false; } - + function letterbox(headerGlyph, headerText, message) { letterboxMessage.headerGlyph = headerGlyph; letterboxMessage.headerText = headerText; @@ -144,7 +144,7 @@ Windows.ScrollingWindow { function canAddToWorld(path) { var supportedExtensions = [/\.fbx\b/i, /\.obj\b/i, /\.jpg\b/i, /\.png\b/i]; - + if (selectedItemCount > 1) { return false; } @@ -153,8 +153,8 @@ Windows.ScrollingWindow { return total | new RegExp(current).test(path); }, false); } - - function canRename() { + + function canRename() { if (treeView.selection.hasSelection && selectedItemCount == 1) { return true; } else { @@ -198,7 +198,7 @@ Windows.ScrollingWindow { var SHAPE_TYPE_STATIC_MESH = 3; var SHAPE_TYPE_BOX = 4; var SHAPE_TYPE_SPHERE = 5; - + var SHAPE_TYPES = []; SHAPE_TYPES[SHAPE_TYPE_NONE] = "No Collision"; SHAPE_TYPES[SHAPE_TYPE_SIMPLE_HULL] = "Basic - Whole model"; @@ -206,7 +206,7 @@ Windows.ScrollingWindow { SHAPE_TYPES[SHAPE_TYPE_STATIC_MESH] = "Exact - All polygons"; SHAPE_TYPES[SHAPE_TYPE_BOX] = "Box"; SHAPE_TYPES[SHAPE_TYPE_SPHERE] = "Sphere"; - + var SHAPE_TYPE_DEFAULT = SHAPE_TYPE_SIMPLE_COMPOUND; var DYNAMIC_DEFAULT = false; var prompt = desktop.customInputDialog({ @@ -348,14 +348,14 @@ Windows.ScrollingWindow { } function deleteFile(index) { var paths = []; - + if (!index) { for (var i = 0; i < selectedItemCount; ++i) { index = treeView.selection.selectedIndexes[i]; paths[i] = assetProxyModel.data(index, 0x100); } } - + if (!paths) { return; } @@ -364,13 +364,13 @@ Windows.ScrollingWindow { var items = selectedItemCount.toString(); var isFolder = assetProxyModel.data(treeView.selection.currentIndex, 0x101); var typeString = isFolder ? 'folder' : 'file'; - + if (selectedItemCount > 1) { modalMessage = "You are about to delete " + items + " items \nDo you want to continue?"; } else { modalMessage = "You are about to delete the following " + typeString + ":\n" + paths + "\nDo you want to continue?"; } - + var object = desktop.messageBox({ icon: hifi.icons.question, buttons: OriginalDialogs.StandardButton.Yes + OriginalDialogs.StandardButton.No, @@ -475,11 +475,11 @@ Windows.ScrollingWindow { }); } } - + Item { width: pane.contentWidth height: pane.height - + // The letterbox used for popup messages LetterboxMessage { id: letterboxMessage; @@ -541,7 +541,7 @@ Windows.ScrollingWindow { anchors.margins: hifi.dimensions.contentMargin.x + 2 // Extra for border anchors.left: parent.left anchors.right: parent.right - + treeModel: assetProxyModel selectionMode: SelectionMode.ExtendedSelection headerVisible: true @@ -563,7 +563,12 @@ Windows.ScrollingWindow { role: "baked" width: 170 } - + + onSortIndicatorOrderChanged: { + console.log("sort indicator changed"); + Assets.sortProxyModel(sortIndicatorColumn, sortIndicatorOrder); + } + itemDelegate: Loader { id: itemDelegateLoader @@ -599,7 +604,7 @@ Windows.ScrollingWindow { } sourceComponent: getComponent() - + Component { id: labelComponent FiraSansSemiBold { @@ -608,15 +613,15 @@ Windows.ScrollingWindow { color: colorScheme == hifi.colorSchemes.light ? (styleData.selected ? hifi.colors.black : hifi.colors.baseGrayHighlight) : (styleData.selected ? hifi.colors.black : hifi.colors.lightGrayText) - + horizontalAlignment: styleData.column === 1 ? TextInput.AlignHCenter : TextInput.AlignLeft - + elide: Text.ElideMiddle MouseArea { id: mouseArea anchors.fill: parent - + acceptedButtons: Qt.NoButton hoverEnabled: true @@ -638,7 +643,7 @@ Windows.ScrollingWindow { color: colorScheme == hifi.colorSchemes.light ? (styleData.selected ? hifi.colors.black : hifi.colors.baseGrayHighlight) : (styleData.selected ? hifi.colors.black : hifi.colors.lightGrayText) - + elide: Text.ElideRight horizontalAlignment: TextInput.AlignHCenter @@ -725,7 +730,7 @@ Windows.ScrollingWindow { size: hifi.fontSizes.tableText color: colorScheme == hifi.colorSchemes.light ? hifi.colors.black : hifi.colors.lightGrayText } - + Timer { id: showTimer interval: 1000 @@ -744,7 +749,7 @@ Windows.ScrollingWindow { treeLabelToolTip.visible = false; } }// End_OF( treeLabelToolTip ) - + MouseArea { propagateComposedEvents: true anchors.fill: parent @@ -802,7 +807,7 @@ Windows.ScrollingWindow { anchors.left: treeView.left anchors.right: treeView.right anchors.bottom: uploadSection.top - + RalewayRegular { anchors.verticalCenter: parent.verticalCenter @@ -846,7 +851,7 @@ Windows.ScrollingWindow { checked = Qt.binding(isChecked); } - + function isEnabled() { if (!treeView.selection.hasSelection) { return false; @@ -870,7 +875,7 @@ Windows.ScrollingWindow { } } - return true; + return true; } function isChecked() { if (!treeView.selection.hasSelection) { @@ -878,10 +883,10 @@ Windows.ScrollingWindow { } var status = assetProxyModel.data(treeView.selection.currentIndex, 0x105); - return isEnabled() && status !== "Not Baked"; - } + return isEnabled() && status !== "Not Baked"; + } } - + Item { anchors.verticalCenter: parent.verticalCenter width: infoGlyph.size; @@ -905,7 +910,7 @@ Windows.ScrollingWindow { "What is baking?", "Baking compresses and optimizes files for faster network transfer and display. We recommend you bake your content to reduce initial load times for your visitors."); } - } + } }// End_OF( infoRow ) HifiControls.ContentSection { diff --git a/interface/src/scripting/AssetMappingsScriptingInterface.cpp b/interface/src/scripting/AssetMappingsScriptingInterface.cpp index 4bc8ec0bd3..7273874be1 100644 --- a/interface/src/scripting/AssetMappingsScriptingInterface.cpp +++ b/interface/src/scripting/AssetMappingsScriptingInterface.cpp @@ -152,6 +152,10 @@ void AssetMappingsScriptingInterface::deleteMappings(QStringList paths, QJSValue request->start(); } +void AssetMappingsScriptingInterface::sortProxyModel(int column, Qt::SortOrder order) { + _proxyModel.sort(column, order); +} + void AssetMappingsScriptingInterface::getAllMappings(QJSValue callback) { auto assetClient = DependencyManager::get(); auto request = assetClient->createGetAllMappingsRequest(); @@ -287,7 +291,7 @@ void AssetMappingModel::refresh() { item->setData(parts[i], Qt::UserRole + 2); item->setData("atp:" + fullPath, Qt::UserRole + 3); item->setData(fullPath, Qt::UserRole + 4); - + if (lastItem) { lastItem->appendRow(item); } else { diff --git a/interface/src/scripting/AssetMappingsScriptingInterface.h b/interface/src/scripting/AssetMappingsScriptingInterface.h index 1a4c7dae48..b27a72fbd0 100644 --- a/interface/src/scripting/AssetMappingsScriptingInterface.h +++ b/interface/src/scripting/AssetMappingsScriptingInterface.h @@ -82,6 +82,7 @@ public: Q_INVOKABLE void getAllMappings(QJSValue callback = QJSValue()); Q_INVOKABLE void renameMapping(QString oldPath, QString newPath, QJSValue callback = QJSValue()); Q_INVOKABLE void setBakingEnabled(QStringList paths, bool enabled, QJSValue callback = QJSValue()); + Q_INVOKABLE void sortProxyModel(int column, Qt::SortOrder order = Qt::AscendingOrder); protected: QSet _pendingRequests; From d6b3e91de192f1791e5ede7deb1b6b5a362dceba Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Wed, 14 Mar 2018 09:35:22 -0700 Subject: [PATCH 03/15] removing debug statement --- interface/resources/qml/hifi/AssetServer.qml | 1 - 1 file changed, 1 deletion(-) diff --git a/interface/resources/qml/hifi/AssetServer.qml b/interface/resources/qml/hifi/AssetServer.qml index ceb56fe445..ef4aeeff23 100644 --- a/interface/resources/qml/hifi/AssetServer.qml +++ b/interface/resources/qml/hifi/AssetServer.qml @@ -565,7 +565,6 @@ Windows.ScrollingWindow { } onSortIndicatorOrderChanged: { - console.log("sort indicator changed"); Assets.sortProxyModel(sortIndicatorColumn, sortIndicatorOrder); } From 563be9ab9171dd03acbbf7303fa4493e883f0181 Mon Sep 17 00:00:00 2001 From: Triplelexx Date: Fri, 16 Mar 2018 20:13:02 +0000 Subject: [PATCH 04/15] tidy inspect.js --- script-archive/inspect.js | 411 +++++++++++++++++++------------------- 1 file changed, 201 insertions(+), 210 deletions(-) diff --git a/script-archive/inspect.js b/script-archive/inspect.js index 555b4105b7..45fc281792 100644 --- a/script-archive/inspect.js +++ b/script-archive/inspect.js @@ -26,14 +26,14 @@ var RADIUS_RATE = 1.0 / 100.0; var PAN_RATE = 250.0; var Y_AXIS = { - x: 0, - y: 1, - z: 0 + x: 0, + y: 1, + z: 0 }; var X_AXIS = { - x: 1, - y: 0, - z: 0 + x: 1, + y: 0, + z: 0 }; var LOOK_AT_TIME = 500; @@ -58,19 +58,19 @@ var mouseLastY = 0; var center = { - x: 0, - y: 0, - z: 0 + x: 0, + y: 0, + z: 0 }; var position = { - x: 0, - y: 0, - z: 0 + x: 0, + y: 0, + z: 0 }; var vector = { - x: 0, - y: 0, - z: 0 + x: 0, + y: 0, + z: 0 }; var radius = 0.0; var azimuth = 0.0; @@ -83,258 +83,249 @@ var rotatingTowardsTarget = false; var targetCamOrientation; var oldPosition, oldOrientation; - function orientationOf(vector) { - var direction, - yaw, - pitch; + var direction, + yaw, + pitch; - direction = Vec3.normalize(vector); - yaw = Quat.angleAxis(Math.atan2(direction.x, direction.z) * RAD_TO_DEG, Y_AXIS); - pitch = Quat.angleAxis(Math.asin(-direction.y) * RAD_TO_DEG, X_AXIS); - return Quat.multiply(yaw, pitch); + direction = Vec3.normalize(vector); + yaw = Quat.angleAxis(Math.atan2(direction.x, direction.z) * RAD_TO_DEG, Y_AXIS); + pitch = Quat.angleAxis(Math.asin(-direction.y) * RAD_TO_DEG, X_AXIS); + return Quat.multiply(yaw, pitch); } - function handleRadialMode(dx, dy) { - azimuth += dx / AZIMUTH_RATE; - radius += radius * dy * RADIUS_RATE; - if (radius < 1) { - radius = 1; - } + azimuth += dx / AZIMUTH_RATE; + radius += radius * dy * RADIUS_RATE; + if (radius < 1) { + radius = 1; + } - vector = { - x: (Math.cos(altitude) * Math.cos(azimuth)) * radius, - y: Math.sin(altitude) * radius, - z: (Math.cos(altitude) * Math.sin(azimuth)) * radius - }; - position = Vec3.sum(center, vector); - Camera.setPosition(position); - Camera.setOrientation(orientationOf(vector)); + vector = { + x: (Math.cos(altitude) * Math.cos(azimuth)) * radius, + y: Math.sin(altitude) * radius, + z: (Math.cos(altitude) * Math.sin(azimuth)) * radius + }; + position = Vec3.sum(center, vector); + Camera.setPosition(position); + Camera.setOrientation(orientationOf(vector)); } function handleOrbitMode(dx, dy) { - azimuth += dx / AZIMUTH_RATE; - altitude += dy / ALTITUDE_RATE; - if (altitude > PI / 2.0) { - altitude = PI / 2.0; - } - if (altitude < -PI / 2.0) { - altitude = -PI / 2.0; - } + azimuth += dx / AZIMUTH_RATE; + altitude += dy / ALTITUDE_RATE; + if (altitude > PI / 2.0) { + altitude = PI / 2.0; + } + if (altitude < -PI / 2.0) { + altitude = -PI / 2.0; + } - vector = { - x: (Math.cos(altitude) * Math.cos(azimuth)) * radius, - y: Math.sin(altitude) * radius, - z: (Math.cos(altitude) * Math.sin(azimuth)) * radius - }; - position = Vec3.sum(center, vector); - Camera.setPosition(position); - Camera.setOrientation(orientationOf(vector)); + vector = { + x: (Math.cos(altitude) * Math.cos(azimuth)) * radius, + y: Math.sin(altitude) * radius, + z: (Math.cos(altitude) * Math.sin(azimuth)) * radius + }; + position = Vec3.sum(center, vector); + Camera.setPosition(position); + Camera.setOrientation(orientationOf(vector)); } - function handlePanMode(dx, dy) { - var up = Quat.getUp(Camera.getOrientation()); - var right = Quat.getRight(Camera.getOrientation()); - var distance = Vec3.length(vector); + var up = Quat.getUp(Camera.getOrientation()); + var right = Quat.getRight(Camera.getOrientation()); + var distance = Vec3.length(vector); - var dv = Vec3.sum(Vec3.multiply(up, distance * dy / PAN_RATE), Vec3.multiply(right, -distance * dx / PAN_RATE)); + var dv = Vec3.sum(Vec3.multiply(up, distance * dy / PAN_RATE), Vec3.multiply(right, -distance * dx / PAN_RATE)); - center = Vec3.sum(center, dv); - position = Vec3.sum(position, dv); + center = Vec3.sum(center, dv); + position = Vec3.sum(position, dv); - Camera.setPosition(position); - Camera.setOrientation(orientationOf(vector)); + Camera.setPosition(position); + Camera.setOrientation(orientationOf(vector)); } function saveCameraState() { - oldMode = Camera.mode; - oldPosition = Camera.getPosition(); - oldOrientation = Camera.getOrientation(); + oldMode = Camera.mode; + oldPosition = Camera.getPosition(); + oldOrientation = Camera.getOrientation(); - Camera.mode = "independent"; - Camera.setPosition(oldPosition); + Camera.mode = "independent"; + Camera.setPosition(oldPosition); } function restoreCameraState() { - Camera.mode = oldMode; - Camera.setPosition(oldPosition); - Camera.setOrientation(oldOrientation); + Camera.mode = oldMode; + Camera.setPosition(oldPosition); + Camera.setOrientation(oldOrientation); } function handleModes() { - var newMode = (mode == noMode) ? noMode : detachedMode; - if (alt) { - if (control) { - if (shift) { - newMode = panningMode; - } else { - newMode = orbitMode; - } - } else { - newMode = radialMode; + var newMode = (mode == noMode) ? noMode : detachedMode; + if (alt) { + if (control) { + if (shift) { + newMode = panningMode; + } else { + newMode = orbitMode; + } + } else { + newMode = radialMode; + } } - } - // if entering detachMode - if (newMode == detachedMode && mode != detachedMode) { - avatarPosition = MyAvatar.position; - avatarOrientation = MyAvatar.orientation; - } - // if leaving detachMode - if (mode == detachedMode && newMode == detachedMode && - (avatarPosition.x != MyAvatar.position.x || - avatarPosition.y != MyAvatar.position.y || - avatarPosition.z != MyAvatar.position.z || - avatarOrientation.x != MyAvatar.orientation.x || - avatarOrientation.y != MyAvatar.orientation.y || - avatarOrientation.z != MyAvatar.orientation.z || - avatarOrientation.w != MyAvatar.orientation.w)) { - newMode = noMode; - } + // if entering detachMode + if (newMode == detachedMode && mode != detachedMode) { + avatarPosition = MyAvatar.position; + avatarOrientation = MyAvatar.orientation; + } + // if leaving detachMode + if (mode == detachedMode && newMode == detachedMode && + (avatarPosition.x != MyAvatar.position.x || + avatarPosition.y != MyAvatar.position.y || + avatarPosition.z != MyAvatar.position.z || + avatarOrientation.x != MyAvatar.orientation.x || + avatarOrientation.y != MyAvatar.orientation.y || + avatarOrientation.z != MyAvatar.orientation.z || + avatarOrientation.w != MyAvatar.orientation.w)) { + newMode = noMode; + } - if (mode == noMode && newMode != noMode && Camera.mode == "independent") { - newMode = noMode; - } + if (mode == noMode && newMode != noMode && Camera.mode == "independent") { + newMode = noMode; + } - // if leaving noMode - if (mode == noMode && newMode != noMode) { - saveCameraState(); - } - // if entering noMode - if (newMode == noMode && mode != noMode) { - restoreCameraState(); - } + // if leaving noMode + if (mode == noMode && newMode != noMode) { + saveCameraState(); + } + // if entering noMode + if (newMode == noMode && mode != noMode) { + restoreCameraState(); + } - mode = newMode; + mode = newMode; } function keyPressEvent(event) { - var changed = false; + var changed = false; - if (event.text == "ALT") { - alt = true; - changed = true; - } - if (event.text == "CONTROL") { - control = true; - changed = true; - } - if (event.text == "SHIFT") { - shift = true; - changed = true; - } + if (event.text == "ALT") { + alt = true; + changed = true; + } + if (event.text == "CONTROL") { + control = true; + changed = true; + } + if (event.text == "SHIFT") { + shift = true; + changed = true; + } - if (changed) { - handleModes(); - } + if (changed) { + handleModes(); + } } function keyReleaseEvent(event) { - var changed = false; + var changed = false; - if (event.text == "ALT") { - alt = false; - changed = true; - mode = noMode; - restoreCameraState(); - } - if (event.text == "CONTROL") { - control = false; - changed = true; - } - if (event.text == "SHIFT") { - shift = false; - changed = true; - } - - if (changed) { - handleModes(); - } -} - - - -function mousePressEvent(event) { - if (alt && !isActive) { - mouseLastX = event.x; - mouseLastY = event.y; - - // Compute trajectories related values - var pickRay = Camera.computePickRay(mouseLastX, mouseLastY); - var modelIntersection = Entities.findRayIntersection(pickRay, true); - - position = Camera.getPosition(); - - var avatarTarget = MyAvatar.getTargetAvatarPosition(); - - - var distance = -1; - var string; - - if (modelIntersection.intersects && modelIntersection.accurate) { - distance = modelIntersection.distance; - center = modelIntersection.intersection; - string = "Inspecting model"; - //We've selected our target, now orbit towards it automatically - rotatingTowardsTarget = true; - //calculate our target cam rotation - Script.setTimeout(function() { - rotatingTowardsTarget = false; - }, LOOK_AT_TIME); - - vector = Vec3.subtract(position, center); - targetCamOrientation = orientationOf(vector); - radius = Vec3.length(vector); - azimuth = Math.atan2(vector.z, vector.x); - altitude = Math.asin(vector.y / Vec3.length(vector)); - - isActive = true; + if (event.text == "ALT") { + alt = false; + changed = true; + mode = noMode; + restoreCameraState(); + } + if (event.text == "CONTROL") { + control = false; + changed = true; + } + if (event.text == "SHIFT") { + shift = false; + changed = true; } - } + if (changed) { + handleModes(); + } +} + +function mousePressEvent(event) { + if (alt && !isActive) { + mouseLastX = event.x; + mouseLastY = event.y; + + // Compute trajectories related values + var pickRay = Camera.computePickRay(mouseLastX, mouseLastY); + var modelIntersection = Entities.findRayIntersection(pickRay, true); + + position = Camera.getPosition(); + + var distance = -1; + var string = ""; + + if (modelIntersection.intersects && modelIntersection.accurate) { + distance = modelIntersection.distance; + center = modelIntersection.intersection; + string = "Inspecting model"; + // We've selected our target, now orbit towards it automatically + rotatingTowardsTarget = true; + // calculate our target cam rotation + Script.setTimeout(function () { + rotatingTowardsTarget = false; + }, LOOK_AT_TIME); + + vector = Vec3.subtract(position, center); + targetCamOrientation = orientationOf(vector); + radius = Vec3.length(vector); + azimuth = Math.atan2(vector.z, vector.x); + altitude = Math.asin(vector.y / Vec3.length(vector)); + + isActive = true; + } + + } } function mouseReleaseEvent(event) { - if (isActive) { - isActive = false; - } + if (isActive) { + isActive = false; + } } function mouseMoveEvent(event) { - if (isActive && mode != noMode && !rotatingTowardsTarget) { - if (mode == radialMode) { - handleRadialMode(event.x - mouseLastX, event.y - mouseLastY); + if (isActive && mode != noMode && !rotatingTowardsTarget) { + if (mode == radialMode) { + handleRadialMode(event.x - mouseLastX, event.y - mouseLastY); + } + if (mode == orbitMode) { + handleOrbitMode(event.x - mouseLastX, event.y - mouseLastY); + } + if (mode == panningMode) { + handlePanMode(event.x - mouseLastX, event.y - mouseLastY); + } } - if (mode == orbitMode) { - handleOrbitMode(event.x - mouseLastX, event.y - mouseLastY); - } - if (mode == panningMode) { - handlePanMode(event.x - mouseLastX, event.y - mouseLastY); - } - - } - mouseLastX = event.x; - mouseLastY = event.y; + mouseLastX = event.x; + mouseLastY = event.y; } function update() { - handleModes(); - if (rotatingTowardsTarget) { - rotateTowardsTarget(); - } + handleModes(); + if (rotatingTowardsTarget) { + rotateTowardsTarget(); + } } function rotateTowardsTarget() { - var newOrientation = Quat.mix(Camera.getOrientation(), targetCamOrientation, .1); - Camera.setOrientation(newOrientation); + var newOrientation = Quat.mix(Camera.getOrientation(), targetCamOrientation, 0.1); + Camera.setOrientation(newOrientation); } function scriptEnding() { - if (mode != noMode) { - restoreCameraState(); - } + if (mode != noMode) { + restoreCameraState(); + } } Controller.keyPressEvent.connect(keyPressEvent); @@ -345,4 +336,4 @@ Controller.mouseReleaseEvent.connect(mouseReleaseEvent); Controller.mouseMoveEvent.connect(mouseMoveEvent); Script.update.connect(update); -Script.scriptEnding.connect(scriptEnding); \ No newline at end of file +Script.scriptEnding.connect(scriptEnding); From 7101a37bf983e890b772adee24c357c25b28c522 Mon Sep 17 00:00:00 2001 From: Triplelexx Date: Fri, 16 Mar 2018 20:27:05 +0000 Subject: [PATCH 05/15] add inspect avatars --- script-archive/inspect.js | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/script-archive/inspect.js b/script-archive/inspect.js index 45fc281792..18b26ab709 100644 --- a/script-archive/inspect.js +++ b/script-archive/inspect.js @@ -56,7 +56,6 @@ var mode = noMode; var mouseLastX = 0; var mouseLastY = 0; - var center = { x: 0, y: 0, @@ -259,16 +258,16 @@ function mousePressEvent(event) { // Compute trajectories related values var pickRay = Camera.computePickRay(mouseLastX, mouseLastY); var modelIntersection = Entities.findRayIntersection(pickRay, true); + var avatarIntersection = AvatarList.findRayIntersection(pickRay); position = Camera.getPosition(); - var distance = -1; - var string = ""; - - if (modelIntersection.intersects && modelIntersection.accurate) { - distance = modelIntersection.distance; - center = modelIntersection.intersection; - string = "Inspecting model"; + if (avatarIntersection.intersects || (modelIntersection.intersects && modelIntersection.accurate)) { + if (avatarIntersection.intersects) { + center = avatarIntersection.intersection; + } else { + center = modelIntersection.intersection; + } // We've selected our target, now orbit towards it automatically rotatingTowardsTarget = true; // calculate our target cam rotation @@ -284,7 +283,6 @@ function mousePressEvent(event) { isActive = true; } - } } From 0d6bfada40f94fe921e78d7a6b17d4eb9f9bb553 Mon Sep 17 00:00:00 2001 From: Cristian Duarte Date: Tue, 20 Mar 2018 17:24:38 -0300 Subject: [PATCH 06/15] Prevent Go To and Avatar windows to move Radar Mode's camera when touched or interacted with --- scripts/+android/defaultScripts.js | 5 +-- scripts/system/+android/androidCombined.js | 24 ++++++++++++++ scripts/system/+android/avatarSelection.js | 1 + scripts/system/+android/bottombar.js | 38 +++++++++++++++++++++- scripts/system/+android/modes.js | 29 ++++++++++++----- 5 files changed, 86 insertions(+), 11 deletions(-) create mode 100644 scripts/system/+android/androidCombined.js diff --git a/scripts/+android/defaultScripts.js b/scripts/+android/defaultScripts.js index a8f6bf42a1..82e32a6d00 100644 --- a/scripts/+android/defaultScripts.js +++ b/scripts/+android/defaultScripts.js @@ -14,9 +14,10 @@ var DEFAULT_SCRIPTS_COMBINED = [ "system/progress.js", "system/+android/touchscreenvirtualpad.js", + "system/+android/audio.js", + "system/+android/androidCombined.js"/*, "system/+android/bottombar.js", - "system/+android/audio.js" , - "system/+android/modes.js"/*, + "system/+android/modes.js", "system/away.js", "system/controllers/controllerDisplayManager.js", "system/controllers/handControllerGrabAndroid.js", diff --git a/scripts/system/+android/androidCombined.js b/scripts/system/+android/androidCombined.js new file mode 100644 index 0000000000..76a52bcab7 --- /dev/null +++ b/scripts/system/+android/androidCombined.js @@ -0,0 +1,24 @@ +"use strict"; +// +// androidCombined.js +// scripts/system/ +// +// Created by Gabriel Calero & Cristian Duarte on Mar 20, 2018 +// Copyright 2018 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 +// + +(function() { // BEGIN LOCAL_SCOPE + +var modesInterface = Script.require('./modes.js'); +var bottombarInterface = Script.require('./bottombar.js'); + +function init() { + modesInterface.isRadarModeValidTouch = bottombarInterface.isRadarModeValidTouch;// set new function +} + +init(); + +}()); // END LOCAL_SCOPE \ No newline at end of file diff --git a/scripts/system/+android/avatarSelection.js b/scripts/system/+android/avatarSelection.js index 2b28fe2c9b..2946e541b5 100644 --- a/scripts/system/+android/avatarSelection.js +++ b/scripts/system/+android/avatarSelection.js @@ -35,6 +35,7 @@ function fromQml(message) { // messages are {method, params}, like json-rpc. See break; case 'hide': Controller.setVPadHidden(false); + module.exports.hide(); module.exports.onHidden(); break; default: diff --git a/scripts/system/+android/bottombar.js b/scripts/system/+android/bottombar.js index 3435edb548..2fb332a33d 100644 --- a/scripts/system/+android/bottombar.js +++ b/scripts/system/+android/bottombar.js @@ -21,7 +21,9 @@ var loginBtn; var gotoScript = Script.require('./goto.js'); var avatarSelection = Script.require('./avatarSelection.js'); -var logEnabled = false; +var bottombarInterface = []; + +var logEnabled = true; function printd(str) { if (logEnabled) { @@ -262,6 +264,40 @@ Script.scriptEnding.connect(function () { GlobalServices.disconnected.disconnect(handleLogout); }); +function isRadarModeValidTouch(coords) { + var qmlFragments = [bottombar, bottomHudOptionsBar.qmlFragment]; + var windows = [gotoScript, avatarSelection]; + for (var i=0; i < qmlFragments.length; i++) { + var aQmlFrag = qmlFragments[i]; + if (aQmlFrag != null && aQmlFrag.isVisible() && + coords.x >= aQmlFrag.position.x && coords.x <= aQmlFrag.position.x + aQmlFrag.size.x && + coords.y >= aQmlFrag.position.y && coords.y <= aQmlFrag.position.y + aQmlFrag.size.y + ) { + printd("isRadarModeValidTouch- false because of qmlFragments!? idx " + i); + return false; + } + } + + for (var i=0; i < windows.length; i++) { + var aWin = windows[i]; + if (aWin != null && aWin.position() != null && aWin.isVisible() && + coords.x >= aWin.position().x && coords.x <= aWin.position().x + aWin.width() && + coords.y >= aWin.position().y && coords.y <= aWin.position().y + aWin.height() + ) { + printd("isRadarModeValidTouch- false because of windows!? idx " + i); + return false; + } else { + printd("isRadarModeValidTouch- discarded of window idx " + i + " visible= " + aWin.isVisible()); + } + } + printd("isRadarModeValidTouch- true by default "); + return true; +} + +bottombarInterface.isRadarModeValidTouch = isRadarModeValidTouch; + +module.exports = bottombarInterface; + init(); }()); // END LOCAL_SCOPE diff --git a/scripts/system/+android/modes.js b/scripts/system/+android/modes.js index 097798e393..4bc4333a09 100644 --- a/scripts/system/+android/modes.js +++ b/scripts/system/+android/modes.js @@ -23,6 +23,8 @@ var logEnabled = true; var radar = Script.require('./radar.js'); var uniqueColor = Script.require('./uniqueColor.js'); +var modesInterface = {}; + function printd(str) { if (logEnabled) { print("[modes.js] " + str); @@ -184,33 +186,44 @@ function onButtonClicked(clickedButton, whatToDo, hideAllAfter) { } function isRadarModeValidTouch(coords) { + if (!modesInterface.isRadarModeValidTouch(coords)) { + printd("isRadarModeValidTouch- false because of modesInterface"); + return false; + } + printd("isRadarModeValidTouch- modesInterface is true, evaluating modesbar qmls.."); + var qmlFragments = [modesbar.qmlFragment]; var windows = []; for (var i=0; i < qmlFragments.length; i++) { var aQmlFrag = qmlFragments[i]; if (aQmlFrag != null && aQmlFrag.isVisible() && - coords.x >= aQmlFrag.position.x * 3 && coords.x <= aQmlFrag.position.x * 3 + aQmlFrag.size.x * 3 && - coords.y >= aQmlFrag.position.y * 3 && coords.y <= aQmlFrag.position.y * 3 + aQmlFrag.size.y * 3 + coords.x >= aQmlFrag.position.x && coords.x <= aQmlFrag.position.x + aQmlFrag.size.x && + coords.y >= aQmlFrag.position.y && coords.y <= aQmlFrag.position.y + aQmlFrag.size.y ) { - printd("godViewModeTouchValid- false because of qmlFragments!? idx " + i); + printd("isRadarModeValidTouch- false because of qmlFragments!? idx " + i); return false; } } for (var i=0; i < windows.length; i++) { var aWin = windows[i]; - if (aWin != null && aWin.position() != null && - coords.x >= aWin.position().x * 3 && coords.x <= aWin.position().x * 3 + aWin.width() * 3 && - coords.y >= aWin.position().y * 3 && coords.y <= aWin.position().y * 3 + aWin.height() * 3 + if (aWin != null && aWin.position() != null && aWin.isVisible() && + coords.x >= aWin.position().x && coords.x <= aWin.position().x + aWin.width() && + coords.y >= aWin.position().y && coords.y <= aWin.position().y + aWin.height() ) { - printd("godViewModeTouchValid- false because of windows!?"); + printd("isRadarModeValidTouch- false because of windows!? idx " + i); return false; } } - printd("godViewModeTouchValid- true by default "); + printd("isRadarModeValidTouch- true by default "); return true; } +// default +modesInterface.isRadarModeValidTouch = function(coords) {return true;}; + +module.exports = modesInterface; + Script.scriptEnding.connect(function () { shutdown(); }); From 05efc5a231cd96c53034a7fd838cd2a2fbfb9ea6 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Wed, 21 Mar 2018 15:36:39 +1300 Subject: [PATCH 07/15] Revert "Remove Overlays.getOverlayObject() from JavaScript API" This reverts commit 8e2a3e8c99ff2bc1f36349db28d5d9a92d3dbfc7. --- interface/src/ui/overlays/Overlays.cpp | 15 +++++++++++++++ interface/src/ui/overlays/Overlays.h | 9 +++++++++ scripts/system/libraries/WebTablet.js | 4 ++++ 3 files changed, 28 insertions(+) diff --git a/interface/src/ui/overlays/Overlays.cpp b/interface/src/ui/overlays/Overlays.cpp index 35274e4fbe..6898b5ed2b 100644 --- a/interface/src/ui/overlays/Overlays.cpp +++ b/interface/src/ui/overlays/Overlays.cpp @@ -388,6 +388,21 @@ QString Overlays::getOverlayType(OverlayID overlayId) { return ""; } +QObject* Overlays::getOverlayObject(OverlayID id) { + if (QThread::currentThread() != thread()) { + QObject* result; + PROFILE_RANGE(script, __FUNCTION__); + BLOCKING_INVOKE_METHOD(this, "getOverlayObject", Q_RETURN_ARG(QObject*, result), Q_ARG(OverlayID, id)); + return result; + } + + Overlay::Pointer thisOverlay = getOverlay(id); + if (thisOverlay) { + return qobject_cast(&(*thisOverlay)); + } + return nullptr; +} + OverlayID Overlays::getOverlayAtPoint(const glm::vec2& point) { if (!_enabled) { return UNKNOWN_OVERLAY_ID; diff --git a/interface/src/ui/overlays/Overlays.h b/interface/src/ui/overlays/Overlays.h index c3d87642f1..544aea75e0 100644 --- a/interface/src/ui/overlays/Overlays.h +++ b/interface/src/ui/overlays/Overlays.h @@ -235,6 +235,15 @@ public slots: */ QString getOverlayType(OverlayID overlayId); + /**jsdoc + * Get the overlay script object. + * @function Overlays.getOverlayObject + * @deprecated This function is deprecated and will soon be removed. + * @param {Uuid} overlayID - The ID of the overlay to get the script object of. + * @returns {object} The script object for the overlay if found. + */ + QObject* getOverlayObject(OverlayID id); + /**jsdoc * Get the ID of the 2D overlay at a particular point on the screen or HUD. * @function Overlays.getOverlayAtPoint diff --git a/scripts/system/libraries/WebTablet.js b/scripts/system/libraries/WebTablet.js index 511bb6989e..a7186f55bd 100644 --- a/scripts/system/libraries/WebTablet.js +++ b/scripts/system/libraries/WebTablet.js @@ -307,6 +307,10 @@ WebTablet.prototype.setScriptURL = function (scriptURL) { Overlays.editOverlay(this.webOverlayID, { scriptURL: scriptURL }); }; +WebTablet.prototype.getOverlayObject = function () { + return Overlays.getOverlayObject(this.webOverlayID); +}; + WebTablet.prototype.setWidth = function (width) { // imported from libraries/utils.js resizeTablet(width); From 8df6cd58c67bb649f7140872b32f100a2a18f471 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Wed, 21 Mar 2018 15:50:22 +1300 Subject: [PATCH 08/15] Document Overlays.getOverlayObject's use for web3d event bridge --- interface/src/ui/overlays/Overlays.h | 39 ++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/interface/src/ui/overlays/Overlays.h b/interface/src/ui/overlays/Overlays.h index 544aea75e0..a47a85624c 100644 --- a/interface/src/ui/overlays/Overlays.h +++ b/interface/src/ui/overlays/Overlays.h @@ -236,11 +236,46 @@ public slots: QString getOverlayType(OverlayID overlayId); /**jsdoc - * Get the overlay script object. + * Get the overlay script object. In particular, this is useful for accessing the event bridge for a web3d + * overlay. * @function Overlays.getOverlayObject - * @deprecated This function is deprecated and will soon be removed. * @param {Uuid} overlayID - The ID of the overlay to get the script object of. * @returns {object} The script object for the overlay if found. + * @example Receive "hello" messages from a web3d overlay. + * // HTML file: name "web3d.html". + * + * + * + * HELLO + * + * + *

HELLO

+ * + * + * + * + * // Script file. + * var web3dOverlay = Overlays.addOverlay("web3d", { + * position: Vec3.sum(MyAvatar.position, Vec3.multiplyQbyV(MyAvatar.orientation, {x: 0, y: 0.5, z: -3 })), + * rotation: MyAvatar.orientation, + * url: Script.resolvePath("web3d.html"), + * alpha: 1.0 + * }); + * + * function onWebEventReceived(event) { + * print("onWebEventReceived() : " + JSON.stringify(event)); + * } + * + * overlayObject = Overlays.getOverlayObject(web3dOverlay); + * overlayObject.webEventReceived.connect(onWebEventReceived); + * + * Script.scriptEnding.connect(function () { + * Overlays.deleteOverlay(web3dOverlay); + * }); */ QObject* getOverlayObject(OverlayID id); From 242b009562de3f10c7b9f58a35d9a59883369e62 Mon Sep 17 00:00:00 2001 From: Cristian Luis Duarte Date: Fri, 23 Mar 2018 18:59:55 -0300 Subject: [PATCH 09/15] Android - Use mouse events for interacting with UI. Now LoginDialog UI interation does not move radar camera. Remove repeated tooggle call in audio.js. Adapt button to simulated mouse events. --- .../resources/qml/hifi/+android/button.qml | 4 +- libraries/qml/src/qml/OffscreenSurface.cpp | 37 +++++++++++++------ scripts/system/+android/audio.js | 1 - 3 files changed, 28 insertions(+), 14 deletions(-) diff --git a/interface/resources/qml/hifi/+android/button.qml b/interface/resources/qml/hifi/+android/button.qml index 4822b6bf33..3e9ce39351 100644 --- a/interface/resources/qml/hifi/+android/button.qml +++ b/interface/resources/qml/hifi/+android/button.qml @@ -118,7 +118,7 @@ Item { tabletRoot.playButtonClickSound(); }*/ } - onEntered: { + onPressed: { button.isEntered = true; button.entered(); if (button.isActive) { @@ -127,7 +127,7 @@ Item { button.state = "hover state"; } } - onExited: { + onReleased: { button.isEntered = false; button.exited() if (button.isActive) { diff --git a/libraries/qml/src/qml/OffscreenSurface.cpp b/libraries/qml/src/qml/OffscreenSurface.cpp index 6580c5b1e8..ff36589b61 100644 --- a/libraries/qml/src/qml/OffscreenSurface.cpp +++ b/libraries/qml/src/qml/OffscreenSurface.cpp @@ -166,18 +166,33 @@ bool OffscreenSurface::eventFilter(QObject* originalDestination, QEvent* event) case QEvent::TouchUpdate: case QEvent::TouchEnd: { QTouchEvent *originalEvent = static_cast(event); - QTouchEvent fakeEvent(*originalEvent); - auto newTouchPoints = fakeEvent.touchPoints(); - for (size_t i = 0; i < newTouchPoints.size(); ++i) { - const auto &originalPoint = originalEvent->touchPoints()[i]; - auto &newPoint = newTouchPoints[i]; - newPoint.setPos(originalPoint.pos()); + QEvent::Type fakeMouseEventType = QEvent::None; + Qt::MouseButton fakeMouseButton = Qt::NoButton; + Qt::MouseButtons fakeMouseButtons = Qt::NoButton; + switch (event->type()) { + case QEvent::TouchBegin: + fakeMouseEventType = QEvent::MouseButtonPress; + fakeMouseButton = Qt::LeftButton; + fakeMouseButtons = Qt::LeftButton; + break; + case QEvent::TouchUpdate: + fakeMouseEventType = QEvent::MouseMove; + fakeMouseButton = Qt::LeftButton; + fakeMouseButtons = Qt::LeftButton; + break; + case QEvent::TouchEnd: + fakeMouseEventType = QEvent::MouseButtonRelease; + fakeMouseButton = Qt::LeftButton; + fakeMouseButtons = Qt::NoButton; + break; } - fakeEvent.setTouchPoints(newTouchPoints); - if (QCoreApplication::sendEvent(_sharedObject->getWindow(), &fakeEvent)) { - qInfo() << __FUNCTION__ << "sent fake touch event:" << fakeEvent.type() - << "_quickWindow handled it... accepted:" << fakeEvent.isAccepted(); - return false; //event->isAccepted(); + if (fakeMouseEventType == QEvent::None) break; + QMouseEvent fakeMouseEvent(fakeMouseEventType, originalEvent->touchPoints()[0].pos(), fakeMouseButton, fakeMouseButtons, Qt::NoModifier); + fakeMouseEvent.ignore(); + if (QCoreApplication::sendEvent(_sharedObject->getWindow(), &fakeMouseEvent)) { + qInfo() << __FUNCTION__ << "sent fake touch event:" << fakeMouseEvent.type() + << "_quickWindow handled it... accepted:" << fakeMouseEvent.isAccepted(); + return fakeMouseEvent.isAccepted(); } break; } diff --git a/scripts/system/+android/audio.js b/scripts/system/+android/audio.js index b4f156d4bf..955f74d63a 100644 --- a/scripts/system/+android/audio.js +++ b/scripts/system/+android/audio.js @@ -46,7 +46,6 @@ function onMuteClicked() { printd("On Mute Clicked"); //Menu.setIsOptionChecked("Mute Microphone", !Menu.isOptionChecked("Mute Microphone")); Audio.muted = !Audio.muted; - onMuteToggled(); } function onMuteToggled() { From 686af4ff777e1fa04a226105b2a6078d0877963e Mon Sep 17 00:00:00 2001 From: Cristian Luis Duarte Date: Fri, 23 Mar 2018 20:02:51 -0300 Subject: [PATCH 10/15] Clean code that manually checked for windows coordinates to disable radar touch --- .../qml/+android/AddressBarDialog.qml | 4 ++ .../qml/hifi/+android/avatarSelection.qml | 4 ++ scripts/+android/defaultScripts.js | 5 +-- scripts/system/+android/androidCombined.js | 24 ----------- scripts/system/+android/bottombar.js | 38 +---------------- scripts/system/+android/modes.js | 42 ------------------- scripts/system/+android/radar.js | 6 ++- 7 files changed, 16 insertions(+), 107 deletions(-) delete mode 100644 scripts/system/+android/androidCombined.js diff --git a/interface/resources/qml/+android/AddressBarDialog.qml b/interface/resources/qml/+android/AddressBarDialog.qml index b8d6b5e270..4477d512fc 100644 --- a/interface/resources/qml/+android/AddressBarDialog.qml +++ b/interface/resources/qml/+android/AddressBarDialog.qml @@ -67,6 +67,10 @@ Item { fill: parent } + MouseArea { + anchors.fill: parent + } + QmlHifi.WindowHeader { id: header iconSource: "../../../icons/goto-i.svg" diff --git a/interface/resources/qml/hifi/+android/avatarSelection.qml b/interface/resources/qml/hifi/+android/avatarSelection.qml index 3090204308..afa5634575 100644 --- a/interface/resources/qml/hifi/+android/avatarSelection.qml +++ b/interface/resources/qml/hifi/+android/avatarSelection.qml @@ -58,6 +58,10 @@ Item { width: parent ? parent.width : 0 height: parent ? parent.height : 0 + MouseArea { + anchors.fill: parent + } + gradient: Gradient { GradientStop { position: 0.0; color: android.color.gradientTop } GradientStop { position: 1.0; color: android.color.gradientBottom } diff --git a/scripts/+android/defaultScripts.js b/scripts/+android/defaultScripts.js index 82e32a6d00..9094952e62 100644 --- a/scripts/+android/defaultScripts.js +++ b/scripts/+android/defaultScripts.js @@ -14,10 +14,9 @@ var DEFAULT_SCRIPTS_COMBINED = [ "system/progress.js", "system/+android/touchscreenvirtualpad.js", - "system/+android/audio.js", - "system/+android/androidCombined.js"/*, "system/+android/bottombar.js", - "system/+android/modes.js", + "system/+android/audio.js", + "system/+android/modes.js"/*, "system/away.js", "system/controllers/controllerDisplayManager.js", "system/controllers/handControllerGrabAndroid.js", diff --git a/scripts/system/+android/androidCombined.js b/scripts/system/+android/androidCombined.js deleted file mode 100644 index 76a52bcab7..0000000000 --- a/scripts/system/+android/androidCombined.js +++ /dev/null @@ -1,24 +0,0 @@ -"use strict"; -// -// androidCombined.js -// scripts/system/ -// -// Created by Gabriel Calero & Cristian Duarte on Mar 20, 2018 -// Copyright 2018 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 -// - -(function() { // BEGIN LOCAL_SCOPE - -var modesInterface = Script.require('./modes.js'); -var bottombarInterface = Script.require('./bottombar.js'); - -function init() { - modesInterface.isRadarModeValidTouch = bottombarInterface.isRadarModeValidTouch;// set new function -} - -init(); - -}()); // END LOCAL_SCOPE \ No newline at end of file diff --git a/scripts/system/+android/bottombar.js b/scripts/system/+android/bottombar.js index 2fb332a33d..3435edb548 100644 --- a/scripts/system/+android/bottombar.js +++ b/scripts/system/+android/bottombar.js @@ -21,9 +21,7 @@ var loginBtn; var gotoScript = Script.require('./goto.js'); var avatarSelection = Script.require('./avatarSelection.js'); -var bottombarInterface = []; - -var logEnabled = true; +var logEnabled = false; function printd(str) { if (logEnabled) { @@ -264,40 +262,6 @@ Script.scriptEnding.connect(function () { GlobalServices.disconnected.disconnect(handleLogout); }); -function isRadarModeValidTouch(coords) { - var qmlFragments = [bottombar, bottomHudOptionsBar.qmlFragment]; - var windows = [gotoScript, avatarSelection]; - for (var i=0; i < qmlFragments.length; i++) { - var aQmlFrag = qmlFragments[i]; - if (aQmlFrag != null && aQmlFrag.isVisible() && - coords.x >= aQmlFrag.position.x && coords.x <= aQmlFrag.position.x + aQmlFrag.size.x && - coords.y >= aQmlFrag.position.y && coords.y <= aQmlFrag.position.y + aQmlFrag.size.y - ) { - printd("isRadarModeValidTouch- false because of qmlFragments!? idx " + i); - return false; - } - } - - for (var i=0; i < windows.length; i++) { - var aWin = windows[i]; - if (aWin != null && aWin.position() != null && aWin.isVisible() && - coords.x >= aWin.position().x && coords.x <= aWin.position().x + aWin.width() && - coords.y >= aWin.position().y && coords.y <= aWin.position().y + aWin.height() - ) { - printd("isRadarModeValidTouch- false because of windows!? idx " + i); - return false; - } else { - printd("isRadarModeValidTouch- discarded of window idx " + i + " visible= " + aWin.isVisible()); - } - } - printd("isRadarModeValidTouch- true by default "); - return true; -} - -bottombarInterface.isRadarModeValidTouch = isRadarModeValidTouch; - -module.exports = bottombarInterface; - init(); }()); // END LOCAL_SCOPE diff --git a/scripts/system/+android/modes.js b/scripts/system/+android/modes.js index 4bc4333a09..c41ae1f327 100644 --- a/scripts/system/+android/modes.js +++ b/scripts/system/+android/modes.js @@ -23,8 +23,6 @@ var logEnabled = true; var radar = Script.require('./radar.js'); var uniqueColor = Script.require('./uniqueColor.js'); -var modesInterface = {}; - function printd(str) { if (logEnabled) { print("[modes.js] " + str); @@ -35,7 +33,6 @@ function init() { radar.setUniqueColor(uniqueColor); radar.init(); setupModesBar(); - radar.isTouchValid = isRadarModeValidTouch; } function shutdown() { @@ -185,45 +182,6 @@ function onButtonClicked(clickedButton, whatToDo, hideAllAfter) { } } -function isRadarModeValidTouch(coords) { - if (!modesInterface.isRadarModeValidTouch(coords)) { - printd("isRadarModeValidTouch- false because of modesInterface"); - return false; - } - printd("isRadarModeValidTouch- modesInterface is true, evaluating modesbar qmls.."); - - var qmlFragments = [modesbar.qmlFragment]; - var windows = []; - for (var i=0; i < qmlFragments.length; i++) { - var aQmlFrag = qmlFragments[i]; - if (aQmlFrag != null && aQmlFrag.isVisible() && - coords.x >= aQmlFrag.position.x && coords.x <= aQmlFrag.position.x + aQmlFrag.size.x && - coords.y >= aQmlFrag.position.y && coords.y <= aQmlFrag.position.y + aQmlFrag.size.y - ) { - printd("isRadarModeValidTouch- false because of qmlFragments!? idx " + i); - return false; - } - } - - for (var i=0; i < windows.length; i++) { - var aWin = windows[i]; - if (aWin != null && aWin.position() != null && aWin.isVisible() && - coords.x >= aWin.position().x && coords.x <= aWin.position().x + aWin.width() && - coords.y >= aWin.position().y && coords.y <= aWin.position().y + aWin.height() - ) { - printd("isRadarModeValidTouch- false because of windows!? idx " + i); - return false; - } - } - printd("isRadarModeValidTouch- true by default "); - return true; -} - -// default -modesInterface.isRadarModeValidTouch = function(coords) {return true;}; - -module.exports = modesInterface; - Script.scriptEnding.connect(function () { shutdown(); }); diff --git a/scripts/system/+android/radar.js b/scripts/system/+android/radar.js index 84fb66403f..2bcdc60db7 100644 --- a/scripts/system/+android/radar.js +++ b/scripts/system/+android/radar.js @@ -13,7 +13,7 @@ var radarModeInterface = {}; -var logEnabled = true; +var logEnabled = false; function printd(str) { if (logEnabled) { print("[radar.js] " + str); @@ -1390,6 +1390,10 @@ radarModeInterface.setUniqueColor = function(c) { uniqueColor = c; }; +radarModeInterface.isTouchValid = function(coords) { + return true; // by default +} + module.exports = radarModeInterface; function updateRadar() { From 4f7d856a1c0ac7849542e03065f26740c6f6d09e Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Tue, 27 Mar 2018 09:28:55 -0700 Subject: [PATCH 11/15] don't free dialogs to avoid crash in setKeyboardRaised --- interface/resources/qml/dialogs/CustomQueryDialog.qml | 8 ++++++-- interface/resources/qml/dialogs/QueryDialog.qml | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/interface/resources/qml/dialogs/CustomQueryDialog.qml b/interface/resources/qml/dialogs/CustomQueryDialog.qml index 4d6fe74bca..6e1bb4b309 100644 --- a/interface/resources/qml/dialogs/CustomQueryDialog.qml +++ b/interface/resources/qml/dialogs/CustomQueryDialog.qml @@ -270,7 +270,9 @@ ModalWindow { onTriggered: { root.result = null; root.canceled(); - root.destroy(); + // FIXME we are leaking memory to avoid a crash + // root.destroy(); + visible = false; } } @@ -292,7 +294,9 @@ ModalWindow { } root.result = JSON.stringify(result); root.selected(root.result); - root.destroy(); + // FIXME we are leaking memory to avoid a crash + // root.destroy(); + visible = false; } } } diff --git a/interface/resources/qml/dialogs/QueryDialog.qml b/interface/resources/qml/dialogs/QueryDialog.qml index b5de5362f2..6f05179bd5 100644 --- a/interface/resources/qml/dialogs/QueryDialog.qml +++ b/interface/resources/qml/dialogs/QueryDialog.qml @@ -169,7 +169,9 @@ ModalWindow { shortcut: Qt.Key_Escape onTriggered: { root.canceled(); - root.destroy(); + // FIXME we are leaking memory to avoid a crash + // root.destroy(); + visible = false; } } Action { @@ -179,7 +181,9 @@ ModalWindow { onTriggered: { root.result = items ? comboBox.currentText : textResult.text root.selected(root.result); - root.destroy(); + // FIXME we are leaking memory to avoid a crash + // root.destroy(); + visible = false; } } } From ad9ca0da204e09e4676952f42192f9d07607416c Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Tue, 27 Mar 2018 16:03:06 -0700 Subject: [PATCH 12/15] fix tablet version --- .../qml/hifi/dialogs/TabletAssetServer.qml | 60 ++++++++++--------- 1 file changed, 32 insertions(+), 28 deletions(-) diff --git a/interface/resources/qml/hifi/dialogs/TabletAssetServer.qml b/interface/resources/qml/hifi/dialogs/TabletAssetServer.qml index a85e5d4498..138eb5c6f8 100644 --- a/interface/resources/qml/hifi/dialogs/TabletAssetServer.qml +++ b/interface/resources/qml/hifi/dialogs/TabletAssetServer.qml @@ -58,7 +58,7 @@ Rectangle { Component.onDestruction: { assetMappingsModel.autoRefreshEnabled = false; } - + function letterbox(headerGlyph, headerText, message) { letterboxMessage.headerGlyph = headerGlyph; letterboxMessage.headerText = headerText; @@ -66,7 +66,7 @@ Rectangle { letterboxMessage.visible = true; letterboxMessage.popupRadius = 0; } - + function errorMessageBox(message) { return tabletRoot.messageBox({ icon: hifi.icons.warning, @@ -145,7 +145,7 @@ Rectangle { function canAddToWorld(path) { var supportedExtensions = [/\.fbx\b/i, /\.obj\b/i, /\.jpg\b/i, /\.png\b/i]; - + if (selectedItemCount > 1) { return false; } @@ -154,8 +154,8 @@ Rectangle { return total | new RegExp(current).test(path); }, false); } - - function canRename() { + + function canRename() { if (treeView.selection.hasSelection && selectedItemCount == 1) { return true; } else { @@ -199,7 +199,7 @@ Rectangle { var SHAPE_TYPE_STATIC_MESH = 3; var SHAPE_TYPE_BOX = 4; var SHAPE_TYPE_SPHERE = 5; - + var SHAPE_TYPES = []; SHAPE_TYPES[SHAPE_TYPE_NONE] = "No Collision"; SHAPE_TYPES[SHAPE_TYPE_SIMPLE_HULL] = "Basic - Whole model"; @@ -207,7 +207,7 @@ Rectangle { SHAPE_TYPES[SHAPE_TYPE_STATIC_MESH] = "Exact - All polygons"; SHAPE_TYPES[SHAPE_TYPE_BOX] = "Box"; SHAPE_TYPES[SHAPE_TYPE_SPHERE] = "Sphere"; - + var SHAPE_TYPE_DEFAULT = SHAPE_TYPE_SIMPLE_COMPOUND; var DYNAMIC_DEFAULT = false; var prompt = tabletRoot.customInputDialog({ @@ -349,14 +349,14 @@ Rectangle { } function deleteFile(index) { var paths = []; - + if (!index) { for (var i = 0; i < selectedItemCount; ++i) { index = treeView.selection.selectedIndexes[i]; paths[i] = assetProxyModel.data(index, 0x100); } } - + if (!paths) { return; } @@ -365,7 +365,7 @@ Rectangle { var items = selectedItemCount.toString(); var isFolder = assetProxyModel.data(treeView.selection.currentIndex, 0x101); var typeString = isFolder ? 'folder' : 'file'; - + if (selectedItemCount > 1) { modalMessage = "You are about to delete " + items + " items \nDo you want to continue?"; } else { @@ -476,7 +476,7 @@ Rectangle { }); } } - + // The letterbox used for popup messages LetterboxMessage { id: letterboxMessage; @@ -540,7 +540,7 @@ Rectangle { anchors.margins: hifi.dimensions.contentMargin.x + 2 // Extra for border anchors.left: parent.left anchors.right: parent.right - + treeModel: assetProxyModel selectionMode: SelectionMode.ExtendedSelection headerVisible: true @@ -560,9 +560,13 @@ Rectangle { id: bakedColumn title: "Use Baked?" role: "baked" - width: 100 + width: 170 } - + + onSortIndicatorOrderChanged: { + Assets.sortProxyModel(sortIndicatorColumn, sortIndicatorOrder); + } + itemDelegate: Loader { id: itemDelegateLoader @@ -598,7 +602,7 @@ Rectangle { } sourceComponent: getComponent() - + Component { id: labelComponent FiraSansSemiBold { @@ -607,15 +611,15 @@ Rectangle { color: colorScheme == hifi.colorSchemes.light ? (styleData.selected ? hifi.colors.black : hifi.colors.baseGrayHighlight) : (styleData.selected ? hifi.colors.black : hifi.colors.lightGrayText) - + horizontalAlignment: styleData.column === 1 ? TextInput.AlignHCenter : TextInput.AlignLeft - + elide: Text.ElideMiddle MouseArea { id: mouseArea anchors.fill: parent - + acceptedButtons: Qt.NoButton hoverEnabled: true @@ -637,7 +641,7 @@ Rectangle { color: colorScheme == hifi.colorSchemes.light ? (styleData.selected ? hifi.colors.black : hifi.colors.baseGrayHighlight) : (styleData.selected ? hifi.colors.black : hifi.colors.lightGrayText) - + elide: Text.ElideRight horizontalAlignment: TextInput.AlignHCenter @@ -724,7 +728,7 @@ Rectangle { size: hifi.fontSizes.tableText color: colorScheme == hifi.colorSchemes.light ? hifi.colors.black : hifi.colors.lightGrayText } - + Timer { id: showTimer interval: 1000 @@ -743,7 +747,7 @@ Rectangle { treeLabelToolTip.visible = false; } }// End_OF( treeLabelToolTip ) - + MouseArea { propagateComposedEvents: true anchors.fill: parent @@ -801,7 +805,7 @@ Rectangle { anchors.left: treeView.left anchors.right: treeView.right anchors.bottomMargin: hifi.dimensions.contentSpacing.y - + RalewayRegular { anchors.verticalCenter: parent.verticalCenter @@ -845,7 +849,7 @@ Rectangle { checked = Qt.binding(isChecked); } - + function isEnabled() { if (!treeView.selection.hasSelection) { return false; @@ -869,7 +873,7 @@ Rectangle { } } - return true; + return true; } function isChecked() { if (!treeView.selection.hasSelection) { @@ -877,10 +881,10 @@ Rectangle { } var status = assetProxyModel.data(treeView.selection.currentIndex, 0x105); - return isEnabled() && status !== "Not Baked"; - } + return isEnabled() && status !== "Not Baked"; + } } - + Item { anchors.verticalCenter: parent.verticalCenter width: infoGlyph.size; @@ -904,7 +908,7 @@ Rectangle { "What is baking?", "Baking compresses and optimizes files for faster network transfer and display. We recommend you bake your content to reduce initial load times for your visitors."); } - } + } }// End_OF( infoRow ) HifiControls.TabletContentSection { From bb101956a69ad5186bb854741f3c081839d2a73e Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Tue, 27 Mar 2018 18:25:43 -0700 Subject: [PATCH 13/15] fix entity importing --- interface/src/Application.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 968af3e298..7e6c65f8f4 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -959,8 +959,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo setProperty(hifi::properties::STEAM, (steamClient && steamClient->isRunning())); setProperty(hifi::properties::CRASHED, _previousSessionCrashed); - _entityClipboard->setIsServerlessMode(true); - { const QString TEST_SCRIPT = "--testScript"; const QString TRACE_FILE = "--traceFile"; From 0172c24cf2f3a2557c56e0cef46cfc6157dc12fb Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Wed, 28 Mar 2018 14:47:09 -0700 Subject: [PATCH 14/15] fix cmake changes for script copy for dev builds --- interface/CMakeLists.txt | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt index e316556d29..fe00d86c3a 100644 --- a/interface/CMakeLists.txt +++ b/interface/CMakeLists.txt @@ -312,7 +312,7 @@ if (APPLE) COMPONENT ${CLIENT_COMPONENT} ) - set(RESOURCES_INSTALL_DIR "${INTERFACE_INSTALL_APP_PATH}/Contents/Resources") + set(SCRIPTS_INSTALL_DIR "${INTERFACE_INSTALL_APP_PATH}/Contents/Resources") set(RESOURCES_DEV_DIR "$/../Resources") # copy script files beside the executable @@ -326,13 +326,14 @@ if (APPLE) fixup_interface() else() - set(RESOURCES_DEV_DIR "$/resources") + set(INTERFACE_EXEC_DIR "$") + set(RESOURCES_DEV_DIR "${INTERFACE_EXEC_DIR}/resources") # copy the resources files beside the executable add_custom_command(TARGET ${TARGET_NAME} POST_BUILD COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${RESOURCES_RCC}" - "$" + "${INTERFACE_EXEC_DIR}" # FIXME, the edit script code loads HTML from the scripts folder # which in turn relies on CSS that refers to the fonts. In theory # we should be able to modify the CSS to reference the QRC path to @@ -340,13 +341,13 @@ else() # so we have to retain a copy of the fonts outside of the resources binary COMMAND "${CMAKE_COMMAND}" -E copy_directory "${PROJECT_SOURCE_DIR}/resources/fonts" - "$/resources/fonts" + "${RESOURCES_DEV_DIR}/fonts" COMMAND "${CMAKE_COMMAND}" -E copy_directory "${CMAKE_SOURCE_DIR}/scripts" - "${RESOURCES_DEV_DIR}/scripts" + "${INTERFACE_EXEC_DIR}/scripts" COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${PROJECT_SOURCE_DIR}/resources/serverless/tutorial.json" - "$/resources/serverless/tutorial.json" + "${RESOURCES_DEV_DIR}/serverless/tutorial.json" ) # link target to external libraries @@ -363,7 +364,7 @@ else() PATTERN "*.exp" EXCLUDE ) - set(RESOURCES_INSTALL_DIR "${INTERFACE_INSTALL_DIR}") + set(SCRIPTS_INSTALL_DIR "${INTERFACE_INSTALL_DIR}") set(EXECUTABLE_COMPONENT ${CLIENT_COMPONENT}) @@ -371,11 +372,11 @@ else() endif() endif() -if (RESOURCES_INSTALL_DIR) +if (SCRIPTS_INSTALL_DIR) # setup install of scripts beside interface executable install( DIRECTORY "${CMAKE_SOURCE_DIR}/scripts/" - DESTINATION ${RESOURCES_INSTALL_DIR}/scripts + DESTINATION ${SCRIPTS_INSTALL_DIR}/scripts COMPONENT ${CLIENT_COMPONENT} ) endif() From fe9481b28d9b7c936e1fa23ea05153e52f617084 Mon Sep 17 00:00:00 2001 From: Cristian Luis Duarte Date: Wed, 28 Mar 2018 19:50:44 -0300 Subject: [PATCH 15/15] Cleanup code, comment out log, simplify radar is valid touch code (no more flag) --- libraries/qml/src/qml/OffscreenSurface.cpp | 11 ++--- scripts/system/+android/radar.js | 51 +--------------------- 2 files changed, 6 insertions(+), 56 deletions(-) diff --git a/libraries/qml/src/qml/OffscreenSurface.cpp b/libraries/qml/src/qml/OffscreenSurface.cpp index ff36589b61..9c1bb79355 100644 --- a/libraries/qml/src/qml/OffscreenSurface.cpp +++ b/libraries/qml/src/qml/OffscreenSurface.cpp @@ -167,31 +167,28 @@ bool OffscreenSurface::eventFilter(QObject* originalDestination, QEvent* event) case QEvent::TouchEnd: { QTouchEvent *originalEvent = static_cast(event); QEvent::Type fakeMouseEventType = QEvent::None; - Qt::MouseButton fakeMouseButton = Qt::NoButton; + Qt::MouseButton fakeMouseButton = Qt::LeftButton; Qt::MouseButtons fakeMouseButtons = Qt::NoButton; switch (event->type()) { case QEvent::TouchBegin: fakeMouseEventType = QEvent::MouseButtonPress; - fakeMouseButton = Qt::LeftButton; fakeMouseButtons = Qt::LeftButton; break; case QEvent::TouchUpdate: fakeMouseEventType = QEvent::MouseMove; - fakeMouseButton = Qt::LeftButton; fakeMouseButtons = Qt::LeftButton; break; case QEvent::TouchEnd: fakeMouseEventType = QEvent::MouseButtonRelease; - fakeMouseButton = Qt::LeftButton; fakeMouseButtons = Qt::NoButton; break; } - if (fakeMouseEventType == QEvent::None) break; + // Same case as OffscreenUi.cpp::eventFilter: touch events are always being accepted so we now use mouse events and consider one touch, touchPoints()[0]. QMouseEvent fakeMouseEvent(fakeMouseEventType, originalEvent->touchPoints()[0].pos(), fakeMouseButton, fakeMouseButtons, Qt::NoModifier); fakeMouseEvent.ignore(); if (QCoreApplication::sendEvent(_sharedObject->getWindow(), &fakeMouseEvent)) { - qInfo() << __FUNCTION__ << "sent fake touch event:" << fakeMouseEvent.type() - << "_quickWindow handled it... accepted:" << fakeMouseEvent.isAccepted(); + /*qInfo() << __FUNCTION__ << "sent fake touch event:" << fakeMouseEvent.type() + << "_quickWindow handled it... accepted:" << fakeMouseEvent.isAccepted();*/ return fakeMouseEvent.isAccepted(); } break; diff --git a/scripts/system/+android/radar.js b/scripts/system/+android/radar.js index 2bcdc60db7..455299dd5f 100644 --- a/scripts/system/+android/radar.js +++ b/scripts/system/+android/radar.js @@ -118,19 +118,10 @@ function actionOnObjectFromEvent(event) { } function mousePress(event) { - if (!isTouchValid(coords)) { - currentTouchIsValid = false; - return; - } else { - currentTouchIsValid = true; - } mousePressOrTouchEnd(event); } function mousePressOrTouchEnd(event) { - if (!currentTouchIsValid) { - return; - } if (radar) { if (actionOnObjectFromEvent(event)) { return; @@ -155,9 +146,6 @@ function fakeDoubleTap(event) { teleporter.dragTeleportRelease(event); } -var currentTouchIsValid = false; // Currently used to know if touch hasn't - // started on a UI overlay - var DOUBLE_TAP_TIME = 300; var fakeDoubleTapStart = Date.now(); var touchEndCount = 0; @@ -238,12 +226,6 @@ function touchEnd(event) { return; } - // if touch is invalid, cancel - if (!currentTouchIsValid) { - printd("touchEnd fail because !currentTouchIsValid"); - return; - } - if (analyzeDoubleTap(event)) return; // double tap detected, finish @@ -345,20 +327,6 @@ function computePointAtPlaneY(x, y, py) { p2.z, py); } -/******************************************************************************* - * - ******************************************************************************/ - -function isTouchValid(coords) { - // TODO: Extend to the detection of touches on new menu bars - var radarModeTouchValid = radarModeInterface.isTouchValid(coords); - - // getItemAtPoint does not exist anymore, look for another way to know if we - // are touching buttons - // is it still needed? - return /* !tablet.getItemAtPoint(coords) && */radarModeTouchValid; -} - /******************************************************************************* * ******************************************************************************/ @@ -373,16 +341,8 @@ function touchBegin(event) { x : event.x, y : event.y }; - if (!isTouchValid(coords)) { - printd("analyze touch - RADAR_TOUCH - INVALID"); - currentTouchIsValid = false; - touchStartingCoordinates = null; - } else { - printd("analyze touch - RADAR_TOUCH - ok"); - currentTouchIsValid = true; - touchStartingCoordinates = coords; - touchBeginTime = Date.now(); - } + touchStartingCoordinates = coords; + touchBeginTime = Date.now(); } var startedDraggingCamera = false; // first time @@ -848,9 +808,6 @@ function oneFingerTouchUpdate(event) { } function touchUpdate(event) { - if (!currentTouchIsValid) { - return; // avoid moving and zooming when tap is over UI entities - } if (event.isPinching || event.isPinchOpening) { pinchUpdate(event); } else { @@ -1390,10 +1347,6 @@ radarModeInterface.setUniqueColor = function(c) { uniqueColor = c; }; -radarModeInterface.isTouchValid = function(coords) { - return true; // by default -} - module.exports = radarModeInterface; function updateRadar() {