From a16b229c6552c80523dd08142174a5b4c0c0d5c7 Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Thu, 12 Jan 2017 18:48:19 +0000 Subject: [PATCH 1/3] begining to remove hud items --- scripts/system/help.js | 2 +- scripts/system/libraries/WebTablet.js | 12 +-- scripts/system/marketplaces/marketplaces.js | 104 ++++---------------- scripts/system/pal.js | 17 ++-- 4 files changed, 31 insertions(+), 104 deletions(-) diff --git a/scripts/system/help.js b/scripts/system/help.js index 663d2edf56..23a162d767 100644 --- a/scripts/system/help.js +++ b/scripts/system/help.js @@ -38,7 +38,7 @@ defaultTab = "gamepad"; } var queryParameters = "handControllerName=" + handControllerName + "&defaultTab=" + defaultTab; - tablet.gotoWebScreen(HELP_URL + "?" + queryParameters); + Menu.triggerOption('Help...'); } button.clicked.connect(onClicked); diff --git a/scripts/system/libraries/WebTablet.js b/scripts/system/libraries/WebTablet.js index 493ed07944..4d759e9730 100644 --- a/scripts/system/libraries/WebTablet.js +++ b/scripts/system/libraries/WebTablet.js @@ -23,6 +23,7 @@ var CAMERA_MATRIX = -7; var ROT_Y_180 = {x: 0, y: 1, z: 0, w: 0}; var TABLET_URL = "http://hifi-content.s3.amazonaws.com/alan/dev/Tablet-Model-v1-x.fbx"; +var HOME_BUTTON_URL = "http://hifi-content.s3.amazonaws.com/alan/dev/tablet-home-button.fbx"; // returns object with two fields: // * position - position in front of the user // * rotation - rotation of entity so it faces the user. @@ -98,10 +99,10 @@ WebTablet = function (url, width, dpi, hand, clientOnly) { var HOME_BUTTON_Y_OFFSET = -0.25; this.homeButtonEntity = Entities.addEntity({ name: "homeButton", - type: "Sphere", + type: "Model", + modelURL: HOME_BUTTON_URL, collisionless: true, localPosition: {x: 0, y: HOME_BUTTON_Y_OFFSET, z: 0}, - dimensions: {x: 0.05, y: 0.05, z: 0.05}, parentID: this.tabletEntityID, script: Script.resolvePath("../tablet-ui/HomeButton.js") }, clientOnly); @@ -110,13 +111,6 @@ WebTablet = function (url, width, dpi, hand, clientOnly) { this.receive = function (channel, senderID, senderUUID, localOnly) { if (_this.homeButtonEntity == senderID) { - if (_this.clicked) { - Entities.editEntity(_this.homeButtonEntity, {color: {red: 0, green: 255, blue: 255}}); - _this.clicked = false; - } else { - Entities.editEntity(_this.homeButtonEntity, {color: {red: 255, green: 255, blue: 0}}); - _this.clicked = true; - } var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system"); tablet.gotoHomeScreen(); } diff --git a/scripts/system/marketplaces/marketplaces.js b/scripts/system/marketplaces/marketplaces.js index c173683c74..c07e799dcf 100644 --- a/scripts/system/marketplaces/marketplaces.js +++ b/scripts/system/marketplaces/marketplaces.js @@ -58,94 +58,37 @@ var marketplaceWebTablet; // To keep things consistent, we pickle the tablet data in Settings, and kill any existing such on restart and domain change. var persistenceKey = "io.highfidelity.lastDomainTablet"; -function shouldShowWebTablet() { - var rightPose = Controller.getPoseValue(Controller.Standard.RightHand); - var leftPose = Controller.getPoseValue(Controller.Standard.LeftHand); - var hasHydra = !!Controller.Hardware.Hydra; - return HMD.active && (leftPose.valid || rightPose.valid || hasHydra); -} - function showMarketplace() { - if (shouldShowWebTablet()) { - updateButtonState(true); - marketplaceWebTablet = new WebTablet(MARKETPLACE_URL_INITIAL, null, null, true); - Settings.setValue(persistenceKey, marketplaceWebTablet.pickle()); - marketplaceWebTablet.setScriptURL(MARKETPLACES_INJECT_SCRIPT_URL); - marketplaceWebTablet.getOverlayObject().webEventReceived.connect(function (message) { - if (message === GOTO_DIRECTORY) { - marketplaceWebTablet.setURL(MARKETPLACES_URL); - } - if (message === QUERY_CAN_WRITE_ASSETS) { - marketplaceWebTablet.getOverlayObject().emitScriptEvent(CAN_WRITE_ASSETS + " " + Entities.canWriteAssets()); - } - if (message === WARN_USER_NO_PERMISSIONS) { - Window.alert(NO_PERMISSIONS_ERROR_MESSAGE); - } - }); - } else { - marketplaceWindow.setURL(MARKETPLACE_URL_INITIAL); - marketplaceWindow.setVisible(true); - } + tablet.gotoWebScreen(MARKETPLACE_URL_INITIAL); + tablet.setScriptURL(MARKETPLACES_INJECT_SCRIPT_URL); + tablet.webEventRecieved(function (message) { + if (message === GOTO_DIRECTORY) { + tablet.gotoWebScreen(MATKETPLACES_URL); + } - marketplaceVisible = true; + if (message === QUERY_CAN_WRITE_ASSESTS) { + tablet.emitScriptEvent(CAN_WRITE_ASSETS + " " + Entities.canWriteAssets()); + } + + if (message === WARN_USER_NO_PERMISSIONS) { + Window.alert(NO_PERMISSIONS_ERROR_MESSAGE); + } + + }); UserActivityLogger.openedMarketplace(); } -function hideTablet(tablet) { - if (!tablet) { - return; - } - updateButtonState(false); - tablet.destroy(); - marketplaceWebTablet = null; - Settings.setValue(persistenceKey, ""); -} -function clearOldTablet() { // If there was a tablet from previous domain or session, kill it and let it be recreated - var tablet = WebTablet.unpickle(Settings.getValue(persistenceKey, "")); - hideTablet(tablet); -} -function hideMarketplace() { - if (marketplaceWindow.visible) { - marketplaceWindow.setVisible(false); - marketplaceWindow.setURL("about:blank"); - } else if (marketplaceWebTablet) { - hideTablet(marketplaceWebTablet); - } - marketplaceVisible = false; -} -marketplaceWindow.closed.connect(function () { - marketplaceWindow.setURL("about:blank"); -}); - function toggleMarketplace() { - if (marketplaceVisible) { - hideMarketplace(); - } else { - showMarketplace(); - } + showMarketplace(); } -var toolBar = Toolbars.getToolbar("com.highfidelity.interface.toolbar.system"); +var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system"); -var browseExamplesButton = toolBar.addButton({ - imageURL: toolIconUrl + "market.svg", - objectName: "marketplace", - buttonState: 1, - defaultState: 1, - hoverState: 3, - alpha: 0.9 +var browseExamplesButton = tablet.addButton({ + icon: "icons/tablet-icons/market-i.svg", + text: "MARKETPLACE" }); -function updateButtonState(visible) { - browseExamplesButton.writeProperty('buttonState', visible ? 0 : 1); - browseExamplesButton.writeProperty('defaultState', visible ? 0 : 1); - browseExamplesButton.writeProperty('hoverState', visible ? 2 : 3); -} -function onMarketplaceWindowVisibilityChanged() { - updateButtonState(marketplaceWindow.visible); - marketplaceVisible = marketplaceWindow.visible; -} - function onCanWriteAssetsChanged() { var message = CAN_WRITE_ASSETS + " " + Entities.canWriteAssets(); if (marketplaceWindow.visible) { @@ -161,16 +104,11 @@ function onClick() { } browseExamplesButton.clicked.connect(onClick); -marketplaceWindow.visibleChanged.connect(onMarketplaceWindowVisibilityChanged); Entities.canWriteAssetsChanged.connect(onCanWriteAssetsChanged); -clearOldTablet(); // Run once at startup, in case there's anything laying around from a crash. -// We could also optionally do something like Window.domainChanged.connect(function () {Script.setTimeout(clearOldTablet, 2000)}), -// but the HUD version stays around, so lets do the same. - Script.scriptEnding.connect(function () { - toolBar.removeButton("marketplace"); browseExamplesButton.clicked.disconnect(onClick); + tablet.removeButton(browseExamplesButton); marketplaceWindow.visibleChanged.disconnect(onMarketplaceWindowVisibilityChanged); Entities.canWriteAssetsChanged.disconnect(onCanWriteAssetsChanged); }); diff --git a/scripts/system/pal.js b/scripts/system/pal.js index f83b2b6796..2e6c179f95 100644 --- a/scripts/system/pal.js +++ b/scripts/system/pal.js @@ -361,16 +361,11 @@ triggerMapping.from(Controller.Standard.LTClick).peek().to(makeClickHandler(Cont // // Manage the connection between the button and the window. // -var toolBar = Toolbars.getToolbar("com.highfidelity.interface.toolbar.system"); -var buttonName = "pal"; -var button = toolBar.addButton({ - objectName: buttonName, - imageURL: Script.resolvePath("assets/images/tools/people.svg"), - visible: true, - hoverState: 2, - defaultState: 1, - buttonState: 1, - alpha: 0.9 +var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system"); +var buttonName = "PAL"; +var button = tablet.addButton({ + text: buttonName, + icon: "icons/tablet-icons/people-i.svg" }); var isWired = false; function off() { @@ -502,7 +497,7 @@ Window.domainConnectionRefused.connect(clearIgnoredInQMLAndClosePAL); // Script.scriptEnding.connect(function () { button.clicked.disconnect(onClicked); - toolBar.removeButton(buttonName); + tablet.removeButton(buttonName); pal.visibleChanged.disconnect(onVisibleChanged); pal.closed.disconnect(off); Users.usernameFromIDReply.disconnect(usernameFromIDReply); From 71083645e9b791a00a4ae521015d091ab4ed41dd Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Thu, 12 Jan 2017 20:51:25 +0000 Subject: [PATCH 2/3] branch update --- scripts/system/libraries/WebTablet.js | 2 +- scripts/system/marketplaces/marketplaces.js | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/scripts/system/libraries/WebTablet.js b/scripts/system/libraries/WebTablet.js index 4d759e9730..ebd30a9c6f 100644 --- a/scripts/system/libraries/WebTablet.js +++ b/scripts/system/libraries/WebTablet.js @@ -102,7 +102,7 @@ WebTablet = function (url, width, dpi, hand, clientOnly) { type: "Model", modelURL: HOME_BUTTON_URL, collisionless: true, - localPosition: {x: 0, y: HOME_BUTTON_Y_OFFSET, z: 0}, + localPosition: {x: 0, y: HOME_BUTTON_Y_OFFSET, z: -0.01}, parentID: this.tabletEntityID, script: Script.resolvePath("../tablet-ui/HomeButton.js") }, clientOnly); diff --git a/scripts/system/marketplaces/marketplaces.js b/scripts/system/marketplaces/marketplaces.js index c07e799dcf..cfd2bb1f30 100644 --- a/scripts/system/marketplaces/marketplaces.js +++ b/scripts/system/marketplaces/marketplaces.js @@ -60,8 +60,11 @@ var persistenceKey = "io.highfidelity.lastDomainTablet"; function showMarketplace() { tablet.gotoWebScreen(MARKETPLACE_URL_INITIAL); - tablet.setScriptURL(MARKETPLACES_INJECT_SCRIPT_URL); - tablet.webEventRecieved(function (message) { + UserActivityLogger.openedMarketplace(); + + // FIXME - the code to support the following is not yet implented + /*tablet.setScriptURL(MARKETPLACES_INJECT_SCRIPT_URL); + tablet.webEventRecieved.connect(function (message) { if (message === GOTO_DIRECTORY) { tablet.gotoWebScreen(MATKETPLACES_URL); } @@ -74,8 +77,7 @@ function showMarketplace() { Window.alert(NO_PERMISSIONS_ERROR_MESSAGE); } - }); - UserActivityLogger.openedMarketplace(); + });*/ } function toggleMarketplace() { @@ -86,7 +88,7 @@ var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system"); var browseExamplesButton = tablet.addButton({ icon: "icons/tablet-icons/market-i.svg", - text: "MARKETPLACE" + text: "MARKET" }); function onCanWriteAssetsChanged() { From 784548bb255f67dd307e54acd2ab8366c53585e5 Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Thu, 12 Jan 2017 22:07:20 +0000 Subject: [PATCH 3/3] removed hud --- interface/resources/qml/hifi/Desktop.qml | 31 +----------------------- 1 file changed, 1 insertion(+), 30 deletions(-) diff --git a/interface/resources/qml/hifi/Desktop.qml b/interface/resources/qml/hifi/Desktop.qml index e20ecd70e1..4c81027211 100644 --- a/interface/resources/qml/hifi/Desktop.qml +++ b/interface/resources/qml/hifi/Desktop.qml @@ -48,14 +48,7 @@ OriginalDesktop.Desktop { // This used to create sysToolbar dynamically with a call to getToolbar() within onCompleted. // Beginning with QT 5.6, this stopped working, as anything added to toolbars too early got // wiped during startup. - Toolbar { - id: sysToolbar; - objectName: "com.highfidelity.interface.toolbar.system"; - anchors.horizontalCenter: settings.constrainToolbarToCenterX ? desktop.horizontalCenter : undefined; - // Literal 50 is overwritten by settings from previous session, and sysToolbar.x comes from settings when not constrained. - x: sysToolbar.x - y: 50 - } + Settings { id: settings; category: "toolbar"; @@ -65,7 +58,6 @@ OriginalDesktop.Desktop { settings.constrainToolbarToCenterX = constrain; } property var toolbars: (function (map) { // answer dictionary preloaded with sysToolbar - map[sysToolbar.objectName] = sysToolbar; return map; })({}); @@ -74,27 +66,6 @@ OriginalDesktop.Desktop { WebEngine.settings.javascriptCanAccessClipboard = false; WebEngine.settings.spatialNavigationEnabled = false; WebEngine.settings.localContentCanAccessRemoteUrls = true; - - [ // Allocate the standard buttons in the correct order. They will get images, etc., via scripts. - "hmdToggle", "mute", "pal", "bubble", "help", - "hudToggle", - "com.highfidelity.interface.system.editButton", "marketplace", "snapshot", "goto" - ].forEach(function (name) { - sysToolbar.addButton({objectName: name}); - }); - var toggleHudButton = sysToolbar.findButton("hudToggle"); - toggleHudButton.imageURL = "../../../icons/hud.svg"; - toggleHudButton.pinned = true; - sysToolbar.updatePinned(); // automatic when adding buttons only IFF button is pinned at creation. - - toggleHudButton.buttonState = Qt.binding(function(){ - return desktop.pinned ? 1 : 0 - }); - toggleHudButton.clicked.connect(function(){ - console.log("Clicked on hud button") - var overlayMenuItem = "Overlays" - MenuInterface.setIsOptionChecked(overlayMenuItem, !MenuInterface.isOptionChecked(overlayMenuItem)); - }); } // Accept a download through the webview